From 1e087b68e131885d71afe65d629209ba6fefe590 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 17 Apr 2019 16:29:48 +0200 Subject: [PATCH 001/299] New show html list instead input text for extrafields typed as list --- htdocs/core/tpl/extrafields_list_search_input.tpl.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/extrafields_list_search_input.tpl.php b/htdocs/core/tpl/extrafields_list_search_input.tpl.php index b4a98946f94..c0a7ecbb437 100644 --- a/htdocs/core/tpl/extrafields_list_search_input.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_input.tpl.php @@ -24,11 +24,11 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $typeofextrafield=$extrafields->attributes[$extrafieldsobjectkey]['type'][$key]; print ''; $tmpkey=preg_replace('/'.$search_options_pattern.'/', '', $key); - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) + if (in_array($typeofextrafield, array('varchar', 'int', 'double')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) { $crit=$val; $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('varchar'))) $searchclass='searchstring'; if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; print ''; } @@ -37,7 +37,9 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') $morecss=''; if ($typeofextrafield == 'sellist') $morecss='maxwidth200'; - echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $search_options_pattern, $morecss); + $keyprefix=$search_options_pattern; + if (substr($search_options_pattern, -8) === 'options_') $keyprefix = substr($search_options_pattern, 0,-8); + echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $keyprefix, $morecss); } elseif (in_array($typeofextrafield, array('datetime','timestamp'))) { From 4678373480056d5ebbc13622990d307d2ed5316a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 16:41:51 +0200 Subject: [PATCH 002/299] NEW print / send email form in takepos --- htdocs/takepos/invoice.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 17805a6b060..fab81c5f3c2 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -399,10 +399,12 @@ if ($action=="valid" || $action=="history") else $sectionwithinvoicelink.=$langs->trans('BillShortStatusValidated'); } $sectionwithinvoicelink.=''; + if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) { if ($conf->global->TAKEPOSCONNECTOR) $sectionwithinvoicelink.=' '; else $sectionwithinvoicelink.=' '; - if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink.=''; -} + $sectionwithinvoicelink.=' '; + $sectionwithinvoicelink.=''; + } else $sectionwithinvoicelink.=' ';} /* From cf1a029b436b4489884b51ac8f2dfc9a1d0c9029 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 16:46:04 +0200 Subject: [PATCH 003/299] Update invoice.php --- htdocs/takepos/invoice.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index fab81c5f3c2..5ab6ee4bfd4 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -404,8 +404,9 @@ if ($action=="valid" || $action=="history") else $sectionwithinvoicelink.=' '; $sectionwithinvoicelink.=' '; $sectionwithinvoicelink.=''; - } else $sectionwithinvoicelink.=' ';} - + } else { $sectionwithinvoicelink.=' '; + $sectionwithinvoicelink.=''; + } /* * View @@ -488,6 +489,12 @@ if ($action == "search") { ?> }); + +function PrintSend(id) +{ + console.log("Open box to select the Print/Send form"); + $.colorbox({href:"printsend.php?facid="+id, width:"90%", height:"80%", transition:"none", iframe:"true", title:"trans("PrintSend");?>"}); +} function Print(id){ $.colorbox({href:"receipt.php?facid="+id, width:"40%", height:"90%", transition:"none", iframe:"true", title:" Date: Sat, 24 Aug 2019 16:58:39 +0200 Subject: [PATCH 004/299] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 5ab6ee4bfd4..3f97f45d40c 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -493,7 +493,7 @@ if ($action == "search") { function PrintSend(id) { console.log("Open box to select the Print/Send form"); - $.colorbox({href:"printsend.php?facid="+id, width:"90%", height:"80%", transition:"none", iframe:"true", title:"trans("PrintSend");?>"}); + $.colorbox({href:"printsend.php?facid="+id, width:"90%", height:"50%", transition:"none", iframe:"true", title:"trans("PrintSend");?>"}); } function Print(id){ From bc93a8b4b1c2ccbe65e85872735a4b8ae8af6c55 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 17:18:43 +0200 Subject: [PATCH 005/299] Create printsend.php --- htdocs/takepos/printsend.php | 152 +++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 htdocs/takepos/printsend.php diff --git a/htdocs/takepos/printsend.php b/htdocs/takepos/printsend.php new file mode 100644 index 00000000000..3208721c95a --- /dev/null +++ b/htdocs/takepos/printsend.php @@ -0,0 +1,152 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/takepos/printsend.php + * \ingroup takepos + * \brief Page with the content of the popup to enter payments + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); + +require '../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + +$invoiceid = GETPOST('facid', 'int'); + +/* + * View + */ + +$invoice = new Facture($db); +if ($invoiceid > 0) +{ + $invoice->fetch($invoiceid); +} +else +{ + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $resql = $db->query($sql); + $obj = $db->fetch_object($resql); + if ($obj) + { + $invoiceid = $obj->rowid; + } + if (! $invoiceid) + { + $invoiceid=0; // Invoice does not exist yet + } + else + { + $invoice->fetch($invoiceid); + } +} + +top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + +$langs->loadLangs(array("main", "bills", "cashdesk")); + +?> + + + + + + +
+
+
+
+
+ +
+ + + + + +
+ + + From 3a4ba0c4018f2230967969d77a399faa6bdb09a5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 17:29:48 +0200 Subject: [PATCH 006/299] Update printsend.php --- htdocs/takepos/printsend.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/takepos/printsend.php b/htdocs/takepos/printsend.php index 3208721c95a..ff97c1cc51c 100644 --- a/htdocs/takepos/printsend.php +++ b/htdocs/takepos/printsend.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2019 Thibault FOUCART * * 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 @@ -131,6 +131,12 @@ else print "var received=0;"; } } } + +function Print(id){ + $.colorbox.close(); + $.colorbox({href:"receipt.php?facid="+id, width:"40%", height:"90%", transition:"none", iframe:"true", title:"trans("PrintTicket"); ?>"}); +} @@ -140,11 +146,11 @@ else print "var received=0;"; -
+
- - + +
From add28f10db02fc7065482839039180fdc2159b8a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 17:37:50 +0200 Subject: [PATCH 007/299] Update invoice.php --- htdocs/takepos/invoice.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 3f97f45d40c..a1882b1964b 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -403,9 +403,9 @@ if ($action=="valid" || $action=="history") if ($conf->global->TAKEPOSCONNECTOR) $sectionwithinvoicelink.=' '; else $sectionwithinvoicelink.=' '; $sectionwithinvoicelink.=' '; - $sectionwithinvoicelink.=''; + if ($invoice->paye) $sectionwithinvoicelink.=''; } else { $sectionwithinvoicelink.=' '; - $sectionwithinvoicelink.=''; + if ($invoice->paye) $sectionwithinvoicelink.=''; } /* From ca5a3da04c287e5bc4801e6237e1869bec46569a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 11 Sep 2019 15:04:13 +0200 Subject: [PATCH 008/299] Update printsend.php --- htdocs/takepos/printsend.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/takepos/printsend.php b/htdocs/takepos/printsend.php index ff97c1cc51c..6a2b672cf60 100644 --- a/htdocs/takepos/printsend.php +++ b/htdocs/takepos/printsend.php @@ -65,8 +65,6 @@ else } } -top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); - $langs->loadLangs(array("main", "bills", "cashdesk")); ?> From 21c51eb3d22f128a43da1afd609d3965073a191a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 15 Sep 2019 21:01:29 +0200 Subject: [PATCH 009/299] Update invoice.php --- htdocs/takepos/invoice.php | 45 +++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index a1882b1964b..8512beee2ee 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -698,9 +698,52 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep $soc = new Societe($db); if ($invoice->socid > 0) $soc->fetch($invoice->socid); else $soc->fetch($conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}); - print '

'; + print '

'; print $langs->trans("Customer").': '.$soc->name; + + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; + if (! empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") + { + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + $warehouse = new Entrepot($db); + $warehouse->fetch($conf->global->$constantforkey); + print '
'.$langs->trans("Warehouse").': '.$warehouse->ref; + } print '

'; + + // Module Adherent + if (! empty($conf->adherent->enabled)) + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $langs->load("members"); + print '

'; + print $langs->trans("Member").': '; + $adh=new Adherent($db); + $result=$adh->fetch('', '', $invoice->socid); + if ($result > 0) + { + $adh->ref=$adh->getFullName($langs); + print $adh->getFullName($langs); + print '
'.$langs->trans("Type").': '.$adh->type; + if ($adh->datefin) + { + print '
'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); + if ($adh->hasDelay()) { + print " ".img_warning($langs->trans("Late")); + } + } + else + { + print $langs->trans("SubscriptionNotReceived"); + if ($adh->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated + } + } + else + { + print ''.$langs->trans("ThirdpartyNotLinkedToMember").''; + } + print '

'; + } } if ($action == "search") From 6ff13ab7e1679cfa6996cf12687503791c4e8c5f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 23 Oct 2019 22:03:43 +0200 Subject: [PATCH 010/299] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index ca119b85791..7ea78438bfe 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -439,7 +439,7 @@ if ($action=="valid" || $action=="history") else $sectionwithinvoicelink.=$langs->trans('BillShortStatusValidated'); } $sectionwithinvoicelink.=''; - if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) { + if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink.=''; if ($conf->global->TAKEPOSCONNECTOR) $sectionwithinvoicelink.=' '; else $sectionwithinvoicelink.=' '; $sectionwithinvoicelink.=' '; From 0e7f3c307eb3899b2db5094102caa563bb236882 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 23 Oct 2019 20:05:37 +0000 Subject: [PATCH 011/299] Fixing style errors. --- htdocs/takepos/invoice.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 7ea78438bfe..9ed6529c222 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -444,9 +444,9 @@ if ($action=="valid" || $action=="history") else $sectionwithinvoicelink.=' '; $sectionwithinvoicelink.=' '; if ($invoice->paye) $sectionwithinvoicelink.=''; - } else { $sectionwithinvoicelink.=' '; +} else { $sectionwithinvoicelink.=' '; if ($invoice->paye) $sectionwithinvoicelink.=''; - } +} /* * View From fced9ec690d2eccfbcd6486cded46ad184e58cdb Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 27 Oct 2019 12:04:01 +0100 Subject: [PATCH 012/299] Fix missing contact fetch on card --- htdocs/contact/card.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 52957d25343..e36327be432 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -78,6 +78,14 @@ $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'ro // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('contactcard','globalcard')); +if ($id > 0) $object->fetch($id); + +if (! ($object->id > 0) && $action == 'view') +{ + $langs->load("errors"); + print($langs->trans('ErrorRecordNotFound')); + exit; +} /* * Actions From abc7198db4e1a66849d4e34046d5c9096e3393ca Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Mon, 28 Oct 2019 12:51:12 +0100 Subject: [PATCH 013/299] Fix Multicompany Filter Select only invoice in current company. --- htdocs/margin/customerMargins.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index b3a2c59e63f..32ef5030cb8 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -220,6 +220,7 @@ if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if (!$user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")"; $sql.= ' AND s.entity IN ('.getEntity('societe').')'; +$sql.= ' AND f.entity IN ('.getEntity('').')'; $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND (d.product_type = 0 OR d.product_type = 1)"; if(! empty($TSelectedProducts)) { From 30d416f8c08cbe1c5400036875a9fe9f3fee6089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 28 Oct 2019 20:16:27 +0100 Subject: [PATCH 014/299] Update agenda.lang --- htdocs/langs/en_US/agenda.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index a7b6ea4f4da..022588139c7 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -85,6 +85,7 @@ PRODUCT_MODIFYInDolibarr=Product %s modified PRODUCT_DELETEInDolibarr=Product %s deleted HOLIDAY_CREATEInDolibarr=Request for leave %s created HOLIDAY_MODIFYInDolibarr=Request for leave %s modified +HOLIDAY_APPROVEInDolibarr=Request for leave %s approved HOLIDAY_VALIDATEDInDolibarr=Request for leave %s validated HOLIDAY_DELETEInDolibarr=Request for leave %s deleted EXPENSE_REPORT_CREATEInDolibarr=Expense report %s created From 85cef09e8313c5deed260cad6a1386ea3412b5a6 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 30 Oct 2019 14:46:46 +0100 Subject: [PATCH 015/299] FIX: triggers: directories read with opendir() never closed --- htdocs/core/class/interfaces.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 655969d73f6..2960d4cf327 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -151,6 +151,8 @@ class Interfaces $i++; } } + + closedir($handle); } } From 5550a62afa9b3f790bf0774c5235498da4df279b Mon Sep 17 00:00:00 2001 From: atm-josselin Date: Thu, 31 Oct 2019 11:05:45 +0100 Subject: [PATCH 016/299] Fix misspelling on field of productlot --- htdocs/product/stock/class/productlot.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index dd811a66cf6..bd1a14329a6 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -62,7 +62,7 @@ class Productlot extends CommonObject 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), - 'fk_user_author'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), + 'fk_user_creat'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511) ); From 8765e7648e1354e6b2bf13ea395f409f2d330811 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 31 Oct 2019 11:03:46 +0000 Subject: [PATCH 017/299] Fixing style errors. --- htdocs/core/tpl/extrafields_list_search_input.tpl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/tpl/extrafields_list_search_input.tpl.php b/htdocs/core/tpl/extrafields_list_search_input.tpl.php index 0ba2385eda2..fb0a0dea3aa 100644 --- a/htdocs/core/tpl/extrafields_list_search_input.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_input.tpl.php @@ -38,9 +38,8 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $morecss=''; if ($typeofextrafield == 'sellist') $morecss='maxwidth200'; $keyprefix=$search_options_pattern; - if (substr($search_options_pattern, -8) === 'options_') $keyprefix = substr($search_options_pattern, 0,-8); + if (substr($search_options_pattern, -8) === 'options_') $keyprefix = substr($search_options_pattern, 0, -8); echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $keyprefix, $morecss); - } else { From e191dd7cc015ed3495d5a27bab94ad96405d71b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 Nov 2019 16:13:40 +0100 Subject: [PATCH 018/299] $key is overwriting a variable from outer foreach loop --- htdocs/admin/notification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 3c7ce730d03..6ba0d5673e2 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -238,7 +238,7 @@ foreach($listofnotifiedevents as $notifiedevent) $s=''; // Do not use type="email" here, we must be able to enter a list of email with , separator. $arrayemail=explode(',', $value); $showwarning=0; - foreach($arrayemail as $key=>$valuedet) + foreach($arrayemail as $keydet => $valuedet) { $valuedet=trim($valuedet); if (! empty($valuedet) && ! isValidEmail($valuedet, 1)) $showwarning++; From d2b7961e873073d52623bad2834066cdae8da88d Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Sun, 3 Nov 2019 22:45:50 +0100 Subject: [PATCH 019/299] Update customerMargins.php --- htdocs/margin/customerMargins.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 32ef5030cb8..78d105ad5cb 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -220,7 +220,7 @@ if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if (!$user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")"; $sql.= ' AND s.entity IN ('.getEntity('societe').')'; -$sql.= ' AND f.entity IN ('.getEntity('').')'; +$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND (d.product_type = 0 OR d.product_type = 1)"; if(! empty($TSelectedProducts)) { From 729ed7806366e55d81413b251132046a026927c6 Mon Sep 17 00:00:00 2001 From: "O. Libre" Date: Sun, 3 Nov 2019 11:52:42 +0100 Subject: [PATCH 020/299] FIX the SELECT examine more than MAX_JOIN_SIZE rows #12305 --- htdocs/accountancy/customer/list.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 7826d2b1faf..e14d6211cbc 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -311,6 +311,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); dol_syslog("accountancy/customer/list.php", LOG_DEBUG); +// MAX_JOIN_SIZE can be very low (ex: 300000) on some limited configurations (ex: https://www.online.net/fr/hosting/online-perso) +// This big SELECT command may exceed the MAX_JOIN_SIZE limit => Therefore we use SQL_BIG_SELECTS=1 to disable the MAX_JOIN_SIZE security +$db->query("SET SQL_BIG_SELECTS=1"); $result = $db->query($sql); if ($result) { $num_lines = $db->num_rows($result); @@ -418,7 +421,7 @@ if ($result) { $facture_static = new Facture($db); $product_static = new Product($db); - $isSellerInEEC = isInEEC($mysoc); + $isSellerInEEC = isInEEC($mysoc); while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); @@ -587,6 +590,7 @@ if ($result) { } else { print $db->error(); } +$db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation // Add code to auto check the box when we select an account print ''."\n"; @@ -523,9 +523,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; // List filters - foreach($object->filters as $rulefilter) + foreach ($object->filters as $rulefilter) { - $rulefilterobj=new EmailCollectorFilter($db); + $rulefilterobj = new EmailCollectorFilter($db); $rulefilterobj->fetch($rulefilter['id']); print ''; @@ -552,16 +552,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Add operation print ''; print ''; - $arrayoftypes=array( + $arrayoftypes = array( 'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), 'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), 'recordevent'=>'RecordEvent'); - if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty'; - if ($conf->ticket->enabled) $arrayoftypes['ticket']='CreateTicketAndThirdParty'; + if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty'; + if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty'; print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300'); print ''; print ''; - $htmltext=$langs->transnoentitiesnoconv("OperationParamDesc"); + $htmltext = $langs->transnoentitiesnoconv("OperationParamDesc"); //var_dump($htmltext); print $form->textwithpicto('', $htmltext); print ''; @@ -571,11 +571,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // List operations $nboflines = count($object->actions); $table_element_line = 'emailcollector_emailcollectoraction'; - $fk_element='position'; - $i=0; - foreach($object->actions as $ruleaction) + $fk_element = 'position'; + $i = 0; + foreach ($object->actions as $ruleaction) { - $ruleactionobj=new EmailcollectorAction($db); + $ruleactionobj = new EmailcollectorAction($db); $ruleactionobj->fetch($ruleaction['id']); print ''; @@ -604,7 +604,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { print ''.img_up('default', 0, 'imgupforline').''; } - if ($i < count($object->actions)-1) { + if ($i < count($object->actions) - 1) { print ''.img_down('default', 0, 'imgdownforline').''; } print ''; @@ -620,15 +620,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; - if (! empty($conf->use_javascript_ajax)) { + if (!empty($conf->use_javascript_ajax)) { $urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id; - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print ''; print '
'; - print ''; // End
+ print '
'; // End
print '

'; @@ -637,26 +637,26 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Buttons for actions if ($action != 'presend' && $action != 'editline') { - print '
' . "\n"; + print '
'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - print ''; + print ''; // Clone - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; } - print '
' . "\n"; + print '
'."\n"; } - if (! empty($debuginfo)) + if (!empty($debuginfo)) { print info_admin($debuginfo); } diff --git a/htdocs/admin/system/xcache.php b/htdocs/admin/system/xcache.php index 0cca1b94fc4..5061305f2e2 100644 --- a/htdocs/admin/system/xcache.php +++ b/htdocs/admin/system/xcache.php @@ -41,7 +41,7 @@ print "
\n"; if (!function_exists('xcache_info')) { - print 'XCache seems to be not installed. Function xcache_info not found.'; + print 'XCache seems to be not installed. Function xcache_info not found.'; llxFooter(); exit; } diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index ddde75ee463..1f6966fcd15 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -39,25 +39,25 @@ $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new Asset($db); +$object = new Asset($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('assetcard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } -if (empty($action) && empty($id) && empty($ref)) $action='view'; +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; // Security check - Protection if external user //if ($user->socid > 0) access_forbidden(); @@ -65,11 +65,11 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; //$result = restrictedArea($user, 'asset', $id); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissionnote=$user->rights->asset->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->asset->write; // Used by the include of actions_dellink.inc.php -$permissiontoadd=$user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->rights->asset->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->asset->write; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php /* @@ -78,13 +78,13 @@ $permissiontoadd=$user->rights->asset->write; // Used by the include of actions * Put here all code to do according to value of "action" parameter */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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)) { - $error=0; + $error = 0; $permissiontoadd = $user->rights->asset->create; $permissiontodelete = $user->rights->asset->delete; @@ -97,9 +97,9 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='ASSET_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_ASSET_TO'; - $trackid='asset'.$object->id; + $trigger_name = 'ASSET_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_ASSET_TO'; + $trackid = 'asset'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -112,11 +112,11 @@ if (empty($reshook)) * Put here all code to build page */ -$form=new Form($db); -$formfile=new FormFile($db); +$form = new Form($db); +$formfile = new FormFile($db); -$title=$langs->trans("Assets").' - '.$langs->trans("Card"); -$help_url=''; +$title = $langs->trans("Assets").' - '.$langs->trans("Card"); +$help_url = ''; llxHeader('', $title, $help_url); // Example : Adding jquery code @@ -150,10 +150,10 @@ if ($action == 'create') print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print '
'."\n"; @@ -162,7 +162,7 @@ if ($action == 'create') print '
'; print ''; print '  '; - print ''; // Cancel for create does not post form if we don't know the backtopage + print ''; // Cancel for create does not post form if we don't know the backtopage print '
'; print ''; @@ -184,10 +184,10 @@ if (($id || $ref) && $action == 'edit') print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; print '
'; @@ -213,21 +213,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAssets'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAssets'), 'confirm_delete', '', 0, 1); } // Confirmation of action xxxx if ($action == 'xxx') { - $formquestion=array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -235,9 +235,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; /* // Ref bis $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->asset->creer, 'string', '', 0, 1); @@ -245,7 +245,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); */ - $morehtmlref.='
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -256,10 +256,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Common attributes //$keyforbreak='fieldkeytoswithonsecondcolumn'; - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; print '
'; @@ -274,14 +274,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Buttons for actions if ($action != 'presend' && $action != 'editline') { print '
'."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { // Send - print '' . $langs->trans('SendMail') . ''."\n"; + print ''.$langs->trans('SendMail').''."\n"; if ($user->rights->asset->write) { @@ -335,11 +335,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $MAXEVENT = 10; $morehtmlright = ''; - $morehtmlright.= $langs->trans("SeeAll"); - $morehtmlright.= ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'asset', $socid, 1, '', $MAXEVENT, '', $morehtmlright); diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 1df8d8ad48f..714e15f0ee9 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -40,9 +40,9 @@ class modBom extends DolibarrModules */ public function __construct($db) { - global $langs,$conf; + global $langs,$conf; - $this->db = $db; + $this->db = $db; // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). @@ -68,8 +68,8 @@ class modBom extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' $this->version = 'dolibarr'; - //Url to the file with your last numberversion of this module - //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; + //Url to the file with your last numberversion of this module + //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; // Key used in llx_const table to save module status enabled/disabled (where BILLOFMATERIALS is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. @@ -79,7 +79,7 @@ class modBom extends DolibarrModules // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( - /* + /* 'triggers' => 1, // Set this to 1 if module has its own trigger directory (core/triggers) 'login' => 0, // Set this to 1 if module has its own login method file (core/login) 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions) @@ -122,8 +122,8 @@ class modBom extends DolibarrModules // ); $this->const = array( 1=>array('BOM_ADDON_PDF', 'chaine', 'alpha', 'Name of PDF model of BOM', 0), - 2=>array('BOM_ADDON', 'chaine', 'mod_bom_standard', 'Name of numbering rules of BOM', 0), - 3=>array('BOM_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/boms', '', 0) + 2=>array('BOM_ADDON', 'chaine', 'mod_bom_standard', 'Name of numbering rules of BOM', 0), + 3=>array('BOM_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/boms', '', 0) ); // Some keys to add into the overwriting translation tables @@ -140,13 +140,13 @@ class modBom extends DolibarrModules // Array to add new pages in new tabs - $this->tabs = array(); + $this->tabs = array(); // Example: // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@bom:$user->rights->bom->read:/bom/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 - // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@bom:$user->rights->othermodule->read:/bom/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. - // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname - // - // Where objecttype can be + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@bom:$user->rights->othermodule->read:/bom/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // + // Where objecttype can be // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) // 'contact' to add a tab in contact view // 'contract' to add a tab in contract view @@ -168,9 +168,9 @@ class modBom extends DolibarrModules // 'user' to add a tab in user view - // Dictionaries + // Dictionaries $this->dictionaries=array(); - /* Example: + /* Example: $this->dictionaries=array( 'langs'=>'mylangfile@bom', 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor @@ -186,11 +186,11 @@ class modBom extends DolibarrModules */ - // Boxes/Widgets + // Boxes/Widgets // Add here list of php file(s) stored in bom/core/boxes that contains class to show a widget. - $this->boxes = array( - 0=>array('file' => 'box_boms.php', 'note' => '', 'enabledbydefaulton' => 'Home') - ); + $this->boxes = array( + 0=>array('file' => 'box_boms.php', 'note' => '', 'enabledbydefaulton' => 'Home') + ); // Cronjobs (List of cron jobs entries to add when module is enabled) @@ -312,12 +312,12 @@ class modBom extends DolibarrModules * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ public function init($options = '') { - global $conf, $langs; + global $conf, $langs; $result=$this->_load_tables('/bom/sql/'); if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') @@ -344,20 +344,20 @@ class modBom extends DolibarrModules if (file_exists($src) && ! file_exists($dest)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_mkdir($dirodt); - $result=dol_copy($src, $dest, 0, 0); - if ($result < 0) - { - $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); - return 0; - } + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result=dol_copy($src, $dest, 0, 0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); + return 0; + } } $sql = array( - //"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'bom' AND entity = ".$conf->entity, - //"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'bom', ".$conf->entity.")" + //"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'bom' AND entity = ".$conf->entity, + //"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'bom', ".$conf->entity.")" ); return $this->_init($sql, $options); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index bbf4340196b..3b2e42b06b6 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -54,38 +54,38 @@ dol_include_once('/mrp/lib/mrp_mo.lib.php'); $langs->loadLangs(array("mrp", "other")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'mocard'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'mocard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); //$lineid = GETPOST('lineid', 'int'); // Initialize technical objects -$object=new Mo($db); +$object = new Mo($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('mocard','globalcard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('mocard', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } -if (empty($action) && empty($id) && empty($ref)) $action='view'; +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user //if ($user->socid > 0) access_forbidden(); @@ -93,9 +93,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu //$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'mrp', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -$permissionnote=$user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->mrp->write; // Used by the include of actions_dellink.inc.php -$permissiontoadd=$user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->mrp->write; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); @@ -105,13 +105,13 @@ $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($ * Put here all code to do according to value of "action" parameter */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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)) { - $error=0; + $error = 0; $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); @@ -120,7 +120,7 @@ if (empty($reshook)) if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); } - $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record + $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, delete or clone include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; @@ -132,9 +132,9 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='MO_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_MO_TO'; - $trackid='mo'.$object->id; + $trigger_name = 'MO_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; + $trackid = 'mo'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Action to move up and down lines of object @@ -157,9 +157,9 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$formfile=new FormFile($db); -$formproject=new FormProjets($db); +$form = new Form($db); +$formfile = new FormFile($db); +$formproject = new FormProjets($db); llxHeader('', $langs->trans('Mo'), ''); @@ -194,10 +194,10 @@ if ($action == 'create') print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print '
'."\n"; @@ -238,7 +238,7 @@ if ($action == 'create') print '
'; print ''; print '  '; - print ''; // Cancel for create does not post form if we don't know the backtopage + print ''; // Cancel for create does not post form if we don't know the backtopage print '
'; print ''; @@ -262,10 +262,10 @@ if (($id || $ref) && $action == 'edit') print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; print '
'; @@ -292,7 +292,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); } // Confirmation to delete line if ($action == 'deleteline') @@ -321,14 +321,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $text .= $notify->confirmMessage('BOM_VALIDATE', $object->socid, $object); }*/ - $formquestion=array(); - if (! empty($conf->bom->enabled)) + $formquestion = array(); + if (!empty($conf->bom->enabled)) { $langs->load("mrp"); - require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $forcecombo = 0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), @@ -336,21 +336,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220); } // Clone confirmation if ($action == 'clone') { // Create an array for form $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -358,46 +358,46 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; /* // Ref bis $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= '
'.$langs->trans('Project').' '; if ($permissiontoadd) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(); + $morehtmlref .= $proj->getNomUrl(); } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -409,13 +409,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; // Common attributes - $keyforbreak='fk_warehouse'; + $keyforbreak = 'fk_warehouse'; unset($object->fields['fk_project']); unset($object->fields['fk_soc']); - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'; print '
'; @@ -430,29 +430,29 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea * Lines */ - if (! empty($object->table_element_line)) + if (!empty($object->table_element_line)) { // Show object lines $result = $object->getLinesArray(); - print '
- - + print ' + + - + '; - if (! empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; - if (! empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { print ''; } - if (! empty($object->lines)) + if (!empty($object->lines)) { $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/mrp/tpl'); } @@ -470,7 +470,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - if (! empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { print '
'; } @@ -484,8 +484,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action != 'presend' && $action != 'editline') { print '
'."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -495,7 +495,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($user->rights->bom->write && $object->status == MO::STATUS_VALIDATED) { - print '' . $langs->trans("SetToDraft") . ''; + print ''.$langs->trans("SetToDraft").''; } // Modify @@ -513,18 +513,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { if (is_array($object->lines) && count($object->lines) > 0) { - print '' . $langs->trans("Validate") . ''; + print ''.$langs->trans("Validate").''; } else { - print '' . $langs->trans("Validate") . ''; + print ''.$langs->trans("Validate").''; } } // Clone if ($permissiontoadd) { - print '' . $langs->trans("ToClone") . ''; + print ''.$langs->trans("ToClone").''; } // Delete (need delete permission, or if draft, just need create/modify permission) @@ -553,11 +553,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Documents $objref = dol_sanitizeFileName($object->ref); - $relativepath = $objref . '/' . $objref . '.pdf'; - $filedir = $conf->mrp->dir_output . '/' . $objref; - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->mrp->create; // If you can create/edit, you can remove a file on card + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->mrp->dir_output.'/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->mrp->create; // If you can create/edit, you can remove a file on card print $formfile->showdocuments('mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang); // Show links to link elements @@ -570,11 +570,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $MAXEVENT = 10; $morehtmlright = ''; - $morehtmlright.= $langs->trans("SeeAll"); - $morehtmlright.= ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'mo', $socid, 1, '', $MAXEVENT, '', $morehtmlright); @@ -585,8 +585,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (GETPOST('modelselected')) $action = 'presend'; // Presend form - $modelmail='mo'; - $defaulttopic='InformationMessage'; + $modelmail = 'mo'; + $defaulttopic = 'InformationMessage'; $diroutput = $conf->mrp->dir_output; $trackid = 'mo'.$object->id; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 8dc7ee4c625..c376cc80cae 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -54,38 +54,38 @@ dol_include_once('/mrp/lib/mrp_mo.lib.php'); $langs->loadLangs(array("mrp", "other")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'mocard'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'mocard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); //$lineid = GETPOST('lineid', 'int'); // Initialize technical objects -$object=new Mo($db); +$object = new Mo($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('mocard','globalcard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('mocard', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } -if (empty($action) && empty($id) && empty($ref)) $action='view'; +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user //if ($user->socid > 0) access_forbidden(); @@ -93,9 +93,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu //$isdraft = (($object->statut == Mo::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'mrp', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -$permissionnote=$user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->mrp->write; // Used by the include of actions_dellink.inc.php -$permissiontoadd=$user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->mrp->write; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0); @@ -105,13 +105,13 @@ $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object * Put here all code to do according to value of "action" parameter */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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)) { - $error=0; + $error = 0; $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); @@ -120,7 +120,7 @@ if (empty($reshook)) if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); } - $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record + $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, delete or clone include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; @@ -144,9 +144,9 @@ if (empty($reshook)) } // Actions to send emails - $trigger_name='MO_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_MO_TO'; - $trackid='mo'.$object->id; + $trigger_name = 'MO_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; + $trackid = 'mo'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -157,8 +157,8 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$formproject=new FormProjets($db); +$form = new Form($db); +$formproject = new FormProjets($db); llxHeader('', $langs->trans('Mo'), ''); @@ -192,7 +192,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); } // Confirmation to delete line if ($action == 'deleteline') @@ -203,13 +203,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action == 'clone') { // Create an array for form $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Confirmation of action xxxx if ($action == 'xxx') { - $formquestion=array(); + $formquestion = array(); /* $forcecombo=0; if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy @@ -220,14 +220,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) ); */ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -235,46 +235,46 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; /* // Ref bis $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->mrp->write) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(); + $morehtmlref .= $proj->getNomUrl(); } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -286,13 +286,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; // Common attributes - $keyforbreak='qty'; + $keyforbreak = 'qty'; unset($object->fields['fk_project']); unset($object->fields['fk_soc']); - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'; print '
'; @@ -307,29 +307,29 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea * Lines */ - if (! empty($object->table_element_line)) + if (!empty($object->table_element_line)) { // Show object lines $result = $object->getLinesArray(); - print '
- - + print ' + + - + '; - if (! empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; - if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + if (!empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') { print ''; } - if (! empty($object->lines)) + if (!empty($object->lines)) { $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); } @@ -347,7 +347,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + if (!empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') { print '
'; } diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 17ce50ca8bb..54a1b7dce88 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -32,17 +32,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; // Defini si peux lire/modifier utilisateurs et permisssions -$canreadperms=($user->admin || $user->rights->user->user->lire); -$caneditperms=($user->admin || $user->rights->user->user->creer); -$candisableperms=($user->admin || $user->rights->user->user->supprimer); +$canreadperms = ($user->admin || $user->rights->user->user->lire); +$caneditperms = ($user->admin || $user->rights->user->user->creer); +$candisableperms = ($user->admin || $user->rights->user->user->supprimer); $feature2 = 'user'; // Advanced permissions -if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { - $canreadperms=($user->admin || $user->rights->user->group_advance->read); - $caneditperms=($user->admin || $user->rights->user->group_advance->write); - $candisableperms=($user->admin || $user->rights->user->group_advance->delete); + $canreadperms = ($user->admin || $user->rights->user->group_advance->read); + $caneditperms = ($user->admin || $user->rights->user->group_advance->write); + $candisableperms = ($user->admin || $user->rights->user->group_advance->delete); $feature2 = 'group_advance'; } @@ -53,7 +53,7 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -$contextpage = GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'groupcard'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'groupcard'; // To manage different context of search $userid = GETPOST('user', 'int'); @@ -61,7 +61,7 @@ $userid = GETPOST('user', 'int'); $result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', $feature2); // Users/Groups management only in master entity if transverse mode -if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) +if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { accessforbidden(); } @@ -78,7 +78,7 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('groupcard','globalcard')); +$hookmanager->initHooks(array('groupcard', 'globalcard')); @@ -86,14 +86,14 @@ $hookmanager->initHooks(array('groupcard','globalcard')); * Actions */ -$parameters=array('id' => $id, 'userid' => $userid, 'caneditperms' => $caneditperms); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id' => $id, 'userid' => $userid, 'caneditperms' => $caneditperms); +$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)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -103,7 +103,7 @@ if (empty($reshook)) { header("Location: ".DOL_URL_ROOT.'/user/group/list.php'); exit; } - $action=''; + $action = ''; } // Action remove group @@ -128,19 +128,19 @@ if (empty($reshook)) { { if ($caneditperms) { - if (! $_POST["nom"]) { + if (!$_POST["nom"]) { setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); - $action="create"; // Go back to create page + $action = "create"; // Go back to create page } else { $object->name = trim(GETPOST("nom", 'nohtml')); - $object->nom = $object->name; // For backward compatibility + $object->nom = $object->name; // For backward compatibility $object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'none'))); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0; + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0; else $object->entity = $_POST["entity"]; $db->begin(); @@ -160,7 +160,7 @@ if (empty($reshook)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorGroupAlreadyExists", $object->name), null, 'errors'); - $action="create"; // Go back to create page + $action = "create"; // Go back to create page } } } @@ -172,7 +172,7 @@ if (empty($reshook)) { } // Add/Remove user into group - if ($action == 'adduser' || $action =='removeuser') + if ($action == 'adduser' || $action == 'removeuser') { if ($caneditperms) { @@ -183,8 +183,8 @@ if (empty($reshook)) { $edituser = new User($db); $edituser->fetch($userid); - if ($action == 'adduser') $result=$edituser->SetInGroup($object->id, $object->entity); - if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id, $object->entity); + if ($action == 'adduser') $result = $edituser->SetInGroup($object->id, $object->entity); + if ($action == 'removeuser') $result = $edituser->RemoveFromGroup($object->id, $object->entity); if ($result > 0) { @@ -216,19 +216,19 @@ if (empty($reshook)) { $object->oldcopy = clone $object; $object->name = trim(GETPOST("group", 'nohtml')); - $object->nom = $object->name; // For backward compatibility + $object->nom = $object->name; // For backward compatibility $object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'none'))); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0; + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0; else $object->entity = $_POST["entity"]; - $ret=$object->update(); + $ret = $object->update(); - if ($ret >= 0 && ! count($object->errors)) + if ($ret >= 0 && !count($object->errors)) { setEventMessages($langs->trans("GroupModified"), null, 'mesgs'); $db->commit(); @@ -248,7 +248,7 @@ if (empty($reshook)) { // Actions to build doc $upload_dir = $conf->usergroup->dir_output; - $permissiontoadd=$user->rights->user->user->creer; + $permissiontoadd = $user->rights->user->user->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -283,9 +283,9 @@ if ($action == 'create') print ''; // Multicompany - if (! empty($conf->multicompany->enabled) && is_object($mc)) + if (!empty($conf->multicompany->enabled) && is_object($mc)) { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { print "".''.$langs->trans("Entity").''; print "".$mc->select_entities($conf->entity); @@ -299,13 +299,13 @@ if ($action == 'create') print "".''.$langs->trans("Description").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note', '', '', 240, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_8, '90%'); + $doleditor = new DolEditor('note', '', '', 240, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_8, '90%'); $doleditor->Create(); print "\n"; // Other attributes - $parameters=array('object' => $object, 'colspan' => ' colspan="2"'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('object' => $object, 'colspan' => ' colspan="2"'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -364,7 +364,7 @@ else print ''; // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) - if (! empty($conf->mutlicompany->enabled)) + if (!empty($conf->mutlicompany->enabled)) { print ''; print '".''; @@ -390,8 +390,8 @@ else print "\n"; // Other attributes - $parameters=array('colspan' => ' colspan="2"'); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('colspan' => ' colspan="2"'); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print "
'.$langs->trans("Name").''.dol_escape_htmltag($object->name); @@ -376,7 +376,7 @@ else } // Multicompany - if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { $mc->getInfo($object->entity); print "
'.$langs->trans("Entity").'
\n"; print '
'; @@ -423,17 +423,17 @@ else // On selectionne les users qui ne sont pas deja dans le groupe $exclude = array(); - if (! empty($object->members)) + if (!empty($object->members)) { - foreach($object->members as $useringroup) + foreach ($object->members as $useringroup) { - $exclude[]=$useringroup->id; + $exclude[] = $useringroup->id; } } // Other form for add user to group - $parameters=array('caneditperms' => $caneditperms, 'exclude' => $exclude); - $reshook=$hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('caneditperms' => $caneditperms, 'exclude' => $exclude); + $reshook = $hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) @@ -467,14 +467,14 @@ else print ' '; print "\n"; - if (! empty($object->members)) + if (!empty($object->members)) { - foreach($object->members as $useringroup) + foreach ($object->members as $useringroup) { print ''; print ''; print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login'); - if ($useringroup->admin && ! $useringroup->entity) { + if ($useringroup->admin && !$useringroup->entity) { print img_picto($langs->trans("SuperAdministrator"), 'redstar'); } elseif ($useringroup->admin) { print img_picto($langs->trans("Administrator"), 'star'); @@ -484,7 +484,7 @@ else print ''.$useringroup->firstname.''; print ''.$useringroup->getLibStatut(3).''; print ''; - if (! empty($user->admin)) { + if (!empty($user->admin)) { print ''; print img_picto($langs->trans("RemoveFromGroup"), 'unlink'); print ''; @@ -511,8 +511,8 @@ else * Documents generes */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->usergroup->dir_output . "/" . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $filedir = $conf->usergroup->dir_output."/".dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->rights->user->user->creer; $delallowed = $user->rights->user->user->supprimer; @@ -550,9 +550,9 @@ else print "\n"; // Multicompany - if (! empty($conf->multicompany->enabled) && is_object($mc)) + if (!empty($conf->multicompany->enabled) && is_object($mc)) { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { print "".''.$langs->trans("Entity").''; print "".$mc->select_entities($object->entity); @@ -567,13 +567,13 @@ else print ''.$langs->trans("Description").''; print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note', $object->note, '', 240, 'dolibarr_notes', '', true, false, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_8, '90%'); + $doleditor = new DolEditor('note', $object->note, '', 240, 'dolibarr_notes', '', true, false, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_8, '90%'); $doleditor->Create(); print ''; print "\n"; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index be7c773ed25..e6c5b0f7c3d 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -29,48 +29,48 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/lib/websiteaccount.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("website","other")); +$langs->loadLangs(array("website", "other")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new SocieteAccount($db); +$object = new SocieteAccount($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('websiteaccountcard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->website->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('websiteaccountcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } -if (empty($action) && empty($id) && empty($ref)) $action='view'; +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; // Security check - Protection if external user //if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'website', $id); -$permissionnote=$user->rights->websiteaccount->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->websiteaccount->write; // Used by the include of actions_dellink.inc.php -$permissiontoadd=$user->rights->websiteaccount->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->rights->websiteaccount->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->websiteaccount->write; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->websiteaccount->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. @@ -78,13 +78,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu * Actions */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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)) { - $error=0; + $error = 0; $permissiontoadd = $user->rights->website->write; $permissiontodelete = $user->rights->website->delete; @@ -97,9 +97,9 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='WEBSITEACCOUNT_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_WEBSITEACCOUNT_TO'; - $trackid='websiteaccount'.$object->id; + $trigger_name = 'WEBSITEACCOUNT_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_WEBSITEACCOUNT_TO'; + $trackid = 'websiteaccount'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -108,8 +108,8 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$formfile=new FormFile($db); +$form = new Form($db); +$formfile = new FormFile($db); llxHeader('', 'WebsiteAccount', ''); @@ -144,10 +144,10 @@ if ($action == 'create') print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print '
'."\n"; @@ -156,7 +156,7 @@ if ($action == 'create') print '
'; print ''; print '  '; - print ''; // Cancel for create does not post form if we don't know the backtopage + print ''; // Cancel for create does not post form if we don't know the backtopage print '
'; print '
'; @@ -177,10 +177,10 @@ if (($id || $ref) && $action == 'edit') print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; print '
'; @@ -196,7 +196,7 @@ if (($id || $ref) && $action == 'edit') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - if ($object->fk_soc >0 && empty($socid)) $socid = $object->fk_soc; + if ($object->fk_soc > 0 && empty($socid)) $socid = $object->fk_soc; $res = $object->fetch_optionals(); @@ -207,14 +207,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteWebsiteAccount'), $langs->trans('ConfirmDeleteWebsiteAccount'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteWebsiteAccount'), $langs->trans('ConfirmDeleteWebsiteAccount'), 'confirm_delete', '', 0, 1); } // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -222,11 +222,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback=''; - if ($socid) $linkback = '' . $langs->trans("BackToListOfThirdParty") . ''; - if ($fk_website) $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''; + if ($socid) $linkback = ''.$langs->trans("BackToListOfThirdParty").''; + if ($fk_website) $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; /* // Ref bis $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->website->creer, 'string', '', 0, 1); @@ -268,7 +268,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } */ - $morehtmlref.='
'; + $morehtmlref .= '
'; if ($socid > 0) $object->next_prev_filter = 'te.fk_soc = '.$socid; @@ -281,10 +281,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'; print '
'; @@ -299,14 +299,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Buttons for actions if ($action != 'presend' && $action != 'editline') { print '
'."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { // Send - print ''."\n"; + print ''."\n"; if ($user->rights->website->write) { @@ -376,8 +376,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Presend form - $modelmail='websiteaccount'; - $defaulttopic='Information'; + $modelmail = 'websiteaccount'; + $defaulttopic = 'Information'; $diroutput = $conf->website->dir_output; $trackid = 'websiteaccount'.$object->id; From 5a4a421a8ebf90993a12a9a5103902903000d23d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Nov 2019 13:07:40 +0100 Subject: [PATCH 060/299] FIX #12372 --- htdocs/compta/bank/class/paymentvarious.class.php | 2 +- htdocs/compta/bank/various_payment/card.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index cc43f9cf830..aea51e1a544 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -378,7 +378,7 @@ class PaymentVarious extends CommonObject $sql.= "'".$this->db->idate($this->datep)."'"; $sql.= ", '".$this->db->idate($this->datev)."'"; $sql.= ", '".$this->db->escape($this->sens)."'"; - $sql.= ", ".$this->amount; + $sql.= ", ".price2num($this->amount); $sql.= ", '".$this->db->escape($this->type_payment)."'"; $sql.= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index aac8f603054..dd022182e61 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -48,12 +48,11 @@ $backtopage = GETPOST('backtopage', 'alpha'); $accountid = GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0; $label = GETPOST("label", "alpha"); $sens = GETPOST("sens", "int"); -$amount = GETPOST("amount", "alpha"); +$amount = price2num(GETPOST("amount", "alpha")); $paymenttype = GETPOST("paymenttype", "int"); $accountancy_code = GETPOST("accountancy_code", "alpha"); $subledger_account = GETPOST("subledger_account", "alpha"); $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); -$category_transaction = GETPOST("category_transaction", 'alpha'); // Security check $socid = GETPOST("socid", "int"); From 7dc94f1761792442cac3e8107714b28401375783 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Thu, 7 Nov 2019 13:50:25 +0100 Subject: [PATCH 061/299] Fix not deactivated commercial menu button --- htdocs/core/menus/standard/eldy.lib.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a73132c366d..48b093e4321 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -230,7 +230,13 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ! empty($conf->contrat->enabled) || ! empty($conf->ficheinter->enabled) )?1:0, - 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), + 'perms'=>(! empty($user->rights->propal->lire) || + ! empty($user->rights->commande->lire) || + ! empty($user->rights->supplier_order->lire) || + ! empty($user->rights->supplier_proposal->lire) || + ! empty($user->rights->contrat->lire) || + ! empty($user->rights->ficheinter->lire) + ), 'module'=>'propal|commande|supplier_order|contrat|ficheinter' ); $menu_arr[] = array( From 1fa61077a0f51d5282870b9dffa5955ba842444c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Nov 2019 14:07:50 +0100 Subject: [PATCH 062/299] FIX #12356 --- .../modules/facture/doc/pdf_crabe.modules.php | 14 +- .../pdf/pdf_canelle.modules.php | 199 +++++++++++------- htdocs/fourn/facture/paiement.php | 4 +- 3 files changed, 129 insertions(+), 88 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 2b198c35336..8ee898b5a4e 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; /** - * Class to manage PDF invoice template Crabe + * Class to generate the customer invoice PDF with template Crabe */ class pdf_crabe extends ModelePDFFactures { @@ -235,7 +235,7 @@ class pdf_crabe extends ModelePDFFactures public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines; + global $user,$langs,$conf,$mysoc,$hookmanager,$nblines; dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); @@ -243,7 +243,7 @@ class pdf_crabe extends ModelePDFFactures // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - // Load traductions files required by page + // Load translation files required by the page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); $nblines = count($object->lines); @@ -769,7 +769,7 @@ class pdf_crabe extends ModelePDFFactures /** * Show payments table * - * @param PDF $pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object invoice * @param int $posy Position y in PDF * @param Translate $outputlangs Object langs for output @@ -1116,9 +1116,9 @@ class pdf_crabe extends ModelePDFFactures /** * Show total to pay * - * @param PDF $pdf Object PDF + * @param PDF $pdf Object PDF * @param Facture $object Object invoice - * @param int $deja_regle Montant deja regle + * @param int $deja_regle Amount already paid (in the currency of invoice) * @param int $posy Position depart * @param Translate $outputlangs Objet langs * @return int Position pour suite @@ -1402,7 +1402,7 @@ class pdf_crabe extends ModelePDFFactures $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); //print "x".$creditnoteamount."-".$depositsamount;exit; $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); - if ($object->paye) $resteapayer=0; + if (! empty($object->paye)) $resteapayer=0; if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) { diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 89dbd9898bc..415ebf3c34c 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; /** - * Class to generate the supplier invoices with the canelle model + * Class to generate the supplier invoices PDF with the template canelle */ class pdf_canelle extends ModelePDFSuppliersInvoices { @@ -53,6 +53,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices public $description; /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + + /** * @var string document type */ public $type; @@ -121,14 +126,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices { global $conf, $langs, $mysoc; - // Load translation files required by the page + // Translations $langs->loadLangs(array("main", "bills")); $this->db = $db; $this->name = "canelle"; $this->description = $langs->trans('SuppliersInvoiceModel'); - // Page size for A4 format + // Dimension page $this->type = 'pdf'; $formatarray=pdf_getFormat(); $this->page_largeur = $formatarray['width']; @@ -188,7 +193,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /** * Function to build pdf onto disk * - * @param FactureFournisseur $object Id of object to generate + * @param FactureFournisseur $object Object to generate * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details @@ -214,13 +219,15 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products")); + $nblines = count($object->lines); + if ($conf->fournisseur->facture->dir_output) { $object->fetch_thirdparty(); - $deja_regle = $object->getSommePaiement(); - //$amount_credit_notes_included = $object->getSumCreditNotesUsed(); - //$amount_deposits_included = $object->getSumDepositsUsed(); + $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Definition of $dir and $file if ($object->specimen) @@ -259,15 +266,19 @@ class pdf_canelle extends ModelePDFSuppliersInvoices global $action; $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + // Set nblines with the new facture lines content after hook $nblines = count($object->lines); - + $nbpayments = count($object->getListOfPayments()); + + // Create pdf instance $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 50; // Height reserved to output the info and total part + $pdf->SetAutoPageBreak(1, 0); + + $heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; - $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) { @@ -278,7 +289,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Set path to the background PDF File if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { - $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } @@ -287,15 +298,15 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities("Invoice")); + $pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right - // Positionne $this->atleastonediscount si on a au moins une remise + // Set $this->atleastonediscount if you have at least one discount for ($i = 0 ; $i < $nblines ; $i++) { if ($object->lines[$i]->remise_percent) @@ -348,11 +359,16 @@ class pdf_canelle extends ModelePDFSuppliersInvoices } } - // Affiche notes + // Display notes if (! empty($object->note_public)) { $tab_top -= 2; + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); + $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1); $nexY = $pdf->GetY(); @@ -376,13 +392,18 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); + // Define size of image if we need it + $imglinesize=array(); + if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $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(); + $showpricebeforepagebreak=1; + // Description of product line $curX = $this->posxdesc-1; - $showpricebeforepagebreak=1; $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva-$curX, 3, $curX, $curY, $hideref, $hidedesc, 1); @@ -415,19 +436,20 @@ class pdf_canelle extends ModelePDFSuppliersInvoices { $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. - // We suppose that a too long description is moved completely on next page + // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) @@ -442,18 +464,13 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); - // Unit price before discount - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxup, $curY); - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); - // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if($conf->global->PRODUCT_USE_UNITS) + if (! empty($conf->global->PRODUCT_USE_UNITS)) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); @@ -461,15 +478,15 @@ class pdf_canelle extends ModelePDFSuppliersInvoices } // Discount on line - $pdf->SetXY($this->posxdiscount, $curY); if ($object->lines[$i]->remise_percent) { + $pdf->SetXY($this->posxdiscount-2, $curY); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R'); } - + // Total HT line - $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs); + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); @@ -494,6 +511,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->localtax1[$localtax1rate]+=$localtax1ligne; $this->localtax2[$localtax2rate]+=$localtax2ligne; + if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; + // Add line if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { @@ -555,18 +574,19 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } - // Affiche zone totaux + // Display total area $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); $amount_credit_notes_included=0; $amount_deposits_included=0; - if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) + // Display Payments area + if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->SUPPLIER_INVOICE_NO_PAYMENT_DETAILS)) { - $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); + $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs, $heightforfooter); } - // Pied de page + // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -594,13 +614,13 @@ class pdf_canelle extends ModelePDFSuppliersInvoices } else { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); + $this->error=$langs->transnoentities("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); return 0; } } @@ -610,9 +630,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /** * Show total to pay * - * @param PDF $pdf Object PDF - * @param Facture $object Object invoice - * @param int $deja_regle Montant deja regle + * @param PDF $pdf Object PDF + * @param Object $object Object invoice + * @param int $deja_regle Amount already paid (in the currency of invoice) * @param int $posy Position depart * @param Translate $outputlangs Objet langs * @return int Position pour suite @@ -622,20 +642,16 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // phpcs:enable global $conf,$mysoc; - $default_font_size = pdf_getPDFFontSize($outputlangs); + $sign=1; + if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + + $default_font_size = pdf_getPDFFontSize($outputlangs); $tab2_top = $posy; $tab2_hl = 4; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($this->marge_gauche, $tab2_top + 0); - // If France, show VAT mention if not applicable - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) - { - $pdf->MultiCell(100, $tab2_hl, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - } - - // Tableau total + // Total table $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { @@ -643,6 +659,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices } $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); + $useborder=0; $index=0; // Total HT @@ -652,11 +669,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + $object->remise), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248, 248, 248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + + $this->atleastoneratenotnull=0; foreach($this->tva as $tvakey => $tvaval) { if ($tvakey > 0) // On affiche pas taux 0 @@ -674,12 +694,12 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; $totalvat.=vatrate($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, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } if (! $this->atleastoneratenotnull) // If no vat at all @@ -688,7 +708,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva, 0, $outputlangs), 0, 'R', 1); // Total LocalTax1 if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) @@ -697,7 +717,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1, 0, $outputlangs), 0, 'R', 1); } // Total LocalTax2 @@ -707,7 +727,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2, 0, $outputlangs), 0, 'R', 1); } } else @@ -734,7 +754,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $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, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } //} @@ -761,14 +781,12 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $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, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } //} } - $useborder=0; - // Total TTC $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -776,35 +794,58 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFillColor(224, 224, 224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); - $creditnoteamount=0; - $depositsamount=0; - //$creditnoteamount=$object->getSumCreditNotesUsed(); - //$depositsamount=$object->getSumDepositsUsed(); + $pdf->SetTextColor(0, 0, 0); + $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received + $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); //print "x".$creditnoteamount."-".$depositsamount;exit; $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if (! empty($object->paye)) $resteapayer=0; - if ($deja_regle > 0) + if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) { + // Already paid + Deposits $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); - + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); - + $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0); + + // Credit note + if ($creditnoteamount) + { + $labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes"); + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $labeltouse, 0, 'L', 0); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0); + } + + // Escompte + if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) + { + $index++; + $pdf->SetFillColor(255, 255, 255); + + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1); + + $resteapayer=0; + } + $index++; $pdf->SetTextColor(0, 0, 60); + $pdf->SetFillColor(224, 224, 224); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetTextColor(0, 0, 0); } @@ -822,7 +863,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param string $tab_height Height of table (rectangle) * @param int $nexY Y (not used) * @param Translate $outputlangs Langs object - * @param int $hidetop Hide top bar of array + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title * @param int $hidebottom Hide bottom bar of array * @param string $currency Currency code * @return void @@ -866,7 +907,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); } - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); if (empty($hidetop)) @@ -890,7 +931,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->MultiCell($this->posxunit-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if($conf->global->PRODUCT_USE_UNITS) { + if (! empty($conf->global->PRODUCT_USE_UNITS)) + { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); @@ -899,20 +941,17 @@ class pdf_canelle extends ModelePDFSuppliersInvoices } } - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); - if (empty($hidetop)) + if ($this->atleastonediscount) { - if ($this->atleastonediscount) + $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); + if (empty($hidetop)) { $pdf->SetXY($this->posxdiscount-1, $tab_top+1); $pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); } } - if ($this->atleastonediscount) - { - $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); - } + $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->postotalht-1, $tab_top+1); @@ -926,7 +965,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * Show payments table * * @param PDF $pdf Object PDF - * @param FactureFournisseur $object Object invoice + * @param Object $object Object to show * @param int $posy Position y in PDF * @param Translate $outputlangs Object langs for output * @return int <0 if KO, >0 if OK diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index a39c4621a80..b9961f56206 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -506,7 +506,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie /* * All unpayed supplier invoices */ - $sql = 'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.type, f.total_ht, f.total_ttc, f.multicurrency_total_ttc, f.datef as df, f.date_lim_reglement as dlr,'; + $sql = 'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.type, f.total_ht, f.total_ttc,'; + $sql.= ' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,'; + $sql.= ' f.datef as df, f.date_lim_reglement as dlr,'; $sql.= ' SUM(pf.amount) as am, SUM(pf.multicurrency_amount) as multicurrency_am'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; From 3b44760e65140889ef9632038702f220e9253088 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Nov 2019 14:10:07 +0100 Subject: [PATCH 063/299] FIX #12356 --- .../core/modules/supplier_invoice/pdf/pdf_canelle.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 2679f00d182..459b9109bce 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -218,7 +218,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices { $object->fetch_thirdparty(); - $deja_regle = $object->getSommePaiement(); + $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); //$amount_credit_notes_included = $object->getSumCreditNotesUsed(); //$amount_deposits_included = $object->getSumDepositsUsed(); From a901ce932dba9dbaec04aa608bf40f01e77b84b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Nov 2019 14:19:52 +0100 Subject: [PATCH 064/299] Repair --- htdocs/install/mysql/migration/repair.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index eac0d5b3bd9..69bdea770c9 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -71,6 +71,8 @@ UPDATE llx_user set api_key = null where api_key = ''; UPDATE llx_c_email_templates SET position = 0 WHERE position IS NULL; +-- DELETE FROM llx_c_email_templates WHERE label = '(SendAnEMailToMember)'; -- Now it is '(SendingAnEMailToMemner)' + -- delete foreign key that should never exists ALTER TABLE llx_propal DROP FOREIGN KEY fk_propal_fk_currency; From c574f5990f63de104d294e0262b060e01426607e Mon Sep 17 00:00:00 2001 From: altairis Date: Thu, 7 Nov 2019 14:31:30 +0100 Subject: [PATCH 065/299] add constant DISPATCH_FORCE_QTY_INPUT --- htdocs/fourn/commande/dispatch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index f7ade86eb64..90ccae61b31 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -780,7 +780,7 @@ if ($id > 0 || ! empty($ref)) { // Qty to dispatch print ''; - print ''; + print ''; print ''; print ''; From c7e261a973607ad250d3cbeb67d26cce8de26d5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Nov 2019 14:40:26 +0100 Subject: [PATCH 066/299] FIX #11907 --- htdocs/compta/facture/class/facture.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b5159683aaf..ed63af9753b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4645,6 +4645,8 @@ class FactureLigne extends CommonInvoiceLine public $marge_tx; public $marque_tx; + public $remise_percent; + public $special_code; // Liste d'options non cumulabels: // 1: frais de port // 2: ecotaxe From 8793fdfe63877e752ddcb976937c3f8e6b4274bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Nov 2019 15:25:57 +0100 Subject: [PATCH 067/299] Fix not working feature --- htdocs/takepos/css/pos.css | 4 ++++ htdocs/takepos/invoice.php | 11 +++++++---- htdocs/takepos/{printsend.php => send.php} | 12 +++++------- 3 files changed, 16 insertions(+), 11 deletions(-) rename htdocs/takepos/{printsend.php => send.php} (91%) diff --git a/htdocs/takepos/css/pos.css b/htdocs/takepos/css/pos.css index db3ddfdfa34..744838bf99d 100644 --- a/htdocs/takepos/css/pos.css +++ b/htdocs/takepos/css/pos.css @@ -6,6 +6,10 @@ html,body { width:100%; } +.center { + text-align: center; +} + button.calcbutton { display: inline-block; position: relative; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 2d14c11893d..6c60fbfd18c 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -451,7 +451,10 @@ if ($action=="valid" || $action=="history") } else { $sectionwithinvoicelink.=' '; } - $sectionwithinvoicelink.=' '; + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $sectionwithinvoicelink.=' '; + } if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink.=''; } @@ -537,11 +540,11 @@ if ($action == "search") { ?> }); - -function PrintSend(id) + +function SendTicket(id) { console.log("Open box to select the Print/Send form"); - $.colorbox({href:"printsend.php?facid="+id, width:"90%", height:"50%", transition:"none", iframe:"true", title:"trans("PrintSend");?>"}); + $.colorbox({href:"send.php?facid="+id, width:"90%", height:"50%", transition:"none", iframe:"true", title:"trans("SendTicket");?>"}); } function Print(id){ diff --git a/htdocs/takepos/printsend.php b/htdocs/takepos/send.php similarity index 91% rename from htdocs/takepos/printsend.php rename to htdocs/takepos/send.php index 6a2b672cf60..93fb753c2f3 100644 --- a/htdocs/takepos/printsend.php +++ b/htdocs/takepos/send.php @@ -70,7 +70,7 @@ $langs->loadLangs(array("main", "bills", "cashdesk")); ?> - + -
+
+
+
-
- - -
From 3677855ebc01d689a4c1b507fc1cd464e03d0d6e Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Thu, 7 Nov 2019 15:45:34 +0100 Subject: [PATCH 068/299] Fix ICAL export add a user to all events --- htdocs/comm/action/class/actioncomm.class.php | 60 ++++++++++++------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index a07e4ceba1a..4096175e87c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -824,35 +824,55 @@ class ActionComm extends CommonObject /** * Initialize this->userassigned array with list of id of user assigned to event * - * @return int <0 if KO, >0 if OK + * @param bool $override this->userownerid when empty + * @return int <0 if KO, >0 if OK */ - public function fetch_userassigned() + public function fetch_userassigned($override = true) { // phpcs:enable $sql ="SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency"; - $sql.=" FROM ".MAIN_DB_PREFIX."actioncomm_resources"; - $sql.=" WHERE element_type = 'user' AND fk_actioncomm = ".$this->id; - $resql2=$this->db->query($sql); - if ($resql2) - { - $this->userassigned=array(); + $sql.=" FROM ".MAIN_DB_PREFIX."actioncomm_resources"; + $sql.=" WHERE element_type = 'user' AND fk_actioncomm = ".$this->id; - // If owner is known, we must but id first into list - if ($this->userownerid > 0) $this->userassigned[$this->userownerid]=array('id'=>$this->userownerid); // Set first so will be first into list. + $resql2=$this->db->query($sql); + if ($resql2) + { + $this->userassigned = array(); + + // If owner is known, we must but id first into list + if ($this->userownerid > 0) + { + // Set first so will be first into list. + $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); + } while ($obj = $this->db->fetch_object($resql2)) { - if ($obj->fk_element > 0) $this->userassigned[$obj->fk_element]=array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); - if (empty($this->userownerid)) $this->userownerid=$obj->fk_element; // If not defined (should not happened, we fix this) + if ($obj->fk_element > 0) + { + $this->userassigned[$obj->fk_element] = array('id'=>$obj->fk_element, + 'mandatory'=>$obj->mandatory, + 'answer_status'=>$obj->answer_status, + 'transparency'=>$obj->transparency); + } + + if($override === true) + { + // If not defined (should not happened, we fix this) + if (empty($this->userownerid)) + { + $this->userownerid = $obj->fk_element; + } + } } - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } } /** @@ -1676,7 +1696,7 @@ class ActionComm extends CommonObject // TODO: find a way to call "$this->fetch_userassigned();" without override "$this" properties $this->id = $obj->id; - $this->fetch_userassigned(); + $this->fetch_userassigned(false); $assignedUserArray = array(); From 8318db85a318970b5ddfc2d7195840c40a33590f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Nov 2019 16:32:44 +0100 Subject: [PATCH 069/299] Fix typo --- ChangeLog | 2 +- htdocs/core/lib/pdf.lib.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2d398c83535..1ce34b5e87a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,7 +24,7 @@ Following changes may create regressions for some external modules, but were nec * Removed function dol_micro_time. Use native PHP microtime instead. * The trigger BON_PRELEVEMENT_CREATE has been renamed into DIRECT_DEBIT_ORDER_CREATE. * The constant INVOICE_SHOW_POS_IN_EXPORT has been renamed into INVOICE_SHOW_POS. -* If your logo was visible on the menu bar, you must upload a new logo into 'Home-Setup-Company/Organization' to have it visible agin in menu. +* If your logo is no more visible on the menu bar, you must upload a new logo into 'Home-Setup-Company/Organization' to have it visible again. * All properties 'libstatut', 'labelstatut', 'labelstatus' were renamed into 'labelStatus'. * All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'. * All properties 'type_libelle' were renamed into 'type_label'. diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 918b5ebb6a3..619a9c7d488 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -416,6 +416,7 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t if ($sourcecompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); } // Professionnal Ids + $reg = array(); if (! empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof1)) { $tmp=$outputlangs->transcountrynoentities("ProfId1", $sourcecompany->country_code); @@ -452,6 +453,9 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6); } + if (! empty($conf->global->PDF_ADD_MORE_AFTER_ADDRESS)) { + $stringaddress.=($stringaddress ? "\n" : '' ).$conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS; + } } if ($mode == 'target' || preg_match('/targetwithdetails/', $mode)) From 34beca0758444f1e936a61be6dbd5c5bc3e6cf61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Nov 2019 16:33:11 +0100 Subject: [PATCH 070/299] Fix var not not consistent --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 619a9c7d488..cac2208eb2f 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -453,7 +453,7 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6); } - if (! empty($conf->global->PDF_ADD_MORE_AFTER_ADDRESS)) { + if (! empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) { $stringaddress.=($stringaddress ? "\n" : '' ).$conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS; } } From ba1f4f0ac6e2632df8436ff61df05c9ac8980171 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Nov 2019 16:40:59 +0100 Subject: [PATCH 071/299] Fix look and feel v11 --- .../cheque/class/remisecheque.class.php | 60 +++++++------------ 1 file changed, 20 insertions(+), 40 deletions(-) diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 6f0438644a6..220cf93c180 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -65,6 +65,10 @@ class RemiseCheque extends CommonObject */ public $ref; + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + + /** * Constructor * @@ -1072,50 +1076,26 @@ class RemiseCheque extends CommonObject /** * Return label of a status * - * @param int $status Statut + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @return string Libelle du statut */ public function LibStatut($status, $mode = 0) { - // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage - $langs->load('compta'); - if ($mode == 0) - { - if ($status == 0) return $langs->trans('ToValidate'); - elseif ($status == 1) return $langs->trans('Validated'); - } - elseif ($mode == 1) - { - if ($status == 0) return $langs->trans('ToValidate'); - elseif ($status == 1) return $langs->trans('Validated'); - } - elseif ($mode == 2) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'), 'statut0').' '.$langs->trans('ToValidate'); - elseif ($status == 1) return img_picto($langs->trans('Validated'), 'statut4').' '.$langs->trans('Validated'); - } - elseif ($mode == 3) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'), 'statut0'); - elseif ($status == 1) return img_picto($langs->trans('Validated'), 'statut4'); - } - elseif ($mode == 4) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'), 'statut0').' '.$langs->trans('ToValidate'); - elseif ($status == 1) return img_picto($langs->trans('Validated'), 'statut4').' '.$langs->trans('Validated'); - } - elseif ($mode == 5) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'), 'statut0'); - elseif ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'), 'statut4'); - } - elseif ($mode == 6) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'), 'statut0'); - elseif ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'), 'statut4'); - } - return $langs->trans('Unknown'); + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) + { + global $langs; + $langs->load('compta'); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('ToValidate'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('ToValidate'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Validated'); + } + + $statusType = 'status'.$status; + if ($status == self::STATUS_VALIDATED) $statusType = 'status4'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } } From a641c81d92c6f511fb744d63e6df1e81fba7adbc Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 7 Nov 2019 17:05:30 +0100 Subject: [PATCH 072/299] FIX socialnetworks API if module not active --- htdocs/api/class/api_setup.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index b32eea1f57f..2e52c6af32f 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1095,7 +1095,11 @@ class Setup extends DolibarrApi */ public function getListOfsocialNetworks($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { - $list = array(); + if (empty($conf->global->MAIN_MODULE_SOCIALNETWORKS)) { + throw new RestException(400, 'API not available: this dictionary is not enabled by setup'); + } + + $list = array(); //TODO link with multicurrency module $sql = "SELECT t.rowid, t.entity, t.code, t.label, t.url, t.icon, t.active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_socialnetworks as t"; From a3878d82e9d1be9edfd110109d2d2eca28719651 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 7 Nov 2019 16:06:58 +0000 Subject: [PATCH 073/299] Fixing style errors. --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 2e52c6af32f..a74f8e8ec79 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1098,7 +1098,7 @@ class Setup extends DolibarrApi if (empty($conf->global->MAIN_MODULE_SOCIALNETWORKS)) { throw new RestException(400, 'API not available: this dictionary is not enabled by setup'); } - + $list = array(); //TODO link with multicurrency module $sql = "SELECT t.rowid, t.entity, t.code, t.label, t.url, t.icon, t.active"; From 4145d7c8259b5d323d6b3c249b61dcbd2634745b Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 7 Nov 2019 17:18:39 +0100 Subject: [PATCH 074/299] Update api_setup.class.php --- htdocs/api/class/api_setup.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index a74f8e8ec79..a264288c111 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1095,7 +1095,9 @@ class Setup extends DolibarrApi */ public function getListOfsocialNetworks($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { - if (empty($conf->global->MAIN_MODULE_SOCIALNETWORKS)) { + global $conf; + + if (empty($conf->socialnetworks->enabled)) { throw new RestException(400, 'API not available: this dictionary is not enabled by setup'); } From b0d62c5c9b9d690afd3532a88c922a4535b2e067 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Nov 2019 18:54:30 +0100 Subject: [PATCH 075/299] Update lib --- composer.json | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index a3407d7fa20..86acd2f8d60 100644 --- a/composer.json +++ b/composer.json @@ -24,10 +24,10 @@ "vendor-dir" : "htdocs/includes" }, "require" : { - "php" : ">=5.3.0", + "php" : ">=5.5.0", "ext-curl" : "*", "ckeditor/ckeditor" : "4.12.1", - "mike42/escpos-php" : "1.2.1", + "mike42/escpos-php" : "2.2", "mobiledetect/mobiledetectlib" : "2.8.33", "phpoffice/phpexcel" : "1.8.1", "restler/framework" : "3.0.0-RC6", @@ -48,13 +48,12 @@ "ext-mssql" : "To use with MSSQL (experimental)", "ext-pdo_sqlite" : "To use with SQLite (experimental)", "ext-gd" : "Image manipulation (Required but maybe built-in PHP)", - "ext-imagick" : "Image manipulation (TCPDF)", + "ext-imagick" : "Generation of thumbs from PDF", "ext-mcrypt" : "(Required but maybe built-in PHP)", "ext-openssl" : "Secure connections (Emails, SOAP\u2026)", - "ext-mbstring" : "Handle non UTF-8 databases", + "ext-mbstring" : "Handle non UTF-8 characters", "ext-soap" : "Native SOAP", - "ext-zip" : "ODT and Excel support", - "ext-xml" : "Excel support", - "firephp/firephp-core" : "Logging to Firebug console support" + "ext-zip" : "ODT, Excel and file compression support", + "ext-xml" : "Excel support" } } \ No newline at end of file From f11943126a638783a740258c8f77426366db48db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Nov 2019 09:42:39 +0100 Subject: [PATCH 076/299] Fix scrutinizer --- htdocs/core/tpl/document_actions_post_headers.tpl.php | 2 +- htdocs/product/inventory/class/inventory.class.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index 692c9cf3494..9fe6946d89d 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -120,5 +120,5 @@ $formfile->list_of_documents( print "
"; //List of links -$formfile->listOfLinks($object, $permission, $action, GETPOST('linkid', 'int'), $param, $relativepathwithnofile); +$formfile->listOfLinks($object, $permission, $action, GETPOST('linkid', 'int'), $param); print "
"; diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index e93942d16d4..be6ca6aa930 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -396,6 +396,7 @@ class Inventory extends CommonObject // phpcs:enable global $langs; + $labelStatus = array(); $labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); $labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); $labelStatus[self::STATUS_CANCELED] = $langs->trans('Canceled'); From d1c49c70210c0825208fd0c21f796d41d7523433 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Nov 2019 10:24:03 +0100 Subject: [PATCH 077/299] Fix trans --- htdocs/core/lib/payments.lib.php | 9 ++++++- htdocs/langs/en_US/paybox.lang | 1 - htdocs/langs/en_US/stripe.lang | 2 +- htdocs/public/payment/newpayment.php | 36 +++++++--------------------- 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 75e2ee08b8f..568da82368f 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -97,22 +97,28 @@ function payment_supplier_prepare_head(Paiement $object) */ function getValidOnlinePaymentMethods($paymentmethod = '') { - global $conf; + global $conf, $langs; $validpaymentmethod=array(); if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled)) { + $langs->load("paypal"); $validpaymentmethod['paypal']='valid'; } if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled)) { + $langs->load("paybox"); $validpaymentmethod['paybox']='valid'; } if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled)) { + $langs->load("stripe"); $validpaymentmethod['stripe']='valid'; } + // TODO Add trigger + + return $validpaymentmethod; } @@ -173,6 +179,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); } + //if ($mode) $out.='&noidempotency=1'; } elseif ($type == 'order') { diff --git a/htdocs/langs/en_US/paybox.lang b/htdocs/langs/en_US/paybox.lang index 35216661140..ec722c990a4 100644 --- a/htdocs/langs/en_US/paybox.lang +++ b/htdocs/langs/en_US/paybox.lang @@ -20,7 +20,6 @@ ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment user ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user interface for a free amount ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription ToOfferALinkForOnlinePaymentOnDonation=URL to offer a %s online payment, user interface for payment of donation -YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (required only for free payment) to add your own payment comment tag. SetupPayBoxToHavePaymentCreatedAutomatically=Setup your Paybox with url %s to have payment created automatically when validated by Paybox. YourPaymentHasBeenRecorded=This page confirms that your payment has been recorded. Thank you. YourPaymentHasNotBeenRecorded=Your payment has NOT been recorded and the transaction has been canceled. Thank you. diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index 6905bd41b20..583ef309727 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -21,7 +21,7 @@ ToOfferALinkForOnlinePaymentOnInvoice=URL to offer a %s online payment user inte ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment user interface for a contract line ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user interface for a free amount ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription -YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (required only for free payment) to add your own payment comment tag. +YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (mandatory only for free payment) to add your own payment comment tag.
For free payment, you may also add the parameter &noidempotency=1 so the same link with same tag can be used several times (some payment mode may limit the payment to 1 for each different link without this parameter) SetupStripeToHavePaymentCreatedAutomatically=Setup your Stripe with url %s to have payment created automatically when validated by Stripe. AccountParameter=Account parameters UsageParameter=Usage parameters diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 4a3d08f6602..d292809eda8 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -63,10 +63,10 @@ $action=GETPOST('action', 'aZ09'); // tag (a free text, required if type is empty) // currency (iso code) -$suffix=GETPOST("suffix", 'aZ09'); -$amount=price2num(GETPOST("amount", 'alpha')); -if (! GETPOST("currency", 'alpha')) $currency=$conf->currency; -else $currency=GETPOST("currency", 'alpha'); +$suffix = GETPOST("suffix", 'aZ09'); +$amount = price2num(GETPOST("amount", 'alpha')); +if (! GETPOST("currency", 'alpha')) $currency = $conf->currency; +else $currency = GETPOST("currency", 'alpha'); $source = GETPOST("s", 'alpha')?GETPOST("s", 'alpha'):GETPOST("source", 'alpha'); $download = GETPOST('d', 'int')?GETPOST('d', 'int'):GETPOST('download', 'int'); @@ -159,7 +159,7 @@ $urlko=preg_replace('/&$/', '', $urlko); // Remove last & -// Find valid payment methods +// Make special controls if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled)) { @@ -186,36 +186,18 @@ if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->payp dol_print_error('', "Paypal setup param PAYPAL_API_SIGNATURE not defined"); return -1; } - - $validpaymentmethod['paypal']='valid'; } - if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled)) { - $langs->load("paybox"); - - // TODO Chek setup is complete - - $validpaymentmethod['paybox']='valid'; + // No specific test for the moment } - if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled)) { - $langs->load("stripe"); - - require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'; - /* already included into /stripe/config.php - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; - */ - - $validpaymentmethod['stripe']='valid'; + require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'; // This include also /stripe/lib/stripe.lib.php, /includes/stripe/init.php, ... } -// TODO Replace previous set of $validpaymentmethod with this line: -//$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod); +// Initialize $validpaymentmethod +$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod); // Check security token From ad2ff551fa86bb6f87c32348eb968ee0f0a27206 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Nov 2019 10:35:34 +0100 Subject: [PATCH 078/299] Fix trans --- htdocs/langs/en_US/paybox.lang | 7 ------- htdocs/langs/en_US/stripe.lang | 13 +++++++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/htdocs/langs/en_US/paybox.lang b/htdocs/langs/en_US/paybox.lang index ec722c990a4..f70b3ee92eb 100644 --- a/htdocs/langs/en_US/paybox.lang +++ b/htdocs/langs/en_US/paybox.lang @@ -13,13 +13,6 @@ PaymentCode=Payment code PayBoxDoPayment=Pay with Paybox YouWillBeRedirectedOnPayBox=You will be redirected on secured Paybox page to input you credit card information Continue=Next -ToOfferALinkForOnlinePayment=URL for %s payment -ToOfferALinkForOnlinePaymentOnOrder=URL to offer a %s online payment user interface for a sales order -ToOfferALinkForOnlinePaymentOnInvoice=URL to offer a %s online payment user interface for a customer invoice -ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment user interface for a contract line -ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user interface for a free amount -ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription -ToOfferALinkForOnlinePaymentOnDonation=URL to offer a %s online payment, user interface for payment of donation SetupPayBoxToHavePaymentCreatedAutomatically=Setup your Paybox with url %s to have payment created automatically when validated by Paybox. YourPaymentHasBeenRecorded=This page confirms that your payment has been recorded. Thank you. YourPaymentHasNotBeenRecorded=Your payment has NOT been recorded and the transaction has been canceled. Thank you. diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index 583ef309727..92fe1051f08 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -16,12 +16,13 @@ StripeDoPayment=Pay with Stripe YouWillBeRedirectedOnStripe=You will be redirected on secured Stripe page to input you credit card information Continue=Next ToOfferALinkForOnlinePayment=URL for %s payment -ToOfferALinkForOnlinePaymentOnOrder=URL to offer a %s online payment user interface for a sales order -ToOfferALinkForOnlinePaymentOnInvoice=URL to offer a %s online payment user interface for a customer invoice -ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment user interface for a contract line -ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user interface for a free amount -ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription -YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (mandatory only for free payment) to add your own payment comment tag.
For free payment, you may also add the parameter &noidempotency=1 so the same link with same tag can be used several times (some payment mode may limit the payment to 1 for each different link without this parameter) +ToOfferALinkForOnlinePaymentOnOrder=URL to offer a %s online payment page for a sales order +ToOfferALinkForOnlinePaymentOnInvoice=URL to offer a %s online payment page for a customer invoice +ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment page for a contract line +ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment page of any amount with no existing object +ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment page for a member subscription +ToOfferALinkForOnlinePaymentOnDonation=URL to offer a %s online payment page for payment of a donation +YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (mandatory only for payment not linked to an object) to add your own payment comment tag.
For the URL of payments with no existing object, you may also add the parameter &noidempotency=1 so the same link with same tag can be used several times (some payment mode may limit the payment to 1 for each different link without this parameter) SetupStripeToHavePaymentCreatedAutomatically=Setup your Stripe with url %s to have payment created automatically when validated by Stripe. AccountParameter=Account parameters UsageParameter=Usage parameters From 2ecfe418105003fbc0d1d629c342a67faeb946fb Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Fri, 8 Nov 2019 09:53:31 +0000 Subject: [PATCH 079/299] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/compta/bank/categ.php | 14 +- htdocs/compta/facture/class/facture.class.php | 2466 ++++++++--------- htdocs/compta/localtax/clients.php | 184 +- htdocs/compta/prelevement/card.php | 64 +- htdocs/compta/prelevement/fiche-rejet.php | 42 +- htdocs/compta/prelevement/fiche-stat.php | 24 +- htdocs/compta/stats/byratecountry.php | 322 +-- htdocs/fourn/commande/orderstoinvoice.php | 208 +- htdocs/fourn/facture/card.php | 1012 +++---- htdocs/fourn/product/list.php | 90 +- htdocs/product/fournisseurs.php | 298 +- .../product/stock/class/productlot.class.php | 178 +- htdocs/product/stock/massstockmove.php | 130 +- htdocs/product/stock/product.php | 444 +-- htdocs/product/stock/replenish.php | 344 +-- htdocs/reception/list.php | 506 ++-- htdocs/resource/card.php | 66 +- htdocs/resource/element_resource.php | 252 +- htdocs/user/card.php | 594 ++-- .../accountancy/export-thirdpartyaccount.php | 96 +- 20 files changed, 3667 insertions(+), 3667 deletions(-) diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 377feaa0cae..a343d09ddc2 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -33,8 +33,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories')); -$action=GETPOST('action', 'aZ09'); -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09'); +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') if (!$user->rights->banque->configurer) accessforbidden(); @@ -92,7 +92,7 @@ print ''; print ''; */ -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; @@ -109,9 +109,9 @@ if ($action != 'edit') $sql = "SELECT rowid, label"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; -$sql.= " WHERE entity = ".$conf->entity; -$sql.= " ORDER BY label"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank_categ"; +$sql .= " WHERE entity = ".$conf->entity; +$sql .= " ORDER BY label"; $result = $db->query($sql); if ($result) @@ -125,7 +125,7 @@ if ($result) print ''; print ''; - if (GETPOST('action', 'aZ09') == 'edit' && GETPOST("categid")== $objp->rowid) + if (GETPOST('action', 'aZ09') == 'edit' && GETPOST("categid") == $objp->rowid) { print "'; - print ''; + print ''; + print ''; print ''; // Multicurrency Amount VAT - print ''; - print ''; + print ''; + print ''; print ''; // Multicurrency Amount TTC - print ''; - print ''; + print ''; + print ''; print ''; } // Amount print ''; print ''; // Amount Local Taxes //TODO: Place into a function to control showing by country or study better option - if ($societe->localtax1_assuj=="1") //Localtax1 + if ($societe->localtax1_assuj == "1") //Localtax1 { print ''; print ''; print ''; } - if ($societe->localtax2_assuj=="1") //Localtax2 + if ($societe->localtax2_assuj == "1") //Localtax2 { print ''; print ''; @@ -2708,27 +2708,27 @@ else $sign = 1; if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = - 1; - $nbrows=9; $nbcols=3; - if (! empty($conf->projet->enabled)) $nbrows++; - if (! empty($conf->banque->enabled)) { $nbrows++; $nbcols++; } - if (! empty($conf->incoterm->enabled)) $nbrows++; - if (! empty($conf->multicurrency->enabled)) $nbrows += 5; + $nbrows = 9; $nbcols = 3; + if (!empty($conf->projet->enabled)) $nbrows++; + if (!empty($conf->banque->enabled)) { $nbrows++; $nbcols++; } + if (!empty($conf->incoterm->enabled)) $nbrows++; + if (!empty($conf->multicurrency->enabled)) $nbrows += 5; // Local taxes - if ($societe->localtax1_assuj=="1") $nbrows++; - if ($societe->localtax2_assuj=="1") $nbrows++; + if ($societe->localtax1_assuj == "1") $nbrows++; + if ($societe->localtax2_assuj == "1") $nbrows++; $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; - $sql.= ' c.id as paiement_type,'; - $sql.= ' pf.amount,'; - $sql.= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; - $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; - $sql.= ' ORDER BY p.datep, p.tms'; + $sql .= ' c.id as paiement_type,'; + $sql .= ' pf.amount,'; + $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; + $sql .= ' WHERE pf.fk_facturefourn = '.$object->id; + $sql .= ' ORDER BY p.datep, p.tms'; $result = $db->query($sql); if ($result) @@ -2739,10 +2739,10 @@ else print '
'; print '
'.$langs->trans("Ref").''.$langs->trans("Label").'
'.$objp->rowid.'"; print ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ed63af9753b..df41f2e5595 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -45,8 +45,8 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; /** * Class to manage invoices @@ -56,12 +56,12 @@ class Facture extends CommonInvoice /** * @var string ID to identify managed object */ - public $element='facture'; + public $element = 'facture'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='facture'; + public $table_element = 'facture'; /** * @var int Name of subtable line @@ -76,7 +76,7 @@ class Facture extends CommonInvoice /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='bill'; + public $picto = 'bill'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -109,7 +109,7 @@ class Facture extends CommonInvoice */ public $fk_user_valid; - public $date; // Date invoice + public $date; // Date invoice public $datem; public $ref_client; public $ref_int; @@ -119,11 +119,11 @@ class Facture extends CommonInvoice //var $amount; public $remise_absolue; public $remise_percent; - public $total_ht=0; - public $total_tva=0; - public $total_localtax1=0; - public $total_localtax2=0; - public $total_ttc=0; + public $total_ht = 0; + public $total_tva = 0; + public $total_localtax1 = 0; + public $total_localtax2 = 0; + public $total_ttc = 0; public $revenuestamp; //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon @@ -141,10 +141,10 @@ class Facture extends CommonInvoice public $fk_fac_rec_source; //! id of source invoice if replacement invoice or credit note public $fk_facture_source; - public $linked_objects=array(); + public $linked_objects = array(); public $date_lim_reglement; - public $cond_reglement_code; // Code in llx_c_paiement - public $mode_reglement_code; // Code in llx_c_paiement + public $cond_reglement_code; // Code in llx_c_paiement + public $mode_reglement_code; // Code in llx_c_paiement /** * @var int ID Field to store bank id to use when payment mode is withdraw @@ -154,15 +154,15 @@ class Facture extends CommonInvoice /** * @deprecated */ - public $products=array(); + public $products = array(); /** * @var FactureLigne[] */ - public $lines=array(); + public $lines = array(); public $line; - public $extraparams=array(); + public $extraparams = array(); public $specimen; public $fac_rec; @@ -197,12 +197,12 @@ class Facture extends CommonInvoice /** * @var array Table of previous situations */ - public $tab_previous_situation_invoice=array(); + public $tab_previous_situation_invoice = array(); /** * @var array Table of next situations */ - public $tab_next_situation_invoice=array(); + public $tab_next_situation_invoice = array(); public $oldcopy; @@ -279,10 +279,10 @@ class Facture extends CommonInvoice */ const STATUS_ABANDONED = 3; - const CLOSECODE_DISCOUNTVAT = 'discount_vat'; // Abandonned remain - escompte - const CLOSECODE_BADDEBT = 'badcustomer'; // Abandonned - bad - const CLOSECODE_ABANDONED = 'abandon'; // Abandonned - other - const CLOSECODE_REPLACED = 'replaced'; // Closed after doing a replacement invoice + const CLOSECODE_DISCOUNTVAT = 'discount_vat'; // Abandonned remain - escompte + const CLOSECODE_BADDEBT = 'badcustomer'; // Abandonned - bad + const CLOSECODE_ABANDONED = 'abandon'; // Abandonned - other + const CLOSECODE_REPLACED = 'replaced'; // Closed after doing a replacement invoice /** * Constructor @@ -306,21 +306,21 @@ class Facture extends CommonInvoice */ public function create(User $user, $notrigger = 0, $forceduedate = 0) { - global $langs,$conf,$mysoc,$hookmanager; - $error=0; + global $langs, $conf, $mysoc, $hookmanager; + $error = 0; // Clean parameters if (empty($this->type)) $this->type = self::TYPE_STANDARD; - $this->ref_client=trim($this->ref_client); - $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated - $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); - $this->note_public=trim($this->note_public); - if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; - if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; + $this->ref_client = trim($this->ref_client); + $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note_private)); + $this->note_public = trim($this->note_public); + if (!$this->cond_reglement_id) $this->cond_reglement_id = 0; + if (!$this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) { @@ -334,26 +334,26 @@ class Facture extends CommonInvoice // Check parameters if (empty($this->date)) { - $this->error="Try to create an invoice with an empty parameter (date)"; + $this->error = "Try to create an invoice with an empty parameter (date)"; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -3; } $soc = new Societe($this->db); - $result=$soc->fetch($this->socid); + $result = $soc->fetch($this->socid); if ($result < 0) { - $this->error="Failed to fetch company: ".$soc->error; + $this->error = "Failed to fetch company: ".$soc->error; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -2; } - $now=dol_now(); + $now = dol_now(); $this->db->begin(); - $originaldatewhen=null; - $nextdatewhen=null; - $previousdaynextdatewhen=null; + $originaldatewhen = null; + $nextdatewhen = null; + $previousdaynextdatewhen = null; // Create invoice from a template invoice if ($this->fac_rec > 0) @@ -362,17 +362,17 @@ class Facture extends CommonInvoice require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; $_facrec = new FactureRec($this->db); - $result=$_facrec->fetch($this->fac_rec); - $result=$_facrec->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); // This load $_facrec->linkedObjectsIds + $result = $_facrec->fetch($this->fac_rec); + $result = $_facrec->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); // This load $_facrec->linkedObjectsIds // Define some dates $originaldatewhen = $_facrec->date_when; - $nextdatewhen=dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); - $previousdaynextdatewhen=dol_time_plus_duree($nextdatewhen, -1, 'd'); + $nextdatewhen = dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); + $previousdaynextdatewhen = dol_time_plus_duree($nextdatewhen, -1, 'd'); - if (! empty($_facrec->frequency)) // Invoice are created on same thirdparty than template when there is a recurrence, but not necessarly when there is no recurrence. + if (!empty($_facrec->frequency)) // Invoice are created on same thirdparty than template when there is a recurrence, but not necessarly when there is no recurrence. { - $this->socid = $_facrec->socid; + $this->socid = $_facrec->socid; } $this->entity = $_facrec->entity; // Invoice created in same entity than template @@ -392,20 +392,20 @@ class Facture extends CommonInvoice // Fields always coming from template $this->remise_absolue = $_facrec->remise_absolue; $this->remise_percent = $_facrec->remise_percent; - $this->fk_incoterms = $_facrec->fk_incoterms; - $this->location_incoterms= $_facrec->location_incoterms; + $this->fk_incoterms = $_facrec->fk_incoterms; + $this->location_incoterms = $_facrec->location_incoterms; // Clean parameters - if (! $this->type) $this->type = self::TYPE_STANDARD; - $this->ref_client=trim($this->ref_client); - $this->note_public=trim($this->note_public); - $this->note_private=trim($this->note_private); - $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); + if (!$this->type) $this->type = self::TYPE_STANDARD; + $this->ref_client = trim($this->ref_client); + $this->note_public = trim($this->note_public); + $this->note_private = trim($this->note_private); + $this->note_private = dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); - $this->array_options=$_facrec->array_options; + $this->array_options = $_facrec->array_options; //if (! $this->remise) $this->remise = 0; - if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; + if (!$this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; $this->linked_objects = $_facrec->linkedObjectsIds; @@ -419,7 +419,7 @@ class Facture extends CommonInvoice { dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); if (empty($_facrec->date_when)) $_facrec->date_when = $now; - $next_date = $_facrec->getNextDate(); // Calculate next date + $next_date = $_facrec->getNextDate(); // Calculate next date $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. $result = $_facrec->setNextDate($next_date, 1); @@ -427,18 +427,18 @@ class Facture extends CommonInvoice // Define lang of customer $outputlangs = $langs; - $newlang=''; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang=$this->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang=$this->default_lang; // for thirdparty - if (! empty($newlang)) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang = $this->default_lang; // for thirdparty + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $this); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $this); $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'); $substitutionarray['__INVOICE_MONTH__'] = dol_print_date($this->date, '%m'); $substitutionarray['__INVOICE_NEXT_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'); @@ -457,8 +457,8 @@ class Facture extends CommonInvoice complete_substitutions_array($substitutionarray, $outputlangs); - $this->note_public=make_substitutions($this->note_public, $substitutionarray); - $this->note_private=make_substitutions($this->note_private, $substitutionarray); + $this->note_public = make_substitutions($this->note_public, $substitutionarray); + $this->note_private = make_substitutions($this->note_private, $substitutionarray); } // Define due date if not already defined @@ -474,103 +474,103 @@ class Facture extends CommonInvoice } // Insert into database - $socid = $this->socid; + $socid = $this->socid; $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture ("; - $sql.= " ref"; - $sql.= ", entity"; - $sql.= ", ref_ext"; - $sql.= ", type"; - $sql.= ", fk_soc"; - $sql.= ", datec"; - $sql.= ", remise_absolue"; - $sql.= ", remise_percent"; - $sql.= ", datef"; - $sql.= ", date_pointoftax"; - $sql.= ", note_private"; - $sql.= ", note_public"; - $sql.= ", ref_client, ref_int"; - $sql.= ", fk_account"; - $sql.= ", module_source, pos_source, fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; - $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; - $sql.= ", situation_cycle_ref, situation_counter, situation_final"; - $sql.= ", fk_incoterms, location_incoterms"; - $sql.= ", fk_multicurrency"; - $sql.= ", multicurrency_code"; - $sql.= ", multicurrency_tx"; - $sql.= ", retained_warranty"; - $sql.= ", retained_warranty_date_limit"; - $sql.= ", retained_warranty_fk_cond_reglement"; - $sql.= ")"; - $sql.= " VALUES ("; - $sql.= "'(PROV)'"; - $sql.= ", ".setEntity($this); - $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); - $sql.= ", '".$this->db->escape($this->type)."'"; - $sql.= ", '".$socid."'"; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".($this->remise_absolue>0?$this->remise_absolue:'NULL'); - $sql.= ", ".($this->remise_percent>0?$this->remise_percent:'NULL'); - $sql.= ", '".$this->db->idate($this->date)."'"; - $sql.= ", ".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null'); - $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); - $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); - $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); - $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); - $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); - $sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); - $sql.= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); - $sql.= ", ".($this->fk_fac_rec_source?"'".$this->db->escape($this->fk_fac_rec_source)."'":"null"); - $sql.= ", ".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); - $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); - $sql.= ", ".($this->fk_project?$this->fk_project:"null"); - $sql.= ", ".$this->cond_reglement_id; - $sql.= ", ".$this->mode_reglement_id; - $sql.= ", '".$this->db->idate($this->date_lim_reglement)."', '".$this->db->escape($this->modelpdf)."'"; - $sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null"); - $sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"); - $sql.= ", ".($this->situation_final?$this->situation_final:0); - $sql.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".(double) $this->multicurrency_tx; - $sql.= ", ".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)); - $sql.= ", ".(!empty($this->retained_warranty_date_limit)?"'".$this->db->idate($this->retained_warranty_date_limit)."'":'NULL'); - $sql.= ", ".(int) $this->retained_warranty_fk_cond_reglement; + $sql .= " ref"; + $sql .= ", entity"; + $sql .= ", ref_ext"; + $sql .= ", type"; + $sql .= ", fk_soc"; + $sql .= ", datec"; + $sql .= ", remise_absolue"; + $sql .= ", remise_percent"; + $sql .= ", datef"; + $sql .= ", date_pointoftax"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", ref_client, ref_int"; + $sql .= ", fk_account"; + $sql .= ", module_source, pos_source, fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; + $sql .= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; + $sql .= ", situation_cycle_ref, situation_counter, situation_final"; + $sql .= ", fk_incoterms, location_incoterms"; + $sql .= ", fk_multicurrency"; + $sql .= ", multicurrency_code"; + $sql .= ", multicurrency_tx"; + $sql .= ", retained_warranty"; + $sql .= ", retained_warranty_date_limit"; + $sql .= ", retained_warranty_fk_cond_reglement"; + $sql .= ")"; + $sql .= " VALUES ("; + $sql .= "'(PROV)'"; + $sql .= ", ".setEntity($this); + $sql .= ", ".($this->ref_ext ? "'".$this->db->escape($this->ref_ext)."'" : "null"); + $sql .= ", '".$this->db->escape($this->type)."'"; + $sql .= ", '".$socid."'"; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".($this->remise_absolue > 0 ? $this->remise_absolue : 'NULL'); + $sql .= ", ".($this->remise_percent > 0 ? $this->remise_percent : 'NULL'); + $sql .= ", '".$this->db->idate($this->date)."'"; + $sql .= ", ".(strval($this->date_pointoftax) != '' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null'); + $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); + $sql .= ", ".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null"); + $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); + $sql .= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); + $sql .= ", ".($this->fk_fac_rec_source ? "'".$this->db->escape($this->fk_fac_rec_source)."'" : "null"); + $sql .= ", ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null"); + $sql .= ", ".($user->id > 0 ? "'".$user->id."'" : "null"); + $sql .= ", ".($this->fk_project ? $this->fk_project : "null"); + $sql .= ", ".$this->cond_reglement_id; + $sql .= ", ".$this->mode_reglement_id; + $sql .= ", '".$this->db->idate($this->date_lim_reglement)."', '".$this->db->escape($this->modelpdf)."'"; + $sql .= ", ".($this->situation_cycle_ref ? "'".$this->db->escape($this->situation_cycle_ref)."'" : "null"); + $sql .= ", ".($this->situation_counter ? "'".$this->db->escape($this->situation_counter)."'" : "null"); + $sql .= ", ".($this->situation_final ? $this->situation_final : 0); + $sql .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".(double) $this->multicurrency_tx; + $sql .= ", ".(empty($this->retained_warranty) ? "0" : $this->db->escape($this->retained_warranty)); + $sql .= ", ".(!empty($this->retained_warranty_date_limit) ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'NULL'); + $sql .= ", ".(int) $this->retained_warranty_fk_cond_reglement; - $sql.=")"; + $sql .= ")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture'); // Update ref with new one - $this->ref='(PROV'.$this->id.')'; + $this->ref = '(PROV'.$this->id.')'; $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; - $resql=$this->db->query($sql); - if (! $resql) $error++; + $resql = $this->db->query($sql); + if (!$resql) $error++; - if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) { - foreach($this->linked_objects as $origin => $tmp_origin_id) + foreach ($this->linked_objects as $origin => $tmp_origin_id) { if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) { - foreach($tmp_origin_id as $origin_id) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -579,9 +579,9 @@ class Facture extends CommonInvoice { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -589,13 +589,13 @@ class Facture extends CommonInvoice } // Propagate contacts - if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object { $originforcontact = $this->origin; $originidforcontact = $this->origin_id; if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order { - require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $exp = new Expedition($this->db); $exp->fetch($this->origin_id); $exp->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); @@ -612,15 +612,15 @@ class Facture extends CommonInvoice } $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; + $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { - while($objcontact = $this->db->fetch_object($resqlcontact)) + while ($objcontact = $this->db->fetch_object($resqlcontact)) { //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object } } else dol_print_error($resqlcontact); @@ -629,15 +629,15 @@ class Facture extends CommonInvoice /* * Insert lines of invoices, if not from template invoice, into database */ - if (! $error && empty($this->fac_rec) && count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode) + if (!$error && empty($this->fac_rec) && count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode) { $fk_parent_line = 0; dol_syslog("There is ".count($this->lines)." lines that are invoice lines objects"); foreach ($this->lines as $i => $val) { - $newinvoiceline=$this->lines[$i]; - $newinvoiceline->fk_facture=$this->id; + $newinvoiceline = $this->lines[$i]; + $newinvoiceline->fk_facture = $this->id; $newinvoiceline->origin = $this->lines[$i]->element; $newinvoiceline->origin_id = $this->lines[$i]->id; @@ -659,9 +659,9 @@ class Facture extends CommonInvoice $fk_parent_line = 0; } - $newinvoiceline->fk_parent_line=$fk_parent_line; + $newinvoiceline->fk_parent_line = $fk_parent_line; - if($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except){ + if ($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { $discount = new DiscountAbsolute($this->db); $discount->fetch($newinvoiceline->fk_remise_except); @@ -669,7 +669,7 @@ class Facture extends CommonInvoice $newinvoiceline->fk_remise_except = $discountId; } - $result=$newinvoiceline->insert(); + $result = $newinvoiceline->insert(); // Defined the new fk_parent_line if ($result > 0 && $newinvoiceline->product_type == 9) { @@ -678,13 +678,13 @@ class Facture extends CommonInvoice } if ($result < 0) { - $this->error=$newinvoiceline->error; + $this->error = $newinvoiceline->error; $error++; break; } } } - elseif (! $error && empty($this->fac_rec)) // If this->lines is an array of invoice line arrays + elseif (!$error && empty($this->fac_rec)) // If this->lines is an array of invoice line arrays { $fk_parent_line = 0; @@ -696,7 +696,7 @@ class Facture extends CommonInvoice // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. - if (! is_object($line)) $line = (object) $line; + if (!is_object($line)) $line = (object) $line; if ($result >= 0) { @@ -707,7 +707,7 @@ class Facture extends CommonInvoice // Complete vat rate with code $vatrate = $line->tva_tx; - if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; + if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; $result = $this->addline( $line->desc, @@ -742,7 +742,7 @@ class Facture extends CommonInvoice ); if ($result < 0) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_print_error($this->db); $this->db->rollback(); return -1; @@ -759,14 +759,14 @@ class Facture extends CommonInvoice /* * Insert lines of template invoices */ - if (! $error && $this->fac_rec > 0) + if (!$error && $this->fac_rec > 0) { foreach ($_facrec->lines as $i => $val) { if ($_facrec->lines[$i]->fk_product) { $prod = new Product($this->db); - $res=$prod->fetch($_facrec->lines[$i]->fk_product); + $res = $prod->fetch($_facrec->lines[$i]->fk_product); } // For line from template invoice, we use data from template invoice @@ -779,14 +779,14 @@ class Facture extends CommonInvoice */ $tva_tx = $_facrec->lines[$i]->tva_tx.($_facrec->lines[$i]->vat_src_code ? '('.$_facrec->lines[$i]->vat_src_code.')' : ''); $tva_npr = $_facrec->lines[$i]->info_bits; - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; $localtax1_tx = $_facrec->lines[$i]->localtax1_tx; $localtax2_tx = $_facrec->lines[$i]->localtax2_tx; - $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price)?null:$_facrec->lines[$i]->fk_product_fournisseur_price; - $buyprice = empty($_facrec->lines[$i]->buyprice)?0:$_facrec->lines[$i]->buyprice; + $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price) ?null:$_facrec->lines[$i]->fk_product_fournisseur_price; + $buyprice = empty($_facrec->lines[$i]->buyprice) ? 0 : $_facrec->lines[$i]->buyprice; // If buyprice not defined from template invoice, we try to guess the best value - if (! $buyprice && $_facrec->lines[$i]->fk_product > 0) + if (!$buyprice && $_facrec->lines[$i]->fk_product > 0) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $producttmp = new ProductFournisseur($this->db); @@ -795,14 +795,14 @@ class Facture extends CommonInvoice // If margin module defined on costprice, we try the costprice // If not defined or if module margin defined and pmp and stock module enabled, we try pmp price // else we get the best supplier price - if ($conf->global->MARGIN_TYPE == 'costprice' && ! empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price; - elseif (! empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && ! empty($producttmp->pmp)) $buyprice = $producttmp->pmp; + if ($conf->global->MARGIN_TYPE == 'costprice' && !empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price; + elseif (!empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && !empty($producttmp->pmp)) $buyprice = $producttmp->pmp; else { if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0) { if ($producttmp->product_fourn_price_id > 0) { - $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent/100) + $producttmp->fourn_remise, 'MU'); + $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent / 100) + $producttmp->fourn_remise, 'MU'); } } } @@ -817,8 +817,8 @@ class Facture extends CommonInvoice $localtax2_tx, $_facrec->lines[$i]->fk_product, $_facrec->lines[$i]->remise_percent, - ($_facrec->lines[$i]->date_start_fill == 1 && $originaldatewhen)?$originaldatewhen:'', - ($_facrec->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen)?$previousdaynextdatewhen:'', + ($_facrec->lines[$i]->date_start_fill == 1 && $originaldatewhen) ? $originaldatewhen : '', + ($_facrec->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) ? $previousdaynextdatewhen : '', 0, $tva_npr, '', @@ -833,45 +833,45 @@ class Facture extends CommonInvoice $fk_product_fournisseur_price, $buyprice, $_facrec->lines[$i]->label, - empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options, + empty($_facrec->lines[$i]->array_options) ?null:$_facrec->lines[$i]->array_options, $_facrec->lines[$i]->situation_percent, '', $_facrec->lines[$i]->fk_unit, $_facrec->lines[$i]->pu_ht_devise ); - if ( $result_insert < 0) + if ($result_insert < 0) { $error++; - $this->error=$this->db->error(); + $this->error = $this->db->error(); break; } } } - if (! $error) + if (!$error) { - $result=$this->update_price(1); + $result = $this->update_price(1); if ($result > 0) { - $action='create'; + $action = 'create'; // Actions on extra fields - if (! $error) + if (!$error) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BILL_CREATE', $user); + $result = $this->call_trigger('BILL_CREATE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -884,7 +884,7 @@ class Facture extends CommonInvoice } else { - $this->error=$langs->trans('FailedToUpdatePrice'); + $this->error = $langs->trans('FailedToUpdatePrice'); $this->db->rollback(); return -3; } @@ -898,7 +898,7 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -917,18 +917,18 @@ class Facture extends CommonInvoice global $conf; // Charge facture source - $facture=new Facture($this->db); + $facture = new Facture($this->db); // Retreive all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); - if(!empty($this->array_options)){ + if (!empty($this->array_options)) { $facture->array_options = $this->array_options; } - foreach($this->lines as &$line){ - $line->fetch_optionals();//fetch extrafields + foreach ($this->lines as &$line) { + $line->fetch_optionals(); //fetch extrafields } $facture->fk_facture_source = $this->fk_facture_source; @@ -949,14 +949,14 @@ class Facture extends CommonInvoice $facture->origin = $this->origin; $facture->origin_id = $this->origin_id; - $facture->lines = $this->lines; // Array of lines of invoice - $facture->products = $this->lines; // Tant que products encore utilise + $facture->lines = $this->lines; // Array of lines of invoice + $facture->products = $this->lines; // Tant que products encore utilise $facture->situation_counter = $this->situation_counter; - $facture->situation_cycle_ref=$this->situation_cycle_ref; - $facture->situation_final = $this->situation_final; + $facture->situation_cycle_ref = $this->situation_cycle_ref; + $facture->situation_final = $this->situation_final; // Loop on each line of new invoice - foreach($facture->lines as $i => $tmpline) + foreach ($facture->lines as $i => $tmpline) { $facture->lines[$i]->fk_prev_id = $this->lines[$i]->rowid; if ($invertdetail) @@ -975,8 +975,8 @@ class Facture extends CommonInvoice $facid = $facture->create($user); if ($facid <= 0) { - $this->error=$facture->error; - $this->errors=$facture->errors; + $this->error = $facture->error; + $this->errors = $facture->errors; } elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) { @@ -1008,33 +1008,33 @@ class Facture extends CommonInvoice { global $hookmanager; - $error=0; + $error = 0; - $object=new Facture($this->db); + $object = new Facture($this->db); $this->db->begin(); $object->fetch($fromid); // Change socid if needed - if (! empty($this->socid) && $this->socid != $object->socid) + if (!empty($this->socid) && $this->socid != $object->socid) { $objsoc = new Societe($this->db); - if ($objsoc->fetch($this->socid)>0) + if ($objsoc->fetch($this->socid) > 0) { - $object->socid = $objsoc->id; - $object->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $object->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $object->fk_project = ''; - $object->fk_delivery_address = ''; + $object->socid = $objsoc->id; + $object->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $object->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $object->fk_project = ''; + $object->fk_delivery_address = ''; } // TODO Change product price if multi-prices } - $object->id=0; - $object->statut= self::STATUS_DRAFT; + $object->id = 0; + $object->statut = self::STATUS_DRAFT; // Clear fields $object->date = (empty($this->date) ? dol_now() : $this->date); @@ -1047,26 +1047,26 @@ class Facture extends CommonInvoice $object->ref_client = ''; $object->close_code = ''; $object->close_note = ''; - $object->products = $object->lines; // For backward compatibility - if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING==1) + $object->products = $object->lines; // For backward compatibility + if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) { $object->note_private = ''; $object->note_public = ''; } // Loop on each line of new invoice - foreach($object->lines as $i => $line) + foreach ($object->lines as $i => $line) { if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts { unset($object->lines[$i]); - unset($object->products[$i]); // Tant que products encore utilise + unset($object->products[$i]); // Tant que products encore utilise } } // Create clone $object->context['createfromclone'] = 'createfromclone'; - $result=$object->create($user); + $result = $object->create($user); if ($result < 0) $error++; else { // copy internal contacts @@ -1081,14 +1081,14 @@ class Facture extends CommonInvoice } } - if (! $error) + if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters=array('objFrom'=>$this); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('objFrom'=>$this); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } } @@ -1096,7 +1096,7 @@ class Facture extends CommonInvoice unset($object->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $object->id; @@ -1119,18 +1119,18 @@ class Facture extends CommonInvoice { global $conf, $hookmanager; - $error=0; + $error = 0; // Closed order $this->date = dol_now(); $this->source = 0; - $num=count($object->lines); + $num = count($object->lines); for ($i = 0; $i < $num; $i++) { $line = new FactureLigne($this->db); - $line->libelle = $object->lines[$i]->libelle; // deprecated + $line->libelle = $object->lines[$i]->libelle; // deprecated $line->label = $object->lines[$i]->label; $line->desc = $object->lines[$i]->desc; $line->subprice = $object->lines[$i]->subprice; @@ -1139,30 +1139,30 @@ class Facture extends CommonInvoice $line->total_localtax1 = $object->lines[$i]->total_localtax1; $line->total_localtax2 = $object->lines[$i]->total_localtax2; $line->total_ttc = $object->lines[$i]->total_ttc; - $line->vat_src_code = $object->lines[$i]->vat_src_code; - $line->tva_tx = $object->lines[$i]->tva_tx; + $line->vat_src_code = $object->lines[$i]->vat_src_code; + $line->tva_tx = $object->lines[$i]->tva_tx; $line->localtax1_tx = $object->lines[$i]->localtax1_tx; $line->localtax2_tx = $object->lines[$i]->localtax2_tx; - $line->qty = $object->lines[$i]->qty; - $line->fk_remise_except = $object->lines[$i]->fk_remise_except; - $line->remise_percent = $object->lines[$i]->remise_percent; - $line->fk_product = $object->lines[$i]->fk_product; - $line->info_bits = $object->lines[$i]->info_bits; + $line->qty = $object->lines[$i]->qty; + $line->fk_remise_except = $object->lines[$i]->fk_remise_except; + $line->remise_percent = $object->lines[$i]->remise_percent; + $line->fk_product = $object->lines[$i]->fk_product; + $line->info_bits = $object->lines[$i]->info_bits; $line->product_type = $object->lines[$i]->product_type; - $line->rang = $object->lines[$i]->rang; + $line->rang = $object->lines[$i]->rang; $line->special_code = $object->lines[$i]->special_code; - $line->fk_parent_line = $object->lines[$i]->fk_parent_line; - $line->fk_unit = $object->lines[$i]->fk_unit; - $line->date_start = $object->lines[$i]->date_start; - $line->date_end = $object->lines[$i]->date_end; + $line->fk_parent_line = $object->lines[$i]->fk_parent_line; + $line->fk_unit = $object->lines[$i]->fk_unit; + $line->date_start = $object->lines[$i]->date_start; + $line->date_end = $object->lines[$i]->date_end; - $line->fk_fournprice = $object->lines[$i]->fk_fournprice; + $line->fk_fournprice = $object->lines[$i]->fk_fournprice; $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); $line->pa_ht = $marginInfos[0]; // get extrafields from original line $object->lines[$i]->fetch_optionals(); - foreach($object->lines[$i]->array_options as $options_key => $value) + foreach ($object->lines[$i]->array_options as $options_key => $value) $line->array_options[$options_key] = $value; $this->lines[$i] = $line; @@ -1181,24 +1181,24 @@ class Facture extends CommonInvoice if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) { - $this->note_private = $object->note_private; - $this->note_public = $object->note_public; + $this->note_private = $object->note_private; + $this->note_public = $object->note_public; } - $this->module_source = $object->module_source; - $this->pos_source = $object->pos_source; + $this->module_source = $object->module_source; + $this->pos_source = $object->pos_source; - $this->origin = $object->element; - $this->origin_id = $object->id; + $this->origin = $object->element; + $this->origin_id = $object->id; // get extrafields from original line $object->fetch_optionals($object->id); - foreach($object->array_options as $options_key => $value) + foreach ($object->array_options as $options_key => $value) $this->array_options[$options_key] = $value; // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; - if (! empty($object->other_linked_objects) && is_array($object->other_linked_objects)) + if (!empty($object->other_linked_objects) && is_array($object->other_linked_objects)) { $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); } @@ -1210,12 +1210,12 @@ class Facture extends CommonInvoice // Actions hooked (by external module) $hookmanager->initHooks(array('invoicedao')); - $parameters=array('objFrom'=>$object); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('objFrom'=>$object); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; - if (! $error) + if (!$error) { return 1; } @@ -1242,9 +1242,9 @@ class Facture extends CommonInvoice { global $langs, $conf, $user, $mysoc; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result=''; + $result = ''; if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id; else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id; @@ -1255,59 +1255,59 @@ class Facture extends CommonInvoice if ($option !== 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } if ($short) return $url; - $picto=$this->picto; - if ($this->type == self::TYPE_REPLACEMENT) $picto.='r'; // Replacement invoice - if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note - if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice - $label=''; + $picto = $this->picto; + if ($this->type == self::TYPE_REPLACEMENT) $picto .= 'r'; // Replacement invoice + if ($this->type == self::TYPE_CREDIT_NOTE) $picto .= 'a'; // Credit note + if ($this->type == self::TYPE_DEPOSIT) $picto .= 'd'; // Deposit invoice + $label = ''; if ($user->rights->facture->lire) { - $label = '' . $langs->trans("ShowInvoice") . ''; - if ($this->type == self::TYPE_REPLACEMENT) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceReplace") . ''; - if ($this->type == self::TYPE_CREDIT_NOTE) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceAvoir") . ''; - if ($this->type == self::TYPE_DEPOSIT) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceDeposit") . ''; - if ($this->type == self::TYPE_SITUATION) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceSituation") . ''; - if (! empty($this->ref)) - $label .= '
'.$langs->trans('Ref') . ': ' . $this->ref; - if (! empty($this->ref_client)) - $label .= '
' . $langs->trans('RefCustomer') . ': ' . $this->ref_client; - if (! empty($this->date)) - $label .= '
' . $langs->trans('Date') . ': ' . dol_print_date($this->date, 'day'); - if (! empty($this->total_ht)) - $label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_tva)) - $label.= '
' . $langs->trans('AmountVAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_localtax1) && $this->total_localtax1 != 0) // We keep test != 0 because $this->total_localtax1 can be '0.00000000' - $label.= '
' . $langs->transcountry('AmountLT1', $mysoc->country_code) . ': ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_localtax2) && $this->total_localtax2 != 0) - $label.= '
' . $langs->transcountry('AmountLT2', $mysoc->country_code) . ': ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_ttc)) - $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - if ($moretitle) $label.=' - '.$moretitle; + $label = ''.$langs->trans("ShowInvoice").''; + if ($this->type == self::TYPE_REPLACEMENT) $label = ''.$langs->transnoentitiesnoconv("ShowInvoiceReplace").''; + if ($this->type == self::TYPE_CREDIT_NOTE) $label = ''.$langs->transnoentitiesnoconv("ShowInvoiceAvoir").''; + if ($this->type == self::TYPE_DEPOSIT) $label = ''.$langs->transnoentitiesnoconv("ShowInvoiceDeposit").''; + if ($this->type == self::TYPE_SITUATION) $label = ''.$langs->transnoentitiesnoconv("ShowInvoiceSituation").''; + if (!empty($this->ref)) + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->ref_client)) + $label .= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; + if (!empty($this->date)) + $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); + if (!empty($this->total_ht)) + $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_tva)) + $label .= '
'.$langs->trans('AmountVAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_localtax1) && $this->total_localtax1 != 0) // We keep test != 0 because $this->total_localtax1 can be '0.00000000' + $label .= '
'.$langs->transcountry('AmountLT1', $mysoc->country_code).': '.price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_localtax2) && $this->total_localtax2 != 0) + $label .= '
'.$langs->transcountry('AmountLT2', $mysoc->country_code).': '.price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_ttc)) + $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + if ($moretitle) $label .= ' - '.$moretitle; } - $linkclose=($target?' target="'.$target.'"':''); + $linkclose = ($target ? ' target="'.$target.'"' : ''); if (empty($notooltip) && $user->rights->facture->lire) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowInvoice"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowInvoice"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } - $linkstart=''; - $linkend=''; + $linkstart = ''; + $linkend = ''; if ($option == 'nolink') { $linkstart = ''; @@ -1315,23 +1315,23 @@ class Facture extends CommonInvoice } $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= ($max?dol_trunc($this->ref, $max):$this->ref); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($max ?dol_trunc($this->ref, $max) : $this->ref); $result .= $linkend; if ($addlinktonotes) { - $txttoshow=($user->socid > 0 ? $this->note_public : $this->note_private); + $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private); if ($txttoshow) { - $notetoshow=$langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow, 1); - $result.=' '; - $result.=''; - $result.=img_picto('', 'note'); - $result.=''; + $notetoshow = $langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow, 1); + $result .= ' '; + $result .= ''; + $result .= img_picto('', 'note'); + $result .= ''; //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); //$result.=''; - $result.=''; + $result .= '
'; } } @@ -1355,36 +1355,36 @@ class Facture extends CommonInvoice if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; $sql = 'SELECT f.rowid,f.entity,f.ref,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; - $sql.= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; - $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; - $sql.= ', f.datef as df, f.date_pointoftax'; - $sql.= ', f.date_lim_reglement as dlr'; - $sql.= ', f.datec as datec'; - $sql.= ', f.date_valid as datev'; - $sql.= ', f.tms as datem'; - $sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf, f.last_main_doc'; - $sql.= ', f.fk_facture_source, f.fk_fac_rec_source'; - $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project, f.extraparams'; - $sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; - $sql.= ', f.fk_account'; - $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; - $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; - $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; - $sql.= ', f.fk_incoterms, f.location_incoterms'; - $sql.= ', f.module_source, f.pos_source'; - $sql.= ", i.libelle as label_incoterms"; - $sql.= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit, f.retained_warranty_fk_cond_reglement as retained_warranty_fk_cond_reglement"; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; + $sql .= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; + $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; + $sql .= ', f.datef as df, f.date_pointoftax'; + $sql .= ', f.date_lim_reglement as dlr'; + $sql .= ', f.datec as datec'; + $sql .= ', f.date_valid as datev'; + $sql .= ', f.tms as datem'; + $sql .= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf, f.last_main_doc'; + $sql .= ', f.fk_facture_source, f.fk_fac_rec_source'; + $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project, f.extraparams'; + $sql .= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; + $sql .= ', f.fk_account'; + $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; + $sql .= ', f.fk_incoterms, f.location_incoterms'; + $sql .= ', f.module_source, f.pos_source'; + $sql .= ", i.libelle as label_incoterms"; + $sql .= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit, f.retained_warranty_fk_cond_reglement as retained_warranty_fk_cond_reglement"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; - if ($rowid) $sql.= " WHERE f.rowid=".$rowid; - else $sql.= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid + if ($rowid) $sql .= " WHERE f.rowid=".$rowid; + else $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid - if ($ref) $sql.= " AND f.ref='".$this->db->escape($ref)."'"; - if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; + if ($ref) $sql .= " AND f.ref='".$this->db->escape($ref)."'"; + if ($ref_ext) $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql .= " AND f.ref_int='".$this->db->escape($ref_int)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -1394,20 +1394,20 @@ class Facture extends CommonInvoice { $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - $this->entity = $obj->entity; + $this->id = $obj->rowid; + $this->entity = $obj->entity; - $this->ref = $obj->ref; - $this->ref_client = $obj->ref_client; + $this->ref = $obj->ref; + $this->ref_client = $obj->ref_client; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; $this->type = $obj->type; $this->date = $this->db->jdate($obj->df); $this->date_pointoftax = $this->db->jdate($obj->date_pointoftax); - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_validation = $this->db->jdate($obj->datev); - $this->date_modification = $this->db->jdate($obj->datem); - $this->datem = $this->db->jdate($obj->datem); + $this->date_modification = $this->db->jdate($obj->datem); + $this->datem = $this->db->jdate($obj->datem); $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; $this->total_ht = $obj->total; @@ -1415,31 +1415,31 @@ class Facture extends CommonInvoice $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total_ttc; - $this->revenuestamp = $obj->revenuestamp; + $this->revenuestamp = $obj->revenuestamp; $this->paye = $obj->paye; $this->close_code = $obj->close_code; $this->close_note = $obj->close_note; $this->socid = $obj->fk_soc; - $this->statut = $obj->fk_statut; - $this->date_lim_reglement = $this->db->jdate($obj->dlr); + $this->statut = $obj->fk_statut; + $this->date_lim_reglement = $this->db->jdate($obj->dlr); $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement_libelle; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; - $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; - $this->fk_account = ($obj->fk_account>0)?$obj->fk_account:null; - $this->fk_project = $obj->fk_project; + $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + $this->fk_account = ($obj->fk_account > 0) ? $obj->fk_account : null; + $this->fk_project = $obj->fk_project; $this->fk_facture_source = $obj->fk_facture_source; $this->fk_fac_rec_source = $obj->fk_fac_rec_source; - $this->note = $obj->note_private; // deprecated - $this->note_private = $obj->note_private; + $this->note = $obj->note_private; // deprecated + $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->user_author = $obj->fk_user_author; - $this->user_valid = $obj->fk_user_valid; - $this->modelpdf = $obj->model_pdf; - $this->last_main_doc = $obj->last_main_doc; + $this->user_valid = $obj->fk_user_valid; + $this->modelpdf = $obj->model_pdf; + $this->last_main_doc = $obj->last_main_doc; $this->situation_cycle_ref = $obj->situation_cycle_ref; $this->situation_counter = $obj->situation_counter; $this->situation_final = $obj->situation_final; @@ -1447,25 +1447,25 @@ class Facture extends CommonInvoice $this->retained_warranty_date_limit = $this->db->jdate($obj->retained_warranty_date_limit); $this->retained_warranty_fk_cond_reglement = $obj->retained_warranty_fk_cond_reglement; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); //Incoterms $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; - $this->label_incoterms = $obj->label_incoterms; + $this->label_incoterms = $obj->label_incoterms; - $this->module_source = $obj->module_source; - $this->pos_source = $obj->pos_source; + $this->module_source = $obj->module_source; + $this->pos_source = $obj->pos_source; // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_code = $obj->multicurrency_code; $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) + if (($this->type == self::TYPE_SITUATION || ($this->type == self::TYPE_CREDIT_NOTE && $this->situation_cycle_ref > 0)) && $fetch_situation) { $this->fetchPreviousNextSituationInvoice(); } @@ -1480,26 +1480,26 @@ class Facture extends CommonInvoice * Lines */ - $this->lines = array(); + $this->lines = array(); - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -3; } return 1; } else { - $this->error='Invoice with id='.$rowid.' or ref='.$ref.' or ref_ext='.$ref_ext.' not found'; + $this->error = 'Invoice with id='.$rowid.' or ref='.$ref.' or ref_ext='.$ref_ext.' not found'; dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1518,21 +1518,21 @@ class Facture extends CommonInvoice { global $langs, $conf; // phpcs:enable - $this->lines=array(); + $this->lines = array(); $sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql.= ' l.situation_percent, l.fk_prev_id,'; - $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; - $sql.= ' l.rang, l.special_code,'; - $sql.= ' l.date_start as date_start, l.date_end as date_end,'; - $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; - $sql.= ' l.fk_unit,'; - $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; - $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql.= ' WHERE l.fk_facture = '.$this->id; - $sql.= ' ORDER BY l.rang, l.rowid'; + $sql .= ' l.situation_percent, l.fk_prev_id,'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; + $sql .= ' l.rang, l.special_code,'; + $sql .= ' l.date_start as date_start, l.date_end as date_end,'; + $sql .= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; + $sql .= ' l.fk_unit,'; + $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; + $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql .= ' WHERE l.fk_facture = '.$this->id; + $sql .= ' ORDER BY l.rang, l.rowid'; dol_syslog(get_class($this).'::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); @@ -1546,22 +1546,22 @@ class Facture extends CommonInvoice $line = new FactureLigne($this->db); $line->id = $objp->rowid; - $line->rowid = $objp->rowid; // deprecated + $line->rowid = $objp->rowid; // deprecated $line->fk_facture = $objp->fk_facture; - $line->label = $objp->custom_label; // deprecated - $line->desc = $objp->description; // Description line - $line->description = $objp->description; // Description line - $line->product_type = $objp->product_type; // Type of line - $line->ref = $objp->product_ref; // Ref product - $line->product_ref = $objp->product_ref; // Ref product - $line->libelle = $objp->product_label; // deprecated - $line->product_label = $objp->product_label; // Label product - $line->product_desc = $objp->product_desc; // Description product - $line->fk_product_type = $objp->fk_product_type; // Type of product + $line->label = $objp->custom_label; // deprecated + $line->desc = $objp->description; // Description line + $line->description = $objp->description; // Description line + $line->product_type = $objp->product_type; // Type of line + $line->ref = $objp->product_ref; // Ref product + $line->product_ref = $objp->product_ref; // Ref product + $line->libelle = $objp->product_label; // deprecated + $line->product_label = $objp->product_label; // Label product + $line->product_desc = $objp->product_desc; // Description product + $line->fk_product_type = $objp->fk_product_type; // Type of product $line->qty = $objp->qty; $line->subprice = $objp->subprice; - $line->vat_src_code = $objp->vat_src_code; + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; @@ -1581,24 +1581,24 @@ class Facture extends CommonInvoice $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; $line->code_ventilation = $objp->fk_code_ventilation; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; $line->marge_tx = $marginInfos[1]; $line->marque_tx = $marginInfos[2]; - $line->rang = $objp->rang; - $line->special_code = $objp->special_code; - $line->fk_parent_line = $objp->fk_parent_line; - $line->situation_percent= $objp->situation_percent; + $line->rang = $objp->rang; + $line->special_code = $objp->special_code; + $line->fk_parent_line = $objp->fk_parent_line; + $line->situation_percent = $objp->situation_percent; $line->fk_prev_id = $objp->fk_prev_id; - $line->fk_unit = $objp->fk_unit; + $line->fk_unit = $objp->fk_unit; // Accountancy - $line->fk_accounting_account = $objp->fk_code_ventilation; + $line->fk_accounting_account = $objp->fk_code_ventilation; // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; $line->multicurrency_subprice = $objp->multicurrency_subprice; $line->multicurrency_total_ht = $objp->multicurrency_total_ht; $line->multicurrency_total_tva = $objp->multicurrency_total_tva; @@ -1607,7 +1607,7 @@ class Facture extends CommonInvoice $line->fetch_optionals(); // multilangs - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { $line = new Product($this->db); $line->fetch($objp->fk_product); $line->getMultiLangs(); @@ -1622,7 +1622,7 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -3; } } @@ -1640,10 +1640,10 @@ class Facture extends CommonInvoice $this->tab_next_situation_invoice = array(); $sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture'; - $sql.= ' WHERE rowid <> '.$this->id; - $sql.= ' AND entity = '.$this->entity; - $sql.= ' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref; - $sql.= ' ORDER BY situation_counter ASC'; + $sql .= ' WHERE rowid <> '.$this->id; + $sql .= ' AND entity = '.$this->entity; + $sql .= ' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref; + $sql .= ' ORDER BY situation_counter ASC'; dol_syslog(get_class($this).'::fetchPreviousNextSituationInvoice ', LOG_DEBUG); $result = $this->db->query($sql); @@ -1680,20 +1680,20 @@ class Facture extends CommonInvoice { global $conf; - $error=0; + $error = 0; // Clean parameters - if (empty($this->type)) $this->type= self::TYPE_STANDARD; - if (isset($this->ref)) $this->ref=trim($this->ref); - if (isset($this->ref_client)) $this->ref_client=trim($this->ref_client); - if (isset($this->increment)) $this->increment=trim($this->increment); - if (isset($this->close_code)) $this->close_code=trim($this->close_code); - if (isset($this->close_note)) $this->close_note=trim($this->close_note); - if (isset($this->note) || isset($this->note_private)) $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated - if (isset($this->note) || isset($this->note_private)) $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); - if (isset($this->note_public)) $this->note_public=trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); - if (isset($this->import_key)) $this->import_key=trim($this->import_key); + if (empty($this->type)) $this->type = self::TYPE_STANDARD; + if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client); + if (isset($this->increment)) $this->increment = trim($this->increment); + if (isset($this->close_code)) $this->close_code = trim($this->close_code); + if (isset($this->close_note)) $this->close_note = trim($this->close_note); + if (isset($this->note) || isset($this->note_private)) $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + if (isset($this->note) || isset($this->note_private)) $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note)); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); + if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); + if (isset($this->import_key)) $this->import_key = trim($this->import_key); if (isset($this->retained_warranty)) $this->retained_warranty = floatval($this->retained_warranty); @@ -1702,67 +1702,67 @@ class Facture extends CommonInvoice // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET"; - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; - $sql.= " type=".(isset($this->type)?$this->db->escape($this->type):"null").","; - $sql.= " ref_client=".(isset($this->ref_client)?"'".$this->db->escape($this->ref_client)."'":"null").","; - $sql.= " increment=".(isset($this->increment)?"'".$this->db->escape($this->increment)."'":"null").","; - $sql.= " fk_soc=".(isset($this->socid)?$this->db->escape($this->socid):"null").","; - $sql.= " datec=".(strval($this->date_creation)!='' ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; - $sql.= " datef=".(strval($this->date)!='' ? "'".$this->db->idate($this->date)."'" : 'null').","; - $sql.= " date_pointoftax=".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null').","; - $sql.= " date_valid=".(strval($this->date_validation)!='' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; - $sql.= " paye=".(isset($this->paye)?$this->db->escape($this->paye):0).","; - $sql.= " remise_percent=".(isset($this->remise_percent)?$this->db->escape($this->remise_percent):"null").","; - $sql.= " remise_absolue=".(isset($this->remise_absolue)?$this->db->escape($this->remise_absolue):"null").","; - $sql.= " close_code=".(isset($this->close_code)?"'".$this->db->escape($this->close_code)."'":"null").","; - $sql.= " close_note=".(isset($this->close_note)?"'".$this->db->escape($this->close_note)."'":"null").","; - $sql.= " tva=".(isset($this->total_tva)?$this->total_tva:"null").","; - $sql.= " localtax1=".(isset($this->total_localtax1)?$this->total_localtax1:"null").","; - $sql.= " localtax2=".(isset($this->total_localtax2)?$this->total_localtax2:"null").","; - $sql.= " total=".(isset($this->total_ht)?$this->total_ht:"null").","; - $sql.= " total_ttc=".(isset($this->total_ttc)?$this->total_ttc:"null").","; - $sql.= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '')?$this->db->escape($this->revenuestamp):"null").","; - $sql.= " fk_statut=".(isset($this->statut)?$this->db->escape($this->statut):"null").","; - $sql.= " fk_user_author=".(isset($this->user_author)?$this->db->escape($this->user_author):"null").","; - $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->db->escape($this->fk_user_valid):"null").","; - $sql.= " fk_facture_source=".(isset($this->fk_facture_source)?$this->db->escape($this->fk_facture_source):"null").","; - $sql.= " fk_projet=".(isset($this->fk_project)?$this->db->escape($this->fk_project):"null").","; - $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->db->escape($this->cond_reglement_id):"null").","; - $sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->db->escape($this->mode_reglement_id):"null").","; - $sql.= " date_lim_reglement=".(strval($this->date_lim_reglement)!='' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').","; - $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; - $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; - $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").","; - $sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).","; - $sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).","; - $sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final)).","; - $sql.= " retained_warranty=".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)).","; - $sql.= " retained_warranty_date_limit=".(strval($this->retained_warranty_date_limit)!='' ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'null').","; - $sql.= " retained_warranty_fk_cond_reglement=".(isset($this->retained_warranty_fk_cond_reglement)?intval($this->retained_warranty_fk_cond_reglement):"null"); - $sql.= " WHERE rowid=".$this->id; + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " type=".(isset($this->type) ? $this->db->escape($this->type) : "null").","; + $sql .= " ref_client=".(isset($this->ref_client) ? "'".$this->db->escape($this->ref_client)."'" : "null").","; + $sql .= " increment=".(isset($this->increment) ? "'".$this->db->escape($this->increment)."'" : "null").","; + $sql .= " fk_soc=".(isset($this->socid) ? $this->db->escape($this->socid) : "null").","; + $sql .= " datec=".(strval($this->date_creation) != '' ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; + $sql .= " datef=".(strval($this->date) != '' ? "'".$this->db->idate($this->date)."'" : 'null').","; + $sql .= " date_pointoftax=".(strval($this->date_pointoftax) != '' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null').","; + $sql .= " date_valid=".(strval($this->date_validation) != '' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; + $sql .= " paye=".(isset($this->paye) ? $this->db->escape($this->paye) : 0).","; + $sql .= " remise_percent=".(isset($this->remise_percent) ? $this->db->escape($this->remise_percent) : "null").","; + $sql .= " remise_absolue=".(isset($this->remise_absolue) ? $this->db->escape($this->remise_absolue) : "null").","; + $sql .= " close_code=".(isset($this->close_code) ? "'".$this->db->escape($this->close_code)."'" : "null").","; + $sql .= " close_note=".(isset($this->close_note) ? "'".$this->db->escape($this->close_note)."'" : "null").","; + $sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; + $sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").","; + $sql .= " localtax2=".(isset($this->total_localtax2) ? $this->total_localtax2 : "null").","; + $sql .= " total=".(isset($this->total_ht) ? $this->total_ht : "null").","; + $sql .= " total_ttc=".(isset($this->total_ttc) ? $this->total_ttc : "null").","; + $sql .= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '') ? $this->db->escape($this->revenuestamp) : "null").","; + $sql .= " fk_statut=".(isset($this->statut) ? $this->db->escape($this->statut) : "null").","; + $sql .= " fk_user_author=".(isset($this->user_author) ? $this->db->escape($this->user_author) : "null").","; + $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? $this->db->escape($this->fk_user_valid) : "null").","; + $sql .= " fk_facture_source=".(isset($this->fk_facture_source) ? $this->db->escape($this->fk_facture_source) : "null").","; + $sql .= " fk_projet=".(isset($this->fk_project) ? $this->db->escape($this->fk_project) : "null").","; + $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->db->escape($this->cond_reglement_id) : "null").","; + $sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->db->escape($this->mode_reglement_id) : "null").","; + $sql .= " date_lim_reglement=".(strval($this->date_lim_reglement) != '' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').","; + $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; + $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; + $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").","; + $sql .= " situation_cycle_ref=".(empty($this->situation_cycle_ref) ? "null" : $this->db->escape($this->situation_cycle_ref)).","; + $sql .= " situation_counter=".(empty($this->situation_counter) ? "null" : $this->db->escape($this->situation_counter)).","; + $sql .= " situation_final=".(empty($this->situation_final) ? "0" : $this->db->escape($this->situation_final)).","; + $sql .= " retained_warranty=".(empty($this->retained_warranty) ? "0" : $this->db->escape($this->retained_warranty)).","; + $sql .= " retained_warranty_date_limit=".(strval($this->retained_warranty_date_limit) != '' ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'null').","; + $sql .= " retained_warranty_fk_cond_reglement=".(isset($this->retained_warranty_fk_cond_reglement) ?intval($this->retained_warranty_fk_cond_reglement) : "null"); + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BILL_MODIFY', $user); + $result = $this->call_trigger('BILL_MODIFY', $user); if ($result < 0) $error++; // End call triggers } @@ -1770,13 +1770,13 @@ class Facture extends CommonInvoice // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -1803,40 +1803,40 @@ class Facture extends CommonInvoice $this->db->begin(); - $remise=new DiscountAbsolute($this->db); - $result=$remise->fetch($idremise); + $remise = new DiscountAbsolute($this->db); + $result = $remise->fetch($idremise); if ($result > 0) { if ($remise->fk_facture) // Protection against multiple submission { - $this->error=$langs->trans("ErrorDiscountAlreadyUsed"); + $this->error = $langs->trans("ErrorDiscountAlreadyUsed"); $this->db->rollback(); return -5; } - $facligne=new FactureLigne($this->db); - $facligne->fk_facture=$this->id; - $facligne->fk_remise_except=$remise->id; - $facligne->desc=$remise->description; // Description ligne - $facligne->vat_src_code=$remise->vat_src_code; - $facligne->tva_tx=$remise->tva_tx; + $facligne = new FactureLigne($this->db); + $facligne->fk_facture = $this->id; + $facligne->fk_remise_except = $remise->id; + $facligne->desc = $remise->description; // Description ligne + $facligne->vat_src_code = $remise->vat_src_code; + $facligne->tva_tx = $remise->tva_tx; $facligne->subprice = -$remise->amount_ht; - $facligne->fk_product=0; // Id produit predefini - $facligne->qty=1; - $facligne->remise_percent=0; - $facligne->rang=-1; - $facligne->info_bits=2; + $facligne->fk_product = 0; // Id produit predefini + $facligne->qty = 1; + $facligne->remise_percent = 0; + $facligne->rang = -1; + $facligne->info_bits = 2; // Get buy/cost price of invoice that is source of discount if ($remise->fk_facture_source > 0) { - $srcinvoice=new Facture($this->db); + $srcinvoice = new Facture($this->db); $srcinvoice->fetch($remise->fk_facture_source); - $totalcostpriceofinvoice=0; - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject - $formmargin=new FormMargin($this->db); - $arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false); + $totalcostpriceofinvoice = 0; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject + $formmargin = new FormMargin($this->db); + $arraytmp = $formmargin->getMarginInfosArray($srcinvoice, false); $facligne->pa_ht = $arraytmp['pa_total']; } @@ -1849,17 +1849,17 @@ class Facture extends CommonInvoice $facligne->multicurrency_total_tva = -$remise->multicurrency_amount_tva; $facligne->multicurrency_total_ttc = -$remise->multicurrency_amount_ttc; - $lineid=$facligne->insert(); + $lineid = $facligne->insert(); if ($lineid > 0) { - $result=$this->update_price(1); + $result = $this->update_price(1); if ($result > 0) { // Create link between discount and invoice line - $result=$remise->link_to_invoice($lineid, 0); + $result = $remise->link_to_invoice($lineid, 0); if ($result < 0) { - $this->error=$remise->error; + $this->error = $remise->error; $this->db->rollback(); return -4; } @@ -1869,14 +1869,14 @@ class Facture extends CommonInvoice } else { - $this->error=$facligne->error; + $this->error = $facligne->error; $this->db->rollback(); return -1; } } else { - $this->error=$facligne->error; + $this->error = $facligne->error; $this->db->rollback(); return -2; } @@ -1901,7 +1901,7 @@ class Facture extends CommonInvoice // phpcs:enable global $user; - $error=0; + $error = 0; $this->db->begin(); @@ -1913,27 +1913,27 @@ class Facture extends CommonInvoice $sql .= ' WHERE rowid = '.$this->id; dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { $this->ref_client = $ref_client; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('BILL_MODIFY', $user); + $result = $this->call_trigger('BILL_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->ref_client = $ref_client; @@ -1942,13 +1942,13 @@ class Facture extends CommonInvoice } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -1962,10 +1962,10 @@ class Facture extends CommonInvoice */ public function delete($user, $notrigger = 0, $idwarehouse = -1) { - global $langs,$conf; + global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $rowid=$this->id; + $rowid = $this->id; dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".$this->thirdparty->name, LOG_DEBUG); @@ -1974,21 +1974,21 @@ class Facture extends CommonInvoice if ($result <= 0) return 0; - $error=0; + $error = 0; $this->db->begin(); - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BILL_DELETE', $user); + $result = $this->call_trigger('BILL_DELETE', $user); if ($result < 0) $error++; // End call triggers } // Removed extrafields - if (! $error) { - $result=$this->deleteExtraFields(); + if (!$error) { + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -1996,52 +1996,52 @@ class Facture extends CommonInvoice } } - if (! $error) + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; } - if (! $error) + if (!$error) { // If invoice was converted into a discount not yet consumed, we remove discount $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' WHERE fk_facture_source = '.$rowid; - $sql.= ' AND fk_facture_line IS NULL'; - $resql=$this->db->query($sql); + $sql .= ' WHERE fk_facture_source = '.$rowid; + $sql .= ' AND fk_facture_line IS NULL'; + $resql = $this->db->query($sql); // If invoice has consumned discounts $this->fetch_lines(); - $list_rowid_det=array(); - foreach($this->lines as $key => $invoiceline) + $list_rowid_det = array(); + foreach ($this->lines as $key => $invoiceline) { - $list_rowid_det[]=$invoiceline->rowid; + $list_rowid_det[] = $invoiceline->rowid; } // Consumned discounts are freed if (count($list_rowid_det)) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' SET fk_facture = NULL, fk_facture_line = NULL'; - $sql.= ' WHERE fk_facture_line IN ('.join(',', $list_rowid_det).')'; + $sql .= ' SET fk_facture = NULL, fk_facture_line = NULL'; + $sql .= ' WHERE fk_facture_line IN ('.join(',', $list_rowid_det).')'; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -5; } } // If we decrement stock on invoice validation, we increment - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse!=-1) + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); - $num=count($this->lines); + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { if ($this->lines[$i]->fk_product > 0) @@ -2049,8 +2049,8 @@ class Facture extends CommonInvoice $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); - else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value + if ($this->type == self::TYPE_CREDIT_NOTE) $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); + else $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceDeleteDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value } } } @@ -2067,33 +2067,33 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // On efface le repertoire de pdf provisoire $ref = dol_sanitizeFileName($this->ref); if ($conf->facture->dir_output && !empty($this->ref)) { - $dir = $conf->facture->dir_output . "/" . $ref; - $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf"; + $dir = $conf->facture->dir_output."/".$ref; + $file = $conf->facture->dir_output."/".$ref."/".$ref.".pdf"; if (file_exists($file)) // We must delete all files before deleting directory { - $ret=dol_delete_preview($this); + $ret = dol_delete_preview($this); - if (! dol_delete_file($file, 0, 0, 0, $this)) // For triggers + if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers { $langs->load("errors"); - $this->error=$langs->trans("ErrorFailToDeleteFile", $file); + $this->error = $langs->trans("ErrorFailToDeleteFile", $file); $this->db->rollback(); return 0; } } if (file_exists($dir)) { - if (! dol_delete_dir_recursive($dir)) // For remove dir and meta + if (!dol_delete_dir_recursive($dir)) // For remove dir and meta { $langs->load("errors"); - $this->error=$langs->trans("ErrorFailToDeleteDir", $dir); + $this->error = $langs->trans("ErrorFailToDeleteDir", $dir); $this->db->rollback(); return 0; } @@ -2105,14 +2105,14 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->lasterror()." sql=".$sql; + $this->error = $this->db->lasterror()." sql=".$sql; $this->db->rollback(); return -6; } } else { - $this->error=$this->db->lasterror()." sql=".$sql; + $this->error = $this->db->lasterror()." sql=".$sql; $this->db->rollback(); return -4; } @@ -2137,40 +2137,40 @@ class Facture extends CommonInvoice public function set_paid($user, $close_code = '', $close_note = '') { // phpcs:enable - $error=0; + $error = 0; if ($this->paye != 1) { $this->db->begin(); - $now=dol_now(); + $now = dol_now(); dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; - $sql.= ' fk_statut='.self::STATUS_CLOSED; - if (! $close_code) $sql.= ', paye=1'; - if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; - if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; - $sql.= ', fk_user_closing = '.$user->id; - $sql.= ", date_closing = '".$this->db->idate($now)."'"; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' fk_statut='.self::STATUS_CLOSED; + if (!$close_code) $sql .= ', paye=1'; + if ($close_code) $sql .= ", close_code='".$this->db->escape($close_code)."'"; + if ($close_note) $sql .= ", close_note='".$this->db->escape($close_note)."'"; + $sql .= ', fk_user_closing = '.$user->id; + $sql .= ", date_closing = '".$this->db->idate($now)."'"; + $sql .= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('BILL_PAYED', $user); + $result = $this->call_trigger('BILL_PAYED', $user); if ($result < 0) $error++; // End call triggers } else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -2200,33 +2200,33 @@ class Facture extends CommonInvoice public function set_unpaid($user) { // phpcs:enable - $error=0; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null,'; - $sql.= ' date_closing=null,'; - $sql.= ' fk_user_closing=null'; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null,'; + $sql .= ' date_closing=null,'; + $sql .= ' fk_user_closing=null'; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('BILL_UNPAYED', $user); + $result = $this->call_trigger('BILL_UNPAYED', $user); if ($result < 0) $error++; // End call triggers } else { $error++; - $this->error=$this->db->error(); + $this->error = $this->db->error(); dol_print_error($this->db); } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -2259,10 +2259,10 @@ class Facture extends CommonInvoice $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; - $sql.= ' fk_statut='.self::STATUS_ABANDONED; - if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; - if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' fk_statut='.self::STATUS_ABANDONED; + if ($close_code) $sql .= ", close_code='".$this->db->escape($close_code)."'"; + if ($close_note) $sql .= ", close_note='".$this->db->escape($close_note)."'"; + $sql .= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); if ($resql) @@ -2270,14 +2270,14 @@ class Facture extends CommonInvoice // On desaffecte de la facture les remises liees // car elles n'ont pas ete utilisees vu que la facture est abandonnee. $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' SET fk_facture = NULL'; - $sql.= ' WHERE fk_facture = '.$this->id; + $sql .= ' SET fk_facture = NULL'; + $sql .= ' WHERE fk_facture = '.$this->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('BILL_CANCEL', $user); + $result = $this->call_trigger('BILL_CANCEL', $user); if ($result < 0) { $this->db->rollback(); @@ -2290,14 +2290,14 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; } } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -2; } @@ -2315,12 +2315,12 @@ class Facture extends CommonInvoice */ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) { - global $conf,$langs; + global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $now=dol_now(); + $now = dol_now(); - $error=0; + $error = 0; dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number.', idwarehouse='.$idwarehouse); // Force to have object complete for checks @@ -2328,7 +2328,7 @@ class Facture extends CommonInvoice $this->fetch_lines(); // Check parameters - if (! $this->brouillon) + if (!$this->brouillon) { dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING); return 0; @@ -2336,13 +2336,13 @@ class Facture extends CommonInvoice if (count($this->lines) <= 0) { $langs->load("errors"); - $this->error=$langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); + $this->error = $langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); return -1; } if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) { - $this->error='Permission denied'; + $this->error = 'Permission denied'; dol_syslog(get_class($this)."::validate ".$this->error.' MAIN_USE_ADVANCED_PERMS='.$conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR); return -1; } @@ -2355,36 +2355,36 @@ class Facture extends CommonInvoice // Controle que facture source connue if ($this->fk_facture_source <= 0) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InvoiceReplacement")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InvoiceReplacement")); $this->db->rollback(); return -10; } // Charge la facture source a remplacer - $facreplaced=new Facture($this->db); - $result=$facreplaced->fetch($this->fk_facture_source); + $facreplaced = new Facture($this->db); + $result = $facreplaced->fetch($this->fk_facture_source); if ($result <= 0) { - $this->error=$langs->trans("ErrorBadInvoice"); + $this->error = $langs->trans("ErrorBadInvoice"); $this->db->rollback(); return -11; } // Controle que facture source non deja remplacee par une autre - $idreplacement=$facreplaced->getIdReplacingInvoice('validated'); + $idreplacement = $facreplaced->getIdReplacingInvoice('validated'); if ($idreplacement && $idreplacement != $this->id) { - $facreplacement=new Facture($this->db); + $facreplacement = new Facture($this->db); $facreplacement->fetch($idreplacement); - $this->error=$langs->trans("ErrorInvoiceAlreadyReplaced", $facreplaced->ref, $facreplacement->ref); + $this->error = $langs->trans("ErrorInvoiceAlreadyReplaced", $facreplaced->ref, $facreplacement->ref); $this->db->rollback(); return -12; } - $result=$facreplaced->set_canceled($user, self::CLOSECODE_REPLACED, ''); + $result = $facreplaced->set_canceled($user, self::CLOSECODE_REPLACED, ''); if ($result < 0) { - $this->error=$facreplaced->error; + $this->error = $facreplaced->error; $this->db->rollback(); return -13; } @@ -2397,10 +2397,10 @@ class Facture extends CommonInvoice } elseif (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life { - if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date + if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date { - $this->date=dol_now(); - $this->date_lim_reglement=$this->calculate_date_lim_reglement(); + $this->date = dol_now(); + $this->date_lim_reglement = $this->calculate_date_lim_reglement(); } $num = $this->getNextNumRef($this->thirdparty); } @@ -2416,41 +2416,41 @@ class Facture extends CommonInvoice // Validate $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= " SET ref='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; - if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date + $sql .= " SET ref='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; + if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date { - $sql.= ", datef='".$this->db->idate($this->date)."'"; - $sql.= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; + $sql .= ", datef='".$this->db->idate($this->date)."'"; + $sql .= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; } - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::validate", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { dol_print_error($this->db); $error++; } // On verifie si la facture etait une provisoire - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref))) { // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne } - if (! $error) + if (!$error) { // Define third party as a customer - $result=$this->thirdparty->set_as_client(); + $result = $this->thirdparty->set_as_client(); // Si active on decremente le produit principal et ses composants a la validation de facture - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); // Loop on each line - $cpt=count($this->lines); + $cpt = count($this->lines); for ($i = 0; $i < $cpt; $i++) { if ($this->lines[$i]->fk_product > 0) @@ -2458,8 +2458,8 @@ class Facture extends CommonInvoice $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num)); - else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num)); + if ($this->type == self::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num)); + else $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num)); if ($result < 0) { $error++; $this->error = $mouvP->error; @@ -2470,15 +2470,15 @@ class Facture extends CommonInvoice } // Trigger calls - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BILL_VALIDATE', $user); + $result = $this->call_trigger('BILL_VALIDATE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -2486,17 +2486,17 @@ class Facture extends CommonInvoice if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'facture/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'facture/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'facture/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'facture/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->facture->dir_output.'/'.$oldref; $dirdest = $conf->facture->dir_output.'/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); @@ -2504,13 +2504,13 @@ class Facture extends CommonInvoice { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -2518,22 +2518,22 @@ class Facture extends CommonInvoice } } - if (! $error && !$this->is_last_in_cycle()) + if (!$error && !$this->is_last_in_cycle()) { - if (! $this->updatePriceNextInvoice($langs)) + if (!$this->updatePriceNextInvoice($langs)) { $error++; } } // Set new ref and define current status - if (! $error) + if (!$error) { $this->ref = $num; - $this->ref=$num; - $this->statut= self::STATUS_VALIDATED; - $this->brouillon=0; - $this->date_validation=$now; + $this->ref = $num; + $this->statut = self::STATUS_VALIDATED; + $this->brouillon = 0; + $this->date_validation = $now; $i = 0; if (!empty($conf->global->INVOICE_USE_SITUATION)) @@ -2557,7 +2557,7 @@ class Facture extends CommonInvoice $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -2620,9 +2620,9 @@ class Facture extends CommonInvoice public function setDraft($user, $idwarehouse = -1) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; - $error=0; + $error = 0; if ($this->statut == self::STATUS_DRAFT) { @@ -2635,24 +2635,24 @@ class Facture extends CommonInvoice $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; - $sql.= " SET fk_statut = ".self::STATUS_DRAFT; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET fk_statut = ".self::STATUS_DRAFT; + $sql .= " WHERE rowid = ".$this->id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; } // Si on decremente le produit principal et ses composants a la validation de facture, on réincrement - if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); - $num=count($this->lines); + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { if ($this->lines[$i]->fk_product > 0) @@ -2660,25 +2660,25 @@ class Facture extends CommonInvoice $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrease stock for product - if ($this->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); - else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value + if ($this->type == self::TYPE_CREDIT_NOTE) $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); + else $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref)); // we use 0 for price, to not change the weighted average value } } } if ($error == 0) { - $old_statut=$this->statut; + $old_statut = $this->statut; $this->brouillon = 1; $this->statut = self::STATUS_DRAFT; // Call trigger - $result=$this->call_trigger('BILL_UNVALIDATE', $user); + $result = $this->call_trigger('BILL_UNVALIDATE', $user); if ($result < 0) { $error++; - $this->statut=$old_statut; - $this->brouillon=0; + $this->statut = $old_statut; + $this->brouillon = 0; } // End call triggers } else { @@ -2699,7 +2699,7 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -2777,7 +2777,7 @@ class Facture extends CommonInvoice ) { // Deprecation warning if ($label) { - dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + dol_syslog(__METHOD__.": using line label is deprecated", LOG_WARNING); //var_dump(debug_backtrace(false));exit; } @@ -2790,37 +2790,37 @@ class Facture extends CommonInvoice include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters - if (empty($remise_percent)) $remise_percent=0; - if (empty($qty)) $qty=0; - if (empty($info_bits)) $info_bits=0; - if (empty($rang)) $rang=0; - if (empty($ventil)) $ventil=0; - if (empty($txtva)) $txtva=0; - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; + if (empty($remise_percent)) $remise_percent = 0; + if (empty($qty)) $qty = 0; + if (empty($info_bits)) $info_bits = 0; + if (empty($rang)) $rang = 0; + if (empty($ventil)) $ventil = 0; + if (empty($txtva)) $txtva = 0; + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; if (empty($fk_prev_id)) $fk_prev_id = 'null'; - if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; + if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - $pu_ht=price2num($pu_ht); - $pu_ht_devise=price2num($pu_ht_devise); - $pu_ttc=price2num($pu_ttc); - $pa_ht=price2num($pa_ht); + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + $pu_ht = price2num($pu_ht); + $pu_ht_devise = price2num($pu_ht_devise); + $pu_ttc = price2num($pu_ttc); + $pa_ht = price2num($pa_ht); if (!preg_match('/\((.*)\)/', $txtva)) { - $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' } - $txlocaltax1=price2num($txlocaltax1); - $txlocaltax2=price2num($txlocaltax2); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); - if ($price_base_type=='HT') + if ($price_base_type == 'HT') { - $pu=$pu_ht; + $pu = $pu_ht; } else { - $pu=$pu_ttc; + $pu = $pu_ttc; } // Check parameters @@ -2828,35 +2828,35 @@ class Facture extends CommonInvoice if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } $this->db->begin(); - $product_type=$type; + $product_type = $type; if (!empty($fk_product)) { - $product=new Product($this->db); - $result=$product->fetch($fk_product); - $product_type=$product->type; + $product = new Product($this->db); + $result = $product->fetch($fk_product); + $product_type = $product->type; - if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { + if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); $this->db->rollback(); return -3; } } - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } // Calcul du total TTC et de la TVA pour la ligne a partir de @@ -2874,7 +2874,7 @@ class Facture extends CommonInvoice $pu_ht = $tabprice[3]; // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; @@ -2888,72 +2888,72 @@ class Facture extends CommonInvoice } // Insert line - $this->line=new FactureLigne($this->db); + $this->line = new FactureLigne($this->db); $this->line->context = $this->context; - $this->line->fk_facture=$this->id; - $this->line->label=$label; // deprecated - $this->line->desc=$desc; + $this->line->fk_facture = $this->id; + $this->line->label = $label; // deprecated + $this->line->desc = $desc; - $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative - $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise - $this->line->vat_src_code=$vat_src_code; - $this->line->tva_tx=$txtva; - $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); - $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); + $this->line->vat_src_code = $vat_src_code; + $this->line->tva_tx = $txtva; + $this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0); + $this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0); $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; - $this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); // For credit note and if qty is negative, total is negative - $this->line->total_tva= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); // For credit note and if qty is negative, total is negative - $this->line->total_localtax1=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax1):$total_localtax1); // For credit note and if qty is negative, total is negative - $this->line->total_localtax2=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax2):$total_localtax2); // For credit note and if qty is negative, total is negative + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative + $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative + $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative - $this->line->fk_product=$fk_product; - $this->line->product_type=$product_type; - $this->line->remise_percent=$remise_percent; - $this->line->date_start=$date_start; - $this->line->date_end=$date_end; - $this->line->ventil=$ventil; - $this->line->rang=$ranktouse; - $this->line->info_bits=$info_bits; - $this->line->fk_remise_except=$fk_remise_except; + $this->line->fk_product = $fk_product; + $this->line->product_type = $product_type; + $this->line->remise_percent = $remise_percent; + $this->line->date_start = $date_start; + $this->line->date_end = $date_end; + $this->line->ventil = $ventil; + $this->line->rang = $ranktouse; + $this->line->info_bits = $info_bits; + $this->line->fk_remise_except = $fk_remise_except; - $this->line->special_code=$special_code; - $this->line->fk_parent_line=$fk_parent_line; - $this->line->origin=$origin; - $this->line->origin_id=$origin_id; + $this->line->special_code = $special_code; + $this->line->fk_parent_line = $fk_parent_line; + $this->line->origin = $origin; + $this->line->origin_id = $origin_id; $this->line->situation_percent = $situation_percent; $this->line->fk_prev_id = $fk_prev_id; - $this->line->fk_unit=$fk_unit; + $this->line->fk_unit = $fk_unit; // infos marge $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - if (is_array($array_options) && count($array_options)>0) { - $this->line->array_options=$array_options; + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; } - $result=$this->line->insert(); + $result = $this->line->insert(); if ($result > 0) { // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); // Mise a jour informations denormalisees au niveau de la facture meme - $result=$this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. + $result = $this->update_price(1, 'auto', 0, $mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. if ($result > 0) { @@ -2962,14 +2962,14 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } } else { - $this->error=$this->line->error; + $this->error = $this->line->error; $this->db->rollback(); return -2; } @@ -3012,15 +3012,15 @@ class Facture extends CommonInvoice */ public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { - global $conf,$user; + global $conf, $user; // Deprecation warning if ($label) { - dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + dol_syslog(__METHOD__.": using line label is deprecated", LOG_WARNING); } include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - global $mysoc,$langs; + global $mysoc, $langs; dol_syslog(get_class($this)."::updateline rowid=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, date_start=$date_start, date_end=$date_end, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, type=$type, fk_parent_line=$fk_parent_line pa_ht=$pa_ht, special_code=$special_code, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); @@ -3030,29 +3030,29 @@ class Facture extends CommonInvoice { if (!$this->checkProgressLine($rowid, $situation_percent)) { - if (!$this->error) $this->error=$langs->trans('invoiceLineProgressError'); + if (!$this->error) $this->error = $langs->trans('invoiceLineProgressError'); return -3; } } if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } $this->db->begin(); // Clean parameters - if (empty($qty)) $qty=0; - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; - if (empty($special_code) || $special_code == 3) $special_code=0; - if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; + if (empty($qty)) $qty = 0; + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; + if (empty($special_code) || $special_code == 3) $special_code = 0; + if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; - $remise_percent = price2num($remise_percent); + $remise_percent = price2num($remise_percent); $qty = price2num($qty); $pu = price2num($pu); - $pu_ht_devise = price2num($pu_ht_devise); + $pu_ht_devise = price2num($pu_ht_devise); $pa_ht = price2num($pa_ht); $txtva = price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); @@ -3065,29 +3065,29 @@ class Facture extends CommonInvoice // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; - $total_localtax1=$tabprice[9]; - $total_localtax2=$tabprice[10]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; $pu_ht = $tabprice[3]; $pu_tva = $tabprice[4]; $pu_ttc = $tabprice[5]; // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; @@ -3100,7 +3100,7 @@ class Facture extends CommonInvoice $remise = round(($pu * $remise_percent / 100), 2); $price = ($pu - $remise); } - $price = price2num($price); + $price = price2num($price); //Fetch current line from the database and then clone the object and set it in $oldline property $line = new FactureLigne($this->db); @@ -3108,13 +3108,13 @@ class Facture extends CommonInvoice if (!empty($line->fk_product)) { - $product=new Product($this->db); - $result=$product->fetch($line->fk_product); - $product_type=$product->type; + $product = new Product($this->db); + $result = $product->fetch($line->fk_product); + $product_type = $product->type; - if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { + if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); $this->db->rollback(); return -3; } @@ -3127,7 +3127,7 @@ class Facture extends CommonInvoice $this->line->context = $this->context; // Reorder if fk_parent_line change - if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) + if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { $rangmax = $this->line_max($fk_parent_line); $this->line->rang = $rangmax + 1; @@ -3135,32 +3135,32 @@ class Facture extends CommonInvoice $this->line->rowid = $rowid; $this->line->label = $label; - $this->line->desc = $desc; - $this->line->qty = ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative + $this->line->desc = $desc; + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative - $this->line->vat_src_code = $vat_src_code; - $this->line->tva_tx = $txtva; + $this->line->vat_src_code = $vat_src_code; + $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; - $this->line->subprice = ($this->type==2?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise - $this->line->date_start = $date_start; + $this->line->subprice = ($this->type == 2 ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->date_start = $date_start; $this->line->date_end = $date_end; - $this->line->total_ht = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); $this->line->total_localtax1 = $total_localtax1; $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); $this->line->info_bits = $info_bits; $this->line->special_code = $special_code; $this->line->product_type = $type; - $this->line->fk_parent_line = $fk_parent_line; - $this->line->skip_update_total = $skip_update_total; - $this->line->situation_percent = $situation_percent; - $this->line->fk_unit = $fk_unit; + $this->line->fk_parent_line = $fk_parent_line; + $this->line->skip_update_total = $skip_update_total; + $this->line->situation_percent = $situation_percent; + $this->line->fk_unit = $fk_unit; $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; @@ -3171,15 +3171,15 @@ class Facture extends CommonInvoice $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - if (is_array($array_options) && count($array_options)>0) { - $this->line->array_options=$array_options; + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; } - $result=$this->line->update($user, $notrigger); + $result = $this->line->update($user, $notrigger); if ($result > 0) { // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); // Mise a jour info denormalisees au niveau facture $this->update_price(1); @@ -3188,14 +3188,14 @@ class Facture extends CommonInvoice } else { - $this->error=$this->line->error; + $this->error = $this->line->error; $this->db->rollback(); return -1; } } else { - $this->error="Invoice statut makes operation forbidden"; + $this->error = "Invoice statut makes operation forbidden"; return -2; } } @@ -3215,9 +3215,9 @@ class Facture extends CommonInvoice AND f.fk_statut <> 0'; $result = $this->db->query($sql); - if (! $result) + if (!$result) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return false; } @@ -3238,7 +3238,7 @@ class Facture extends CommonInvoice public function update_percent($line, $percent) { // phpcs:enable - global $mysoc,$user; + global $mysoc, $user; // Progress should never be changed for discount lines if (($line->info_bits & 2) == 2) @@ -3276,9 +3276,9 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); - if (! $this->brouillon) + if (!$this->brouillon) { - $this->error='ErrorDeleteLineNotAllowedByObjectStatus'; + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -1; } @@ -3286,29 +3286,29 @@ class Facture extends CommonInvoice // Libere remise liee a ligne de facture $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' SET fk_facture_line = NULL'; - $sql.= ' WHERE fk_facture_line = '.$rowid; + $sql .= ' SET fk_facture_line = NULL'; + $sql .= ' WHERE fk_facture_line = '.$rowid; dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) + if (!$result) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } - $line=new FactureLigne($this->db); + $line = new FactureLigne($this->db); $line->context = $this->context; // For triggers $result = $line->fetch($rowid); - if (! ($result > 0)) dol_print_error($this->db, $line->error, $line->errors); + if (!($result > 0)) dol_print_error($this->db, $line->error, $line->errors); if ($line->delete($user) > 0) { - $result=$this->update_price(1); + $result = $this->update_price(1); if ($result > 0) { @@ -3318,14 +3318,14 @@ class Facture extends CommonInvoice else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } else { $this->db->rollback(); - $this->error=$line->error; + $this->error = $line->error; return -1; } } @@ -3343,38 +3343,38 @@ class Facture extends CommonInvoice { // phpcs:enable // Clean parameters - if (empty($remise)) $remise=0; + if (empty($remise)) $remise = 0; if ($user->rights->facture->creer) { - $remise=price2num($remise); + $remise = price2num($remise); - $error=0; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET remise_percent = '.$remise; - $sql.= ' WHERE rowid = '.$this->id; - $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; + $sql .= ' SET remise_percent = '.$remise; + $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' AND fk_statut = '.self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('BILL_MODIFY', $user); + $result = $this->call_trigger('BILL_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->remise_percent = $remise; $this->update_price(1); @@ -3384,13 +3384,13 @@ class Facture extends CommonInvoice } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } } @@ -3408,58 +3408,58 @@ class Facture extends CommonInvoice public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable - if (empty($remise)) $remise=0; + if (empty($remise)) $remise = 0; if ($user->rights->facture->creer) { - $error=0; + $error = 0; $this->db->begin(); - $remise=price2num($remise); + $remise = price2num($remise); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET remise_absolue = '.$remise; - $sql.= ' WHERE rowid = '.$this->id; - $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; + $sql .= ' SET remise_absolue = '.$remise; + $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' AND fk_statut = '.self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; $this->remise_absolue = $remise; $this->update_price(1); } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('BILL_MODIFY', $user); + $result = $this->call_trigger('BILL_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } } @@ -3478,15 +3478,15 @@ class Facture extends CommonInvoice $langs->load("bills"); // Clean parameters (if not defined or using deprecated value) - if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON='mod_facture_terre'; - elseif ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre'; - elseif ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure'; + if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON = 'mod_facture_terre'; + elseif ($conf->global->FACTURE_ADDON == 'terre') $conf->global->FACTURE_ADDON = 'mod_facture_terre'; + elseif ($conf->global->FACTURE_ADDON == 'mercure') $conf->global->FACTURE_ADDON = 'mod_facture_mercure'; - if (! empty($conf->global->FACTURE_ADDON)) + if (!empty($conf->global->FACTURE_ADDON)) { dol_syslog("Call getNextNumRef with FACTURE_ADDON = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->nom.", type=".$soc->typent_code, LOG_DEBUG); - $mybool=false; + $mybool = false; $file = $conf->global->FACTURE_ADDON.".php"; @@ -3502,12 +3502,12 @@ class Facture extends CommonInvoice // Load file with numbering class (if found) if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir . $file; + $mybool |= include_once $dir.$file; } } // For compatibility - if (! $mybool) + if (!$mybool) { $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; $classname = "mod_facture_".$conf->global->FACTURE_ADDON; @@ -3519,12 +3519,12 @@ class Facture extends CommonInvoice // Load file with numbering class (if found) if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir . $file; + $mybool |= include_once $dir.$file; } } } - if (! $mybool) + if (!$mybool) { dol_print_error('', "Failed to include file ".$file); return ''; @@ -3539,7 +3539,7 @@ class Facture extends CommonInvoice * set up mask. */ if ($mode != 'last' && !$numref) { - $this->error=$obj->error; + $this->error = $obj->error; //dol_print_error($this->db,"Facture::getNextNumRef ".$obj->error); return ""; } @@ -3563,12 +3563,12 @@ class Facture extends CommonInvoice public function info($id) { $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; - $sql.= ' date_closing as dateclosing,'; - $sql.= ' fk_user_author, fk_user_valid, fk_user_closing'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as c'; - $sql.= ' WHERE c.rowid = '.$id; + $sql .= ' date_closing as dateclosing,'; + $sql .= ' fk_user_author, fk_user_valid, fk_user_closing'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as c'; + $sql .= ' WHERE c.rowid = '.$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -3579,7 +3579,7 @@ class Facture extends CommonInvoice { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) { @@ -3591,7 +3591,7 @@ class Facture extends CommonInvoice { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_closing); - $this->user_closing = $cluser; + $this->user_closing = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); @@ -3625,28 +3625,28 @@ class Facture extends CommonInvoice public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') { // phpcs:enable - global $conf,$user; + global $conf, $user; $ga = array(); $sql = "SELECT s.rowid, s.nom as name, s.client,"; - $sql.= " f.rowid as fid, f.ref as ref, f.datef as df"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.entity IN (".getEntity('invoice').")"; - $sql.= " AND f.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) //restriction + $sql .= " f.rowid as fid, f.ref as ref, f.datef as df"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').")"; + $sql .= " AND f.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) //restriction { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } - if ($socid) $sql.= " AND s.rowid = ".$socid; - if ($draft) $sql.= " AND f.fk_statut = ".self::STATUS_DRAFT; - if (is_object($excluser)) $sql.= " AND f.fk_user_author <> ".$excluser->id; - $sql.= $this->db->order($sortfield, $sortorder); - $sql.= $this->db->plimit($limit, $offset); + if ($socid) $sql .= " AND s.rowid = ".$socid; + if ($draft) $sql .= " AND f.fk_statut = ".self::STATUS_DRAFT; + if (is_object($excluser)) $sql .= " AND f.fk_user_author <> ".$excluser->id; + $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit, $offset); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { $numc = $this->db->num_rows($result); @@ -3667,7 +3667,7 @@ class Facture extends CommonInvoice } else { - $ga[$i]['id'] = $obj->fid; + $ga[$i]['id'] = $obj->fid; $ga[$i]['ref'] = $obj->ref; $ga[$i]['name'] = $obj->name; } @@ -3701,25 +3701,25 @@ class Facture extends CommonInvoice $return = array(); $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut,"; - $sql.= " ff.rowid as rowidnext"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source"; - $sql.= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= " AND f.paye = 0"; // Pas classee payee completement - $sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait - $sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; - $sql.= " ORDER BY f.ref"; + $sql .= " ff.rowid as rowidnext"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source"; + $sql .= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND f.paye = 0"; // Pas classee payee completement + $sql .= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait + $sql .= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement + if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + $sql .= " ORDER BY f.ref"; dol_syslog(get_class($this)."::list_replacable_invoices", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $return[$obj->rowid]=array( 'id' => $obj->rowid, + $return[$obj->rowid] = array('id' => $obj->rowid, 'ref' => $obj->ref, 'status' => $obj->fk_statut); } @@ -3728,7 +3728,7 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -3752,50 +3752,50 @@ class Facture extends CommonInvoice $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut, f.type, f.paye, pf.fk_paiement"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; - $sql.= " WHERE f.entity IN (".getEntity('invoice').")"; - $sql.= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').")"; + $sql .= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; // $sql.= " WHERE f.fk_statut >= 1"; // $sql.= " AND (f.paye = 1"; // Classee payee completement // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement - $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement - $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir + $sql .= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement + $sql .= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir - if (! empty($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE)) { + if (!empty($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE)) { // Select the last situation invoice $sqlSit = 'SELECT MAX(fs.rowid)'; - $sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs"; - $sqlSit.= " WHERE fs.entity IN (".getEntity('invoice').")"; - $sqlSit.= " AND fs.type = ".self::TYPE_SITUATION; - $sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; - $sqlSit.= " GROUP BY fs.situation_cycle_ref"; - $sqlSit.= " ORDER BY fs.situation_counter"; - $sql.= " AND ( f.type != ".self::TYPE_SITUATION . " OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir + $sqlSit .= " FROM ".MAIN_DB_PREFIX."facture as fs"; + $sqlSit .= " WHERE fs.entity IN (".getEntity('invoice').")"; + $sqlSit .= " AND fs.type = ".self::TYPE_SITUATION; + $sqlSit .= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; + $sqlSit .= " GROUP BY fs.situation_cycle_ref"; + $sqlSit .= " ORDER BY fs.situation_counter"; + $sql .= " AND ( f.type != ".self::TYPE_SITUATION." OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir } else { - $sql.= " AND f.type != ".self::TYPE_SITUATION ; // Type non 5 si facture non avoir + $sql .= " AND f.type != ".self::TYPE_SITUATION; // Type non 5 si facture non avoir } - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; - $sql.= " ORDER BY f.ref"; + if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + $sql .= " ORDER BY f.ref"; dol_syslog(get_class($this)."::list_qualified_avoir_invoices", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $qualified=0; - if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified=1; - if ($obj->fk_statut == self::STATUS_CLOSED) $qualified=1; + $qualified = 0; + if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified = 1; + if ($obj->fk_statut == self::STATUS_CLOSED) $qualified = 1; if ($qualified) { //$ref=$obj->ref; - $paymentornot=($obj->fk_paiement?1:0); - $return[$obj->rowid]=array('ref'=>$obj->ref,'status'=>$obj->fk_statut,'type'=>$obj->type,'paye'=>$obj->paye,'paymentornot'=>$paymentornot); + $paymentornot = ($obj->fk_paiement ? 1 : 0); + $return[$obj->rowid] = array('ref'=>$obj->ref, 'status'=>$obj->fk_statut, 'type'=>$obj->type, 'paye'=>$obj->paye, 'paymentornot'=>$paymentornot); } } @@ -3803,7 +3803,7 @@ class Facture extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -3822,31 +3822,31 @@ class Facture extends CommonInvoice { // phpcs:enable - $error=0; + $error = 0; dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) { - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $bac = new CompanyBankAccount($this->db); $bac->fetch(0, $this->socid); $sql = 'SELECT count(*)'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; - $sql.= ' WHERE fk_facture = '.$this->id; - $sql.= ' AND traite = 0'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; + $sql .= ' WHERE fk_facture = '.$this->id; + $sql .= ' AND traite = 0'; dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $row = $this->db->fetch_row($resql); if ($row[0] == 0) { - $now=dol_now(); + $now = dol_now(); - $totalpaye = $this->getSommePaiement(); + $totalpaye = $this->getSommePaiement(); $totalcreditnotes = $this->getSumCreditNotesUsed(); $totaldeposits = $this->getSumDepositsUsed(); //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; @@ -3871,28 +3871,28 @@ class Facture extends CommonInvoice $sql .= ",'".$bac->cle_rib."')"; dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::demandeprelevement Erreur'); $error++; } } else { - $this->error='WithdrawRequestErrorNilAmount'; + $this->error = 'WithdrawRequestErrorNilAmount'; dol_syslog(get_class($this).'::demandeprelevement WithdrawRequestErrorNilAmount'); $error++; } - if (! $error) + if (!$error) { // Force payment mode of invoice to withdraw $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1); if ($payment_mode_id > 0) { - $result=$this->setPaymentMethods($payment_mode_id); + $result = $this->setPaymentMethods($payment_mode_id); } } @@ -3901,21 +3901,21 @@ class Facture extends CommonInvoice } else { - $this->error="A request already exists"; + $this->error = "A request already exists"; dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours'); return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); dol_syslog(get_class($this).'::demandeprelevement Erreur -2'); return -2; } } else { - $this->error="Status of invoice does not allow this"; + $this->error = "Status of invoice does not allow this"; dol_syslog(get_class($this)."::demandeprelevement ".$this->error." $this->statut, $this->paye, $this->mode_reglement_id"); return -3; } @@ -3935,13 +3935,13 @@ class Facture extends CommonInvoice $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; $sql .= ' WHERE rowid = '.$did; $sql .= ' AND traite = 0'; - if ( $this->db->query($sql) ) + if ($this->db->query($sql)) { return 0; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::demande_prelevement_delete Error '.$this->error); return -1; } @@ -3963,34 +3963,34 @@ class Facture extends CommonInvoice $clause = " WHERE"; $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut, f.total"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; $clause = " AND"; } - $sql.= $clause." f.paye=0"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= " AND f.fk_statut = ".self::STATUS_VALIDATED; - if ($user->socid) $sql.= " AND f.fk_soc = ".$user->socid; + $sql .= $clause." f.paye=0"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND f.fk_statut = ".self::STATUS_VALIDATED; + if ($user->socid) $sql .= " AND f.fk_soc = ".$user->socid; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $langs->load("bills"); - $now=dol_now(); + $now = dol_now(); $response = new WorkboardResponse(); - $response->warning_delay=$conf->facture->client->warning_delay/60/60/24; - $response->label=$langs->trans("CustomerBillsUnpaid"); - $response->labelShort=$langs->trans("Unpaid"); - $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=billing&leftmenu=customers_bills'; - $response->img=img_object('', "bill"); + $response->warning_delay = $conf->facture->client->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("CustomerBillsUnpaid"); + $response->labelShort = $langs->trans("Unpaid"); + $response->url = DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=billing&leftmenu=customers_bills'; + $response->img = img_object('', "bill"); $generic_facture = new Facture($this->db); - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { $generic_facture->date_lim_reglement = $this->db->jdate($obj->datefin); $generic_facture->statut = $obj->fk_statut; @@ -4008,7 +4008,7 @@ class Facture extends CommonInvoice else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -4049,16 +4049,16 @@ class Facture extends CommonInvoice { global $langs; - $now=dol_now(); - $arraynow=dol_getdate($now); - $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); + $now = dol_now(); + $arraynow = dol_getdate($now); + $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -4073,27 +4073,27 @@ class Facture extends CommonInvoice } //Avoid php warning Warning: mt_rand(): max(0) is smaller than min(1) when no product exists if (empty($num_prods)) { - $num_prods=1; + $num_prods = 1; } // Initialize parameters - $this->id=0; + $this->id = 0; $this->entity = 1; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->socid = 1; $this->date = $nownotime; - $this->date_lim_reglement = $nownotime + 3600 * 24 *30; + $this->date_lim_reglement = $nownotime + 3600 * 24 * 30; $this->cond_reglement_id = 1; $this->cond_reglement_code = 'RECEP'; - $this->date_lim_reglement=$this->calculate_date_lim_reglement(); - $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR - $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR - $this->note_public='This is a comment (public)'; - $this->note_private='This is a comment (private)'; - $this->note='This is a comment (private)'; - $this->fk_incoterms=0; - $this->location_incoterms=''; + $this->date_lim_reglement = $this->calculate_date_lim_reglement(); + $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR + $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR + $this->note_public = 'This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; + $this->note = 'This is a comment (private)'; + $this->fk_incoterms = 0; + $this->location_incoterms = ''; if (empty($option) || $option != 'nolines') { @@ -4102,63 +4102,63 @@ class Facture extends CommonInvoice $xnbp = 0; while ($xnbp < $nbp) { - $line=new FactureLigne($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->qty=1; - $line->subprice=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; - $line->remise_percent=0; + $line = new FactureLigne($this->db); + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->qty = 1; + $line->subprice = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; + $line->remise_percent = 0; if ($xnbp == 1) // Qty is negative (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->qty=-1; - $line->total_ht=-100; - $line->total_ttc=-119.6; - $line->total_tva=-19.6; - $line->multicurrency_total_ht=-200; - $line->multicurrency_total_ttc=-239.2; - $line->multicurrency_total_tva=-39.2; + $line->fk_product = $prodids[$prodid]; + $line->qty = -1; + $line->total_ht = -100; + $line->total_ttc = -119.6; + $line->total_tva = -19.6; + $line->multicurrency_total_ht = -200; + $line->multicurrency_total_ttc = -239.2; + $line->multicurrency_total_tva = -39.2; } elseif ($xnbp == 2) // UP is negative (free line) { - $line->subprice=-100; - $line->total_ht=-100; - $line->total_ttc=-119.6; - $line->total_tva=-19.6; - $line->remise_percent=0; - $line->multicurrency_total_ht=-200; - $line->multicurrency_total_ttc=-239.2; - $line->multicurrency_total_tva=-39.2; + $line->subprice = -100; + $line->total_ht = -100; + $line->total_ttc = -119.6; + $line->total_tva = -19.6; + $line->remise_percent = 0; + $line->multicurrency_total_ht = -200; + $line->multicurrency_total_ttc = -239.2; + $line->multicurrency_total_tva = -39.2; } elseif ($xnbp == 3) // Discount is 50% (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->total_ht=50; - $line->total_ttc=59.8; - $line->total_tva=9.8; - $line->multicurrency_total_ht=100; - $line->multicurrency_total_ttc=119.6; - $line->multicurrency_total_tva=19.6; - $line->remise_percent=50; + $line->fk_product = $prodids[$prodid]; + $line->total_ht = 50; + $line->total_ttc = 59.8; + $line->total_tva = 9.8; + $line->multicurrency_total_ht = 100; + $line->multicurrency_total_ttc = 119.6; + $line->multicurrency_total_tva = 19.6; + $line->remise_percent = 50; } else // (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->total_ht=100; - $line->total_ttc=119.6; - $line->total_tva=19.6; - $line->multicurrency_total_ht=200; - $line->multicurrency_total_ttc=239.2; - $line->multicurrency_total_tva=39.2; - $line->remise_percent=0; + $line->fk_product = $prodids[$prodid]; + $line->total_ht = 100; + $line->total_ttc = 119.6; + $line->total_tva = 19.6; + $line->multicurrency_total_ht = 200; + $line->multicurrency_total_ttc = 239.2; + $line->multicurrency_total_tva = 39.2; + $line->remise_percent = 0; } - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $this->total_ht += $line->total_ht; @@ -4174,24 +4174,24 @@ class Facture extends CommonInvoice $this->revenuestamp = 0; // Add a line "offered" - $line=new FactureLigne($this->db); - $line->desc=$langs->trans("Description")." (offered line)"; - $line->qty=1; - $line->subprice=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; - $line->remise_percent=100; - $line->total_ht=0; - $line->total_ttc=0; // 90 * 1.196 - $line->total_tva=0; - $line->multicurrency_total_ht=0; - $line->multicurrency_total_ttc=0; - $line->multicurrency_total_tva=0; + $line = new FactureLigne($this->db); + $line->desc = $langs->trans("Description")." (offered line)"; + $line->qty = 1; + $line->subprice = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; + $line->remise_percent = 100; + $line->total_ht = 0; + $line->total_ttc = 0; // 90 * 1.196 + $line->total_tva = 0; + $line->multicurrency_total_ht = 0; + $line->multicurrency_total_ttc = 0; + $line->multicurrency_total_tva = 0; $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + $line->fk_product = $prodids[$prodid]; - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $xnbp++; } } @@ -4207,27 +4207,27 @@ class Facture extends CommonInvoice // phpcs:enable global $conf, $user; - $this->nb=array(); + $this->nb = array(); $clause = "WHERE"; $sql = "SELECT count(f.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; $clause = "AND"; } - $sql.= " ".$clause." f.entity IN (".getEntity('invoice').")"; + $sql .= " ".$clause." f.entity IN (".getEntity('invoice').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["invoices"]=$obj->nb; + $this->nb["invoices"] = $obj->nb; } $this->db->free($resql); return 1; @@ -4235,7 +4235,7 @@ class Facture extends CommonInvoice else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -4263,20 +4263,20 @@ class Facture extends CommonInvoice */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("bills"); - if (! dol_strlen($modele)) + if (!dol_strlen($modele)) { $modele = 'crabe'; $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$this->type; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->$thisTypeConfName)) { + } elseif (!empty($conf->global->$thisTypeConfName)) { $modele = $conf->global->$thisTypeConfName; - } elseif (! empty($conf->global->FACTURE_ADDON_PDF)) { + } elseif (!empty($conf->global->FACTURE_ADDON_PDF)) { $modele = $conf->global->FACTURE_ADDON_PDF; } } @@ -4293,8 +4293,8 @@ class Facture extends CommonInvoice */ public function newCycle() { - $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; - $sql.= " WHERE f.entity IN (".getEntity('invoice', 0).")"; + $sql = 'SELECT max(situation_cycle_ref) FROM '.MAIN_DB_PREFIX.'facture as f'; + $sql .= " WHERE f.entity IN (".getEntity('invoice', 0).")"; $resql = $this->db->query($sql); if ($resql) { if ($resql->num_rows > 0) @@ -4309,7 +4309,7 @@ class Facture extends CommonInvoice return $ref; } else { $this->error = $this->db->lasterror(); - dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR); return -1; } } @@ -4337,10 +4337,10 @@ class Facture extends CommonInvoice // phpcs:enable global $conf; - $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture'; - $sql .= ' WHERE situation_cycle_ref = ' . $this->situation_cycle_ref; - $sql .= ' AND situation_counter < ' . $this->situation_counter; - $sql .= ' AND entity = '. ($this->entity > 0 ? $this->entity : $conf->entity); + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture'; + $sql .= ' WHERE situation_cycle_ref = '.$this->situation_cycle_ref; + $sql .= ' AND situation_counter < '.$this->situation_counter; + $sql .= ' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); $res = array(); if ($resql && $resql->num_rows > 0) { @@ -4352,7 +4352,7 @@ class Facture extends CommonInvoice } } else { $this->error = $this->db->error(); - dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR); return -1; } @@ -4368,42 +4368,42 @@ class Facture extends CommonInvoice */ public function setFinal(User $user, $notrigger = 0) { - $error=0; + $error = 0; $this->db->begin(); - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET situation_final = '.$this->situation_final.' where rowid = '.$this->id; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('BILL_MODIFY', $user); + $result = $this->call_trigger('BILL_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -4420,9 +4420,9 @@ class Facture extends CommonInvoice if (!empty($this->situation_cycle_ref)) { // No point in testing anything if we're not inside a cycle - $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture'; - $sql.= ' WHERE situation_cycle_ref = ' . $this->situation_cycle_ref; - $sql.= ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); + $sql = 'SELECT max(situation_counter) FROM '.MAIN_DB_PREFIX.'facture'; + $sql .= ' WHERE situation_cycle_ref = '.$this->situation_cycle_ref; + $sql .= ' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); if ($resql && $resql->num_rows > 0) { @@ -4431,7 +4431,7 @@ class Facture extends CommonInvoice return ($last == $this->situation_counter); } else { $this->error = $this->db->lasterror(); - dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::select Error ".$this->error, LOG_ERR); return false; } } else { @@ -4479,40 +4479,40 @@ class Facture extends CommonInvoice */ public function getRetainedWarrantyAmount() { - if(empty($this->retained_warranty) ){ + if (empty($this->retained_warranty)) { return -1; } $retainedWarrantyAmount = 0; // Billed - retained warranty - if($this->type == Facture::TYPE_SITUATION) + if ($this->type == Facture::TYPE_SITUATION) { $displayWarranty = true; // Check if this situation invoice is 100% for real - if(!empty($this->lines)){ - foreach($this->lines as $i => $line){ - if($line->product_type < 2 && $line->situation_percent < 100){ + if (!empty($this->lines)) { + foreach ($this->lines as $i => $line) { + if ($line->product_type < 2 && $line->situation_percent < 100) { $displayWarranty = false; break; } } } - if($displayWarranty && !empty($this->situation_final)) + if ($displayWarranty && !empty($this->situation_final)) { $this->fetchPreviousNextSituationInvoice(); $TPreviousIncoice = $this->tab_previous_situation_invoice; $total2BillWT = 0; - foreach ($TPreviousIncoice as &$fac){ + foreach ($TPreviousIncoice as &$fac) { $total2BillWT += $fac->total_ttc; } $total2BillWT += $this->total_ttc; $retainedWarrantyAmount = $total2BillWT * $this->retained_warranty / 100; } - else{ + else { return -1; } } @@ -4549,14 +4549,14 @@ class Facture extends CommonInvoice else { dol_syslog(get_class($this).'::setRetainedWarranty Erreur '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } else { dol_syslog(get_class($this).'::setRetainedWarranty, status of the object is incompatible'); - $this->error='Status of the object is incompatible '.$this->statut; + $this->error = 'Status of the object is incompatible '.$this->statut; return -2; } } @@ -4571,7 +4571,7 @@ class Facture extends CommonInvoice */ public function setRetainedWarrantyDateLimit($timestamp, $dateYmd = false) { - if(!$timestamp && $dateYmd){ + if (!$timestamp && $dateYmd) { $timestamp = $this->db->jdate($dateYmd); } @@ -4581,7 +4581,7 @@ class Facture extends CommonInvoice { $fieldname = 'retained_warranty_date_limit'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.(strval($timestamp)!='' ? '\'' .$this->db->idate($timestamp).'\'' : 'null' ); + $sql .= ' SET '.$fieldname.' = '.(strval($timestamp) != '' ? '\''.$this->db->idate($timestamp).'\'' : 'null'); $sql .= ' WHERE rowid='.$this->id; if ($this->db->query($sql)) @@ -4592,14 +4592,14 @@ class Facture extends CommonInvoice else { dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit Erreur '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } else { dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit, status of the object is incompatible'); - $this->error='Status of the object is incompatible '.$this->statut; + $this->error = 'Status of the object is incompatible '.$this->statut; return -2; } } @@ -4614,12 +4614,12 @@ class FactureLigne extends CommonInvoiceLine /** * @var string ID to identify managed object */ - public $element='facturedet'; + public $element = 'facturedet'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='facturedet'; + public $table_element = 'facturedet'; public $oldline; @@ -4635,9 +4635,9 @@ class FactureLigne extends CommonInvoiceLine //! Description ligne public $desc; - public $localtax1_type; // Local tax 1 type - public $localtax2_type; // Local tax 2 type - public $fk_remise_except; // Link to line into llx_remise_except + public $localtax1_type; // Local tax 1 type + public $localtax2_type; // Local tax 2 type + public $fk_remise_except; // Link to line into llx_remise_except public $rang = 0; public $fk_fournprice; @@ -4647,7 +4647,7 @@ class FactureLigne extends CommonInvoiceLine public $remise_percent; - public $special_code; // Liste d'options non cumulabels: + public $special_code; // Liste d'options non cumulabels: // 1: frais de port // 2: ecotaxe // 3: ?? @@ -4665,15 +4665,15 @@ class FactureLigne extends CommonInvoiceLine * @deprecated * @see $product_ref */ - public $ref; // Product ref (deprecated) - public $product_ref; // Product ref + public $ref; // Product ref (deprecated) + public $product_ref; // Product ref /** * @deprecated * @see $product_label */ - public $libelle; // Product label (deprecated) - public $product_label; // Product label - public $product_desc; // Description produit + public $libelle; // Product label (deprecated) + public $product_label; // Product label + public $product_desc; // Description produit public $skip_update_total; // Skip update price total for special lines @@ -4704,76 +4704,76 @@ class FactureLigne extends CommonInvoiceLine public function fetch($rowid) { $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; - $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; - $sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; - $sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; - $sql.= ' fd.fk_code_ventilation,'; - $sql.= ' fd.fk_unit, fd.fk_user_author, fd.fk_user_modif,'; - $sql.= ' fd.situation_percent, fd.fk_prev_id,'; - $sql.= ' fd.multicurrency_subprice,'; - $sql.= ' fd.multicurrency_total_ht,'; - $sql.= ' fd.multicurrency_total_tva,'; - $sql.= ' fd.multicurrency_total_ttc,'; - $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; - $sql.= ' WHERE fd.rowid = '.$rowid; + $sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; + $sql .= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; + $sql .= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; + $sql .= ' fd.fk_code_ventilation,'; + $sql .= ' fd.fk_unit, fd.fk_user_author, fd.fk_user_modif,'; + $sql .= ' fd.situation_percent, fd.fk_prev_id,'; + $sql .= ' fd.multicurrency_subprice,'; + $sql .= ' fd.multicurrency_total_ht,'; + $sql .= ' fd.multicurrency_total_tva,'; + $sql .= ' fd.multicurrency_total_ttc,'; + $sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; + $sql .= ' WHERE fd.rowid = '.$rowid; $result = $this->db->query($sql); if ($result) { $objp = $this->db->fetch_object($result); - $this->rowid = $objp->rowid; - $this->id = $objp->rowid; - $this->fk_facture = $objp->fk_facture; - $this->fk_parent_line = $objp->fk_parent_line; + $this->rowid = $objp->rowid; + $this->id = $objp->rowid; + $this->fk_facture = $objp->fk_facture; + $this->fk_parent_line = $objp->fk_parent_line; $this->label = $objp->custom_label; $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->subprice = $objp->subprice; - $this->vat_src_code = $objp->vat_src_code; - $this->tva_tx = $objp->tva_tx; + $this->qty = $objp->qty; + $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; + $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; $this->localtax2_tx = $objp->localtax2_tx; - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; $this->fk_product = $objp->fk_product; - $this->product_type = $objp->product_type; + $this->product_type = $objp->product_type; $this->date_start = $this->db->jdate($objp->date_start); $this->date_end = $this->db->jdate($objp->date_end); $this->info_bits = $objp->info_bits; - $this->tva_npr = ($objp->info_bits & 1 == 1) ? 1 : 0; - $this->special_code = $objp->special_code; + $this->tva_npr = ($objp->info_bits & 1 == 1) ? 1 : 0; + $this->special_code = $objp->special_code; $this->total_ht = $objp->total_ht; $this->total_tva = $objp->total_tva; $this->total_localtax1 = $objp->total_localtax1; $this->total_localtax2 = $objp->total_localtax2; $this->total_ttc = $objp->total_ttc; - $this->fk_code_ventilation = $objp->fk_code_ventilation; + $this->fk_code_ventilation = $objp->fk_code_ventilation; $this->rang = $objp->rang; - $this->fk_fournprice = $objp->fk_fournprice; + $this->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); $this->pa_ht = $marginInfos[0]; $this->marge_tx = $marginInfos[1]; $this->marque_tx = $marginInfos[2]; - $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_libelle; // deprecated + $this->ref = $objp->product_ref; // deprecated + $this->product_ref = $objp->product_ref; + $this->libelle = $objp->product_libelle; // deprecated $this->product_label = $objp->product_libelle; $this->product_desc = $objp->product_desc; $this->fk_unit = $objp->fk_unit; $this->fk_user_modif = $objp->fk_user_modif; - $this->fk_user_author = $objp->fk_user_author; + $this->fk_user_author = $objp->fk_user_author; $this->situation_percent = $objp->situation_percent; $this->fk_prev_id = $objp->fk_prev_id; $this->multicurrency_subprice = $objp->multicurrency_subprice; $this->multicurrency_total_ht = $objp->multicurrency_total_ht; - $this->multicurrency_total_tva= $objp->multicurrency_total_tva; - $this->multicurrency_total_ttc= $objp->multicurrency_total_ttc; + $this->multicurrency_total_tva = $objp->multicurrency_total_tva; + $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; $this->db->free($result); @@ -4795,37 +4795,37 @@ class FactureLigne extends CommonInvoiceLine */ public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0) { - global $langs,$user,$conf; + global $langs, $user, $conf; - $error=0; + $error = 0; $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG); // Clean parameters - $this->desc=trim($this->desc); - if (empty($this->tva_tx)) $this->tva_tx=0; - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; - if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->rang)) $this->rang=0; - if (empty($this->remise_percent)) $this->remise_percent=0; - if (empty($this->info_bits)) $this->info_bits=0; - if (empty($this->subprice)) $this->subprice=0; - if (empty($this->special_code)) $this->special_code=0; - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + $this->desc = trim($this->desc); + if (empty($this->tva_tx)) $this->tva_tx = 0; + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; + if (empty($this->localtax1_type)) $this->localtax1_type = 0; + if (empty($this->localtax2_type)) $this->localtax2_type = 0; + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; + if (empty($this->rang)) $this->rang = 0; + if (empty($this->remise_percent)) $this->remise_percent = 0; + if (empty($this->info_bits)) $this->info_bits = 0; + if (empty($this->subprice)) $this->subprice = 0; + if (empty($this->special_code)) $this->special_code = 0; + if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; if (empty($this->fk_prev_id)) $this->fk_prev_id = 0; - if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; + if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; - if (empty($this->pa_ht)) $this->pa_ht=0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; + if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) @@ -4843,16 +4843,16 @@ class FactureLigne extends CommonInvoiceLine // Check parameters if ($this->product_type < 0) { - $this->error='ErrorProductTypeMustBe0orMore'; + $this->error = 'ErrorProductTypeMustBe0orMore'; return -1; } - if (! empty($this->fk_product)) + if (!empty($this->fk_product)) { // Check product exists - $result=Product::isExistingObject('product', $this->fk_product); + $result = Product::isExistingObject('product', $this->fk_product); if ($result <= 0) { - $this->error='ErrorProductIdDoesNotExists'; + $this->error = 'ErrorProductIdDoesNotExists'; dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); return -1; } @@ -4862,68 +4862,68 @@ class FactureLigne extends CommonInvoiceLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet'; - $sql.= ' (fk_facture, fk_parent_line, label, description, qty,'; - $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; - $sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; - $sql.= ' date_start, date_end, fk_code_ventilation, '; - $sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; - $sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; - $sql.= ' situation_percent, fk_prev_id,'; - $sql.= ' fk_unit, fk_user_author, fk_user_modif,'; - $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; - $sql.= ')'; - $sql.= " VALUES (".$this->fk_facture.","; - $sql.= " ".($this->fk_parent_line>0 ? $this->fk_parent_line:"null").","; - $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; - $sql.= " '".$this->db->escape($this->desc)."',"; - $sql.= " ".price2num($this->qty).","; - $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").","; - $sql.= " ".price2num($this->tva_tx).","; - $sql.= " ".price2num($this->localtax1_tx).","; - $sql.= " ".price2num($this->localtax2_tx).","; - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; - $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").','; - $sql.= " ".((int) $this->product_type).","; - $sql.= " ".price2num($this->remise_percent).","; - $sql.= " ".price2num($this->subprice).","; - $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").','; - $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").","; - $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").","; - $sql.= ' '.$this->fk_code_ventilation.','; - $sql.= ' '.$this->rang.','; - $sql.= ' '.$this->special_code.','; - $sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").','; - $sql.= ' '.price2num($this->pa_ht).','; - $sql.= " '".$this->db->escape($this->info_bits)."',"; - $sql.= " ".price2num($this->total_ht).","; - $sql.= " ".price2num($this->total_tva).","; - $sql.= " ".price2num($this->total_ttc).","; - $sql.= " ".price2num($this->total_localtax1).","; - $sql.= " ".price2num($this->total_localtax2); - $sql.= ", " . $this->situation_percent; - $sql.= ", " . (!empty($this->fk_prev_id)?$this->fk_prev_id:"null"); - $sql.= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ", ".$user->id; - $sql.= ", ".$user->id; - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".price2num($this->multicurrency_subprice); - $sql.= ", ".price2num($this->multicurrency_total_ht); - $sql.= ", ".price2num($this->multicurrency_total_tva); - $sql.= ", ".price2num($this->multicurrency_total_ttc); - $sql.= ')'; + $sql .= ' (fk_facture, fk_parent_line, label, description, qty,'; + $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql .= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; + $sql .= ' date_start, date_end, fk_code_ventilation, '; + $sql .= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; + $sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; + $sql .= ' situation_percent, fk_prev_id,'; + $sql .= ' fk_unit, fk_user_author, fk_user_modif,'; + $sql .= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; + $sql .= ')'; + $sql .= " VALUES (".$this->fk_facture.","; + $sql .= " ".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null").","; + $sql .= " ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; + $sql .= " '".$this->db->escape($this->desc)."',"; + $sql .= " ".price2num($this->qty).","; + $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; + $sql .= " ".price2num($this->tva_tx).","; + $sql .= " ".price2num($this->localtax1_tx).","; + $sql .= " ".price2num($this->localtax2_tx).","; + $sql .= " '".$this->db->escape($this->localtax1_type)."',"; + $sql .= " '".$this->db->escape($this->localtax2_type)."',"; + $sql .= ' '.(!empty($this->fk_product) ? $this->fk_product : "null").','; + $sql .= " ".((int) $this->product_type).","; + $sql .= " ".price2num($this->remise_percent).","; + $sql .= " ".price2num($this->subprice).","; + $sql .= ' '.(!empty($this->fk_remise_except) ? $this->fk_remise_except : "null").','; + $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").","; + $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").","; + $sql .= ' '.$this->fk_code_ventilation.','; + $sql .= ' '.$this->rang.','; + $sql .= ' '.$this->special_code.','; + $sql .= ' '.(!empty($this->fk_fournprice) ? $this->fk_fournprice : "null").','; + $sql .= ' '.price2num($this->pa_ht).','; + $sql .= " '".$this->db->escape($this->info_bits)."',"; + $sql .= " ".price2num($this->total_ht).","; + $sql .= " ".price2num($this->total_tva).","; + $sql .= " ".price2num($this->total_ttc).","; + $sql .= " ".price2num($this->total_localtax1).","; + $sql .= " ".price2num($this->total_localtax2); + $sql .= ", ".$this->situation_percent; + $sql .= ", ".(!empty($this->fk_prev_id) ? $this->fk_prev_id : "null"); + $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= ", ".$user->id; + $sql .= ", ".$user->id; + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".price2num($this->multicurrency_subprice); + $sql .= ", ".price2num($this->multicurrency_total_ht); + $sql .= ", ".price2num($this->multicurrency_total_tva); + $sql .= ", ".price2num($this->multicurrency_total_ttc); + $sql .= ')'; dol_syslog(get_class($this)."::insert", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); - $this->rowid=$this->id; // For backward compatibility + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); + $this->rowid = $this->id; // For backward compatibility if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -4934,8 +4934,8 @@ class FactureLigne extends CommonInvoiceLine // ce qui la flague comme "consommee". if ($this->fk_remise_except) { - $discount=new DiscountAbsolute($this->db); - $result=$discount->fetch($this->fk_remise_except); + $discount = new DiscountAbsolute($this->db); + $result = $discount->fetch($this->fk_remise_except); if ($result >= 0) { // Check if discount was found @@ -4946,7 +4946,7 @@ class FactureLigne extends CommonInvoiceLine { if (empty($noerrorifdiscountalreadylinked)) { - $this->error=$langs->trans("ErrorDiscountAlreadyUsed", $discount->id); + $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id); dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; @@ -4954,10 +4954,10 @@ class FactureLigne extends CommonInvoiceLine } else { - $result=$discount->link_to_invoice($this->rowid, 0); + $result = $discount->link_to_invoice($this->rowid, 0); if ($result < 0) { - $this->error=$discount->error; + $this->error = $discount->error; dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; @@ -4966,7 +4966,7 @@ class FactureLigne extends CommonInvoiceLine } else { - $this->error=$langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); + $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; @@ -4974,17 +4974,17 @@ class FactureLigne extends CommonInvoiceLine } else { - $this->error=$discount->error; + $this->error = $discount->error; dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } } - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('LINEBILL_INSERT', $user); + $result = $this->call_trigger('LINEBILL_INSERT', $user); if ($result < 0) { $this->db->rollback(); @@ -4998,7 +4998,7 @@ class FactureLigne extends CommonInvoiceLine } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } @@ -5013,33 +5013,33 @@ class FactureLigne extends CommonInvoiceLine */ public function update($user = '', $notrigger = 0) { - global $user,$conf; + global $user, $conf; - $error=0; + $error = 0; $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. // Clean parameters - $this->desc=trim($this->desc); - if (empty($this->tva_tx)) $this->tva_tx=0; - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; - if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->remise_percent)) $this->remise_percent=0; - if (empty($this->info_bits)) $this->info_bits=0; - if (empty($this->special_code)) $this->special_code=0; - if (empty($this->product_type)) $this->product_type=0; - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; - if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; - if (empty($this->pa_ht)) $this->pa_ht=0; + $this->desc = trim($this->desc); + if (empty($this->tva_tx)) $this->tva_tx = 0; + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; + if (empty($this->localtax1_type)) $this->localtax1_type = 0; + if (empty($this->localtax2_type)) $this->localtax2_type = 0; + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; + if (empty($this->remise_percent)) $this->remise_percent = 0; + if (empty($this->info_bits)) $this->info_bits = 0; + if (empty($this->special_code)) $this->special_code = 0; + if (empty($this->product_type)) $this->product_type = 0; + if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; + if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; + if (empty($this->pa_ht)) $this->pa_ht = 0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; // Check parameters if ($this->product_type < 0) return -1; @@ -5061,66 +5061,66 @@ class FactureLigne extends CommonInvoiceLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; - $sql.= " description='".$this->db->escape($this->desc)."'"; - $sql.= ", label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); - $sql.= ", subprice=".price2num($this->subprice).""; - $sql.= ", remise_percent=".price2num($this->remise_percent).""; - if ($this->fk_remise_except) $sql.= ", fk_remise_except=".$this->fk_remise_except; - else $sql.= ", fk_remise_except=null"; - $sql.= ", vat_src_code = '".(empty($this->vat_src_code)?'':$this->db->escape($this->vat_src_code))."'"; - $sql.= ", tva_tx=".price2num($this->tva_tx).""; - $sql.= ", localtax1_tx=".price2num($this->localtax1_tx).""; - $sql.= ", localtax2_tx=".price2num($this->localtax2_tx).""; - $sql.= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql.= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; - $sql.= ", qty=".price2num($this->qty); - $sql.= ", date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null"); - $sql.= ", date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); - $sql.= ", product_type=".$this->product_type; - $sql.= ", info_bits='".$this->db->escape($this->info_bits)."'"; - $sql.= ", special_code='".$this->db->escape($this->special_code)."'"; + $sql .= " description='".$this->db->escape($this->desc)."'"; + $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", subprice=".price2num($this->subprice).""; + $sql .= ", remise_percent=".price2num($this->remise_percent).""; + if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except; + else $sql .= ", fk_remise_except=null"; + $sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->db->escape($this->vat_src_code))."'"; + $sql .= ", tva_tx=".price2num($this->tva_tx).""; + $sql .= ", localtax1_tx=".price2num($this->localtax1_tx).""; + $sql .= ", localtax2_tx=".price2num($this->localtax2_tx).""; + $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql .= ", qty=".price2num($this->qty); + $sql .= ", date_start=".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null"); + $sql .= ", date_end=".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null"); + $sql .= ", product_type=".$this->product_type; + $sql .= ", info_bits='".$this->db->escape($this->info_bits)."'"; + $sql .= ", special_code='".$this->db->escape($this->special_code)."'"; if (empty($this->skip_update_total)) { - $sql.= ", total_ht=".price2num($this->total_ht); - $sql.= ", total_tva=".price2num($this->total_tva); - $sql.= ", total_ttc=".price2num($this->total_ttc); - $sql.= ", total_localtax1=".price2num($this->total_localtax1); - $sql.= ", total_localtax2=".price2num($this->total_localtax2); + $sql .= ", total_ht=".price2num($this->total_ht); + $sql .= ", total_tva=".price2num($this->total_tva); + $sql .= ", total_ttc=".price2num($this->total_ttc); + $sql .= ", total_localtax1=".price2num($this->total_localtax1); + $sql .= ", total_localtax2=".price2num($this->total_localtax2); } - $sql.= ", fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); - $sql.= ", buy_price_ht='".price2num($this->pa_ht)."'"; - $sql.= ", fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); - if (! empty($this->rang)) $sql.= ", rang=".$this->rang; - $sql.= ", situation_percent=" . $this->situation_percent; - $sql.= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ", fk_user_modif =".$user->id; + $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); + $sql .= ", buy_price_ht='".price2num($this->pa_ht)."'"; + $sql .= ", fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); + if (!empty($this->rang)) $sql .= ", rang=".$this->rang; + $sql .= ", situation_percent=".$this->situation_percent; + $sql .= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= ", fk_user_modif =".$user->id; // Multicurrency - $sql.= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql.= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql.= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql.= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; + $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; + $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; + $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $this->id=$this->rowid; - $result=$this->insertExtraFields(); + $this->id = $this->rowid; + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINEBILL_UPDATE', $user); + $result = $this->call_trigger('LINEBILL_UPDATE', $user); if ($result < 0) { $this->db->rollback(); @@ -5133,7 +5133,7 @@ class FactureLigne extends CommonInvoiceLine } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -2; } @@ -5152,7 +5152,7 @@ class FactureLigne extends CommonInvoiceLine $this->db->begin(); // Call trigger - $result=$this->call_trigger('LINEBILL_DELETE', $user); + $result = $this->call_trigger('LINEBILL_DELETE', $user); if ($result < 0) { $this->db->rollback(); @@ -5163,14 +5163,14 @@ class FactureLigne extends CommonInvoiceLine $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if ($this->db->query($sql) ) + if ($this->db->query($sql)) { $this->db->commit(); return 1; } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; } @@ -5190,21 +5190,21 @@ class FactureLigne extends CommonInvoiceLine dol_syslog(get_class($this)."::update_total", LOG_DEBUG); // Clean parameters - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; - $sql.= " total_ht=".price2num($this->total_ht).""; - $sql.= ",total_tva=".price2num($this->total_tva).""; - $sql.= ",total_localtax1=".price2num($this->total_localtax1).""; - $sql.= ",total_localtax2=".price2num($this->total_localtax2).""; - $sql.= ",total_ttc=".price2num($this->total_ttc).""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " total_ht=".price2num($this->total_ht).""; + $sql .= ",total_tva=".price2num($this->total_tva).""; + $sql .= ",total_localtax1=".price2num($this->total_localtax1).""; + $sql .= ",total_localtax2=".price2num($this->total_localtax2).""; + $sql .= ",total_ttc=".price2num($this->total_ttc).""; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update_total", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); @@ -5212,7 +5212,7 @@ class FactureLigne extends CommonInvoiceLine } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -2; } @@ -5236,28 +5236,28 @@ class FactureLigne extends CommonInvoiceLine } else { // If invoice is not a situation invoice, this->fk_prev_id is used for something else if (!isset($invoicecache[$invoiceid])) { - $invoicecache[$invoiceid]=new Facture($this->db); + $invoicecache[$invoiceid] = new Facture($this->db); $invoicecache[$invoiceid]->fetch($invoiceid); } if ($invoicecache[$invoiceid]->type != Facture::TYPE_SITUATION) return 0; - $sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id; + $sql = 'SELECT situation_percent FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid='.$this->fk_prev_id; $resql = $this->db->query($sql); if ($resql && $resql->num_rows > 0) { $res = $this->db->fetch_array($resql); $returnPercent = floatval($res['situation_percent']); - if($include_credit_note) { - $sql = 'SELECT fd.situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet fd'; - $sql.= ' JOIN ' . MAIN_DB_PREFIX . 'facture f ON (f.rowid = fd.fk_facture) '; - $sql.= ' WHERE fd.fk_prev_id =' . $this->fk_prev_id; - $sql.= ' AND f.situation_cycle_ref = '.$tmpinvoice->situation_cycle_ref; // Prevent cycle outed - $sql.= ' AND f.type = '.Facture::TYPE_CREDIT_NOTE; + if ($include_credit_note) { + $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd'; + $sql .= ' JOIN '.MAIN_DB_PREFIX.'facture f ON (f.rowid = fd.fk_facture) '; + $sql .= ' WHERE fd.fk_prev_id ='.$this->fk_prev_id; + $sql .= ' AND f.situation_cycle_ref = '.$tmpinvoice->situation_cycle_ref; // Prevent cycle outed + $sql .= ' AND f.type = '.Facture::TYPE_CREDIT_NOTE; $res = $this->db->query($sql); - if($res) { - while($obj = $this->db->fetch_object($res)) { + if ($res) { + while ($obj = $this->db->fetch_object($res)) { $returnPercent = $returnPercent + floatval($obj->situation_percent); } } @@ -5266,7 +5266,7 @@ class FactureLigne extends CommonInvoiceLine return $returnPercent; } else { $this->error = $this->db->error(); - dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::select Error ".$this->error, LOG_ERR); $this->db->rollback(); return -1; } diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index fbc09ea4e12..a5a98b052c4 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -31,12 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; // Load translation files required by the page -$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); +$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin")); -$local=GETPOST('localTaxType', 'int'); +$local = GETPOST('localTaxType', 'int'); // Date range -$year=GETPOST("year", "int"); +$year = GETPOST("year", "int"); if (empty($year)) { $year_current = strftime("%Y", dol_now()); @@ -45,29 +45,29 @@ if (empty($year)) $year_current = $year; $year_start = $year; } -$date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); -$date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q"); + $q = GETPOST("q"); if (empty($q)) { - if (GETPOST("month")) { $date_start=dol_get_first_day($year_start, GETPOST("month"), false); $date_end=dol_get_last_day($year_start, GETPOST("month"), false); } + if (GETPOST("month")) { $date_start = dol_get_first_day($year_start, GETPOST("month"), false); $date_end = dol_get_last_day($year_start, GETPOST("month"), false); } else { - $date_start=dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START, false); - if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1; + $date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false); + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; + elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; + elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; } } else { - if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); } - if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); } - if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); } - if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); } + if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } + if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } + if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } + if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } } } @@ -77,12 +77,12 @@ if (empty($min)) $min = 0; // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax", 'int'); -if (empty($modetax)) $modetax=0; +if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int'); +if (empty($modetax)) $modetax = 0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); if (empty($local)) @@ -97,72 +97,72 @@ if (empty($local)) * View */ -$form=new Form($db); -$company_static=new Societe($db); +$form = new Form($db); +$company_static = new Societe($db); -$morequerystring=''; -$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); -foreach($listofparams as $param) +$morequerystring = ''; +$listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); +foreach ($listofparams as $param) { - if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); + if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); } llxHeader('', '', '', '', 0, 0, '', '', $morequerystring); -$name=$langs->transcountry($local==1?"LT1ReportByCustomers":"LT2ReportByCustomers", $mysoc->country_code); +$name = $langs->transcountry($local == 1 ? "LT1ReportByCustomers" : "LT2ReportByCustomers", $mysoc->country_code); -$fsearch =''; -$fsearch.=''; -$fsearch.=''; -$fsearch.=''; -$fsearch.=$langs->trans("SalesTurnoverMinimum").': '; -$fsearch.=''; +$fsearch = ''; +$fsearch .= ''; +$fsearch .= ''; +$fsearch .= ''; +$fsearch .= $langs->trans("SalesTurnoverMinimum").': '; +$fsearch .= ''; -$calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; +$calc = $conf->global->MAIN_INFO_LOCALTAX_CALC.$local; // Affiche en-tete du rapport -if ($calc==0 || $calc==1) // Calculate on invoice for goods and services +if ($calc == 0 || $calc == 1) // Calculate on invoice for goods and services { - $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); - $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; - $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); - if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); - $description.=$fsearch; - $description.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; - $builddate=dol_now(); + $calcmode = $calc == 0 ? $langs->trans("CalcModeLT".$local) : $langs->trans("CalcModeLT".$local."Rec"); + $calcmode .= '
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); + if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .= '
'.$langs->trans("WarningDepositsNotIncluded"); + $description .= $fsearch; + $description .= '
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $builddate = dol_now(); - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("Description"); - $amountcust=$langs->trans("AmountHT"); - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("Description"); - $amountsup=$langs->trans("AmountHT"); + $elementcust = $langs->trans("CustomersInvoices"); + $productcust = $langs->trans("Description"); + $amountcust = $langs->trans("AmountHT"); + $elementsup = $langs->trans("SuppliersInvoices"); + $productsup = $langs->trans("Description"); + $amountsup = $langs->trans("AmountHT"); } -if ($calc==2) // Invoice for goods, payment for services +if ($calc == 2) // Invoice for goods, payment for services { - $calcmode=$langs->trans("CalcModeLT2Debt"); - $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; - $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); - if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); - $description.=$fsearch; - $description.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; - $builddate=dol_now(); + $calcmode = $langs->trans("CalcModeLT2Debt"); + $calcmode .= '
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); + if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .= '
'.$langs->trans("WarningDepositsNotIncluded"); + $description .= $fsearch; + $description .= '
('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $builddate = dol_now(); - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("Description"); - $amountcust=$langs->trans("AmountHT"); - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("Description"); - $amountsup=$langs->trans("AmountHT"); + $elementcust = $langs->trans("CustomersInvoices"); + $productcust = $langs->trans("Description"); + $amountcust = $langs->trans("AmountHT"); + $elementsup = $langs->trans("SuppliersInvoices"); + $productsup = $langs->trans("Description"); + $amountsup = $langs->trans("AmountHT"); } report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); -$vatcust=$langs->transcountry($local==1?"LT1":"LT2", $mysoc->country_code); -$vatsup=$langs->transcountry($local==1?"LT1":"LT2", $mysoc->country_code); +$vatcust = $langs->transcountry($local == 1 ? "LT1" : "LT2", $mysoc->country_code); +$vatsup = $langs->transcountry($local == 1 ? "LT1" : "LT2", $mysoc->country_code); // IRPF that the customer has retained me -if($calc ==0 || $calc == 2) +if ($calc == 0 || $calc == 2) { print ''; print ''; @@ -185,20 +185,20 @@ if($calc ==0 || $calc == 2) // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('externalbalance')); - $reshook=$hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (is_array($coll_list)) { - $total = 0; $totalamount = 0; + $total = 0; $totalamount = 0; $i = 1; - foreach($coll_list as $coll) + foreach ($coll_list as $coll) { - if(($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local==1?$coll->localtax1:$coll->localtax2) !=0) + if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) { $intra = str_replace($find, $replace, $coll->tva_intra); - if(empty($intra)) + if (empty($intra)) { - if($coll->assuj == '1') + if ($coll->assuj == '1') { $intra = $langs->trans('Unknown'); } @@ -209,16 +209,16 @@ if($calc ==0 || $calc == 2) } print ''; print '"; - $company_static->id=$coll->socid; - $company_static->name=$coll->name; + $company_static->id = $coll->socid; + $company_static->name = $coll->name; print ''; - $find = array(' ','.'); - $replace = array('',''); + $find = array(' ', '.'); + $replace = array('', ''); print ''; print ''; - print ''; + print ''; $totalamount = $totalamount + $coll->amount; - $total = $total + ($local==1?$coll->localtax1:$coll->localtax2); + $total = $total + ($local == 1 ? $coll->localtax1 : $coll->localtax2); print "\n"; $i++; } @@ -243,7 +243,7 @@ if($calc ==0 || $calc == 2) } // IRPF I retained my supplier -if($calc ==0 || $calc == 1){ +if ($calc == 0 || $calc == 1) { print '
'.$i."'.$company_static->getNomUrl(1).''.$intra.''.price($coll->amount).''.price($local==1?$coll->localtax1:$coll->localtax2).''.price($local == 1 ? $coll->localtax1 : $coll->localtax2).'
'; print ''; print '"; @@ -253,25 +253,25 @@ if($calc ==0 || $calc == 1){ print ''; print "\n"; - $company_static=new Societe($db); + $company_static = new Societe($db); $coll_list = tax_by_thirdparty('localtax'.$local, $db, 0, $date_start, $date_end, $modetax, 'buy'); $parameters["direction"] = 'buy'; $parameters["type"] = 'localtax'.$local; - $reshook=$hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (is_array($coll_list)) { - $total = 0; $totalamount = 0; + $total = 0; $totalamount = 0; $i = 1; - foreach($coll_list as $coll) + foreach ($coll_list as $coll) { - if(($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local==1?$coll->localtax1:$coll->localtax2) != 0) + if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) { $intra = str_replace($find, $replace, $coll->tva_intra); - if(empty($intra)) + if (empty($intra)) { - if($coll->assuj == '1') + if ($coll->assuj == '1') { $intra = $langs->trans('Unknown'); } @@ -282,16 +282,16 @@ if($calc ==0 || $calc == 1){ } print ''; print '"; - $company_static->id=$coll->socid; - $company_static->name=$coll->name; + $company_static->id = $coll->socid; + $company_static->name = $coll->name; print ''; - $find = array(' ','.'); - $replace = array('',''); + $find = array(' ', '.'); + $replace = array('', ''); print '"; print ''; - print ''; + print ''; $totalamount = $totalamount + $coll->amount; - $total = $total + ($local==1?$coll->localtax1:$coll->localtax2); + $total = $total + ($local == 1 ? $coll->localtax1 : $coll->localtax2); print "\n"; $i++; } @@ -317,13 +317,13 @@ if($calc ==0 || $calc == 1){ } } -if($calc ==0){ +if ($calc == 0) { // Total to pay print '

'; print '
'.$langs->trans("Num")."'.$vatsup.'
'.$i."'.$company_static->getNomUrl(1).''.$intra."'.price($coll->amount).''.price($local==1?$coll->localtax1:$coll->localtax2).''.price($local == 1 ? $coll->localtax1 : $coll->localtax2).'
'; - $diff = $x_coll_sum - $x_paye_sum ; + $diff = $x_coll_sum - $x_paye_sum; print ''; - print ''; + print ''; print '\n"; print "\n"; } diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 0008a948c16..fb41142d970 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.p require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array('banks', 'categories','bills','withdrawals')); +$langs->loadLangs(array('banks', 'categories', 'bills', 'withdrawals')); if (!$user->rights->prelevement->bons->lire) accessforbidden(); @@ -46,7 +46,7 @@ $ref = GETPOST('ref', 'alpha'); $socid = GETPOST('socid', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -55,15 +55,15 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='pl.fk_soc'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'pl.fk_soc'; +if (!$sortorder) $sortorder = 'DESC'; $object = new BonPrelevement($db, ""); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -$hookmanager->initHooks(array('directdebitprevcard','globalcard')); +$hookmanager->initHooks(array('directdebitprevcard', 'globalcard')); /* * Actions @@ -75,9 +75,9 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ( $action == 'confirm_delete' ) + if ($action == 'confirm_delete') { - $res=$object->delete($user); + $res = $object->delete($user); if ($res > 0) { header("Location: index.php"); @@ -86,9 +86,9 @@ if (empty($reshook)) } // Seems to no be used and replaced with $action == 'infocredit' - if ( $action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') + if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') { - $res=$object->set_credite(); + $res = $object->set_credite(); if ($res >= 0) { header("Location: card.php?id=".$id); @@ -160,7 +160,7 @@ if ($id > 0 || $ref) $head = prelevement_prepare_head($object); dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); - if (GETPOST('error', 'alpha')!='') + if (GETPOST('error', 'alpha') != '') { print '
'.$object->getErrorString(GETPOST('error', 'alpha')).'
'; } @@ -190,7 +190,7 @@ if ($id > 0 || $ref) print ''; */ - if($object->date_trans <> 0) + if ($object->date_trans <> 0) { $muser = new User($db); $muser->fetch($object->user_trans); @@ -202,7 +202,7 @@ if ($id > 0 || $ref) print $object->methodes_trans[$object->method_trans]; print ''; } - if($object->date_credit <> 0) + if ($object->date_credit <> 0) { print ''; } // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').''.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').''.price(price2num($diff, 'MT'))."
'.$langs->trans('CreditDate').''; print dol_print_date($object->date_credit, 'day'); @@ -217,7 +217,7 @@ if ($id > 0 || $ref) print ''; $acc = new Account($db); - $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); print ''; @@ -2576,16 +2576,16 @@ else print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print ''; if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) - print ''; + print ''; print '
'; print $langs->trans("BankToReceiveWithdraw"); @@ -244,7 +244,7 @@ if ($id > 0 || $ref) // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); } // Call Hook formConfirm @@ -257,7 +257,7 @@ if ($id > 0 || $ref) print $formconfirm; - if (empty($object->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted') + if (empty($object->date_trans) && $user->rights->prelevement->bons->send && $action == 'settransmitted') { print '
'; print ''; @@ -281,7 +281,7 @@ if ($id > 0 || $ref) print '
'; } - if (! empty($object->date_trans) && $object->date_credit == 0 && $user->rights->prelevement->bons->credit && $action=='setcredited') + if (!empty($object->date_trans) && $object->date_credit == 0 && $user->rights->prelevement->bons->credit && $action == 'setcredited') { print ''; print ''; @@ -310,7 +310,7 @@ if ($id > 0 || $ref) print "id."\">".$langs->trans("SetToStatusSent").""; } - if (! empty($object->date_trans) && $object->date_credit == 0) + if (!empty($object->date_trans) && $object->date_credit == 0) { print "id."\">".$langs->trans("ClassCredited").""; } @@ -321,22 +321,22 @@ if ($id > 0 || $ref) } - $ligne=new LignePrelevement($db, $user); + $ligne = new LignePrelevement($db, $user); /* * Lines into withdraw request */ $sql = "SELECT pl.rowid, pl.statut, pl.amount,"; - $sql.= " s.rowid as socid, s.nom as name"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; - $sql.= ", ".MAIN_DB_PREFIX."prelevement_bons as pb"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE pl.fk_prelevement_bons = ".$id; - $sql.= " AND pl.fk_prelevement_bons = pb.rowid"; - $sql.= " AND pb.entity = ".$conf->entity; - $sql.= " AND pl.fk_soc = s.rowid"; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " s.rowid as socid, s.nom as name"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; + $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE pl.fk_prelevement_bons = ".$id; + $sql .= " AND pl.fk_prelevement_bons = pb.rowid"; + $sql .= " AND pb.entity = ".$conf->entity; + $sql .= " AND pl.fk_soc = s.rowid"; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -351,7 +351,7 @@ if ($id > 0 || $ref) } } - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); @@ -364,7 +364,7 @@ if ($id > 0 || $ref) print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print_liste_field_titre("Lines", $_SERVER["PHP_SELF"], "pl.rowid", '', $urladd); @@ -389,7 +389,7 @@ if ($id > 0 || $ref) print sprintf("%06s", $obj->rowid); print ''; - $thirdparty=new Societe($db); + $thirdparty = new Societe($db); $thirdparty->fetch($obj->socid); print ''; */ - if($object->date_trans <> 0) + if ($object->date_trans <> 0) { $muser = new User($db); $muser->fetch($object->user_trans); @@ -100,7 +100,7 @@ if ($prev_id > 0 || $ref) print $object->methodes_trans[$object->method_trans]; print ''; } - if($object->date_credit <> 0) + if ($object->date_credit <> 0) { print ''; // Ref supplier - print ''; + print ''; print ''; print ''; @@ -1997,37 +1997,37 @@ if ($action == 'create') // Payment term print ''; // Payment mode print ''; // Bank Account print ''; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; print ''; print ''; } // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); $langs->load('projects'); - print ''; } @@ -2037,7 +2037,7 @@ if ($action == 'create') print ''; print ''; print ''; } @@ -2045,8 +2045,8 @@ if ($action == 'create') print ''; print ''; // print ''; @@ -2056,9 +2056,9 @@ if ($action == 'create') print ''; print ''; // print ''; @@ -2079,10 +2079,10 @@ if ($action == 'create') print ''; print ''; - $txt=$langs->trans($classname); - if ($classname=='CommandeFournisseur') { + $txt = $langs->trans($classname); + if ($classname == 'CommandeFournisseur') { $langs->load('orders'); - $txt=$langs->trans("SupplierOrder"); + $txt = $langs->trans("SupplierOrder"); } print ''; print ''; print '"; - if ($mysoc->localtax1_assuj=="1" || $object->total_localtax1 != 0) //Localtax1 + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) //Localtax1 { print '"; } - if ($mysoc->localtax2_assuj=="1" || $object->total_localtax2 != 0) //Localtax2 + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) //Localtax2 { print '"; } @@ -2118,15 +2118,15 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled)) { - print ''; - print '"; - print '"; + print ''; + print '"; + print '"; } } // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Bouton "Create Draft" @@ -2137,7 +2137,7 @@ if ($action == 'create') print '
'; print ''; print '     '; - print ''; + print ''; print '
'; print "\n"; @@ -2148,7 +2148,7 @@ if ($action == 'create') { print '
'; - $title=$langs->trans('ProductsAndServices'); + $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); print '
'; print $thirdparty->getNomUrl(1); diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index ca5cb77432b..ebb7ab7fbb2 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","categories",'withdrawals','bills')); +$langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills')); // Securite acces client if ($user->socid > 0) accessforbidden(); @@ -42,7 +42,7 @@ $prev_id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -88,7 +88,7 @@ if ($prev_id > 0 || $ref) print '
'.$langs->trans('CreditDate').''; print dol_print_date($object->date_credit, 'day'); @@ -115,7 +115,7 @@ if ($prev_id > 0 || $ref) print ''; $acc = new Account($db); - $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); print ''; - print ''; + print ''; // Order date print ''; // Statut - print ''; + print ''; // Checkbox print ''; print ''; $total = $total + $objp->price; $subtotal = $subtotal + $objp->price; - $i ++; + $i++; } print '
'; print $langs->trans("BankToReceiveWithdraw"); @@ -148,20 +148,20 @@ $rej = new RejetPrelevement($db, $user); * List errors */ $sql = "SELECT pl.rowid, pl.amount, pl.statut"; -$sql.= " , s.rowid as socid, s.nom as name"; -$sql.= " , pr.motif, pr.afacturer, pr.fk_facture"; -$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; -$sql.= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; -$sql.= " , ".MAIN_DB_PREFIX."societe as s"; -$sql.= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr"; -$sql.= " WHERE p.rowid=".$object->id; -$sql.= " AND pl.fk_prelevement_bons = p.rowid"; -$sql.= " AND p.entity = ".$conf->entity; -$sql.= " AND pl.fk_soc = s.rowid"; -$sql.= " AND pl.statut = 3 "; -$sql.= " AND pr.fk_prelevement_lignes = pl.rowid"; -if ($socid) $sql.= " AND s.rowid = ".$socid; -$sql.= " ORDER BY pl.amount DESC"; +$sql .= " , s.rowid as socid, s.nom as name"; +$sql .= " , pr.motif, pr.afacturer, pr.fk_facture"; +$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; +$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; +$sql .= " , ".MAIN_DB_PREFIX."societe as s"; +$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr"; +$sql .= " WHERE p.rowid=".$object->id; +$sql .= " AND pl.fk_prelevement_bons = p.rowid"; +$sql .= " AND p.entity = ".$conf->entity; +$sql .= " AND pl.fk_soc = s.rowid"; +$sql .= " AND pl.statut = 3 "; +$sql .= " AND pr.fk_prelevement_lignes = pl.rowid"; +if ($socid) $sql .= " AND s.rowid = ".$socid; +$sql .= " ORDER BY pl.amount DESC"; // Count total nb of records $nbtotalofrecords = ''; @@ -176,7 +176,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -186,7 +186,7 @@ if ($resql) print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); print"\n\n"; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 1b351371958..fa7b1758435 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","categories",'withdrawals','bills')); +$langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills')); // Security check if ($user->socid > 0) accessforbidden(); @@ -40,7 +40,7 @@ $prev_id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -85,7 +85,7 @@ if ($prev_id > 0 || $ref) print ''; */ - if($object->date_trans <> 0) + if ($object->date_trans <> 0) { $muser = new User($db); $muser->fetch($object->user_trans); @@ -97,7 +97,7 @@ if ($prev_id > 0 || $ref) print $object->methodes_trans[$object->method_trans]; print ''; } - if($object->date_credit <> 0) + if ($object->date_credit <> 0) { print ''; @@ -441,22 +441,22 @@ if (($action != 'create' && $action != 'add') && !$error) { $sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,'; $sql .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'societe as s'; - $sql .= ', ' . MAIN_DB_PREFIX . 'commande_fournisseur as c'; - if (! $user->rights->societe->client->voir && ! $socid) - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; - $sql .= ' WHERE c.entity = ' . $conf->entity; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; + $sql .= ', '.MAIN_DB_PREFIX.'commande_fournisseur as c'; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ' WHERE c.entity = '.$conf->entity; $sql .= ' AND c.fk_soc = s.rowid'; // Show orders we can bill if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) { - $sql.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/card.php + $sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")"; // Must match filter in htdocs/fourn/card.php } else { // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY - $sql.= " AND c.fk_statut IN (".$db->escape($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).")"; + $sql .= " AND c.fk_statut IN (".$db->escape($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).")"; } $sql .= " AND c.billed = 0"; @@ -466,33 +466,33 @@ if (($action != 'create' && $action != 'add') && !$error) { //$sql .= " AND c.rowid NOT IN (SELECT fk_source FROM " . MAIN_DB_PREFIX . "element_element WHERE targettype='invoice_supplier')"; if ($socid) - $sql .= ' AND s.rowid = ' . $socid; - if (! $user->rights->societe->client->voir && ! $socid) - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; + $sql .= ' AND s.rowid = '.$socid; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($sref) { $sql .= natural_search("c.ref", $sref); } if ($sall) { - $sql .= natural_search(array("c.ref","c.note"), $sall); + $sql .= natural_search(array("c.ref", "c.note"), $sall); } // Date filter //$sql.= dolSqlDateFilter("c.date_commande", GETPOST("date_startday", 'int'), GETPOST("date_startmonth", 'int'), GETPOST("date_startyear", 'int')); //$sql.= dolSqlDateFilter("c.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); if ($date_start) - $sql .= " AND c.date_commande >= '" . $db->idate($date_start) . "'"; + $sql .= " AND c.date_commande >= '".$db->idate($date_start)."'"; if ($date_end) - $sql .= " AND c.date_commande <= '" . $db->idate($date_end) . "'"; + $sql .= " AND c.date_commande <= '".$db->idate($date_end)."'"; if ($date_starty) - $sql .= " AND c.date_livraison >= '" . $db->idate($date_starty) . "'"; + $sql .= " AND c.date_livraison >= '".$db->idate($date_starty)."'"; if ($date_endy) - $sql .= " AND c.date_livraison <= '" . $db->idate($date_endy) . "'"; + $sql .= " AND c.date_livraison <= '".$db->idate($date_endy)."'"; - if (! empty($sref_client)) { + if (!empty($sref_client)) { $sql .= natural_search('c.ref_supplier', $sref_client); } - $sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder; - dol_syslog('fourn/commande/ordertoinvoice.php sql=' . $sql); + $sql .= ' ORDER BY '.$sortfield.' '.$sortorder; + dol_syslog('fourn/commande/ordertoinvoice.php sql='.$sql); $resql = $db->query($sql); if ($resql) { @@ -501,28 +501,28 @@ if (($action != 'create' && $action != 'add') && !$error) { $soc->fetch($socid); } $title = $langs->trans('ListOfSupplierOrders'); - $title .= ' - ' . $langs->trans('StatusOrderReceivedAllShort'); - $title .= ' - ' . $soc->getNomUrl(1, 'supplier'); + $title .= ' - '.$langs->trans('StatusOrderReceivedAllShort'); + $title .= ' - '.$soc->getNomUrl(1, 'supplier'); $num = $db->num_rows($resql); print load_fiche_titre($title); $i = 0; - $period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); - $periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); + $period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); + $periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); print ''; - print ''; - print ''; + print ''; + print ''; print '
'.$langs->trans("Line").''.$langs->trans("ThirdParty").''.$langs->trans("Amount").'
'.$langs->trans('CreditDate').''; print dol_print_date($object->date_credit, 'day'); @@ -112,7 +112,7 @@ if ($prev_id > 0 || $ref) print ''; $acc = new Account($db); - $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); print ''; print "\n"; @@ -188,7 +188,7 @@ if ($prev_id > 0 || $ref) } else { - print $db->error() . ' ' . $sql; + print $db->error().' '.$sql; } } diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index b43ccbacb38..3416cd553a0 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -36,13 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; // Load translation files required by the page -$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin","accountancy")); +$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin", "accountancy")); $modecompta = (GETPOST('modecompta', 'alpha') ? GETPOST('modecompta', 'alpha') : $conf->global->ACCOUNTING_MODE); // Date range -$year=GETPOST("year", 'int'); -$month=GETPOST("month", 'int'); +$year = GETPOST("year", 'int'); +$month = GETPOST("month", 'int'); if (empty($year)) { $year_current = strftime("%Y", dol_now()); @@ -53,44 +53,44 @@ if (empty($year)) $month_current = strftime("%m", dol_now()); $year_start = $year; } -$date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); -$date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q", "int"); + $q = GETPOST("q", "int"); if (empty($q)) { // We define date_start and date_end - $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); - $year_end=$year_start; - $month_end=$month_start; - if (! GETPOST("month")) // If month not forced + $month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); + $year_end = $year_start; + $month_end = $month_start; + if (!GETPOST("month")) // If month not forced { - if (! GETPOST('year') && $month_start > $month_current) + if (!GETPOST('year') && $month_start > $month_current) { $year_start--; $year_end--; } - $month_end=$month_start-1; - if ($month_end < 1) $month_end=12; + $month_end = $month_start - 1; + if ($month_end < 1) $month_end = 12; else $year_end++; } - $date_start=dol_get_first_day($year_start, $month_start, false); $date_end=dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); } else { - if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); } - if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); } - if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); } - if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); } + if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } + if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } + if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } + if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } } } // $date_start and $date_end are defined. We force $year_start and $nbofyear -$tmps=dol_getdate($date_start); +$tmps = dol_getdate($date_start); $year_start = $tmps['year']; -$tmpe=dol_getdate($date_end); +$tmpe = dol_getdate($date_end); $year_end = $tmpe['year']; $tmp_date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; @@ -102,12 +102,12 @@ if (empty($min)) $min = 0; // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax", 'int'); -if (empty($modetax)) $modetax=0; +if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int'); +if (empty($modetax)) $modetax = 0; // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); @@ -116,21 +116,21 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); * View */ -$form=new Form($db); -$company_static=new Societe($db); -$invoice_customer=new Facture($db); -$invoice_supplier=new FactureFournisseur($db); -$expensereport=new ExpenseReport($db); -$product_static=new Product($db); -$payment_static=new Paiement($db); -$paymentfourn_static=new PaiementFourn($db); -$paymentexpensereport_static=new PaymentExpenseReport($db); +$form = new Form($db); +$company_static = new Societe($db); +$invoice_customer = new Facture($db); +$invoice_supplier = new FactureFournisseur($db); +$expensereport = new ExpenseReport($db); +$product_static = new Product($db); +$payment_static = new Paiement($db); +$paymentfourn_static = new PaiementFourn($db); +$paymentexpensereport_static = new PaymentExpenseReport($db); -$morequerystring=''; -$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); +$morequerystring = ''; +$listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); foreach ($listofparams as $param) { - if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); + if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); } llxHeader('', $langs->trans("TurnoverReport"), '', '', 0, 0, '', '', $morequerystring); @@ -139,103 +139,103 @@ llxHeader('', $langs->trans("TurnoverReport"), '', '', 0, 0, '', '', $morequerys //print load_fiche_titre($langs->trans("VAT"),""); //$fsearch.='
'; -$fsearch.=' '; -$fsearch.=' '; +$fsearch .= ' '; +$fsearch .= ' '; //$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': '; //$fsearch.=' '; // Show report header -$name=$langs->trans("xxx"); -$calcmode=''; -if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); -if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); -if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices'); -$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; +$name = $langs->trans("xxx"); +$calcmode = ''; +if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault'); +if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption'); +if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices'); +$calcmode .= '
('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; // Set period -$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); -$prevyear=$year_start; $prevquarter=$q; +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +$prevyear = $year_start; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; } else { - $prevquarter=4; $prevyear--; + $prevquarter = 4; $prevyear--; } -$nextyear=$year_start; $nextquarter=$q; +$nextyear = $year_start; $nextquarter = $q; if ($nextquarter < 4) { $nextquarter++; } else { - $nextquarter=1; $nextyear++; + $nextquarter = 1; $nextyear++; } -$description.=$fsearch; -$builddate=dol_now(); +$description .= $fsearch; +$builddate = dol_now(); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts"); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='
'.$langs->trans("RulesVATDueServices"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='
'.$langs->trans("RulesVATInServices"); -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $description.='
'.$langs->trans("DepositsAreNotIncluded"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description .= $langs->trans("RulesVATDueProducts"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->trans("RulesVATInProducts"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '
'.$langs->trans("RulesVATDueServices"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '
'.$langs->trans("RulesVATInServices"); +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description .= '
'.$langs->trans("DepositsAreNotIncluded"); } -if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); +if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); // Customers invoices -$elementcust=$langs->trans("CustomersInvoices"); -$productcust=$langs->trans("ProductOrService"); -$amountcust=$langs->trans("AmountHT"); +$elementcust = $langs->trans("CustomersInvoices"); +$productcust = $langs->trans("ProductOrService"); +$amountcust = $langs->trans("AmountHT"); // Suppliers invoices -$elementsup=$langs->trans("SuppliersInvoices"); -$productsup=$productcust; -$amountsup=$amountcust; -$namesup=$namecust; +$elementsup = $langs->trans("SuppliersInvoices"); +$productsup = $productcust; +$amountsup = $amountcust; +$namesup = $namecust; // TODO Report from bookkeeping not yet available, so we switch on report on business events -if ($modecompta=="BOOKKEEPING") $modecompta="CREANCES-DETTES"; -if ($modecompta=="BOOKKEEPINGCOLLECTED") $modecompta="RECETTES-DEPENSES"; +if ($modecompta == "BOOKKEEPING") $modecompta = "CREANCES-DETTES"; +if ($modecompta == "BOOKKEEPINGCOLLECTED") $modecompta = "RECETTES-DEPENSES"; // Show report header -if ($modecompta=="CREANCES-DETTES") { - $name=$langs->trans("Turnover").', '.$langs->trans("ByVatRate"); - $calcmode=$langs->trans("CalcModeDebt"); +if ($modecompta == "CREANCES-DETTES") { + $name = $langs->trans("Turnover").', '.$langs->trans("ByVatRate"); + $calcmode = $langs->trans("CalcModeDebt"); //$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $description=$langs->trans("RulesCADue"); - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $description.= $langs->trans("DepositsAreNotIncluded"); + $description = $langs->trans("RulesCADue"); + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description .= $langs->trans("DepositsAreNotIncluded"); } else { - $description.= $langs->trans("DepositsAreIncluded"); + $description .= $langs->trans("DepositsAreIncluded"); } - $builddate=dol_now(); + $builddate = dol_now(); } -elseif ($modecompta=="RECETTES-DEPENSES") +elseif ($modecompta == "RECETTES-DEPENSES") { - $name=$langs->trans("TurnoverCollected").', '.$langs->trans("ByVatRate"); - $calcmode=$langs->trans("CalcModeEngagement"); + $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByVatRate"); + $calcmode = $langs->trans("CalcModeEngagement"); //$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; - $description=$langs->trans("RulesCAIn"); - $description.= $langs->trans("DepositsAreIncluded"); + $description = $langs->trans("RulesCAIn"); + $description .= $langs->trans("DepositsAreIncluded"); - $builddate=dol_now(); + $builddate = dol_now(); } -elseif ($modecompta=="BOOKKEEPING") +elseif ($modecompta == "BOOKKEEPING") { } -elseif ($modecompta=="BOOKKEEPINGCOLLECTED") +elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } -$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); -if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().''.img_next().''; +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink = ''.img_previous().''.img_next().''; else $periodlink = ''; -$description.=' '; +$description .= ' '; report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); -if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') +if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') { print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); } @@ -243,62 +243,62 @@ if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') if ($modecompta == 'CREANCES-DETTES') { print '
'; print $langs->trans("BankToReceiveWithdraw"); @@ -142,14 +142,14 @@ if ($prev_id > 0 || $ref) /* * Stats */ - $ligne=new LignePrelevement($db, $user); + $ligne = new LignePrelevement($db, $user); $sql = "SELECT sum(pl.amount), pl.statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; - $sql.= " WHERE pl.fk_prelevement_bons = ".$object->id; - $sql.= " GROUP BY pl.statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; + $sql .= " WHERE pl.fk_prelevement_bons = ".$object->id; + $sql .= " GROUP BY pl.statut"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -174,7 +174,7 @@ if ($prev_id > 0 || $ref) print price($row[0]); print ''; - if ($object->amount) print round($row[0]/$object->amount*100, 2)." %"; + if ($object->amount) print round($row[0] / $object->amount * 100, 2)." %"; print '
'; - print ''; - print ''; - print ''; - $i=0; - while($i < 12) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + print ''; + print ''; + print ''; + $i = 0; + while ($i < 12) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; - print ''; + print ''; $i++; } - print ''; + print ''; $sql = "SELECT fd.tva_tx AS vatrate,"; $sql .= " fd.product_type AS product_type,"; $sql .= " cc.label AS country,"; - for ($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + for ($i = 1; $i <= 12; $i++) { + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$i, 'fd.total_ht', '0').") AS month".str_pad($i, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(fd.total_ht) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = f.fk_soc"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; - $sql .= " WHERE f.datef >= '" . $db->idate($date_start) . "'"; - $sql .= " AND f.datef <= '" . $db->idate($date_end) . "'"; - $sql.= " AND f.fk_statut in (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND f.type IN (0,1,2,5)"; + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as soc ON soc.rowid = f.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = soc.fk_pays"; + $sql .= " WHERE f.datef >= '".$db->idate($date_start)."'"; + $sql .= " AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND 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 { - $sql.= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.type IN (0,1,2,3,5)"; } - $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; + $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; $sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label "; - dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); + dol_syslog("htdocs/compta/tva/index.php sql=".$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $totalpermonth = array(); - while ( $obj = $db->fetch_object($resql)) { - print ''; + while ($obj = $db->fetch_object($resql)) { + print ''; if ($obj->product_type == 0) { - print ''; + print ''; } else { - print ''; + print ''; } - print ''; - for($i = 0; $i < 12; $i++) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + print ''; + for ($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; - $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + print ''; + $totalpermonth[$j] = (empty($totalpermonth[$j]) ? 0 : $totalpermonth[$j]) + $obj->$monthj; } - print ''; - $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; + $totalpermonth['total'] = (empty($totalpermonth['total']) ? 0 : $totalpermonth['total']) + $obj->total; print ''; } $db->free($resql); @@ -307,77 +307,77 @@ if ($modecompta == 'CREANCES-DETTES') { print ''; print ''; print ''; - for($i = 0; $i < 12; $i++) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + for ($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; + print ''; } - print ''; + print ''; print ''; } else { print $db->lasterror(); // Show last sql error } - print ''; - print ''; - print ''; - $i=0; - while($i < 12) + print ''; + print ''; + print ''; + $i = 0; + while ($i < 12) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; - print ''; + print ''; $i++; } - print ''; + print ''; $sql2 = "SELECT ffd.tva_tx AS vatrate,"; $sql2 .= " ffd.product_type AS product_type,"; $sql2 .= " cc.label AS country,"; - for($i = 1; $i <= 12; $i ++) { - $sql2 .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + for ($i = 1; $i <= 12; $i++) { + $sql2 .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$i, 'ffd.total_ht', '0').") AS month".str_pad($i, 2, '0', STR_PAD_LEFT).","; } $sql2 .= " SUM(ffd.total_ht) as total"; - $sql2 .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; - $sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; - $sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = ff.fk_soc"; - $sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; - $sql2 .= " WHERE ff.datef >= '" . $db->idate($date_start) . "'"; - $sql2 .= " AND ff.datef <= '" . $db->idate($date_end) . "'"; - $sql.= " AND ff.fk_statut in (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND ff.type IN (0,1,2,5)"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; + $sql2 .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; + $sql2 .= " INNER JOIN ".MAIN_DB_PREFIX."societe as soc ON soc.rowid = ff.fk_soc"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = soc.fk_pays"; + $sql2 .= " WHERE ff.datef >= '".$db->idate($date_start)."'"; + $sql2 .= " AND ff.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND ff.fk_statut in (1,2)"; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND ff.type IN (0,1,2,5)"; } else { - $sql.= " AND ff.type IN (0,1,2,3,5)"; + $sql .= " AND ff.type IN (0,1,2,3,5)"; } - $sql2 .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; + $sql2 .= " AND ff.entity IN (".getEntity("facture_fourn", 0).")"; $sql2 .= " GROUP BY ffd.tva_tx, ffd.product_type, cc.label"; //print $sql2; - dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); + dol_syslog("htdocs/compta/tva/index.php sql=".$sql, LOG_DEBUG); $resql2 = $db->query($sql2); if ($resql2) { $num = $db->num_rows($resql2); $totalpermonth = array(); - while ( $obj = $db->fetch_object($resql2)) { - print ''; + while ($obj = $db->fetch_object($resql2)) { + print ''; if ($obj->product_type == 0) { - print ''; + print ''; } else { - print ''; + print ''; } - print ''; - for($i = 0; $i < 12; $i++) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + print ''; + for ($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; - $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + print ''; + $totalpermonth[$j] = (empty($totalpermonth[$j]) ? 0 : $totalpermonth[$j]) + $obj->$monthj; } - print ''; - $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; + $totalpermonth['total'] = (empty($totalpermonth['total']) ? 0 : $totalpermonth['total']) + $obj->total; print ''; } $db->free($resql2); @@ -386,13 +386,13 @@ if ($modecompta == 'CREANCES-DETTES') { print ''; print ''; print ''; - for($i = 0; $i < 12; $i++) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + for ($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; + print ''; } - print ''; + print ''; print ''; } else { print $db->lasterror(); // Show last sql error @@ -403,7 +403,7 @@ if ($modecompta == 'CREANCES-DETTES') { // "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an // invoice with 2 product (product A for 10 euros and product B for 20 euros), what is part of paiment for product A and part of paiment for product B ? // Because there is no way to know this, this report is not relevant. - print '
'.$langs->trans("TurnoverPerSaleTaxRateInCommitmentAccountingNotRelevant") . '
'; + print '
'.$langs->trans("TurnoverPerSaleTaxRateInCommitmentAccountingNotRelevant").'
'; } // End of page diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index c5df8e7d743..7927af38786 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -30,21 +30,21 @@ * \brief Page to invoice multiple supplier orders */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_invoice/modules_facturefournisseur.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page $langs->loadLangs(array("orders", "companies", "deliveries")); -if (! $user->rights->fournisseur->facture->creer) +if (!$user->rights->fournisseur->facture->creer) accessforbidden(); $id = (GETPOST('id') ? GETPOST('id', 'int') : GETPOST("facid")); // For backward compatibility @@ -53,16 +53,16 @@ $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $sref = GETPOST('sref'); $sref_client = GETPOST('sref_client'); -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $socid = GETPOST('socid', 'int'); $selected = GETPOST('orders_to_invoice'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $viewstatut = GETPOST('viewstatut'); -if (! $sortfield) +if (!$sortfield) $sortfield = 'c.rowid'; -if (! $sortorder) +if (!$sortorder) $sortorder = 'DESC'; $now = dol_now(); @@ -80,13 +80,13 @@ $extrafields->fetch_name_optionals_label($object->table_element); if ($action == 'create') { - if (! GETPOST('createbill')) + if (!GETPOST('createbill')) { $action = ''; } else { - if (! is_array($selected)) + if (!is_array($selected)) { //$error++; setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); @@ -99,7 +99,7 @@ if ($action == 'create') } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); $hookmanager->initHooks(array('orderstoinvoicesupplier')); @@ -108,10 +108,10 @@ $hookmanager->initHooks(array('orderstoinvoicesupplier')); * Actions */ -if (($action == 'create' || $action == 'add') && ! $error) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/fourn.lib.php'; - if (! empty($conf->projet->enabled)) - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (($action == 'create' || $action == 'add') && !$error) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; + if (!empty($conf->projet->enabled)) + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array("bills", "main", "products")); @@ -157,7 +157,7 @@ if (($action == 'create' || $action == 'add') && ! $error) { if (empty($datefacture)) { $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y")); } - if (! $error) { + if (!$error) { $object->ref = GETPOST('ref', 'nohtml'); $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); $object->socid = GETPOST('socid', 'int'); @@ -181,18 +181,18 @@ if (($action == 'create' || $action == 'add') && ! $error) { if ($ret < 0) $error++; if ($_POST['origin'] && $_POST['originid']) { - $linked_orders_ids=array(); + $linked_orders_ids = array(); foreach ($orders_id as $origin => $origin_id) { - $origin_id = (! empty($origin_id) ? $origin_id : $orders_id[$ii]); - $linked_orders_ids[]=$origin_id; + $origin_id = (!empty($origin_id) ? $origin_id : $orders_id[$ii]); + $linked_orders_ids[] = $origin_id; } $object->linked_objects = array(GETPOST('origin')=>$linked_orders_ids); $id = $object->create($user); if ($id > 0) { - while ( $ii < $nn ) { + while ($ii < $nn) { $objectsrc = new CommandeFournisseur($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $objectsrc->fetch($orders_id[$ii]); if ($result > 0) { $lines = $objectsrc->lines; @@ -202,7 +202,7 @@ if (($action == 'create' || $action == 'add') && ! $error) { } $fk_parent_line = 0; $num = count($lines); - for($i = 0; $i < $num; $i ++) { + for ($i = 0; $i < $num; $i++) { $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); @@ -232,7 +232,7 @@ if (($action == 'create' || $action == 'add') && ! $error) { $lineid = $result; } else { $lineid = 0; - $error ++; + $error++; break; } // Defined the new fk_parent_line @@ -242,22 +242,22 @@ if (($action == 'create' || $action == 'add') && ! $error) { } } else { $mesgs[] = $objectsrc->error; - $error ++; + $error++; } - $ii ++; + $ii++; } } else { $mesgs[] = $object->error; - $error ++; + $error++; } } } // End of object creation, we show it - if ($id > 0 && ! $error) { - foreach($orders_id as $fk_supplier_order) { + if ($id > 0 && !$error) { + foreach ($orders_id as $fk_supplier_order) { $supplier_order = new CommandeFournisseur($db); - if ($supplier_order->fetch($fk_supplier_order)>0 && $supplier_order->statut == 5) + if ($supplier_order->fetch($fk_supplier_order) > 0 && $supplier_order->statut == 5) { if ($supplier_order->classifyBilled($user) < 0) { @@ -265,7 +265,7 @@ if (($action == 'create' || $action == 'add') && ! $error) { $action = 'create'; $_GET["origin"] = $_POST["origin"]; $_GET["originid"] = $_POST["originid"]; - $mesgs[] = '
' . $object->error . '
'; + $mesgs[] = '
'.$object->error.'
'; $error++; break; @@ -273,9 +273,9 @@ if (($action == 'create' || $action == 'add') && ! $error) { } } - if(!$error) { + if (!$error) { $db->commit(); - header('Location: ' . DOL_URL_ROOT . '/fourn/facture/card.php?facid=' . $id); + header('Location: '.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$id); exit(); } } else { @@ -283,7 +283,7 @@ if (($action == 'create' || $action == 'add') && ! $error) { $action = 'create'; $_GET["origin"] = $_POST["origin"]; $_GET["originid"] = $_POST["originid"]; - $mesgs[] = '
' . $object->error . '
'; + $mesgs[] = '
'.$object->error.'
'; } } } @@ -308,7 +308,7 @@ if ($action == 'create' && !$error) { $cond_reglement_id = $soc->cond_reglement_supplier_id; $mode_reglement_id = $soc->mode_reglement_supplier_id; } - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : ''; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? -1 : ''; $objectsrc = new CommandeFournisseur($db); $listoforders = array(); @@ -322,50 +322,50 @@ if ($action == 'create' && !$error) { if (empty($mode_reglement_id)) $mode_reglement_id = $objectsrc->mode_reglement_id; } - print ''; - print ''; + print ''; + print ''; print ''; - print '' . "\n"; + print ''."\n"; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print '
' . $langs->trans("TurnoverbyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '
'.$langs->trans("TurnoverbyVatrate").''.$langs->trans("ProductOrService").''.$langs->trans("Country").'' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . ''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("TotalHT") . '
'.$langs->trans("TotalHT").'
' . vatrate($obj->vatrate) . '
'.vatrate($obj->vatrate).''. $langs->trans("Product") . ''.$langs->trans("Product").''. $langs->trans("Service") . ''.$langs->trans("Service").'' .$obj->country . ''.$obj->country.'' . price($obj->$monthj) . ''.price($obj->$monthj).'' . price($obj->total) . ''.price($obj->total).'
' . price($totalpermonth[$j]) . ''.price($totalpermonth[$j]).'' . price($totalpermonth['total']) . ''.price($totalpermonth['total']).'
' . $langs->trans("PurchasebyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '
'.$langs->trans("PurchasebyVatrate").''.$langs->trans("ProductOrService").''.$langs->trans("Country").'' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . ''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("TotalHT") . '
'.$langs->trans("TotalHT").'
' . vatrate($obj->vatrate) . '
'.vatrate($obj->vatrate).''. $langs->trans("Product") . ''.$langs->trans("Product").''. $langs->trans("Service") . ''.$langs->trans("Service").'' . $obj->country . ''.$obj->country.'' . price($obj->$monthj) . ''.price($obj->$monthj).'' . price($obj->total) . ''.price($obj->total).'
' . price($totalpermonth[$j]) . ''.price($totalpermonth[$j]).'' . price($totalpermonth['total']) . ''.price($totalpermonth['total']).'
'; // Ref - print ''; + print ''; // Ref supplier - print ''; + print ''; print ''; // Date invoice - print ''; // Payment term - print ''; // Payment mode - print ''; // Project - if (! empty($conf->projet->enabled)) { + if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); $langs->load('projects'); - print ''; } // Other attributes - $parameters = array ( + $parameters = array( 'objectsrc' => $objectsrc, 'idsrc' => $listoforders, 'colspan' => ' colspan="2"', @@ -376,12 +376,12 @@ if ($action == 'create' && !$error) { if (empty($reshook)) { - $object=new FactureFournisseur($db); + $object = new FactureFournisseur($db); print $object->showOptionals($extrafields, 'edit'); } // Modele PDF - print ''; + print ''; print ''; - print ''; + print ''; print ''; // Private note if (empty($user->socid)) { print ''; - print ''; + print ''; print ''; } @@ -410,13 +410,13 @@ if ($action == 'create' && !$error) { print '
' . $langs->trans('Ref') . '' . $langs->trans('Draft') . '
'.$langs->trans('Ref').''.$langs->trans('Draft').'
' . $langs->trans('RefSupplier') . '
'.$langs->trans('RefSupplier').'
' . $langs->trans('Date') . ''; + print '
'.$langs->trans('Date').''; print $html->selectDate('', '', '', '', '', "add", 1, 1); print '
' . $langs->trans('PaymentConditionsShort') . ''; + print '
'.$langs->trans('PaymentConditionsShort').''; $html->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); print '
' . $langs->trans('PaymentMode') . ''; + print '
'.$langs->trans('PaymentMode').''; $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); print '
' . $langs->trans('Project') . ''; + print '
'.$langs->trans('Project').''; $formproject->select_projects($soc->id, $projectid, 'projectid'); print '
' . $langs->trans('Model') . '
'.$langs->trans('Model').''; $liste = ModelePDFSuppliersInvoices::liste_modeles($db); print $html->selectarray('model', $liste, $conf->global->INVOICE_SUPPLIER_ADDON_PDF); @@ -389,20 +389,20 @@ if ($action == 'create' && !$error) { // Public note print '
' . $langs->trans('NotePublic') . ''.$langs->trans('NotePublic').''; - print '
' . $langs->trans('NotePrivate') . ''.$langs->trans('NotePrivate').''; - print '
'; while ($i < $n) { - print ''; + print ''; $i++; } // Button "Create Draft" - print '
'; + print '
'; print "\n"; print '
'; print ''; - print_liste_field_titre('Ref', 'orderstoinvoice.php', 'c.ref', '', '&socid=' . $socid, '', $sortfield, $sortorder); - print_liste_field_titre('RefSupplier', 'orderstoinvoice.php', 'c.ref_supplier', '', '&socid=' . $socid, '', $sortfield, $sortorder); - print_liste_field_titre('OrderDate', 'orderstoinvoice.php', 'c.date_commande', '', '&socid=' . $socid, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DeliveryDate', 'orderstoinvoice.php', 'c.date_livraison', '', '&socid=' . $socid, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Ref', 'orderstoinvoice.php', 'c.ref', '', '&socid='.$socid, '', $sortfield, $sortorder); + print_liste_field_titre('RefSupplier', 'orderstoinvoice.php', 'c.ref_supplier', '', '&socid='.$socid, '', $sortfield, $sortorder); + print_liste_field_titre('OrderDate', 'orderstoinvoice.php', 'c.date_commande', '', '&socid='.$socid, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DeliveryDate', 'orderstoinvoice.php', 'c.date_livraison', '', '&socid='.$socid, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('Status', '', '', '', '', '', '', '', 'right '); print_liste_field_titre('GenerateBill', '', '', '', '', '', '', '', 'center '); print "\n"; @@ -532,12 +532,12 @@ if (($action != 'create' && $action != 'add') && !$error) { print ''; // print ''; // DATE ORDER @@ -552,13 +552,13 @@ if (($action != 'create' && $action != 'add') && !$error) { // SEARCH BUTTON print ''; // ALL/NONE print ''; print ''; @@ -581,13 +581,13 @@ if (($action != 'create' && $action != 'add') && !$error) { print '
'; // REF - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; if ($conf->use_javascript_ajax) - print '' . $langs->trans("All") . ' / ' . $langs->trans("None") . ''; + print ''.$langs->trans("All").' / '.$langs->trans("None").''; print '
'; $filename = dol_sanitizeFileName($objp->ref); - $filedir = $conf->fournisseur->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref); - $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objp->rowid; + $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($objp->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objp->rowid; print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print '
'; print '
' . $objp->ref_supplier . ''.$objp->ref_supplier.''; @@ -600,18 +600,18 @@ if (($action != 'create' && $action != 'add') && !$error) { print '' . $generic_commande->LibStatut($objp->fk_statut, 5) . ''.$generic_commande->LibStatut($objp->fk_statut, 5).''; - print ''; + print ''; print '
'; @@ -620,11 +620,11 @@ if (($action != 'create' && $action != 'add') && !$error) { */ print '
'; print '
'; - print ''; + print ''; print ''; print '
'; // print ''.$langs->trans("GoBack").''; - print ''; + print ''; print '
'; print '
'; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 3dc6e0383b0..6a5e29892d2 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -53,82 +53,82 @@ if (!empty($conf->projet->enabled)) { if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -$langs->loadLangs(array('bills','compta','suppliers','companies','products','banks')); +$langs->loadLangs(array('bills', 'compta', 'suppliers', 'companies', 'products', 'banks')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -$id = (GETPOST('facid', 'int') ? GETPOST('facid', 'int') : GETPOST('id', 'int')); -$socid = GETPOST('socid', 'int'); +$id = (GETPOST('facid', 'int') ? GETPOST('facid', 'int') : GETPOST('id', 'int')); +$socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST("confirm"); -$ref = GETPOST('ref', 'alpha'); +$ref = GETPOST('ref', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $lineid = GETPOST('lineid', 'int'); -$projectid = GETPOST('projectid', 'int'); +$projectid = GETPOST('projectid', 'int'); $origin = GETPOST('origin', 'alpha'); -$originid = GETPOST('originid', 'int'); +$originid = GETPOST('originid', 'int'); // PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('invoicesuppliercard','globalcard')); +$hookmanager->initHooks(array('invoicesuppliercard', 'globalcard')); -$object=new FactureFournisseur($db); +$object = new FactureFournisseur($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { - $ret=$object->fetch($id, $ref); + $ret = $object->fetch($id, $ref); if ($ret < 0) dol_print_error($db, $object->error); - $ret=$object->fetch_thirdparty(); + $ret = $object->fetch_thirdparty(); if ($ret < 0) dol_print_error($db, $object->error); } // Security check -$socid=''; -if (! empty($user->socid)) $socid=$user->socid; +$socid = ''; +if (!empty($user->socid)) $socid = $user->socid; $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft); -$permissionnote=$user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php -$permissiontoadd=$user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php /* * Actions */ -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; } - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Link invoice to order if (GETPOST('linkedOrder') && empty($cancel) && $id > 0) @@ -141,12 +141,12 @@ if (empty($reshook)) // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. if (GETPOST('newsupplierref', 'alphanohtml')) $objectutil->ref_supplier = GETPOST('newsupplierref', 'alphanohtml'); $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); - $result=$objectutil->createFromClone($user, $id); + $result = $objectutil->createFromClone($user, $id); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -156,49 +156,49 @@ if (empty($reshook)) { $langs->load("errors"); setEventMessages($objectutil->error, $objectutil->errors, 'errors'); - $action=''; + $action = ''; } } elseif ($action == 'confirm_valid' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate))) ) { - $idwarehouse=GETPOST('idwarehouse'); + $idwarehouse = GETPOST('idwarehouse'); $object->fetch($id); $object->fetch_thirdparty(); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } - if (! $error) + if (!$error) { $result = $object->validate($user, '', $idwarehouse); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); - }else{ + } else { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -206,14 +206,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } } @@ -225,12 +225,12 @@ if (empty($reshook)) $object->fetch($id); $object->fetch_thirdparty(); - $isErasable=$object->is_erasable(); + $isErasable = $object->is_erasable(); if (($user->rights->fournisseur->facture->supprimer && $isErasable > 0) || ($user->rights->fournisseur->facture->creer && $isErasable == 1)) { - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { header('Location: list.php?restore_lastsearch_values=1'); @@ -272,7 +272,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); /* Fix bug 1485 : Reset action to avoid asking again confirmation on failure */ - $action=''; + $action = ''; } } @@ -287,8 +287,8 @@ if (empty($reshook)) elseif ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - $result=$object->set_paid($user); - if ($result<0) + $result = $object->set_paid($user); + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -313,7 +313,7 @@ if (empty($reshook)) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -327,7 +327,7 @@ if (empty($reshook)) // payments conditions if ($action == 'setconditions' && $user->rights->fournisseur->facture->creer) { - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } // Set incoterm @@ -354,21 +354,21 @@ if (empty($reshook)) // bank account elseif ($action == 'setbankaccount' && $user->rights->fournisseur->facture->creer) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } // Set label elseif ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - $object->label=GETPOST('label'); - $result=$object->update($user); + $object->label = GETPOST('label'); + $result = $object->update($user); if ($result < 0) dol_print_error($db); } elseif ($action == 'setdatef' && $user->rights->fournisseur->facture->creer) { - $newdate=dol_mktime(0, 0, 0, $_POST['datefmonth'], $_POST['datefday'], $_POST['datefyear']); - if ($newdate > (dol_now() + (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE)?0:$conf->global->INVOICE_MAX_OFFSET_IN_FUTURE))) + $newdate = dol_mktime(0, 0, 0, $_POST['datefmonth'], $_POST['datefday'], $_POST['datefyear']); + if ($newdate > (dol_now() + (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE) ? 0 : $conf->global->INVOICE_MAX_OFFSET_IN_FUTURE))) { if (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE)) setEventMessages($langs->trans("WarningInvoiceDateInFuture"), null, 'warnings'); else setEventMessages($langs->trans("WarningInvoiceDateTooFarInFuture"), null, 'warnings'); @@ -376,30 +376,30 @@ if (empty($reshook)) $object->fetch($id); - $object->date=$newdate; - $date_echence_calc=$object->calculate_date_lim_reglement(); - if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) + $object->date = $newdate; + $date_echence_calc = $object->calculate_date_lim_reglement(); + if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) { $object->date_echeance = $date_echence_calc; } if ($object->date_echeance && $object->date_echeance < $object->date) { - $object->date_echeance=$object->date; + $object->date_echeance = $object->date; } - $result=$object->update($user); + $result = $object->update($user); if ($result < 0) dol_print_error($db, $object->error); } elseif ($action == 'setdate_lim_reglement' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - $object->date_echeance=dol_mktime(12, 0, 0, $_POST['date_lim_reglementmonth'], $_POST['date_lim_reglementday'], $_POST['date_lim_reglementyear']); - if (! empty($object->date_echeance) && $object->date_echeance < $object->date) + $object->date_echeance = dol_mktime(12, 0, 0, $_POST['date_lim_reglementmonth'], $_POST['date_lim_reglementday'], $_POST['date_lim_reglementyear']); + if (!empty($object->date_echeance) && $object->date_echeance < $object->date) { - $object->date_echeance=$object->date; + $object->date_echeance = $object->date; setEventMessages($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), null, 'warnings'); } - $result=$object->update($user); + $result = $object->update($user); if ($result < 0) dol_print_error($db, $object->error); } elseif ($action == "setabsolutediscount" && $user->rights->fournisseur->facture->creer) @@ -407,7 +407,7 @@ if (empty($reshook)) // POST[remise_id] or POST[remise_id_for_payment] // We use the credit to reduce amount of invoice - if (! empty($_POST["remise_id"])) { + if (!empty($_POST["remise_id"])) { $ret = $object->fetch($id); if ($ret > 0) { $result = $object->insert_discount($_POST["remise_id"]); @@ -419,9 +419,9 @@ if (empty($reshook)) } } // We use the credit to reduce remain to pay - if (! empty($_POST["remise_id_for_payment"])) + if (!empty($_POST["remise_id_for_payment"])) { - require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($db); $discount->fetch($_POST["remise_id_for_payment"]); @@ -434,7 +434,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorDiscountLargerThanRemainToPaySplitItBefore"), null, 'errors'); } - if (! $error) + if (!$error) { $result = $discount->link_to_invoice(0, $id); if ($result < 0) { @@ -449,7 +449,7 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -467,12 +467,12 @@ if (empty($reshook)) //$object->fetch_lines(); // Already done into fetch // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) - $discountcheck=new DiscountAbsolute($db); - $result=$discountcheck->fetch(0, 0, $object->id); + $discountcheck = new DiscountAbsolute($db); + $result = $discountcheck->fetch(0, 0, $object->id); - $canconvert=0; - if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) - if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) + $canconvert = 0; + if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) + if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) if ($canconvert) { $db->begin(); @@ -488,7 +488,7 @@ if (empty($reshook)) $amount_ht[$line->tva_tx] += $line->total_ht; $amount_tva[$line->tva_tx] += $line->total_tva; $amount_ttc[$line->tva_tx] += $line->total_ttc; - $i ++; + $i++; } } @@ -514,14 +514,14 @@ if (empty($reshook)) // If we're on a standard invoice, we have to get excess paid to create a discount in TTC without VAT $sql = 'SELECT SUM(pf.amount) as total_paiements'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'paiementfourn as p'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN (' . getEntity('c_paiement') . ')'; - $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; - $sql.= ' AND pf.fk_paiementfourn = p.rowid'; - $sql.= ' AND p.entity IN (' . getEntity('invoice').')'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'paiementfourn as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.getEntity('c_paiement').')'; + $sql .= ' WHERE pf.fk_facturefourn = '.$object->id; + $sql .= ' AND pf.fk_paiementfourn = p.rowid'; + $sql .= ' AND p.entity IN ('.getEntity('invoice').')'; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); $res = $db->fetch_object($resql); $total_paiements = $res->total_paiements; @@ -556,7 +556,7 @@ if (empty($reshook)) if (empty($error)) { - if($object->type != FactureFournisseur::TYPE_DEPOSIT) { + if ($object->type != FactureFournisseur::TYPE_DEPOSIT) { // Classe facture $result = $object->set_paid($user); if ($result >= 0) @@ -588,9 +588,9 @@ if (empty($reshook)) if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0) { $paiementfourn = new PaiementFourn($db); - $result=$paiementfourn->fetch(GETPOST('paiement_id')); + $result = $paiementfourn->fetch(GETPOST('paiement_id')); if ($result > 0) { - $result=$paiementfourn->delete(); // If fetch ok and found + $result = $paiementfourn->delete(); // If fetch ok and found header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); } if ($result < 0) { @@ -612,8 +612,8 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - $datefacture=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $datedue=dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); + $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $datedue = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); // Replacement invoice if ($_POST['type'] == FactureFournisseur::TYPE_REPLACEMENT) @@ -621,36 +621,36 @@ if (empty($reshook)) if ($datefacture == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; $error++; } - if (! ($_POST['fac_replacement'] > 0)) { - $error ++; + if (!($_POST['fac_replacement'] > 0)) { + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), null, 'errors'); } - if (! $error) { + if (!$error) { // This is a replacement invoice $result = $object->fetch(GETPOST('fac_replacement'), 'int'); $object->fetch_thirdparty(); - $object->ref = GETPOST('ref', 'nohtml'); - $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); - $object->socid = GETPOST('socid', 'int'); - $object->libelle = GETPOST('label', 'nohtml'); - $object->date = $datefacture; - $object->date_echeance = $datedue; - $object->note_public = GETPOST('note_public', 'none'); - $object->note_private = GETPOST('note_private', 'none'); + $object->ref = GETPOST('ref', 'nohtml'); + $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); + $object->socid = GETPOST('socid', 'int'); + $object->libelle = GETPOST('label', 'nohtml'); + $object->date = $datefacture; + $object->date_echeance = $datedue; + $object->note_public = GETPOST('note_public', 'none'); + $object->note_private = GETPOST('note_private', 'none'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); - $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); // Proprietes particulieres a facture de remplacement $object->fk_facture_source = GETPOST('fac_replacement'); @@ -668,73 +668,73 @@ if (empty($reshook)) if ($_POST['type'] == FactureFournisseur::TYPE_CREDIT_NOTE) { $sourceinvoice = GETPOST('fac_avoir', 'int'); - if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) + if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) { - $error ++; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors'); } - if (GETPOST('socid', 'int')<1) + if (GETPOST('socid', 'int') < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } if ($datefacture == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; $error++; } - if (! GETPOST('ref_supplier')) + if (!GETPOST('ref_supplier')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('RefSupplier')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; $error++; } - if (! $error) + if (!$error) { $tmpproject = GETPOST('projectid', 'int'); // Creation facture - $object->ref = GETPOST('ref', 'nohtml'); - $object->ref_supplier = GETPOST('ref_supplier', 'nohtml'); + $object->ref = GETPOST('ref', 'nohtml'); + $object->ref_supplier = GETPOST('ref_supplier', 'nohtml'); $object->socid = GETPOST('socid', 'int'); - $object->libelle = GETPOST('label', 'nohtml'); + $object->libelle = GETPOST('label', 'nohtml'); $object->label = GETPOST('label', 'nohtml'); - $object->date = $datefacture; - $object->date_echeance = $datedue; - $object->note_public = GETPOST('note_public', 'none'); - $object->note_private = GETPOST('note_private', 'none'); + $object->date = $datefacture; + $object->date_echeance = $datedue; + $object->note_public = GETPOST('note_public', 'none'); + $object->note_private = GETPOST('note_private', 'none'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); - $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); // Proprietes particulieres a facture avoir - $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; + $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; $object->type = FactureFournisseur::TYPE_CREDIT_NOTE; $id = $object->create($user); - if($id <= 0) { + if ($id <= 0) { $error++; } - if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) + if (GETPOST('invoiceAvoirWithLines', 'int') == 1 && $id > 0) { $facture_source = new FactureFournisseur($db); // fetch origin object - if ($facture_source->fetch($object->fk_facture_source)>0) + if ($facture_source->fetch($object->fk_facture_source) > 0) { $fk_parent_line = 0; - foreach($facture_source->lines as $line) + foreach ($facture_source->lines as $line) { // Reset fk_parent_line for no child products and special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { @@ -744,13 +744,13 @@ if (empty($reshook)) $line->fk_facture_fourn = $object->id; $line->fk_parent_line = $fk_parent_line; - $line->subprice =-$line->subprice; // invert price for object + $line->subprice = -$line->subprice; // invert price for object $line->pa_ht = -$line->pa_ht; - $line->total_ht=-$line->total_ht; - $line->total_tva=-$line->total_tva; - $line->total_ttc=-$line->total_ttc; - $line->total_localtax1=-$line->total_localtax1; - $line->total_localtax2=-$line->total_localtax2; + $line->total_ht = -$line->total_ht; + $line->total_tva = -$line->total_tva; + $line->total_ttc = -$line->total_ttc; + $line->total_localtax1 = -$line->total_localtax1; + $line->total_localtax2 = -$line->total_localtax2; $result = $line->insert(); @@ -766,10 +766,10 @@ if (empty($reshook)) } } - if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) + if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) { $facture_source = new FactureFournisseur($db); // fetch origin object if not previously defined - if ($facture_source->fetch($object->fk_facture_source)>0) + if ($facture_source->fetch($object->fk_facture_source) > 0) { $totalpaye = $facture_source->getSommePaiement(); $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); @@ -785,29 +785,29 @@ if (empty($reshook)) // Standard or deposit if ($_POST['type'] == FactureFournisseur::TYPE_STANDARD || $_POST['type'] == FactureFournisseur::TYPE_DEPOSIT) { - if (GETPOST('socid', 'int')<1) + if (GETPOST('socid', 'int') < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } if ($datefacture == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; $error++; } - if (! GETPOST('ref_supplier')) + if (!GETPOST('ref_supplier')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('RefSupplier')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; $error++; } - if (! $error) + if (!$error) { $tmpproject = GETPOST('projectid', 'int'); @@ -823,19 +823,19 @@ if (empty($reshook)) $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; + $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); // Auto calculation of date due if not filled by user - if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement(); + if (empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement(); $object->fetch_thirdparty(); // If creation from another object of another module - if (! $error && $_POST['origin'] && $_POST['originid']) + if (!$error && $_POST['origin'] && $_POST['originid']) { // Parse element/subelement (ex: project_task) $element = $subelement = GETPOST('origin'); @@ -846,10 +846,10 @@ if (empty($reshook)) }*/ // For compatibility - if ($element == 'order') { + if ($element == 'order') { $element = $subelement = 'commande'; } - if ($element == 'propal') { + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'contract') { @@ -868,7 +868,7 @@ if (empty($reshook)) require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + if ($classname == 'Fournisseur.commande') $classname = 'CommandeFournisseur'; $objectsrc = new $classname($db); $objectsrc->fetch($originid); $objectsrc->fetch_thirdparty(); @@ -893,10 +893,10 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + if ($classname == 'Fournisseur.commande') $classname = 'CommandeFournisseur'; $srcobject = new $classname($db); - $result=$srcobject->fetch(GETPOST('originid', 'int')); + $result = $srcobject->fetch(GETPOST('originid', 'int')); if ($result > 0) { $lines = $srcobject->lines; @@ -906,11 +906,11 @@ if (empty($reshook)) $lines = $srcobject->lines; } - $num=count($lines); + $num = count($lines); for ($i = 0; $i < $num; $i++) // TODO handle subprice < 0 { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { @@ -919,12 +919,12 @@ if (empty($reshook)) // Dates // TODO mutualiser - $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; - $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; + $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; // FIXME Missing special_code into addline and updateline methods $object->special_code = $lines[$i]->special_code; @@ -975,7 +975,7 @@ if (empty($reshook)) $error++; } } - elseif (! $error) + elseif (!$error) { $id = $object->create($user); if ($id < 0) @@ -992,8 +992,8 @@ if (empty($reshook)) $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; } else { @@ -1002,7 +1002,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) + if ($result < 0) { dol_print_error($db, $object->error, $object->errors); exit; @@ -1038,9 +1038,9 @@ if (empty($reshook)) if (GETPOST('productid') > 0) { $productsupplier = new ProductFournisseur($db); - if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) + if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) { - if (GETPOST('productid') > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), GETPOST('productid'), 'none', GETPOST('socid', 'int')) < 0 ) + if (GETPOST('productid') > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), GETPOST('productid'), 'none', GETPOST('socid', 'int')) < 0) { setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); } @@ -1049,18 +1049,18 @@ if (empty($reshook)) $prod = new Product($db); $prod->fetch(GETPOST('productid')); $label = $prod->description; - if (trim($_POST['product_desc']) != trim($label)) $label=$_POST['product_desc']; + if (trim($_POST['product_desc']) != trim($label)) $label = $_POST['product_desc']; $type = $prod->type; } else { $label = $_POST['product_desc']; - $type = $_POST["type"]?$_POST["type"]:0; + $type = $_POST["type"] ? $_POST["type"] : 0; } - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); // Define info_bits $info_bits = 0; @@ -1069,10 +1069,10 @@ if (empty($reshook)) // Define vat_rate $tva_tx = str_replace('*', '', $tva_tx); - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - $remise_percent=GETPOST('remise_percent'); + $remise_percent = GETPOST('remise_percent'); $pu_ht_devise = GETPOST('multicurrency_subprice'); // Extrafields Lines @@ -1081,11 +1081,11 @@ if (empty($reshook)) // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } - $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); + $result = $object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); if ($result >= 0) { unset($_POST['label']); @@ -1116,39 +1116,39 @@ if (empty($reshook)) { $db->begin(); - $ret=$object->fetch($id); + $ret = $object->fetch($id); if ($ret < 0) { dol_print_error($db, $object->error); exit; } - $ret=$object->fetch_thirdparty(); + $ret = $object->fetch_thirdparty(); $langs->load('errors'); - $error=0; + $error = 0; // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $predef = ''; + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $price_ht = ''; $tva_tx = ''; } $qty = GETPOST('qty'.$predef); - $remise_percent=GETPOST('remise_percent'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); $price_ht_devise = GETPOST('multicurrency_price_ht'); // Extrafields @@ -1158,31 +1158,31 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } - if ($prod_entry_mode =='free' && GETPOST('price_ht') < 0 && $qty < 0) + if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) { setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && ! GETPOST('idprodfournprice') && GETPOST('type') < 0) + if ($prod_entry_mode == 'free' && !GETPOST('idprodfournprice') && GETPOST('type') < 0) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='' && $price_ht_devise==='') // Unit price can be 0 but not '' + if ($prod_entry_mode == 'free' && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') // Unit price can be 0 but not '' { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && ! GETPOST('dp_desc')) + if ($prod_entry_mode == 'free' && !GETPOST('dp_desc')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } - if (! GETPOST('qty')) + if (!GETPOST('qty')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; @@ -1197,28 +1197,28 @@ if (empty($reshook)) $idprod = $res->fk_product_child; } else { setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors'); - $error ++; + $error++; } } } if ($prod_entry_mode != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' { - $productsupplier=new ProductFournisseur($db); + $productsupplier = new ProductFournisseur($db); - $idprod=0; - if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + $idprod = 0; + if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { - $idprod=$reg[1]; - $res=$productsupplier->fetch($idprod); // Load product from its id + $idprod = $reg[1]; + $res = $productsupplier->fetch($idprod); // Load product from its id // Call to init some price properties of $productsupplier // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price - if (! empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) + if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) { $fksoctosearch = 0; - $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist + $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist if ($productsupplier->fourn_socid != $socid) // The price we found is for another supplier, so we clear supplier price { $productsupplier->ref_supplier = ''; @@ -1227,15 +1227,15 @@ if (empty($reshook)) else { $fksoctosearch = $object->thirdparty->id; - $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist + $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist } } elseif (GETPOST('idprodfournprice', 'alpha') > 0) { - $qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat. + $qtytosearch = $qty; // Just to see if a price exists for the quantity. Not used to found vat. //$qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist - $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); - $res=$productsupplier->fetch($idprod); + $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); + $res = $productsupplier->fetch($idprod); } if ($idprod > 0) @@ -1243,27 +1243,27 @@ if (empty($reshook)) $label = $productsupplier->label; // if we use supplier description of the products - if(!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { + if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { $desc = $productsupplier->desc_supplier; } else $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $type = $productsupplier->type; - $price_base_type = ($productsupplier->fourn_price_base_type?$productsupplier->fourn_price_base_type:'HT'); + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); $ref_supplier = $productsupplier->ref_supplier; - $tva_tx=get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + $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; - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); + if (empty($tva_tx)) $tva_npr = 0; + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); $pu = $productsupplier->fourn_pu; - if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value + if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value - $result=$object->addline( + $result = $object->addline( $desc, $pu, $tva_tx, @@ -1311,13 +1311,13 @@ if (empty($reshook)) $type = GETPOST('type'); $ref_supplier = GETPOST('fourn_ref', 'alpha'); - $fk_unit= GETPOST('units', 'alpha'); + $fk_unit = GETPOST('units', 'alpha'); - $tva_tx = price2num($tva_tx); // When vat is text input field + $tva_tx = price2num($tva_tx); // When vat is text input field // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); if ($price_ht !== '') { @@ -1335,7 +1335,7 @@ if (empty($reshook)) } //print "xx".$tva_tx; exit; - if (! $error && $result > 0) + if (!$error && $result > 0) { $db->commit(); @@ -1346,14 +1346,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } @@ -1402,7 +1402,7 @@ if (empty($reshook)) elseif ($action == 'classin' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - $result=$object->setProject($projectid); + $result = $object->setProject($projectid); } @@ -1417,7 +1417,7 @@ if (empty($reshook)) // We check that lines of invoices are exported in accountancy $ventilExportCompta = $object->getVentilExportCompta(); - if (! $ventilExportCompta) + if (!$ventilExportCompta) { // On verifie si aucun paiement n'a ete effectue if ($resteapayer == price2num($object->total_ttc, 'MT', 1) && $object->statut == FactureFournisseur::STATUS_VALIDATED) @@ -1426,25 +1426,25 @@ if (empty($reshook)) $object->fetch_thirdparty(); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } @@ -1457,18 +1457,18 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } - $action=''; + $action = ''; } } } @@ -1497,10 +1497,10 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='BILL_SUPPLIER_SENTBYMAIL'; - $paramname='id'; - $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO'; - $trackid='sin'.$object->id; + $trigger_name = 'BILL_SUPPLIER_SENTBYMAIL'; + $paramname = 'id'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO'; + $trackid = 'sin'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc @@ -1511,12 +1511,12 @@ if (empty($reshook)) // Make calculation according to calculationrule if ($action == 'calculate') { - $calculationrule=GETPOST('calculationrule'); + $calculationrule = GETPOST('calculationrule'); $object->fetch($id); $object->fetch_thirdparty(); - $result=$object->update_price(0, (($calculationrule=='totalofround')?'0':'1'), 0, $object->thirdparty); - if ($result <= 0) + $result = $object->update_price(0, (($calculationrule == 'totalofround') ? '0' : '1'), 0, $object->thirdparty); + if ($result <= 0) { dol_print_error($db, $result); exit; @@ -1530,12 +1530,12 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$object->insertExtraFields('BILL_SUPPLIER_MODIFY'); + $result = $object->insertExtraFields('BILL_SUPPLIER_MODIFY'); if ($result < 0) { $error++; @@ -1547,7 +1547,7 @@ if (empty($reshook)) $action = 'edit_extras'; } - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer) { if ($action == 'addcontact') { @@ -1583,7 +1583,7 @@ if (empty($reshook)) { if ($object->fetch($id)) { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { @@ -1616,13 +1616,13 @@ if (empty($reshook)) $form = new Form($db); $formfile = new FormFile($db); -$bankaccountstatic=new Account($db); -$paymentstatic=new PaiementFourn($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +$bankaccountstatic = new Account($db); +$paymentstatic = new PaiementFourn($db); +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $now = dol_now(); -$title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Card'); +$title = $langs->trans('SupplierInvoice')." - ".$langs->trans('Card'); $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; llxHeader('', $title, $helpurl); @@ -1637,15 +1637,15 @@ if ($action == 'create') $currency_code = $conf->currency; - $societe=''; + $societe = ''; if (GETPOST('socid') > 0) { - $societe=new Societe($db); + $societe = new Societe($db); $societe->fetch(GETPOST('socid', 'int')); if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) $currency_code = $societe->multicurrency_code; } - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -1657,10 +1657,10 @@ if ($action == 'create') } // For compatibility - if ($element == 'order') { + if ($element == 'order') { $element = $subelement = 'commande'; } - if ($element == 'propal') { + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'contract') { @@ -1672,21 +1672,21 @@ if ($action == 'create') require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + if ($classname == 'Fournisseur.commande') $classname = 'CommandeFournisseur'; $objectsrc = new $classname($db); $objectsrc->fetch($originid); $objectsrc->fetch_thirdparty(); - $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); + $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); //$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); $soc = $objectsrc->thirdparty; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_supplier_id)?$soc->cond_reglement_supplier_id:0)); // TODO maybe add default value option - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0)); - $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_supplier_id) ? $soc->cond_reglement_supplier_id : 0)); // TODO maybe add default value option + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_supplier_id) ? $soc->mode_reglement_supplier_id : 0)); + $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; if (!empty($conf->multicurrency->enabled)) { @@ -1694,10 +1694,10 @@ if ($action == 'create') if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; } - $datetmp=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); - $datetmp=dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); - $datedue=($datetmp==''?-1:$datetmp); + $datetmp = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp); + $datetmp = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); + $datedue = ($datetmp == '' ?-1 : $datetmp); // Replicate extrafields $objectsrc->fetch_optionals($originid); @@ -1708,10 +1708,10 @@ if ($action == 'create') $cond_reglement_id = $societe->cond_reglement_supplier_id; $mode_reglement_id = $societe->mode_reglement_supplier_id; $fk_account = $societe->fk_account; - $datetmp=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); - $datetmp=dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); - $datedue=($datetmp==''?-1:$datetmp); + $datetmp = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp); + $datetmp = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); + $datedue = ($datetmp == '' ?-1 : $datetmp); if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } @@ -1719,10 +1719,10 @@ if ($action == 'create') print ''; print ''; print ''; - if ($societe->id > 0) print '' . "\n"; + if ($societe->id > 0) print ''."\n"; print ''; print ''; - if (!empty($currency_tx)) print ''; + if (!empty($currency_tx)) print ''; dol_fiche_head(); @@ -1762,16 +1762,16 @@ if ($action == 'create') print '
'.$langs->trans('RefSupplier').'
'.$langs->trans('RefSupplier').'
'.$langs->trans('Type').''; - print '
' . "\n"; + print '
'."\n"; // Standard invoice print '
'; - $tmp=' '; + $tmp = ' '; $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; @@ -1883,7 +1883,7 @@ if ($action == 'create') if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) { // Show link for credit note - $facids=$facturestatic->list_qualified_avoir_supplier_invoices($societe->id); + $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id); if ($facids < 0) { dol_print_error($db, $facturestatic); @@ -1899,19 +1899,19 @@ if ($action == 'create') $newinvoice_static->type = $valarray ['type']; $newinvoice_static->paye = $valarray ['paye']; - $optionsav .= ''; } print '
'; - $tmp=' jQuery(document).ready(function() { @@ -1927,26 +1927,26 @@ if ($action == 'create') }); }); '; - $text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' '; + $text = $tmp.$langs->transnoentities("InvoiceAvoirAsk").' '; // $text.=''; $text .= ''; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; - print '    0 ? 'checked':'').' /> '; + print '    0 ? 'checked' : '').' /> '; print '"; - print '
    0 ? 'checked':'').' /> '; + print '
    0 ? 'checked' : '').' /> '; print '"; print '
'; @@ -1956,12 +1956,12 @@ if ($action == 'create') else { print '
'; - $tmp=' '; - $text = $tmp.$langs->trans("InvoiceAvoir") . ' '; - $text.= '('.$langs->trans("YouMustCreateInvoiceFromSupplierThird").') '; + $tmp = ' '; + $text = $tmp.$langs->trans("InvoiceAvoir").' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromSupplierThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; - print '
' . "\n"; + print '
'."\n"; } } @@ -1972,11 +1972,11 @@ if ($action == 'create') if ($societe->id > 0) { // Discounts for third party - print '
' . $langs->trans('Discounts') . ''; + print '
'.$langs->trans('Discounts').''; $thirdparty = $societe; $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$societe->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '
'.$langs->trans('PaymentConditionsShort').''; - $form->select_conditions_paiements(GETPOSTISSET('cond_reglement_id')?GETPOST('cond_reglement_id', 'int'):$cond_reglement_id, 'cond_reglement_id'); + $form->select_conditions_paiements(GETPOSTISSET('cond_reglement_id') ?GETPOST('cond_reglement_id', 'int') : $cond_reglement_id, 'cond_reglement_id'); print '
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements(GETPOSTISSET('mode_reglement_id')?GETPOST('mode_reglement_id', 'int'):$mode_reglement_id, 'mode_reglement_id', 'DBIT'); + $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ?GETPOST('mode_reglement_id', 'int') : $mode_reglement_id, 'mode_reglement_id', 'DBIT'); print '
'.$langs->trans('BankAccount').''; - $form->select_comptes((GETPOSTISSET('fk_account')?GETPOST('fk_account', 'alpha'):$fk_account), 'fk_account', 0, '', 1); + $form->select_comptes((GETPOSTISSET('fk_account') ?GETPOST('fk_account', 'alpha') : $fk_account), 'fk_account', 0, '', 1); print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; - print $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code')?GETPOST('multicurrency_code', 'alpha'):$currency_code), 'multicurrency_code'); + print $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ?GETPOST('multicurrency_code', 'alpha') : $currency_code), 'multicurrency_code'); print '
' . $langs->trans('Project') . ''; - $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); + print '
'.$langs->trans('Project').''; + $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1); print '
'; - print $form->select_incoterms(GETPOSTISSET('incoterm_id') ? GETPOST('incoterm_id', 'alphanohtml') : (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), GETPOSTISSET('location_incoterms') ? GETPOST('location_incoterms', 'alphanohtml') : (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:'')); + print $form->select_incoterms(GETPOSTISSET('incoterm_id') ? GETPOST('incoterm_id', 'alphanohtml') : (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), GETPOSTISSET('location_incoterms') ? GETPOST('location_incoterms', 'alphanohtml') : (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : '')); print '
'.$langs->trans('NotePublic').''; $note_public = $object->getDefaultCreateValueFor('note_public'); - if(empty($note_public))$note_public = $objectsrc->note_public; - $doleditor = new DolEditor('note_public', (GETPOSTISSET('note_public')?GETPOST('note_public', 'none'):$note_public), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + if (empty($note_public))$note_public = $objectsrc->note_public; + $doleditor = new DolEditor('note_public', (GETPOSTISSET('note_public') ?GETPOST('note_public', 'none') : $note_public), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print '
'.$langs->trans('NotePrivate').''; $note_private = $object->getDefaultCreateValueFor('note_private'); - if(empty($note_private))$note_private = $objectsrc->note_private; + if (empty($note_private))$note_private = $objectsrc->note_private; - $doleditor = new DolEditor('note_private', (GETPOSTISSET('note_private')?GETPOST('note_private', 'none'):$note_private), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', (GETPOSTISSET('note_private') ?GETPOST('note_private', 'none') : $note_private), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print '
'.$txt.''.$objectsrc->getNomUrl(1); // We check if Origin document (id and type is known) has already at least one invoice attached to it @@ -2091,7 +2091,7 @@ if ($action == 'create') $invoice_supplier = $objectsrc->linkedObjects['invoice_supplier']; // count function need a array as argument (Note: the array must implement Countable too) - if(is_array($invoice_supplier)) + if (is_array($invoice_supplier)) { $cntinvoice = count($invoice_supplier); @@ -2105,12 +2105,12 @@ if ($action == 'create') echo '
'.$langs->trans('AmountHT').''.price($objectsrc->total_ht).'
'.$langs->trans('AmountVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2)."
' . $langs->trans('MulticurrencyAmountHT') . '' . price($objectsrc->multicurrency_total_ht) . '
' . $langs->trans('MulticurrencyAmountVAT') . '' . price($objectsrc->multicurrency_total_tva) . "
' . $langs->trans('MulticurrencyAmountTTC') . '' . price($objectsrc->multicurrency_total_ttc) . "
'.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
'.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva)."
'.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc)."
'; @@ -2160,7 +2160,7 @@ if ($action == 'create') } else { - if ($id > 0 || ! empty($ref)) + if ($id > 0 || !empty($ref)) { /* *************************************************************************** */ /* */ @@ -2168,16 +2168,16 @@ else /* */ /* *************************************************************************** */ - $now=dol_now(); + $now = dol_now(); $productstatic = new Product($db); $object->fetch($id, $ref); - $result=$object->fetch_thirdparty(); + $result = $object->fetch_thirdparty(); if ($result < 0) dol_print_error($db); $societe = new Fournisseur($db); - $result=$societe->fetch($object->socid); + $result = $societe->fetch($object->socid); if ($result < 0) dol_print_error($db); $totalpaye = $object->getSommePaiement(); @@ -2198,7 +2198,7 @@ else } $resteapayeraffiche = $resteapayer; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -2215,7 +2215,7 @@ else * View card */ $head = facturefourn_prepare_head($object); - $titre=$langs->trans('SupplierInvoice'); + $titre = $langs->trans('SupplierInvoice'); dol_fiche_head($head, 'card', $titre, -1, 'bill'); @@ -2223,19 +2223,19 @@ else // Confirmation de la conversion de l'avoir en reduc if ($action == 'converttoreduc') { - if($object->type == FactureFournisseur::TYPE_STANDARD) $type_fac = 'ExcessPaid'; - elseif($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $type_fac = 'CreditNote'; - elseif($object->type == FactureFournisseur::TYPE_DEPOSIT) $type_fac = 'Deposit'; + if ($object->type == FactureFournisseur::TYPE_STANDARD) $type_fac = 'ExcessPaid'; + elseif ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $type_fac = 'CreditNote'; + elseif ($object->type == FactureFournisseur::TYPE_DEPOSIT) $type_fac = 'Deposit'; $text = $langs->trans('ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac))); $text .= '
'.$langs->trans('ConfirmConvertToReducSupplier2'); - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2); } // Clone confirmation if ($action == 'clone') { // Create an array for form - $formquestion=array( + $formquestion = array( array('type' => 'text', 'name' => 'newsupplierref', 'label' => $langs->trans("RefSupplier"), 'value' => $langs->trans("CopyOf").' '.$object->ref_supplier), array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now()) ); @@ -2250,7 +2250,7 @@ else $objectref = substr($object->ref, 1, 4); if ($objectref == 'PROV') { - $savdate=$object->date; + $savdate = $object->date; $numref = $object->getNextNumRef($societe); } else @@ -2258,7 +2258,7 @@ else $numref = $object->ref; } - $text=$langs->trans('ConfirmValidateBill', $numref); + $text = $langs->trans('ConfirmValidateBill', $numref); /*if (! empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; @@ -2266,34 +2266,34 @@ else $text.='
'; $text.=$notify->confirmMessage('BILL_SUPPLIER_VALIDATE',$object->socid, $object); }*/ - $formquestion=array(); + $formquestion = array(); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct=new FormProduct($db); + $formproduct = new FormProduct($db); $warehouse = new Entrepot($db); $warehouse_array = $warehouse->list_array(); if (count($warehouse_array) == 1) { $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans("WarehouseForStockIncrease", current($warehouse_array)); - $value = ''; + $value = ''; } else { $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease"); - $value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1); + $value = $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1); } $formquestion = array( - array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value) ); } @@ -2314,7 +2314,7 @@ else { $qualified_for_stock_change = $object->hasProductsOrServices(1); } - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; @@ -2323,13 +2323,13 @@ else $warehouse_array = $warehouse->list_array(); if (count($warehouse_array) == 1) { $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockIncrease", current($warehouse_array)) : $langs->trans("WarehouseForStockDecrease", current($warehouse_array)); - $value = ''; + $value = ''; } else { $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockIncrease") : $langs->trans("SelectWarehouseForStockDecrease"); - $value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1); + $value = $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1); } $formquestion = array( - array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value) ); } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnvalidateBill'), $langs->trans('ConfirmUnvalidateBill', $object->ref), 'confirm_edit', $formquestion, 1, 1); @@ -2355,15 +2355,15 @@ else // Confirmation to delete line if ($action == 'ask_deleteline') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } if (!$formconfirm) { - $parameters=array('lineid'=>$lineid); + $parameters = array('lineid'=>$lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; } // Print form confirm @@ -2371,51 +2371,51 @@ else // Supplier invoice card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; // Ref supplier - $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherBills").')'; + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->fournisseur->facture->creer) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
'; + $morehtmlref .= '
'; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -2430,27 +2430,27 @@ else print $object->getLibType(); if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) { - $facreplaced=new FactureFournisseur($db); + $facreplaced = new FactureFournisseur($db); $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; } if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { - $facusing=new FactureFournisseur($db); + $facusing = new FactureFournisseur($db); $facusing->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } - $facidavoir=$object->getListIdAvoirFromInvoice(); + $facidavoir = $object->getListIdAvoirFromInvoice(); if (count($facidavoir) > 0) { print ' ('.$langs->transnoentities("InvoiceHasAvoir"); - $i=0; - foreach($facidavoir as $id) + $i = 0; + foreach ($facidavoir as $id) { - if ($i==0) print ' '; + if ($i == 0) print ' '; else print ','; - $facavoir=new FactureFournisseur($db); + $facavoir = new FactureFournisseur($db); $facavoir->fetch($id); print $facavoir->getNomUrl(1); } @@ -2458,14 +2458,14 @@ else } if (isset($facidnext) && $facidnext > 0) { - $facthatreplace=new FactureFournisseur($db); + $facthatreplace = new FactureFournisseur($db); $facthatreplace->fetch($facidnext); print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')'; } if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) { $discount = new DiscountAbsolute($db); $result = $discount->fetch(0, 0, $object->id); - if ($result > 0){ + if ($result > 0) { print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'
'; } } @@ -2473,12 +2473,12 @@ else // Relative and absolute discounts - print ''; @@ -2548,7 +2548,7 @@ else print ''; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print ''; @@ -2557,13 +2557,13 @@ else print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print ''; if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT) - print ''; + print ''; print '
' . $langs->trans('Discounts'); + print '
'.$langs->trans('Discounts'); print ''; $thirdparty = $societe; $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?facid=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '
id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; print '
'; if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); } print '
id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; print '
'; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '
        '; print ''.$langs->trans("ActualizeCurrency").''; @@ -2631,14 +2631,14 @@ else } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print '
'; @@ -2652,44 +2652,44 @@ else if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print '
' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$langs->trans('AmountHT').''.price($object->total_ht, 1, $langs, 0, -1, -1, $conf->currency).'
'.$langs->trans('AmountVAT').''.price($object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).'
        '; - if (GETPOST('calculationrule')) $calculationrule=GETPOST('calculationrule', 'alpha'); - else $calculationrule=(empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)?'totalofround':'roundoftotal'); - if ($calculationrule == 'totalofround') $calculationrulenum=1; - else $calculationrulenum=2; - $s=$langs->trans("ReCalculate").' '; - $s.=''.$langs->trans("Mode1").''; - $s.=' / '; - $s.=''.$langs->trans("Mode2").''; + if (GETPOST('calculationrule')) $calculationrule = GETPOST('calculationrule', 'alpha'); + else $calculationrule = (empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND) ? 'totalofround' : 'roundoftotal'); + if ($calculationrule == 'totalofround') $calculationrulenum = 1; + else $calculationrulenum = 2; + $s = $langs->trans("ReCalculate").' '; + $s .= ''.$langs->trans("Mode1").''; + $s .= ' / '; + $s .= ''.$langs->trans("Mode2").''; print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc", $calculationrulenum).'
'.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('', 'help')); print '
'.$langs->transcountry("AmountLT1", $societe->country_code).''.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).'
'.$langs->transcountry("AmountLT2", $societe->country_code).''.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).'
'; print ''; - print ''; + print ''; print ''; print ''; - if (! empty($conf->banque->enabled)) print ''; + if (!empty($conf->banque->enabled)) print ''; print ''; print ''; print ''; @@ -2753,28 +2753,28 @@ else { $objp = $db->fetch_object($result); - $paymentstatic->id=$objp->rowid; - $paymentstatic->datepaye=$db->jdate($objp->dp); - $paymentstatic->ref=($objp->ref ? $objp->ref : $objp->rowid); - $paymentstatic->num_paiement=$objp->num_paiement; - $paymentstatic->payment_code=$objp->payment_code; + $paymentstatic->id = $objp->rowid; + $paymentstatic->datepaye = $db->jdate($objp->dp); + $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid); + $paymentstatic->num_paiement = $objp->num_paiement; + $paymentstatic->payment_code = $objp->payment_code; print ''; print ''; - print ''; + print ''; print ''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { - $bankaccountstatic->id=$objp->baid; - $bankaccountstatic->ref=$objp->baref; - $bankaccountstatic->label=$objp->baref; + $bankaccountstatic->id = $objp->baid; + $bankaccountstatic->ref = $objp->baref; + $bankaccountstatic->label = $objp->baref; $bankaccountstatic->number = $objp->banumber; - if (! empty($conf->accounting->enabled)) { + if (!empty($conf->accounting->enabled)) { $bankaccountstatic->account_number = $objp->account_number; $accountingjournal = new AccountingJournal($db); @@ -2786,7 +2786,7 @@ else if ($objp->baid > 0) print $bankaccountstatic->getNomUrl(1, 'transactions'); print ''; } - print ''; + print ''; print ''; + print ' :'; //$resteapayer = $object->total_ttc - $totalpaye; $resteapayeraffiche = $resteapayer; @@ -2847,8 +2847,8 @@ else $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql .= " re.description, re.fk_invoice_supplier_source"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; - $sql .= " WHERE fk_invoice_supplier = " . $object->id; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_invoice_supplier = ".$object->id; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -2857,18 +2857,18 @@ else while ($i < $num) { $obj = $db->fetch_object($resql); $invoice->fetch($obj->fk_invoice_supplier_source); - print ''; - print ''; + print ''; print ''; - $i ++; + $i++; if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) $creditnoteamount += $obj->amount_ttc; if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT) @@ -2880,73 +2880,73 @@ else // Paye partiellement 'escompte' if (($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED) && $object->close_code == 'discount_vat') { - print ''; + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Paye partiellement ou Abandon 'badsupplier' if (($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED) && $object->close_code == 'badsupplier') { - print ''; + print ''; // $resteapayeraffiche=0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Paye partiellement ou Abandon 'product_returned' if (($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED) && $object->close_code == 'product_returned') { - print ''; + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Paye partiellement ou Abandon 'abandon' if (($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED) && $object->close_code == 'abandon') { - print ''; + $text .= '

'.$langs->trans("Reason").':'.$object->close_note; + print $form->textwithpicto($langs->trans("Abandoned").':', $text, - 1); + print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Billed - print ''; + print ''; // Remainder to pay - print ''; - print ''; + print ''; print ''; } else // Credit note { - $cssforamountpaymentcomplete='amountpaymentneutral'; + $cssforamountpaymentcomplete = 'amountpaymentneutral'; // Total already paid back - print ''; + print ' :'; // Billed - print ''; + print ''; // Remainder to pay back - print ''; - print ''; + print ''; print ''; // Sold credit note @@ -2964,16 +2964,16 @@ else print '

'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $colwidth=20; + $colwidth = 20; $blocname = 'notes'; $title = $langs->trans('Notes'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; @@ -2983,31 +2983,31 @@ else /* * Lines */ - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - if (! empty($conf->use_javascript_ajax) && $object->statut == FactureFournisseur::STATUS_DRAFT) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->statut == FactureFournisseur::STATUS_DRAFT) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; print '
' . ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')) . ''.($object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('BankAccount').''.$langs->trans('Amount').' 
'; print $paymentstatic->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->dp), 'day') . ''.dol_print_date($db->jdate($objp->dp), 'day').''; print $form->form_modes_reglement(null, $objp->paiement_type, 'none').' '.$objp->num_paiement; print '' . price($sign * $objp->amount) . ''.price($sign * $objp->amount).''; if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { @@ -2828,12 +2828,12 @@ else if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE) { // Total already paid - print '
'; + print '
'; if ($object->type != FactureFournisseur::TYPE_DEPOSIT) print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); else print $langs->trans('AlreadyPaid'); - print ' : 0)?' class="amountalreadypaid"':'').'>' . price($totalpaye) . ' 
0) ? ' class="amountalreadypaid"' : '').'>'.price($totalpaye).' 
'; + print '
'; if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) - print $langs->trans("CreditNote") . ' '; + print $langs->trans("CreditNote").' '; if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT) - print $langs->trans("Deposit") . ' '; + print $langs->trans("Deposit").' '; print $invoice->getNomUrl(0); print ' :' . price($obj->amount_ttc) . ''.price($obj->amount_ttc).''; - print 'rowid . '">' . img_delete() . ''; + print 'rowid.'">'.img_delete().''; print '
'; - print $form->textwithpicto($langs->trans("Discount") . ':', $langs->trans("HelpEscompte"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + print $form->textwithpicto($langs->trans("Discount").':', $langs->trans("HelpEscompte"), - 1); + print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' 
'; - print $form->textwithpicto($langs->trans("Abandoned") . ':', $langs->trans("HelpAbandonBadCustomer"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + print $form->textwithpicto($langs->trans("Abandoned").':', $langs->trans("HelpAbandonBadCustomer"), - 1); + print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' 
'; - print $form->textwithpicto($langs->trans("ProductReturned") . ':', $langs->trans("HelpAbandonProductReturned"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + print $form->textwithpicto($langs->trans("ProductReturned").':', $langs->trans("HelpAbandonProductReturned"), - 1); + print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' 
'; + 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($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' 
' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' 
'.$langs->trans("Billed").' :'.price($object->total_ttc).' 
'; + print '
'; if ($resteapayeraffiche >= 0) print $langs->trans('RemainderToPay'); else print $langs->trans('ExcessPaid'); print ' :' . price($resteapayeraffiche) . ''.price($resteapayeraffiche).' 
'; + print '
'; print $langs->trans('AlreadyPaidBack'); - print ' :' . price($sign * $totalpaye) . ' 
'.price($sign * $totalpaye).' 
' . $langs->trans("Billed") . ' :' . price($sign * $object->total_ttc) . ' 
'.$langs->trans("Billed").' :'.price($sign * $object->total_ttc).' 
'; + print '
'; if ($resteapayeraffiche <= 0) print $langs->trans('RemainderToPayBack'); else print $langs->trans('ExcessPaid'); print ' :' . price($sign * $resteapayeraffiche) . ''.price($sign * $resteapayeraffiche).' 
'; global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; - $forceall=1; $dateSelector=0; $inputalsopricewithtax=1; - $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. + $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1; + $senderissupplier = 2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. //if (! empty($conf->global->SUPPLIER_INVOICE_WITH_NOPRICEDEFINED)) $senderissupplier=2; - if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; + if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier = 1; // Show object lines - if (! empty($object->lines)) + if (!empty($object->lines)) $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); - $num=count($object->lines); + $num = count($object->lines); // Form to add new line if ($object->statut == FactureFournisseur::STATUS_DRAFT && $user->rights->fournisseur->facture->creer) @@ -3046,7 +3046,7 @@ else if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer) { // We check if lines of invoice are not already transfered into accountancy - $ventilExportCompta = $object->getVentilExportCompta(); // Should be 0 since the sum of payments are zero. But we keep the protection. + $ventilExportCompta = $object->getVentilExportCompta(); // Should be 0 since the sum of payments are zero. But we keep the protection. if ($ventilExportCompta == 0) { @@ -3054,7 +3054,7 @@ else } else { - print '
' . $langs->trans('Modify') . '
'; + print '
'.$langs->trans('Modify').'
'; } } @@ -3066,7 +3066,7 @@ else || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id))) && ($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED)) // A paid invoice (partially or completely) { - if (! $facidnext && $object->close_code != 'replaced' && $user->rights->fournisseur->facture->creer) // Not replaced by another invoice + if (!$facidnext && $object->close_code != 'replaced' && $user->rights->fournisseur->facture->creer) // Not replaced by another invoice { print ''; } @@ -3091,13 +3091,13 @@ else } // Make payments - if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) + if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { - print ''; // must use facid because id is for payment id not invoice + print ''; // must use facid because id is for payment id not invoice } // Classify paid - if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) + if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { print ''; @@ -3127,7 +3127,7 @@ else } // For credit note if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() == 0) { - print ''; + print ''; } // For deposit invoice if ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 1 && $resteapayer == 0 && $user->rights->fournisseur->facture->creer && empty($discount->id)) @@ -3141,8 +3141,8 @@ else { if (count($object->lines)) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate))) + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate))) { print ''; @@ -3170,32 +3170,32 @@ else // Create a credit note if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_DEPOSIT) && $object->statut > 0 && $user->rights->fournisseur->facture->creer) { - if (! $objectidnext) + if (!$objectidnext) { - print ''; + print ''; } } // Delete - $isErasable=$object->is_erasable(); + $isErasable = $object->is_erasable(); if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($user->rights->fournisseur->facture->creer && $isErasable == 1))) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) { //var_dump($isErasable); if ($isErasable == -4) { - print ''; + print ''; } elseif ($isErasable == -3) { // Should never happen with supplier invoice - print ''; + print ''; } elseif ($isErasable == -2) { // Should never happen with supplier invoice - print ''; + print ''; } elseif ($isErasable == -1) { - print ''; + print ''; } elseif ($isErasable <= 0) // Any other cases { - print ''; + print ''; } else { @@ -3211,16 +3211,16 @@ else /* * Documents generes */ - $ref=dol_sanitizeFileName($object->ref); + $ref = dol_sanitizeFileName($object->ref); $subdir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$ref; $filedir = $conf->fournisseur->facture->dir_output.'/'.$subdir; - $urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id; - $genallowed=$user->rights->fournisseur->facture->lire; - $delallowed=$user->rights->fournisseur->facture->creer; - $modelpdf=(! empty($object->modelpdf)?$object->modelpdf:(empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)?'':$conf->global->INVOICE_SUPPLIER_ADDON_PDF)); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id; + $genallowed = $user->rights->fournisseur->facture->lire; + $delallowed = $user->rights->fournisseur->facture->creer; + $modelpdf = (!empty($object->modelpdf) ? $object->modelpdf : (empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF) ? '' : $conf->global->INVOICE_SUPPLIER_ADDON_PDF)); print $formfile->showdocuments('facture_fournisseur', $subdir, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0, '', '', '', $societe->default_lang); - $somethingshown=$formfile->numoffiles; + $somethingshown = $formfile->numoffiles; // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice_supplier')); @@ -3232,8 +3232,8 @@ else // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - $somethingshown = $formactions->showactions($object, 'invoice_supplier', $socid, 1, 'listaction'.($genallowed?'largetitle':'')); + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'invoice_supplier', $socid, 1, 'listaction'.($genallowed ? 'largetitle' : '')); print ''; //print '
'; @@ -3247,10 +3247,10 @@ else } // Presend form - $modelmail='invoice_supplier_send'; - $defaulttopic='SendBillRef'; + $modelmail = 'invoice_supplier_send'; + $defaulttopic = 'SendBillRef'; $diroutput = $conf->fournisseur->facture->dir_output; - $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO'; $trackid = 'sin'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 133fa4fd3d6..cfa12648377 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -$langs->loadLangs(array("products","suppliers")); +$langs->loadLangs(array("products", "suppliers")); if (!$user->rights->produit->lire && !$user->rights->service->lire) accessforbidden(); @@ -42,7 +42,7 @@ $type = GETPOST('type'); $optioncss = GETPOST('optioncss', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -50,11 +50,11 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="p.ref"; // Set here default search field -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "p.ref"; // Set here default search field +if (!$sortorder) $sortorder = "ASC"; $fourn_id = GETPOST('fourn_id', 'intcomma'); -if ($user->socid) $fourn_id=$user->socid; +if ($user->socid) $fourn_id = $user->socid; $catid = GETPOST('catid', 'intcomma'); @@ -71,12 +71,12 @@ $extrafields = new ExtraFields($db); * Put here all code to do according to value of "action" parameter */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array(); +$parameters = array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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)) @@ -85,17 +85,17 @@ if (empty($reshook)) 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 + 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 { $sref = ''; $sRefSupplier = ''; $snom = ''; - $search_field1=''; - $search_field2=''; - $search_date_creation=''; - $search_date_update=''; - $toselect=''; - $search_array_options=array(); + $search_field1 = ''; + $search_field2 = ''; + $search_date_creation = ''; + $search_date_update = ''; + $toselect = ''; + $search_array_options = array(); } } @@ -107,7 +107,7 @@ $form = new Form($db); $productstatic = new Product($db); $companystatic = new Societe($db); -$title=$langs->trans("ProductsAndServices"); +$title = $langs->trans("ProductsAndServices"); if ($fourn_id) { @@ -117,36 +117,36 @@ if ($fourn_id) -$arrayofmassactions = array( +$arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); -if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); $sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity,"; -$sql.= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,"; -$sql.= " s.rowid as socid, s.nom as name"; +$sql .= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,"; +$sql .= " s.rowid as socid, s.nom as name"; // Add fields to SELECT from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $sql .= $hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."product as p"; -if ($catid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ppf.fk_soc = s.rowid"; -$sql.= " WHERE p.entity IN (".getEntity('product').")"; +$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; +if ($catid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ppf.fk_soc = s.rowid"; +$sql .= " WHERE p.entity IN (".getEntity('product').")"; if ($sRefSupplier) { $sql .= natural_search('ppf.ref_fourn', $sRefSupplier); } if (GETPOST('type')) { - $sql .= " AND p.fk_product_type = " . GETPOST('type', 'int'); + $sql .= " AND p.fk_product_type = ".GETPOST('type', 'int'); } if ($sref) { @@ -156,7 +156,7 @@ if ($snom) { $sql .= natural_search('p.label', $snom); } -if($catid) +if ($catid) { $sql .= " AND cp.fk_categorie = ".$catid; } @@ -203,18 +203,18 @@ if ($resql) exit; } - if (! empty($supplier->id)) $texte = $langs->trans("ListOfSupplierProductForSupplier", $supplier->name); + if (!empty($supplier->id)) $texte = $langs->trans("ListOfSupplierProductForSupplier", $supplier->name); else $texte = $langs->trans("List"); llxHeader("", "", $texte); - $param="&tobuy=".$tobuy."&sref=".$sref."&snom=".$snom."&fourn_id=".$fourn_id.(isset($type)?"&type=".$type:"").(empty($sRefSupplier)?"":"&srefsupplier=".$sRefSupplier); - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = "&tobuy=".$tobuy."&sref=".$sref."&snom=".$snom."&fourn_id=".$fourn_id.(isset($type) ? "&type=".$type : "").(empty($sRefSupplier) ? "" : "&srefsupplier=".$sRefSupplier); + if ($optioncss != '') $param .= '&optioncss='.$optioncss; print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); - if (! empty($catid)) + if (!empty($catid)) { print "
"; $c = new Categorie($db); @@ -232,10 +232,10 @@ if ($resql) print ''; print ''; - $topicmail="Information"; - $modelmail="product"; - $objecttmp=new Product($db); - $trackid='prod'.$object->id; + $topicmail = "Information"; + $modelmail = "product"; + $objecttmp = new Product($db); + $trackid = 'prod'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; print ''; @@ -261,7 +261,7 @@ if ($resql) if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); print $hookmanager->resPrint; print ''; print ''; @@ -292,10 +292,10 @@ if ($resql) print ''; print ''; @@ -303,8 +303,8 @@ if ($resql) print ''."\n"; - $companystatic->name=$objp->name; - $companystatic->id=$objp->socid; + $companystatic->name = $objp->name; + $companystatic->id = $objp->socid; print ''; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 777c467ad67..b10f409e9a1 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -39,26 +39,26 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_expression.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; -if(!empty($conf->barcode->enabled)) dol_include_once('/core/class/html.formbarcode.class.php'); +if (!empty($conf->barcode->enabled)) dol_include_once('/core/class/html.formbarcode.class.php'); // Load translation files required by the page $langs->loadLangs(array('products', 'suppliers', 'bills', 'margins')); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$rowid=GETPOST('rowid', 'int'); -$action=GETPOST('action', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'pricesuppliercard'; +$rowid = GETPOST('rowid', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'pricesuppliercard'; -$socid=GETPOST('socid', 'int'); -$cost_price=GETPOST('cost_price', 'alpha'); -$backtopage=GETPOST('backtopage', 'alpha'); -$error=0; +$socid = GETPOST('socid', 'int'); +$cost_price = GETPOST('cost_price', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$error = 0; $extrafields = new ExtraFields($db); // If socid provided by ajax company selector -if (! empty($_REQUEST['search_fourn_id'])) +if (!empty($_REQUEST['search_fourn_id'])) { $_GET['id_fourn'] = $_GET['search_fourn_id']; $_POST['id_fourn'] = $_POST['search_fourn_id']; @@ -66,26 +66,26 @@ if (! empty($_REQUEST['search_fourn_id'])) } // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); if (empty($user->rights->fournisseur->lire)) accessforbidden(); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = (GETPOST("page", 'int')?GETPOST("page", 'int'):0); +$page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="s.nom"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "s.nom"; +if (!$sortorder) $sortorder = "ASC"; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('pricesuppliercard','globalcard')); +$hookmanager->initHooks(array('pricesuppliercard', 'globalcard')); $object = new ProductFournisseur($db); if ($id > 0 || $ref) @@ -96,21 +96,21 @@ if ($id > 0 || $ref) $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (! $sortfield) $sortfield="s.nom"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "s.nom"; +if (!$sortorder) $sortorder = "ASC"; /* * Actions */ -if ($cancel) $action=''; +if ($cancel) $action = ''; $usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); $usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); -$parameters=array('socid'=>$socid, 'id_prod'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid, 'id_prod'=>$id); +$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)) @@ -119,13 +119,13 @@ if (empty($reshook)) { if ($id) { - $result=$object->fetch($id); + $result = $object->fetch($id); $object->cost_price = price2num($cost_price); - $result=$object->update($object->id, $user); + $result = $object->update($object->id, $user); if ($result > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $action=''; + $action = ''; } else { @@ -140,11 +140,11 @@ if (empty($reshook)) if ($rowid) // id of product supplier price to remove { $action = ''; - $result=$object->remove_product_fournisseur_price($rowid); - if($result > 0){ - $db->query("DELETE FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = $rowid"); + $result = $object->remove_product_fournisseur_price($rowid); + if ($result > 0) { + $db->query("DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = $rowid"); setEventMessages($langs->trans("PriceRemoved"), null, 'mesgs'); - }else{ + } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); } @@ -153,23 +153,23 @@ if (empty($reshook)) if ($action == 'save_price') { - $id_fourn=GETPOST("id_fourn"); - if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn"); - $ref_fourn=GETPOST("ref_fourn"); - if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn"); - $ref_fourn_old=GETPOST("ref_fourn_old"); + $id_fourn = GETPOST("id_fourn"); + if (empty($id_fourn)) $id_fourn = GETPOST("search_id_fourn"); + $ref_fourn = GETPOST("ref_fourn"); + if (empty($ref_fourn)) $ref_fourn = GETPOST("search_ref_fourn"); + $ref_fourn_old = GETPOST("ref_fourn_old"); if (empty($ref_fourn_old)) $ref_fourn_old = $ref_fourn; - $quantity=price2num(GETPOST("qty", 'nohtml'), 'MS'); - $remise_percent=price2num(GETPOST('remise_percent', 'alpha')); - $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0 ; + $quantity = price2num(GETPOST("qty", 'nohtml'), 'MS'); + $remise_percent = price2num(GETPOST('remise_percent', 'alpha')); + $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0; $tva_tx = str_replace('*', '', GETPOST('tva_tx', 'alpha')); $tva_tx = price2num($tva_tx); $price_expression = GETPOST('eid', 'int') ? GETPOST('eid', 'int') : ''; // Discard expression if not in expression mode $delivery_time_days = GETPOST('delivery_time_days', 'int') ? GETPOST('delivery_time_days', 'int') : ''; $supplier_reputation = GETPOST('supplier_reputation'); $supplier_description = GETPOST('supplier_description', 'alpha'); - $barcode=GETPOST('barcode', 'alpha'); - $fk_barcode_type=GETPOST('fk_barcode_type', 'int'); + $barcode = GETPOST('barcode', 'alpha'); + $fk_barcode_type = GETPOST('fk_barcode_type', 'int'); if ($tva_tx == '') { @@ -177,7 +177,7 @@ if (empty($reshook)) $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("VATRateForSupplierProduct")), null, 'errors'); } - if (! is_numeric($tva_tx)) + if (!is_numeric($tva_tx)) { $error++; $langs->load("errors"); @@ -232,13 +232,13 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $db->begin(); - if (! $error) + if (!$error) { - $ret=$object->add_fournisseur($user, $id_fourn, $ref_fourn_old, $quantity); // This insert record with no value for price. Values are update later with update_buyprice + $ret = $object->add_fournisseur($user, $id_fourn, $ref_fourn_old, $quantity); // This insert record with no value for price. Values are update later with update_buyprice if ($ret == -3) { $error++; @@ -255,37 +255,37 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { - $supplier=new Fournisseur($db); - $result=$supplier->fetch($id_fourn); + $supplier = new Fournisseur($db); + $result = $supplier->fetch($id_fourn); if (isset($_POST['ref_fourn_price_id'])) $object->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']); - $extralabels=$extrafields->fetch_name_optionals_label("product_fournisseur_price"); + $extralabels = $extrafields->fetch_name_optionals_label("product_fournisseur_price"); $extrafield_values = $extrafields->getOptionalsFromPost("product_fournisseur_price"); $sql = ""; - $resql = $db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = " . $object->product_fourn_price_id); + $resql = $db->query("SELECT * FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = ".$object->product_fourn_price_id); // Insert a new extrafields row, if none exists if ($db->num_rows($resql) != 1) { - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields (fk_object, "; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields (fk_object, "; foreach ($extrafield_values as $key => $value) { - $sql .= str_replace('options_', '', $key) . ', '; + $sql .= str_replace('options_', '', $key).', '; } - $sql = substr($sql, 0, strlen($sql)-2) . ") VALUES (" . $object->product_fourn_price_id . ", "; + $sql = substr($sql, 0, strlen($sql) - 2).") VALUES (".$object->product_fourn_price_id.", "; foreach ($extrafield_values as $key => $value) { - $sql .= '"' . $value . '", '; + $sql .= '"'.$value.'", '; } - $sql = substr($sql, 0, strlen($sql)-2) . ')'; + $sql = substr($sql, 0, strlen($sql) - 2).')'; } // else update the existing one else { - $sql = "UPDATE " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields SET "; + $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields SET "; foreach ($extrafield_values as $key => $value) { - $sql .= str_replace('options_', '', $key) . ' = "' . $value . '", '; + $sql .= str_replace('options_', '', $key).' = "'.$value.'", '; } - $sql = substr($sql, 0, strlen($sql)-2) . ' WHERE fk_object = ' . $object->product_fourn_price_id; + $sql = substr($sql, 0, strlen($sql) - 2).' WHERE fk_object = '.$object->product_fourn_price_id; } // Execute the sql command from above @@ -321,10 +321,10 @@ if (empty($reshook)) setEventMessages($priceparser->translatedError(), null, 'errors'); } } - if (! $error && ! empty($conf->dynamicprices->enabled)) + if (!$error && !empty($conf->dynamicprices->enabled)) { //Set the price expression for this supplier price - $ret=$object->setSupplierPriceExpression($price_expression); + $ret = $object->setSupplierPriceExpression($price_expression); if ($ret < 0) { $error++; @@ -334,10 +334,10 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $db->commit(); - $action=''; + $action = ''; } else { @@ -361,13 +361,13 @@ $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('BuyingPrices'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('BuyingPrices'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('BuyingPrices'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('BuyingPrices'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); @@ -380,23 +380,23 @@ if ($id > 0 || $ref) { if ($action == 'ask_remove_pf') { $form = new Form($db); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id . '&rowid=' . $rowid, $langs->trans('DeleteProductBuyPrice'), $langs->trans('ConfirmDeleteProductBuyPrice'), 'confirm_remove_pf', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&rowid='.$rowid, $langs->trans('DeleteProductBuyPrice'), $langs->trans('ConfirmDeleteProductBuyPrice'), 'confirm_remove_pf', '', 0, 1); echo $formconfirm; } if ($action <> 'edit' && $action <> 're-edit') { - $head=product_prepare_head($object); - $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); + $head = product_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'suppliers', $titre, -1, $picto); $linkback = ''.$langs->trans("BackToList").''; - $object->next_prev_filter=" fk_product_type = ".$object->type; + $object->next_prev_filter = " fk_product_type = ".$object->type; $shownav = 1; - if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -419,9 +419,9 @@ if ($id > 0 || $ref) // Cost price. Can be used for margin module for option "calculate margin on explicit cost price // Accountancy sell code print ''; print ''; // Availability - if (! empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) + if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) { $langs->load("propal"); print ''; // Vat rate - $default_vat=''; + $default_vat = ''; // We don't have supplier, so we try to guess. // For this we build a fictive supplier with same properties than user but using vat) $mysoc2 = clone $mysoc; - $mysoc2->name='Fictive seller with same country'; - $mysoc2->tva_assuj=1; - $default_vat=get_default_tva($mysoc2, $mysoc, $object->id, 0); - $default_npr=get_default_npr($mysoc2, $mysoc, $object->id, 0); - if (empty($default_vat)) $default_npr=$default_vat; + $mysoc2->name = 'Fictive seller with same country'; + $mysoc2->tva_assuj = 1; + $default_vat = get_default_tva($mysoc2, $mysoc, $object->id, 0); + $default_npr = get_default_npr($mysoc2, $mysoc, $object->id, 0); + if (empty($default_vat)) $default_npr = $default_vat; print ''; print ''; - if (! empty($conf->dynamicprices->enabled)) //Only show price mode and expression selector if module is enabled + if (!empty($conf->dynamicprices->enabled)) //Only show price mode and expression selector if module is enabled { // Price mode selector print ''; print ''; print ''; // Currency tx print ''; - print ''; print ''; // Currency price qty min print ''; - $pricesupplierincurrencytouse=(GETPOST('multicurrency_price')?GETPOST('multicurrency_price'):(isset($object->fourn_multicurrency_price)?$object->fourn_multicurrency_price:'')); + $pricesupplierincurrencytouse = (GETPOST('multicurrency_price') ?GETPOST('multicurrency_price') : (isset($object->fourn_multicurrency_price) ? $object->fourn_multicurrency_price : '')); print ''; // Price qty min - print ''; + print ''; print ''; - print ''; + print ''; } // Discount qty min print ''; - print ''; print ''; @@ -712,22 +712,22 @@ SCRIPT; // Reputation print ''; // Barcode - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { // Option to define a transport cost on supplier price print ''; - print ''; + print ''; print ''; print ''; $formbarcode = new FormBarCode($db); // Barcode type print ''; - print ''; + print ''; print ''; @@ -737,18 +737,18 @@ SCRIPT; // Option to define a transport cost on supplier price if ($conf->global->PRODUCT_CHARGES) { - if (! empty($conf->margin->enabled)) + if (!empty($conf->margin->enabled)) { print ''; print ''; - print ''; print ''; } } // Product description of the supplier - if (! empty($conf->global->PRODUIT_FOURN_TEXTS)) + if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -765,21 +765,21 @@ SCRIPT; } $extrafields->fetch_name_optionals_label("product_fournisseur_price"); - $extralabels=$extrafields->attributes["product_fournisseur_price"]['label']; + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; // Extrafields - $resql = $db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = " . $rowid); + $resql = $db->query("SELECT * FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = ".$rowid); if (!empty($extralabels)) { if ($db->num_rows($resql) != 1) { foreach ($extralabels as $key => $value) { - if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { - print 'attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '') . '>' . $langs->trans($value) . ''; + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { + print 'attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>'.$langs->trans($value).''; } } } else { $resql = $db->fetch_object($resql); foreach ($extralabels as $key => $value) { - if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { - print 'attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '') . '>' . $langs->trans($value) . ''; + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) { + print 'attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>'.$langs->trans($value).''; } } } @@ -787,8 +787,8 @@ SCRIPT; if (is_object($hookmanager)) { - $parameters=array('id_fourn'=>$id_fourn,'prod_id'=>$object->id); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); + $parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; } @@ -811,8 +811,8 @@ SCRIPT; if ($action != 'add_price' && $action != 'update_price') { - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if ($usercancreate) @@ -828,10 +828,10 @@ SCRIPT; if ($user->rights->fournisseur->lire) // Duplicate ? this check is already in the head of this file { - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - $param.='&ref='.urlencode($object->ref); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + $param .= '&ref='.urlencode($object->ref); $product_fourn = new ProductFournisseur($db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($object->id, $sortfield, $sortorder, $limit, $offset); @@ -846,7 +846,7 @@ SCRIPT; print '
'; print '
'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; - $productstatic->id=$objp->rowid; - $productstatic->ref=$objp->ref; - $productstatic->type=$objp->fk_product_type; - $productstatic->entity=$objp->entity; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->type = $objp->fk_product_type; + $productstatic->entity = $objp->entity; print $productstatic->getNomUrl(1, 'supplier'); print ''.$objp->label.''; if ($companystatic->id > 0) print $companystatic->getNomUrl(1, 'supplier'); print '
'; - $textdesc =$langs->trans("CostPriceDescription"); - $textdesc.="
".$langs->trans("CostPriceUsage"); - $text=$form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', ''); + $textdesc = $langs->trans("CostPriceDescription"); + $textdesc .= "
".$langs->trans("CostPriceUsage"); + $text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', ''); print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); print '
'; print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); @@ -436,7 +436,7 @@ if ($id > 0 || $ref) // Form to add or update a price - if (($action == 'add_price' || $action == 'update_price' ) && $usercancreate) + if (($action == 'add_price' || $action == 'update_price') && $usercancreate) { $langs->load("suppliers"); @@ -462,7 +462,7 @@ if ($id > 0 || $ref) print '
'.$langs->trans("Supplier").''; if ($rowid) { - $supplier=new Fournisseur($db); + $supplier = new Fournisseur($db); $supplier->fetch($socid); print $supplier->getNomUrl(1); print ''; @@ -472,12 +472,12 @@ if ($id > 0 || $ref) } else { - $events=array(); - $events[]=array('method' => 'getVatRates', 'url' => dol_buildpath('/core/ajax/vatrates.php', 1), 'htmlname' => 'tva_tx', 'params' => array()); + $events = array(); + $events[] = array('method' => 'getVatRates', 'url' => dol_buildpath('/core/ajax/vatrates.php', 1), 'htmlname' => 'tva_tx', 'params' => array()); print $form->select_company(GETPOST("id_fourn", 'alpha'), 'id_fourn', 'fournisseur=1', 'SelectThirdParty', 0, 0, $events); - $parameters=array('filtre'=>"fournisseur=1",'html_name'=>'id_fourn','selected'=>GETPOST("id_fourn"),'showempty'=>1,'prod_id'=>$object->id); - $reshook=$hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action); + $parameters = array('filtre'=>"fournisseur=1", 'html_name'=>'id_fourn', 'selected'=>GETPOST("id_fourn"), 'showempty'=>1, 'prod_id'=>$object->id); + $reshook = $hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action); if (empty($reshook)) { if (empty($form->result)) @@ -497,13 +497,13 @@ if ($id > 0 || $ref) } else { - print ''; + print ''; } print '
'.$langs->trans("Availability").''; @@ -529,46 +529,46 @@ if ($id > 0 || $ref) if ($conf->global->PRODUCT_USE_UNITS) { $unit = $object->getLabelOfUnit(); if ($unit !== '') { - print '  ' . $langs->trans($unit); + print '  '.$langs->trans($unit); } } print '
'.$langs->trans("VATRateForSupplierProduct").''; //print $form->load_tva('tva_tx',$object->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country - if (! empty($rowid)) // If we have a supplier, it is an update, we must show the vat of current supplier price + if (!empty($rowid)) // If we have a supplier, it is an update, we must show the vat of current supplier price { - $tmpproductsupplier=new ProductFournisseur($db); + $tmpproductsupplier = new ProductFournisseur($db); $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1); - $default_vat=$tmpproductsupplier->fourn_tva_tx; - $default_npr=$tmpproductsupplier->fourn_tva_npr; + $default_vat = $tmpproductsupplier->fourn_tva_tx; + $default_npr = $tmpproductsupplier->fourn_tva_npr; } else { if (empty($default_vat)) { - $default_vat=$object->tva_tx; + $default_vat = $object->tva_tx; } } - $vattosuggest=(GETPOST("tva_tx")?vatrate(GETPOST("tva_tx")):($default_vat!=''?vatrate($default_vat):'')); - $vattosuggest=preg_replace('/\s*\(.*\)$/', '', $vattosuggest); + $vattosuggest = (GETPOST("tva_tx") ?vatrate(GETPOST("tva_tx")) : ($default_vat != '' ?vatrate($default_vat) : '')); + $vattosuggest = preg_replace('/\s*\(.*\)$/', '', $vattosuggest); print ''; print '
'.$langs->trans("PriceMode").''; @@ -606,28 +606,28 @@ if ($id > 0 || $ref) // Currency print '
'.$langs->trans("Currency").''; - $currencycodetouse = GETPOST('multicurrency_code')?GETPOST('multicurrency_code'):(isset($object->fourn_multicurrency_code)?$object->fourn_multicurrency_code:''); - if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) $currencycodetouse=$conf->currency; + $currencycodetouse = GETPOST('multicurrency_code') ?GETPOST('multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code : ''); + if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) $currencycodetouse = $conf->currency; print $form->selectMultiCurrency($currencycodetouse, "multicurrency_code", 1); print '
'.$langs->trans("CurrencyRate").''; + print ''; print '
'.$langs->trans("PriceQtyMinCurrency").''; print ' '; - print $form->selectPriceBaseType((GETPOST('multicurrency_price_base_type')?GETPOST('multicurrency_price_base_type'):'HT'), "multicurrency_price_base_type"); // We keep 'HT' here, multicurrency_price_base_type is not yet supported for supplier prices + print $form->selectPriceBaseType((GETPOST('multicurrency_price_base_type') ?GETPOST('multicurrency_price_base_type') : 'HT'), "multicurrency_price_base_type"); // We keep 'HT' here, multicurrency_price_base_type is not yet supported for supplier prices print '
' . $langs->trans("PriceQtyMin") . '
'.$langs->trans("PriceQtyMin").''; print ''; print ''; @@ -690,17 +690,17 @@ if ($id > 0 || $ref) SCRIPT; } else { // Price qty min - print '
' . $langs->trans("PriceQtyMin") . ''; + print '
'.$langs->trans("PriceQtyMin").''; print ' '; - print $form->selectPriceBaseType((GETPOST('price_base_type') ? GETPOST('price_base_type') : 'HT'), "price_base_type"); // We keep 'HT' here, price_base_type is not yet supported for supplier prices + print $form->selectPriceBaseType((GETPOST('price_base_type') ? GETPOST('price_base_type') : 'HT'), "price_base_type"); // We keep 'HT' here, price_base_type is not yet supported for supplier prices print '
'.$langs->trans("DiscountQtyMin").' %'; + print ' %'; print '
'.$langs->trans("SupplierReputation").''; - echo $form->selectarray('supplier_reputation', $object->reputations, $supplier_reputation?$supplier_reputation:$object->supplier_reputation); + echo $form->selectarray('supplier_reputation', $object->reputations, $supplier_reputation ? $supplier_reputation : $object->supplier_reputation); print '
' . $langs->trans('BarcodeValue') . ''.$langs->trans('BarcodeValue').'
' . $langs->trans('BarcodeType') . ''.$langs->trans('BarcodeType').''; print $formbarcode->selectBarcodeType(($rowid ? $object->fourn_fk_barcode_type : $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE), 'fk_barcode_type', 1); print '
'.$langs->trans("Charges").''; + print ''; print '
' . $extrafields->showInputField($key, '', '', '', '', '', 0, 'product_fournisseur_price') . '
'.$extrafields->showInputField($key, '', '', '', '', '', 0, 'product_fournisseur_price').'
' . $extrafields->showInputField($key, $resql->{$key}, '', '', '', '', 0, 'product_fournisseur_price') . '
'.$extrafields->showInputField($key, $resql->{$key}, '', '', '', '', 0, 'product_fournisseur_price').'
'; - $param="&id=".$object->id; + $param = "&id=".$object->id; print ''; print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder); @@ -875,11 +875,11 @@ SCRIPT; // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label("product_fournisseur_price"); - $extralabels=$extrafields->attributes["product_fournisseur_price"]['label']; + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; if (!empty($extralabels)) { foreach ($extralabels as $key => $value) { // Show field if not hidden - if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { print_liste_field_titre($value, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); } } @@ -887,20 +887,20 @@ SCRIPT; if (is_object($hookmanager)) { - $parameters=array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); + $parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); } print_liste_field_titre(''); print "\n"; if (is_array($product_fourn_list)) { - foreach($product_fourn_list as $productfourn) + foreach ($product_fourn_list as $productfourn) { print ''; // Date from - print ''; + print ''; // Supplier print ''; @@ -916,10 +916,10 @@ SCRIPT; } // Availability - if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) + if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) { $form->load_cache_availability(); - $availability= $form->cache_availability[$productfourn->fk_availability]['label']; + $availability = $form->cache_availability[$productfourn->fk_availability]['label']; print ''; } @@ -930,7 +930,7 @@ SCRIPT; if ($conf->global->PRODUCT_USE_UNITS) { $unit = $object->getLabelOfUnit(); if ($unit !== '') { - print '  ' . $langs->trans($unit); + print '  '.$langs->trans($unit); } } print ''; @@ -942,7 +942,7 @@ SCRIPT; // Price for the quantity print ''; if ($conf->multicurrency->enabled) { @@ -995,9 +995,9 @@ SCRIPT; // Barcode type print ''; } @@ -1007,19 +1007,19 @@ SCRIPT; print ''; // Extrafields - $resql = $db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields WHERE fk_object = " . $productfourn->product_fourn_price_id); - if (! empty($extralabels)) { + $resql = $db->query("SELECT * FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = ".$productfourn->product_fourn_price_id); + if (!empty($extralabels)) { if ($db->num_rows($resql) != 1) { foreach ($extralabels as $key => $value) { - if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { print ""; } } } else { $resql = $db->fetch_object($resql); foreach ($extralabels as $key => $value) { - if (! empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { - print '"; + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + print '"; } } } @@ -1027,8 +1027,8 @@ SCRIPT; if (is_object($hookmanager)) { - $parameters=array('id_pfp'=>$productfourn->product_fourn_price_id,'id_fourn'=>$id_fourn,'prod_id'=>$object->id); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); + $parameters = array('id_pfp'=>$productfourn->product_fourn_price_id, 'id_fourn'=>$id_fourn, 'prod_id'=>$object->id); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); } // Modify-Remove diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index f5604cbacdb..e2d954b2847 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -26,7 +26,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -48,7 +48,7 @@ class Productlot extends CommonObject /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='barcode'; + public $picto = 'barcode'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -59,14 +59,14 @@ class Productlot extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'batch' =>array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>0, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), - 'fk_user_creat'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511) + 'batch' =>array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>0, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + 'fk_user_creat'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511) ); /** @@ -150,56 +150,56 @@ class Productlot extends CommonObject // Put here code to add control on parameters values // Insert request - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql.= 'entity,'; - $sql.= 'fk_product,'; - $sql.= 'batch,'; - $sql.= 'eatby,'; - $sql.= 'sellby,'; - $sql.= 'datec,'; - $sql.= 'fk_user_creat,'; - $sql.= 'fk_user_modif,'; - $sql.= 'import_key'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'('; + $sql .= 'entity,'; + $sql .= 'fk_product,'; + $sql .= 'batch,'; + $sql .= 'eatby,'; + $sql .= 'sellby,'; + $sql .= 'datec,'; + $sql .= 'fk_user_creat,'; + $sql .= 'fk_user_modif,'; + $sql .= 'import_key'; $sql .= ') VALUES ('; - $sql .= ' '.(! isset($this->entity)?$conf->entity:$this->entity).','; - $sql .= ' '.(! isset($this->fk_product)?'NULL':$this->fk_product).','; - $sql .= ' '.(! isset($this->batch)?'NULL':"'".$this->db->escape($this->batch)."'").','; - $sql .= ' '.(! isset($this->eatby) || dol_strlen($this->eatby)==0?'NULL':"'".$this->db->idate($this->eatby)."'").','; - $sql .= ' '.(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':"'".$this->db->idate($this->sellby)."'").','; + $sql .= ' '.(!isset($this->entity) ? $conf->entity : $this->entity).','; + $sql .= ' '.(!isset($this->fk_product) ? 'NULL' : $this->fk_product).','; + $sql .= ' '.(!isset($this->batch) ? 'NULL' : "'".$this->db->escape($this->batch)."'").','; + $sql .= ' '.(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'".$this->db->idate($this->eatby)."'").','; + $sql .= ' '.(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'".$this->db->idate($this->sellby)."'").','; $sql .= ' '."'".$this->db->idate(dol_now())."'".','; - $sql .= ' '.(! isset($this->fk_user_creat)?'NULL':$this->fk_user_creat).','; - $sql .= ' '.(! isset($this->fk_user_modif)?'NULL':$this->fk_user_modif).','; - $sql .= ' '.(! isset($this->import_key)?'NULL':$this->import_key); + $sql .= ' '.(!isset($this->fk_user_creat) ? 'NULL' : $this->fk_user_creat).','; + $sql .= ' '.(!isset($this->fk_user_modif) ? 'NULL' : $this->fk_user_modif).','; + $sql .= ' '.(!isset($this->import_key) ? 'NULL' : $this->import_key); $sql .= ')'; $this->db->begin(); $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) { + if (!$error && !$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. // Call triggers - $result=$this->call_trigger('PRODUCTLOT_CREATE', $user); + $result = $this->call_trigger('PRODUCTLOT_CREATE', $user); if ($result < 0) $error++; // End call triggers } @@ -209,7 +209,7 @@ class Productlot extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -243,11 +243,11 @@ class Productlot extends CommonObject $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif,"; $sql .= " t.import_key"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($product_id > 0 && $batch != '') { - $sql .= " WHERE t.batch = '". $this->db->escape($batch) . "' AND t.fk_product = " . $product_id; + $sql .= " WHERE t.batch = '".$this->db->escape($batch)."' AND t.fk_product = ".$product_id; } else { - $sql .= ' WHERE t.rowid = ' . $id; + $sql .= ' WHERE t.rowid = '.$id; } $resql = $this->db->query($sql); @@ -261,7 +261,7 @@ class Productlot extends CommonObject //$this->ref = $obj->fk_product.'_'.$obj->batch; $this->batch = $obj->batch; - $this->entity = (!empty($obj->entity)?$obj->entity:$conf->entity); // Prevent "null" entity + $this->entity = (!empty($obj->entity) ? $obj->entity : $conf->entity); // Prevent "null" entity $this->fk_product = $obj->fk_product; $this->eatby = $this->db->jdate($obj->eatby); $this->sellby = $this->db->jdate($obj->sellby); @@ -283,10 +283,10 @@ class Productlot extends CommonObject return 0; } } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -330,38 +330,38 @@ class Productlot extends CommonObject if (empty($this->oldcopy)) { - $org=new self($this->db); + $org = new self($this->db); $org->fetch($this->id); - $this->oldcopy=$org; + $this->oldcopy = $org; } // Update request - $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= ' entity = '.(isset($this->entity)?$this->entity:"null").','; - $sql .= ' fk_product = '.(isset($this->fk_product)?$this->fk_product:"null").','; - $sql .= ' batch = '.(isset($this->batch)?"'".$this->db->escape($this->batch)."'":"null").','; - $sql .= ' eatby = '.(! isset($this->eatby) || dol_strlen($this->eatby) != 0 ? "'".$this->db->idate($this->eatby)."'" : 'null').','; - $sql .= ' sellby = '.(! isset($this->sellby) || dol_strlen($this->sellby) != 0 ? "'".$this->db->idate($this->sellby)."'" : 'null').','; - $sql .= ' datec = '.(! isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; + $sql .= ' entity = '.(isset($this->entity) ? $this->entity : "null").','; + $sql .= ' fk_product = '.(isset($this->fk_product) ? $this->fk_product : "null").','; + $sql .= ' batch = '.(isset($this->batch) ? "'".$this->db->escape($this->batch)."'" : "null").','; + $sql .= ' eatby = '.(!isset($this->eatby) || dol_strlen($this->eatby) != 0 ? "'".$this->db->idate($this->eatby)."'" : 'null').','; + $sql .= ' sellby = '.(!isset($this->sellby) || dol_strlen($this->sellby) != 0 ? "'".$this->db->idate($this->sellby)."'" : 'null').','; + $sql .= ' datec = '.(!isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; - $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat)?$this->fk_user_creat:"null").','; - $sql .= ' fk_user_modif = '.(isset($this->fk_user_modif)?$this->fk_user_modif:"null").','; - $sql .= ' import_key = '.(isset($this->import_key)?$this->import_key:"null"); - $sql .= ' WHERE rowid=' . $this->id; + $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").','; + $sql .= ' fk_user_modif = '.(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").','; + $sql .= ' import_key = '.(isset($this->import_key) ? $this->import_key : "null"); + $sql .= ' WHERE rowid='.$this->id; $this->db->begin(); $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -370,7 +370,7 @@ class Productlot extends CommonObject if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger('PRODUCTLOT_MODIFY', $user); + $result = $this->call_trigger('PRODUCTLOT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -379,7 +379,7 @@ class Productlot extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -416,14 +416,14 @@ class Productlot extends CommonObject //} if (!$error) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; - $sql .= ' WHERE rowid=' . $this->id; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' WHERE rowid='.$this->id; $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } } @@ -431,7 +431,7 @@ class Productlot extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -469,9 +469,9 @@ class Productlot extends CommonObject // Other options if ($result < 0) { - $error ++; + $error++; $this->errors = $object->errors; - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } unset($object->context['createfromclone']); @@ -484,7 +484,7 @@ class Productlot extends CommonObject } else { $this->db->rollback(); - return - 1; + return -1; } } @@ -539,16 +539,16 @@ class Productlot extends CommonObject $result = ''; - $label = '' . $langs->trans("Batch") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Batch') . ': ' . $this->batch; + $label = ''.$langs->trans("Batch").''; + $label .= '
'; + $label .= ''.$langs->trans('Batch').': '.$this->batch; if ($this->eatby) { - $label.= '
' . $langs->trans('EatByDate') . ': ' . dol_print_date($this->eatby, 'day'); + $label .= '
'.$langs->trans('EatByDate').': '.dol_print_date($this->eatby, 'day'); } if ($this->sellby) { - $label.= '
' . $langs->trans('SellByDate') . ': ' . dol_print_date($this->sellby, 'day'); + $label .= '
'.$langs->trans('SellByDate').': '.dol_print_date($this->sellby, 'day'); } $url = DOL_URL_ROOT.'/product/stock/productlot_card.php?id='.$this->id; @@ -556,31 +556,31 @@ class Productlot extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->batch; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->batch; $result .= $linkend; return $result; diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 81fbd774111..22c8787348a 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -38,7 +38,7 @@ $langs->loadLangs(array('products', 'stocks', 'orders', 'productbatch')); if ($user->socid) { $socid = $user->socid; } -$result=restrictedArea($user, 'produit|service'); +$result = restrictedArea($user, 'produit|service'); //checks if a product has been ordered @@ -62,11 +62,11 @@ if (!$sortfield) { if (!$sortorder) { $sortorder = 'ASC'; } -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$offset = $limit * $page ; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$offset = $limit * $page; -$listofdata=array(); -if (! empty($_SESSION['massstockmove'])) $listofdata=json_decode($_SESSION['massstockmove'], true); +$listofdata = array(); +if (!empty($_SESSION['massstockmove'])) $listofdata = json_decode($_SESSION['massstockmove'], true); /* @@ -75,17 +75,17 @@ if (! empty($_SESSION['massstockmove'])) $listofdata=json_decode($_SESSION['mass if ($action == 'addline') { - if (! ($id_product > 0)) + if (!($id_product > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); } - if (! ($id_sw > 0)) + if (!($id_sw > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); } - if (! ($id_tw > 0)) + if (!($id_tw > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); @@ -96,16 +96,16 @@ if ($action == 'addline') $langs->load("errors"); setEventMessages($langs->trans("ErrorWarehouseMustDiffers"), null, 'errors'); } - if (! $qty) + if (!$qty) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); } // Check a batch number is provided if product need it - if (! $error) + if (!$error) { - $producttmp=new Product($db); + $producttmp = new Product($db); $producttmp->fetch($id_product); if ($producttmp->hasbatch()) { @@ -120,7 +120,7 @@ if ($action == 'addline') // TODO Check qty is ok for stock move. Note qty may not be enough yet, but we make a check now to report a warning. // What is important is to have qty when doing action 'createmovements' - if (! $error) + if (!$error) { // Warning, don't forget lines already added into the $_SESSION['massstockmove'] if ($producttmp->hasbatch()) @@ -131,12 +131,12 @@ if ($action == 'addline') } } - if (! $error) + if (!$error) { - if (count(array_keys($listofdata)) > 0) $id=max(array_keys($listofdata)) + 1; - else $id=1; - $listofdata[$id]=array('id'=>$id, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw, 'batch'=>$batch); - $_SESSION['massstockmove']=json_encode($listofdata); + if (count(array_keys($listofdata)) > 0) $id = max(array_keys($listofdata)) + 1; + else $id = 1; + $listofdata[$id] = array('id'=>$id, 'id_product'=>$id_product, 'qty'=>$qty, 'id_sw'=>$id_sw, 'id_tw'=>$id_tw, 'batch'=>$batch); + $_SESSION['massstockmove'] = json_encode($listofdata); unset($id_product); //unset($id_sw); @@ -147,16 +147,16 @@ if ($action == 'addline') if ($action == 'delline' && $idline != '') { - if (! empty($listofdata[$idline])) unset($listofdata[$idline]); - if (count($listofdata) > 0) $_SESSION['massstockmove']=json_encode($listofdata); + if (!empty($listofdata[$idline])) unset($listofdata[$idline]); + if (count($listofdata) > 0) $_SESSION['massstockmove'] = json_encode($listofdata); else unset($_SESSION['massstockmove']); } if ($action == 'createmovements') { - $error=0; + $error = 0; - if (! GETPOST("label")) + if (!GETPOST("label")) { $error++; setEventMessages($langs->trans("ErrorFieldRequired"), $langs->transnoentitiesnoconv("MovementLabel"), null, 'errors'); @@ -164,38 +164,38 @@ if ($action == 'createmovements') $db->begin(); - if (! $error) + if (!$error) { $product = new Product($db); - foreach($listofdata as $key => $val) // Loop on each movement to do + foreach ($listofdata as $key => $val) // Loop on each movement to do { - $id=$val['id']; - $id_product=$val['id_product']; - $id_sw=$val['id_sw']; - $id_tw=$val['id_tw']; - $qty=price2num($val['qty']); - $batch=$val['batch']; - $dlc=-1; // They are loaded later from serial - $dluo=-1; // They are loaded later from serial + $id = $val['id']; + $id_product = $val['id_product']; + $id_sw = $val['id_sw']; + $id_tw = $val['id_tw']; + $qty = price2num($val['qty']); + $batch = $val['batch']; + $dlc = -1; // They are loaded later from serial + $dluo = -1; // They are loaded later from serial - if (! $error && $id_sw <> $id_tw && is_numeric($qty) && $id_product) + if (!$error && $id_sw <> $id_tw && is_numeric($qty) && $id_product) { - $result=$product->fetch($id_product); + $result = $product->fetch($id_product); - $product->load_stock('novirtual'); // Load array product->stock_warehouse + $product->load_stock('novirtual'); // Load array product->stock_warehouse // Define value of products moved - $pricesrc=0; - if (! empty($product->pmp)) $pricesrc=$product->pmp; - $pricedest=$pricesrc; + $pricesrc = 0; + if (!empty($product->pmp)) $pricesrc = $product->pmp; + $pricedest = $pricesrc; //print 'price src='.$pricesrc.', price dest='.$pricedest;exit; - if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) // If product does not need lot/serial + if (empty($conf->productbatch->enabled) || !$product->hasbatch()) // If product does not need lot/serial { // Remove stock - $result1=$product->correct_stock( + $result1 = $product->correct_stock( $user, $id_sw, $qty, @@ -211,7 +211,7 @@ if ($action == 'createmovements') } // Add stock - $result2=$product->correct_stock( + $result2 = $product->correct_stock( $user, $id_tw, $qty, @@ -228,22 +228,22 @@ if ($action == 'createmovements') } else { - $arraybatchinfo=$product->loadBatchInfo($batch); + $arraybatchinfo = $product->loadBatchInfo($batch); if (count($arraybatchinfo) > 0) { $firstrecord = array_shift($arraybatchinfo); - $dlc=$firstrecord['eatby']; - $dluo=$firstrecord['sellby']; + $dlc = $firstrecord['eatby']; + $dluo = $firstrecord['sellby']; //var_dump($batch); var_dump($arraybatchinfo); var_dump($firstrecord); var_dump($dlc); var_dump($dluo); exit; } else { - $dlc=''; - $dluo=''; + $dlc = ''; + $dluo = ''; } // Remove stock - $result1=$product->correct_stock_batch( + $result1 = $product->correct_stock_batch( $user, $id_sw, $qty, @@ -262,7 +262,7 @@ if ($action == 'createmovements') } // Add stock - $result2=$product->correct_stock_batch( + $result2 = $product->correct_stock_batch( $user, $id_tw, $qty, @@ -289,13 +289,13 @@ if ($action == 'createmovements') } } - if (! $error) + if (!$error) { unset($_SESSION['massstockmove']); $db->commit(); setEventMessages($langs->trans("StockMovementRecorded"), null, 'mesgs'); - header("Location: ".DOL_URL_ROOT.'/product/stock/index.php'); // Redirect to avoid pb when using back + header("Location: ".DOL_URL_ROOT.'/product/stock/index.php'); // Redirect to avoid pb when using back exit; } else @@ -311,10 +311,10 @@ if ($action == 'createmovements') * View */ -$now=dol_now(); +$now = dol_now(); -$form=new Form($db); -$formproduct=new FormProduct($db); +$form = new Form($db); +$formproduct = new FormProduct($db); $productstatic = new Product($db); $warehousestatics = new Entrepot($db); $warehousestatict = new Entrepot($db); @@ -325,16 +325,16 @@ llxHeader('', $title); print load_fiche_titre($langs->trans("MassStockTransferShort")); -$titletoadd=$langs->trans("Select"); -$buttonrecord=$langs->trans("RecordMovement"); -$titletoaddnoent=$langs->transnoentitiesnoconv("Select"); -$buttonrecordnoent=$langs->transnoentitiesnoconv("RecordMovement"); +$titletoadd = $langs->trans("Select"); +$buttonrecord = $langs->trans("RecordMovement"); +$titletoaddnoent = $langs->transnoentitiesnoconv("Select"); +$buttonrecordnoent = $langs->transnoentitiesnoconv("RecordMovement"); print ''.$langs->trans("SelectProductInAndOutWareHouse", $titletoaddnoent, $buttonrecordnoent).'
'; print '
'."\n"; // Form to add a line print ''; -print ''; +print ''; print ''; @@ -342,7 +342,7 @@ print '
'; print '
'.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation: $productfourn->date_creation), 'dayhour').''.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation : $productfourn->date_creation), 'dayhour').''.$productfourn->getSocNomUrl(1, 'supplier').''.$availability.''; - print $productfourn->fourn_price?price($productfourn->fourn_price):""; + print $productfourn->fourn_price ?price($productfourn->fourn_price) : ""; print ''; - $productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type:0; + $productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type : 0; $productfourn->fetch_barcode(); - print $productfourn->barcode_type_label?$productfourn->barcode_type_label:($productfourn->barcode?'
'.$langs->trans("SetDefaultBarcodeType").'
':''); + print $productfourn->barcode_type_label ? $productfourn->barcode_type_label : ($productfourn->barcode ? '
'.$langs->trans("SetDefaultBarcodeType").'
' : ''); print '
' . $extrafields->showOutputField($key, $resql->{$key}) . "'.$extrafields->showOutputField($key, $resql->{$key})."
'; //print '
'; -$param=''; +$param = ''; print '
'; print getTitleFieldOfList($langs->trans('ProductRef'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); @@ -359,10 +359,10 @@ print ''; print ''; // Product print '
'; -$filtertype=0; -if (! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype=''; +$filtertype = 0; +if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype = ''; if ($conf->global->PRODUIT_LIMIT_SIZE <= 0) { - $limit=''; + $limit = ''; } else { @@ -394,7 +394,7 @@ print ''; -foreach($listofdata as $key => $val) +foreach ($listofdata as $key => $val) { $productstatic->fetch($val['id_product']); $warehousestatics->fetch($val['id_sw']); @@ -432,12 +432,12 @@ print '
'; print ''; -print ''; +print ''; print ''; // Button to record mass movement -$codemove=(isset($_POST["codemove"])?GETPOST("codemove", 'alpha'):dol_print_date(dol_now(), '%Y%m%d%H%M%S')); -$labelmovement=GETPOST("label")?GETPOST('label'):$langs->trans("StockTransfer").' '.dol_print_date($now, '%Y-%m-%d %H:%M'); +$codemove = (isset($_POST["codemove"]) ?GETPOST("codemove", 'alpha') : dol_print_date(dol_now(), '%Y%m%d%H%M%S')); +$labelmovement = GETPOST("label") ?GETPOST('label') : $langs->trans("StockTransfer").' '.dol_print_date($now, '%Y-%m-%d %H:%M'); print ''; print ''; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 2932ba43d5b..d1c81ff7251 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -38,46 +38,46 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productstockentrepot.class.php'; -if (! empty($conf->productbatch->enabled)) { +if (!empty($conf->productbatch->enabled)) { require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; } -if (! empty($conf->projet->enabled)) { +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } -if (! empty($conf->variants->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductAttribute.class.php'; - require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductAttributeValue.class.php'; - require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductCombination.class.php'; - require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductCombination2ValuePair.class.php'; +if (!empty($conf->variants->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php'; + require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php'; + require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; + require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php'; } // Load translation files required by the page $langs->loadlangs(array('products', 'orders', 'bills', 'stocks', 'sendings')); -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); -$backtopage=GETPOST('backtopage', 'alpha'); -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); -$id=GETPOST('id', 'int'); -$ref=GETPOST('ref', 'alpha'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $stocklimit = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); $cancel = GETPOST('cancel', 'alpha'); -$fieldid = isset($_GET["ref"])?'ref':'rowid'; -$d_eatby=dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); -$d_sellby=dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); -$pdluoid=GETPOST('pdluoid', 'int'); -$batchnumber=GETPOST('batch_number', 'san_alpha'); +$fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid'; +$d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); +$d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); +$pdluoid = GETPOST('pdluoid', 'int'); +$batchnumber = GETPOST('batch_number', 'san_alpha'); if (!empty($batchnumber)) { - $batchnumber=trim($batchnumber); + $batchnumber = trim($batchnumber); } // Security check -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'produit&stock', $id, 'product&product', '', '', $fieldid); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit&stock', $id, 'product&product', '', '', $fieldid); $object = new Product($db); @@ -86,19 +86,19 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); } -if(empty($id) && !empty($object->id)) $id = $object->id; +if (empty($id) && !empty($object->id)) $id = $object->id; -$modulepart='product'; +$modulepart = 'product'; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -$canvas = !empty($object->canvas)?$object->canvas:GETPOST("canvas"); -$objcanvas=null; -if (! empty($canvas)) +$canvas = !empty($object->canvas) ? $object->canvas : GETPOST("canvas"); +$objcanvas = null; +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); @@ -106,17 +106,17 @@ if (! empty($canvas)) } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('stockproductcard','globalcard')); +$hookmanager->initHooks(array('stockproductcard', 'globalcard')); /* * Actions */ -if ($cancel) $action=''; +if ($cancel) $action = ''; -$parameters=array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); +$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 ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer)) @@ -125,29 +125,29 @@ if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer) $desiredstock = GETPOST('desiredstock'); $maj_ok = true; - if($seuil_stock_alerte == '') { + if ($seuil_stock_alerte == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("StockLimit")), null, 'errors'); $maj_ok = false; } - if($desiredstock == '') { + if ($desiredstock == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DesiredStock")), null, 'errors'); $maj_ok = false; } - if($maj_ok) { + if ($maj_ok) { $pse = new ProductStockEntrepot($db); if ($pse->fetch(0, $id, GETPOST('fk_entrepot', 'int')) > 0) { // Update $pse->seuil_stock_alerte = $seuil_stock_alerte; - $pse->desiredstock = $desiredstock; - if($pse->update($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseUpdated'), null, 'mesgs'); + $pse->desiredstock = $desiredstock; + if ($pse->update($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseUpdated'), null, 'mesgs'); } else { // Create - $pse->fk_entrepot = GETPOST('fk_entrepot'); + $pse->fk_entrepot = GETPOST('fk_entrepot'); $pse->fk_product = $id; $pse->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $pse->desiredstock = GETPOST('desiredstock'); - if($pse->create($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseCreated'), null, 'mesgs'); + if ($pse->create($user) > 0) setEventMessages($langs->trans('ProductStockWarehouseCreated'), null, 'mesgs'); } } @@ -155,7 +155,7 @@ if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer) exit; } -if($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->creer)) +if ($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->creer)) { $pse = new ProductStockEntrepot($db); @@ -169,61 +169,61 @@ if($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->c if ($action == 'setseuil_stock_alerte' && !empty($user->rights->produit->creer)) { $object = new Product($db); - $result=$object->fetch($id); - $object->seuil_stock_alerte=$stocklimit; - $result=$object->update($object->id, $user, 0, 'update'); + $result = $object->fetch($id); + $object->seuil_stock_alerte = $stocklimit; + $result = $object->update($object->id, $user, 0, 'update'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); //else // setEventMessages($lans->trans("SavedRecordSuccessfully"), null, 'mesgs'); - $action=''; + $action = ''; } // Set desired stock if ($action == 'setdesiredstock' && !empty($user->rights->produit->creer)) { $object = new Product($db); - $result=$object->fetch($id); - $object->desiredstock=$desiredstock; - $result=$object->update($object->id, $user, 0, 'update'); + $result = $object->fetch($id); + $object->desiredstock = $desiredstock; + $result = $object->update($object->id, $user, 0, 'update'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } // Correct stock -if ($action == "correct_stock" && ! $cancel) +if ($action == "correct_stock" && !$cancel) { - if (! (GETPOST("id_entrepot") > 0)) + if (!(GETPOST("id_entrepot") > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; - $action='correction'; + $action = 'correction'; } - if (! GETPOST("nbpiece")) + if (!GETPOST("nbpiece")) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; - $action='correction'; + $action = 'correction'; } - if (! empty($conf->productbatch->enabled)) + if (!empty($conf->productbatch->enabled)) { $object = new Product($db); - $result=$object->fetch($id); + $result = $object->fetch($id); - if ($object->hasbatch() && ! $batchnumber) + if ($object->hasbatch() && !$batchnumber) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; - $action='correction'; + $action = 'correction'; } } - if (! $error) + if (!$error) { - $priceunit=price2num(GETPOST("unitprice")); + $priceunit = price2num(GETPOST("unitprice")); if (is_numeric(GETPOST("nbpiece")) && $id) { $origin_element = ''; @@ -237,16 +237,16 @@ if ($action == "correct_stock" && ! $cancel) if (empty($object)) { $object = new Product($db); - $result=$object->fetch($id); + $result = $object->fetch($id); } if ($object->hasbatch()) { - $result=$object->correct_stock_batch( + $result = $object->correct_stock_batch( $user, GETPOST("id_entrepot"), GETPOST("nbpiece"), GETPOST("mouvement"), - GETPOST("label"), // label movement + GETPOST("label"), // label movement $priceunit, $d_eatby, $d_sellby, @@ -254,11 +254,11 @@ if ($action == "correct_stock" && ! $cancel) GETPOST('inventorycode'), $origin_element, $origin_id - ); // We do not change value of stock for a correction + ); // We do not change value of stock for a correction } else { - $result=$object->correct_stock( + $result = $object->correct_stock( $user, GETPOST("id_entrepot"), GETPOST("nbpiece"), @@ -268,7 +268,7 @@ if ($action == "correct_stock" && ! $cancel) GETPOST('inventorycode'), $origin_element, $origin_id - ); // We do not change value of stock for a correction + ); // We do not change value of stock for a correction } if ($result > 0) @@ -287,61 +287,61 @@ if ($action == "correct_stock" && ! $cancel) else { setEventMessages($object->error, $object->errors, 'errors'); - $action='correction'; + $action = 'correction'; } } } } // Transfer stock from a warehouse to another warehouse -if ($action == "transfert_stock" && ! $cancel) +if ($action == "transfert_stock" && !$cancel) { - if (! (GETPOST("id_entrepot", 'int') > 0) || ! (GETPOST("id_entrepot_destination", 'int') > 0)) + if (!(GETPOST("id_entrepot", 'int') > 0) || !(GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } - if (! GETPOST("nbpiece", 'int')) + if (!GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } if (GETPOST("id_entrepot", 'int') == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } - if (! empty($conf->productbatch->enabled)) + if (!empty($conf->productbatch->enabled)) { $object = new Product($db); - $result=$object->fetch($id); + $result = $object->fetch($id); - if ($object->hasbatch() && ! $batchnumber) + if ($object->hasbatch() && !$batchnumber) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } } - if (! $error) + if (!$error) { if ($id) { $object = new Product($db); - $result=$object->fetch($id); + $result = $object->fetch($id); $db->begin(); - $object->load_stock('novirtual'); // Load array product->stock_warehouse + $object->load_stock('novirtual'); // Load array product->stock_warehouse // Define value of products moved - $pricesrc=0; - if (isset($object->pmp)) $pricesrc=$object->pmp; - $pricedest=$pricesrc; + $pricesrc = 0; + if (isset($object->pmp)) $pricesrc = $object->pmp; + $pricedest = $pricesrc; if ($object->hasbatch()) { @@ -349,13 +349,13 @@ if ($action == "transfert_stock" && ! $cancel) if ($pdluoid > 0) { - $result=$pdluo->fetch($pdluoid); + $result = $pdluo->fetch($pdluoid); if ($result) { - $srcwarehouseid=$pdluo->warehouseid; - $batch=$pdluo->batch; - $eatby=$pdluo->eatby; - $sellby=$pdluo->sellby; + $srcwarehouseid = $pdluo->warehouseid; + $batch = $pdluo->batch; + $eatby = $pdluo->eatby; + $sellby = $pdluo->sellby; } else { @@ -365,16 +365,16 @@ if ($action == "transfert_stock" && ! $cancel) } else { - $srcwarehouseid=GETPOST('id_entrepot', 'int'); - $batch=$batchnumber; - $eatby=$d_eatby; - $sellby=$d_sellby; + $srcwarehouseid = GETPOST('id_entrepot', 'int'); + $batch = $batchnumber; + $eatby = $d_eatby; + $sellby = $d_sellby; } - if (! $error) + if (!$error) { // Remove stock - $result1=$object->correct_stock_batch( + $result1 = $object->correct_stock_batch( $user, $srcwarehouseid, GETPOST("nbpiece", 'int'), @@ -386,10 +386,10 @@ if ($action == "transfert_stock" && ! $cancel) ); if ($result1 < 0) $error++; } - if (! $error) + if (!$error) { // Add stock - $result2=$object->correct_stock_batch( + $result2 = $object->correct_stock_batch( $user, GETPOST("id_entrepot_destination", 'int'), GETPOST("nbpiece", 'int'), @@ -404,10 +404,10 @@ if ($action == "transfert_stock" && ! $cancel) } else { - if (! $error) + if (!$error) { // Remove stock - $result1=$object->correct_stock( + $result1 = $object->correct_stock( $user, GETPOST("id_entrepot"), GETPOST("nbpiece"), @@ -418,10 +418,10 @@ if ($action == "transfert_stock" && ! $cancel) ); if ($result1 < 0) $error++; } - if (! $error) + if (!$error) { // Add stock - $result2=$object->correct_stock( + $result2 = $object->correct_stock( $user, GETPOST("id_entrepot_destination"), GETPOST("nbpiece"), @@ -435,7 +435,7 @@ if ($action == "transfert_stock" && ! $cancel) } - if (! $error && $result1 >= 0 && $result2 >= 0) + if (!$error && $result1 >= 0 && $result2 >= 0) { $db->commit(); @@ -454,7 +454,7 @@ if ($action == "transfert_stock" && ! $cancel) { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); - $action='transfert'; + $action = 'transfert'; } } } @@ -464,24 +464,24 @@ if ($action == "transfert_stock" && ! $cancel) if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) { $pdluo = new Productbatch($db); - $result=$pdluo->fetch(GETPOST('pdluoid', 'int')); + $result = $pdluo->fetch(GETPOST('pdluoid', 'int')); - if ($result>0) + if ($result > 0) { if ($pdluo->id) { - if ((! GETPOST("sellby")) && (! GETPOST("eatby")) && (! $batchnumber)) { + if ((!GETPOST("sellby")) && (!GETPOST("eatby")) && (!$batchnumber)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); } else { - $d_eatby=dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); - $d_sellby=dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); - $pdluo->batch=$batchnumber; - $pdluo->eatby=$d_eatby; - $pdluo->sellby=$d_sellby; - $result=$pdluo->update($user); - if ($result<0) + $d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); + $d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); + $pdluo->batch = $batchnumber; + $pdluo->eatby = $d_eatby; + $pdluo->sellby = $d_sellby; + $result = $pdluo->update($user); + if ($result < 0) { setEventMessages($pdluo->error, $pdluo->errors, 'errors'); } @@ -507,8 +507,8 @@ if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) */ $form = new Form($db); -$formproduct=new FormProduct($db); -if (! empty($conf->projet->enabled)) $formproject=new FormProjets($db); +$formproduct = new FormProduct($db); +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); if ($id > 0 || $ref) { @@ -524,22 +524,22 @@ if ($id > 0 || $ref) $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Stock'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Stock'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Stock'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Stock'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); if ($result > 0) { - $head=product_prepare_head($object); - $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type==Product::TYPE_SERVICE?'service':'product'); + $head = product_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'stock', $titre, -1, $picto); @@ -548,7 +548,7 @@ if ($id > 0 || $ref) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -557,22 +557,22 @@ if ($id > 0 || $ref) print '
'; print '
'; - if (! $variants) { + if (!$variants) { if ($conf->productbatch->enabled) { - print ''; } // PMP - print ''; + print ''; print ''; print ''; // Minimum Price - print ''; + print ''; print ''; // Price minimum - print ''; } else { // Price - print ''; // Price minimum - print ''; } // Stock alert threshold - print ''; // Hook formObject $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Desired stock - print ''; // Real stock - $text_stock_options = $langs->trans("RealStockDesc") . '
'; - $text_stock_options .= $langs->trans("RealStockWillAutomaticallyWhen") . '
'; - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? $langs->trans("DeStockOnShipment") . '
' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? $langs->trans("DeStockOnValidateOrder") . '
' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ? $langs->trans("DeStockOnBill") . '
' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill") . '
' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder") . '
' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder") . '
' : ''); - $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)?$langs->trans("StockOnReception").'
':''); + $text_stock_options = $langs->trans("RealStockDesc").'
'; + $text_stock_options .= $langs->trans("RealStockWillAutomaticallyWhen").'
'; + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? $langs->trans("DeStockOnShipment").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? $langs->trans("DeStockOnValidateOrder").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ? $langs->trans("DeStockOnBill").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? $langs->trans("StockOnReception").'
' : ''); print ''; - print ''; print ''; $stocktheo = price2num($object->stock_theorique, 'MS'); $found = 0; - $helpondiff = '' . $langs->trans("StockDiffPhysicTeoric") . ':
'; + $helpondiff = ''.$langs->trans("StockDiffPhysicTeoric").':
'; // Number of customer orders running if (!empty($conf->commande->enabled)) { if ($found) $helpondiff .= '
'; else $found = 1; - $helpondiff .= $langs->trans("ProductQtyInCustomersOrdersRunning") . ': ' . $object->stats_commande['qty']; + $helpondiff .= $langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty']; $result = $object->load_stats_commande(0, '0', 1); if ($result < 0) dol_print_error($db, $object->error); - $helpondiff .= ' (' . $langs->trans("ProductQtyInDraft") . ': ' . $object->stats_commande['qty'] . ')'; + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; } // Number of product from customer order already sent (partial shipping) if (!empty($conf->expedition->enabled)) { if ($found) $helpondiff .= '
'; else $found = 1; $result = $object->load_stats_sending(0, '2', 1); - $helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent") . ': ' . $object->stats_expedition['qty']; + $helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; } // Number of supplier order running if (!empty($conf->fournisseur->enabled)) { if ($found) $helpondiff .= '
'; else $found = 1; $result = $object->load_stats_commande_fournisseur(0, '3,4', 1); - $helpondiff .= $langs->trans("ProductQtyInSuppliersOrdersRunning") . ': ' . $object->stats_commande_fournisseur['qty']; + $helpondiff .= $langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty']; $result = $object->load_stats_commande_fournisseur(0, '0,1,2', 1); if ($result < 0) dol_print_error($db, $object->error); - $helpondiff .= ' (' . $langs->trans("ProductQtyInDraftOrWaitingApproved") . ': ' . $object->stats_commande_fournisseur['qty'] . ')'; + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; } // Number of product from supplier order already received (partial receipt) if (!empty($conf->fournisseur->enabled)) { if ($found) $helpondiff .= '
'; else $found = 1; - $helpondiff .= $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied") . ': ' . $object->stats_reception['qty']; + $helpondiff .= $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty']; } // Calculating a theorical value @@ -689,7 +689,7 @@ if ($id > 0 || $ref) print "'; print ''; @@ -697,8 +697,8 @@ if ($id > 0 || $ref) if (!empty($user->rights->stock->mouvement->lire)) { $sql = "SELECT max(m.datem) as datem"; - $sql .= " FROM " . MAIN_DB_PREFIX . "stock_mouvement as m"; - $sql .= " WHERE m.fk_product = '" . $object->id . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; + $sql .= " WHERE m.fk_product = '".$object->id."'"; $resqlbis = $db->query($sql); if ($resqlbis) { $obj = $db->fetch_object($resqlbis); @@ -706,12 +706,12 @@ if ($id > 0 || $ref) } else { dol_print_error($db); } - print '"; } @@ -750,9 +750,9 @@ else /* */ /* ************************************************************************** */ -$parameters=array(); +$parameters = array(); -$reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if (empty($action) && $object->id) @@ -761,33 +761,33 @@ if (empty($reshook)) if ($user->rights->stock->mouvement->creer) { - if (! $variants || ! empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { - print '' . $langs->trans("CorrectStock") . ''; + if (!$variants || !empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { + print ''.$langs->trans("CorrectStock").''; } else { - print '' . $langs->trans("CorrectStock") . ''; + print ''.$langs->trans("CorrectStock").''; } } else { - print '' . $langs->trans("CorrectStock") . ''; + print ''.$langs->trans("CorrectStock").''; } //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) if ($user->rights->stock->mouvement->creer) { - if (! $variants || ! empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { - print '' . $langs->trans("TransferStock") . ''; + if (!$variants || !empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { + print ''.$langs->trans("TransferStock").''; } else { - print '' . $langs->trans("TransferStock") . ''; + print ''.$langs->trans("TransferStock").''; } } else { - print '' . $langs->trans("CorrectStock") . ''; + print ''.$langs->trans("CorrectStock").''; } print ''; @@ -795,7 +795,7 @@ if (empty($reshook)) } -if (! $variants) { +if (!$variants) { /* * Stock detail (by warehouse). May go down into batch details. */ @@ -804,18 +804,18 @@ if (! $variants) { print '
' . $langs->trans("ManageLotSerial") . ''; + print '
'.$langs->trans("ManageLotSerial").''; print $object->getLibStatut(0, 2); print '
' . $langs->trans("AverageUnitPricePMP") . '
'.$langs->trans("AverageUnitPricePMP").''; - if ($object->pmp > 0) print price($object->pmp) . ' ' . $langs->trans("HT"); + if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT"); print '
' . $langs->trans("BuyingPriceMin") . '
'.$langs->trans("BuyingPriceMin").''; $product_fourn = new ProductFournisseur($db); if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) { @@ -583,103 +583,103 @@ if ($id > 0 || $ref) if (empty($conf->global->PRODUIT_MULTIPRICES)) { // Price - print '
' . $langs->trans("SellingPrice") . ''; + print '
'.$langs->trans("SellingPrice").''; if ($object->price_base_type == 'TTC') { - print price($object->price_ttc) . ' ' . $langs->trans($object->price_base_type); + print price($object->price_ttc).' '.$langs->trans($object->price_base_type); } else { - print price($object->price) . ' ' . $langs->trans($object->price_base_type); + print price($object->price).' '.$langs->trans($object->price_base_type); } print '
' . $langs->trans("MinPrice") . ''; + print '
'.$langs->trans("MinPrice").''; if ($object->price_base_type == 'TTC') { - print price($object->price_min_ttc) . ' ' . $langs->trans($object->price_base_type); + print price($object->price_min_ttc).' '.$langs->trans($object->price_base_type); } else { - print price($object->price_min) . ' ' . $langs->trans($object->price_base_type); + print price($object->price_min).' '.$langs->trans($object->price_base_type); } print '
' . $langs->trans("SellingPrice") . ''; + print '
'.$langs->trans("SellingPrice").''; print $langs->trans("Variable"); print '
' . $langs->trans("MinPrice") . ''; + print '
'.$langs->trans("MinPrice").''; print $langs->trans("Variable"); print '
' . $form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer) . ''; + print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer).''; print $form->editfieldval("StockLimit", 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer, 'string'); print '
' . $form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer); + print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer); print ''; print $form->editfieldval("DesiredStock", 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer, 'string'); print '
'; print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1); print '' . price2num($object->stock_reel, 'MS'); - if ($object->seuil_stock_alerte != '' && ($object->stock_reel < $object->seuil_stock_alerte)) print ' ' . img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); + print ''.price2num($object->stock_reel, 'MS'); + if ($object->seuil_stock_alerte != '' && ($object->stock_reel < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); print '
"; //print (empty($stocktheo)?0:$stocktheo); print $form->textwithpicto((empty($stocktheo) ? 0 : $stocktheo), $helpondiff); - if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) print ' ' . img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); + if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte)); print '
' . $langs->trans("LastMovement") . ''; + print '
'.$langs->trans("LastMovement").''; if ($lastmovementdate) { - print dol_print_date($lastmovementdate, 'dayhour') . ' '; - print '(' . $langs->trans("FullList") . ')'; + print dol_print_date($lastmovementdate, 'dayhour').' '; + print '('.$langs->trans("FullList").')'; } else { - print '' . $langs->trans("None") . ''; + print ''.$langs->trans("None").''; } print "
'; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) { print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -825,13 +825,13 @@ if (! $variants) { } $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; - $sql .= " FROM " . MAIN_DB_PREFIX . "entrepot as e,"; - $sql .= " " . MAIN_DB_PREFIX . "product_stock as ps"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = ps.fk_product"; + $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; + $sql .= " ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; $sql .= " WHERE ps.reel != 0"; $sql .= " AND ps.fk_entrepot = e.rowid"; - $sql .= " AND e.entity IN (" . getEntity('stock') . ")"; - $sql .= " AND ps.fk_product = " . $object->id; + $sql .= " AND e.entity IN (".getEntity('stock').")"; + $sql .= " AND ps.fk_product = ".$object->id; $sql .= " ORDER BY e.ref"; $entrepotstatic = new Entrepot($db); @@ -859,12 +859,12 @@ if (! $variants) { $stock_real = price2num($obj->reel, 'MS'); print ''; - print ''; - print ''; + print ''; + print ''; // PMP - print ''; + print ''; // Value purchase - print ''; + print ''; // Sell price print ''; // Value sell print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price * $obj->reel, 'MT'), 1).''; else print $langs->trans("Variable"); print ''; $total += $obj->reel; @@ -890,27 +890,27 @@ if (! $variants) { $product_lot_static->sellby = $pdluo->sellby; if ($action == 'editline' && GETPOST('lineid', 'int') == $pdluo->id) { //Current line edit - print "\n" . ''; + print "\n".''; print ''; } else { - print "\n" . ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; } @@ -931,10 +931,10 @@ if (! $variants) { } else dol_print_error($db); // Total line - print ''; - print ''; + print ''; + print ''; print ''; // Value purchase print ''; print '
' . $langs->trans("Warehouse") . '' . $langs->trans("NumberOfUnit") . '' . $langs->trans("AverageUnitPricePMPShort") . '' . $langs->trans("EstimatedStockValueShort") . '' . $langs->trans("SellPriceMin") . '' . $langs->trans("EstimatedStockValueSellShort") . ''.$langs->trans("Warehouse").''.$langs->trans("NumberOfUnit").''.$langs->trans("AverageUnitPricePMPShort").''.$langs->trans("EstimatedStockValueShort").''.$langs->trans("SellPriceMin").''.$langs->trans("EstimatedStockValueSellShort").'
' . $langs->trans("batch_number") . '' . $langs->trans("EatByDate") . '' . $langs->trans("SellByDate") . ''.$langs->trans("batch_number").''.$langs->trans("EatByDate").''.$langs->trans("SellByDate").'
' . $entrepotstatic->getNomUrl(1) . '' . $stock_real . ($stock_real < 0 ? ' ' . img_warning() : '') . ''.$entrepotstatic->getNomUrl(1).''.$stock_real.($stock_real < 0 ? ' '.img_warning() : '').'' . (price2num($object->pmp) ? price2num($object->pmp, 'MU') : '') . ''.(price2num($object->pmp) ? price2num($object->pmp, 'MU') : '').'' . (price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '') . ''.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').''; if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price, 'MU'), 1); @@ -872,7 +872,7 @@ if (! $variants) { print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price * $obj->reel, 'MT'), 1) . '
'; - print ''; - print ''; - print ''; + print ''; + print '
'; + print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print '
'; print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0); print ''; print $form->selectDate($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0); print '' . $pdluo->qty . ($pdluo->qty < 0 ? ' ' . img_warning() : '') . ''; - print '
'.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; + print '
'; print ''; print '
'; - print img_picto($langs->trans("Tranfer"), 'uparrow', 'class="hideonsmartphone"') . ' '; - print 'id . '">' . $langs->trans("TransferStock") . ''; + print "\n".'
'; + print img_picto($langs->trans("Tranfer"), 'uparrow', 'class="hideonsmartphone"').' '; + print 'id.'">'.$langs->trans("TransferStock").''; // Disabled, because edition of stock content must use the "Correct stock menu". // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... //print 'id.'#'.$pdluo->id.'">'; @@ -918,9 +918,9 @@ if (! $variants) { print ''; print $product_lot_static->getNomUrl(1); print '' . dol_print_date($pdluo->eatby, 'day') . '' . dol_print_date($pdluo->sellby, 'day') . '' . $pdluo->qty . ($pdluo->qty < 0 ? ' ' . img_warning() : '') . ''.dol_print_date($pdluo->eatby, 'day').''.dol_print_date($pdluo->sellby, 'day').''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').'
' . $langs->trans("Total") . ':' . price2num($total, 'MS') . '
'.$langs->trans("Total").':'.price2num($total, 'MS').''; - print ($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors + print ($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors print ''; @@ -959,21 +959,21 @@ if (! $variants) { print load_fiche_titre($langs->trans('AddNewProductStockWarehouse')); if (!empty($user->rights->produit->creer)) { - print '
'; + print ''; print ''; - print ''; + print ''; } print ''; if (!empty($user->rights->produit->creer)) { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; } else { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; } @@ -985,11 +985,11 @@ if (! $variants) { foreach ($lines as $line) { $ent = new Entrepot($db); $ent->fetch($line['fk_entrepot']); - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (!empty($user->rights->produit->creer)) { - print ''; + print ''; } print ''; } @@ -1035,12 +1035,12 @@ if (! $variants) { if (count($productCombinations)) { - $stock_total= 0; + $stock_total = 0; foreach ($productCombinations as $currcomb) { $prodstatic->fetch($currcomb->fk_product_child); $prodstatic->load_stock(); - $stock_total+=$prodstatic->stock_reel; + $stock_total += $prodstatic->stock_reel; ?> diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index dbab10c0bf4..1d8b709f662 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -41,7 +41,7 @@ $langs->loadLangs(array('products', 'stocks', 'orders')); if ($user->socid) { $socid = $user->socid; } -$result=restrictedArea($user, 'produit|service'); +$result = restrictedArea($user, 'produit|service'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('stockreplenishlist')); @@ -51,7 +51,7 @@ $hookmanager->initHooks(array('stockreplenishlist')); $action = GETPOST('action', 'alpha'); $sref = GETPOST('sref', 'alpha'); $snom = GETPOST('snom', 'alpha'); -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $type = GETPOST('type', 'int'); $tobuy = GETPOST('tobuy', 'int'); $salert = GETPOST('salert', 'alpha'); @@ -68,8 +68,8 @@ $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$offset = $limit * $page ; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$offset = $limit * $page; if (!$sortfield) { $sortfield = 'p.ref'; @@ -80,20 +80,20 @@ if (!$sortorder) { } // Define virtualdiffersfromphysical -$virtualdiffersfromphysical=0; -if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) -|| ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) -|| ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) +$virtualdiffersfromphysical = 0; +if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) +|| !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) +|| !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { - $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } -$usevirtualstock=0; -if ($mode == 'virtual') $usevirtualstock=1; +$usevirtualstock = 0; +if ($mode == 'virtual') $usevirtualstock = 1; -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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'); /* @@ -106,9 +106,9 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $snom = ''; $sal = ''; $salert = ''; - $draftorder=''; + $draftorder = ''; } -if($draftorder == 'on') $draftchecked = "checked"; +if ($draftorder == 'on') $draftchecked = "checked"; // Create orders if ($action == 'order' && isset($_POST['valid'])) @@ -122,19 +122,19 @@ if ($action == 'order' && isset($_POST['valid'])) $db->begin(); $suppliers = array(); - require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productsupplier = new ProductFournisseur($db); for ($i = 0; $i < $linecount; $i++) { - if (GETPOST('choose' . $i, 'alpha') === 'on' && GETPOST('fourn' . $i, 'int') > 0) + if (GETPOST('choose'.$i, 'alpha') === 'on' && GETPOST('fourn'.$i, 'int') > 0) { //one line $box = $i; $supplierpriceid = GETPOST('fourn'.$i, 'int'); //get all the parameters needed to create a line $qty = GETPOST('tobuy'.$i, 'int'); - $idprod=$productsupplier->get_buyprice($supplierpriceid, $qty); - $res=$productsupplier->fetch($idprod); + $idprod = $productsupplier->get_buyprice($supplierpriceid, $qty); + $res = $productsupplier->fetch($idprod); if ($res && $idprod > 0) { if ($qty) @@ -146,12 +146,12 @@ if ($action == 'order' && isset($_POST['valid'])) //$product = new Product($db); //$product->fetch($obj->fk_product); - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { $productsupplier->getMultiLangs(); } $line->desc = $productsupplier->description; - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { // TODO Get desc in language of thirdparty } @@ -175,11 +175,11 @@ if ($action == 'order' && isset($_POST['valid'])) } else { - $error=$db->lasterror(); + $error = $db->lasterror(); dol_print_error($db); } - unset($_POST['fourn' . $i]); + unset($_POST['fourn'.$i]); } unset($_POST[$i]); } @@ -193,12 +193,12 @@ if ($action == 'order' && isset($_POST['valid'])) $order = new CommandeFournisseur($db); // Check if an order for the supplier exists $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " WHERE fk_soc = ".$suppliersid[$i]; - $sql.= " AND source = 42 AND fk_statut = 0"; - $sql.= " AND entity IN (".getEntity('commande_fournisseur').")"; - $sql.= " ORDER BY date_creation DESC"; + $sql .= " WHERE fk_soc = ".$suppliersid[$i]; + $sql .= " AND source = 42 AND fk_statut = 0"; + $sql .= " AND entity IN (".getEntity('commande_fournisseur').")"; + $sql .= " ORDER BY date_creation DESC"; $resql = $db->query($sql); - if($resql && $db->num_rows($resql) > 0) { + if ($resql && $db->num_rows($resql) > 0) { $obj = $db->fetch_object($resql); $order->fetch($obj->rowid); foreach ($supplier['lines'] as $line) { @@ -226,7 +226,7 @@ if ($action == 'order' && isset($_POST['valid'])) } if ($result < 0) { $fail++; - $msg = $langs->trans('OrderFail') . " : "; + $msg = $langs->trans('OrderFail')." : "; $msg .= $order->error; setEventMessages($msg, null, 'errors'); } else { @@ -245,7 +245,7 @@ if ($action == 'order' && isset($_POST['valid'])) $id = $order->create($user); if ($id < 0) { $fail++; - $msg = $langs->trans('OrderFail') . " : "; + $msg = $langs->trans('OrderFail')." : "; $msg .= $order->error; setEventMessages($msg, null, 'errors'); } @@ -253,9 +253,9 @@ if ($action == 'order' && isset($_POST['valid'])) } } - if($errorQty) setEventMessages($langs->trans('ErrorOrdersNotCreatedQtyTooLow'), null, 'warnings'); + if ($errorQty) setEventMessages($langs->trans('ErrorOrdersNotCreatedQtyTooLow'), null, 'warnings'); - if (! $fail && $id) + if (!$fail && $id) { $db->commit(); @@ -286,45 +286,45 @@ $prod = new Product($db); $title = $langs->trans('Status'); if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sqldesiredtock=$db->ifsql("pse.desiredstock IS NULL", "p.desiredstock", "pse.desiredstock"); - $sqlalertstock=$db->ifsql("pse.seuil_stock_alerte IS NULL", "p.seuil_stock_alerte", "pse.seuil_stock_alerte"); + $sqldesiredtock = $db->ifsql("pse.desiredstock IS NULL", "p.desiredstock", "pse.desiredstock"); + $sqlalertstock = $db->ifsql("pse.seuil_stock_alerte IS NULL", "p.seuil_stock_alerte", "pse.seuil_stock_alerte"); } else { - $sqldesiredtock='p.desiredstock'; - $sqlalertstock='p.seuil_stock_alerte'; + $sqldesiredtock = 'p.desiredstock'; + $sqlalertstock = 'p.seuil_stock_alerte'; } $sql = 'SELECT p.rowid, p.ref, p.label, p.description, p.price,'; -$sql.= ' p.price_ttc, p.price_base_type,p.fk_product_type,'; -$sql.= ' p.tms as datem, p.duration, p.tobuy,'; -$sql.= ' p.desiredstock, p.seuil_stock_alerte,'; +$sql .= ' p.price_ttc, p.price_base_type,p.fk_product_type,'; +$sql .= ' p.tms as datem, p.duration, p.tobuy,'; +$sql .= ' p.desiredstock, p.seuil_stock_alerte,'; if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sql.= ' pse.desiredstock as desiredstockpse, pse.seuil_stock_alerte as seuil_stock_alertepse,'; + $sql .= ' pse.desiredstock as desiredstockpse, pse.seuil_stock_alerte as seuil_stock_alertepse,'; } -$sql.= ' '.$sqldesiredtock.' as desiredstockcombined, '.$sqlalertstock.' as seuil_stock_alertecombined,'; -$sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'; +$sql .= ' '.$sqldesiredtock.' as desiredstockcombined, '.$sqlalertstock.' as seuil_stock_alertecombined,'; +$sql .= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'; // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$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 . 'product as p'; -$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s'; -$sql.= ' ON (p.rowid = s.fk_product AND s.fk_entrepot IN (SELECT ent.rowid FROM '.MAIN_DB_PREFIX.'entrepot AS ent WHERE ent.entity IN('.getEntity('stock').')))'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s'; +$sql .= ' ON (p.rowid = s.fk_product AND s.fk_entrepot IN (SELECT ent.rowid FROM '.MAIN_DB_PREFIX.'entrepot AS ent WHERE ent.entity IN('.getEntity('stock').')))'; if ($fk_supplier > 0) { - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid AND pfp.fk_soc = '.$fk_supplier.')'; + $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid AND pfp.fk_soc = '.$fk_supplier.')'; } if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.$fk_entrepot.')'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties AS pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.$fk_entrepot.')'; } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= ' WHERE p.entity IN (' . getEntity('product') . ')'; +$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($type)) { @@ -334,83 +334,83 @@ if (dol_strlen($type)) { $sql .= ' AND p.fk_product_type <> 1'; } } -if ($sref) $sql.=natural_search('p.ref', $sref); -if ($snom) $sql.=natural_search('p.label', $snom); -$sql.= ' AND p.tobuy = 1'; -if (!empty($canvas)) $sql .= ' AND p.canvas = "' . $db->escape($canvas) . '"'; -$sql.= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price'; -$sql.= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms'; -$sql.= ', p.duration, p.tobuy'; -$sql.= ', p.desiredstock'; -$sql.= ', p.seuil_stock_alerte'; +if ($sref) $sql .= natural_search('p.ref', $sref); +if ($snom) $sql .= natural_search('p.label', $snom); +$sql .= ' AND p.tobuy = 1'; +if (!empty($canvas)) $sql .= ' AND p.canvas = "'.$db->escape($canvas).'"'; +$sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price'; +$sql .= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms'; +$sql .= ', p.duration, p.tobuy'; +$sql .= ', p.desiredstock'; +$sql .= ', p.seuil_stock_alerte'; if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $sql.= ', pse.desiredstock' ; - $sql.= ', pse.seuil_stock_alerte' ; + $sql .= ', pse.desiredstock'; + $sql .= ', pse.seuil_stock_alerte'; } -$sql.= ', s.fk_product'; +$sql .= ', s.fk_product'; if ($usevirtualstock) { $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty"; - $sqlCommandesCli.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; - $sqlCommandesCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; - $sqlCommandesCli.= " WHERE c.entity IN (".getEntity('commande').")"; - $sqlCommandesCli.= " AND cd.fk_product = p.rowid"; - $sqlCommandesCli.= " AND c.fk_statut IN (1,2))"; + $sqlCommandesCli .= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; + $sqlCommandesCli .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; + $sqlCommandesCli .= " WHERE c.entity IN (".getEntity('commande').")"; + $sqlCommandesCli .= " AND cd.fk_product = p.rowid"; + $sqlCommandesCli .= " AND c.fk_statut IN (1,2))"; $sqlExpeditionsCli = "(SELECT ".$db->ifsql("SUM(ed.qty) IS NULL", "0", "SUM(ed.qty)")." as qty"; - $sqlExpeditionsCli.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet as ed ON (ed.fk_expedition = e.rowid)"; - $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commandedet as cd ON (cd.rowid = ed.fk_origin_line)"; - $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; - $sqlExpeditionsCli.= " WHERE e.entity IN (".getEntity('expedition').")"; - $sqlExpeditionsCli.= " AND cd.fk_product = p.rowid"; - $sqlExpeditionsCli.= " AND c.fk_statut IN (1,2))"; + $sqlExpeditionsCli .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sqlExpeditionsCli .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet as ed ON (ed.fk_expedition = e.rowid)"; + $sqlExpeditionsCli .= " LEFT JOIN ".MAIN_DB_PREFIX."commandedet as cd ON (cd.rowid = ed.fk_origin_line)"; + $sqlExpeditionsCli .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; + $sqlExpeditionsCli .= " WHERE e.entity IN (".getEntity('expedition').")"; + $sqlExpeditionsCli .= " AND cd.fk_product = p.rowid"; + $sqlExpeditionsCli .= " AND c.fk_statut IN (1,2))"; $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty"; - $sqlCommandesFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; - $sqlCommandesFourn.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - $sqlCommandesFourn.= " WHERE c.rowid = cd.fk_commande"; - $sqlCommandesFourn.= " AND c.entity IN (".getEntity('supplier_order').")"; - $sqlCommandesFourn.= " AND cd.fk_product = p.rowid"; - $sqlCommandesFourn.= " AND c.fk_statut IN (3,4))"; + $sqlCommandesFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; + $sqlCommandesFourn .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + $sqlCommandesFourn .= " WHERE c.rowid = cd.fk_commande"; + $sqlCommandesFourn .= " AND c.entity IN (".getEntity('supplier_order').")"; + $sqlCommandesFourn .= " AND cd.fk_product = p.rowid"; + $sqlCommandesFourn .= " AND c.fk_statut IN (3,4))"; $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd.qty) IS NULL", "0", "SUM(fd.qty)")." as qty"; - $sqlReceptionFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sqlReceptionFourn.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd ON (fd.fk_commande = cf.rowid)"; - $sqlReceptionFourn.= " WHERE cf.entity IN (".getEntity('supplier_order').")"; - $sqlReceptionFourn.= " AND fd.fk_product = p.rowid"; - $sqlReceptionFourn.= " AND cf.fk_statut IN (3,4))"; + $sqlReceptionFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sqlReceptionFourn .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd ON (fd.fk_commande = cf.rowid)"; + $sqlReceptionFourn .= " WHERE cf.entity IN (".getEntity('supplier_order').")"; + $sqlReceptionFourn .= " AND fd.fk_product = p.rowid"; + $sqlReceptionFourn .= " AND cf.fk_statut IN (3,4))"; - $sql.= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; - $sql.= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.'))))'; + $sql .= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; + $sql .= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.'))))'; if ($salert == 'on') // Option to see when stock is lower than alert { - $sql.= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; + $sql .= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; $alertchecked = 'checked'; } } else { - $sql.= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; - $sql.= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; + $sql .= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + $sql .= ' OR ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; if ($salert == 'on') // Option to see when stock is lower than alert { - $sql.= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + $sql .= ' AND ('.$sqlalertstock.' >= 0 AND ('.$sqlalertstock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; $alertchecked = 'checked'; } } // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->order($sortfield, $sortorder); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); @@ -473,8 +473,8 @@ print '
'; print $langs->trans('Supplier').' '.$form->select_company($fk_supplier, 'fk_supplier', 'fournisseur=1', 1); print '
'; -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) print $hookmanager->resPrint; print '
'; @@ -484,13 +484,13 @@ print '
'; print ''; if ($sref || $snom || $sall || $salert || $draftorder || GETPOST('search', 'alpha')) { - $filters = '&sref=' . $sref . '&snom=' . $snom; - $filters .= '&sall=' . $sall; - $filters .= '&salert=' . $salert; - $filters .= '&draftorder=' . $draftorder; - $filters .= '&mode=' . $mode; - $filters .= '&fk_supplier=' . $fk_supplier; - $filters .= '&fk_entrepot=' . $fk_entrepot; + $filters = '&sref='.$sref.'&snom='.$snom; + $filters .= '&sall='.$sall; + $filters .= '&salert='.$salert; + $filters .= '&draftorder='.$draftorder; + $filters .= '&mode='.$mode; + $filters .= '&fk_supplier='.$fk_supplier; + $filters .= '&fk_entrepot='.$fk_entrepot; print_barre_liste( $texte, $page, @@ -502,14 +502,14 @@ if ($sref || $snom || $sall || $salert || $draftorder || GETPOST('search', 'alph $num ); } else { - $filters = '&sref=' . $sref . '&snom=' . $snom; - $filters .= '&fourn_id=' . $fourn_id; - $filters .= (isset($type)?'&type=' . $type:''); - $filters .= '&=' . $salert; - $filters .= '&draftorder=' . $draftorder; - $filters .= '&mode=' . $mode; - $filters .= '&fk_supplier=' . $fk_supplier; - $filters .= '&fk_entrepot=' . $fk_entrepot; + $filters = '&sref='.$sref.'&snom='.$snom; + $filters .= '&fourn_id='.$fourn_id; + $filters .= (isset($type) ? '&type='.$type : ''); + $filters .= '&='.$salert; + $filters .= '&draftorder='.$draftorder; + $filters .= '&mode='.$mode; + $filters .= '&fk_supplier='.$fk_supplier; + $filters .= '&fk_entrepot='.$fk_entrepot; print_barre_liste( $texte, $page, @@ -522,33 +522,33 @@ if ($sref || $snom || $sall || $salert || $draftorder || GETPOST('search', 'alph ); } -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
' . $formproduct->selectWarehouses('', 'fk_entrepot') . '
'.$formproduct->selectWarehouses('', 'fk_entrepot').'
' . $langs->trans("Warehouse") . '' . $langs->trans("StockLimit") . '' . $langs->trans("DesiredStock") . '
'.$langs->trans("Warehouse").''.$langs->trans("StockLimit").''.$langs->trans("DesiredStock").'
' . $ent->getNomUrl(3) . '' . $line['seuil_stock_alerte'] . '' . $line['desiredstock'] . '
'.$ent->getNomUrl(3).''.$line['seuil_stock_alerte'].''.$line['desiredstock'].'' . img_delete() . ''.img_delete().'
getNomUrl(1) ?>
'; -$param = (isset($type)? '&type=' . $type : ''); -$param .= '&fourn_id=' . $fourn_id . '&snom='. $snom . '&salert=' . $salert . '&draftorder='.$draftorder; -$param .= '&sref=' . $sref; -$param .= '&mode=' . $mode; -$param .= '&fk_supplier=' . $fk_supplier; -$param .= '&fk_entrepot=' . $fk_entrepot; +$param = (isset($type) ? '&type='.$type : ''); +$param .= '&fourn_id='.$fourn_id.'&snom='.$snom.'&salert='.$salert.'&draftorder='.$draftorder; +$param .= '&sref='.$sref; +$param .= '&mode='.$mode; +$param .= '&fk_supplier='.$fk_supplier; +$param .= '&fk_entrepot='.$fk_entrepot; $stocklabel = $langs->trans('Stock'); if ($usevirtualstock == 1) $stocklabel = $langs->trans('VirtualStock'); if ($usevirtualstock == 0) $stocklabel = $langs->trans('PhysicalStock'); if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { - $stocklabel.=' ('.$langs->trans("AllWarehouses").')'; + $stocklabel .= ' ('.$langs->trans("AllWarehouses").')'; } print ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. ''. - ''; + ''; // Fields title search print ''; @@ -558,16 +558,16 @@ print ''; print ''; print ''; -print ''; -print ''; +print ''; +print ''; print ''; // Fields from hook -$parameters=array('param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''; print ''; @@ -586,8 +586,8 @@ print_liste_field_titre('StockToBuy', $_SERVER["PHP_SELF"], '', $param, '', '', print_liste_field_titre('SupplierRef', $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'right '); // Hook fields -$parameters=array('param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('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 "\n"; @@ -596,18 +596,18 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $objp = $db->fetch_object($resql); - if (! empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0) + if (!empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0) { $prod->fetch($objp->rowid); $prod->load_stock('warehouseopen, warehouseinternal'); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { $sql = 'SELECT label,description'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'product_lang'; - $sql .= ' WHERE fk_product = ' . $objp->rowid; - $sql .= ' AND lang = "' . $langs->getDefaultLang() . '"'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; + $sql .= ' WHERE fk_product = '.$objp->rowid; + $sql .= ' AND lang = "'.$langs->getDefaultLang().'"'; $sql .= ' LIMIT 1'; $resqlm = $db->query($sql); @@ -630,25 +630,25 @@ while ($i < ($limit ? min($num, $limit) : $num)) } // Force call prod->load_stats_xxx to choose status to count (otherwise it is loaded by load_stock function) - if(isset($draftchecked)){ - $result=$prod->load_stats_commande_fournisseur(0, '0,1,2,3,4'); - }else { - $result=$prod->load_stats_commande_fournisseur(0, '1,2,3,4'); + if (isset($draftchecked)) { + $result = $prod->load_stats_commande_fournisseur(0, '0,1,2,3,4'); + } else { + $result = $prod->load_stats_commande_fournisseur(0, '1,2,3,4'); } - $result=$prod->load_stats_reception(0, '4'); + $result = $prod->load_stats_reception(0, '4'); //print $prod->stats_commande_fournisseur['qty'].'
'."\n"; //print $prod->stats_reception['qty']; $ordered = $prod->stats_commande_fournisseur['qty'] - $prod->stats_reception['qty']; - $desiredstock=($objp->desiredstockpse ? $objp->desiredstockpse : $objp->desiredstock); - $alertstock=($objp->seuil_stock_alertepse ? $objp->seuil_stock_alertepse : $objp->seuil_stock_alerte); + $desiredstock = ($objp->desiredstockpse ? $objp->desiredstockpse : $objp->desiredstock); + $alertstock = ($objp->seuil_stock_alertepse ? $objp->seuil_stock_alertepse : $objp->seuil_stock_alerte); - $warning=''; + $warning = ''; if ($alertstock && ($stock < $alertstock)) { - $warning = img_warning($langs->trans('StockTooLow')) . ' '; + $warning = img_warning($langs->trans('StockTooLow')).' '; } //depending on conf, use either physical stock or @@ -679,18 +679,18 @@ while ($i < ($limit ? min($num, $limit) : $num)) print ''; - print ''; if (!empty($conf->service->enabled) && $type == 1) { if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { - $duration = $regs[1] . ' ' . $langs->trans('DurationYear'); + $duration = $regs[1].' '.$langs->trans('DurationYear'); } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { - $duration = $regs[1] . ' ' . $langs->trans('DurationMonth'); + $duration = $regs[1].' '.$langs->trans('DurationMonth'); } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) { - $duration = $regs[1] . ' ' . $langs->trans('DurationDay'); + $duration = $regs[1].' '.$langs->trans('DurationDay'); } else { $duration = $objp->duration; } @@ -698,27 +698,27 @@ while ($i < ($limit ? min($num, $limit) : $num)) } // Desired stock - print ''; + print ''; // Limit stock for alert - print ''; + print ''; // Current stock (all warehouses) - print ''; + print ''; // Already ordered - print ''; + print ''; // To order //print ''; print ''; // Supplier - print ''; + print ''; // Fields from hook - $parameters=array( 'objp'=>$objp); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('objp'=>$objp); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''; @@ -726,8 +726,8 @@ while ($i < ($limit ? min($num, $limit) : $num)) $i++; } -$parameters=array('sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
service->enabled) && $type == 1) print '   ' . $langs->trans('AlertOnly') . ' ' . $langs->trans('IncludeAlsoDraftOrders') . ' '.$langs->trans('AlertOnly').' '.$langs->trans('IncludeAlsoDraftOrders').'  '; -$searchpicto=$form->showFilterAndCheckAddButtons(0); +$searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
'.$prod->getNomUrl(1, '').''.$objp->label ; - print ''; // TODO Remove this and make a fetch to get description when creating order instead of a GETPOST + print ''.$objp->label; + print ''; // TODO Remove this and make a fetch to get description when creating order instead of a GETPOST print '' . $desiredstock . ''.$desiredstock.'' . $alertstock . ''.$alertstock.''. $warning . $stock. ''.$warning.$stock.''. $ordered . ' ' . $picto. ''.$ordered.' '.$picto.''. $form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier).''.$form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier).'
'; @@ -738,7 +738,7 @@ $db->free($resql); dol_fiche_end(); -$value=$langs->trans("CreateOrders"); +$value = $langs->trans("CreateOrders"); print '
'; diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 989339590b3..beadddc6397 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -36,45 +36,45 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $langs->loadLangs(array("sendings", "receptions", "deliveries", 'companies', 'bills')); -$socid=GETPOST('socid', 'int'); -$massaction=GETPOST('massaction', 'alpha'); +$socid = GETPOST('socid', 'int'); +$massaction = GETPOST('massaction', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Security check $receptionid = GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'reception', $receptionid, ''); -$diroutputmassaction=$conf->reception->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->reception->dir_output.'/temp/massgeneration/'.$user->id; $search_ref_rcp = GETPOST("search_ref_rcp"); $search_ref_liv = GETPOST('search_ref_liv'); $search_ref_supplier = GETPOST('search_ref_supplier'); $search_company = GETPOST("search_company"); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_billed=GETPOST("search_billed", 'int'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_billed = GETPOST("search_billed", 'int'); $sall = GETPOST('sall', 'alphanohtml'); $optioncss = GETPOST('optioncss', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if (! $sortfield) $sortfield="e.ref"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "e.ref"; +if (!$sortorder) $sortorder = "DESC"; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='receptionlist'; +$contextpage = 'receptionlist'; -$viewstatut=GETPOST('viewstatut'); +$viewstatut = GETPOST('viewstatut'); $object = new Reception($db); @@ -92,10 +92,10 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'e.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["e.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["e.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'e.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), @@ -113,10 +113,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -127,11 +127,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction') && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction') && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -139,18 +139,18 @@ 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_ref_supplier=''; - $search_ref_rcp=''; - $search_ref_liv=''; - $search_company=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_country=''; - $search_type_thirdparty=''; - $search_billed=''; - $viewstatut=''; - $search_array_options=array(); + $search_ref_supplier = ''; + $search_ref_rcp = ''; + $search_ref_liv = ''; + $search_company = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_country = ''; + $search_type_thirdparty = ''; + $search_billed = ''; + $viewstatut = ''; + $search_array_options = array(); } if (empty($reshook)) @@ -166,29 +166,29 @@ if (empty($reshook)) $nb_bills_created = 0; $db->begin(); - $errors =array(); - foreach($receptions as $id_reception) + $errors = array(); + foreach ($receptions as $id_reception) { $rcp = new Reception($db); // On ne facture que les réceptions validées - if ($rcp->fetch($id_reception) <= 0 || $rcp->statut != 1){ - $errors[]=$langs->trans('StatusMustBeValidate', $rcp->ref); + if ($rcp->fetch($id_reception) <= 0 || $rcp->statut != 1) { + $errors[] = $langs->trans('StatusMustBeValidate', $rcp->ref); $error++; continue; } $object = new FactureFournisseur($db); - if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])){ + if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])) { $object = $TFactThird[$rcp->socid]; // If option "one bill per third" is set, we use already created reception. - if(empty($object->rowid)&&$object->id != null)$object->rowid = $object->id; - if(!empty($object->rowid))$object->fetchObjectLinked(); + if (empty($object->rowid) && $object->id != null)$object->rowid = $object->id; + if (!empty($object->rowid))$object->fetchObjectLinked(); $rcp->fetchObjectLinked(); if (count($rcp->linkedObjectsIds['order_supplier']) > 0) { foreach ($rcp->linkedObjectsIds['order_supplier'] as $key => $value) { - if(empty($object->linkedObjectsIds['order_supplier']) || !in_array($value, $object->linkedObjectsIds['order_supplier']))//Dont try to link if already linked + if (empty($object->linkedObjectsIds['order_supplier']) || !in_array($value, $object->linkedObjectsIds['order_supplier']))//Dont try to link if already linked $object->add_object_linked('order_supplier', $value); // add supplier order linked object } } @@ -198,12 +198,12 @@ if (empty($reshook)) $object->type = FactureFournisseur::TYPE_STANDARD; $object->cond_reglement_id = $rcp->thirdparty->cond_reglement_supplier_id; $object->mode_reglement_id = $rcp->thirdparty->mode_reglement_supplier_id; - $object->fk_account = !empty($rcp->thirdparty->fk_account)?$rcp->thirdparty->fk_account:0; - $object->remise_percent = !empty($rcp->thirdparty->remise_percent)?$rcp->thirdparty->remise_percent:0; - $object->remise_absolue = !empty($rcp->thirdparty->remise_absolue)?$rcp->thirdparty->remise_absolue:0; + $object->fk_account = !empty($rcp->thirdparty->fk_account) ? $rcp->thirdparty->fk_account : 0; + $object->remise_percent = !empty($rcp->thirdparty->remise_percent) ? $rcp->thirdparty->remise_percent : 0; + $object->remise_absolue = !empty($rcp->thirdparty->remise_absolue) ? $rcp->thirdparty->remise_absolue : 0; $object->fk_project = $rcp->fk_project; - $object->ref_supplier = $rcp->ref_supplier; + $object->ref_supplier = $rcp->ref_supplier; $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); if (empty($datefacture)) @@ -226,28 +226,28 @@ if (empty($reshook)) $res = $object->create($user); //var_dump($object->error);exit; - if($res > 0){ + if ($res > 0) { $nb_bills_created++; $object->id = $res; - }else { - $errors[]=$rcp->ref.' : '.$langs->trans($object->error); + } else { + $errors[] = $rcp->ref.' : '.$langs->trans($object->error); $error++; } } if ($object->id > 0) { - if(!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])){ //cause function create already add object linked for facturefournisseur + if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])) { //cause function create already add object linked for facturefournisseur $res = $object->add_object_linked($object->origin, $id_reception); - if ($res==0) + if ($res == 0) { - $errors[]=$object->error; + $errors[] = $object->error; $error++; } } - if (! $error) + if (!$error) { $lines = $rcp->lines; if (empty($lines) && method_exists($rcp, 'fetch_lines')) @@ -256,27 +256,27 @@ if (empty($reshook)) $lines = $rcp->lines; } - $fk_parent_line=0; - $num=count($lines); + $fk_parent_line = 0; + $num = count($lines); - for ($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); - $discount->fk_soc=$object->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); + $discount->fk_soc = $object->socid; + $discount->amount_ht = abs($lines[$i]->total_ht); + $discount->amount_tva = abs($lines[$i]->total_tva); + $discount->amount_ttc = abs($lines[$i]->total_ttc); + $discount->tva_tx = $lines[$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); if ($discountid > 0) { - $result=$object->insert_discount($discountid); + $result = $object->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else @@ -289,17 +289,17 @@ if (empty($reshook)) else { // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_start = false; + if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + $date_end = false; + if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { @@ -333,11 +333,11 @@ if (empty($reshook)) if ($result > 0) { - $lineid=$result; + $lineid = $result; } else { - $lineid=0; + $lineid = 0; $error++; break; } @@ -353,7 +353,7 @@ if (empty($reshook)) //$rcp->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. - if(!empty($createbills_onebythird) && empty($TFactThird[$rcp->socid])) $TFactThird[$rcp->socid] = $object; + if (!empty($createbills_onebythird) && empty($TFactThird[$rcp->socid])) $TFactThird[$rcp->socid] = $object; else $TFact[$object->id] = $object; } @@ -361,10 +361,10 @@ if (empty($reshook)) $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - if (! $error && $validate_invoices) + if (!$error && $validate_invoices) { $massaction = $action = 'builddoc'; - foreach($TAllFact as &$object) + foreach ($TAllFact as &$object) { $result = $object->validate($user); if ($result <= 0) @@ -379,14 +379,14 @@ if (empty($reshook)) // Fac builddoc $donotredirect = 1; $upload_dir = $conf->fournisseur->facture->dir_output; - $permissiontoadd=$user->rights->fournisseur->facture->creer; + $permissiontoadd = $user->rights->fournisseur->facture->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } $massaction = $action = 'confirm_createbills'; } - if (! $error) + if (!$error) { $db->commit(); setEventMessage($langs->trans('BillCreated', $nb_bills_created)); @@ -394,9 +394,9 @@ if (empty($reshook)) else { $db->rollback(); - $action='create'; - $_GET["origin"]=$_POST["origin"]; - $_GET["originid"]=$_POST["originid"]; + $action = 'create'; + $_GET["origin"] = $_POST["origin"]; + $_GET["originid"] = $_POST["originid"]; setEventMessages($object->error, $errors, 'errors'); $error++; } @@ -408,58 +408,58 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$companystatic=new Societe($db); -$reception=new Reception($db); -$formcompany=new FormCompany($db); +$form = new Form($db); +$companystatic = new Societe($db); +$reception = new Reception($db); +$formcompany = new FormCompany($db); $formfile = new FormFile($db); -$helpurl='EN:Module_Receptions|FR:Module_Receptions|ES:Módulo_Receptiones'; +$helpurl = 'EN:Module_Receptions|FR:Module_Receptions|ES:Módulo_Receptiones'; llxHeader('', $langs->trans('ListOfReceptions'), $helpurl); $sql = "SELECT e.rowid, e.ref, e.ref_supplier, e.date_reception as date_reception, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed,"; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' e.date_creation as date_creation, e.tms as date_update'; +$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= ' e.date_creation as date_creation, e.tms as date_update'; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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."reception as e"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; -$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)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'reception' AND ee.targettype = 'delivery'"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target"; +$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."reception as e"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; +$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)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'reception' AND ee.targettype = 'delivery'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target"; if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -$sql.= " WHERE e.entity IN (".getEntity('reception').")"; +$sql .= " WHERE e.entity IN (".getEntity('reception').")"; if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all { - $sql.= " AND e.fk_soc = sc.fk_soc"; - $sql.= " AND sc.fk_user = " .$user->id; + $sql .= " AND e.fk_soc = sc.fk_soc"; + $sql .= " AND sc.fk_user = ".$user->id; } if ($socid) { - $sql.= " AND e.fk_soc = ".$socid; + $sql .= " AND e.fk_soc = ".$socid; } if ($viewstatut <> '' && $viewstatut >= 0) { - $sql.= " AND e.fk_statut = ".$viewstatut; + $sql .= " AND e.fk_statut = ".$viewstatut; } -if ($search_billed != '' && $search_billed >= 0) $sql.=' AND e.billed = '.$search_billed; -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_billed != '' && $search_billed >= 0) $sql .= ' AND e.billed = '.$search_billed; +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_ref_rcp) $sql .= natural_search('e.ref', $search_ref_rcp); @@ -471,21 +471,21 @@ if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); // Add where from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/', '', $key); - $typ=$extrafields->attributes[$object->table_element]['type'][$tmpkey]; - $mode=0; - if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric - if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) + $crit = $val; + $tmpkey = preg_replace('/search_options_/', '', $key); + $typ = $extrafields->attributes[$object->table_element]['type'][$tmpkey]; + $mode = 0; + if (in_array($typ, array('int', 'double', 'real'))) $mode = 1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode = 2; // Search on a foreign key int + if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0')) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); } } // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -494,51 +494,51 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->order($sortfield, $sortorder); -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->order($sortfield, $sortorder); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $reception = new Reception($db); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($sall) $param.= "&sall=".$sall; - if ($search_ref_rcp) $param.= "&search_ref_rcp=".$search_ref_rcp; - if ($search_ref_liv) $param.= "&search_ref_liv=".$search_ref_liv; - if ($search_company) $param.= "&search_company=".$search_company; - if ($optioncss != '') $param.='&optioncss='.$optioncss; - if ($search_billed != '' && $search_billed >= 0)$param.= "&search_billed=".$search_billed; - if ($search_town) $param.= "&search_town=".$search_town; - if ($search_zip) $param.= "&search_zip=".$search_zip; - if ($search_state) $param.= "&search_state=".$search_state; - if ($viewstatut) $param.= "&viewstatut=".$viewstatut; - if ($search_country) $param.= "&search_country=".$search_country; - if ($search_type_thirdparty) $param.= "&search_type_thirdparty=".$search_type_thirdparty; - if ($search_ref_supplier) $param.= "&search_ref_supplier=".$search_ref_supplier; + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($sall) $param .= "&sall=".$sall; + if ($search_ref_rcp) $param .= "&search_ref_rcp=".$search_ref_rcp; + if ($search_ref_liv) $param .= "&search_ref_liv=".$search_ref_liv; + if ($search_company) $param .= "&search_company=".$search_company; + if ($optioncss != '') $param .= '&optioncss='.$optioncss; + if ($search_billed != '' && $search_billed >= 0)$param .= "&search_billed=".$search_billed; + if ($search_town) $param .= "&search_town=".$search_town; + if ($search_zip) $param .= "&search_zip=".$search_zip; + if ($search_state) $param .= "&search_state=".$search_state; + if ($viewstatut) $param .= "&viewstatut=".$viewstatut; + if ($search_country) $param .= "&search_country=".$search_country; + if ($search_type_thirdparty) $param .= "&search_type_thirdparty=".$search_type_thirdparty; + if ($search_ref_supplier) $param .= "&search_ref_supplier=".$search_ref_supplier; // Add $param from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/', '', $key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + $crit = $val; + $tmpkey = preg_replace('/search_options_/', '', $key); + if ($val != '') $param .= '&search_options_'.$tmpkey.'='.urlencode($val); } - $arrayofmassactions = array( + $arrayofmassactions = array( // 'presend'=>$langs->trans("SendByMail"), ); - if($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisSupplier"); - if($massaction == 'createbills') $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier"); + if ($massaction == 'createbills') $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); //$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); $i = 0; @@ -581,7 +581,7 @@ if ($resql) print $langs->trans('ValidateInvoices'); print '
'; - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { print $form->selectyesno('validate_invoices', 0, 1, 1); print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; @@ -604,91 +604,91 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall); + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print $langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall); } - $moreforfilter=''; - if (! empty($moreforfilter)) + $moreforfilter = ''; + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters=array('type'=>$type); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; - print ''."\n"; + print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; // Ref - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print ''; } // Ref customer - if (! empty($arrayfields['e.ref_supplier']['checked'])) + if (!empty($arrayfields['e.ref_supplier']['checked'])) { print ''; } // Thirdparty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } // Town - if (! empty($arrayfields['s.town']['checked'])) print ''; + if (!empty($arrayfields['s.town']['checked'])) print ''; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print ''; + if (!empty($arrayfields['s.zip']['checked'])) print ''; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; } // Date delivery planned - if (! empty($arrayfields['e.date_delivery']['checked'])) + if (!empty($arrayfields['e.date_delivery']['checked'])) { print ''; } - if (! empty($arrayfields['l.ref']['checked'])) + if (!empty($arrayfields['l.ref']['checked'])) { // Delivery ref print ''; @@ -697,30 +697,30 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['e.datec']['checked'])) + if (!empty($arrayfields['e.datec']['checked'])) { print ''; } // Date modification - if (! empty($arrayfields['e.tms']['checked'])) + if (!empty($arrayfields['e.tms']['checked'])) { print ''; } // Status - if (! empty($arrayfields['e.fk_statut']['checked'])) + if (!empty($arrayfields['e.fk_statut']['checked'])) { print ''; } // Status billed - if (! empty($arrayfields['e.billed']['checked'])) + if (!empty($arrayfields['e.billed']['checked'])) { print ''; print "\n"; print ''; - if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['e.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['e.ref_supplier']['label'], $_SERVER["PHP_SELF"], "e.ref_supplier", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['e.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['e.ref_supplier']['label'], $_SERVER["PHP_SELF"], "e.ref_supplier", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $reception->id=$obj->rowid; - $reception->ref=$obj->ref; + $reception->id = $obj->rowid; + $reception->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->ref=$obj->name; - $companystatic->name=$obj->name; + $companystatic->id = $obj->socid; + $companystatic->ref = $obj->name; + $companystatic->name = $obj->name; print ''; // Ref - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref customer - if (! empty($arrayfields['e.ref_supplier']['checked'])) + if (!empty($arrayfields['e.ref_supplier']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['s.town']['checked'])) + if (!empty($arrayfields['s.town']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['s.zip']['checked'])) + if (!empty($arrayfields['s.zip']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date delivery planed - if (! empty($arrayfields['e.date_delivery']['checked'])) + if (!empty($arrayfields['e.date_delivery']['checked'])) { print '\n"; } - if (! empty($arrayfields['l.ref']['checked']) || ! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { $reception->fetchObjectLinked($reception->id, $reception->element); - $receiving=''; - if (count($reception->linkedObjects['delivery']) > 0) $receiving=reset($reception->linkedObjects['delivery']); + $receiving = ''; + if (count($reception->linkedObjects['delivery']) > 0) $receiving = reset($reception->linkedObjects['delivery']); - if (! empty($arrayfields['l.ref']['checked'])) + if (!empty($arrayfields['l.ref']['checked'])) { // Ref print ''; } - if (! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.date_delivery']['checked'])) { // Date received print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['e.tms']['checked'])) + if (!empty($arrayfields['e.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['e.fk_statut']['checked'])) + if (!empty($arrayfields['e.fk_statut']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Billed - if (! empty($arrayfields['e.billed']['checked'])) + if (!empty($arrayfields['e.billed']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 1ad5c03ef98..d2b16926a1a 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -40,7 +40,7 @@ $cancel = GETPOST('cancel', 'alpha'); $ref = GETPOST('ref', 'alpha'); $description = GETPOST('description'); $confirm = GETPOST('confirm'); -$fk_code_type_resource = GETPOST('fk_code_type_resource', 'alpha'); +$fk_code_type_resource = GETPOST('fk_code_type_resource', 'alpha'); $country_id = GETPOST('country_id', 'int'); // Protection if external user @@ -49,7 +49,7 @@ if ($user->socid > 0) accessforbidden(); } -if( ! $user->rights->resource->read) +if (!$user->rights->resource->read) { accessforbidden(); } @@ -67,16 +67,16 @@ $extrafields->fetch_name_optionals_label($object->table_element); * Actions */ -$hookmanager->initHooks(array('resource', 'resource_card','globalcard')); -$parameters=array('resource_id'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$hookmanager->initHooks(array('resource', 'resource_card', 'globalcard')); +$parameters = array('resource_id'=>$id); +$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)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -86,14 +86,14 @@ if (empty($reshook)) header("Location: ".DOL_URL_ROOT.'/resource/list.php'); exit; } - $action=''; + $action = ''; } if ($action == 'add' && $user->rights->resource->write) { - if (! $cancel) + if (!$cancel) { - $error=''; + $error = ''; if (empty($ref)) { @@ -111,7 +111,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - $result=$object->create($user); + $result = $object->create($user); if ($result > 0) { // Creation OK @@ -134,9 +134,9 @@ if (empty($reshook)) } } - if ($action == 'update' && ! $cancel && $user->rights->resource->write) + if ($action == 'update' && !$cancel && $user->rights->resource->write) { - $error=0; + $error = 0; if (empty($ref)) { @@ -144,10 +144,10 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $res = $object->fetch($id); - if ( $res > 0 ) + if ($res > 0) { $object->ref = $ref; $object->description = $description; @@ -157,10 +157,10 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error ++; + $error++; } - $result=$object->update($user); + $result = $object->update($user); if ($result > 0) { Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -181,14 +181,14 @@ if (empty($reshook)) if ($error) { - $action='edit'; + $action = 'edit'; } } if ($action == 'confirm_delete_resource' && $user->rights->resource->delete && $confirm === 'yes') { $res = $object->fetch($id); - if($res > 0) + if ($res > 0) { $result = $object->delete($id); @@ -236,13 +236,13 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) if ($action == 'create' || $action == 'edit') { - if (! $user->rights->resource->write) accessforbidden('', 0, 1); + if (!$user->rights->resource->write) accessforbidden('', 0, 1); // Create/Edit object print ''; print ''; - print ''; + print ''; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print ' '; print ''; } - if (! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.date_delivery']['checked'])) { // Date received print ' '; print ''; print ''; - print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusReceptionDraftShort'),'1'=>$langs->trans('StatusReceptionValidatedShort'),'2'=>$langs->trans('StatusReceptionProcessedShort')), $viewstatut, 1); + print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $viewstatut, 1); print ''; print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); @@ -728,126 +728,126 @@ if ($resql) } // Action column print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
"; print $reception->getNomUrl(1); - $filename=dol_sanitizeFileName($reception->ref); - $filedir=$conf->reception->dir_output . '/' . dol_sanitizeFileName($reception->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$reception->rowid; + $filename = dol_sanitizeFileName($reception->ref); + $filedir = $conf->reception->dir_output.'/'.dol_sanitizeFileName($reception->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$reception->rowid; print $formfile->getDocumentsLink($reception->element, $filename, $filedir); print ""; print $obj->ref_supplier; print "'; print $companystatic->getNomUrl(1); print ''; print $obj->town; print ''; print $obj->zip; print '".$obj->state_name."'; - $tmparray=getCountry($obj->fk_pays, 'all'); + $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print ''; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print ''; print dol_print_date($db->jdate($obj->date_livraison), "day"); @@ -858,13 +858,13 @@ if ($resql) print "'; @@ -872,7 +872,7 @@ if ($resql) print ''; @@ -885,48 +885,48 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['e.datec']['checked'])) + if (!empty($arrayfields['e.datec']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ''.$reception->LibStatut($obj->fk_statut, 5).''.yn($obj->billed).''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'; @@ -271,8 +271,8 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) print ''; // Other attributes - $parameters=array('objectsrc' => $objectsrc); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('objectsrc' => $objectsrc); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -284,9 +284,9 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ''; @@ -306,11 +306,11 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) print $formconfirm; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; - $morehtmlref.='
'; + $morehtmlref = '
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -326,7 +326,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) // Resource type print ''; - print ''; + print ''; print ''; @@ -334,13 +334,13 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) // Description print ''; - print ''; + print ''; print ''; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; @@ -371,10 +371,10 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) // modified by hook if (empty($reshook)) { - if ($action != "create" && $action != "edit" ) + if ($action != "create" && $action != "edit") { // Edit resource - if($user->rights->resource->write) + if ($user->rights->resource->write) { print '
'; print ''.$langs->trans('Modify').''; @@ -384,7 +384,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) if ($action != "delete" && $action != "create" && $action != "edit") { // Delete resource - if($user->rights->resource->delete) + if ($user->rights->resource->delete) { print '
'; print ''.$langs->trans('Delete').''; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 62fc5ca9a9c..81e79aea228 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -28,12 +28,12 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; } // Load translation files required by the page @@ -45,19 +45,19 @@ $sortfield = GETPOST('sortfield','alpha'); $page = GETPOST('page','int'); */ -if( ! $user->rights->resource->read) +if (!$user->rights->resource->read) accessforbidden(); -$object=new Dolresource($db); +$object = new Dolresource($db); $hookmanager->initHooks(array('element_resource')); $object->available_resources = array('dolresource'); // Get parameters -$id = GETPOST('id', 'int'); // resource id -$element_id = GETPOST('element_id', 'int'); // element_id -$element_ref = GETPOST('ref', 'alpha'); // element ref -$element = GETPOST('element', 'alpha'); // element_type +$id = GETPOST('id', 'int'); // resource id +$element_id = GETPOST('element_id', 'int'); // element_id +$element_ref = GETPOST('ref', 'alpha'); // element ref +$element = GETPOST('element', 'alpha'); // element_type $action = GETPOST('action', 'alpha'); $mode = GETPOST('mode', 'alpha'); $lineid = GETPOST('lineid', 'int'); @@ -89,14 +89,14 @@ if (empty($reshook)) { $error = 0; - if ($action == 'add_element_resource' && ! $cancel) + if ($action == 'add_element_resource' && !$cancel) { $res = 0; - if (! ($resource_id > 0)) + if (!($resource_id > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Resource")), null, 'errors'); - $action=''; + $action = ''; } else { @@ -105,7 +105,7 @@ if (empty($reshook)) // TODO : add this check at update_linked_resource and when modifying event start or end date // check if an event resource is already in use - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $objstat->element=='action' && $resource_type=='dolresource' && intval($busy)==1) { + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $objstat->element == 'action' && $resource_type == 'dolresource' && intval($busy) == 1) { $eventDateStart = $objstat->datep; $eventDateEnd = $objstat->datef; $isFullDayEvent = intval($objstat->fulldayevent); @@ -118,24 +118,24 @@ if (empty($reshook)) } $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) . "'"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($objstat->element) . "'"; - $sql .= " WHERE er.resource_id = " . $resource_id; + $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = '".$db->escape($resource_type)."'"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($objstat->element)."'"; + $sql .= " WHERE er.resource_id = ".$resource_id; $sql .= " AND er.busy = 1"; $sql .= " AND ("; // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) - $sql .= " (ac.datep <= '" . $db->idate($eventDateStart) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) . "'))"; + $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; // event date end between ac.datep and ac.datep2 if (!empty($eventDateEnd)) { - $sql .= " OR (ac.datep <= '" . $db->idate($eventDateEnd) . "' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) . "'))"; + $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; } // event date start before ac.datep and event date end after ac.datep2 $sql .= " OR ("; - $sql .= "ac.datep >= '" . $db->idate($eventDateStart) . "'"; + $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; if (!empty($eventDateEnd)) { - $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) . "')"; + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; } $sql .= ")"; @@ -146,12 +146,12 @@ if (empty($reshook)) $objstat->error = $db->lasterror(); $objstat->errors[] = $objstat->error; } else { - if ($db->num_rows($resql)>0) { + if ($db->num_rows($resql) > 0) { // already in use $error++; - $objstat->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; + $objstat->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; while ($obj = $db->fetch_object($resql)) { - $objstat->error .= '
- ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + $objstat->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); } $objstat->errors[] = $objstat->error; } @@ -164,7 +164,7 @@ if (empty($reshook)) } } - if (! $error && $res > 0) + if (!$error && $res > 0) { setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$objstat->id); @@ -177,15 +177,15 @@ if (empty($reshook)) } // Update ressource - if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel', 'alpha') ) + if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel', 'alpha')) { $res = $object->fetch_element_resource($lineid); - if($res) + if ($res) { $object->busy = $busy; $object->mandatory = $mandatory; - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element_type=='action' && $object->resource_type=='dolresource' && intval($object->busy)==1) { + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element_type == 'action' && $object->resource_type == 'dolresource' && intval($object->busy) == 1) { $eventDateStart = $object->objelement->datep; $eventDateEnd = $object->objelement->datef; $isFullDayEvent = intval($objstat->fulldayevent); @@ -198,25 +198,25 @@ if (empty($reshook)) } $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "element_resources as er"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($object->resource_type) . "'"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape($object->element_type) . "'"; - $sql .= " WHERE er.resource_id = " . $object->resource_id; - $sql .= " AND ac.id != " . $object->element_id; + $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = '".$db->escape($object->resource_type)."'"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element_type)."'"; + $sql .= " WHERE er.resource_id = ".$object->resource_id; + $sql .= " AND ac.id != ".$object->element_id; $sql .= " AND er.busy = 1"; $sql .= " AND ("; // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) - $sql .= " (ac.datep <= '" . $db->idate($eventDateStart) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) . "'))"; + $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; // event date end between ac.datep and ac.datep2 if (!empty($eventDateEnd)) { - $sql .= " OR (ac.datep <= '" . $db->idate($eventDateEnd) . "' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateEnd) . "'))"; + $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; } // event date start before ac.datep and event date end after ac.datep2 $sql .= " OR ("; - $sql .= "ac.datep >= '" . $db->idate($eventDateStart) . "'"; + $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; if (!empty($eventDateEnd)) { - $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) . "')"; + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; } $sql .= ")"; @@ -227,12 +227,12 @@ if (empty($reshook)) $object->error = $db->lasterror(); $object->errors[] = $object->error; } else { - if ($db->num_rows($resql)>0) { + if ($db->num_rows($resql) > 0) { // already in use $error++; - $object->error = $langs->trans('ErrorResourcesAlreadyInUse') . ' : '; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; while ($obj = $db->fetch_object($resql)) { - $object->error .= '
- ' . $langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label . ' [' . $obj->ac_id . ']'); + $object->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); } $object->errors[] = $objstat->error; } @@ -273,8 +273,8 @@ if (empty($reshook)) } } -$parameters=array('resource_id'=>$resource_id); -$reshook=$hookmanager->executeHooks('getElementResources', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('resource_id'=>$resource_id); +$reshook = $hookmanager->executeHooks('getElementResources', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -283,15 +283,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e * View */ -$form=new Form($db); +$form = new Form($db); -$pagetitle=$langs->trans('ResourceElementPage'); +$pagetitle = $langs->trans('ResourceElementPage'); llxHeader('', $pagetitle, ''); // Load available resource, declared by modules $ret = count($object->available_resources); -if($ret == -1) { +if ($ret == -1) { dol_print_error($db, $object->error); exit; } @@ -315,49 +315,49 @@ else $act = fetchObjectByElement($element_id, $element, $element_ref); if (is_object($act)) { - $head=actions_prepare_head($act); + $head = actions_prepare_head($act); dol_fiche_head($head, 'resources', $langs->trans("Action"), -1, 'action'); - $linkback =img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); - $linkback.= ''.$langs->trans("BackToList").''; + $linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); + $linkback .= ''.$langs->trans("BackToList").''; // Link to other agenda views - $out=''; - $out.='
  • '.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); - $out.=''.$langs->trans("ViewPerUser").''; - $out.='
  • '.img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"'); - $out.=''.$langs->trans("ViewCal").''; - $out.='
  • '.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); - $out.=''.$langs->trans("ViewWeek").''; - $out.='
  • '.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); - $out.=''.$langs->trans("ViewDay").''; + $out = ''; + $out .= '
  • '.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewPerUser").''; + $out .= '
  • '.img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewCal").''; + $out .= '
  • '.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewWeek").''; + $out .= '
  • '.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewDay").''; - $linkback.=$out; + $linkback .= $out; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Thirdparty //$morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); //$morehtmlref.='
    '.$langs->trans('Project') . ' '; - $morehtmlref.=$langs->trans('Project') . ': '; - if (! empty($act->fk_project)) { + $morehtmlref .= $langs->trans('Project').': '; + if (!empty($act->fk_project)) { $proj = new Project($db); $proj->fetch($act->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - if ($proj->title) $morehtmlref.=' - '.$proj->title; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + if ($proj->title) $morehtmlref .= ' - '.$proj->title; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; - dol_banner_tab($act, 'element_id', $linkback, ($user->socid?0:1), 'id', 'ref', $morehtmlref, '&element='.$element, 0, '', ''); + dol_banner_tab($act, 'element_id', $linkback, ($user->socid ? 0 : 1), 'id', 'ref', $morehtmlref, '&element='.$element, 0, '', ''); print '
    '; @@ -366,7 +366,7 @@ else print '
  • ' . $langs->trans("ResourceType") . ''.$langs->trans("ResourceType").''; print $object->type_label; print '
    ' . $langs->trans("ResourceFormLabel_description") . ''.$langs->trans("ResourceFormLabel_description").''; print $object->description; print '
    '; // Type - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''; } @@ -376,7 +376,7 @@ else // Date start print ''; @@ -384,9 +384,9 @@ else // Date end print ''; // Location @@ -397,32 +397,32 @@ else // Assigned to print ''; print ''; print ''; print ''; print ''; - $generated_password=''; + $generated_password = ''; if (empty($ldap_sid)) // ldap_sid is for activedirectory { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generated_password=getRandomPassword(false); + $generated_password = getRandomPassword(false); } - $password=$generated_password; + $password = $generated_password; // Password print ''; print ''; - if (! empty($conf->api->enabled)) + if (!empty($conf->api->enabled)) { // API key $generated_api_key = ''; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generated_password=getRandomPassword(false); + $generated_password = getRandomPassword(false); print ''; print ''; } @@ -905,20 +905,20 @@ if ($action == 'create' || $action == 'adduserldap') { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; // PARTIAL WORKAROUND - $generated_fake_api_key=getRandomPassword(false); + $generated_fake_api_key = getRandomPassword(false); print ''; } // Administrator - if (! empty($user->admin)) + if (!empty($user->admin)) { print ''; print '\n"; @@ -962,15 +962,15 @@ if ($action == 'create' || $action == 'adduserldap') // Gender print ''; print ''; // Employee - $defaultemployee=1; + $defaultemployee = 1; print ''; print ''; // Hierarchy @@ -981,7 +981,7 @@ if ($action == 'create' || $action == 'adduserldap') print "\n"; // Expense report validator - if(!empty($conf->expensereport->enabled)) + if (!empty($conf->expensereport->enabled)) { print ''; // Town print ''; // Country print ''; @@ -1043,7 +1043,7 @@ if ($action == 'create' || $action == 'adduserldap') // Tel print ''; print ''; print ''; print ''; // EMail - print 'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; + print 'global->USER_MAIL_REQUIRED) ? ' class="fieldrequired"' : '').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; print ''; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { print ''; print ''; } else { // if social network is not active but value exist we do not want to loose it - if (! empty($ldap_social[$key])) { + if (!empty($ldap_social[$key])) { print ''; } else { print ''; @@ -1196,30 +1196,30 @@ if ($action == 'create' || $action == 'adduserldap') } // User color - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { print ''; print ''; } // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print '"; } // Multicompany - if (! empty($conf->multicompany->enabled) && is_object($mc)) + if (!empty($conf->multicompany->enabled) && is_object($mc)) { // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module - if (! method_exists($mc, 'formObjectOptions')) + if (!method_exists($mc, 'formObjectOptions')) { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) // condition must be same for create and edit mode { print "".''; print "\n"; @@ -1254,7 +1254,7 @@ if ($action == 'create' || $action == 'adduserldap') print ''; print ''; @@ -1265,7 +1265,7 @@ if ($action == 'create' || $action == 'adduserldap') // TODO Move this into tab RH (HierarchicalResponsible must be on both tab) // Default warehouse - if (! empty($conf->stock->enabled) && ! empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? + if (!empty($conf->stock->enabled) && !empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? { print ''; - if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) - || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) + || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); // THM print ''; print ''; print ''; - if (! empty($object->ldap_sid) && $object->statut==0) + if (!empty($object->ldap_sid) && $object->statut == 0) { print ''; } @@ -1506,68 +1506,68 @@ else print ''; print '"; print ''."\n"; // API key - if (! empty($conf->api->enabled) && $user->admin) { + if (!empty($conf->api->enabled) && $user->admin) { print ''; print ''; } // Administrator print ''."\n"; @@ -1618,7 +1618,7 @@ else print ''; print ''; print '\n"; // Default warehouse - if (! empty($conf->stock->enabled) && ! empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? + if (!empty($conf->stock->enabled) && !empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? { - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php'; - $warehousestatic=new Entrepot($db); + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + $warehousestatic = new Entrepot($db); $warehousestatic->fetch($object->fk_warehouse); print ''; print ''; print "\n"; // TJM print ''; print ''; print "\n"; // Salary print ''; print ''; print "\n"; } @@ -1750,7 +1750,7 @@ else print '
    '.$langs->trans("Type").''.$act->type.'
    '.$langs->trans("DateActionStart").''; - if (! $act->fulldayevent) print dol_print_date($act->datep, 'dayhour'); + if (!$act->fulldayevent) print dol_print_date($act->datep, 'dayhour'); else print dol_print_date($act->datep, 'day'); if ($act->percentage == 0 && $act->datep && $act->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print '
    '.$langs->trans("DateActionEnd").''; - if (! $act->fulldayevent) print dol_print_date($act->datef, 'dayhour'); + if (!$act->fulldayevent) print dol_print_date($act->datef, 'dayhour'); else print dol_print_date($act->datef, 'day'); - if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); + if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print '
    '.$langs->trans("ActionAffectedTo").''; - $listofuserid=array(); + $listofuserid = array(); if (empty($donotclearsession)) { - if ($act->userownerid > 0) $listofuserid[$act->userownerid]=array('id'=>$act->userownerid,'transparency'=>$act->transparency); // Owner first - if (! empty($act->userassigned)) // Now concat assigned users + if ($act->userownerid > 0) $listofuserid[$act->userownerid] = array('id'=>$act->userownerid, 'transparency'=>$act->transparency); // Owner first + if (!empty($act->userassigned)) // Now concat assigned users { // Restore array with key with same value than param 'id' - $tmplist1=$act->userassigned; $tmplist2=array(); - foreach($tmplist1 as $key => $val) + $tmplist1 = $act->userassigned; $tmplist2 = array(); + foreach ($tmplist1 as $key => $val) { - if ($val['id'] && $val['id'] != $act->userownerid) $listofuserid[$val['id']]=$val; + if ($val['id'] && $val['id'] != $act->userownerid) $listofuserid[$val['id']] = $val; } } - $_SESSION['assignedtouser']=json_encode($listofuserid); + $_SESSION['assignedtouser'] = json_encode($listofuserid); } else { if (!empty($_SESSION['assignedtouser'])) { - $listofuserid=json_decode($_SESSION['assignedtouser'], true); + $listofuserid = json_decode($_SESSION['assignedtouser'], true); } } - $listofcontactid=array(); // not used yet - $listofotherid=array(); // not used yet + $listofcontactid = array(); // not used yet + $listofotherid = array(); // not used yet print '
    '; - print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($act->datep != $act->datef)?1:0, $listofuserid, $listofcontactid, $listofotherid); + print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($act->datep != $act->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid); print '
    '; /*if (in_array($user->id,array_keys($listofuserid))) { @@ -448,7 +448,7 @@ else $savobject = $object; $object = $socstatic; - require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $head = societe_prepare_head($socstatic); dol_fiche_head($head, 'resources', $langs->trans("ThirdParty"), -1, 'company'); @@ -461,7 +461,7 @@ else print ''; // Alias name (commercial, trademark or alias name) - print '"; @@ -486,53 +486,53 @@ else if (is_object($fichinter)) { - $head=fichinter_prepare_head($fichinter); + $head = fichinter_prepare_head($fichinter); dol_fiche_head($head, 'resource', $langs->trans("InterventionCard"), -1, 'intervention'); // Intervention card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Ref customer //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $fichinter->thirdparty->getNomUrl(1); + $morehtmlref .= $langs->trans('ThirdParty').' : '.$fichinter->thirdparty->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
    '.$langs->trans('Project') . ' '; + $morehtmlref .= '
    '.$langs->trans('Project').' '; if ($user->rights->commande->creer) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $fichinter->id, $fichinter->socid, $fichinter->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($fichinter->socid, $fichinter->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($fichinter->socid, $fichinter->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $fichinter->id, $fichinter->socid, $fichinter->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($fichinter->fk_project)) { + if (!empty($fichinter->fk_project)) { $proj = new Project($db); $proj->fetch($fichinter->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; dol_banner_tab($fichinter, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '&element='.$element, 0, '', '', 1); @@ -551,13 +551,13 @@ else if (is_object($product)) { $head = product_prepare_head($product); - $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); + $titre = $langs->trans("CardProduct".$product->type); + $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'resources', $titre, -1, $picto); $shownav = 1; - if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($product, 'ref', '', $shownav, 'ref', 'ref', '', '&element='.$element); dol_fiche_end(); @@ -566,8 +566,8 @@ else // hook for other elements linked - $parameters=array('element'=>$element, 'element_id'=>$element_id, 'element_ref'=>$element_ref); - $reshook=$hookmanager->executeHooks('printElementTab', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('element'=>$element, 'element_id'=>$element_id, 'element_ref'=>$element_ref); + $reshook = $hookmanager->executeHooks('printElementTab', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -578,26 +578,26 @@ else foreach ($object->available_resources as $modresources => $resources) { - $resources=(array) $resources; // To be sure $resources is an array - foreach($resources as $resource_obj) + $resources = (array) $resources; // To be sure $resources is an array + foreach ($resources as $resource_obj) { $element_prop = getElementProperties($resource_obj); //print '/'.$modresources.'/class/'.$resource_obj.'.class.php
    '; $path = ''; - if(strpos($resource_obj, '@')) + if (strpos($resource_obj, '@')) $path .= '/'.$element_prop['module']; $linked_resources = $object->getElementResources($element, $element_id, $resource_obj); // Output template part (modules that overwrite templates must declare this into descriptor) - $defaulttpldir='/core/tpl'; - $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir), array($path.$defaulttpldir)); + $defaulttpldir = '/core/tpl'; + $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir), array($path.$defaulttpldir)); - foreach($dirtpls as $module => $reldir) + foreach ($dirtpls as $module => $reldir) { - if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php'))) + if (file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php'))) { $tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php'); } @@ -606,18 +606,18 @@ else $tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_add.tpl.php'; } if (empty($conf->file->strict_mode)) { - $res=@include $tpl; + $res = @include $tpl; } else { - $res=include $tpl; // for debug + $res = include $tpl; // for debug } if ($res) break; } if ($mode != 'add' || $resource_obj != $resource_type) { - foreach($dirtpls as $module => $reldir) + foreach ($dirtpls as $module => $reldir) { - if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php'))) + if (file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php'))) { $tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php'); } @@ -626,9 +626,9 @@ else $tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_view.tpl.php'; } if (empty($conf->file->strict_mode)) { - $res=@include $tpl; + $res = @include $tpl; } else { - $res=include $tpl; // for debug + $res = include $tpl; // for debug } if ($res) break; } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 7c4c3bc0ef1..7886c0ef728 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -45,50 +45,50 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; -if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +if (!empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; +if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); -$mode = GETPOST('mode', 'alpha'); +$mode = GETPOST('mode', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$group = GETPOST("group", "int", 3); +$group = GETPOST("group", "int", 3); $cancel = GETPOST('cancel', 'alpha'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'useracard'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useracard'; // To manage different context of search // Define value to know what current user can do on users -$canadduser=(! empty($user->admin) || $user->rights->user->user->creer); -$canreaduser=(! empty($user->admin) || $user->rights->user->user->lire); -$canedituser=(! empty($user->admin) || $user->rights->user->user->creer); -$candisableuser=(! empty($user->admin) || $user->rights->user->user->supprimer); -$canreadgroup=$canreaduser; -$caneditgroup=$canedituser; -if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) +$canadduser = (!empty($user->admin) || $user->rights->user->user->creer); +$canreaduser = (!empty($user->admin) || $user->rights->user->user->lire); +$canedituser = (!empty($user->admin) || $user->rights->user->user->creer); +$candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer); +$canreadgroup = $canreaduser; +$caneditgroup = $canedituser; +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { - $canreadgroup=(! empty($user->admin) || $user->rights->user->group_advance->read); - $caneditgroup=(! empty($user->admin) || $user->rights->user->group_advance->write); + $canreadgroup = (!empty($user->admin) || $user->rights->user->group_advance->read); + $caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write); } // Define value to know what current user can do on properties of edited user if ($id) { // $user est le user qui edite, $id est l'id de l'utilisateur edite - $caneditfield=((($user->id == $id) && $user->rights->user->self->creer) + $caneditfield = ((($user->id == $id) && $user->rights->user->self->creer) || (($user->id != $id) && $user->rights->user->user->creer)); - $caneditpassword=((($user->id == $id) && $user->rights->user->self->password) + $caneditpassword = ((($user->id == $id) && $user->rights->user->self->password) || (($user->id != $id) && $user->rights->user->user->password)); } // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) $socid = $user->socid; -$feature2='user'; +$feature2 = 'user'; $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -if ($user->id <> $id && ! $canreaduser) accessforbidden(); +if ($user->id <> $id && !$canreaduser) accessforbidden(); // Load translation files required by page $langs->loadLangs(array('users', 'companies', 'ldap', 'admin', 'hrm', 'stocks')); @@ -109,8 +109,8 @@ $hookmanager->initHooks(array('usercard', 'globalcard')); /** * Actions */ -$parameters=array('id' => $id, 'socid' => $socid, 'group' => $group, 'caneditgroup' => $caneditgroup); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id' => $id, 'socid' => $socid, 'group' => $group, 'caneditgroup' => $caneditgroup); +$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)) { @@ -131,7 +131,7 @@ if (empty($reshook)) { if (!empty($conf->file->main_limit_users)) { $nb = $object->getNbOfUsers("active"); if ($nb >= $conf->file->main_limit_users) { - $error ++; + $error++; setEventMessages($langs->trans("YourQuotaOfUsersIsReached"), null, 'errors'); } } @@ -148,7 +148,7 @@ if (empty($reshook)) { { if ($id <> $user->id) { - if (! GETPOSTISSET('token')) + if (!GETPOSTISSET('token')) { print 'Error, token required for this critical operation'; exit; @@ -175,22 +175,22 @@ if (empty($reshook)) { $error = 0; if (!$_POST["lastname"]) { - $error ++; + $error++; setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); - $action = "create"; // Go back to create page + $action = "create"; // Go back to create page } if (!$_POST["login"]) { - $error ++; + $error++; setEventMessages($langs->trans("LoginNotDefined"), null, 'errors'); - $action = "create"; // Go back to create page + $action = "create"; // Go back to create page } if (!empty($conf->file->main_limit_users)) { // If option to limit users is set $nb = $object->getNbOfUsers("active"); if ($nb >= $conf->file->main_limit_users) { - $error ++; + $error++; setEventMessages($langs->trans("YourQuotaOfUsersIsReached"), null, 'errors'); - $action = "create"; // Go back to create page + $action = "create"; // Go back to create page } } @@ -217,7 +217,7 @@ if (empty($reshook)) { //$object->facebook = GETPOST("facebook", 'alphanohtml'); //$object->linkedin = GETPOST("linkedin", 'alphanohtml'); $object->socialnetworks = array(); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } @@ -252,16 +252,16 @@ if (empty($reshook)) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error ++; + $error++; } // Set entity property $entity = GETPOST('entity', 'int'); - if (! empty($conf->multicompany->enabled)) { + if (!empty($conf->multicompany->enabled)) { if (GETPOST('superadmin', 'int')) { $object->entity = 0; } else { - if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->entity = 1; // all users are forced into master entity } else { $object->entity = ($entity == '' ? 1 : $entity); @@ -281,7 +281,7 @@ if (empty($reshook)) { if (GETPOST('password')) { $object->setPassword($user, GETPOST('password')); } - if (! empty($conf->categorie->enabled)) { + if (!empty($conf->categorie->enabled)) { // Categories association $usercats = GETPOST('usercats', 'array'); $object->setCategories($usercats); @@ -296,7 +296,7 @@ if (empty($reshook)) { $langs->load("errors"); $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); - $action = "create"; // Go back to create page + $action = "create"; // Go back to create page } } } @@ -308,7 +308,7 @@ if (empty($reshook)) { { $editgroup = new UserGroup($db); $editgroup->fetch($group); - $editgroup->oldcopy=clone $editgroup; + $editgroup->oldcopy = clone $editgroup; $object->fetch($id); if ($action == 'addgroup') { @@ -329,7 +329,7 @@ if (empty($reshook)) { } } - if ($action == 'update' && ! $cancel) + if ($action == 'update' && !$cancel) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -337,15 +337,15 @@ if (empty($reshook)) { { $error = 0; - if (! GETPOST("lastname", 'alpha')) { + if (!GETPOST("lastname", 'alpha')) { setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); - $action = "edit"; // Go back to create page - $error ++; + $action = "edit"; // Go back to create page + $error++; } - if (! GETPOST("login", 'alpha')) { + if (!GETPOST("login", 'alpha')) { setEventMessages($langs->trans("LoginNotDefined"), null, 'errors'); - $action = "edit"; // Go back to create page - $error ++; + $action = "edit"; // Go back to create page + $error++; } if (!$error) @@ -364,7 +364,7 @@ if (empty($reshook)) { $object->birth = $birth; $object->pass = GETPOST("password", 'none'); $object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key; - if (! empty($user->admin)) $object->admin = GETPOST("admin", "int"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request + if (!empty($user->admin)) $object->admin = GETPOST("admin", "int"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request $object->address = GETPOST('address', 'alphanohtml'); $object->zip = GETPOST('zipcode', 'alphanohtml'); $object->town = GETPOST('town', 'alphanohtml'); @@ -378,7 +378,7 @@ if (empty($reshook)) { //$object->facebook = GETPOST("facebook", 'alphanohtml'); //$object->linkedin = GETPOST("linkedin", 'alphanohtml'); $object->socialnetworks = array(); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } @@ -405,35 +405,35 @@ if (empty($reshook)) { $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int')); $object->dateemploymentend = $dateemploymentend; - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { $object->fk_warehouse = GETPOST('fk_warehouse', 'int'); } - if (! empty($conf->multicompany->enabled)) + if (!empty($conf->multicompany->enabled)) { - if (! empty($_POST["superadmin"])) + if (!empty($_POST["superadmin"])) { $object->entity = 0; } - elseif (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + elseif (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->entity = 1; // all users in master entity } else { - $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); + $object->entity = (!GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); } } else { - $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); + $object->entity = (!GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error ++; + $error++; } if (GETPOST('deletephoto')) { @@ -441,7 +441,7 @@ if (empty($reshook)) { } if (!empty($_FILES['photo']['name'])) { - $isimage=image_format_supported($_FILES['photo']['name']); + $isimage = image_format_supported($_FILES['photo']['name']); if ($isimage > 0) { $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); @@ -491,7 +491,7 @@ if (empty($reshook)) { dol_syslog("usercard::update", LOG_DEBUG); $resql = $db->query($sql); if (!$resql) { - $error ++; + $error++; setEventMessages($db->lasterror(), null, 'errors'); } } @@ -520,14 +520,14 @@ if (empty($reshook)) { $object->addThumbs($newfile); } } else { - $error ++; + $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); } } } - if (! $error && ! count($object->errors)) + if (!$error && !count($object->errors)) { // Then we add the associated categories $categories = GETPOST('usercats', 'array'); @@ -657,15 +657,15 @@ if (empty($reshook)) { } // Actions to send emails - $trigger_name='USER_SENTBYMAIL'; - $paramname='id'; // Name of param key to open the card - $mode='emailfromuser'; - $trackid='use'.$id; + $trigger_name = 'USER_SENTBYMAIL'; + $paramname = 'id'; // Name of param key to open the card + $mode = 'emailfromuser'; + $trackid = 'use'.$id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc $upload_dir = $conf->user->dir_output; - $permissiontoadd=$user->rights->user->user->creer; + $permissiontoadd = $user->rights->user->user->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -675,10 +675,10 @@ if (empty($reshook)) { */ $form = new Form($db); -$formother=new FormOther($db); +$formother = new FormOther($db); $formcompany = new FormCompany($db); $formfile = new FormFile($db); -if (! empty($conf->stock->enabled)) $formproduct = new FormProduct($db); +if (!empty($conf->stock->enabled)) $formproduct = new FormProduct($db); llxHeader('', $langs->trans("UserCard")); @@ -696,7 +696,7 @@ if ($action == 'create' || $action == 'adduserldap') print "
    "; - if (! empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) + if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) { /* * Affiche formulaire d'ajout d'un compte depuis LDAP @@ -707,7 +707,7 @@ if ($action == 'create' || $action == 'adduserldap') $result = $ldap->connect_bind(); if ($result >= 0) { - $required_fields=array( + $required_fields = array( $conf->global->LDAP_KEY_USERS, $conf->global->LDAP_FIELD_FULLNAME, $conf->global->LDAP_FIELD_NAME, @@ -727,23 +727,23 @@ if ($action == 'create' || $action == 'adduserldap') ); // Remove from required_fields all entries not configured in LDAP (empty) and duplicated - $required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement"))); + $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement"))); // Get from LDAP database an array of results $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1); if (is_array($ldapusers)) { - $liste=array(); + $liste = array(); foreach ($ldapusers as $key => $ldapuser) { // Define the label string for this user - $label=''; + $label = ''; foreach ($required_fields as $value) { if ($value) { - $label.=$value."=".$ldapuser[$value]." "; + $label .= $value."=".$ldapuser[$value]." "; } } $liste[$key] = $label; @@ -776,7 +776,7 @@ if ($action == 'create' || $action == 'adduserldap') print ajax_combobox('users'); } print '
    ' . $langs->trans('AliasNames') . ''; + print '
    '.$langs->trans('AliasNames').''; print $socstatic->name_alias; print "
    '; - print ''; + print ''; print '
    '; print ''; @@ -788,7 +788,7 @@ if ($action == 'create' || $action == 'adduserldap') print '
    '; print ''; print ''; - if (! empty($ldap_sid)) print ''; + if (!empty($ldap_sid)) print ''; print ''; dol_fiche_head('', '', '', 0, ''); @@ -801,7 +801,7 @@ if ($action == 'create' || $action == 'adduserldap') print '
    '.$langs->trans("Lastname").''; - if (! empty($ldap_lastname)) + if (!empty($ldap_lastname)) { print ''; print $ldap_lastname; @@ -815,7 +815,7 @@ if ($action == 'create' || $action == 'adduserldap') // Firstname print '
    '.$langs->trans("Firstname").''; - if (! empty($ldap_firstname)) + if (!empty($ldap_firstname)) { print ''; print $ldap_firstname; @@ -829,12 +829,12 @@ if ($action == 'create' || $action == 'adduserldap') // Login print '
    '.$langs->trans("Login").''; - if (! empty($ldap_login)) + if (!empty($ldap_login)) { print ''; print $ldap_login; } - elseif (! empty($ldap_loginsmb)) + elseif (!empty($ldap_loginsmb)) { print ''; print $ldap_loginsmb; @@ -845,59 +845,59 @@ if ($action == 'create' || $action == 'adduserldap') } print '
    '.$langs->trans("Password").''; - $valuetoshow=''; + $valuetoshow = ''; if (preg_match('/ldap/', $dolibarr_main_authentication)) { - $valuetoshow.=($valuetoshow?', ':'').$langs->trans("PasswordOfUserInLDAP"); + $valuetoshow .= ($valuetoshow ? ', ' : '').$langs->trans("PasswordOfUserInLDAP"); } if (preg_match('/http/', $dolibarr_main_authentication)) { - $valuetoshow.=($valuetoshow?', ':'').$langs->trans("HTTPBasicPassword"); + $valuetoshow .= ($valuetoshow ? ', ' : '').$langs->trans("HTTPBasicPassword"); } if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { - if (! empty($ldap_pass)) // For very old system comaptibilty. Now clear password can't be viewed from LDAP read + if (!empty($ldap_pass)) // For very old system comaptibilty. Now clear password can't be viewed from LDAP read { - $valuetoshow.= ($valuetoshow?', ':'').''; // Dolibarr password is preffiled with LDAP known password - $valuetoshow.= preg_replace('/./i', '*', $ldap_pass); + $valuetoshow .= ($valuetoshow ? ', ' : '').''; // Dolibarr password is preffiled with LDAP known password + $valuetoshow .= preg_replace('/./i', '*', $ldap_pass); } else { // We do not use a field password but a field text to show new password to use. - $valuetoshow.= ($valuetoshow?', ':'').''; + $valuetoshow .= ($valuetoshow ? ', ' : '').''; } } // Other form for user password - $parameters=array('valuetoshow' => $valuetoshow, 'password' => $password); - $reshook=$hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) $valuetoshow=$hookmanager->resPrint; // to replace - else $valuetoshow.=$hookmanager->resPrint; // to add + $parameters = array('valuetoshow' => $valuetoshow, 'password' => $password); + $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) $valuetoshow = $hookmanager->resPrint; // to replace + else $valuetoshow .= $hookmanager->resPrint; // to add print $valuetoshow; print '
    '.$langs->trans("ApiKey").''; print ''; - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); print '
    '.$langs->trans("Administrator").''; print $form->selectyesno('admin', GETPOST('admin'), 1); - if (! empty($conf->multicompany->enabled) && ! $user->entity) + if (!empty($conf->multicompany->enabled) && !$user->entity) { - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print ''; } - $checked=(GETPOST('superadmin', 'int')?' checked':''); - $disabled=(GETPOST('superadmin', 'int')?'':' disabled'); + $checked = (GETPOST('superadmin', 'int') ? ' checked' : ''); + $disabled = (GETPOST('superadmin', 'int') ? '' : ' disabled'); print ' '.$langs->trans("SuperAdministrator"); } print "
    '.$langs->trans("Gender").''; - $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1); print '
    '.$langs->trans('Employee').''; - print $form->selectyesno("employee", (GETPOST('employee')!=''?GETPOST('employee'):$defaultemployee), 1); + print $form->selectyesno("employee", (GETPOST('employee') != '' ?GETPOST('employee') : $defaultemployee), 1); print '
    '; $text = $langs->trans("ForceUserExpenseValidator"); @@ -994,7 +994,7 @@ if ($action == 'create' || $action == 'adduserldap') } // Holiday request validator - if(!empty($conf->holiday->enabled)) + if (!empty($conf->holiday->enabled)) { print '
    '; $text = $langs->trans("ForceUserHolidayValidator"); @@ -1018,17 +1018,17 @@ if ($action == 'create' || $action == 'adduserldap') // Zip print '
    '.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).''; - print $formcompany->select_ziptown($object->zip, 'zipcode', array('town','selectcountry_id','state_id'), 6); + print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print '
    '.$form->editfieldkey('Town', 'town', '', $object, 0).''; - print $formcompany->select_ziptown($object->town, 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
    '.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).''; - print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id)); + print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id)); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
    '.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").''; - if (! empty($ldap_phone)) + if (!empty($ldap_phone)) { print ''; print $ldap_phone; @@ -1057,7 +1057,7 @@ if ($action == 'create' || $action == 'adduserldap') // Tel portable print '
    '.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").''; - if (! empty($ldap_mobile)) + if (!empty($ldap_mobile)) { print ''; print $ldap_mobile; @@ -1071,7 +1071,7 @@ if ($action == 'create' || $action == 'adduserldap') // Fax print '
    '.img_picto('', 'object_phoning_fax').' '.$langs->trans("Fax").''; - if (! empty($ldap_fax)) + if (!empty($ldap_fax)) { print ''; print $ldap_fax; @@ -1083,9 +1083,9 @@ if ($action == 'create' || $action == 'adduserldap') print '
    '; - if (! empty($ldap_mail)) + if (!empty($ldap_mail)) { print ''; print $ldap_mail; @@ -1096,12 +1096,12 @@ if ($action == 'create' || $action == 'adduserldap') } print '
    '.$langs->trans($value['label']).''; - if (! empty($ldap_social[$key])) { + if (!empty($ldap_social[$key])) { print ''; print $ldap_social[$key]; } else { @@ -1110,7 +1110,7 @@ if ($action == 'create' || $action == 'adduserldap') print '
    '.$langs->trans("ColorUser").''; - print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); + print $formother->selectColor(GETPOST('color') ?GETPOST('color') : $object->color, 'color', null, 1, '', 'hideifnotset'); print '
    ' . $form->editfieldkey('Categories', 'usercats', '', $object, 0) . ''; + print '
    '.$form->editfieldkey('Categories', 'usercats', '', $object, 0).''; $cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1); print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null, null, '90%'); print "
    '.$langs->trans("Entity").'".$mc->select_entities($conf->entity); @@ -1233,8 +1233,8 @@ if ($action == 'create' || $action == 'adduserldap') } // Other attributes - $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1246,7 +1246,7 @@ if ($action == 'create' || $action == 'adduserldap') print $langs->trans("Note"); print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note', '', '', 120, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%'); + $doleditor = new DolEditor('note', '', '', 120, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%'); $doleditor->Create(); print "
    '.$langs->trans("Signature").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1, ROWS_4, '90%'); + $doleditor = new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); print $doleditor->Create(1); print '
    '.$langs->trans("DefaultWarehouse").''; print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); @@ -1278,14 +1278,14 @@ if ($action == 'create' || $action == 'adduserldap') print ''; print '
    '; - $text=$langs->trans("THM"); + $text = $langs->trans("THM"); print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm'); print ''; @@ -1295,7 +1295,7 @@ if ($action == 'create' || $action == 'adduserldap') // TJM print '
    '; - $text=$langs->trans("TJM"); + $text = $langs->trans("TJM"); print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm'); print ''; @@ -1363,7 +1363,7 @@ else { $object->fetch($id, '', '', 1); if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); // Check if user has rights if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) @@ -1374,15 +1374,15 @@ else // Connexion ldap // pour recuperer passDoNotExpire et userChangePassNextLogon - if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) + if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) { $ldap = new Ldap(); - $result=$ldap->connect_bind(); + $result = $ldap->connect_bind(); if ($result > 0) { $userSearchFilter = '('.$conf->global->LDAP_FILTER_CONNECTION.'('.$ldap->getUserIdentifier().'='.$object->login.'))'; $entries = $ldap->fetch($object->login, $userSearchFilter); - if (! $entries) + if (!$entries) { setEventMessages($ldap->error, $ldap->errors, 'errors'); } @@ -1492,7 +1492,7 @@ else // Login print '
    '.$langs->trans("Login").''.$langs->trans("LoginAccountDisableInDolibarr").'
    '.$langs->trans("Password").''; - $valuetoshow=''; + $valuetoshow = ''; if (preg_match('/ldap/', $dolibarr_main_authentication)) { - if (! empty($object->ldap_sid)) + if (!empty($object->ldap_sid)) { if ($passDoNotExpire) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("LdapUacf_".$statutUACF); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("LdapUacf_".$statutUACF); } - elseif($userChangePassNextLogon) + elseif ($userChangePassNextLogon) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').''.$langs->trans("UserMustChangePassNextLogon", $ldap->domainFQDN).''; + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("UserMustChangePassNextLogon", $ldap->domainFQDN).''; } - elseif($userDisabled) + elseif ($userDisabled) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').''.$langs->trans("LdapUacf_".$statutUACF, $ldap->domainFQDN).''; + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("LdapUacf_".$statutUACF, $ldap->domainFQDN).''; } else { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("PasswordOfUserInLDAP"); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); } } else { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("PasswordOfUserInLDAP"); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); } } if (preg_match('/http/', $dolibarr_main_authentication)) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("HTTPBasicPassword"); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("HTTPBasicPassword"); } if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { - if ($object->pass) $valuetoshow.= ($valuetoshow?(' '.$langs->trans("or").' '):'').preg_replace('/./i', '*', $object->pass); + if ($object->pass) $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); else { - if ($user->admin) $valuetoshow.= ($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("Crypted").': '.$object->pass_indatabase_crypted; - else $valuetoshow.= ($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("Hidden"); + if ($user->admin) $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("Crypted").': '.$object->pass_indatabase_crypted; + else $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("Hidden"); } } // Other form for user password - $parameters=array('valuetoshow' => $valuetoshow); - $reshook=$hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) $valuetoshow=$hookmanager->resPrint; // to replace - else $valuetoshow.=$hookmanager->resPrint; // to add + $parameters = array('valuetoshow' => $valuetoshow); + $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) $valuetoshow = $hookmanager->resPrint; // to replace + else $valuetoshow .= $hookmanager->resPrint; // to add print $valuetoshow; print "
    '.$langs->trans("ApiKey").''; - if (! empty($object->api_key)) print preg_replace('/./', '*', $object->api_key); + if (!empty($object->api_key)) print preg_replace('/./', '*', $object->api_key); print '
    '.$langs->trans("Administrator").''; - if (! empty($conf->multicompany->enabled) && $object->admin && ! $object->entity) + if (!empty($conf->multicompany->enabled) && $object->admin && !$object->entity) { print $form->textwithpicto(yn($object->admin), $langs->trans("SuperAdministratorDesc"), 1, "superadmin"); } @@ -1583,11 +1583,11 @@ else // Type print '
    '; - $text=$langs->trans("Type"); + $text = $langs->trans("Type"); print $form->textwithpicto($text, $langs->trans("InternalExternalDesc")); print ''; - $type=$langs->trans("Internal"); - if ($object->societe_id > 0) $type=$langs->trans("External"); + $type = $langs->trans("Internal"); + if ($object->societe_id > 0) $type = $langs->trans("External"); print $type; if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; print '
    '; if (empty($object->fk_user)) print $langs->trans("None"); else { - $huser=new User($db); + $huser = new User($db); $huser->fetch($object->fk_user); print $huser->getNomUrl(1); } @@ -1631,8 +1631,8 @@ else print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print ''; - if (! empty($object->fk_user_expense_validator)) { - $evuser=new User($db); + if (!empty($object->fk_user_expense_validator)) { + $evuser = new User($db); $evuser->fetch($object->fk_user_expense_validator); print $evuser->getNomUrl(1); } @@ -1645,8 +1645,8 @@ else print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print ''; - if (! empty($object->fk_user_holiday_validator)) { - $hvuser=new User($db); + if (!empty($object->fk_user_holiday_validator)) { + $hvuser = new User($db); $hvuser->fetch($object->fk_user_holiday_validator); print $hvuser->getNomUrl(1); } @@ -1654,10 +1654,10 @@ else print "
    '.$langs->trans("DefaultWarehouse").''; print $warehousestatic->getNomUrl(); @@ -1671,8 +1671,8 @@ else //$childids = $user->getAllChildIds(1); - if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) - || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) + || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { // Even a superior can't see this info of its subordinates wihtout $user->rights->salaries->read and $user->rights->hrm->employee->read (setting/viewing is reserverd to HR people). // However, he can see the valuation of timesheet of its subordinates even without these permissions. @@ -1680,28 +1680,28 @@ else // THM print '
    '; - $text=$langs->trans("THM"); + $text = $langs->trans("THM"); print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm'); print ''; - print ($object->thm!=''?price($object->thm, '', $langs, 1, -1, -1, $conf->currency):''); + print ($object->thm != '' ?price($object->thm, '', $langs, 1, -1, -1, $conf->currency) : ''); print '
    '; - $text=$langs->trans("TJM"); + $text = $langs->trans("TJM"); print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm'); print ''; - print ($object->tjm!=''?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency):''); + print ($object->tjm != '' ?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency) : ''); print '
    '.$langs->trans("Salary").''; - print ($object->salary!=''?price($object->salary, '', $langs, 1, -1, -1, $conf->currency):''); + print ($object->salary != '' ?price($object->salary, '', $langs, 1, -1, -1, $conf->currency) : ''); print '
    '; // Color user - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { print ''; print ''; + print ''; print ''; } - if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) + if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) { print ''; print ''; @@ -1784,14 +1784,14 @@ else print "\n"; // Multicompany - if (! empty($conf->multicompany->enabled) && is_object($mc)) + if (!empty($conf->multicompany->enabled) && is_object($mc)) { // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module - if (! method_exists($mc, 'formObjectOptions')) + if (!method_exists($mc, 'formObjectOptions')) { - if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { - print ''; print ''; print ''; print ''; // LDAP reading -$ldap=new Ldap(); -$result=$ldap->connect_bind(); +$ldap = new Ldap(); +$result = $ldap->connect_bind(); if ($result > 0) { - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info, 1); + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; $records = $ldap->getAttribute($dn, $search); @@ -161,15 +161,15 @@ if ($result > 0) //print_r($records); // Show tree - if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { - if (! is_array($records)) + if (!is_array($records)) { print ''; } else { - $result=show_ldap_content($records, 0, $records['count'], true); + $result = show_ldap_content($records, 0, $records['count'], true); } } else diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 4e77cd09f39..4dce2533bdc 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -22,7 +22,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -86,9 +86,9 @@ class BOM extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'noteditable'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'1',), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), @@ -158,7 +158,7 @@ class BOM extends CommonObject /** * @var array List of child tables. To know object to delete on cascade. */ - protected $childtablesoncascade=array('bom_bomline'); + protected $childtablesoncascade = array('bom_bomline'); /** * @var BOMLine[] Array of subtable lines @@ -178,11 +178,11 @@ class BOM extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -191,13 +191,13 @@ class BOM extends CommonObject } // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (is_array($val['arrayofkeyval'])) { - foreach($val['arrayofkeyval'] as $key2 => $val2) + foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } } @@ -237,7 +237,7 @@ class BOM extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); // Get lines so they will be clone //foreach($object->lines as $line) @@ -249,18 +249,18 @@ class BOM extends CommonObject unset($object->import_key); // Clear fields - $object->ref = empty($this->fields['ref']['default']) ? $langs->trans("copy_of_").$object->ref: $this->fields['ref']['default']; - $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->ref = empty($this->fields['ref']['default']) ? $langs->trans("copy_of_").$object->ref : $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($object->table_element); - foreach($object->array_options as $key => $option) + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); @@ -277,7 +277,7 @@ class BOM extends CommonObject $this->errors = $object->errors; } - if (! $error) + if (!$error) { // copy internal contacts if ($this->copy_linked_contact($object, 'internal') < 0) @@ -286,7 +286,7 @@ class BOM extends CommonObject } } - if (! $error) + if (!$error) { // copy external contacts if same company if (property_exists($this, 'socid') && $this->socid == $object->socid) @@ -322,7 +322,7 @@ class BOM extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); return $result; } @@ -333,7 +333,7 @@ class BOM extends CommonObject */ public function fetchLines() { - $this->lines=array(); + $this->lines = array(); $result = $this->fetchLinesCommon(); return $result; @@ -356,40 +356,40 @@ class BOM extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $records=array(); + $records = array(); $sql = 'SELECT '; $sql .= $this->getFieldList(); - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($this->ismultientitymanaged) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; else $sql .= ' WHERE 1 = 1'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key=='t.rowid') { - $sqlwhere[] = $key . '='. $value; + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; } - elseif ($key=='customsql') { + elseif ($key == 'customsql') { $sqlwhere[] = $value; } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } if (count($sqlwhere) > 0) { - $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -407,8 +407,8 @@ class BOM extends CommonObject return $records; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } @@ -472,21 +472,21 @@ class BOM extends CommonObject global $langs, $conf; $langs->load("mrp"); - if (! empty($conf->global->BOM_ADDON)) + if (!empty($conf->global->BOM_ADDON)) { - $mybool=false; + $mybool = false; $file = $conf->global->BOM_ADDON.".php"; $classname = $conf->global->BOM_ADDON; // Include file with class - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/bom/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } if ($mybool === false) @@ -504,7 +504,7 @@ class BOM extends CommonObject } else { - $this->error=$obj->error; + $this->error = $obj->error; //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } @@ -529,7 +529,7 @@ class BOM extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; // Protection if ($this->statut == self::STATUS_VALIDATED) @@ -546,12 +546,12 @@ class BOM extends CommonObject return -1; }*/ - $now=dol_now(); + $now = dol_now(); $this->db->begin(); // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $this->fetch_product(); $num = $this->getNextNumRef($this->product); @@ -564,30 +564,30 @@ class BOM extends CommonObject // Validate $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->db->escape($num)."',"; - $sql.= " status = ".self::STATUS_VALIDATED.","; - $sql.= " date_valid='".$this->db->idate($now)."',"; - $sql.= " fk_user_valid = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " status = ".self::STATUS_VALIDATED.","; + $sql .= " date_valid='".$this->db->idate($now)."',"; + $sql .= " fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::validate()", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { dol_print_error($this->db); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BOM_VALIDATE', $user); + $result = $this->call_trigger('BOM_VALIDATE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -595,17 +595,17 @@ class BOM extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'bom/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'bom/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'bom/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'bom/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->bom->dir_output.'/'.$oldref; $dirdest = $conf->bom->dir_output.'/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); @@ -613,13 +613,13 @@ class BOM extends CommonObject { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->bom->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->bom->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -628,13 +628,13 @@ class BOM extends CommonObject } // Set new ref and current status - if (! $error) + if (!$error) { $this->ref = $num; $this->status = self::STATUS_VALIDATED; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -738,34 +738,34 @@ class BOM extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = '' . $langs->trans("BillOfMaterials") . ''; - $label.= '
    '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("BillOfMaterials").''; + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/bom/bom_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowBillOfMaterials"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowBillOfMaterials"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('bomdao')); @@ -774,22 +774,22 @@ class BOM extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('bomdao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -842,10 +842,10 @@ class BOM extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -856,7 +856,7 @@ class BOM extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -870,7 +870,7 @@ class BOM extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); @@ -893,7 +893,7 @@ class BOM extends CommonObject */ public function getLinesArray() { - $this->lines=array(); + $this->lines = array(); $objectline = new BOMLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_bom = '.$this->id)); @@ -924,16 +924,16 @@ class BOM extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("mrp"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'standard'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->BOM_ADDON_PDF)) { + } elseif (!empty($conf->global->BOM_ADDON_PDF)) { $modele = $conf->global->BOM_ADDON_PDF; } } @@ -972,7 +972,7 @@ class BOM extends CommonObject $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; dol_syslog(__METHOD__, LOG_DEBUG); @@ -1043,7 +1043,7 @@ class BOMLine extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'LineID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'fk_bom' => array('type'=>'integer:BillOfMaterials:societe/class/bom.class.php', 'label'=>'BillOfMaterials', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1,), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), @@ -1079,11 +1079,11 @@ class BOMLine extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -1092,13 +1092,13 @@ class BOMLine extends CommonObject } // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (is_array($val['arrayofkeyval'])) { - foreach($val['arrayofkeyval'] as $key2 => $val2) + foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } } @@ -1149,40 +1149,40 @@ class BOMLine extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $records=array(); + $records = array(); $sql = 'SELECT '; $sql .= $this->getFieldList(); - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($this->ismultientitymanaged) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; else $sql .= ' WHERE 1 = 1'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key=='t.rowid') { - $sqlwhere[] = $key . '='. $value; + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; } - elseif ($key=='customsql') { + elseif ($key == 'customsql') { $sqlwhere[] = $value; } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } if (count($sqlwhere) > 0) { - $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -1200,8 +1200,8 @@ class BOMLine extends CommonObject return $records; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } @@ -1248,34 +1248,34 @@ class BOMLine extends CommonObject { global $db, $conf, $langs, $hookmanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = '' . $langs->trans("BillOfMaterialsLine") . ''; - $label.= '
    '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("BillOfMaterialsLine").''; + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/bom/bomline_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowBillOfMaterialsLine"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowBillOfMaterialsLine"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('bomlinedao')); @@ -1284,22 +1284,22 @@ class BOMLine extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('bomlinedao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -1340,10 +1340,10 @@ class BOMLine extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -1354,7 +1354,7 @@ class BOMLine extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -1368,7 +1368,7 @@ class BOMLine extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 391d4df5cb5..ce582040ac9 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -29,14 +29,14 @@ // $upload_dir must be defined (example $conf->projet->dir_output . "/";) // $hidedetails, $hidedesc, $hideref and $moreparams may have been set or not. -if (!empty($permissioncreate) && empty($permissiontoadd)) $permissiontoadd = $permissioncreate; // For backward compatibility +if (!empty($permissioncreate) && empty($permissiontoadd)) $permissiontoadd = $permissioncreate; // For backward compatibility // Build doc if ($action == 'builddoc' && $permissiontoadd) { if (is_numeric(GETPOST('model', 'alpha'))) { - $error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); + $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); } else { @@ -61,34 +61,34 @@ if ($action == 'builddoc' && $permissiontoadd) if (GETPOST('fk_bank', 'int')) { // this field may come from an external module $object->fk_bank = GETPOST('fk_bank', 'int'); - } elseif (! empty($object->fk_account)) { + } elseif (!empty($object->fk_account)) { $object->fk_bank = $object->fk_account; } //} $outputlangs = $langs; - $newlang=''; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang=$object->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang=$object->default_lang; // for thirdparty - if (! empty($newlang)) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // To be sure vars is defined - if (empty($hidedetails)) $hidedetails=0; - if (empty($hidedesc)) $hidedesc=0; - if (empty($hideref)) $hideref=0; - if (empty($moreparams)) $moreparams=null; + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; - $result= $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } else { @@ -98,7 +98,7 @@ if ($action == 'builddoc' && $permissiontoadd) $urltoredirect = $_SERVER['REQUEST_URI']; $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); - $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop + $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop header('Location: '.$urltoredirect.'#builddoc'); exit; @@ -110,10 +110,10 @@ if ($action == 'builddoc' && $permissiontoadd) // Delete file in doc form if ($action == 'remove_file' && $permissiontoadd) { - if (! empty($upload_dir)) { + if (!empty($upload_dir)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (empty($object->id) || ! $object->id > 0) + if (empty($object->id) || !$object->id > 0) { // Reload to get all modified line records and be ready for hooks $ret = $object->fetch($id); @@ -121,9 +121,9 @@ if ($action == 'remove_file' && $permissiontoadd) } $langs->load("other"); - $filetodelete=GETPOST('file', 'alpha'); - $file = $upload_dir . '/' . $filetodelete; - $ret=dol_delete_file($file, 0, 0, 0, $object); + $filetodelete = GETPOST('file', 'alpha'); + $file = $upload_dir.'/'.$filetodelete; + $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 54a2c5825b4..e0a30c271a2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -37,7 +37,7 @@ * This file contains all frequently used functions. */ -include_once DOL_DOCUMENT_ROOT .'/core/lib/json.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; /** @@ -53,10 +53,10 @@ include_once DOL_DOCUMENT_ROOT .'/core/lib/json.lib.php'; */ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) { - require_once DOL_DOCUMENT_ROOT ."/core/db/".$type.'.class.php'; + require_once DOL_DOCUMENT_ROOT."/core/db/".$type.'.class.php'; - $class='DoliDB'.ucfirst($type); - $dolidb=new $class($type, $host, $user, $pass, $name, $port); + $class = 'DoliDB'.ucfirst($type); + $dolidb = new $class($type, $host, $user, $pass, $name, $port); return $dolidb; } @@ -87,10 +87,10 @@ function getEntity($element, $shared = 1, $currentobject = null) } else { - $out=''; + $out = ''; $addzero = array('user', 'usergroup', 'c_email_templates', 'email_template', 'default_values'); - if (in_array($element, $addzero)) $out.= '0,'; - $out.= $conf->entity; + if (in_array($element, $addzero)) $out .= '0,'; + $out .= $conf->entity; return $out; } } @@ -135,9 +135,9 @@ function getBrowserInfo($user_agent) { include_once DOL_DOCUMENT_ROOT.'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php'; - $name='unknown'; - $version=''; - $os='unknown'; + $name = 'unknown'; + $version = ''; + $os = 'unknown'; $phone = ''; $detectmobile = new Mobile_Detect(null, $user_agent); @@ -168,22 +168,22 @@ function getBrowserInfo($user_agent) } // OS - if (preg_match('/linux/i', $user_agent)) { $os='linux'; } - elseif (preg_match('/macintosh/i', $user_agent)) { $os='macintosh'; } - elseif (preg_match('/windows/i', $user_agent)) { $os='windows'; } + if (preg_match('/linux/i', $user_agent)) { $os = 'linux'; } + elseif (preg_match('/macintosh/i', $user_agent)) { $os = 'macintosh'; } + elseif (preg_match('/windows/i', $user_agent)) { $os = 'windows'; } // Name - if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='firefox'; $version=$reg[2]; } - elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='edge'; $version=$reg[2]; } - elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name='chrome'; $version=$reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string - elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name='chrome'; } - elseif (preg_match('/iceweasel/i', $user_agent)) { $name='iceweasel'; } - elseif (preg_match('/epiphany/i', $user_agent)) { $name='epiphany'; } - elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='safari'; $version=$reg[2]; } // Safari is often present in string for mobile but its not. - elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='opera'; $version=$reg[2]; } - elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end - elseif (preg_match('/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end - elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name='lynxlinks'; $version=$reg[4]; } + if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'firefox'; $version = $reg[2]; } + elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'edge'; $version = $reg[2]; } + elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name = 'chrome'; $version = $reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string + elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name = 'chrome'; } + elseif (preg_match('/iceweasel/i', $user_agent)) { $name = 'iceweasel'; } + elseif (preg_match('/epiphany/i', $user_agent)) { $name = 'epiphany'; } + elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'safari'; $version = $reg[2]; } // Safari is often present in string for mobile but its not. + elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'opera'; $version = $reg[2]; } + elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end + elseif (preg_match('/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end + elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name = 'lynxlinks'; $version = $reg[4]; } if ($tablet) { $layout = 'tablet'; @@ -210,10 +210,10 @@ function getBrowserInfo($user_agent) */ function dol_shutdown() { - global $conf,$user,$langs,$db; - $disconnectdone=false; $depth=0; - if (is_object($db) && ! empty($db->connected)) { $depth=$db->transaction_opened; $disconnectdone=$db->close(); } - dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth)?' (Warn: db disconnection forced, transaction depth was '.$depth.')':''), (($disconnectdone && $depth)?LOG_WARNING:LOG_INFO)); + global $conf, $user, $langs, $db; + $disconnectdone = false; $depth = 0; + if (is_object($db) && !empty($db->connected)) { $depth = $db->transaction_opened; $disconnectdone = $db->close(); } + dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was '.$depth.')' : ''), (($disconnectdone && $depth) ?LOG_WARNING:LOG_INFO)); } /** @@ -253,7 +253,7 @@ function GETPOSTISSET($paramname) */ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $options = null, $noreplace = 0) { - global $mysoc,$user,$conf; + global $mysoc, $user, $conf; if (empty($paramname)) return 'BadFirstParameterForGETPOST'; if (empty($check)) @@ -263,10 +263,10 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti //var_dump(debug_backtrace()[0]); } - if (empty($method)) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); - elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:''; - elseif ($method==2) $out = isset($_POST[$paramname])?$_POST[$paramname]:''; - elseif ($method==3) $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:''); + if (empty($method)) $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : ''); + elseif ($method == 1) $out = isset($_GET[$paramname]) ? $_GET[$paramname] : ''; + elseif ($method == 2) $out = isset($_POST[$paramname]) ? $_POST[$paramname] : ''; + elseif ($method == 3) $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : ''); else return 'BadThirdParameterForGETPOST'; if (empty($method) || $method == 3 || $method == 4) @@ -281,41 +281,41 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti // Code for search criteria persistence. // Retrieve values if restore_lastsearch_values - if (! empty($_GET['restore_lastsearch_values'])) // Use $_GET here and not GETPOST + if (!empty($_GET['restore_lastsearch_values'])) // Use $_GET here and not GETPOST { - if (! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // If there is saved values + if (!empty($_SESSION['lastsearch_values_'.$relativepathstring])) // If there is saved values { - $tmp=json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true); + $tmp = json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true); if (is_array($tmp)) { - foreach($tmp as $key => $val) + foreach ($tmp as $key => $val) { if ($key == $paramname) // We are on the requested parameter { - $out=$val; + $out = $val; break; } } } } // If there is saved contextpage, page or limit - if ($paramname == 'contextpage' && ! empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) + if ($paramname == 'contextpage' && !empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) { $out = $_SESSION['lastsearch_contextpage_'.$relativepathstring]; } - elseif ($paramname == 'page' && ! empty($_SESSION['lastsearch_page_'.$relativepathstring])) + elseif ($paramname == 'page' && !empty($_SESSION['lastsearch_page_'.$relativepathstring])) { $out = $_SESSION['lastsearch_page_'.$relativepathstring]; } - elseif ($paramname == 'limit' && ! empty($_SESSION['lastsearch_limit_'.$relativepathstring])) + elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_'.$relativepathstring])) { $out = $_SESSION['lastsearch_limit_'.$relativepathstring]; } } // Else, retreive default values if we are not doing a sort - elseif (! isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set + elseif (!isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set { - if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + if (!empty($_GET['action']) && $_GET['action'] == 'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { // Search default value from $object->field global $object; @@ -324,28 +324,28 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti $out = $object->fields[$paramname]['default']; } } - if (! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) + if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { - if (! empty($_GET['action']) && (preg_match('/^create/', $_GET['action']) || preg_match('/^presend/', $_GET['action'])) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + if (!empty($_GET['action']) && (preg_match('/^create/', $_GET['action']) || preg_match('/^presend/', $_GET['action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { // Now search in setup to overwrite default values - if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' + if (!empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' { if (isset($user->default_values[$relativepathstring]['createform'])) { - foreach($user->default_values[$relativepathstring]['createform'] as $defkey => $defval) + foreach ($user->default_values[$relativepathstring]['createform'] as $defkey => $defval) { $qualified = 0; if ($defkey != '_noquery_') { - $tmpqueryarraytohave=explode('&', $defkey); - $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); - $foundintru=0; - foreach($tmpqueryarraytohave as $tmpquerytohave) + $tmpqueryarraytohave = explode('&', $defkey); + $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + $foundintru = 0; + foreach ($tmpqueryarraytohave as $tmpquerytohave) { - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru = 1; } - if (! $foundintru) $qualified=1; + if (!$foundintru) $qualified = 1; //var_dump($defkey.'-'.$qualified); } else $qualified = 1; @@ -365,45 +365,45 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti } // Management of default search_filters and sort order //elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) - elseif (! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { - if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' + if (!empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' { //var_dump($user->default_values[$relativepathstring]); if ($paramname == 'sortfield' || $paramname == 'sortorder') // Sorted on which fields ? ASC or DESC ? { if (isset($user->default_values[$relativepathstring]['sortorder'])) // Even if paramname is sortfield, data are stored into ['sortorder...'] { - foreach($user->default_values[$relativepathstring]['sortorder'] as $defkey => $defval) + foreach ($user->default_values[$relativepathstring]['sortorder'] as $defkey => $defval) { $qualified = 0; if ($defkey != '_noquery_') { - $tmpqueryarraytohave=explode('&', $defkey); - $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); - $foundintru=0; - foreach($tmpqueryarraytohave as $tmpquerytohave) + $tmpqueryarraytohave = explode('&', $defkey); + $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + $foundintru = 0; + foreach ($tmpqueryarraytohave as $tmpquerytohave) { - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru = 1; } - if (! $foundintru) $qualified=1; + if (!$foundintru) $qualified = 1; //var_dump($defkey.'-'.$qualified); } else $qualified = 1; if ($qualified) { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , - foreach($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) + $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and , + foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) { - if ($out) $out.=', '; + if ($out) $out .= ', '; if ($paramname == 'sortfield') { - $out.=dol_string_nospecial($key, '', $forbidden_chars_to_replace); + $out .= dol_string_nospecial($key, '', $forbidden_chars_to_replace); } if ($paramname == 'sortorder') { - $out.=dol_string_nospecial($val, '', $forbidden_chars_to_replace); + $out .= dol_string_nospecial($val, '', $forbidden_chars_to_replace); } } //break; // No break for sortfield and sortorder so we can cumulate fields (is it realy usefull ?) @@ -413,19 +413,19 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti } elseif (isset($user->default_values[$relativepathstring]['filters'])) { - foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) // $defkey is a querystring like 'a=b&c=d', $defval is key of user + foreach ($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) // $defkey is a querystring like 'a=b&c=d', $defval is key of user { $qualified = 0; if ($defkey != '_noquery_') { - $tmpqueryarraytohave=explode('&', $defkey); - $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); - $foundintru=0; - foreach($tmpqueryarraytohave as $tmpquerytohave) + $tmpqueryarraytohave = explode('&', $defkey); + $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + $foundintru = 0; + foreach ($tmpqueryarraytohave as $tmpquerytohave) { - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru = 1; } - if (! $foundintru) $qualified=1; + if (!$foundintru) $qualified = 1; //var_dump($defkey.'-'.$qualified); } else $qualified = 1; @@ -437,13 +437,13 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti // We made a search from quick search menu, do we still use default filter ? if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , + $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and , $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); } } else { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , + $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and , $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); } break; @@ -459,22 +459,22 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti // Substitution variables for GETPOST (used to get final url with variable parameters or final default value with variable parameters) // Example of variables: __DAY__, __MONTH__, __YEAR__, __MYCOMPANY_COUNTRY_ID__, __USER_ID__, ... // We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text. - if (! is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) + if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) { - $maxloop=20; $loopnb=0; // Protection against infinite loop + $maxloop = 20; $loopnb = 0; // Protection against infinite loop while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side. { $loopnb++; $newout = ''; - if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; } - elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; } - elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; } - elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } - elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } - elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); } - elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } - elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } - elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); } + if ($reg[1] == 'DAY') { $tmp = dol_getdate(dol_now(), true); $newout = $tmp['mday']; } + elseif ($reg[1] == 'MONTH') { $tmp = dol_getdate(dol_now(), true); $newout = $tmp['mon']; } + elseif ($reg[1] == 'YEAR') { $tmp = dol_getdate(dol_now(), true); $newout = $tmp['year']; } + elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } + elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_prev_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } + elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp = dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); } + elseif ($reg[1] == 'NEXT_DAY') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } + elseif ($reg[1] == 'NEXT_MONTH') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_next_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } + elseif ($reg[1] == 'NEXT_YEAR') { $tmp = dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); } elseif ($reg[1] == 'MYCOMPANY_COUNTRY_ID' || $reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID') { $newout = $mysoc->country_id; @@ -491,7 +491,7 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti { $newout = $conf->entity; } - else $newout = ''; // Key not found, we replace with empty string + else $newout = ''; // Key not found, we replace with empty string //var_dump('__'.$reg[1].'__ -> '.$newout); $out = preg_replace('/__'.preg_quote($reg[1], '/').'__/', $newout, $out); } @@ -503,68 +503,68 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti case 'none': break; case 'int': // Check param is a numeric value (integer but also float or hexadecimal) - if (! is_numeric($out)) { $out=''; } + if (!is_numeric($out)) { $out = ''; } break; case 'intcomma': - if (preg_match('/[^0-9,-]+/i', $out)) $out=''; + if (preg_match('/[^0-9,-]+/i', $out)) $out = ''; break; case 'alpha': - if (! is_array($out)) + if (!is_array($out)) { - $out=trim($out); + $out = trim($out); // '"' is dangerous because param in url can close the href= or src= and add javascript functions. // '../' is dangerous because it allows dir transversals - if (preg_match('/"/', $out)) $out=''; - elseif (preg_match('/\.\.\//', $out)) $out=''; + if (preg_match('/"/', $out)) $out = ''; + elseif (preg_match('/\.\.\//', $out)) $out = ''; } break; case 'san_alpha': - $out=filter_var($out, FILTER_SANITIZE_STRING); + $out = filter_var($out, FILTER_SANITIZE_STRING); break; case 'aZ': - if (! is_array($out)) + if (!is_array($out)) { - $out=trim($out); - if (preg_match('/[^a-z]+/i', $out)) $out=''; + $out = trim($out); + if (preg_match('/[^a-z]+/i', $out)) $out = ''; } break; case 'aZ09': - if (! is_array($out)) + if (!is_array($out)) { - $out=trim($out); - if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) $out=''; + $out = trim($out); + if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) $out = ''; } break; case 'aZ09comma': // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh - if (! is_array($out)) + if (!is_array($out)) { - $out=trim($out); - if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) $out=''; + $out = trim($out); + if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) $out = ''; } break; case 'array': - if (! is_array($out) || empty($out)) $out=array(); + if (!is_array($out) || empty($out)) $out = array(); break; case 'nohtml': // Recommended for most scalar parameters - $out=dol_string_nohtmltag($out, 0); + $out = dol_string_nohtmltag($out, 0); break; case 'alphanohtml': // Recommended for search parameters - if (! is_array($out)) + if (!is_array($out)) { - $out=trim($out); + $out = trim($out); // '"' is dangerous because param in url can close the href= or src= and add javascript functions. // '../' is dangerous because it allows dir transversals - if (preg_match('/"/', $out)) $out=''; - elseif (preg_match('/\.\.\//', $out)) $out=''; - $out=dol_string_nohtmltag($out); + if (preg_match('/"/', $out)) $out = ''; + elseif (preg_match('/\.\.\//', $out)) $out = ''; + $out = dol_string_nohtmltag($out); } break; case 'restricthtml': // Recommended for most html textarea - $out=dol_string_onlythesehtmltags($out, 0); + $out = dol_string_onlythesehtmltags($out, 0); break; case 'custom': if (empty($filter)) return 'BadFourthParameterForGETPOST'; - $out=filter_var($out, $filter, $options); + $out = filter_var($out, $filter, $options); break; } @@ -572,7 +572,7 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti // Save data into session if key start with 'search_' or is 'smonth', 'syear', 'month', 'year' if (empty($method) || $method == 3 || $method == 4) { - if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder','sortfield'))) + if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder', 'sortfield'))) { //var_dump($paramname.' - '.$out.' '.$user->default_values[$relativepathstring]['filters'][$paramname]); @@ -582,7 +582,7 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti if ($out != '') // $out = '0' or 'abc', it is a search criteria to keep { - $user->lastsearch_values_tmp[$relativepathstring][$paramname]=$out; + $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out; } } } @@ -591,7 +591,7 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti } -if (! function_exists('dol_getprefix')) +if (!function_exists('dol_getprefix')) { /** * Return a prefix to use for this Dolibarr instance, for session/cookie names or email id. @@ -608,21 +608,21 @@ if (! function_exists('dol_getprefix')) // If prefix is for email if ($mode == 'email') { - if (! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended) + if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended) { if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; elseif (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"]; } // The recommended value (may be not defined for old versions) - if (! empty($conf->file->instance_unique_id)) return $conf->file->instance_unique_id; + if (!empty($conf->file->instance_unique_id)) return $conf->file->instance_unique_id; // For backward compatibility return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3'); } // The recommended value (may be not defined for old versions) - if (! empty($conf->file->instance_unique_id)) return $conf->file->instance_unique_id; + if (!empty($conf->file->instance_unique_id)) return $conf->file->instance_unique_id; // For backward compatibility if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) @@ -646,7 +646,7 @@ if (! function_exists('dol_getprefix')) */ function dol_include_once($relpath, $classname = '') { - global $conf,$langs,$user,$mysoc; // Do not remove this. They must be defined for files we include. Other globals var must be retreived with $GLOBALS['var'] + global $conf, $langs, $user, $mysoc; // Do not remove this. They must be defined for files we include. Other globals var must be retreived with $GLOBALS['var'] $fullpath = dol_buildpath($relpath); @@ -655,7 +655,7 @@ function dol_include_once($relpath, $classname = '') return false; } - if (! empty($classname) && ! class_exists($classname)) { + if (!empty($classname) && !class_exists($classname)) { return include $fullpath; } else { return include_once $fullpath; @@ -677,11 +677,11 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) { global $conf; - $path=preg_replace('/^\//', '', $path); + $path = preg_replace('/^\//', '', $path); if (empty($type)) // For a filesystem path { - $res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard default path + $res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard default path if (is_array($conf->file->dol_document_root)) { foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array("main"=>"/home/main/htdocs", "alt0"=>"/home/dirmod/htdocs", ...) @@ -692,14 +692,14 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) } if (file_exists($dirroot.'/'.$path)) { - $res=$dirroot.'/'.$path; + $res = $dirroot.'/'.$path; return $res; } } } if ($returnemptyifnotfound) // Not found into alternate dir { - if ($returnemptyifnotfound == 1 || ! file_exists($res)) return ''; + if ($returnemptyifnotfound == 1 || !file_exists($res)) return ''; } } else // For an url path @@ -708,9 +708,9 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) // Note that trying to know if a file on disk exist by forging path on disk from url // works only for some web server and some setup. This is bugged when // using proxy, rewriting, virtual path, etc... - $res=''; - if ($type == 1) $res = DOL_URL_ROOT.'/'.$path; // Standard value - if ($type == 2) $res = DOL_MAIN_URL_ROOT.'/'.$path; // Standard value + $res = ''; + if ($type == 1) $res = DOL_URL_ROOT.'/'.$path; // Standard value + if ($type == 2) $res = DOL_MAIN_URL_ROOT.'/'.$path; // Standard value if ($type == 3) $res = DOL_URL_ROOT.'/'.$path; foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...) @@ -722,38 +722,38 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) global $dolibarr_main_url_root; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $res=(preg_match('/^http/i', $conf->file->dol_url_root[$key])?'':$urlwithroot).'/'.$path; // Test on start with http is for old conf syntax + $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot).'/'.$path; // Test on start with http is for old conf syntax } continue; } - preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs); // Take part before '?' - if (! empty($regs[1])) + preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs); // Take part before '?' + if (!empty($regs[1])) { //print $key.'-'.$dirroot.'/'.$path.'-'.$conf->file->dol_url_root[$type].'
    '."\n"; if (file_exists($dirroot.'/'.$regs[1])) { if ($type == 1) { - $res=(preg_match('/^http/i', $conf->file->dol_url_root[$key])?'':DOL_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; + $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; } if ($type == 2) { - $res=(preg_match('/^http/i', $conf->file->dol_url_root[$key])?'':DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; + $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; } if ($type == 3) { global $dolibarr_main_url_root; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $res=(preg_match('/^http/i', $conf->file->dol_url_root[$key])?'':$urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax + $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax } break; } @@ -778,11 +778,11 @@ function dol_clone($object, $native = 0) { if (empty($native)) { - $myclone=unserialize(serialize($object)); + $myclone = unserialize(serialize($object)); } else { - $myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable) + $myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable) } return $myclone; @@ -822,7 +822,7 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1) // Char '>' '<' '|' '$' and ';' are special chars for shells. // Char '/' and '\' are file delimiters. $filesystem_forbidden_chars = array('<', '>', '/', '\\', '?', '*', '|', '"', ':', '°', '$', ';'); - return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars); + return dol_string_nospecial($unaccent ?dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars); } /** @@ -837,8 +837,8 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1) */ function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1) { - $filesystem_forbidden_chars = array('<','>','?','*','|','"','°'); - return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars); + $filesystem_forbidden_chars = array('<', '>', '?', '*', '|', '"', '°'); + return dol_string_nospecial($unaccent ?dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars); } /** @@ -856,21 +856,21 @@ function dol_string_unaccent($str) // See http://www.utf8-chartable.de/ $string = rawurlencode($str); $replacements = array( - '%C3%80' => 'A','%C3%81' => 'A','%C3%82' => 'A','%C3%83' => 'A','%C3%84' => 'A','%C3%85' => 'A', - '%C3%88' => 'E','%C3%89' => 'E','%C3%8A' => 'E','%C3%8B' => 'E', - '%C3%8C' => 'I','%C3%8D' => 'I','%C3%8E' => 'I','%C3%8F' => 'I', - '%C3%92' => 'O','%C3%93' => 'O','%C3%94' => 'O','%C3%95' => 'O','%C3%96' => 'O', - '%C3%99' => 'U','%C3%9A' => 'U','%C3%9B' => 'U','%C3%9C' => 'U', - '%C3%A0' => 'a','%C3%A1' => 'a','%C3%A2' => 'a','%C3%A3' => 'a','%C3%A4' => 'a','%C3%A5' => 'a', + '%C3%80' => 'A', '%C3%81' => 'A', '%C3%82' => 'A', '%C3%83' => 'A', '%C3%84' => 'A', '%C3%85' => 'A', + '%C3%88' => 'E', '%C3%89' => 'E', '%C3%8A' => 'E', '%C3%8B' => 'E', + '%C3%8C' => 'I', '%C3%8D' => 'I', '%C3%8E' => 'I', '%C3%8F' => 'I', + '%C3%92' => 'O', '%C3%93' => 'O', '%C3%94' => 'O', '%C3%95' => 'O', '%C3%96' => 'O', + '%C3%99' => 'U', '%C3%9A' => 'U', '%C3%9B' => 'U', '%C3%9C' => 'U', + '%C3%A0' => 'a', '%C3%A1' => 'a', '%C3%A2' => 'a', '%C3%A3' => 'a', '%C3%A4' => 'a', '%C3%A5' => 'a', '%C3%A7' => 'c', - '%C3%A8' => 'e','%C3%A9' => 'e','%C3%AA' => 'e','%C3%AB' => 'e', - '%C3%AC' => 'i','%C3%AD' => 'i','%C3%AE' => 'i','%C3%AF' => 'i', + '%C3%A8' => 'e', '%C3%A9' => 'e', '%C3%AA' => 'e', '%C3%AB' => 'e', + '%C3%AC' => 'i', '%C3%AD' => 'i', '%C3%AE' => 'i', '%C3%AF' => 'i', '%C3%B1' => 'n', - '%C3%B2' => 'o','%C3%B3' => 'o','%C3%B4' => 'o','%C3%B5' => 'o','%C3%B6' => 'o', - '%C3%B9' => 'u','%C3%BA' => 'u','%C3%BB' => 'u','%C3%BC' => 'u', + '%C3%B2' => 'o', '%C3%B3' => 'o', '%C3%B4' => 'o', '%C3%B5' => 'o', '%C3%B6' => 'o', + '%C3%B9' => 'u', '%C3%BA' => 'u', '%C3%BB' => 'u', '%C3%BC' => 'u', '%C3%BF' => 'y' ); - $string=strtr($string, $replacements); + $string = strtr($string, $replacements); return rawurldecode($string); } else @@ -909,9 +909,9 @@ function dol_string_unaccent($str) */ function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '') { - $forbidden_chars_to_replace=array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName - $forbidden_chars_to_remove=array(); - if (is_array($badcharstoreplace)) $forbidden_chars_to_replace=$badcharstoreplace; + $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName + $forbidden_chars_to_remove = array(); + if (is_array($badcharstoreplace)) $forbidden_chars_to_replace = $badcharstoreplace; //$forbidden_chars_to_remove=array("(",")"); return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove, "", $str)); @@ -929,13 +929,13 @@ function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '') function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0) { // escape quotes and backslashes, newlines, etc. - $substitjs=array("'"=>"\\'","\r"=>'\\r'); + $substitjs = array("'"=>"\\'", "\r"=>'\\r'); //$substitjs['"=>'',''=>'')); - if (! $keepn) $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); - return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags + $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags + if (!$keepb) $tmp = strtr($tmp, array(""=>'', ''=>'')); + if (!$keepn) $tmp = strtr($tmp, array("\r"=>'\\r', "\n"=>'\\n')); + return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags } @@ -1022,28 +1022,28 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = } } - if (! empty($message)) + if (!empty($message)) { // Test log level $logLevels = array(LOG_EMERG=>'EMERG', LOG_ALERT=>'ALERT', LOG_CRIT=>'CRITICAL', LOG_ERR=>'ERR', LOG_WARNING=>'WARN', LOG_NOTICE=>'NOTICE', LOG_INFO=>'INFO', LOG_DEBUG=>'DEBUG'); - if (! array_key_exists($level, $logLevels)) + if (!array_key_exists($level, $logLevels)) { throw new Exception('Incorrect log level'); } if ($level > $conf->global->SYSLOG_LEVEL) return; - $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log + $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log // If adding log inside HTML page is required - if ((! empty($_REQUEST['logtohtml']) && ! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML)) - || (! empty($user->rights->debugbar->read) && is_object($debugbar))) + if ((!empty($_REQUEST['logtohtml']) && !empty($conf->global->MAIN_ENABLE_LOG_TO_HTML)) + || (!empty($user->rights->debugbar->read) && is_object($debugbar))) { $conf->logbuffer[] = dol_print_date(time(), "%Y-%m-%d %H:%M:%S")." ".$logLevels[$level]." ".$message; } //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output // If html log tag enabled and url parameter log defined, we show output log on HTML comments - if (! empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && ! empty($_GET["log"])) + if (!empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET["log"])) { print "\n\n'; - if ((! empty($title) && $showtitle) || $morehtmlright || ! empty($links)) { - $out.= '
    '."\n"; + if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) { + $out .= '
    '."\n"; } // Show right part - if ($morehtmlright) $out.='
    '.$morehtmlright.'
    '; // Output right area first so when space is missing, text is in front of tabs and not under. + if ($morehtmlright) $out .= '
    '.$morehtmlright.'
    '; // Output right area first so when space is missing, text is in front of tabs and not under. // Show title - if (! empty($title) && $showtitle) + if (!empty($title) && $showtitle) { - $limittitle=30; - $out.=''; - if ($picto) $out.=img_picto($title, ($pictoisfullpath?'':'object_').$picto, '', $pictoisfullpath).' '; - $out.=''.dol_trunc($title, $limittitle).''; - $out.=''; + $limittitle = 30; + $out .= ''; + if ($picto) $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_').$picto, '', $pictoisfullpath).' '; + $out .= ''.dol_trunc($title, $limittitle).''; + $out .= ''; } // Show tabs // Define max of key (max may be higher than sizeof because of hole due to module disabling some tabs). - $maxkey=-1; - if (is_array($links) && ! empty($links)) + $maxkey = -1; + if (is_array($links) && !empty($links)) { - $keys=array_keys($links); - if (count($keys)) $maxkey=max($keys); + $keys = array_keys($links); + if (count($keys)) $maxkey = max($keys); } - if (! empty($conf->dol_optimize_smallscreen)) $conf->global->MAIN_MAXTABS_IN_CARD=2; + if (!empty($conf->dol_optimize_smallscreen)) $conf->global->MAIN_MAXTABS_IN_CARD = 2; // Show tabs // if =0 we don't use the feature - $limittoshow=(empty($conf->global->MAIN_MAXTABS_IN_CARD)?99:$conf->global->MAIN_MAXTABS_IN_CARD); - $displaytab=0; - $nbintab=0; - $popuptab=0; - $outmore=''; - for ($i = 0 ; $i <= $maxkey ; $i++) + $limittoshow = (empty($conf->global->MAIN_MAXTABS_IN_CARD) ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD); + $displaytab = 0; + $nbintab = 0; + $popuptab = 0; + $outmore = ''; + for ($i = 0; $i <= $maxkey; $i++) { - if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2])) { + if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) { // If active tab is already present if ($i >= $limittoshow) $limittoshow--; } } - for ($i = 0 ; $i <= $maxkey ; $i++) + for ($i = 0; $i <= $maxkey; $i++) { - if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2])) { - $isactive=true; + if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) { + $isactive = true; } else { - $isactive=false; + $isactive = false; } if ($i < $limittoshow || $isactive) { - $out.='
    '; + $out .= '
    '; if (isset($links[$i][2]) && $links[$i][2] == 'image') { if (!empty($links[$i][0])) { - $out.=''.$links[$i][1].''."\n"; + $out .= ''.$links[$i][1].''."\n"; } else { - $out.=''.$links[$i][1].''."\n"; + $out .= ''.$links[$i][1].''."\n"; } } - elseif (! empty($links[$i][1])) + elseif (!empty($links[$i][1])) { //print "x $i $active ".$links[$i][2]." z"; if ($isactive) { - $out.=''; - $out.=$links[$i][1]; - $out.=''."\n"; + $out .= ''; + $out .= $links[$i][1]; + $out .= ''."\n"; } else { - $out.=''; - $out.=$links[$i][1]; - $out.=''."\n"; + $out .= ''; + $out .= $links[$i][1]; + $out .= ''."\n"; } } - $out.='
    '; + $out .= '
    '; } else { // The popup with the other tabs - if (! $popuptab) + if (!$popuptab) { - $popuptab=1; - $outmore.='
    '; // The css used to hide/show popup + $popuptab = 1; + $outmore .= '
    '; // The css used to hide/show popup } - $outmore.='
    '; + $outmore .= '
    '; if (isset($links[$i][2]) && $links[$i][2] == 'image') { if (!empty($links[$i][0])) - $outmore.=''.$links[$i][1].''."\n"; + $outmore .= ''.$links[$i][1].''."\n"; else - $outmore.=''.$links[$i][1].''."\n"; + $outmore .= ''.$links[$i][1].''."\n"; } - elseif (! empty($links[$i][1])) + elseif (!empty($links[$i][1])) { - $outmore.=''; - $outmore.=preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts. - $outmore.=''."\n"; + $outmore .= ''; + $outmore .= preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts. + $outmore .= ''."\n"; } - $outmore.='
    '; + $outmore .= '
    '; $nbintab++; } - $displaytab=$i; + $displaytab = $i; } - if ($popuptab) $outmore.='
    '; + if ($popuptab) $outmore .= '
    '; if ($popuptab) // If there is some tabs not shown { - $left=($langs->trans("DIRECTION") == 'rtl'?'right':'left'); - $right=($langs->trans("DIRECTION") == 'rtl'?'left':'right'); + $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); + $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); - $tabsname=str_replace("@", "", $picto); - $out.='
    '; - $out.=''.$langs->trans("More").'... ('.$nbintab.')'; - $out.='
    '; - $out.=$outmore; - $out.='
    '; - $out.='
    '; - $out.="
    \n"; + $tabsname = str_replace("@", "", $picto); + $out .= '
    '; + $out .= ''.$langs->trans("More").'... ('.$nbintab.')'; + $out .= '
    '; + $out .= $outmore; + $out .= '
    '; + $out .= '
    '; + $out .= "
    \n"; - $out.=""; + $out .= ""; } - if ((! empty($title) && $showtitle) || $morehtmlright || ! empty($links)) { - $out.="
    \n"; + if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) { + $out .= "
    \n"; } - if (! $notab || $notab == -1 || $notab == -2) $out.="\n".'
    '."\n"; + if (!$notab || $notab == -1 || $notab == -2) $out .= "\n".'
    '."\n"; - $parameters=array('tabname' => $active, 'out' => $out); - $reshook=$hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead" + $parameters = array('tabname' => $active, 'out' => $out); + $reshook = $hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead" if ($reshook > 0) { $out = $hookmanager->resPrint; @@ -1298,7 +1298,7 @@ function dol_fiche_end($notab = 0) */ function dol_get_fiche_end($notab = 0) { - if (! $notab || $notab == -1) return "\n
    \n"; + if (!$notab || $notab == -1) return "\n
    \n"; else return ''; } @@ -1327,79 +1327,79 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $error = 0; - $maxvisiblephotos=1; - $showimage=1; - $entity=(empty($object->entity)?$conf->entity:$object->entity); - $showbarcode=empty($conf->barcode->enabled)?0:($object->barcode?1:0); - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; - $modulepart='unknown'; + $maxvisiblephotos = 1; + $showimage = 1; + $entity = (empty($object->entity) ? $conf->entity : $object->entity); + $showbarcode = empty($conf->barcode->enabled) ? 0 : ($object->barcode ? 1 : 0); + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0; + $modulepart = 'unknown'; - if ($object->element == 'societe') $modulepart='societe'; - if ($object->element == 'contact') $modulepart='contact'; - if ($object->element == 'member') $modulepart='memberphoto'; - if ($object->element == 'user') $modulepart='userphoto'; - if ($object->element == 'product') $modulepart='product'; - if ($object->element == 'ticket') $modulepart='ticket'; + if ($object->element == 'societe') $modulepart = 'societe'; + if ($object->element == 'contact') $modulepart = 'contact'; + if ($object->element == 'member') $modulepart = 'memberphoto'; + if ($object->element == 'user') $modulepart = 'userphoto'; + if ($object->element == 'product') $modulepart = 'product'; + if ($object->element == 'ticket') $modulepart = 'ticket'; if (class_exists("Imagick")) { - if ($object->element == 'propal') $modulepart='propal'; - if ($object->element == 'commande') $modulepart='commande'; - if ($object->element == 'facture') $modulepart='facture'; - if ($object->element == 'fichinter') $modulepart='ficheinter'; - if ($object->element == 'contrat') $modulepart='contract'; - if ($object->element == 'supplier_proposal') $modulepart='supplier_proposal'; - if ($object->element == 'order_supplier') $modulepart='supplier_order'; - if ($object->element == 'invoice_supplier') $modulepart='supplier_invoice'; - if ($object->element == 'expensereport') $modulepart='expensereport'; + if ($object->element == 'propal') $modulepart = 'propal'; + if ($object->element == 'commande') $modulepart = 'commande'; + if ($object->element == 'facture') $modulepart = 'facture'; + if ($object->element == 'fichinter') $modulepart = 'ficheinter'; + if ($object->element == 'contrat') $modulepart = 'contract'; + if ($object->element == 'supplier_proposal') $modulepart = 'supplier_proposal'; + if ($object->element == 'order_supplier') $modulepart = 'supplier_order'; + if ($object->element == 'invoice_supplier') $modulepart = 'supplier_invoice'; + if ($object->element == 'expensereport') $modulepart = 'expensereport'; } if ($object->element == 'product') { - $width=80; $cssclass='photoref'; - $showimage=$object->is_photo_available($conf->product->multidir_output[$entity]); - $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); - if ($conf->browser->layout == 'phone') $maxvisiblephotos=1; - if ($showimage) $morehtmlleft.='
    '.$object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0).'
    '; + $width = 80; $cssclass = 'photoref'; + $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]); + $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5); + if ($conf->browser->layout == 'phone') $maxvisiblephotos = 1; + if ($showimage) $morehtmlleft .= '
    '.$object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0).'
    '; else { if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) { - $nophoto=''; - $morehtmlleft.='
    '; + $nophoto = ''; + $morehtmlleft .= '
    '; } else { // Show no photo link - $nophoto='/public/theme/common/nophoto.png'; - $morehtmlleft.='
    No photo
    '; + $nophoto = '/public/theme/common/nophoto.png'; + $morehtmlleft .= '
    No photo
    '; } } } elseif ($object->element == 'ticket') { - $width=80; $cssclass='photoref'; - $showimage=$object->is_photo_available($conf->ticket->multidir_output[$entity].'/'.$object->ref); - $maxvisiblephotos=(isset($conf->global->TICKET_MAX_VISIBLE_PHOTO)?$conf->global->TICKET_MAX_VISIBLE_PHOTO:2); - if ($conf->browser->layout == 'phone') $maxvisiblephotos=1; + $width = 80; $cssclass = 'photoref'; + $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].'/'.$object->ref); + $maxvisiblephotos = (isset($conf->global->TICKET_MAX_VISIBLE_PHOTO) ? $conf->global->TICKET_MAX_VISIBLE_PHOTO : 2); + if ($conf->browser->layout == 'phone') $maxvisiblephotos = 1; if ($showimage) { $showphoto = $object->show_photos('ticket', $conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0); if ($object->nbphoto > 0) { - $morehtmlleft.='
    '.$showphoto.'
    '; + $morehtmlleft .= '
    '.$showphoto.'
    '; } else { $showimage = 0; } } - if (! $showimage) + if (!$showimage) { if (!empty($conf->global->TICKET_NODISPLAYIFNOPHOTO)) { - $nophoto=''; - $morehtmlleft.='
    '; + $nophoto = ''; + $morehtmlleft .= '
    '; } else { // Show no photo link - $nophoto='/public/theme/common/nophoto.png'; - $morehtmlleft.='
    No photo
    '; + $nophoto = '/public/theme/common/nophoto.png'; + $morehtmlleft .= '
    No photo
    '; } } } @@ -1409,26 +1409,26 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi { if ($modulepart != 'unknown') { - $phototoshow=''; + $phototoshow = ''; // Check if a preview file is available if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick")) { $objectref = dol_sanitizeFileName($object->ref); - $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]) . "/"; + $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity])."/"; if (in_array($modulepart, array('invoice_supplier', 'supplier_invoice'))) { $subdir = get_exdir($object->id, 2, 0, 1, $object, $modulepart); - $subdir.= ((! empty($subdir) && ! preg_match('/\/$/', $subdir))?'/':'').$objectref; // the objectref dir is not included into get_exdir when used with level=2, so we add it at end + $subdir .= ((!empty($subdir) && !preg_match('/\/$/', $subdir)) ? '/' : '').$objectref; // the objectref dir is not included into get_exdir when used with level=2, so we add it at end } else { $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart); } - if (empty($subdir)) $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path + if (empty($subdir)) $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path - $filepath = $dir_output . $subdir . "/"; + $filepath = $dir_output.$subdir."/"; - $filepdf = $filepath . $objectref . ".pdf"; + $filepdf = $filepath.$objectref.".pdf"; $relativepath = $subdir.'/'.$objectref.'.pdf'; // Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png") @@ -1441,159 +1441,159 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi if ($pdfexists) { // Conversion du PDF en image png si fichier png non existant - if (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) + if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) { if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experience trouble with pdf thumb generation and imagick, you can disable here. { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png + $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png if ($ret < 0) $error++; } } } - if ($pdfexists && ! $error) + if ($pdfexists && !$error) { - $heightforphotref=70; - if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60; + $heightforphotref = 70; + if (!empty($conf->dol_optimize_smallscreen)) $heightforphotref = 60; // If the preview file is found if (file_exists($fileimage)) { $phototoshow = '
    '; - $phototoshow.= ''; - $phototoshow.= '
    '; + $phototoshow .= ''; + $phototoshow .= ''; } } } - elseif (! $phototoshow) + elseif (!$phototoshow) { - $phototoshow.= $form->showphoto($modulepart, $object, 0, 0, 0, 'photoref', 'small', 1, 0, $maxvisiblephotos); + $phototoshow .= $form->showphoto($modulepart, $object, 0, 0, 0, 'photoref', 'small', 1, 0, $maxvisiblephotos); } if ($phototoshow) { - $morehtmlleft.='
    '; - $morehtmlleft.=$phototoshow; - $morehtmlleft.='
    '; + $morehtmlleft .= '
    '; + $morehtmlleft .= $phototoshow; + $morehtmlleft .= '
    '; } } - if (! $phototoshow) // Show No photo link (picto of pbject) + if (!$phototoshow) // Show No photo link (picto of pbject) { - $morehtmlleft.='
    '; + $morehtmlleft .= '
    '; if ($object->element == 'action') { - $width=80; - $cssclass='photorefcenter'; - $nophoto=img_picto('', 'title_agenda', '', false, 1); + $width = 80; + $cssclass = 'photorefcenter'; + $nophoto = img_picto('', 'title_agenda', '', false, 1); } else { - $width=14; $cssclass='photorefcenter'; + $width = 14; $cssclass = 'photorefcenter'; $picto = $object->picto; - if ($object->element == 'project' && ! $object->public) $picto = 'project'; // instead of projectpub - $nophoto=img_picto('', 'object_'.$picto, '', false, 1); + if ($object->element == 'project' && !$object->public) $picto = 'project'; // instead of projectpub + $nophoto = img_picto('', 'object_'.$picto, '', false, 1); } - $morehtmlleft.=''; - $morehtmlleft.='
    No photo
    '; + $morehtmlleft .= ''; + $morehtmlleft .= '
    No photo
    '; - $morehtmlleft.='
    '; + $morehtmlleft .= '
    '; } } } - if ($showbarcode) $morehtmlleft.='
    '.$form->showbarcode($object).'
    '; + if ($showbarcode) $morehtmlleft .= '
    '.$form->showbarcode($object).'
    '; if ($object->element == 'societe') { - if (! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) + if (!empty($conf->use_javascript_ajax) && $user->rights->societe->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - $morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); + $morehtmlstatus .= ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); } else { - $morehtmlstatus.=$object->getLibStatut(6); + $morehtmlstatus .= $object->getLibStatut(6); } } elseif ($object->element == 'product') { //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Sell").') '; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - $morehtmlstatus.=ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); + if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + $morehtmlstatus .= ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { - $morehtmlstatus.=''.$object->getLibStatut(6, 0).''; + $morehtmlstatus .= ''.$object->getLibStatut(6, 0).''; } - $morehtmlstatus.='   '; + $morehtmlstatus .= '   '; //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Buy").') '; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - $morehtmlstatus.=ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); + if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + $morehtmlstatus .= ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { - $morehtmlstatus.=''.$object->getLibStatut(6, 1).''; + $morehtmlstatus .= ''.$object->getLibStatut(6, 1).''; } } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) { - $tmptxt=$object->getLibStatut(6, $object->totalpaye); - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt=$object->getLibStatut(5, $object->totalpaye); - $morehtmlstatus.=$tmptxt; + $tmptxt = $object->getLibStatut(6, $object->totalpaye); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt = $object->getLibStatut(5, $object->totalpaye); + $morehtmlstatus .= $tmptxt; } elseif ($object->element == 'contrat' || $object->element == 'contract') { - if ($object->statut == 0) $morehtmlstatus.=$object->getLibStatut(5); - else $morehtmlstatus.=$object->getLibStatut(4); + if ($object->statut == 0) $morehtmlstatus .= $object->getLibStatut(5); + else $morehtmlstatus .= $object->getLibStatut(4); } elseif ($object->element == 'facturerec') { - if ($object->frequency == 0) $morehtmlstatus.=$object->getLibStatut(2); - else $morehtmlstatus.=$object->getLibStatut(5); + if ($object->frequency == 0) $morehtmlstatus .= $object->getLibStatut(2); + else $morehtmlstatus .= $object->getLibStatut(5); } elseif ($object->element == 'project_task') { $object->fk_statut = 1; if ($object->progress > 0) $object->fk_statut = 2; if ($object->progress >= 100) $object->fk_statut = 3; - $tmptxt=$object->getLibStatut(5); - $morehtmlstatus.=$tmptxt; // No status on task + $tmptxt = $object->getLibStatut(5); + $morehtmlstatus .= $tmptxt; // No status on task } else { // Generic case - $tmptxt=$object->getLibStatut(6); - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt=$object->getLibStatut(5); - $morehtmlstatus.=$tmptxt; + $tmptxt = $object->getLibStatut(6); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt = $object->getLibStatut(5); + $morehtmlstatus .= $tmptxt; } // Add if object was dispatched "into accountancy" - if (! empty($conf->accounting->enabled) && in_array($object->element, array('bank', 'facture', 'invoice', 'invoice_supplier', 'expensereport'))) + if (!empty($conf->accounting->enabled) && in_array($object->element, array('bank', 'facture', 'invoice', 'invoice_supplier', 'expensereport'))) { if (method_exists($object, 'getVentilExportCompta')) { $accounted = $object->getVentilExportCompta(); $langs->load("accountancy"); - $morehtmlstatus.='
    '.($accounted > 0 ? $langs->trans("Accounted") : ''.$langs->trans("NotYetAccounted").''); + $morehtmlstatus .= '
    '.($accounted > 0 ? $langs->trans("Accounted") : ''.$langs->trans("NotYetAccounted").''); } } // Add alias for thirdparty - if (! empty($object->name_alias)) $morehtmlref.='
    '.$object->name_alias.'
    '; + if (!empty($object->name_alias)) $morehtmlref .= '
    '.$object->name_alias.'
    '; // Add label if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') { - if (! empty($object->label)) $morehtmlref.='
    '.$object->label.'
    '; + if (!empty($object->label)) $morehtmlref .= '
    '.$object->label.'
    '; } if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') { - $morehtmlref.='
    '; - $morehtmlref.=$object->getBannerAddress('refaddress', $object); - $morehtmlref.='
    '; + $morehtmlref .= '
    '; + $morehtmlref .= $object->getBannerAddress('refaddress', $object); + $morehtmlref .= '
    '; } - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product'))) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product'))) { - $morehtmlref.='
    '; - $morehtmlref.=$langs->trans("TechnicalID").': '.$object->id; - $morehtmlref.='
    '; + $morehtmlref .= '
    '; + $morehtmlref .= $langs->trans("TechnicalID").': '.$object->id; + $morehtmlref .= '
    '; } - print '
    '; + print '
    '; print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright); print '
    '; print '
    '; @@ -1611,12 +1611,12 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi function fieldLabel($langkey, $fieldkey, $fieldrequired = 0) { global $langs; - $ret=''; - if ($fieldrequired) $ret.=''; - $ret.=''; - if ($fieldrequired) $ret.=''; + $ret = ''; + if ($fieldrequired) $ret .= ''; + $ret .= ''; + if ($fieldrequired) $ret .= ''; return $ret; } @@ -1630,8 +1630,8 @@ function fieldLabel($langkey, $fieldkey, $fieldrequired = 0) function dol_bc($var, $moreclass = '') { global $bc; - $ret=' '.$bc[$var]; - if ($moreclass) $ret=preg_replace('/class=\"/', 'class="'.$moreclass.' ', $ret); + $ret = ' '.$bc[$var]; + if ($moreclass) $ret = preg_replace('/class=\"/', 'class="'.$moreclass.' ', $ret); return $ret; } @@ -1648,63 +1648,63 @@ function dol_bc($var, $moreclass = '') */ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = '', $mode = 0) { - global $conf,$langs; + global $conf, $langs; - $ret=''; - $countriesusingstate=array('AU','CA','US','IN','GB','ES','UK','TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS + $ret = ''; + $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS // Address if (empty($mode)) { $ret .= $object->address; } // Zip/Town/State - if (in_array($object->country_code, array('AU', 'CA', 'US')) || ! empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) // US: title firstname name \n address lines \n town, state, zip \n country + if (in_array($object->country_code, array('AU', 'CA', 'US')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) // US: title firstname name \n address lines \n town, state, zip \n country { - $ret .= ($ret ? $sep : '' ).$object->town; + $ret .= ($ret ? $sep : '').$object->town; if ($object->state) { - $ret.=($ret?", ":'').$object->state; + $ret .= ($ret ? ", " : '').$object->state; } - if ($object->zip) $ret .= ($ret?", ":'').$object->zip; + if ($object->zip) $ret .= ($ret ? ", " : '').$object->zip; } - elseif (in_array($object->country_code, array('GB','UK'))) // UK: title firstname name \n address lines \n town state \n zip \n country + elseif (in_array($object->country_code, array('GB', 'UK'))) // UK: title firstname name \n address lines \n town state \n zip \n country { - $ret .= ($ret ? $sep : '' ).$object->town; + $ret .= ($ret ? $sep : '').$object->town; if ($object->state) { - $ret.=($ret?", ":'').$object->state; + $ret .= ($ret ? ", " : '').$object->state; } - if ($object->zip) $ret .= ($ret ? $sep : '' ).$object->zip; + if ($object->zip) $ret .= ($ret ? $sep : '').$object->zip; } - elseif (in_array($object->country_code, array('ES','TR'))) // ES: title firstname name \n address lines \n zip town \n state \n country + elseif (in_array($object->country_code, array('ES', 'TR'))) // ES: title firstname name \n address lines \n zip town \n state \n country { - $ret .= ($ret ? $sep : '' ).$object->zip; - $ret .= ($object->town?(($object->zip?' ':'').$object->town):''); + $ret .= ($ret ? $sep : '').$object->zip; + $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : ''); if ($object->state) { - $ret.="\n".$object->state; + $ret .= "\n".$object->state; } } elseif (in_array($object->country_code, array('IT'))) // IT: tile firstname name\n address lines \n zip (Code Departement) \n country { - $ret .= ($ret ? $sep : '' ).$object->zip; - $ret .= ($object->town?(($object->zip?' ':'').$object->town):''); - $ret .= ($object->state_id?(' ('.($object->state_id).')'):''); + $ret .= ($ret ? $sep : '').$object->zip; + $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : ''); + $ret .= ($object->state_id ? (' ('.($object->state_id).')') : ''); } else // Other: title firstname name \n address lines \n zip town \n country { - $ret .= $object->zip ? (($ret ? $sep : '' ).$object->zip) : ''; - $ret .= ($object->town?(($object->zip?' ':($ret ? $sep : '' )).$object->town):''); + $ret .= $object->zip ? (($ret ? $sep : '').$object->zip) : ''; + $ret .= ($object->town ? (($object->zip ? ' ' : ($ret ? $sep : '')).$object->town) : ''); if ($object->state && in_array($object->country_code, $countriesusingstate)) { - $ret.=($ret?", ":'').$object->state; + $ret .= ($ret ? ", " : '').$object->state; } } - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; if ($withcountry) { $langs->load("dict"); - $ret.=($object->country_code?($ret?$sep:'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)):''); + $ret .= ($object->country_code ? ($ret ? $sep : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)) : ''); } return $ret; @@ -1723,7 +1723,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs function dol_strftime($fmt, $ts = false, $is_gmt = false) { if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range - return ($is_gmt)? @gmstrftime($fmt, $ts): @strftime($fmt, $ts); + return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts); } else return 'Error date into a not supported range'; } @@ -1751,83 +1751,83 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false) */ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlangs = '', $encodetooutput = false) { - global $conf,$langs; + global $conf, $langs; // Clean parameters - $to_gmt=false; - $offsettz=$offsetdst=0; + $to_gmt = false; + $offsettz = $offsetdst = 0; if ($tzoutput) { - $to_gmt=true; // For backward compatibility + $to_gmt = true; // For backward compatibility if (is_string($tzoutput)) { if ($tzoutput == 'tzserver') { - $to_gmt=false; - $offsettzstring=@date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion' - $offsettz=0; - $offsetdst=0; + $to_gmt = false; + $offsettzstring = @date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion' + $offsettz = 0; + $offsetdst = 0; } elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') { - $to_gmt=true; - $offsettzstring=(empty($_SESSION['dol_tz_string'])?'UTC':$_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion' - $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; // Will not be used anymore - $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; // Will not be used anymore + $to_gmt = true; + $offsettzstring = (empty($_SESSION['dol_tz_string']) ? 'UTC' : $_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion' + $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore + $offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; // Will not be used anymore } } } - if (! is_object($outputlangs)) $outputlangs=$langs; - if (! $format) $format='daytextshort'; - $reduceformat=(! empty($conf->dol_optimize_smallscreen) && in_array($format, array('day','dayhour')))?1:0; + if (!is_object($outputlangs)) $outputlangs = $langs; + if (!$format) $format = 'daytextshort'; + $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0; $formatwithoutreduce = preg_replace('/reduceformat/', '', $format); - if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat=1; } // so format 'dayreduceformat' is processed like day + if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat = 1; } // so format 'dayreduceformat' is processed like day // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. // TODO Add format daysmallyear and dayhoursmallyear - if ($format == 'day') $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short); - elseif ($format == 'hour') $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short); - elseif ($format == 'hourduration') $format=($outputlangs->trans("FormatHourShortDuration")!="FormatHourShortDuration"?$outputlangs->trans("FormatHourShortDuration"):$conf->format_hour_short_duration); - elseif ($format == 'daytext') $format=($outputlangs->trans("FormatDateText")!="FormatDateText"?$outputlangs->trans("FormatDateText"):$conf->format_date_text); - elseif ($format == 'daytextshort') $format=($outputlangs->trans("FormatDateTextShort")!="FormatDateTextShort"?$outputlangs->trans("FormatDateTextShort"):$conf->format_date_text_short); - elseif ($format == 'dayhour') $format=($outputlangs->trans("FormatDateHourShort")!="FormatDateHourShort"?$outputlangs->trans("FormatDateHourShort"):$conf->format_date_hour_short); - elseif ($format == 'dayhoursec') $format=($outputlangs->trans("FormatDateHourSecShort")!="FormatDateHourSecShort"?$outputlangs->trans("FormatDateHourSecShort"):$conf->format_date_hour_sec_short); - elseif ($format == 'dayhourtext') $format=($outputlangs->trans("FormatDateHourText")!="FormatDateHourText"?$outputlangs->trans("FormatDateHourText"):$conf->format_date_hour_text); - elseif ($format == 'dayhourtextshort') $format=($outputlangs->trans("FormatDateHourTextShort")!="FormatDateHourTextShort"?$outputlangs->trans("FormatDateHourTextShort"):$conf->format_date_hour_text_short); + if ($format == 'day') $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short); + elseif ($format == 'hour') $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short); + elseif ($format == 'hourduration') $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration); + elseif ($format == 'daytext') $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text); + elseif ($format == 'daytextshort') $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : $conf->format_date_text_short); + elseif ($format == 'dayhour') $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short); + elseif ($format == 'dayhoursec') $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short); + elseif ($format == 'dayhourtext') $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text); + elseif ($format == 'dayhourtextshort') $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short); // Format not sensitive to language - elseif ($format == 'dayhourlog') $format='%Y%m%d%H%M%S'; - elseif ($format == 'dayhourldap') $format='%Y%m%d%H%M%SZ'; - elseif ($format == 'dayhourxcard') $format='%Y%m%dT%H%M%SZ'; - elseif ($format == 'dayxcard') $format='%Y%m%d'; - elseif ($format == 'dayrfc') $format='%Y-%m-%d'; // DATE_RFC3339 - elseif ($format == 'dayhourrfc') $format='%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 - elseif ($format == 'standard') $format='%Y-%m-%d %H:%M:%S'; + elseif ($format == 'dayhourlog') $format = '%Y%m%d%H%M%S'; + elseif ($format == 'dayhourldap') $format = '%Y%m%d%H%M%SZ'; + elseif ($format == 'dayhourxcard') $format = '%Y%m%dT%H%M%SZ'; + elseif ($format == 'dayxcard') $format = '%Y%m%d'; + elseif ($format == 'dayrfc') $format = '%Y-%m-%d'; // DATE_RFC3339 + elseif ($format == 'dayhourrfc') $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 + elseif ($format == 'standard') $format = '%Y-%m-%d %H:%M:%S'; if ($reduceformat) { - $format=str_replace('%Y', '%y', $format); - $format=str_replace('yyyy', 'yy', $format); + $format = str_replace('%Y', '%y', $format); + $format = str_replace('yyyy', 'yy', $format); } // If date undefined or "", we return "" - if (dol_strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) + if (dol_strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) // Clean format if (preg_match('/%b/i', $format)) // There is some text to translate { // We inhibate translation to text made by strftime functions. We will use trans instead later. - $format=str_replace('%b', '__b__', $format); - $format=str_replace('%B', '__B__', $format); + $format = str_replace('%b', '__b__', $format); + $format = str_replace('%B', '__B__', $format); } if (preg_match('/%a/i', $format)) // There is some text to translate { // We inhibate translation to text made by strftime functions. We will use trans instead later. - $format=str_replace('%a', '__a__', $format); - $format=str_replace('%A', '__A__', $format); + $format = str_replace('%a', '__a__', $format); + $format = str_replace('%A', '__A__', $format); } // Analyze date - $reg=array(); + $reg = array(); if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 { dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]); @@ -1839,59 +1839,59 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang dol_syslog("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"], LOG_WARNING); //if (function_exists('debug_print_backtrace')) debug_print_backtrace(); // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' - $syear = (! empty($reg[1]) ? $reg[1] : ''); - $smonth = (! empty($reg[2]) ? $reg[2] : ''); - $sday = (! empty($reg[3]) ? $reg[3] : ''); - $shour = (! empty($reg[4]) ? $reg[4] : ''); - $smin = (! empty($reg[5]) ? $reg[5] : ''); - $ssec = (! empty($reg[6]) ? $reg[6] : ''); + $syear = (!empty($reg[1]) ? $reg[1] : ''); + $smonth = (!empty($reg[2]) ? $reg[2] : ''); + $sday = (!empty($reg[3]) ? $reg[3] : ''); + $shour = (!empty($reg[4]) ? $reg[4] : ''); + $smin = (!empty($reg[5]) ? $reg[5] : ''); + $ssec = (!empty($reg[6]) ? $reg[6] : ''); - $time=dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true); - $ret=adodb_strftime($format, $time+$offsettz+$offsetdst, $to_gmt); + $time = dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true); + $ret = adodb_strftime($format, $time + $offsettz + $offsetdst, $to_gmt); } else { // Date is a timestamps if ($time < 100000000000) // Protection against bad date values { - $timetouse = $time+$offsettz+$offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $ret=adodb_strftime($format, $timetouse, $to_gmt); + $ret = adodb_strftime($format, $timetouse, $to_gmt); } - else $ret='Bad value '.$time.' for date'; + else $ret = 'Bad value '.$time.' for date'; } if (preg_match('/__b__/i', $format)) { - $timetouse = $time+$offsettz+$offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. // Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs. - $month=adodb_strftime('%m', $timetouse); - $month=sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'. + $month = adodb_strftime('%m', $timetouse); + $month = sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'. if ($encodetooutput) { - $monthtext=$outputlangs->transnoentities('Month'.$month); - $monthtextshort=$outputlangs->transnoentities('MonthShort'.$month); + $monthtext = $outputlangs->transnoentities('Month'.$month); + $monthtextshort = $outputlangs->transnoentities('MonthShort'.$month); } else { - $monthtext=$outputlangs->transnoentitiesnoconv('Month'.$month); - $monthtextshort=$outputlangs->transnoentitiesnoconv('MonthShort'.$month); + $monthtext = $outputlangs->transnoentitiesnoconv('Month'.$month); + $monthtextshort = $outputlangs->transnoentitiesnoconv('MonthShort'.$month); } //print 'monthtext='.$monthtext.' monthtextshort='.$monthtextshort; - $ret=str_replace('__b__', $monthtextshort, $ret); - $ret=str_replace('__B__', $monthtext, $ret); + $ret = str_replace('__b__', $monthtextshort, $ret); + $ret = str_replace('__B__', $monthtext, $ret); //print 'x'.$outputlangs->charset_output.'-'.$ret.'x'; //return $ret; } if (preg_match('/__a__/i', $format)) { - $timetouse = $time+$offsettz+$offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $w=adodb_strftime('%w', $timetouse); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $dayweek=$outputlangs->transnoentitiesnoconv('Day'.$w); - $ret=str_replace('__A__', $dayweek, $ret); - $ret=str_replace('__a__', dol_substr($dayweek, 0, 3), $ret); + $w = adodb_strftime('%w', $timetouse); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $dayweek = $outputlangs->transnoentitiesnoconv('Day'.$w); + $ret = str_replace('__A__', $dayweek, $ret); + $ret = str_replace('__a__', dol_substr($dayweek, 0, 3), $ret); } return $ret; @@ -1935,17 +1935,17 @@ function dol_getdate($timestamp, $fast = false) { global $conf; - $usealternatemethod=false; - if ($timestamp <= 0) $usealternatemethod=true; // <= 1970 - if ($timestamp >= 2145913200) $usealternatemethod=true; // >= 2038 + $usealternatemethod = false; + if ($timestamp <= 0) $usealternatemethod = true; // <= 1970 + if ($timestamp >= 2145913200) $usealternatemethod = true; // >= 2038 if ($usealternatemethod) { - $arrayinfo=adodb_getdate($timestamp, $fast); + $arrayinfo = adodb_getdate($timestamp, $fast); } else { - $arrayinfo=getdate($timestamp); + $arrayinfo = getdate($timestamp); } return $arrayinfo; @@ -1976,47 +1976,47 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $ //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; // Clean parameters - if ($hour == -1 || empty($hour)) $hour=0; - if ($minute == -1 || empty($minute)) $minute=0; - if ($second == -1 || empty($second)) $second=0; + if ($hour == -1 || empty($hour)) $hour = 0; + if ($minute == -1 || empty($minute)) $minute = 0; + if ($second == -1 || empty($second)) $second = 0; // Check parameters if ($check) { - if (! $month || ! $day) return ''; - if ($day > 31) return ''; + if (!$month || !$day) return ''; + if ($day > 31) return ''; if ($month > 12) return ''; - if ($hour < 0 || $hour > 24) return ''; - if ($minute< 0 || $minute > 60) return ''; - if ($second< 0 || $second > 60) return ''; + if ($hour < 0 || $hour > 24) return ''; + if ($minute < 0 || $minute > 60) return ''; + if ($second < 0 || $second > 60) return ''; } if (empty($gm) || $gm === 'server') { - $default_timezone=@date_default_timezone_get(); // Example 'Europe/Berlin' + $default_timezone = @date_default_timezone_get(); // Example 'Europe/Berlin' $localtz = new DateTimeZone($default_timezone); } elseif ($gm === 'user') { // We use dol_tz_string first because it is more reliable. - $default_timezone=(empty($_SESSION["dol_tz_string"])?@date_default_timezone_get():$_SESSION["dol_tz_string"]); // Example 'Europe/Berlin' + $default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]); // Example 'Europe/Berlin' try { $localtz = new DateTimeZone($default_timezone); } - catch(Exception $e) + catch (Exception $e) { dol_syslog("Warning dol_tz_string contains an invalid value ".$_SESSION["dol_tz_string"], LOG_WARNING); - $default_timezone=@date_default_timezone_get(); + $default_timezone = @date_default_timezone_get(); } } elseif (strrpos($gm, "tz,") !== false) { - $timezone=str_replace("tz,", "", $gm); // Example 'tz,Europe/Berlin' + $timezone = str_replace("tz,", "", $gm); // Example 'tz,Europe/Berlin' try { $localtz = new DateTimeZone($timezone); } - catch(Exception $e) + catch (Exception $e) { dol_syslog("Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING); } @@ -2030,7 +2030,7 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $ $dt = new DateTime(null, $localtz); $dt->setDate((int) $year, (int) $month, (int) $day); $dt->setTime((int) $hour, (int) $minute, (int) $second); - $date=$dt->getTimestamp(); // should include daylight saving time + $date = $dt->getTimestamp(); // should include daylight saving time //var_dump($date); return $date; } @@ -2047,16 +2047,16 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $ */ function dol_now($mode = 'gmt') { - $ret=0; + $ret = 0; // Note that gmmktime and mktime return same value (GMT) when used without parameters //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead - if ($mode == 'gmt') $ret=time(); // Time for now at greenwich. + if ($mode == 'gmt') $ret = time(); // Time for now at greenwich. elseif ($mode == 'tzserver') // Time for now with PHP server timezone added { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $tzsecond=getServerTimeZoneInt('now'); // Contains tz+dayling saving time - $ret=(int) (dol_now('gmt')+($tzsecond*3600)); + $tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time + $ret = (int) (dol_now('gmt') + ($tzsecond * 3600)); } /*else if ($mode == 'tzref') // Time for now with parent company timezone is added { @@ -2067,9 +2067,9 @@ function dol_now($mode = 'gmt') elseif ($mode == 'tzuser') // Time for now with user timezone added { //print 'time: '.time().'-'.mktime().'-'.gmmktime(); - $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; - $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; - $ret=(int) (dol_now('gmt')+($offsettz+$offsetdst)); + $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; + $offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; + $ret = (int) (dol_now('gmt') + ($offsettz + $offsetdst)); } return $ret; @@ -2086,27 +2086,27 @@ function dol_now($mode = 'gmt') */ function dol_print_size($size, $shortvalue = 0, $shortunit = 0) { - global $conf,$langs; - $level=1024; + global $conf, $langs; + $level = 1024; - if (! empty($conf->dol_optimize_smallscreen)) $shortunit=1; + if (!empty($conf->dol_optimize_smallscreen)) $shortunit = 1; // Set value text - if (empty($shortvalue) || $size < ($level*10)) + if (empty($shortvalue) || $size < ($level * 10)) { - $ret=$size; - $textunitshort=$langs->trans("b"); - $textunitlong=$langs->trans("Bytes"); + $ret = $size; + $textunitshort = $langs->trans("b"); + $textunitlong = $langs->trans("Bytes"); } else { - $ret=round($size/$level, 0); - $textunitshort=$langs->trans("Kb"); - $textunitlong=$langs->trans("KiloBytes"); + $ret = round($size / $level, 0); + $textunitshort = $langs->trans("Kb"); + $textunitlong = $langs->trans("KiloBytes"); } // Use long or short text unit - if (empty($shortunit)) { $ret.=' '.$textunitlong; } - else { $ret.=' '.$textunitshort; } + if (empty($shortunit)) { $ret .= ' '.$textunitlong; } + else { $ret .= ' '.$textunitshort; } return $ret; } @@ -2126,16 +2126,16 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0) if (empty($url)) return ''; - $link=''.($withpicto?img_picto($langs->trans("Url"), 'globe').' ':'').$link.'
    '; + $link = ''.($withpicto ?img_picto($langs->trans("Url"), 'globe').' ' : '').$link.'
    '; } /** @@ -2152,47 +2152,47 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0) */ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0) { - global $conf,$user,$langs,$hookmanager; + global $conf, $user, $langs, $hookmanager; - $newemail=$email; + $newemail = $email; if (empty($email)) return ' '; - if (! empty($addlink)) + if (!empty($addlink)) { - $newemail=''; - $newemail.=dol_trunc($email, $max); - $newemail.=''; - if ($showinvalid && ! isValidEmail($email)) + $newemail = ''; + $newemail .= dol_trunc($email, $max); + $newemail .= ''; + if ($showinvalid && !isValidEmail($email)) { $langs->load("errors"); - $newemail.=img_warning($langs->trans("ErrorBadEMail", $email)); + $newemail .= img_warning($langs->trans("ErrorBadEMail", $email)); } - if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { - $type='AC_EMAIL'; $link=''; - if (! empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) $link=''.img_object($langs->trans("AddAction"), "calendar").''; - if ($link) $newemail='
    '.$newemail.' '.$link.'
    '; + $type = 'AC_EMAIL'; $link = ''; + if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) $link = ''.img_object($langs->trans("AddAction"), "calendar").''; + if ($link) $newemail = '
    '.$newemail.' '.$link.'
    '; } } else { - if ($showinvalid && ! isValidEmail($email)) + if ($showinvalid && !isValidEmail($email)) { $langs->load("errors"); - $newemail.=img_warning($langs->trans("ErrorBadEMail", $email)); + $newemail .= img_warning($langs->trans("ErrorBadEMail", $email)); } } - $rep = '
    '.($withpicto?img_picto($langs->trans("EMail"), 'object_email.png').' ':'').$newemail.'
    '; + $rep = '
    '.($withpicto ?img_picto($langs->trans("EMail"), 'object_email.png').' ' : '').$newemail.'
    '; if ($hookmanager) { - $parameters = array('cid' => $cid, 'socid' => $socid,'addlink' => $addlink, 'picto' => $withpicto); + $parameters = array('cid' => $cid, 'socid' => $socid, 'addlink' => $addlink, 'picto' => $withpicto); $reshook = $hookmanager->executeHooks('printEmail', $parameters, $email); - $rep.=$hookmanager->resPrint; + $rep .= $hookmanager->resPrint; } return $rep; @@ -2207,7 +2207,7 @@ function getArrayOfSocialNetworks() { global $conf, $db; $sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; - $sql.= " WHERE entity=".$conf->entity; + $sql .= " WHERE entity=".$conf->entity; $socialnetworks = array(); $resql = $db->query($sql); if ($resql) { @@ -2235,43 +2235,43 @@ function getArrayOfSocialNetworks() */ function dol_print_socialnetworks($value, $cid, $socid, $type) { - global $conf,$user,$langs; + global $conf, $user, $langs; - $htmllink=$value; + $htmllink = $value; if (empty($value)) return ' '; - if (! empty($type)) + if (!empty($type)) { $htmllink = '
    '; $htmllink .= img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright', 0); $htmllink .= $value; if ($type == 'skype') { - $htmllink.= ' '; - $htmllink.=''; - $htmllink.=''; - $htmllink.=''; - $htmllink.=''; - $htmllink.=''; + $htmllink .= ' '; + $htmllink .= ''; + $htmllink .= ''; + $htmllink .= ''; + $htmllink .= ''; + $htmllink .= ''; } - if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type=='skype') + if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') { - $addlink='AC_SKYPE'; - $link=''; - if (! empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link=''.img_object($langs->trans("AddAction"), "calendar").''; - $htmllink.=($link?' '.$link:''); + $addlink = 'AC_SKYPE'; + $link = ''; + if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link = ''.img_object($langs->trans("AddAction"), "calendar").''; + $htmllink .= ($link ? ' '.$link : ''); } - $htmllink.='
    '; + $htmllink .= ''; } else { $langs->load("errors"); - $htmllink.=img_warning($langs->trans("ErrorBadSocialNetworkValue", $value)); + $htmllink .= img_warning($langs->trans("ErrorBadSocialNetworkValue", $value)); } return $htmllink; } @@ -2297,104 +2297,104 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli // Clean phone parameter $phone = preg_replace("/[\s.-]/", "", trim($phone)); if (empty($phone)) { return ''; } - if (empty($countrycode)) $countrycode=$mysoc->country_code; + if (empty($countrycode)) $countrycode = $mysoc->country_code; // Short format for small screens - if ($conf->dol_optimize_smallscreen) $separ=''; + if ($conf->dol_optimize_smallscreen) $separ = ''; - $newphone=$phone; + $newphone = $phone; if (strtoupper($countrycode) == "FR") { // France if (dol_strlen($phone) == 10) { - $newphone=substr($newphone, 0, 2).$separ.substr($newphone, 2, 2).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2); + $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 2).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2); } elseif (dol_strlen($phone) == 7) { - $newphone=substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2); } elseif (dol_strlen($phone) == 9) { - $newphone=substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2); + $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2); } elseif (dol_strlen($phone) == 11) { - $newphone=substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); } elseif (dol_strlen($phone) == 12) { - $newphone=substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "CA") { if (dol_strlen($phone) == 10) { - $newphone=($separ!=''?'(':'').substr($newphone, 0, 3).($separ!=''?')':'').$separ.substr($newphone, 3, 3).($separ!=''?'-':'').substr($newphone, 6, 4); + $newphone = ($separ != '' ? '(' : '').substr($newphone, 0, 3).($separ != '' ? ')' : '').$separ.substr($newphone, 3, 3).($separ != '' ? '-' : '').substr($newphone, 6, 4); } } - elseif (strtoupper($countrycode) == "PT" ) + elseif (strtoupper($countrycode) == "PT") {//Portugal if (dol_strlen($phone) == 13) {//ex: +351_ABC_DEF_GHI - $newphone= substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); } } - elseif (strtoupper($countrycode) == "SR" ) + elseif (strtoupper($countrycode) == "SR") {//Suriname if (dol_strlen($phone) == 10) {//ex: +597_ABC_DEF - $newphone= substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3); + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3); } elseif (dol_strlen($phone) == 11) {//ex: +597_ABC_DEFG - $newphone= substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4); + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4); } } - elseif (strtoupper($countrycode) == "DE" ) + elseif (strtoupper($countrycode) == "DE") {//Allemagne if (dol_strlen($phone) == 14) {//ex: +49_ABCD_EFGH_IJK - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3); } elseif (dol_strlen($phone) == 13) {//ex: +49_ABC_DEFG_HIJ - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3); } } elseif (strtoupper($countrycode) == "ES") {//Espagne if (dol_strlen($phone) == 12) {//ex: +34_ABC_DEF_GHI - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); } } elseif (strtoupper($countrycode) == "BF") {// Burkina Faso if (dol_strlen($phone) == 12) {//ex : +22 A BC_DE_FG_HI - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "RO") {// Roumanie if (dol_strlen($phone) == 12) {//ex : +40 AB_CDE_FG_HI - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "TR") {//Turquie if (dol_strlen($phone) == 13) {//ex : +90 ABC_DEF_GHIJ - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4); } } elseif (strtoupper($countrycode) == "US") {//Etat-Unis if (dol_strlen($phone) == 12) {//ex: +1 ABC_DEF_GHIJ - $newphone= substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4); + $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4); } } elseif (strtoupper($countrycode) == "MX") @@ -2414,18 +2414,18 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli } elseif (strtoupper($countrycode) == "ML") {//Mali - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +223 AB_CD_EF_GH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "TH") {//Thaïlande - if(dol_strlen($phone) == 11) + if (dol_strlen($phone) == 11) {//ex: +66_ABC_DE_FGH $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3); } - elseif(dol_strlen($phone) == 12) + elseif (dol_strlen($phone) == 12) {//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); } @@ -2433,240 +2433,240 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli elseif (strtoupper($countrycode) == "MU") { //Maurice - if(dol_strlen($phone) == 11) + if (dol_strlen($phone) == 11) {//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) + elseif (dol_strlen($phone) == 12) {//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); } } elseif (strtoupper($countrycode) == "ZA") {//Afrique du sud - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +27_AB_CDE_FG_HI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "SY") {//Syrie - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +963_AB_CD_EF_GH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } - elseif(dol_strlen($phone) == 13) + elseif (dol_strlen($phone) == 13) {//ex: +963_AB_CD_EF_GHI $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3); } } elseif (strtoupper($countrycode) == "AE") {//Emirats Arabes Unis - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +971_ABC_DEF_GH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2); } - elseif(dol_strlen($phone) == 13) + elseif (dol_strlen($phone) == 13) {//ex: +971_ABC_DEF_GHI $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); } - elseif(dol_strlen($phone) == 14) + elseif (dol_strlen($phone) == 14) {//ex: +971_ABC_DEF_GHIK $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4); } } elseif (strtoupper($countrycode) == "DZ") {//Algérie - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +213_ABC_DEF_GHI $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); } } elseif (strtoupper($countrycode) == "BE") {//Belgique - if(dol_strlen($phone) == 11) + if (dol_strlen($phone) == 11) {//ex: +32_ABC_DE_FGH $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3); } - elseif(dol_strlen($phone) == 12) + elseif (dol_strlen($phone) == 12) {//ex: +32_ABC_DEF_GHI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); } } elseif (strtoupper($countrycode) == "PF") {//Polynésie française - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +689_AB_CD_EF_GH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "CO") {//Colombie - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +57_ABC_DEF_GH_IJ $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); } } elseif (strtoupper($countrycode) == "JO") {//Jordanie - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +962_A_BCD_EF_GH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); } } elseif (strtoupper($countrycode) == "JM") {//Jamaïque - if(dol_strlen($newphone) == 12) + if (dol_strlen($newphone) == 12) {//ex: +1867_ABC_DEFG $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4); } } elseif (strtoupper($countrycode) == "MG") {//Madagascar - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +261_AB_CD_EF_GHI $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3); } } elseif (strtoupper($countrycode) == "GB") {//Royaume uni - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +44_ABCD_EFG_HIJ $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); } } elseif (strtoupper($countrycode) == "CH") {//Suisse - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +41_AB_CDE_FG_HI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } - elseif(dol_strlen($phone) == 15) + elseif (dol_strlen($phone) == 15) {// +41_AB_CDE_FGH_IJKL - $newphone =$newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 4); + $newphone = $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 4); } } elseif (strtoupper($countrycode) == "TN") {//Tunisie - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +216_AB_CDE_FGH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); } } elseif (strtoupper($countrycode) == "GF") {//Guyane francaise - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +594_ABC_DE_FG_HI (ABC=594 de nouveau) $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); } } elseif (strtoupper($countrycode) == "GP") {//Guadeloupe - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +590_ABC_DE_FG_HI (ABC=590 de nouveau) $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); } } elseif (strtoupper($countrycode) == "MQ") {//Martinique - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +596_ABC_DE_FG_HI (ABC=596 de nouveau) $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); } } elseif (strtoupper($countrycode) == "IT") {//Italie - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +39_ABC_DEF_GHI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); } - elseif(dol_strlen($phone) == 13) + elseif (dol_strlen($phone) == 13) {//ex: +39_ABC_DEF_GH_IJ $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); } } - elseif(strtoupper($countrycode) == "AU") + elseif (strtoupper($countrycode) == "AU") { //Australie - if(dol_strlen($phone) == 12) + 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); } } - if (! empty($addlink)) // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set) + if (!empty($addlink)) // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set) { - if ($conf->browser->layout == 'phone' || (! empty($conf->clicktodial->enabled) && ! empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) // If phone or option for, we use link of phone + if ($conf->browser->layout == 'phone' || (!empty($conf->clicktodial->enabled) && !empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) // If phone or option for, we use link of phone { - $newphone =''; + $newphone = ''; } - elseif (! empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') // If click to dial, we use click to dial url + elseif (!empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') // If click to dial, we use click to dial url { if (empty($user->clicktodial_loaded)) $user->fetch_clicktodial(); // Define urlmask - $urlmask='ErrorClickToDialModuleNotConfigured'; - if (! empty($conf->global->CLICKTODIAL_URL)) $urlmask=$conf->global->CLICKTODIAL_URL; - if (! empty($user->clicktodial_url)) $urlmask=$user->clicktodial_url; + $urlmask = 'ErrorClickToDialModuleNotConfigured'; + if (!empty($conf->global->CLICKTODIAL_URL)) $urlmask = $conf->global->CLICKTODIAL_URL; + if (!empty($user->clicktodial_url)) $urlmask = $user->clicktodial_url; - $clicktodial_poste=(! empty($user->clicktodial_poste)?urlencode($user->clicktodial_poste):''); - $clicktodial_login=(! empty($user->clicktodial_login)?urlencode($user->clicktodial_login):''); - $clicktodial_password=(! empty($user->clicktodial_password)?urlencode($user->clicktodial_password):''); + $clicktodial_poste = (!empty($user->clicktodial_poste) ?urlencode($user->clicktodial_poste) : ''); + $clicktodial_login = (!empty($user->clicktodial_login) ?urlencode($user->clicktodial_login) : ''); + $clicktodial_password = (!empty($user->clicktodial_password) ?urlencode($user->clicktodial_password) : ''); // This line is for backward compatibility $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password); // Thoose lines are for substitution - $substitarray=array('__PHONEFROM__'=>$clicktodial_poste, + $substitarray = array('__PHONEFROM__'=>$clicktodial_poste, '__PHONETO__'=>urlencode($phone), '__LOGIN__'=>$clicktodial_login, '__PASS__'=>$clicktodial_password); $url = make_substitutions($url, $substitarray); - $newphonesav=$newphone; - $newphone ='global->CLICKTODIAL_FORCENEWTARGET)) $newphone.=' target="_blank"'; - $newphone.='>'.$newphonesav.''; + $newphonesav = $newphone; + $newphone = 'global->CLICKTODIAL_FORCENEWTARGET)) $newphone .= ' target="_blank"'; + $newphone .= '>'.$newphonesav.''; } //if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) - if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { - $type='AC_TEL'; $link=''; - if ($addlink == 'AC_FAX') $type='AC_FAX'; - if (! empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link=''.img_object($langs->trans("AddAction"), "calendar").''; - if ($link) $newphone='
    '.$newphone.' '.$link.'
    '; + $type = 'AC_TEL'; $link = ''; + if ($addlink == 'AC_FAX') $type = 'AC_FAX'; + if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link = ''.img_object($langs->trans("AddAction"), "calendar").''; + if ($link) $newphone = '
    '.$newphone.' '.$link.'
    '; } } if (empty($titlealt)) { - $titlealt=($withpicto=='fax'?$langs->trans("Fax"):$langs->trans("Phone")); + $titlealt = ($withpicto == 'fax' ? $langs->trans("Fax") : $langs->trans("Phone")); } - $rep=''; + $rep = ''; if ($hookmanager) { - $parameters = array('countrycode' => $countrycode, 'cid' => $cid, 'socid' => $socid,'titlealt' => $titlealt, 'picto' => $withpicto); + $parameters = array('countrycode' => $countrycode, 'cid' => $cid, 'socid' => $socid, 'titlealt' => $titlealt, 'picto' => $withpicto); $reshook = $hookmanager->executeHooks('printPhone', $parameters, $phone); - $rep.=$hookmanager->resPrint; + $rep .= $hookmanager->resPrint; } if (empty($reshook)) { $picto = ''; - if($withpicto){ - if($withpicto=='fax'){ + if ($withpicto) { + if ($withpicto == 'fax') { $picto = 'phoning_fax'; - }elseif($withpicto=='phone'){ + }elseif ($withpicto == 'phone') { $picto = 'phoning'; - }elseif($withpicto=='mobile'){ + }elseif ($withpicto == 'mobile') { $picto = 'phoning_mobile'; - }else{ + } else { $picto = ''; } } - if ($adddivfloat) $rep.='
    '; - else $rep.=''; - $rep.=($withpicto?img_picto($titlealt, 'object_'.$picto.'.png').' ':'').$newphone; - if ($adddivfloat) $rep.='
    '; - else $rep.=''; + if ($adddivfloat) $rep .= '
    '; + else $rep .= ''; + $rep .= ($withpicto ?img_picto($titlealt, 'object_'.$picto.'.png').' ' : '').$newphone; + if ($adddivfloat) $rep .= '
    '; + else $rep .= ''; } return $rep; @@ -2681,22 +2681,22 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli */ function dol_print_ip($ip, $mode = 0) { - global $conf,$langs; + global $conf, $langs; - $ret=''; + $ret = ''; - if (empty($mode)) $ret.=$ip; + if (empty($mode)) $ret .= $ip; if ($mode != 2) { - $countrycode=dolGetCountryCodeFromIp($ip); + $countrycode = dolGetCountryCodeFromIp($ip); if ($countrycode) // If success, countrycode is us, fr, ... { if (file_exists(DOL_DOCUMENT_ROOT.'/theme/common/flags/'.$countrycode.'.png')) { - $ret.=' '.img_picto($countrycode.' '.$langs->trans("AccordingToGeoIPDatabase"), DOL_URL_ROOT.'/theme/common/flags/'.$countrycode.'.png', '', 1); + $ret .= ' '.img_picto($countrycode.' '.$langs->trans("AccordingToGeoIPDatabase"), DOL_URL_ROOT.'/theme/common/flags/'.$countrycode.'.png', '', 1); } - else $ret.=' ('.$countrycode.')'; + else $ret .= ' ('.$countrycode.')'; } else { @@ -2717,7 +2717,7 @@ function dol_print_ip($ip, $mode = 0) */ function getUserRemoteIP() { - $ip = empty($_SERVER['HTTP_X_FORWARDED_FOR'])? (empty($_SERVER['HTTP_CLIENT_IP'])?(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']):$_SERVER['HTTP_CLIENT_IP']) : $_SERVER['HTTP_X_FORWARDED_FOR']; + $ip = empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? (empty($_SERVER['HTTP_CLIENT_IP']) ? (empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']) : $_SERVER['HTTP_CLIENT_IP']) : $_SERVER['HTTP_X_FORWARDED_FOR']; return $ip; } @@ -2731,17 +2731,17 @@ function dolGetCountryCodeFromIp($ip) { global $conf; - $countrycode=''; + $countrycode = ''; - if (! empty($conf->geoipmaxmind->enabled)) + if (!empty($conf->geoipmaxmind->enabled)) { - $datafile=$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; + $datafile = $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; //$ip='24.24.24.24'; //$datafile='/usr/share/GeoIP/GeoIP.dat'; Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages) include_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'; - $geoip=new DolGeoIP('country', $datafile); + $geoip = new DolGeoIP('country', $datafile); //print 'ip='.$ip.' databaseType='.$geoip->gi->databaseType." GEOIP_CITY_EDITION_REV1=".GEOIP_CITY_EDITION_REV1."\n"; - $countrycode=$geoip->getCountryCodeFromIP($ip); + $countrycode = $geoip->getCountryCodeFromIP($ip); } return $countrycode; @@ -2756,20 +2756,20 @@ function dolGetCountryCodeFromIp($ip) */ function dol_user_country() { - global $conf,$langs,$user; + global $conf, $langs, $user; //$ret=$user->xxx; - $ret=''; - if (! empty($conf->geoipmaxmind->enabled)) + $ret = ''; + if (!empty($conf->geoipmaxmind->enabled)) { - $ip=getUserRemoteIP(); - $datafile=$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; + $ip = getUserRemoteIP(); + $datafile = $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; //$ip='24.24.24.24'; //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'; - $geoip=new DolGeoIP('country', $datafile); - $countrycode=$geoip->getCountryCodeFromIP($ip); - $ret=$countrycode; + $geoip = new DolGeoIP('country', $datafile); + $countrycode = $geoip->getCountryCodeFromIP($ip); + $ret = $countrycode; } return $ret; } @@ -2797,32 +2797,32 @@ function dol_print_address($address, $htmlid, $mode, $id, $noprint = 0, $charfor if ($hookmanager) { $parameters = array('element' => $mode, 'id' => $id); $reshook = $hookmanager->executeHooks('printAddress', $parameters, $address); - $out.=$hookmanager->resPrint; + $out .= $hookmanager->resPrint; } if (empty($reshook)) { - if (empty($charfornl)) $out.=nl2br($address); - else $out.=preg_replace('/[\r\n]+/', $charfornl, $address); + if (empty($charfornl)) $out .= nl2br($address); + else $out .= preg_replace('/[\r\n]+/', $charfornl, $address); - $showgmap=$showomap=0; + $showgmap = $showomap = 0; // TODO Add a hook here - if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap=1; - if ($mode=='contact' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) $showgmap=1; - if ($mode=='member' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) $showgmap=1; - if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap=1; - if ($mode=='contact' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) $showomap=1; - if ($mode=='member' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) $showomap=1; + if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap = 1; + if ($mode == 'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) $showgmap = 1; + if ($mode == 'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) $showgmap = 1; + if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap = 1; + if ($mode == 'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) $showomap = 1; + if ($mode == 'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) $showomap = 1; if ($showgmap) { - $url=dol_buildpath('/google/gmaps.php?mode='.$mode.'&id='.$id, 1); - $out.=' '; + $url = dol_buildpath('/google/gmaps.php?mode='.$mode.'&id='.$id, 1); + $out .= ' '; } if ($showomap) { - $url=dol_buildpath('/openstreetmap/maps.php?mode='.$mode.'&id='.$id, 1); - $out.=' '; + $url = dol_buildpath('/openstreetmap/maps.php?mode='.$mode.'&id='.$id, 1); + $out .= ' '; } } } @@ -2857,17 +2857,17 @@ function isValidMXRecord($domain) { if (function_exists('idn_to_ascii') && function_exists('checkdnsrr')) { - if (! checkdnsrr(idn_to_ascii($domain), 'MX')) + if (!checkdnsrr(idn_to_ascii($domain), 'MX')) { return 0; } if (function_exists('getmxrr')) { - $mxhosts=array(); - $weight=array(); + $mxhosts = array(); + $weight = array(); getmxrr(idn_to_ascii($domain), $mxhosts, $weight); if (count($mxhosts) > 1) return 1; - if (count($mxhosts) == 1 && ! empty($mxhosts[0])) return 1; + if (count($mxhosts) == 1 && !empty($mxhosts[0])) return 1; return 0; } @@ -2915,29 +2915,29 @@ function dol_substr($string, $start, $length, $stringencoding = '', $trunconbyte { global $langs; - if (empty($stringencoding)) $stringencoding=$langs->charset_output; + if (empty($stringencoding)) $stringencoding = $langs->charset_output; - $ret=''; + $ret = ''; if (empty($trunconbytes)) { if (function_exists('mb_substr')) { - $ret=mb_substr($string, $start, $length, $stringencoding); + $ret = mb_substr($string, $start, $length, $stringencoding); } else { - $ret=substr($string, $start, $length); + $ret = substr($string, $start, $length); } } else { if (function_exists('mb_strcut')) { - $ret=mb_strcut($string, $start, $length, $stringencoding); + $ret = mb_strcut($string, $start, $length, $stringencoding); } else { - $ret=substr($string, $start, $length); + $ret = substr($string, $start, $length); } } return $ret; @@ -2961,29 +2961,29 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF { global $conf; - if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; + if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; - if (empty($stringencoding)) $stringencoding='UTF-8'; + if (empty($stringencoding)) $stringencoding = 'UTF-8'; // reduce for small screen - if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3); + if ($conf->dol_optimize_smallscreen == 1 && $display == 1) $size = round($size / 3); // We go always here if ($trunc == 'right') { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string, 1):$string; - if (dol_strlen($newstring, $stringencoding) > ($size+($nodot?0:3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... - return dol_substr($newstring, 0, $size, $stringencoding).($nodot?'':'...'); + $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... + return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '...'); else //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; return $string; } elseif ($trunc == 'middle') { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string, 1):$string; - if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size+1)) + $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) { - $size1=round($size/2); - $size2=round($size/2); + $size1 = round($size / 2); + $size2 = round($size / 2); return dol_substr($newstring, 0, $size1, $stringencoding).'...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding); } else @@ -2991,17 +2991,17 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF } elseif ($trunc == 'left') { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string, 1):$string; - if (dol_strlen($newstring, $stringencoding) > ($size+($nodot?0:3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... + $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... return '...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); else return $string; } elseif ($trunc == 'wrap') { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string, 1):$string; - if (dol_strlen($newstring, $stringencoding) > ($size+1)) - return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding)-$size, $stringencoding), $size, $trunc); + $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > ($size + 1)) + return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); else return $string; } @@ -3039,13 +3039,13 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ // Define fullpathpicto to use into src if ($pictoisfullpath) { // Clean parameters - if (! preg_match('/(\.png|\.gif|\.svg)$/i', $picto)) { + if (!preg_match('/(\.png|\.gif|\.svg)$/i', $picto)) { $picto .= '.png'; } $fullpathpicto = $picto; - $reg=array(); + $reg = array(); if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { - $morecss .= ($morecss ? ' ' : '') . $reg[1]; + $morecss .= ($morecss ? ' ' : '').$reg[1]; $moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt); } } else { @@ -3056,25 +3056,25 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'address', 'bank', 'bookmark', 'building', 'cash-register', 'close_title', 'cubes', 'delete', 'dolly', 'edit', 'ellipsis-h', 'filter', 'file-code', 'grip', 'grip_title', 'list', 'listlight', 'note', - 'object_bookmark', 'object_list','object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', + 'object_bookmark', 'object_list', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'stats', 'note', 'setup', 'sign-out', 'split', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'wrench', 'globe', - 'jabber','skype','twitter','facebook','linkedin', - 'instagram', 'snapchat', 'youtube', 'google-plus-g','whatsapp', - 'chevron-left','chevron-right','chevron-down','chevron-top', + 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', + 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', + 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'home', 'companies', 'products', 'commercial', 'invoicing', 'accountancy', 'project', 'hrm', 'members', 'ticket', 'generic', - 'error','warning', + 'error', 'warning', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda' ) )) { $fakey = $pictowithouttext; $facolor = ''; $fasize = ''; - $fa='fas'; + $fa = 'fas'; if (in_array($pictowithouttext, array('off', 'on', 'object_bookmark', 'bookmark'))) { - $fa='far'; + $fa = 'far'; } - if (in_array($pictowithouttext, array('skype', 'twitter', 'facebook', 'linkedin', 'instagram','snapchat','youtube','google-plus-g','whatsapp'))) { - $fa='fab'; + if (in_array($pictowithouttext, array('skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp'))) { + $fa = 'fab'; } $arrayconvpictotofa = array( @@ -3082,7 +3082,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'hrm'=>'umbrella-beach', 'members'=>'users', 'ticket'=>'ticket-alt', 'generic'=>'folder-open', 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'object_bookmark'=>'star', 'bookmark'=>'star', 'stats' => 'chart-bar', 'bank'=>'university', 'close_title'=>'window-close', 'delete'=>'trash', 'edit'=>'pencil', 'filter'=>'filter', 'split'=>'code-fork', - 'object_list'=>'list-alt','object_calendar'=>'calendar-alt', 'object_calendarweek'=>'calendar-week', 'object_calendarmonth'=>'calendar-alt', 'object_calendarday'=>'calendar-day', 'object_calendarperuser'=>'table', + 'object_list'=>'list-alt', 'object_calendar'=>'calendar-alt', 'object_calendarweek'=>'calendar-week', 'object_calendarmonth'=>'calendar-alt', 'object_calendarday'=>'calendar-day', 'object_calendarperuser'=>'table', 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt' ); @@ -3129,7 +3129,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ elseif ($pictowithouttext == 'listlight') { $fakey = 'fa-download'; $facolor = '#999'; - $marginleftonlyshort=1; + $marginleftonlyshort = 1; } elseif ($pictowithouttext == 'printer') { $fakey = 'fa-print'; @@ -3144,21 +3144,21 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = 'fa-sticky-note'; $fa = 'far'; $facolor = '#999'; - $marginleftonlyshort=1; + $marginleftonlyshort = 1; } elseif ($pictowithouttext == 'uparrow') { $fakey = 'fa-mail-forward'; $facolor = '#555'; } elseif (in_array($pictowithouttext, array('1uparrow', '1downarrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected'))) { - $convertarray=array('1uparrow'=>'caret-up', '1downarrow'=>'caret-down', '1leftarrow'=>'caret-left', '1rightarrow'=>'caret-right', '1uparrow_selected'=>'caret-up', '1downarrow_selected'=>'caret-down', '1leftarrow_selected'=>'caret-left', '1rightarrow_selected'=>'caret-right'); + $convertarray = array('1uparrow'=>'caret-up', '1downarrow'=>'caret-down', '1leftarrow'=>'caret-left', '1rightarrow'=>'caret-right', '1uparrow_selected'=>'caret-up', '1downarrow_selected'=>'caret-down', '1leftarrow_selected'=>'caret-left', '1rightarrow_selected'=>'caret-right'); $fakey = 'fa-'.$convertarray[$pictowithouttext]; if (preg_match('/selected/', $pictowithouttext)) $facolor = '#888'; $marginleftonlyshort = 1; } elseif ($pictowithouttext == 'sign-out') { $fakey = 'fa-sign-out-alt'; - $marginleftonlyshort=0; + $marginleftonlyshort = 0; } elseif ($pictowithouttext == 'unlink') { $fakey = 'fa-unlink'; @@ -3178,61 +3178,61 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ // Img for type of views elseif (in_array($pictowithouttext, array('object_list', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser'))) { $fakey = 'imgforviewmode fa-'.$arrayconvpictotofa[$pictowithouttext]; - $marginleftonlyshort=0; + $marginleftonlyshort = 0; } - elseif (! empty($arrayconvpictotofa[$pictowithouttext])) + elseif (!empty($arrayconvpictotofa[$pictowithouttext])) { $fakey = 'fa-'.$arrayconvpictotofa[$pictowithouttext]; //$facolor = '#444'; - $marginleftonlyshort=0; + $marginleftonlyshort = 0; } else { $fakey = 'fa-'.$pictowithouttext; //$facolor = '#444'; - $marginleftonlyshort=0; + $marginleftonlyshort = 0; } //this snippet only needed since function img_edit accepts only one additional parameter: no separate one for css only. //class/style need to be extracted to avoid duplicate class/style validation errors when $moreatt is added to the end of the attributes - $reg=array(); + $reg = array(); if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { - $morecss .= ($morecss ? ' ' : '') . $reg[1]; + $morecss .= ($morecss ? ' ' : '').$reg[1]; $moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt); } if (preg_match('/style="([^"]+)"/', $moreatt, $reg)) { - $morestyle = ' '. $reg[1]; + $morestyle = ' '.$reg[1]; $moreatt = str_replace('style="'.$reg[1].'"', '', $moreatt); } - $moreatt=trim($moreatt); + $moreatt = trim($moreatt); - $enabledisablehtml = ''; - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $enabledisablehtml.= $titlealt; + $enabledisablehtml = ''; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $enabledisablehtml .= $titlealt; } - $enabledisablehtml.= ''; + $enabledisablehtml .= ''; return $enabledisablehtml; } - if (! empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) { - $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module + if (!empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) { + $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module } - elseif (! empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { - $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme + elseif (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { + $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme } - elseif (! empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) { - $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module + elseif (!empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) { + $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module } // If we ask an image into $url/$mymodule/img (instead of default path) if (preg_match('/^([^@]+)@([^@]+)$/i', $picto, $regs)) { $picto = $regs[1]; - $path = $regs[2]; // $path is $mymodule + $path = $regs[2]; // $path is $mymodule } // Clean parameters - if (! preg_match('/(\.png|\.gif|\.svg)$/i', $picto)) { + if (!preg_match('/(\.png|\.gif|\.svg)$/i', $picto)) { $picto .= '.png'; } // If alt path are defined, define url where img file is, according to physical path @@ -3256,7 +3256,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ return $fullpathpicto; } // tag title is used for tooltip on , tag alt can be used with very simple text on image for blind people - return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup + return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup } /** @@ -3294,11 +3294,11 @@ function img_weather($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $mo if (is_numeric($picto)) { - $leveltopicto=array(0=>'weather-clear.png', 1=>'weather-few-clouds.png', 2=>'weather-clouds.png', 3=>'weather-many-clouds.png', 4=>'weather-storm.png'); + $leveltopicto = array(0=>'weather-clear.png', 1=>'weather-few-clouds.png', 2=>'weather-clouds.png', 3=>'weather-many-clouds.png', 4=>'weather-storm.png'); //return ''; $picto = $leveltopicto[$picto]; } - elseif (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; + elseif (!preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; $path = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/weather/'.$picto; @@ -3319,14 +3319,14 @@ function img_picto_common($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0 { global $conf; - if (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; + if (!preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; if ($pictoisfullpath) $path = $picto; else { $path = DOL_URL_ROOT.'/theme/common/'.$picto; - if (! empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) + if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) { $themepath = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/'.$picto; @@ -3350,14 +3350,14 @@ function img_action($titlealt, $numaction) if (empty($titlealt) || $titlealt == 'default') { - if ($numaction == '-1' || $numaction == 'ST_NO') { $numaction = -1; $titlealt = $langs->transnoentitiesnoconv('ChangeDoNotContact'); } - elseif ($numaction == '0' || $numaction == 'ST_NEVER') { $numaction = 0; $titlealt = $langs->transnoentitiesnoconv('ChangeNeverContacted'); } - elseif ($numaction == '1' || $numaction == 'ST_TODO') { $numaction = 1; $titlealt = $langs->transnoentitiesnoconv('ChangeToContact'); } - elseif ($numaction == '2' || $numaction == 'ST_PEND') { $numaction = 2; $titlealt = $langs->transnoentitiesnoconv('ChangeContactInProcess'); } - elseif ($numaction == '3' || $numaction == 'ST_DONE') { $numaction = 3; $titlealt = $langs->transnoentitiesnoconv('ChangeContactDone'); } + if ($numaction == '-1' || $numaction == 'ST_NO') { $numaction = -1; $titlealt = $langs->transnoentitiesnoconv('ChangeDoNotContact'); } + elseif ($numaction == '0' || $numaction == 'ST_NEVER') { $numaction = 0; $titlealt = $langs->transnoentitiesnoconv('ChangeNeverContacted'); } + elseif ($numaction == '1' || $numaction == 'ST_TODO') { $numaction = 1; $titlealt = $langs->transnoentitiesnoconv('ChangeToContact'); } + elseif ($numaction == '2' || $numaction == 'ST_PEND') { $numaction = 2; $titlealt = $langs->transnoentitiesnoconv('ChangeContactInProcess'); } + elseif ($numaction == '3' || $numaction == 'ST_DONE') { $numaction = 3; $titlealt = $langs->transnoentitiesnoconv('ChangeContactDone'); } else { $titlealt = $langs->transnoentitiesnoconv('ChangeStatus '.$numaction); $numaction = 0; } } - if (! is_numeric($numaction)) $numaction=0; + if (!is_numeric($numaction)) $numaction = 0; return img_picto($titlealt, 'stcomm'.$numaction.'.png'); } @@ -3423,7 +3423,7 @@ function img_edit($titlealt = 'default', $float = 0, $other = '') if ($titlealt == 'default') $titlealt = $langs->trans('Modify'); - return img_picto($titlealt, 'edit.png', ($float ? 'style="float: '.($langs->tab_translate["DIRECTION"] == 'rtl'?'left':'right').'"' : "") . ($other?' '.$other:'')); + return img_picto($titlealt, 'edit.png', ($float ? 'style="float: '.($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right').'"' : "").($other ? ' '.$other : '')); } /** @@ -3471,8 +3471,8 @@ function img_delete($titlealt = 'default', $other = 'class="pictodelete"') */ function img_printer($titlealt = "default", $other = '') { - global $conf,$langs; - if ($titlealt=="default") $titlealt=$langs->trans("Print"); + global $conf, $langs; + if ($titlealt == "default") $titlealt = $langs->trans("Print"); return img_picto($titlealt, 'printer.png', $other); } @@ -3509,7 +3509,7 @@ function img_help($usehelpcursor = 1, $usealttitle = 1) else $usealttitle = $langs->trans('Info'); } - return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;'.($usehelpcursor == 1 ? ' cursor: help': ($usehelpcursor == 2 ? ' cursor: pointer':'')).'"'); + return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;'.($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')).'"'); } /** @@ -3542,7 +3542,7 @@ function img_warning($titlealt = 'default', $moreatt = '', $morecss = 'pictowarn if ($titlealt == 'default') $titlealt = $langs->trans('Warning'); //return '
    '.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'
    '; - return img_picto($titlealt, 'warning.png', 'class="'.$morecss.'"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')); + return img_picto($titlealt, 'warning.png', 'class="'.$morecss.'"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt) : '')); } /** @@ -3608,7 +3608,7 @@ function img_down($titlealt = 'default', $selected = 0, $moreclass = '') if ($titlealt == 'default') $titlealt = $langs->trans('Down'); - return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown'.($moreclass?" ".$moreclass:"").'"'); + return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown'.($moreclass ? " ".$moreclass : "").'"'); } /** @@ -3625,7 +3625,7 @@ function img_up($titlealt = 'default', $selected = 0, $moreclass = '') if ($titlealt == 'default') $titlealt = $langs->trans('Up'); - return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup'.($moreclass?" ".$moreclass:"").'"'); + return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup'.($moreclass ? " ".$moreclass : "").'"'); } /** @@ -3688,13 +3688,13 @@ function img_allow($allow, $titlealt = 'default') */ function img_credit_card($brand) { - if ($brand == 'visa' || $brand == 'Visa') {$brand='cc-visa';} - elseif ($brand == 'mastercard' || $brand == 'MasterCard') {$brand='cc-mastercard';} - elseif ($brand == 'amex' || $brand == 'American Express') {$brand='cc-amex';} - elseif ($brand == 'discover' || $brand == 'Discover') {$brand='cc-discover';} - elseif ($brand == 'jcb' || $brand == 'JCB') {$brand='cc-jcb';} - elseif ($brand == 'diners' || $brand == 'Diners club') {$brand='cc-diners-club';} - elseif (! in_array($brand, array('cc-visa','cc-mastercard','cc-amex','cc-discover','cc-jcb','cc-diners-club'))) {$brand='credit-card';} + if ($brand == 'visa' || $brand == 'Visa') {$brand = 'cc-visa'; } + elseif ($brand == 'mastercard' || $brand == 'MasterCard') {$brand = 'cc-mastercard'; } + elseif ($brand == 'amex' || $brand == 'American Express') {$brand = 'cc-amex'; } + elseif ($brand == 'discover' || $brand == 'Discover') {$brand = 'cc-discover'; } + elseif ($brand == 'jcb' || $brand == 'JCB') {$brand = 'cc-jcb'; } + elseif ($brand == 'diners' || $brand == 'Diners club') {$brand = 'cc-diners-club'; } + elseif (!in_array($brand, array('cc-visa', 'cc-mastercard', 'cc-amex', 'cc-discover', 'cc-jcb', 'cc-diners-club'))) {$brand = 'credit-card'; } return ''; } @@ -3738,7 +3738,7 @@ function img_search($titlealt = 'default', $other = '') $img = img_picto($titlealt, 'search.png', $other, false, 1); $input = ''; + $input .= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >'; return $input; } @@ -3759,7 +3759,7 @@ function img_searchclear($titlealt = 'default', $other = '') $img = img_picto($titlealt, 'searchclear.png', $other, false, 1); $input = ''; + $input .= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >'; return $input; } @@ -3780,10 +3780,10 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss if ($infoonimgalt) { - return img_picto($text, 'info', 'class="hideonsmartphone'.($morecss?' '.$morecss:'').'"'); + return img_picto($text, 'info', 'class="hideonsmartphone'.($morecss ? ' '.$morecss : '').'"'); } - return ($nodiv?'':'
    ').' '.$text.($nodiv?'':'
    '); + return ($nodiv ? '' : '
    ').' '.$text.($nodiv ? '' : '
    '); } @@ -3800,16 +3800,16 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss */ function dol_print_error($db = '', $error = '', $errors = null) { - global $conf,$langs,$argv; + global $conf, $langs, $argv; global $dolibarr_main_prod; $out = ''; $syslog = ''; // Si erreur intervenue avant chargement langue - if (! $langs) + if (!$langs) { - require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs = new Translate('', $conf); $langs->load("main"); } @@ -3818,62 +3818,62 @@ function dol_print_error($db = '', $error = '', $errors = null) if ($_SERVER['DOCUMENT_ROOT']) // Mode web { - $out.=$langs->trans("DolibarrHasDetectedError").".
    \n"; - if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $out.="You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.
    \n"; - $out.=$langs->trans("InformationToHelpDiagnose").":
    \n"; + $out .= $langs->trans("DolibarrHasDetectedError").".
    \n"; + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.
    \n"; + $out .= $langs->trans("InformationToHelpDiagnose").":
    \n"; - $out.="".$langs->trans("Date").": ".dol_print_date(time(), 'dayhourlog')."
    \n"; - $out.="".$langs->trans("Dolibarr").": ".DOL_VERSION."
    \n"; - if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out.="".$langs->trans("LevelOfFeature").": ".$conf->global->MAIN_FEATURES_LEVEL."
    \n"; + $out .= "".$langs->trans("Date").": ".dol_print_date(time(), 'dayhourlog')."
    \n"; + $out .= "".$langs->trans("Dolibarr").": ".DOL_VERSION."
    \n"; + if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out .= "".$langs->trans("LevelOfFeature").": ".$conf->global->MAIN_FEATURES_LEVEL."
    \n"; if (function_exists("phpversion")) { - $out.="".$langs->trans("PHP").": ".phpversion()."
    \n"; + $out .= "".$langs->trans("PHP").": ".phpversion()."
    \n"; } - $out.="".$langs->trans("Server").": ".$_SERVER["SERVER_SOFTWARE"]."
    \n"; + $out .= "".$langs->trans("Server").": ".$_SERVER["SERVER_SOFTWARE"]."
    \n"; if (function_exists("php_uname")) { - $out.="".$langs->trans("OS").": ".php_uname()."
    \n"; + $out .= "".$langs->trans("OS").": ".php_uname()."
    \n"; } - $out.="".$langs->trans("UserAgent").": ".$_SERVER["HTTP_USER_AGENT"]."
    \n"; - $out.="
    \n"; - $out.="".$langs->trans("RequestedUrl").": ".dol_htmlentities($_SERVER["REQUEST_URI"], ENT_COMPAT, 'UTF-8')."
    \n"; - $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT, 'UTF-8'):'')."
    \n"; - $out.="".$langs->trans("MenuManager").": ".(isset($conf->standard_menu)?$conf->standard_menu:'')."
    \n"; - $out.="
    \n"; - $syslog.="url=".dol_escape_htmltag($_SERVER["REQUEST_URI"]); - $syslog.=", query_string=".dol_escape_htmltag($_SERVER["QUERY_STRING"]); + $out .= "".$langs->trans("UserAgent").": ".$_SERVER["HTTP_USER_AGENT"]."
    \n"; + $out .= "
    \n"; + $out .= "".$langs->trans("RequestedUrl").": ".dol_htmlentities($_SERVER["REQUEST_URI"], ENT_COMPAT, 'UTF-8')."
    \n"; + $out .= "".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"]) ?dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT, 'UTF-8') : '')."
    \n"; + $out .= "".$langs->trans("MenuManager").": ".(isset($conf->standard_menu) ? $conf->standard_menu : '')."
    \n"; + $out .= "
    \n"; + $syslog .= "url=".dol_escape_htmltag($_SERVER["REQUEST_URI"]); + $syslog .= ", query_string=".dol_escape_htmltag($_SERVER["QUERY_STRING"]); } else // Mode CLI { - $out.='> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n"; - $syslog.="pid=".dol_getmypid(); + $out .= '> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n"; + $syslog .= "pid=".dol_getmypid(); } - if (! empty($conf->modules)) + if (!empty($conf->modules)) { - $out.="".$langs->trans("Modules").": ".join(', ', $conf->modules)."
    \n"; + $out .= "".$langs->trans("Modules").": ".join(', ', $conf->modules)."
    \n"; } if (is_object($db)) { if ($_SERVER['DOCUMENT_ROOT']) // Mode web { - $out.="".$langs->trans("DatabaseTypeManager").": ".$db->type."
    \n"; - $out.="".$langs->trans("RequestLastAccessInError").": ".($db->lastqueryerror()?dol_escape_htmltag($db->lastqueryerror()):$langs->trans("ErrorNoRequestInError"))."
    \n"; - $out.="".$langs->trans("ReturnCodeLastAccessInError").": ".($db->lasterrno()?dol_escape_htmltag($db->lasterrno()):$langs->trans("ErrorNoRequestInError"))."
    \n"; - $out.="".$langs->trans("InformationLastAccessInError").": ".($db->lasterror()?dol_escape_htmltag($db->lasterror()):$langs->trans("ErrorNoRequestInError"))."
    \n"; - $out.="
    \n"; + $out .= "".$langs->trans("DatabaseTypeManager").": ".$db->type."
    \n"; + $out .= "".$langs->trans("RequestLastAccessInError").": ".($db->lastqueryerror() ?dol_escape_htmltag($db->lastqueryerror()) : $langs->trans("ErrorNoRequestInError"))."
    \n"; + $out .= "".$langs->trans("ReturnCodeLastAccessInError").": ".($db->lasterrno() ?dol_escape_htmltag($db->lasterrno()) : $langs->trans("ErrorNoRequestInError"))."
    \n"; + $out .= "".$langs->trans("InformationLastAccessInError").": ".($db->lasterror() ?dol_escape_htmltag($db->lasterror()) : $langs->trans("ErrorNoRequestInError"))."
    \n"; + $out .= "
    \n"; } else // Mode CLI { // No dol_escape_htmltag for output, we are in CLI mode - $out.='> '.$langs->transnoentities("DatabaseTypeManager").":\n".$db->type."\n"; - $out.='> '.$langs->transnoentities("RequestLastAccessInError").":\n".($db->lastqueryerror()?$db->lastqueryerror():$langs->transnoentities("ErrorNoRequestInError"))."\n"; - $out.='> '.$langs->transnoentities("ReturnCodeLastAccessInError").":\n".($db->lasterrno()?$db->lasterrno():$langs->transnoentities("ErrorNoRequestInError"))."\n"; - $out.='> '.$langs->transnoentities("InformationLastAccessInError").":\n".($db->lasterror()?$db->lasterror():$langs->transnoentities("ErrorNoRequestInError"))."\n"; + $out .= '> '.$langs->transnoentities("DatabaseTypeManager").":\n".$db->type."\n"; + $out .= '> '.$langs->transnoentities("RequestLastAccessInError").":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities("ErrorNoRequestInError"))."\n"; + $out .= '> '.$langs->transnoentities("ReturnCodeLastAccessInError").":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities("ErrorNoRequestInError"))."\n"; + $out .= '> '.$langs->transnoentities("InformationLastAccessInError").":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities("ErrorNoRequestInError"))."\n"; } - $syslog.=", sql=".$db->lastquery(); - $syslog.=", db_error=".$db->lasterror(); + $syslog .= ", sql=".$db->lastquery(); + $syslog .= ", db_error=".$db->lasterror(); } if ($error || $errors) @@ -3881,33 +3881,33 @@ function dol_print_error($db = '', $error = '', $errors = null) $langs->load("errors"); // Merge all into $errors array - if (is_array($error) && is_array($errors)) $errors=array_merge($error, $errors); - elseif (is_array($error)) $errors=$error; - elseif (is_array($errors)) $errors=array_merge(array($error), $errors); - else $errors=array_merge(array($error)); + if (is_array($error) && is_array($errors)) $errors = array_merge($error, $errors); + elseif (is_array($error)) $errors = $error; + elseif (is_array($errors)) $errors = array_merge(array($error), $errors); + else $errors = array_merge(array($error)); - foreach($errors as $msg) + foreach ($errors as $msg) { if (empty($msg)) continue; if ($_SERVER['DOCUMENT_ROOT']) // Mode web { - $out.="".$langs->trans("Message").": ".dol_escape_htmltag($msg)."
    \n" ; + $out .= "".$langs->trans("Message").": ".dol_escape_htmltag($msg)."
    \n"; } else // Mode CLI { - $out.='> '.$langs->transnoentities("Message").":\n".$msg."\n" ; + $out .= '> '.$langs->transnoentities("Message").":\n".$msg."\n"; } - $syslog.=", msg=".$msg; + $syslog .= ", msg=".$msg; } } if (empty($dolibarr_main_prod) && $_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_print_function_stack') && function_exists('xdebug_call_file')) { xdebug_print_function_stack(); - $out.='XDebug informations:'."
    \n"; - $out.='File: '.xdebug_call_file()."
    \n"; - $out.='Line: '.xdebug_call_line()."
    \n"; - $out.='Function: '.xdebug_call_function()."
    \n"; - $out.="
    \n"; + $out .= 'XDebug informations:'."
    \n"; + $out .= 'File: '.xdebug_call_file()."
    \n"; + $out .= 'Line: '.xdebug_call_line()."
    \n"; + $out .= 'Function: '.xdebug_call_function()."
    \n"; + $out .= "
    \n"; } if (empty($dolibarr_main_prod)) print $out; @@ -3935,19 +3935,19 @@ function dol_print_error($db = '', $error = '', $errors = null) */ function dol_print_error_email($prefixcode, $errormessage = '', $errormessages = array(), $morecss = 'error', $email = '') { - global $langs,$conf; + global $langs, $conf; - if (empty($email)) $email=$conf->global->MAIN_INFO_SOCIETE_MAIL; + if (empty($email)) $email = $conf->global->MAIN_INFO_SOCIETE_MAIL; $langs->load("errors"); - $now=dol_now(); + $now = dol_now(); print '
    '.$langs->trans("ColorUser").''; @@ -1760,15 +1760,15 @@ else } // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print '
    ' . $langs->trans("Categories") . '
    '.$langs->trans("Categories").''; print $form->showCategories($object->id, 'user', 1); print '
    '.$langs->trans("OpenIDURL").''.$object->openid.'
    ' . $langs->trans("Entity") . ''; + print '
    '.$langs->trans("Entity").''; if (empty($object->entity)) { print $langs->trans("AllEntities"); } else { @@ -1804,10 +1804,10 @@ else } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Company / Contact - if (! empty($conf->societe->enabled)) + if (!empty($conf->societe->enabled)) { print '
    '.$langs->trans("LinkToCompanyContact").''; @@ -1821,7 +1821,7 @@ else { print $langs->trans("ThisUserIsNot"); } - if (! empty($object->contactid)) + if (!empty($object->contactid)) { $contact = new Contact($db); $contact->fetch($object->contactid); @@ -1834,16 +1834,16 @@ else } // Module Adherent - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { $langs->load("members"); print '
    '.$langs->trans("LinkedToDolibarrMember").''; if ($object->fk_member) { - $adh=new Adherent($db); + $adh = new Adherent($db); $adh->fetch($object->fk_member); - $adh->ref=$adh->getFullname($langs); // Force to show login instead of id + $adh->ref = $adh->getFullname($langs); // Force to show login instead of id print $adh->getNomUrl(1); } else @@ -1875,11 +1875,11 @@ else print '
    '; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - if (! empty($object->email)) + if (!empty($object->email)) { $langs->load("mails"); print ''; @@ -1890,9 +1890,9 @@ else print ''; } - if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { - if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) + if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { print ''; } @@ -1901,8 +1901,8 @@ else print ''; } } - elseif ($caneditpassword && ! $object->ldap_sid && - (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + elseif ($caneditpassword && !$object->ldap_sid && + (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } @@ -1915,7 +1915,7 @@ else print ''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } @@ -1925,7 +1925,7 @@ else print ''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { if ($object->email) print ''; else print ''; @@ -1934,13 +1934,13 @@ else // Enable user if ($user->id <> $id && $candisableuser && $object->statut == 0 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } // Disable user if ($user->id <> $id && $candisableuser && $object->statut == 1 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } @@ -1953,9 +1953,9 @@ else } // Delete if ($user->id <> $id && $candisableuser && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { - if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin + if ($user->admin || !$object->admin) // If user edited is admin, delete is possible on for an admin { print ''; } @@ -1974,8 +1974,8 @@ else if (GETPOST('modelselected')) $action = 'presend'; // Presend form - $modelmail='user'; - $defaulttopic='Information'; + $modelmail = 'user'; + $defaulttopic = 'Information'; $diroutput = $conf->user->dir_output; $trackid = 'use'.$object->id; @@ -1994,14 +1994,14 @@ else // On selectionne les groupes auquel fait parti le user $exclude = array(); - $usergroup=new UserGroup($db); + $usergroup = new UserGroup($db); $groupslist = $usergroup->listGroupsForUser($object->id); - if (! empty($groupslist)) + if (!empty($groupslist)) { - foreach($groupslist as $groupforuser) + foreach ($groupslist as $groupforuser) { - $exclude[]=$groupforuser->id; + $exclude[] = $groupforuser->id; } } @@ -2015,8 +2015,8 @@ else print ''."\n"; // Other form for add user to group - $parameters=array('caneditgroup' => $caneditgroup, 'groupslist' => $groupslist, 'exclude' => $exclude); - $reshook=$hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('caneditgroup' => $caneditgroup, 'groupslist' => $groupslist, 'exclude' => $exclude); + $reshook = $hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) @@ -2035,9 +2035,9 @@ else /* * Groups assigned to user */ - if (! empty($groupslist)) + if (!empty($groupslist)) { - foreach($groupslist as $group) + foreach ($groupslist as $group) { print ''; print '
    '; @@ -2096,7 +2096,7 @@ else print ''; // Ref/ID - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; print '".''; print ''; print '\n"; // API key - if(! empty($conf->api->enabled) && $user->admin) + if (!empty($conf->api->enabled) && $user->admin) { print ''; print ''; } @@ -2215,13 +2215,13 @@ else && ($user->id != $object->id) // Don't downgrade ourself && ( (empty($conf->multicompany->enabled) && $nbAdmin >= 1) - || (! empty($conf->multicompany->enabled) && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone + || (!empty($conf->multicompany->enabled) && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone ) ) { print $form->selectyesno('admin', $object->admin, 1); - if (! empty($conf->multicompany->enabled) && ! $user->entity) + if (!empty($conf->multicompany->enabled) && !$user->entity) { if ($conf->use_javascript_ajax) { @@ -2262,7 +2262,7 @@ else '; } - $checked=(($object->admin && ! $object->entity) ? ' checked' : ''); + $checked = (($object->admin && !$object->entity) ? ' checked' : ''); print ' '.$langs->trans("SuperAdministrator"); } } @@ -2271,7 +2271,7 @@ else $yn = yn($object->admin); print ''; print ''; - if (! empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn, $langs->trans("DontDowngradeSuperAdmin"), 1, 'warning'); + if (!empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn, $langs->trans("DontDowngradeSuperAdmin"), 1, 'warning'); else print $yn; } print ''; @@ -2280,17 +2280,17 @@ else // Type print ''; print ''; print ''; // Employee @@ -2309,7 +2309,7 @@ else if ($caneditfield) { print $form->selectyesno("employee", $object->employee, 1); } else { - if ($object->employee){ + if ($object->employee) { print $langs->trans("Yes"); } else { print $langs->trans("No"); @@ -2327,7 +2327,7 @@ else else { print ''; - $huser=new User($db); + $huser = new User($db); $huser->fetch($object->fk_user); print $huser->getNomUrl(1); } @@ -2347,7 +2347,7 @@ else else { print ''; - $evuser=new User($db); + $evuser = new User($db); $evuser->fetch($object->fk_user_expense_validator); print $evuser->getNomUrl(1); } @@ -2367,7 +2367,7 @@ else else { print ''; - $hvuser=new User($db); + $hvuser = new User($db); $hvuser->fetch($object->fk_user_holiday_validator); print $hvuser->getNomUrl(1); } @@ -2396,7 +2396,7 @@ else // Country print ''; @@ -2411,7 +2411,7 @@ else // Tel pro print "".''; print '".''; print ''; // EMail - print "".'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; + print "".'global->USER_MAIL_REQUIRED) ? ' class="fieldrequired"' : '').'>'.img_picto('', 'object_email').' '.$langs->trans("EMail").''; print ''; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { print ''; print '".''; print ''; print ''; @@ -2614,7 +2614,7 @@ else // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print ''; + print ''; print '"; @@ -2638,7 +2638,7 @@ else print ''; // Company / Contact - if (! empty($conf->societe->enabled)) + if (!empty($conf->societe->enabled)) { print ''; print ''; print '".''; - print "\n"; } else @@ -2705,15 +2705,15 @@ else } // Other attributes - $parameters=array('colspan' => ' colspan="2"'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('colspan' => ' colspan="2"'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { if ($caneditfield) { print $object->showOptionals($extrafields, 'edit'); - }else{ + } else { print $object->showOptionals($extrafields, 'view'); } } @@ -2724,7 +2724,7 @@ else if ($caneditfield) { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('signature', $object->signature, '', 138, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1, ROWS_4, '90%'); + $doleditor = new DolEditor('signature', $object->signature, '', 138, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); print $doleditor->Create(1); } else @@ -2740,7 +2740,7 @@ else // TODO Move this into tab RH (HierarchicalResponsible must be on both tab) // Default warehouse - if (! empty($conf->stock->enabled) && ! empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? + if (!empty($conf->stock->enabled) && !empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? { print ''; - if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) - || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) + || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); // THM print ''; print ''; print "\n"; // TJM print ''; print ''; print "\n"; @@ -2799,7 +2799,7 @@ else // Salary print ''; print ''; print "\n"; } @@ -2807,10 +2807,10 @@ else // Weeklyhours print ''; print ''; @@ -2819,10 +2819,10 @@ else // Date employment print ''; print ''; @@ -2831,10 +2831,10 @@ else // Date employmentEnd print ''; print ''; @@ -2844,10 +2844,10 @@ else // Date birth print ''; print ''; @@ -2873,8 +2873,8 @@ else * Documents generes */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->user->dir_output . "/" . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $filedir = $conf->user->dir_output."/".dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->rights->user->user->lire; $delallowed = $user->rights->user->user->creer; @@ -2888,7 +2888,7 @@ else print '
    '; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'user', $socid, 1); @@ -2896,11 +2896,11 @@ else print '
    '; } - if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) $ldap->close(); + if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) $ldap->close(); } } -if (! empty($conf->api->enabled) && ! empty($conf->use_javascript_ajax)) +if (!empty($conf->api->enabled) && !empty($conf->use_javascript_ajax)) { print "\n".''; - $out.=$this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); - $out.=' '; - $out.='
    '; + $out .= ''; + $out .= ''; + $out .= $this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); + $out .= ' '; + $out .= '
    '; } - $assignedtouser=array(); + $assignedtouser = array(); if (!empty($_SESSION['assignedtouser'])) { - $assignedtouser=json_decode($_SESSION['assignedtouser'], true); + $assignedtouser = json_decode($_SESSION['assignedtouser'], true); } - $nbassignetouser=count($assignedtouser); + $nbassignetouser = count($assignedtouser); - if ($nbassignetouser && $action != 'view') $out.='
    '; - if ($nbassignetouser) $out.='
      '; - $i=0; $ownerid=0; - foreach($assignedtouser as $key => $value) + if ($nbassignetouser && $action != 'view') $out .= '
      '; + if ($nbassignetouser) $out .= '
        '; + $i = 0; $ownerid = 0; + foreach ($assignedtouser as $key => $value) { if ($value['id'] == $ownerid) continue; - $out.='
      • '; + $out .= '
      • '; $userstatic->fetch($value['id']); - $out.= $userstatic->getNomUrl(-1); - if ($i == 0) { $ownerid = $value['id']; $out.=' ('.$langs->trans("Owner").')'; } + $out .= $userstatic->getNomUrl(-1); + if ($i == 0) { $ownerid = $value['id']; $out .= ' ('.$langs->trans("Owner").')'; } if ($nbassignetouser > 1 && $action != 'view') { - $out.=' '; + $out .= ' '; } // Show my availability if ($showproperties) { if ($ownerid == $value['id'] && is_array($listofuserid) && count($listofuserid) && in_array($ownerid, array_keys($listofuserid))) { - $out.='
        '; - $out.=' - '.$langs->trans("Availability").': '.$langs->trans("Busy"); - $out.='
        '; + $out .= '
        '; + $out .= ' - '.$langs->trans("Availability").': '.$langs->trans("Busy"); + $out .= '
        '; } } //$out.=' '.($value['mandatory']?$langs->trans("Mandatory"):$langs->trans("Optional")); //$out.=' '.($value['transparency']?$langs->trans("Busy"):$langs->trans("NotBusy")); - $out.='
      • '; + $out .= ''; $i++; } - if ($nbassignetouser) $out.='
      '; + if ($nbassignetouser) $out .= '
    '; //$out.=''; return $out; @@ -1897,31 +1897,31 @@ class Form public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = array()) { // phpcs:enable - global $langs,$conf; + global $langs, $conf; // check parameters - $price_level = (! empty($price_level) ? $price_level : 0); - if (is_null($ajaxoptions)) $ajaxoptions=array(); + $price_level = (!empty($price_level) ? $price_level : 0); + if (is_null($ajaxoptions)) $ajaxoptions = array(); - if(strval($filtertype) === '' && (!empty($conf->product->enabled) || !empty($conf->service->enabled))){ - if(!empty($conf->product->enabled) && empty($conf->service->enabled)){ + if (strval($filtertype) === '' && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { + if (!empty($conf->product->enabled) && empty($conf->service->enabled)) { $filtertype = '0'; } - elseif(empty($conf->product->enabled) && !empty($conf->service->enabled)){ + elseif (empty($conf->product->enabled) && !empty($conf->service->enabled)) { $filtertype = '1'; } } - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { - $placeholder=''; + $placeholder = ''; if ($selected && empty($selected_input_value)) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $producttmpselect = new Product($this->db); $producttmpselect->fetch($selected); - $selected_input_value=$producttmpselect->ref; + $selected_input_value = $producttmpselect->ref; unset($producttmpselect); } // handle case where product or service module is disabled + no filter specified @@ -1935,10 +1935,10 @@ class Form } } // mode=1 means customers products - $urloption='htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus; + $urloption = 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus; //Price by customer - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { - $urloption.='&socid='.$socid; + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { + $urloption .= '&socid='.$socid; } print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); @@ -2017,7 +2017,7 @@ class Form } if (empty($hidelabel)) print $langs->trans("RefOrLabel").' : '; elseif ($hidelabel > 1) { - $placeholder=' placeholder="'.$langs->trans("RefOrLabel").'"'; + $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"'; if ($hidelabel == 2) { print img_picto($langs->trans("Search"), 'search'); } @@ -2060,10 +2060,10 @@ class Form public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') { // phpcs:enable - global $langs,$conf,$user,$db; + global $langs, $conf, $user, $db; - $out=''; - $outarray=array(); + $out = ''; + $outarray = array(); // Units if ($conf->global->PRODUCT_USE_UNITS) { @@ -2071,7 +2071,7 @@ class Form } $warehouseStatusArray = array(); - if (! empty($warehouseStatus)) + if (!empty($warehouseStatus)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; if (preg_match('/warehouseclosed/', $warehouseStatus)) @@ -2091,7 +2091,7 @@ class Form $selectFields = " p.rowid, p.label, p.ref, p.description, p.barcode, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression"; if (count($warehouseStatusArray)) { - $selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock + $selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock } else { @@ -2099,12 +2099,12 @@ class Form } $sql = "SELECT "; - $sql.= $selectFields . $selectFieldsGrouped; + $sql .= $selectFields.$selectFieldsGrouped; - if (! empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) + if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) { //Product category - $sql.= ", (SELECT ".MAIN_DB_PREFIX."categorie_product.fk_categorie + $sql .= ", (SELECT ".MAIN_DB_PREFIX."categorie_product.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_product WHERE ".MAIN_DB_PREFIX."categorie_product.fk_product=p.rowid LIMIT 1 @@ -2112,70 +2112,70 @@ class Form } //Price by customer - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { - $sql.=', pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,'; - $sql.=' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx'; - $selectFields.= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx"; + $sql .= ', pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,'; + $sql .= ' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx'; + $selectFields .= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx"; } // Units - if (! empty($conf->global->PRODUCT_USE_UNITS)) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; $selectFields .= ', unit_long, unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units'; } // Multilang : we add translation - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { - $sql.= ", pl.label as label_translated"; - $selectFields.= ", label_translated"; + $sql .= ", pl.label as label_translated"; + $selectFields .= ", label_translated"; } // Price by quantity - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - $sql.= ", (SELECT pp.rowid FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid"; - if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $sql.= " AND price_level=".$price_level; - $sql.= " ORDER BY date_price"; - $sql.= " DESC LIMIT 1) as price_rowid"; - $sql.= ", (SELECT pp.price_by_qty FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid"; // price_by_qty is 1 if some prices by qty exists in subtable - if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $sql.= " AND price_level=".$price_level; - $sql.= " ORDER BY date_price"; - $sql.= " DESC LIMIT 1) as price_by_qty"; - $selectFields.= ", price_rowid, price_by_qty"; + $sql .= ", (SELECT pp.rowid FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid"; + if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $sql .= " AND price_level=".$price_level; + $sql .= " ORDER BY date_price"; + $sql .= " DESC LIMIT 1) as price_rowid"; + $sql .= ", (SELECT pp.price_by_qty FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid"; // price_by_qty is 1 if some prices by qty exists in subtable + if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $sql .= " AND price_level=".$price_level; + $sql .= " ORDER BY date_price"; + $sql .= " DESC LIMIT 1) as price_by_qty"; + $selectFields .= ", price_rowid, price_by_qty"; } - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if (count($warehouseStatusArray)) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_product = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (".getEntity('stock').")"; - $sql.= ' AND e.statut IN ('.$this->db->escape(implode(',', $warehouseStatusArray)).')'; // Return line if product is inside the selected stock. If not, an empty line will be returned so we will count 0. + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_product = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (".getEntity('stock').")"; + $sql .= ' AND e.statut IN ('.$this->db->escape(implode(',', $warehouseStatusArray)).')'; // Return line if product is inside the selected stock. If not, an empty line will be returned so we will count 0. } // include search in supplier ref - if(!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) + if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; } //Price by customer - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid"; + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid"; } // Units - if (! empty($conf->global->PRODUCT_USE_UNITS)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_units u ON u.rowid = p.fk_unit"; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; } // Multilang : we add translation - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='". $langs->getDefaultLang() ."'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='".$langs->getDefaultLang()."'"; } if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } - $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; + $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { $sql .= " AND pac.rowid IS NULL"; @@ -2183,103 +2183,103 @@ class Form if ($finished == 0) { - $sql.= " AND p.finished = ".$finished; + $sql .= " AND p.finished = ".$finished; } elseif ($finished == 1) { - $sql.= " AND p.finished = ".$finished; - if ($status >= 0) $sql.= " AND p.tosell = ".$status; + $sql .= " AND p.finished = ".$finished; + if ($status >= 0) $sql .= " AND p.tosell = ".$status; } elseif ($status >= 0) { - $sql.= " AND p.tosell = ".$status; + $sql .= " AND p.tosell = ".$status; } // Filter by product type - if (strval($filtertype) != '') $sql.= " AND p.fk_product_type = ".$filtertype; + if (strval($filtertype) != '') $sql .= " AND p.fk_product_type = ".$filtertype; elseif (empty($conf->product->enabled)) { // when product module is disabled, show services only - $sql.= " AND p.fk_product_type = 1"; + $sql .= " AND p.fk_product_type = 1"; } elseif (empty($conf->service->enabled)) { // when service module is disabled, show products only - $sql.= " AND p.fk_product_type = 0"; + $sql .= " AND p.fk_product_type = 0"; } // Add criteria on ref/label if ($filterkey != '') { - $sql.=' AND ('; - $prefix=empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)?'%':''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on + $sql .= ' AND ('; + $prefix = empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on // For natural search $scrit = explode(' ', $filterkey); - $i=0; - if (count($scrit) > 1) $sql.="("; + $i = 0; + if (count($scrit) > 1) $sql .= "("; foreach ($scrit as $crit) { - if ($i > 0) $sql.=" AND "; - $sql.="(p.ref LIKE '".$db->escape($prefix.$crit)."%' OR p.label LIKE '".$db->escape($prefix.$crit)."%'"; - if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '".$db->escape($prefix.$crit)."%'"; + if ($i > 0) $sql .= " AND "; + $sql .= "(p.ref LIKE '".$db->escape($prefix.$crit)."%' OR p.label LIKE '".$db->escape($prefix.$crit)."%'"; + if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " OR pl.label LIKE '".$db->escape($prefix.$crit)."%'"; if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION)) { - $sql.=" OR p.description LIKE '".$db->escape($prefix.$crit)."%'"; - if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.description LIKE '".$db->escape($prefix.$crit)."%'"; + $sql .= " OR p.description LIKE '".$db->escape($prefix.$crit)."%'"; + if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " OR pl.description LIKE '".$db->escape($prefix.$crit)."%'"; } - if (! empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) $sql.=" OR pfp.ref_fourn LIKE '".$db->escape($prefix.$crit)."%'"; - $sql.=")"; + if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) $sql .= " OR pfp.ref_fourn LIKE '".$db->escape($prefix.$crit)."%'"; + $sql .= ")"; $i++; } - if (count($scrit) > 1) $sql.=")"; - if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$db->escape($prefix.$filterkey)."%'"; - $sql.=')'; + if (count($scrit) > 1) $sql .= ")"; + if (!empty($conf->barcode->enabled)) $sql .= " OR p.barcode LIKE '".$db->escape($prefix.$filterkey)."%'"; + $sql .= ')'; } if (count($warehouseStatusArray)) { - $sql.= ' GROUP BY'.$selectFields; + $sql .= ' GROUP BY'.$selectFields; } //Sort by category - if(! empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) + if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) { $sql .= " ORDER BY categorie_product_id "; //ASC OR DESC order - ($conf->global->PRODUCT_SORT_BY_CATEGORY == 1) ? $sql .="ASC" : $sql .="DESC"; + ($conf->global->PRODUCT_SORT_BY_CATEGORY == 1) ? $sql .= "ASC" : $sql .= "DESC"; } else { - $sql.= $db->order("p.ref"); + $sql .= $db->order("p.ref"); } - $sql.= $db->plimit($limit, 0); + $sql .= $db->plimit($limit, 0); // Build output string dol_syslog(get_class($this)."::select_produits_list search product", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; $num = $this->db->num_rows($result); - $events=null; + $events = null; - if (! $forcecombo) + if (!$forcecombo) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname, $events, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); } - $out.=''; - $textifempty=''; + $textifempty = ''; // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty=''; - if (! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) + if (!empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { - if ($showempty && ! is_numeric($showempty)) $textifempty=$langs->trans($showempty); - else $textifempty.=$langs->trans("All"); + if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); + else $textifempty .= $langs->trans("All"); } else { - if ($showempty && ! is_numeric($showempty)) $textifempty=$langs->trans($showempty); + if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); } - if ($showempty) $out.=''; + if ($showempty) $out .= ''; $i = 0; while ($num && $i < $num) @@ -2291,9 +2291,9 @@ class Form if ((!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1) { // Price by quantity will return many prices for the same product $sql = "SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql.= " WHERE fk_product_price=".$objp->price_rowid; - $sql.= " ORDER BY quantity ASC"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; + $sql .= " WHERE fk_product_price=".$objp->price_rowid; + $sql .= " ORDER BY quantity ASC"; dol_syslog(get_class($this)."::select_produits_list search price by qty", LOG_DEBUG); $result2 = $this->db->query($sql); @@ -2323,7 +2323,7 @@ class Form // Add new entry // "key" value of json key array is used by jQuery automatically as selected value // "label" value of json key array is used by jQuery automatically as text for combo box - $out.=$opt; + $out .= $opt; array_push($outarray, $optJson); } } @@ -2347,14 +2347,14 @@ class Form // Add new entry // "key" value of json key array is used by jQuery automatically as selected value // "label" value of json key array is used by jQuery automatically as text for combo box - $out.=$opt; + $out .= $opt; array_push($outarray, $optJson); } $i++; } - $out.=''; + $out .= ''; $this->db->free($result); @@ -2384,59 +2384,59 @@ class Form { global $langs, $conf, $user, $db; - $outkey=''; - $outval=''; - $outref=''; - $outlabel=''; - $outdesc=''; - $outbarcode=''; - $outtype=''; - $outprice_ht=''; - $outprice_ttc=''; - $outpricebasetype=''; - $outtva_tx=''; - $outqty=1; - $outdiscount=0; + $outkey = ''; + $outval = ''; + $outref = ''; + $outlabel = ''; + $outdesc = ''; + $outbarcode = ''; + $outtype = ''; + $outprice_ht = ''; + $outprice_ttc = ''; + $outpricebasetype = ''; + $outtva_tx = ''; + $outqty = 1; + $outdiscount = 0; - $maxlengtharticle=(empty($conf->global->PRODUCT_MAX_LENGTH_COMBO)?48:$conf->global->PRODUCT_MAX_LENGTH_COMBO); + $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO); - $label=$objp->label; - if (! empty($objp->label_translated)) $label=$objp->label_translated; - if (! empty($filterkey) && $filterkey != '') $label=preg_replace('/('.preg_quote($filterkey).')/i', '$1', $label, 1); + $label = $objp->label; + if (!empty($objp->label_translated)) $label = $objp->label_translated; + if (!empty($filterkey) && $filterkey != '') $label = preg_replace('/('.preg_quote($filterkey).')/i', '$1', $label, 1); - $outkey=$objp->rowid; - $outref=$objp->ref; - $outlabel=$objp->label; - $outdesc=$objp->description; - $outbarcode=$objp->barcode; + $outkey = $objp->rowid; + $outref = $objp->ref; + $outlabel = $objp->label; + $outdesc = $objp->description; + $outbarcode = $objp->barcode; - $outtype=$objp->fk_product_type; - $outdurationvalue=$outtype == Product::TYPE_SERVICE?substr($objp->duration, 0, dol_strlen($objp->duration)-1):''; - $outdurationunit=$outtype == Product::TYPE_SERVICE?substr($objp->duration, -1):''; + $outtype = $objp->fk_product_type; + $outdurationvalue = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; + $outdurationunit = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, -1) : ''; // Units $outvalUnits = ''; - if (! empty($conf->global->PRODUCT_USE_UNITS)) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { if (!empty($objp->unit_short)) { - $outvalUnits .= ' - ' . $objp->unit_short; + $outvalUnits .= ' - '.$objp->unit_short; } } - if (! empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) { - if (!empty($objp->weight) && $objp->weight_units!==null) { + if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) { + if (!empty($objp->weight) && $objp->weight_units !== null) { $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); - $outvalUnits .= ' - ' . $unitToShow; + $outvalUnits .= ' - '.$unitToShow; } - if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units!==null) { - $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuringUnitString(0, 'size', $objp->length_units); - $outvalUnits .= ' - ' . $unitToShow; + if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { + $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); + $outvalUnits .= ' - '.$unitToShow; } - if (!empty($objp->surface) && $objp->surface_units!==null) { + if (!empty($objp->surface) && $objp->surface_units !== null) { $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); - $outvalUnits .= ' - ' . $unitToShow; + $outvalUnits .= ' - '.$unitToShow; } - if (!empty($objp->volume) && $objp->volume_units!==null) { + if (!empty($objp->volume) && $objp->volume_units !== null) { $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); - $outvalUnits .= ' - ' . $unitToShow; + $outvalUnits .= ' - '.$unitToShow; } } if ($outdurationvalue && $outdurationunit) { @@ -2448,50 +2448,50 @@ class Form 'y' => $langs->trans('Year') ); if (isset($da[$outdurationunit])) { - $outvalUnits .= ' - ' . $outdurationvalue . ' ' . $langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); + $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); } } $opt = '\n"; + $opt .= "\n"; $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit); } @@ -2663,25 +2663,25 @@ class Form public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '') { // phpcs:enable - global $langs,$conf; + global $langs, $conf; global $price_level, $status, $finished; - $selected_input_value=''; - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) + $selected_input_value = ''; + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { if ($selected > 0) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $producttmpselect = new Product($this->db); $producttmpselect->fetch($selected); - $selected_input_value=$producttmpselect->ref; + $selected_input_value = $producttmpselect->ref; unset($producttmpselect); } // mode=2 means suppliers products - $urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice; + $urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice; print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); - print ($hidelabel?'':$langs->trans("RefOrLabel").' : ').''; + print ($hidelabel ? '' : $langs->trans("RefOrLabel").' : ').''; } else { @@ -2709,10 +2709,10 @@ class Form public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') { // phpcs:enable - global $langs,$conf,$db; + global $langs, $conf, $db; - $out=''; - $outarray=array(); + $out = ''; + $outarray = array(); $langs->load('stocks'); // Units @@ -2721,55 +2721,55 @@ class Form } $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration, p.fk_product_type,"; - $sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,"; - $sql.= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; - $sql.= " pfp.supplier_reputation"; + $sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,"; + $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; + $sql .= " pfp.supplier_reputation"; // Units if ($conf->global->PRODUCT_USE_UNITS) { $sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units"; } - if (! empty($conf->barcode->enabled)) $sql.= " ,pfp.barcode"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; - if ($socid) $sql.= " AND pfp.fk_soc = ".$socid; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; + if (!empty($conf->barcode->enabled)) $sql .= " ,pfp.barcode"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; + if ($socid) $sql .= " AND pfp.fk_soc = ".$socid; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; // Units if ($conf->global->PRODUCT_USE_UNITS) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_units u ON u.rowid = p.fk_unit"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units u ON u.rowid = p.fk_unit"; } - $sql.= " WHERE p.entity IN (".getEntity('product').")"; - $sql.= " AND p.tobuy = 1"; - if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$this->db->escape($filtertype); - if (! empty($filtre)) $sql.=" ".$filtre; + $sql .= " WHERE p.entity IN (".getEntity('product').")"; + $sql .= " AND p.tobuy = 1"; + if (strval($filtertype) != '') $sql .= " AND p.fk_product_type=".$this->db->escape($filtertype); + if (!empty($filtre)) $sql .= " ".$filtre; // Add criteria on ref/label if ($filterkey != '') { - $sql.=' AND ('; - $prefix=empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)?'%':''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on + $sql .= ' AND ('; + $prefix = empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on // For natural search $scrit = explode(' ', $filterkey); - $i=0; - if (count($scrit) > 1) $sql.="("; + $i = 0; + if (count($scrit) > 1) $sql .= "("; foreach ($scrit as $crit) { - if ($i > 0) $sql.=" AND "; - $sql.="(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%')"; + if ($i > 0) $sql .= " AND "; + $sql .= "(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%')"; $i++; } - if (count($scrit) > 1) $sql.=")"; - if (! empty($conf->barcode->enabled)){ - $sql.= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; - $sql.= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + if (count($scrit) > 1) $sql .= ")"; + if (!empty($conf->barcode->enabled)) { + $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + $sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; } - $sql.=')'; + $sql .= ')'; } - $sql.= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; - $sql.= $db->plimit($limit, 0); + $sql .= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; + $sql .= $db->plimit($limit, 0); // Build output string dol_syslog(get_class($this)."::select_produits_fournisseurs_list", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; @@ -2777,47 +2777,47 @@ class Form $num = $this->db->num_rows($result); //$out.=''; - if (! $selected) $out.=''; - else $out.=''; + $out .= ''; + $out .= ''; $this->db->free($result); - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.=ajax_combobox($htmlname); + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlname); if (empty($outputmode)) return $out; return $outarray; @@ -2997,24 +2997,24 @@ class Form public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') { // phpcs:enable - global $langs,$conf; + global $langs, $conf; $langs->load('stocks'); $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration, pfp.fk_soc,"; - $sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,"; - $sql.= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; - $sql.= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; - $sql.= " AND p.tobuy = 1"; - $sql.= " AND s.fournisseur = 1"; - $sql.= " AND p.rowid = ".$productid; - $sql.= " ORDER BY s.nom, pfp.ref_fourn DESC"; + $sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,"; + $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; + $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; + $sql .= " AND p.tobuy = 1"; + $sql .= " AND s.fournisseur = 1"; + $sql .= " AND p.rowid = ".$productid; + $sql .= " ORDER BY s.nom, pfp.ref_fourn DESC"; dol_syslog(get_class($this)."::select_product_fourn_price", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { @@ -3022,14 +3022,14 @@ class Form $form = ''; + $form .= ''; $this->db->free($result); return $form; } @@ -3113,12 +3113,12 @@ class Form // phpcs:enable // looking for users $sql = "SELECT a.rowid, a.label"; - $sql .= " FROM ".MAIN_DB_PREFIX ."societe_address as a"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_address as a"; $sql .= " WHERE a.fk_soc = ".$socid; $sql .= " ORDER BY a.label ASC"; dol_syslog(get_class($this)."::select_address", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { print ''; if ($addempty) print ''; - foreach($this->cache_availability as $id => $arrayavailability) + foreach ($this->cache_availability as $id => $arrayavailability) { if ($selected == $id) { @@ -3296,34 +3296,34 @@ class Form global $langs; $num = count($this->cache_demand_reason); - if ($num > 0) return 0; // Cache already loaded + if ($num > 0) return 0; // Cache already loaded $sql = "SELECT rowid, code, label"; - $sql.= " FROM ".MAIN_DB_PREFIX.'c_input_reason'; - $sql.= " WHERE active > 0"; + $sql .= " FROM ".MAIN_DB_PREFIX.'c_input_reason'; + $sql .= " WHERE active > 0"; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - $tmparray=array(); + $tmparray = array(); while ($i < $num) { $obj = $this->db->fetch_object($resql); // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $label=($obj->label!='-'?$obj->label:''); + $label = ($obj->label != '-' ? $obj->label : ''); if ($langs->trans("DemandReasonType".$obj->code) != ("DemandReasonType".$obj->code)) $label = $langs->trans("DemandReasonType".$obj->code); // So translation key DemandReasonTypeSRC_XXX will work - if ($langs->trans($obj->code) != $obj->code) $label=$langs->trans($obj->code); // So translation key SRC_XXX will work + if ($langs->trans($obj->code) != $obj->code) $label = $langs->trans($obj->code); // So translation key SRC_XXX will work - $tmparray[$obj->rowid]['id'] =$obj->rowid; - $tmparray[$obj->rowid]['code'] =$obj->code; - $tmparray[$obj->rowid]['label']=$label; + $tmparray[$obj->rowid]['id'] = $obj->rowid; + $tmparray[$obj->rowid]['code'] = $obj->code; + $tmparray[$obj->rowid]['label'] = $label; $i++; } - $this->cache_demand_reason=dol_sort_array($tmparray, 'label', 'asc', 0, 0, 1); + $this->cache_demand_reason = dol_sort_array($tmparray, 'label', 'asc', 0, 0, 1); unset($tmparray); return $num; @@ -3347,15 +3347,15 @@ class Form */ public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0) { - global $langs,$user; + global $langs, $user; $this->loadCacheInputReason(); print ''; + print ''; + print ''; - if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin && !$noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } @@ -3546,26 +3546,26 @@ class Form { global $langs; - $return=''; + $return = ''; - $return.= ''; $options = array( 'HT'=>$langs->trans("HT"), 'TTC'=>$langs->trans("TTC") ); - foreach($options as $id => $value) + foreach ($options as $id => $value) { if ($selected == $id) { - $return.= ''; + $return .= ''; } - $return.= ''; + $return .= ''; return $return; } @@ -3588,10 +3588,10 @@ class Form $langs->load("deliveries"); $sql = "SELECT rowid, code, libelle as label"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode"; - $sql.= " WHERE active > 0"; - if ($filtre) $sql.=" AND ".$filtre; - $sql.= " ORDER BY libelle ASC"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode"; + $sql .= " WHERE active > 0"; + if ($filtre) $sql .= " AND ".$filtre; + $sql .= " ORDER BY libelle ASC"; dol_syslog(get_class($this)."::selectShippingMode", LOG_DEBUG); $result = $this->db->query($sql); @@ -3599,7 +3599,7 @@ class Form $num = $this->db->num_rows($result); $i = 0; if ($num) { - print ''; if ($useempty == 1 || ($useempty == 2 && $num > 1)) { print ''; } @@ -3648,7 +3648,7 @@ class Form print ''; } else { if ($selected) { - $code=$langs->getLabelFromKey($db, $selected, 'c_shipment_mode', 'rowid', 'code'); + $code = $langs->getLabelFromKey($db, $selected, 'c_shipment_mode', 'rowid', 'code'); print $langs->trans("SendingMethod".strtoupper($code)); } else { print " "; @@ -3672,15 +3672,15 @@ class Form $opt = ''; $sql = 'SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc'; - $sql.= ' FROM ' . MAIN_DB_PREFIX . 'facture'; - $sql.= ' WHERE entity IN ('.getEntity('invoice').')'; - $sql.= ' AND situation_counter>=1'; - $sql.= ' ORDER by situation_cycle_ref, situation_counter desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture'; + $sql .= ' WHERE entity IN ('.getEntity('invoice').')'; + $sql .= ' AND situation_counter>=1'; + $sql .= ' ORDER by situation_cycle_ref, situation_counter desc'; $resql = $this->db->query($sql); if ($resql && $this->db->num_rows($resql) > 0) { // Last seen cycle $ref = 0; - while ($obj = $this->db->fetch_object($resql)){ + while ($obj = $this->db->fetch_object($resql)) { //Same company ? if ($socid == $obj->fk_soc) { //Same cycle ? @@ -3692,9 +3692,9 @@ class Form //Not prov? if (substr($obj->ref, 1, 4) != 'PROV') { if ($selected == $obj->rowid) { - $opt .= ''; + $opt .= ''; } else { - $opt .= ''; + $opt .= ''; } } } @@ -3704,11 +3704,11 @@ class Form } else { - dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR); } if ($opt == '') { - $opt = ''; + $opt = ''; } return $opt; } @@ -3727,34 +3727,34 @@ class Form $langs->load('products'); - $return= ''; $sql = 'SELECT rowid, label, code from '.MAIN_DB_PREFIX.'c_units'; - $sql.= ' WHERE active > 0'; + $sql .= ' WHERE active > 0'; $resql = $this->db->query($sql); - if($resql && $this->db->num_rows($resql) > 0) + if ($resql && $this->db->num_rows($resql) > 0) { if ($showempty) $return .= ''; - while($res = $this->db->fetch_object($resql)) + while ($res = $this->db->fetch_object($resql)) { $unitLabel = $res->label; - if (! empty($langs->tab_translate['unit'.$res->code])) // check if Translation is available before + if (!empty($langs->tab_translate['unit'.$res->code])) // check if Translation is available before { - $unitLabel = $langs->trans('unit'.$res->code)!=$res->label?$langs->trans('unit'.$res->code):$res->label; + $unitLabel = $langs->trans('unit'.$res->code) != $res->label ? $langs->trans('unit'.$res->code) : $res->label; } if ($selected == $res->rowid) { - $return.=''; + $return .= ''; } else { - $return.=''; + $return .= ''; } } - $return.=''; + $return .= ''; } return $return; } @@ -3796,7 +3796,7 @@ class Form $i = 0; if ($num) { - print ''; if ($useempty == 1 || ($useempty == 2 && $num > 1)) { print ''; @@ -3868,7 +3868,7 @@ class Form $i = 0; if ($num) { - print ''; if ($useempty == 1 || ($useempty == 2 && $num > 1)) { print ''; @@ -3926,8 +3926,8 @@ class Form $langs->load('banks'); if ($selected) { - require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; - $bankstatic=new Account($this->db); + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $bankstatic = new Account($this->db); $result = $bankstatic->fetch($selected); if ($result) print $bankstatic->getNomUrl(1); } else { @@ -3965,17 +3965,17 @@ class Form // For backward compatibility if (is_numeric($type)) { - dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); + dol_syslog(__METHOD__.': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); } if ($type === Categorie::TYPE_BANK_LINE) { // TODO Move this into common category feature - $categids=array(); + $categids = array(); $sql = "SELECT c.label, c.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ as c"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " ORDER BY c.label"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as c"; + $sql .= " WHERE entity = ".$conf->entity; + $sql .= " ORDER BY c.label"; $result = $this->db->query($sql); if ($result) { @@ -3984,7 +3984,7 @@ class Form while ($i < $num) { $objp = $this->db->fetch_object($result); - if ($objp) $cate_arbo[$objp->rowid]=array('id'=>$objp->rowid, 'fulllabel'=>$objp->label); + if ($objp) $cate_arbo[$objp->rowid] = array('id'=>$objp->rowid, 'fulllabel'=>$objp->label); $i++; } $this->db->free($result); @@ -3998,14 +3998,14 @@ class Form } $output = ''; - $output.= "\n"; + $output .= ''; + $output .= "\n"; if ($outputmode) return $outarray; return $output; @@ -4048,7 +4048,7 @@ class Form public function form_confirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = "", $useajax = 0, $height = 170, $width = 500) { // phpcs:enable - dol_syslog(__METHOD__ . ': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING); + dol_syslog(__METHOD__.': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING); print $this->formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width); } @@ -4078,17 +4078,17 @@ class Form */ public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0) { - global $langs,$conf; + global $langs, $conf; global $useglobalvars; - $more=''; - $formconfirm=''; - $inputok=array(); - $inputko=array(); + $more = ''; + $formconfirm = ''; + $inputok = array(); + $inputko = array(); // Clean parameters - $newselectedchoice=empty($selectedchoice)?"no":$selectedchoice; - if ($conf->browser->layout == 'phone') $width='95%'; + $newselectedchoice = empty($selectedchoice) ? "no" : $selectedchoice; + if ($conf->browser->layout == 'phone') $width = '95%'; // Set height automatically if not defined if (empty($height)) { @@ -4098,79 +4098,79 @@ class Form } } - if (is_array($formquestion) && ! empty($formquestion)) + if (is_array($formquestion) && !empty($formquestion)) { // First add hidden fields and value foreach ($formquestion as $key => $input) { - if (is_array($input) && ! empty($input)) + if (is_array($input) && !empty($input)) { if ($input['type'] == 'hidden') { - $more.=''."\n"; + $more .= ''."\n"; } } } // Now add questions - $more.='
    '."\n"; - if (! empty($formquestion['text'])) $more.='
    '."\n"; + $more .= '
    '."\n"; + if (!empty($formquestion['text'])) $more .= '
    '."\n"; foreach ($formquestion as $key => $input) { - if (is_array($input) && ! empty($input)) + if (is_array($input) && !empty($input)) { - $size=(! empty($input['size'])?' size="'.$input['size'].'"':''); - $moreattr=(! empty($input['moreattr'])?' '.$input['moreattr']:''); - $morecss=(! empty($input['morecss'])?' '.$input['morecss']:''); + $size = (!empty($input['size']) ? ' size="'.$input['size'].'"' : ''); + $moreattr = (!empty($input['moreattr']) ? ' '.$input['moreattr'] : ''); + $morecss = (!empty($input['morecss']) ? ' '.$input['morecss'] : ''); if ($input['type'] == 'text') { - $more.='
    '.$input['label'].'
    '."\n"; + $more .= '
    '.$input['label'].'
    '."\n"; } elseif ($input['type'] == 'password') { - $more.='
    '.$input['label'].'
    '."\n"; + $more .= '
    '.$input['label'].'
    '."\n"; } elseif ($input['type'] == 'select') { - $more.='
    '; - if (! empty($input['label'])) $more.=$input['label'].'
    '; - $more.=$this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss); - $more.='
    '."\n"; + $more .= '
    '; + if (!empty($input['label'])) $more .= $input['label'].'
    '; + $more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss); + $more .= '
    '."\n"; } elseif ($input['type'] == 'checkbox') { - $more.='
    '; - $more.='
    '.$input['label'].'
    '; - $more.=''.$input['label'].'
    '; + $more .= ' $selval) + $i = 0; + foreach ($input['values'] as $selkey => $selval) { - $more.='
    '; - if ($i==0) $more.='
    '.$input['label'].'
    '; - else $more.='
     
    '; - $more.='
    '.$input['label'].'
    '; + else $more .= '
     
    '; + $more .= '
    '.$input['label'].'
    '; - $more.='
    '; - $more.=$this->selectDate($input['value'], $input['name'], 0, 0, 0, '', 1, 0); - $more.='
    '."\n"; + $more .= '
    '.$input['label'].'
    '; + $more .= '
    '; + $more .= $this->selectDate($input['value'], $input['name'], 0, 0, 0, '', 1, 0); + $more .= '
    '."\n"; $formquestion[] = array('name'=>$input['name'].'day'); $formquestion[] = array('name'=>$input['name'].'month'); $formquestion[] = array('name'=>$input['name'].'year'); @@ -4179,43 +4179,43 @@ class Form } elseif ($input['type'] == 'other') { - $more.='
    '; - if (! empty($input['label'])) $more.=$input['label'].'
    '; - $more.=$input['value']; - $more.='
    '."\n"; + $more .= '
    '; + if (!empty($input['label'])) $more .= $input['label'].'
    '; + $more .= $input['value']; + $more .= '
    '."\n"; } elseif ($input['type'] == 'onecolumn') { - $more.='
    '; - $more.=$input['value']; - $more.='
    '."\n"; + $more .= '
    '; + $more .= $input['value']; + $more .= '
    '."\n"; } } } - $more.='
    '."\n"; + $more .= '
    '."\n"; } // JQUI method dialog is broken with jmobile, we use standard HTML. // Note: When using dol_use_jmobile or no js, you must also check code for button use a GET url with action=xxx and check that you also output the confirm code when action=xxx // See page product/card.php for example - if (! empty($conf->dol_use_jmobile)) $useajax=0; - if (empty($conf->use_javascript_ajax)) $useajax=0; + if (!empty($conf->dol_use_jmobile)) $useajax = 0; + if (empty($conf->use_javascript_ajax)) $useajax = 0; if ($useajax) { - $autoOpen=true; - $dialogconfirm='dialog-confirm'; - $button=''; - if (! is_numeric($useajax)) + $autoOpen = true; + $dialogconfirm = 'dialog-confirm'; + $button = ''; + if (!is_numeric($useajax)) { - $button=$useajax; - $useajax=1; - $autoOpen=false; - $dialogconfirm.='-'.$button; + $button = $useajax; + $useajax = 1; + $autoOpen = false; + $dialogconfirm .= '-'.$button; } - $pageyes=$page.(preg_match('/\?/', $page)?'&':'?').'action='.$action.'&confirm=yes'; - $pageno=($useajax == 2 ? $page.(preg_match('/\?/', $page)?'&':'?').'confirm=no':''); + $pageyes = $page.(preg_match('/\?/', $page) ? '&' : '?').'action='.$action.'&confirm=yes'; + $pageno = ($useajax == 2 ? $page.(preg_match('/\?/', $page) ? '&' : '?').'confirm=no' : ''); // Add input fields into list of fields to read during submit (inputok and inputko) if (is_array($formquestion)) { @@ -4227,28 +4227,28 @@ class Form } } // Show JQuery confirm box. Note that global var $useglobalvars is used inside this template - $formconfirm.= ''."\n"; - $formconfirm.= "\n\n"; - $formconfirm.= ''; - $formconfirm.= "\n"; + $formconfirm .= "\n"; } else { - $formconfirm.= "\n\n"; + $formconfirm .= "\n\n"; - if (empty($disableformtag)) $formconfirm.= ''."\n"; + if (empty($disableformtag)) $formconfirm .= ''."\n"; - $formconfirm.= ''."\n"; - $formconfirm.= ''."\n"; + $formconfirm .= ''."\n"; + $formconfirm .= ''."\n"; - $formconfirm.= '
    '.$langs->trans("Ref").''; @@ -2138,7 +2138,7 @@ else // Login print "
    '.$langs->trans("Login").''; - if ($user->admin && !$object->ldap_sid) + if ($user->admin && !$object->ldap_sid) { print ''; } @@ -2153,43 +2153,43 @@ else // Pass print '
    '.$langs->trans("Password").''; - $valuetoshow=''; + $valuetoshow = ''; if (preg_match('/ldap/', $dolibarr_main_authentication)) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$langs->trans("PasswordOfUserInLDAP"); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); } if (preg_match('/http/', $dolibarr_main_authentication)) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning'); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning'); } if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { if ($caneditpassword) { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').''; + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''; } else { - $valuetoshow.=($valuetoshow?(' '.$langs->trans("or").' '):'').preg_replace('/./i', '*', $object->pass); + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); } } // Other form for user password - $parameters=array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword); - $reshook=$hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) $valuetoshow=$hookmanager->resPrint; // to replace - else $valuetoshow.=$hookmanager->resPrint; // to add + $parameters = array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword); + $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) $valuetoshow = $hookmanager->resPrint; // to replace + else $valuetoshow .= $hookmanager->resPrint; // to add print $valuetoshow; print "
    '.$langs->trans("ApiKey").''; print ''; - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); print '
    '.$langs->trans("Type").''; - if ($user->id == $object->id || ! $user->admin) + if ($user->id == $object->id || !$user->admin) { - $type=$langs->trans("Internal"); - if ($object->socid) $type=$langs->trans("External"); + $type = $langs->trans("Internal"); + if ($object->socid) $type = $langs->trans("External"); print $form->textwithpicto($type, $langs->trans("InternalExternalDesc")); if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; } else { - $type=0; - if ($object->contactid) $type=$object->contactid; + $type = 0; + if ($object->contactid) $type = $object->contactid; print $form->selectcontacts(0, $type, 'contactid', 2, '', '', 1, '', false, 1); if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; } @@ -2299,8 +2299,8 @@ else // Gender print '
    '.$langs->trans("Gender").''; - $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); - print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1); + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); print '
    '.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).''; - print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id), 'country_id'); + print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
    '.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").''; - if ($caneditfield && empty($object->ldap_sid)) + if ($caneditfield && empty($object->ldap_sid)) { print ''; } @@ -2439,7 +2439,7 @@ else // Fax print "
    '.img_picto('', 'object_phoning_fax').' '.$langs->trans("Fax").''; - if ($caneditfield && empty($object->ldap_sid)) + if ($caneditfield && empty($object->ldap_sid)) { print ''; } @@ -2451,9 +2451,9 @@ else print '
    '; - if ($caneditfield && empty($object->ldap_sid)) + if ($caneditfield && empty($object->ldap_sid)) { print ''; } @@ -2464,12 +2464,12 @@ else } print '
    '.$langs->trans($value['label']).''; - if ($caneditfield && empty($object->ldap_sid)) { + if ($caneditfield && empty($object->ldap_sid)) { print ''; } else { print ''; @@ -2552,7 +2552,7 @@ else // } // OpenID url - if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) + if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) { print "
    '.$langs->trans("OpenIDURL").''; @@ -2590,14 +2590,14 @@ else } // User color - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { print '
    '.$langs->trans("ColorUser").''; if ($caneditfield) { - print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); - }else{ + print $formother->selectColor(GETPOST('color') ?GETPOST('color') : $object->color, 'color', null, 1, '', 'hideifnotset'); + } else { print $formother->showColor($object->color, ''); } print '
    ' . $form->editfieldkey('Categories', 'usercats', '', $object, 0) . '
    '.$form->editfieldkey('Categories', 'usercats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_USER, null, null, null, null, 1); $c = new Categorie($db); @@ -2625,7 +2625,7 @@ else if ($caneditfield) { print $form->multiselectarray('usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); - }else{ + } else { print $form->showCategories($object->id, 'user', 1); } print "
    '.$langs->trans("LinkToCompanyContact").''; @@ -2664,16 +2664,16 @@ else } // Module Adherent - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { $langs->load("members"); print '
    '.$langs->trans("LinkedToDolibarrMember").''; if ($object->fk_member) { - $adh=new Adherent($db); + $adh = new Adherent($db); $adh->fetch($object->fk_member); - $adh->ref=$adh->login; // Force to show login instead of id + $adh->ref = $adh->login; // Force to show login instead of id print $adh->getNomUrl(1); } else @@ -2686,15 +2686,15 @@ else // Multicompany // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! - if (! empty($conf->multicompany->enabled) && is_object($mc)) + if (!empty($conf->multicompany->enabled) && is_object($mc)) { // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module - if (! method_exists($mc, 'formObjectOptions')) + if (!method_exists($mc, 'formObjectOptions')) { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && !$user->entity) { print "
    '.$langs->trans("Entity").'".$mc->select_entities($object->entity, 'entity', '', 0, 1, false, false, 1); // last parameter 1 means, show also a choice 0=>'all entities' + print "".$mc->select_entities($object->entity, 'entity', '', 0, 1, false, false, 1); // last parameter 1 means, show also a choice 0=>'all entities' print "
    '.$langs->trans("DefaultWarehouse").''; print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); @@ -2762,36 +2762,36 @@ else } print '
    '; - $text=$langs->trans("THM"); + $text = $langs->trans("THM"); print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm'); print ''; - if($caneditfield){ - print ''; - }else{ - print ($object->thm!=''?price($object->thm, '', $langs, 1, -1, -1, $conf->currency):''); + if ($caneditfield) { + print ''; + } else { + print ($object->thm != '' ?price($object->thm, '', $langs, 1, -1, -1, $conf->currency) : ''); } print '
    '; - $text=$langs->trans("TJM"); + $text = $langs->trans("TJM"); print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm'); print ''; - if($caneditfield) + if ($caneditfield) { - print ''; - }else{ - print ($object->tjm!=''?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency):''); + print ''; + } else { + print ($object->tjm != '' ?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency) : ''); } print '
    '.$langs->trans("Salary").''; - print ''; + print ''; print '
    '.$langs->trans("WeeklyHours").''; - if($caneditfield) + if ($caneditfield) { - print ''; - }else{ + print ''; + } else { print price2num($object->weeklyhours); } print '
    '.$langs->trans("DateEmployment").''; - if($caneditfield) + if ($caneditfield) { - print $form->selectDate(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 0); - }else{ + print $form->selectDate(GETPOST('dateemployment') ?GETPOST('dateemployment') : $object->dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 0); + } else { print dol_print_date($object->dateemployment, 'day'); } print '
    '.$langs->trans("DateEmploymentEnd").''; - if($caneditfield) + if ($caneditfield) { - print $form->selectDate(GETPOST('dateemploymentend')?GETPOST('dateemploymentend'):$object->dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0); - }else{ + print $form->selectDate(GETPOST('dateemploymentend') ?GETPOST('dateemploymentend') : $object->dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0); + } else { print dol_print_date($object->dateemploymentend, 'day'); } print '
    '.$langs->trans("DateToBirth").''; - if($caneditfield) + if ($caneditfield) { - echo $form->selectDate(GETPOST('birth')?GETPOST('birth'):$object->birth, 'birth', 0, 0, 1, 'updateuser', 1, 0); - }else{ + echo $form->selectDate(GETPOST('birth') ?GETPOST('birth') : $object->birth, 'birth', 0, 0, 1, 'updateuser', 1, 0); + } else { print dol_print_date($object->birth, 'day'); } print '
    '.$formquestion['text'].'
    '.$formquestion['text'].'
    '."\n"; + $formconfirm .= '
    '."\n"; // Line title - $formconfirm.= ''."\n"; + $formconfirm .= ''."\n"; // Line form fields if ($more) { - $formconfirm.=''."\n"; + $formconfirm .= ''."\n"; } // Line with question - $formconfirm.= ''; - $formconfirm.= ''; - $formconfirm.= ''; - $formconfirm.= ''; - $formconfirm.= ''."\n"; + $formconfirm .= ''; + $formconfirm .= ''; + $formconfirm .= ''; + $formconfirm .= ''; + $formconfirm .= ''."\n"; - $formconfirm.= '
    '.img_picto('', 'recent').' '.$title.'
    '.img_picto('', 'recent').' '.$title.'
    '."\n"; - $formconfirm.=$more; - $formconfirm.='
    '."\n"; + $formconfirm .= $more; + $formconfirm .= '
    '.$question.''; - $formconfirm.= $this->selectyesno("confirm", $newselectedchoice); - $formconfirm.= '
    '.$question.''; + $formconfirm .= $this->selectyesno("confirm", $newselectedchoice); + $formconfirm .= '
    '."\n"; + $formconfirm .= '
    '."\n"; - if (empty($disableformtag)) $formconfirm.= "\n"; - $formconfirm.= '
    '; + if (empty($disableformtag)) $formconfirm .= "\n"; + $formconfirm .= '
    '; - $formconfirm.= "\n"; + $formconfirm .= "\n"; } return $formconfirm; @@ -4372,20 +4372,20 @@ class Form require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; - $out=''; + $out = ''; - $formproject=new FormProjets($this->db); + $formproject = new FormProjets($this->db); $langs->load("project"); if ($htmlname != "none") { - $out.="\n"; - $out.='
    '; - $out.=''; - $out.=''; - $out.=$formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0, '', 1); - $out.=''; - $out.='
    '; + $out .= "\n"; + $out .= '
    '; + $out .= ''; + $out .= ''; + $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0, '', 1); + $out .= ''; + $out .= '
    '; } else { @@ -4394,11 +4394,11 @@ class Form $projet = new Project($this->db); $projet->fetch($selected); //print ''.$projet->title.''; - $out.=$projet->getNomUrl(0, '', 1); + $out .= $projet->getNomUrl(0, '', 1); } else { - $out.=" "; + $out .= " "; } } @@ -4539,24 +4539,24 @@ class Form // phpcs:enable global $langs; - $ret=''; + $ret = ''; if ($htmlname != "none") { - $ret.='
    '; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.='
    '; - $ret.=$this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form'.$htmlname, 1, 0); - $ret.='
    '; + $ret .= '
    '; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= '
    '; + $ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form'.$htmlname, 1, 0); + $ret .= '
    '; } else { - if ($displayhour) $ret.=dol_print_date($selected, 'dayhour'); - else $ret.=dol_print_date($selected, 'day'); + if ($displayhour) $ret .= dol_print_date($selected, 'dayhour'); + else $ret .= dol_print_date($selected, 'day'); } if (empty($nooutput)) print $ret; @@ -4593,8 +4593,8 @@ class Form { if ($selected) { - require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; - $theuser=new User($this->db); + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + $theuser = new User($this->db); $theuser->fetch($selected); print $theuser->getNomUrl(1); } else { @@ -4700,7 +4700,7 @@ class Form } else { - if (! empty($rate)) + if (!empty($rate)) { print price($rate, 1, $langs, 1, 0); if ($currency && $rate != 1) print '   ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')'; @@ -4732,33 +4732,33 @@ class Form public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter = '', $maxvalue = 0, $more = '', $hidelist = 0, $discount_type = 0) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; if ($htmlname != "none") { print '
    '; print ''; print ''; print '
    '; - if(! empty($discount_type)) { - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + if (!empty($discount_type)) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - if (! $filter || $filter=="fk_invoice_supplier_source IS NULL") $translationKey = 'HasAbsoluteDiscountFromSupplier'; // If we want deposit to be substracted to payments only and not to total of final invoice + if (!$filter || $filter == "fk_invoice_supplier_source IS NULL") $translationKey = 'HasAbsoluteDiscountFromSupplier'; // If we want deposit to be substracted to payments only and not to total of final invoice else $translationKey = 'HasCreditNoteFromSupplier'; } else { - if (! $filter || $filter=="fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") $translationKey = 'HasAbsoluteDiscountFromSupplier'; + if (!$filter || $filter == "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") $translationKey = 'HasAbsoluteDiscountFromSupplier'; else $translationKey = 'HasCreditNoteFromSupplier'; } } else { - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - if (! $filter || $filter=="fk_facture_source IS NULL") $translationKey = 'CompanyHasAbsoluteDiscount'; // If we want deposit to be substracted to payments only and not to total of final invoice + if (!$filter || $filter == "fk_facture_source IS NULL") $translationKey = 'CompanyHasAbsoluteDiscount'; // If we want deposit to be substracted to payments only and not to total of final invoice else $translationKey = 'CompanyHasCreditNote'; } else { - if (! $filter || $filter=="fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") $translationKey = 'CompanyHasAbsoluteDiscount'; + if (!$filter || $filter == "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") $translationKey = 'CompanyHasAbsoluteDiscount'; else $translationKey = 'CompanyHasCreditNote'; } } @@ -4769,19 +4769,19 @@ class Form { print '
    '; $newfilter = 'discount_type='.intval($discount_type); - if(! empty($discount_type)) { - $newfilter.= ' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL'; // Supplier discounts available + if (!empty($discount_type)) { + $newfilter .= ' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL'; // Supplier discounts available } else { - $newfilter.= ' AND fk_facture IS NULL AND fk_facture_line IS NULL'; // Customer discounts available + $newfilter .= ' AND fk_facture IS NULL AND fk_facture_line IS NULL'; // Customer discounts available } - if ($filter) $newfilter.=' AND ('.$filter.')'; - $nbqualifiedlines=$this->select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue); + if ($filter) $newfilter .= ' AND ('.$filter.')'; + $nbqualifiedlines = $this->select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue); if ($nbqualifiedlines > 0) { print '   '; @@ -4832,10 +4832,10 @@ class Form print ''; print ''; print ''; @@ -4846,8 +4846,8 @@ class Form { if ($selected) { - require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php'; - $contact=new Contact($this->db); + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + $contact = new Contact($this->db); $contact->fetch($selected); print $contact->getFullName($langs); } else { @@ -4879,25 +4879,25 @@ class Form $out = ''; if ($htmlname != "none") { - $out.=''; - $out.= ''; - $out.= ''; - $out.= $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events); - $out.= ''; - $out.= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events); + $out .= ''; + $out .= ''; } else { if ($selected) { - require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $soc = new Societe($this->db); $soc->fetch($selected); - $out.= $soc->getNomUrl($langs); + $out .= $soc->getNomUrl($langs); } else { - $out.= " "; + $out .= " "; } } @@ -4930,41 +4930,41 @@ class Form */ public function selectCurrency($selected = '', $htmlname = 'currency_id', $mode = 0) { - global $conf,$langs,$user; + global $conf, $langs, $user; $langs->loadCacheCurrencies(''); - $out=''; + $out = ''; - if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilite + if ($selected == 'euro' || $selected == 'euros') $selected = 'EUR'; // Pour compatibilite - $out.= ''; foreach ($langs->cache_currencies as $code_iso => $currency) { if ($selected && $selected == $code_iso) { - $out.= ''; + $out .= ''; } - $out.= ''; - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= ''; + if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); // Make select dynamic - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); return $out; @@ -4980,25 +4980,25 @@ class Form */ public function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0) { - global $db,$conf,$langs,$user; + global $db, $conf, $langs, $user; - $langs->loadCacheCurrencies(''); // Load ->cache_currencies + $langs->loadCacheCurrencies(''); // Load ->cache_currencies $TCurrency = array(); $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; - $sql.= " WHERE entity IN ('".getEntity('mutlicurrency')."')"; + $sql .= " WHERE entity IN ('".getEntity('mutlicurrency')."')"; $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) $TCurrency[$obj->code] = $obj->code; } - $out=''; - $out.= ''; if ($useempty) $out .= ''; // If company current currency not in table, we add it into list. Should always be available. - if (! in_array($conf->currency, $TCurrency)) + if (!in_array($conf->currency, $TCurrency)) { $TCurrency[$conf->currency] = $conf->currency; } @@ -5008,20 +5008,20 @@ class Form { if (isset($TCurrency[$code_iso])) { - if (!empty($selected) && $selected == $code_iso) $out.= ''; + $out .= $currency['label']; + $out .= ' ('.$langs->getCurrencySymbol($code_iso).')'; + $out .= ''; } } } - $out.= ''; + $out .= ''; // Make select dynamic - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox($htmlname); + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlname); return $out; } @@ -5039,18 +5039,18 @@ class Form global $langs; $num = count($this->cache_vatrates); - if ($num > 0) return $num; // Cache already loaded + if ($num > 0) return $num; // Cache already loaded dol_syslog(__METHOD__, LOG_DEBUG); - $sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; - $sql.= " WHERE t.fk_pays = c.rowid"; - $sql.= " AND t.active > 0"; - $sql.= " AND c.code IN (".$country_code.")"; - $sql.= " ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC"; + $sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql .= " WHERE t.fk_pays = c.rowid"; + $sql .= " AND t.active > 0"; + $sql .= " AND c.code IN (".$country_code.")"; + $sql .= " ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -5060,22 +5060,22 @@ class Form { $obj = $this->db->fetch_object($resql); $this->cache_vatrates[$i]['rowid'] = $obj->rowid; - $this->cache_vatrates[$i]['code'] = $obj->code; + $this->cache_vatrates[$i]['code'] = $obj->code; $this->cache_vatrates[$i]['txtva'] = $obj->taux; - $this->cache_vatrates[$i]['nprtva'] = $obj->recuperableonly; + $this->cache_vatrates[$i]['nprtva'] = $obj->recuperableonly; $this->cache_vatrates[$i]['localtax1'] = $obj->localtax1; $this->cache_vatrates[$i]['localtax1_type'] = $obj->localtax1_type; $this->cache_vatrates[$i]['localtax2'] = $obj->localtax2; $this->cache_vatrates[$i]['localtax2_type'] = $obj->localtax1_type; - $this->cache_vatrates[$i]['label'] = $obj->taux.'%'.($obj->code?' ('.$obj->code.')':''); // Label must contains only 0-9 , . % or * - $this->cache_vatrates[$i]['labelallrates'] = $obj->taux.'/'.($obj->localtax1?$obj->localtax1:'0').'/'.($obj->localtax2?$obj->localtax2:'0').($obj->code?' ('.$obj->code.')':''); // Must never be used as key, only label - $positiverates=''; - if ($obj->taux) $positiverates.=($positiverates?'/':'').$obj->taux; - if ($obj->localtax1) $positiverates.=($positiverates?'/':'').$obj->localtax1; - if ($obj->localtax2) $positiverates.=($positiverates?'/':'').$obj->localtax2; - if (empty($positiverates)) $positiverates='0'; - $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates.($obj->code?' ('.$obj->code.')':''); // Must never be used as key, only label + $this->cache_vatrates[$i]['label'] = $obj->taux.'%'.($obj->code ? ' ('.$obj->code.')' : ''); // Label must contains only 0-9 , . % or * + $this->cache_vatrates[$i]['labelallrates'] = $obj->taux.'/'.($obj->localtax1 ? $obj->localtax1 : '0').'/'.($obj->localtax2 ? $obj->localtax2 : '0').($obj->code ? ' ('.$obj->code.')' : ''); // Must never be used as key, only label + $positiverates = ''; + if ($obj->taux) $positiverates .= ($positiverates ? '/' : '').$obj->taux; + if ($obj->localtax1) $positiverates .= ($positiverates ? '/' : '').$obj->localtax1; + if ($obj->localtax2) $positiverates .= ($positiverates ? '/' : '').$obj->localtax2; + if (empty($positiverates)) $positiverates = '0'; + $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates.($obj->code ? ' ('.$obj->code.')' : ''); // Must never be used as key, only label } return $num; @@ -5118,34 +5118,34 @@ class Form public function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false, $mode = 0) { // phpcs:enable - global $langs,$conf,$mysoc; + global $langs, $conf, $mysoc; $langs->load('errors'); - $return=''; + $return = ''; // Define defaultnpr, defaultttx and defaultcode - $defaultnpr=($info_bits & 0x01); - $defaultnpr=(preg_match('/\*/', $selectedrate) ? 1 : $defaultnpr); - $defaulttx=str_replace('*', '', $selectedrate); - $defaultcode=''; + $defaultnpr = ($info_bits & 0x01); + $defaultnpr = (preg_match('/\*/', $selectedrate) ? 1 : $defaultnpr); + $defaulttx = str_replace('*', '', $selectedrate); + $defaultcode = ''; if (preg_match('/\((.*)\)/', $defaulttx, $reg)) { - $defaultcode=$reg[1]; - $defaulttx=preg_replace('/\s*\(.*\)/', '', $defaulttx); + $defaultcode = $reg[1]; + $defaulttx = preg_replace('/\s*\(.*\)/', '', $defaulttx); } //var_dump($selectedrate.'-'.$defaulttx.'-'.$defaultnpr.'-'.$defaultcode); // Check parameters - if (is_object($societe_vendeuse) && ! $societe_vendeuse->country_code) + if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) { if ($societe_vendeuse->id == $mysoc->id) { - $return.= ''.$langs->trans("ErrorYourCountryIsNotDefined").''; + $return .= ''.$langs->trans("ErrorYourCountryIsNotDefined").''; } else { - $return.= ''.$langs->trans("ErrorSupplierCountryIsNotDefined").''; + $return .= ''.$langs->trans("ErrorSupplierCountryIsNotDefined").''; } return $return; } @@ -5158,82 +5158,82 @@ class Form // First we defined code_country to use to find list if (is_object($societe_vendeuse)) { - $code_country="'".$societe_vendeuse->country_code."'"; + $code_country = "'".$societe_vendeuse->country_code."'"; } else { - $code_country="'".$mysoc->country_code."'"; // Pour compatibilite ascendente + $code_country = "'".$mysoc->country_code."'"; // Pour compatibilite ascendente } - if (! empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) // If option to have vat for end customer for services is on + if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) // If option to have vat for end customer for services is on { require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - if (! isInEEC($societe_vendeuse) && (! is_object($societe_acheteuse) || (isInEEC($societe_acheteuse) && ! $societe_acheteuse->isACompany()))) + if (!isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) { // We also add the buyer if (is_numeric($type)) { if ($type == 1) // We know product is a service { - $code_country.=",'".$societe_acheteuse->country_code."'"; + $code_country .= ",'".$societe_acheteuse->country_code."'"; } } - elseif (! $idprod) // We don't know type of product + elseif (!$idprod) // We don't know type of product { - $code_country.=",'".$societe_acheteuse->country_code."'"; + $code_country .= ",'".$societe_acheteuse->country_code."'"; } else { - $prodstatic=new Product($this->db); + $prodstatic = new Product($this->db); $prodstatic->fetch($idprod); if ($prodstatic->type == Product::TYPE_SERVICE) // We know product is a service { - $code_country.=",'".$societe_acheteuse->country_code."'"; + $code_country .= ",'".$societe_acheteuse->country_code."'"; } } } } // Now we get list - $num = $this->load_cache_vatrates($code_country); // If no vat defined, return -1 with message into this->error + $num = $this->load_cache_vatrates($code_country); // If no vat defined, return -1 with message into this->error if ($num > 0) { // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) { - $tmpthirdparty=new Societe($this->db); - $defaulttx=get_default_tva($societe_vendeuse, (is_object($societe_acheteuse)?$societe_acheteuse:$tmpthirdparty), $idprod); - $defaultnpr=get_default_npr($societe_vendeuse, (is_object($societe_acheteuse)?$societe_acheteuse:$tmpthirdparty), $idprod); + $tmpthirdparty = new Societe($this->db); + $defaulttx = get_default_tva($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod); + $defaultnpr = get_default_npr($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod); if (preg_match('/\((.*)\)/', $defaulttx, $reg)) { - $defaultcode=$reg[1]; - $defaulttx=preg_replace('/\s*\(.*\)/', '', $defaulttx); + $defaultcode = $reg[1]; + $defaulttx = preg_replace('/\s*\(.*\)/', '', $defaulttx); } - if (empty($defaulttx)) $defaultnpr=0; + if (empty($defaulttx)) $defaultnpr = 0; } // Si taux par defaut n'a pu etre determine, on prend dernier de la liste. // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) { - if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) $defaulttx = $this->cache_vatrates[$num-1]['txtva']; - else $defaulttx=($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS); + if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) $defaulttx = $this->cache_vatrates[$num - 1]['txtva']; + else $defaulttx = ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS); } // Disabled if seller is not subject to VAT - $disabled=false; $title=''; + $disabled = false; $title = ''; if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj == "0") { // Override/enable VAT for expense report regardless of global setting - needed if expense report used for business expenses if (empty($conf->global->OVERRIDE_VAT_FOR_EXPENSE_REPORT)) { - $title=' title="'.$langs->trans('VATIsNotUsed').'"'; - $disabled=true; + $title = ' title="'.$langs->trans('VATIsNotUsed').'"'; + $disabled = true; } } - if (! $options_only) $return.= ''; - $selectedfound=false; + $selectedfound = false; foreach ($this->cache_vatrates as $rate) { // Keep only 0 if seller is not subject to VAT @@ -5241,48 +5241,48 @@ class Form // Define key to use into select list $key = $rate['txtva']; - $key.= $rate['nprtva'] ? '*': ''; - if ($mode > 0 && $rate['code']) $key.=' ('.$rate['code'].')'; + $key .= $rate['nprtva'] ? '*' : ''; + if ($mode > 0 && $rate['code']) $key .= ' ('.$rate['code'].')'; if ($mode < 0) $key = $rate['rowid']; - $return.= ''; + $return .= ''; } - if (! $options_only) $return.= ''; + if (!$options_only) $return .= ''; } else { - $return.= $this->error; + $return .= $this->error; } $this->num = $num; @@ -5319,7 +5319,7 @@ class Form { // phpcs:enable $retstring = $this->selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof); - if (! empty($nooutput)) { + if (!empty($nooutput)) { return $retstring; } print $retstring; @@ -5353,35 +5353,35 @@ class Form */ public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1, $labeladddateof = '') { - global $conf,$langs; + global $conf, $langs; - $retstring=''; + $retstring = ''; - if ($prefix=='') $prefix='re'; - if ($h == '') $h=0; - if ($m == '') $m=0; - $emptydate=0; - $emptyhours=0; - if ($stepminutes<=0 || $stepminutes>30) $stepminutes = 1; - if ($empty == 1) { $emptydate=1; $emptyhours=1; } - if ($empty == 2) { $emptydate=0; $emptyhours=1; } - $orig_set_time=$set_time; + if ($prefix == '') $prefix = 're'; + if ($h == '') $h = 0; + if ($m == '') $m = 0; + $emptydate = 0; + $emptyhours = 0; + if ($stepminutes <= 0 || $stepminutes > 30) $stepminutes = 1; + if ($empty == 1) { $emptydate = 1; $emptyhours = 1; } + if ($empty == 2) { $emptydate = 0; $emptyhours = 1; } + $orig_set_time = $set_time; if ($set_time === '' && $emptydate == 0) { include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $set_time = dol_now('tzuser')-(getServerTimeZoneInt('now')*3600); // set_time must be relative to PHP server timezone + $set_time = dol_now('tzuser') - (getServerTimeZoneInt('now') * 3600); // set_time must be relative to PHP server timezone } // Analysis of the pre-selection date if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) // deprecated usage { // Date format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' - $syear = (! empty($reg[1])?$reg[1]:''); - $smonth = (! empty($reg[2])?$reg[2]:''); - $sday = (! empty($reg[3])?$reg[3]:''); - $shour = (! empty($reg[4])?$reg[4]:''); - $smin = (! empty($reg[5])?$reg[5]:''); + $syear = (!empty($reg[1]) ? $reg[1] : ''); + $smonth = (!empty($reg[2]) ? $reg[2] : ''); + $sday = (!empty($reg[3]) ? $reg[3] : ''); + $shour = (!empty($reg[4]) ? $reg[4] : ''); + $smin = (!empty($reg[5]) ? $reg[5] : ''); } elseif (strval($set_time) != '' && $set_time != -1) { @@ -5416,9 +5416,9 @@ class Form if ($m == 3) $smin = ''; // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' - $usecalendar='combo'; - if (! empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) { - $usecalendar = ((empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR == 'eldy')?'jquery':$conf->global->MAIN_POPUP_CALENDAR); + $usecalendar = 'combo'; + if (!empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) { + $usecalendar = ((empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR == 'eldy') ? 'jquery' : $conf->global->MAIN_POPUP_CALENDAR); } if ($d) @@ -5426,50 +5426,50 @@ class Form // Show date with popup if ($usecalendar != 'combo') { - $formated_date=''; + $formated_date = ''; //print "e".$set_time." t ".$conf->format_date_short; if (strval($set_time) != '' && $set_time != -1) { //$formated_date=dol_print_date($set_time,$conf->format_date_short); - $formated_date=dol_print_date($set_time, $langs->trans("FormatDateShortInput")); // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript + $formated_date = dol_print_date($set_time, $langs->trans("FormatDateShortInput")); // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript } // Calendrier popup version eldy if ($usecalendar == "eldy") { // Zone de saisie manuelle de la date - $retstring.='trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript - $retstring.='>'; + $retstring .= 'trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript + $retstring .= '>'; // Icone calendrier - if (! $disabled) + if (!$disabled) { - $retstring.=''; + $retstring .= ''; } - else $retstring.=''; + else $retstring .= ''; - $retstring.=''."\n"; - $retstring.=''."\n"; - $retstring.=''."\n"; + $retstring .= ''."\n"; + $retstring .= ''."\n"; + $retstring .= ''."\n"; } elseif ($usecalendar == 'jquery') { - if (! $disabled) + if (!$disabled) { // Output javascript for datepicker - $retstring.=""; + $retstring .= ""; } // Zone de saisie manuelle de la date - $retstring.='
    '; - $retstring.='trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript - $retstring.='>'; + $retstring .= '
    '; + $retstring .= 'trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript + $retstring .= '>'; // Icone calendrier - if (! $disabled) + if (!$disabled) { /* Not required. Managed by option buttonImage of jquery $retstring.=img_object($langs->trans("SelectDate"),'calendarday','id="'.$prefix.'id" class="datecallink"'); @@ -5513,17 +5513,17 @@ class Form } else { - $retstring.=''; + $retstring .= ''; } - $retstring.='
    '; - $retstring.=''."\n"; - $retstring.=''."\n"; - $retstring.=''."\n"; + $retstring .= '
    '; + $retstring .= ''."\n"; + $retstring .= ''."\n"; + $retstring .= ''."\n"; } else { - $retstring.="Bad value of MAIN_POPUP_CALENDAR"; + $retstring .= "Bad value of MAIN_POPUP_CALENDAR"; } } // Show date with combo selects @@ -5531,55 +5531,55 @@ class Form { //$retstring.='
    '; // Day - $retstring.=''; + $retstring .= ''; if ($emptydate || $set_time == -1) { - $retstring.=''; + $retstring .= ''; } - for ($day = 1 ; $day <= 31; $day++) + for ($day = 1; $day <= 31; $day++) { - $retstring.=''; + $retstring .= ''; } - $retstring.=""; + $retstring .= ""; - $retstring.=''; + $retstring .= ''; if ($emptydate || $set_time == -1) { - $retstring.=''; + $retstring .= ''; } // Month - for ($month = 1 ; $month <= 12 ; $month++) + for ($month = 1; $month <= 12; $month++) { - $retstring.='"; + $retstring .= '"; } - $retstring.=""; + $retstring .= ""; // Year if ($emptydate || $set_time == -1) { - $retstring.=''; + $retstring .= ''; } else { - $retstring.=''; + $retstring .= ''; - for ($year = $syear - 10; $year < $syear + 10 ; $year++) + for ($year = $syear - 10; $year < $syear + 10; $year++) { - $retstring.=''; + $retstring .= ''; } - $retstring.="\n"; + $retstring .= "\n"; } //$retstring.='
    '; } } - if ($d && $h) $retstring.=($h==2?'
    ':' '); + if ($d && $h) $retstring .= ($h == 2 ? '
    ' : ' '); if ($h) { @@ -5589,33 +5589,33 @@ class Form $openinghours = explode(',', $openinghours); $hourstart = $openinghours[0]; $hourend = $openinghours[1]; - if ($hourend<$hourstart) $hourend = $hourstart; + if ($hourend < $hourstart) $hourend = $hourstart; } // Show hour - $retstring.=''; - if ($emptyhours) $retstring.=''; + $retstring .= ''; + if ($emptyhours) $retstring .= ''; for ($hour = $hourstart; $hour < $hourend; $hour++) { - if (strlen($hour) < 2) $hour = "0" . $hour; - $retstring.=''; + if (strlen($hour) < 2) $hour = "0".$hour; + $retstring .= ''; } - $retstring.=''; - if ($m && empty($conf->dol_optimize_smallscreen)) $retstring.=":"; + $retstring .= ''; + if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":"; } if ($m) { // Show minutes - $retstring.=''; - if ($emptyhours) $retstring.=''; - for ($min = 0; $min < 60 ; $min+=$stepminutes) + $retstring .= ''; + if ($emptyhours) $retstring .= ''; + for ($min = 0; $min < 60; $min += $stepminutes) { - if (strlen($min) < 2) $min = "0" . $min; - $retstring.=''; + if (strlen($min) < 2) $min = "0".$min; + $retstring .= ''; } - $retstring.=''; + $retstring .= ''; - $retstring.=''; + $retstring .= ''; } // Add a "Now" link @@ -5623,10 +5623,10 @@ class Form { // Script which will be inserted in the onClick of the "Now" link $reset_scripts = ""; - if ($addnowlink==2) // local computer time + if ($addnowlink == 2) // local computer time { // pad add leading 0 on numbers - $reset_scripts.="Number.prototype.pad = function(size) { + $reset_scripts .= "Number.prototype.pad = function(size) { var s = String(this); while (s.length < (size || 2)) {s = '0' + s;} return s; @@ -5635,14 +5635,14 @@ class Form } // Generate the date part, depending on the use or not of the javascript calendar - if($addnowlink==1) // server time expressed in user time setup + if ($addnowlink == 1) // server time expressed in user time setup { $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');'; $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');'; } - elseif($addnowlink==2) + elseif ($addnowlink == 2) { $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));'; $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());'; @@ -5665,11 +5665,11 @@ class Form { if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; - if($addnowlink==1) + if ($addnowlink == 1) { $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H', 'tzuser').'\');'; } - elseif($addnowlink==2) + elseif ($addnowlink == 2) { $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());'; } @@ -5681,11 +5681,11 @@ class Form { if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; - if($addnowlink==1) + if ($addnowlink == 1) { $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M', 'tzuser').'\');'; } - elseif($addnowlink==2) + elseif ($addnowlink == 2) { $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());'; } @@ -5694,9 +5694,9 @@ class Form // If reset_scripts is not empty, print the link with the reset_scripts in the onClick if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) { - $retstring.=' '; + $retstring .= ' '; } } @@ -5764,9 +5764,9 @@ class Form // phpcs:enable global $langs; - $retstring=''; + $retstring = ''; - $hourSelected=0; $minSelected=0; + $hourSelected = 0; $minSelected = 0; // Hours if ($iSecond != '') @@ -5777,54 +5777,54 @@ class Form $minSelected = convertSecondToTime($iSecond, 'min'); } - if ($typehour=='select' ) + if ($typehour == 'select') { - $retstring.=''; for ($hour = 0; $hour < 25; $hour++) // For a duration, we allow 24 hours { - $retstring.='"; } - $retstring.=""; + $retstring .= ""; } - elseif ($typehour=='text' || $typehour=='textselect') + elseif ($typehour == 'text' || $typehour == 'textselect') { - $retstring.=''; + $retstring .= ''; } else return 'BadValueForParameterTypeHour'; - if ($typehour!='text') $retstring.=' '.$langs->trans('HourShort'); - else $retstring.=':'; + if ($typehour != 'text') $retstring .= ' '.$langs->trans('HourShort'); + else $retstring .= ':'; // Minutes - if ($minunderhours) $retstring.='
    '; - else $retstring.=' '; + if ($minunderhours) $retstring .= '
    '; + else $retstring .= ' '; - if ($typehour=='select' || $typehour=='textselect') + if ($typehour == 'select' || $typehour == 'textselect') { - $retstring.=''; + for ($min = 0; $min <= 55; $min = $min + 5) { - $retstring.=''; + $out .= ''; } else { - $out.= ''; + $out .= ''; } } else @@ -6083,18 +6083,18 @@ class Form } $i++; - if (($i % 10) == 0) $out.="\n"; + if (($i % 10) == 0) $out .= "\n"; } } - $out.= ''."\n"; + $out .= ''."\n"; } else { dol_print_error($this->db); } - $this->result=array('nbofelement'=>$num); + $this->result = array('nbofelement'=>$num); if ($outputmode) return $outarray; return $out; @@ -6133,31 +6133,31 @@ class Form //if (preg_match('/^multi/',$htmlname)) $jsbeautify = 1; $jsbeautify = 1; - if ($value_as_key) $array=array_combine($array, $array); + if ($value_as_key) $array = array_combine($array, $array); - $out=''; + $out = ''; // Add code for jquery to use multiselect if ($addjscombo && $jsbeautify) { - $minLengthToAutocomplete=0; - $tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?(constant('REQUIRE_JQUERY_MULTISELECT')?constant('REQUIRE_JQUERY_MULTISELECT'):'select2'):$conf->global->MAIN_USE_JQUERY_MULTISELECT; + $minLengthToAutocomplete = 0; + $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ? (constant('REQUIRE_JQUERY_MULTISELECT') ?constant('REQUIRE_JQUERY_MULTISELECT') : 'select2') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; // Enhance with select2 - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); } - $out.='"; + $out .= ""; return $out; } @@ -6251,16 +6251,16 @@ class Form global $delayedhtmlcontent; // TODO Use an internal dolibarr component instead of select2 - if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return ''; + if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) return ''; - $out=''; + $out = ''; - $tmpplugin='select2'; - $outdelayed="\n".' + $tmpplugin = 'select2'; + $outdelayed = "\n".' '; if ($acceptdelayedhtml) { - $delayedhtmlcontent.=$outdelayed; + $delayedhtmlcontent .= $outdelayed; } else { - $out.=$outdelayed; + $out .= $outdelayed; } return $out; } @@ -6353,13 +6353,13 @@ class Form global $delayedhtmlcontent; // TODO Use an internal dolibarr component instead of select2 - if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return ''; + if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) return ''; - $out=''; + $out = ''; $formattedarrayresult = array(); - foreach($array as $key => $value) { + foreach ($array as $key => $value) { $o = new stdClass(); $o->id = $key; $o->text = $value['text']; @@ -6367,13 +6367,13 @@ class Form $formattedarrayresult[] = $o; } - $tmpplugin='select2'; - $outdelayed="\n".' + $tmpplugin = 'select2'; + $outdelayed = "\n".' '; if ($acceptdelayedhtml) { - $delayedhtmlcontent.=$outdelayed; + $delayedhtmlcontent .= $outdelayed; } else { - $out.=$outdelayed; + $out .= $outdelayed; } return $out; } @@ -6477,36 +6477,36 @@ class Form } // Add code for jquery to use multiselect - if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) + if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) { - $out.="\n".' + $out .= "\n".' '; + $out .= ''; } // Try also magic suggest - $out .= ''."\n"; + if (is_array($array) && !empty($array)) { - if ($value_as_key) $array=array_combine($array, $array); + if ($value_as_key) $array = array_combine($array, $array); - if (! empty($array)) + if (!empty($array)) { foreach ($array as $key => $value) { - $out.= ''."\n"; + $out .= dol_htmlentitiesbr($newval); + $out .= ''."\n"; } } } - $out.= ''."\n"; + $out .= ''."\n"; return $out; } @@ -6577,44 +6577,44 @@ class Form */ public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage) { - global $conf,$langs,$user; + global $conf, $langs, $user; - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return ''; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return ''; - $tmpvar="MAIN_SELECTEDFIELDS_".$varpage; - if (! empty($user->conf->$tmpvar)) + $tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; + if (!empty($user->conf->$tmpvar)) { - $tmparray=explode(',', $user->conf->$tmpvar); - foreach($array as $key => $val) + $tmparray = explode(',', $user->conf->$tmpvar); + foreach ($array as $key => $val) { //var_dump($key); //var_dump($tmparray); - if (in_array($key, $tmparray)) $array[$key]['checked']=1; - else $array[$key]['checked']=0; + if (in_array($key, $tmparray)) $array[$key]['checked'] = 1; + else $array[$key]['checked'] = 0; } } - $lis=''; - $listcheckedstring=''; + $lis = ''; + $listcheckedstring = ''; - foreach($array as $key => $val) + foreach ($array as $key => $val) { /* var_dump($val); var_dump(array_key_exists('enabled', $val)); var_dump(!$val['enabled']);*/ - if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) + if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) { - unset($array[$key]); // We don't want this field + unset($array[$key]); // We don't want this field continue; } if ($val['label']) { - $lis.='
  • '; - $listcheckedstring.=(empty($val['checked'])?'':$key.','); + $lis .= '
  • '; + $listcheckedstring .= (empty($val['checked']) ? '' : $key.','); } } - $out =' + $out = '
    '; print ''; - $nboftypesoutput=0; + $nboftypesoutput = 0; - foreach($object->linkedObjects as $objecttype => $objects) + foreach ($object->linkedObjects as $objecttype => $objects) { $tplpath = $element = $subelement = $objecttype; // to display inport button on tpl - $showImportButton=false; - if(!empty($compatibleImportElementsList) && in_array($element, $compatibleImportElementsList)){ - $showImportButton=true; + $showImportButton = false; + if (!empty($compatibleImportElementsList) && in_array($element, $compatibleImportElementsList)) { + $showImportButton = true; } $regs = array(); @@ -6762,47 +6762,47 @@ class Form $subelement = $regs[2]; $tplpath = $element.'/'.$subelement; } - $tplname='linkedobjectblock'; + $tplname = 'linkedobjectblock'; // To work with non standard path - if ($objecttype == 'facture') { + if ($objecttype == 'facture') { $tplpath = 'compta/'.$element; - if (empty($conf->facture->enabled)) continue; // Do not show if module disabled + if (empty($conf->facture->enabled)) continue; // Do not show if module disabled } - elseif ($objecttype == 'facturerec') { + elseif ($objecttype == 'facturerec') { $tplpath = 'compta/facture'; $tplname = 'linkedobjectblockForRec'; - if (empty($conf->facture->enabled)) continue; // Do not show if module disabled + if (empty($conf->facture->enabled)) continue; // Do not show if module disabled } - elseif ($objecttype == 'propal') { + elseif ($objecttype == 'propal') { $tplpath = 'comm/'.$element; - if (empty($conf->propal->enabled)) continue; // Do not show if module disabled + if (empty($conf->propal->enabled)) continue; // Do not show if module disabled } - elseif ($objecttype == 'supplier_proposal') { - if (empty($conf->supplier_proposal->enabled)) continue; // Do not show if module disabled + elseif ($objecttype == 'supplier_proposal') { + if (empty($conf->supplier_proposal->enabled)) continue; // Do not show if module disabled } elseif ($objecttype == 'shipping' || $objecttype == 'shipment') { $tplpath = 'expedition'; - if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled + if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled } elseif ($objecttype == 'reception') { $tplpath = 'reception'; - if (empty($conf->reception->enabled)) continue; // Do not show if module disabled + if (empty($conf->reception->enabled)) continue; // Do not show if module disabled } - elseif ($objecttype == 'delivery') { + elseif ($objecttype == 'delivery') { $tplpath = 'livraison'; - if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled + if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled } elseif ($objecttype == 'invoice_supplier') { $tplpath = 'fourn/facture'; } - elseif ($objecttype == 'order_supplier') { + elseif ($objecttype == 'order_supplier') { $tplpath = 'fourn/commande'; } - elseif ($objecttype == 'expensereport') { + elseif ($objecttype == 'expensereport') { $tplpath = 'expensereport'; } - elseif ($objecttype == 'subscription') { + elseif ($objecttype == 'subscription') { $tplpath = 'adherents'; } @@ -6811,16 +6811,16 @@ class Form // Output template part (modules that overwrite templates must declare this into descriptor) - $dirtpls=array_merge($conf->modules_parts['tpl'], array('/'.$tplpath.'/tpl')); - foreach($dirtpls as $reldir) + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/'.$tplpath.'/tpl')); + foreach ($dirtpls as $reldir) { if ($nboftypesoutput == ($nbofdifferenttypes - 1)) // No more type to show after { global $noMoreLinkedObjectBlockAfter; - $noMoreLinkedObjectBlockAfter=1; + $noMoreLinkedObjectBlockAfter = 1; } - $res=@include dol_buildpath($reldir.'/'.$tplname.'.tpl.php'); + $res = @include dol_buildpath($reldir.'/'.$tplname.'.tpl.php'); if ($res) { $nboftypesoutput++; @@ -6829,7 +6829,7 @@ class Form } } - if (! $nboftypesoutput) + if (!$nboftypesoutput) { print ''; } @@ -6838,7 +6838,7 @@ class Form if (!empty($compatibleImportElementsList)) { - $res=@include dol_buildpath('core/tpl/ajax/objectlinked_lineimport.tpl.php'); + $res = @include dol_buildpath('core/tpl/ajax/objectlinked_lineimport.tpl.php'); } @@ -6861,73 +6861,73 @@ class Form global $conf, $langs, $hookmanager; global $bc, $action; - $linktoelem=''; - $linktoelemlist=''; - $listofidcompanytoscan=''; + $linktoelem = ''; + $linktoelemlist = ''; + $listofidcompanytoscan = ''; - if (! is_object($object->thirdparty)) $object->fetch_thirdparty(); + if (!is_object($object->thirdparty)) $object->fetch_thirdparty(); - $possiblelinks=array(); - if (is_object($object->thirdparty) && ! empty($object->thirdparty->id) && $object->thirdparty->id > 0) + $possiblelinks = array(); + if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) { - $listofidcompanytoscan=$object->thirdparty->id; - if (($object->thirdparty->parent > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan.=','.$object->thirdparty->parent; - if (($object->fk_project > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) + $listofidcompanytoscan = $object->thirdparty->id; + if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan .= ','.$object->thirdparty->parent; + if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $tmpproject=new Project($this->db); + $tmpproject = new Project($this->db); $tmpproject->fetch($object->fk_project); - if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) $listofidcompanytoscan.=','.$tmpproject->socid; + if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) $listofidcompanytoscan .= ','.$tmpproject->socid; unset($tmpproject); } - $possiblelinks=array( + $possiblelinks = array( 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'), 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande').')'), 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), - 'contrat'=>array('enabled'=>$conf->contrat->enabled , 'perms'=>1, 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), + 'contrat'=>array('enabled'=>$conf->contrat->enabled, 'perms'=>1, 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'), - 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled , 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'), - 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled , 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), - 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')'), - 'ticket'=>array('enabled'=>$conf->ticket->enabled , 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('ticket').')') + 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'), + 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), + 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled, 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')'), + 'ticket'=>array('enabled'=>$conf->ticket->enabled, 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('ticket').')') ); } // Can complete the possiblelink array $hookmanager->initHooks(array('commonobject')); - $parameters=array('listofidcompanytoscan' => $listofidcompanytoscan); + $parameters = array('listofidcompanytoscan' => $listofidcompanytoscan); - if (! empty($listofidcompanytoscan)) // If empty, we don't have criteria to scan the object we can link to + if (!empty($listofidcompanytoscan)) // If empty, we don't have criteria to scan the object we can link to { - $reshook=$hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } if (empty($reshook)) { if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) { - $possiblelinks=array_merge($possiblelinks, $hookmanager->resArray); + $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray); } } elseif ($reshook > 0) { if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) { - $possiblelinks=$hookmanager->resArray; + $possiblelinks = $hookmanager->resArray; } } - foreach($possiblelinks as $key => $possiblelink) + foreach ($possiblelinks as $key => $possiblelink) { $num = 0; if (empty($possiblelink['enabled'])) continue; - if (! empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || ! in_array($key, $excludelinksto))) + if (!empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) { - print '
    use_javascript_ajax)?'':' style="display:none"').'>'; + print '
    use_javascript_ajax) ? '' : ' style="display:none"').'>'; $sql = $possiblelink['sql']; $resqllist = $this->db->query($sql); @@ -6945,10 +6945,10 @@ class Form print '
    '; - $num=$this->select_contacts($societe->id, $selected, $htmlname); - if ($num==0) + $num = $this->select_contacts($societe->id, $selected, $htmlname); + if ($num == 0) { - $addcontact = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); print ''.$addcontact.''; } print '
    '.$langs->trans("None").'
    '; print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; while ($i < $num) { @@ -6956,17 +6956,17 @@ class Form print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; $i++; } print '
    ' . $langs->trans("Ref") . '' . $langs->trans("RefCustomer") . '' . $langs->trans("AmountHTShort") . '' . $langs->trans("Company") . ''.$langs->trans("Ref").''.$langs->trans("RefCustomer").''.$langs->trans("AmountHTShort").''.$langs->trans("Company").'
    '; - print ''; + print ''; print '' . $objp->ref . '' . $objp->ref_client . '' . price($objp->total_ht) . '' . $objp->name . ''.$objp->ref.''.$objp->ref_client.''.price($objp->total_ht).''.$objp->name.'
    '; - print '
         
    '; + print '
         
    '; print ''; $this->db->free($resqllist); @@ -6979,19 +6979,19 @@ class Form } //$linktoelem.=($linktoelem?'   ':''); - if ($num > 0) $linktoelemlist.='
  • ' . $langs->trans($possiblelink['label']) .' ('.$num.')
  • '; + if ($num > 0) $linktoelemlist .= '
  • '.$langs->trans($possiblelink['label']).' ('.$num.')
  • '; //else $linktoelem.=$langs->trans($possiblelink['label']); - else $linktoelemlist.='
  • ' . $langs->trans($possiblelink['label']) . ' (0)
  • '; + else $linktoelemlist .= '
  • '.$langs->trans($possiblelink['label']).' (0)
  • '; } } if ($linktoelemlist) { - $linktoelem=' + $linktoelem = '
    '.$langs->trans("Value").'
    '.$langs->trans("ErrorFailedToReadLDAP").'
    '; // maring bottom must be same than into print_barre_list - if ($picto) $return.= ''; - $return.= ''; + $return .= "\n"; + $return .= '
    '.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).''; - $return.= '
    '.$titre.'
    '; - $return.= '
    '; // maring bottom must be same than into print_barre_list + if ($picto) $return .= ''; + $return .= ''; if (dol_strlen($morehtmlcenter)) { - $return.= ''; + $return .= ''; } if (dol_strlen($morehtmlright)) { - $return.= ''; + $return .= ''; } - $return.= '
    '.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).''; + $return .= '
    '.$titre.'
    '; + $return .= '
    '.$morehtmlcenter.''.$morehtmlcenter.''.$morehtmlright.''.$morehtmlright.'
    '."\n"; + $return .= '
    '."\n"; return $return; } @@ -4187,14 +4187,14 @@ function load_fiche_titre($titre, $morehtmlright = '', $picto = 'generic', $pict */ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', $sortorder = '', $morehtmlcenter = '', $num = -1, $totalnboflines = '', $picto = 'generic', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limit = -1, $hideselectlimit = 0, $hidenavigation = 0) { - global $conf,$langs; + global $conf, $langs; $savlimit = $limit; $savtotalnboflines = $totalnboflines; - $totalnboflines=abs($totalnboflines); + $totalnboflines = abs($totalnboflines); - if ($picto == 'setup') $picto='title_setup.png'; - if (($conf->browser->name == 'ie') && $picto=='generic') $picto='title.gif'; + if ($picto == 'setup') $picto = 'title_setup.png'; + if (($conf->browser->name == 'ie') && $picto == 'generic') $picto = 'title.gif'; if ($limit < 0) $limit = $conf->liste_limit; if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) { @@ -4208,7 +4208,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', print "\n"; print "\n"; - print ''; // maring bottom must be same than into load_fiche_tire + print '
    '; // maring bottom must be same than into load_fiche_tire // Left print ''; @@ -4304,26 +4304,26 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be print '
    '; @@ -4234,48 +4234,48 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', if ($totalnboflines) // If we know total nb of lines { // Define nb of extra page links before and after selected page + ... + first or last - $maxnbofpage=(empty($conf->dol_optimize_smallscreen) ? 4 : 1); + $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 1); - if ($limit > 0) $nbpages=ceil($totalnboflines/$limit); - else $nbpages=1; - $cpt=($page-$maxnbofpage); - if ($cpt < 0) { $cpt=0; } + if ($limit > 0) $nbpages = ceil($totalnboflines / $limit); + else $nbpages = 1; + $cpt = ($page - $maxnbofpage); + if ($cpt < 0) { $cpt = 0; } - if ($cpt>=1) + if ($cpt >= 1) { - $pagelist.= ''; - if ($cpt > 2) $pagelist.=''; - elseif ($cpt == 2) $pagelist.=''; + $pagelist .= ''; + if ($cpt > 2) $pagelist .= ''; + elseif ($cpt == 2) $pagelist .= ''; } do { - if ($cpt==$page) + if ($cpt == $page) { - $pagelist.= ''; + $pagelist .= ''; } else { - $pagelist.= ''; + $pagelist .= ''; } $cpt++; } - while ($cpt < $nbpages && $cpt<=$page+$maxnbofpage); + while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage); - if ($cpt<$nbpages) + if ($cpt < $nbpages) { - if ($cpt<$nbpages-2) $pagelist.= ''; - elseif ($cpt == $nbpages-2) $pagelist.= ''; - $pagelist.= ''; + if ($cpt < $nbpages - 2) $pagelist .= ''; + elseif ($cpt == $nbpages - 2) $pagelist .= ''; + $pagelist .= ''; } } else { - $pagelist.= '"; + $pagelist .= '"; } } - print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist + print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist print '
    '; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
    '; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
    '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->BOM_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
    '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->BOM_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->BOM_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->BOM_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
    '; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
    '; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
    '; - $texte.= ''; + $texte .= '
    '; + $texte .= ''; return $texte; } @@ -199,7 +199,7 @@ class doc_generic_bom_odt extends ModelePDFBom public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -208,28 +208,28 @@ class doc_generic_bom_odt extends ModelePDFBom } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->bom->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Bom($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -237,16 +237,16 @@ class doc_generic_bom_odt extends ModelePDFBom } } - $dir = $conf->bom->multidir_output[isset($object->entity)?$object->entity:1]; + $dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1]; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -254,25 +254,25 @@ class doc_generic_bom_odt extends ModelePDFBom if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -282,20 +282,20 @@ class doc_generic_bom_odt extends ModelePDFBom // If CUSTOMER contact defined on order, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + 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; + 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 @@ -304,24 +304,24 @@ class doc_generic_bom_odt extends ModelePDFBom } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__QTY_TO_PRODUCE__' => $object->qty, ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='BOM_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'BOM_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -331,15 +331,15 @@ class doc_generic_bom_odt extends ModelePDFBom $srctemplatepath, array( 'PATH_TO_TMP' => $conf->bom->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -354,31 +354,31 @@ class doc_generic_bom_odt extends ModelePDFBom try { $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -391,7 +391,7 @@ class doc_generic_bom_odt extends ModelePDFBom $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -403,7 +403,7 @@ class doc_generic_bom_odt extends ModelePDFBom try { $listlines = $odfHandler->setSegment('lines'); } - catch(OdfException $e) + catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; @@ -413,22 +413,22 @@ class doc_generic_bom_odt extends ModelePDFBom { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -438,21 +438,21 @@ class doc_generic_bom_odt extends ModelePDFBom $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -460,15 +460,15 @@ class doc_generic_bom_odt extends ModelePDFBom // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); - }catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -477,27 +477,27 @@ class doc_generic_bom_odt extends ModelePDFBom try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 07a1d542644..ef61306c692 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -68,37 +68,37 @@ class doc_generic_mo_odt extends ModelePDFMo 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"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'MRP_MO_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'MRP_MO_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -110,83 +110,83 @@ class doc_generic_mo_odt extends ModelePDFMo */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
    \n"; - $texte.= '
    '; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
    '; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
    '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MRP_MO_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
    '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MRP_MO_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->MRP_MO_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->MRP_MO_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
    '; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
    '; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
    '; - $texte.= '
    '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -206,7 +206,7 @@ class doc_generic_mo_odt extends ModelePDFMo public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -215,28 +215,28 @@ class doc_generic_mo_odt extends ModelePDFMo } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->mrp->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new MO($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -244,16 +244,16 @@ class doc_generic_mo_odt extends ModelePDFMo } } - $dir = $conf->mrp->multidir_output[isset($object->entity)?$object->entity:1]; + $dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -261,25 +261,25 @@ class doc_generic_mo_odt extends ModelePDFMo if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -289,20 +289,20 @@ class doc_generic_mo_odt extends ModelePDFMo // If CUSTOMER contact defined on order, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + 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; + 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 @@ -311,24 +311,24 @@ class doc_generic_mo_odt extends ModelePDFMo } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__QTY_TO_PRODUCE__' => $object->qty, ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='MRP_MO_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'MRP_MO_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -338,15 +338,15 @@ class doc_generic_mo_odt extends ModelePDFMo $srctemplatepath, array( 'PATH_TO_TMP' => $conf->mrp->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -361,31 +361,31 @@ class doc_generic_mo_odt extends ModelePDFMo try { $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -398,7 +398,7 @@ class doc_generic_mo_odt extends ModelePDFMo $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -410,7 +410,7 @@ class doc_generic_mo_odt extends ModelePDFMo try { $listlines = $odfHandler->setSegment('lines'); } - catch(OdfException $e) + catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; @@ -420,22 +420,22 @@ class doc_generic_mo_odt extends ModelePDFMo { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -445,21 +445,21 @@ class doc_generic_mo_odt extends ModelePDFMo $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -467,15 +467,15 @@ class doc_generic_mo_odt extends ModelePDFMo // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); - }catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -484,27 +484,27 @@ class doc_generic_mo_odt extends ModelePDFMo try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/mrp/mod_mo_advanced.php b/htdocs/core/modules/mrp/mod_mo_advanced.php index 1059ec4a9c5..54e82467900 100644 --- a/htdocs/core/modules/mrp/mod_mo_advanced.php +++ b/htdocs/core/modules/mrp/mod_mo_advanced.php @@ -26,7 +26,7 @@ * \brief File containing class for numbering model of MOs advanced */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/mrp/modules_mo.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php'; /** @@ -38,7 +38,7 @@ class mod_mo_advanced extends ModeleNumRefMos * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error message @@ -48,7 +48,7 @@ class mod_mo_advanced extends ModeleNumRefMos /** * @var string name */ - public $name='advanced'; + public $name = 'advanced'; /** @@ -65,28 +65,28 @@ class mod_mo_advanced extends ModeleNumRefMos $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
    \n"; - $texte.= '
    '; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
    '; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Mo"), $langs->transnoentities("Mo")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Mo"), $langs->transnoentities("Mo")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Mo"), $langs->transnoentities("Mo")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Mo"), $langs->transnoentities("Mo")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
    '; - $texte.= '
    '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -98,17 +98,17 @@ class mod_mo_advanced extends ModeleNumRefMos */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $old_code_type=$mysoc->typent_code; - $mysoc->code_client='CCCCCCCCCC'; - $mysoc->typent_code='TTTTTTTTTT'; + $old_code_client = $mysoc->code_client; + $old_code_type = $mysoc->typent_code; + $mysoc->code_client = 'CCCCCCCCCC'; + $mysoc->typent_code = 'TTTTTTTTTT'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; - $mysoc->typent_code=$old_code_type; + $mysoc->code_client = $old_code_client; + $mysoc->typent_code = $old_code_type; - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -124,22 +124,22 @@ class mod_mo_advanced extends ModeleNumRefMos */ public function getNextValue($objprod, $object) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // We get cursor rule - $mask=$conf->global->MRP_MO_ADVANCED_MASK; + $mask = $conf->global->MRP_MO_ADVANCED_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } $date = ($object->date_mo ? $object->date_mo : $object->date); - $numFinal=get_next_value($db, $mask, 'mrp_mo', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'mrp_mo', 'ref', '', null, $date); return $numFinal; } diff --git a/htdocs/core/modules/mrp/mod_mo_standard.php b/htdocs/core/modules/mrp/mod_mo_standard.php index 9546748387b..05b13525023 100644 --- a/htdocs/core/modules/mrp/mod_mo_standard.php +++ b/htdocs/core/modules/mrp/mod_mo_standard.php @@ -22,7 +22,7 @@ * \ingroup mrp * \brief File of class to manage MO numbering rules standard */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/mrp/modules_mo.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php'; /** * Class to manage MO numbering rules standard @@ -33,19 +33,19 @@ class mod_mo_standard extends ModeleNumRefMos * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $prefix='MO'; + public $prefix = 'MO'; /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string name */ - public $name='standard'; + public $name = 'standard'; /** @@ -79,26 +79,26 @@ class mod_mo_standard extends ModeleNumRefMos */ public function canBeActivated() { - global $conf,$langs,$db; + global $conf, $langs, $db; - $coyymm=''; $max=''; + $coyymm = ''; $max = ''; - $posindice=8; + $posindice = 8; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."mrp_mo"; - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $row = $db->fetch_row($resql); - if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; } + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } } - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { $langs->load("errors"); - $this->error=$langs->trans('ErrorNumRefModel', $max); + $this->error = $langs->trans('ErrorNumRefModel', $max); return false; } @@ -114,21 +114,21 @@ class mod_mo_standard extends ModeleNumRefMos */ public function getNextValue($objprod, $object) { - global $db,$conf; + global $db, $conf; // D'abord on recupere la valeur max - $posindice=9; + $posindice = 9; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."mrp_mo"; - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj) $max = intval($obj->max); - else $max=0; + else $max = 0; } else { @@ -137,11 +137,11 @@ class mod_mo_standard extends ModeleNumRefMos } //$date=time(); - $date=$object->date_creation; + $date = $object->date_creation; $yymm = strftime("%y%m", $date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s", $max+1); + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max + 1); dol_syslog("mod_mo_standard::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/tpl/commonfields_view.tpl.php b/htdocs/core/tpl/commonfields_view.tpl.php index 96268b11f67..2eae2655fbb 100644 --- a/htdocs/core/tpl/commonfields_view.tpl.php +++ b/htdocs/core/tpl/commonfields_view.tpl.php @@ -24,12 +24,12 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } -if (! is_object($form)) $form=new Form($db); +if (!is_object($form)) $form = new Form($db); ?> @@ -37,22 +37,22 @@ if (! is_object($form)) $form=new Form($db); $object->fields = dol_sort_array($object->fields, 'position'); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { // Discard if extrafield is a hidden field on form if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) continue; - if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! verifCond($val['enabled'])) continue; // We don't want this field - if (in_array($key, array('ref','status'))) continue; // Ref and status are already in dol_banner + if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) continue; // We don't want this field + if (in_array($key, array('ref', 'status'))) continue; // Ref and status are already in dol_banner - $value=$object->$key; + $value = $object->$key; print ''; - if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); + if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); else print $langs->trans($val['label']); print ''; print '
    '; print ''; $alreadyoutput = 1; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { if ($alreadyoutput) { - if (! empty($keyforbreak) && $key == $keyforbreak) $alreadyoutput = 0; // key used for break on second column + if (!empty($keyforbreak) && $key == $keyforbreak) $alreadyoutput = 0; // key used for break on second column continue; } - if (abs($val['visible']) != 1) continue; // Discard such field from form - if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field - if (in_array($key, array('ref','status'))) continue; // Ref and status are already in dol_banner + if (abs($val['visible']) != 1) continue; // Discard such field from form + if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) continue; // We don't want this field + if (in_array($key, array('ref', 'status'))) continue; // Ref and status are already in dol_banner - $value=$object->$key; + $value = $object->$key; print ''; - if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); + if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); else print $langs->trans($val['label']); print ''; print ''; print ''; - $balancestart=array(); - $content=array(); + $balancestart = array(); + $content = array(); while ($i < min($numrows, $conf->liste_limit)) { $objp = $db->fetch_object($result); - if (! isset($objp->numr)) + if (!isset($objp->numr)) { // } @@ -309,13 +309,13 @@ if (empty($numref)) // Calculate start amount $sql = "SELECT sum(b.amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve < '".$db->escape($objp->numr)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.num_releve < '".$db->escape($objp->numr)."'"; + $sql .= " AND b.fk_account = ".$object->id; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $balancestart[$objp->numr] = $obj->amount; $db->free($resql); } @@ -323,17 +323,17 @@ if (empty($numref)) // Calculate end amount $sql = "SELECT sum(b.amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve = '".$db->escape($objp->numr)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.num_releve = '".$db->escape($objp->numr)."'"; + $sql .= " AND b.fk_account = ".$object->id; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $content[$objp->numr] = $obj->amount; $db->free($resql); } - print ''; + print ''; print '\n"; print ''; // Type and num if ($objp->fk_type == 'SOLD') { - $type_label=' '; + $type_label = ' '; } else { - $type_label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type; + $type_label = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $objp->fk_type; } - $link=''; - if ($objp->fk_bordereau>0) { + $link = ''; + if ($objp->fk_bordereau > 0) { $remisestatic->id = $objp->fk_bordereau; $remisestatic->ref = $objp->ref; $link = ' '.$remisestatic->getNomUrl(1); } - print ''; + print ''; // Description print ''; - print ''; + print ''; + print ''; } if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 { - print ''; - print ''; + print ''; + print ''; } print ''; @@ -1318,18 +1318,18 @@ else print $langs->trans('PaymentConditionsShort'); print ''; if ($action != 'editconditions' && $user->rights->facture->creer) - print ''; + print ''; print '
    '; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 8e53cffd020..96cb662fe0b 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -23,7 +23,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -59,7 +59,7 @@ class Mo extends CommonObject const STATUS_DRAFT = 0; - const STATUS_VALIDATED = 1; // To produce + const STATUS_VALIDATED = 1; // To produce const STATUS_INPROGRESS = 2; const STATUS_PRODUCED = 3; const STATUS_CANCELED = -1; @@ -90,7 +90,7 @@ class Mo extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1,), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1',), @@ -197,11 +197,11 @@ class Mo extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -210,13 +210,13 @@ class Mo extends CommonObject } // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (is_array($val['arrayofkeyval'])) { - foreach($val['arrayofkeyval'] as $key2 => $val2) + foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } } @@ -254,7 +254,7 @@ class Mo extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); // get lines so they will be clone //foreach($this->lines as $line) @@ -266,18 +266,18 @@ class Mo extends CommonObject unset($object->import_key); // Clear fields - $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default']; - $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref : $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach($object->array_options as $key => $option) + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); @@ -294,7 +294,7 @@ class Mo extends CommonObject $this->errors = $object->errors; } - if (! $error) + if (!$error) { // copy internal contacts if ($this->copy_linked_contact($object, 'internal') < 0) @@ -303,7 +303,7 @@ class Mo extends CommonObject } } - if (! $error) + if (!$error) { // copy external contacts if same company if (property_exists($this, 'socid') && $this->socid == $object->socid) @@ -335,7 +335,7 @@ class Mo extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); return $result; } @@ -346,7 +346,7 @@ class Mo extends CommonObject */ public function fetchLines() { - $this->lines=array(); + $this->lines = array(); $result = $this->fetchLinesCommon(); return $result; @@ -370,40 +370,40 @@ class Mo extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $records=array(); + $records = array(); $sql = 'SELECT '; $sql .= $this->getFieldList(); - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; else $sql .= ' WHERE 1 = 1'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key=='t.rowid') { - $sqlwhere[] = $key . '='. $value; + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; } - elseif ($key=='customsql') { + elseif ($key == 'customsql') { $sqlwhere[] = $value; } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } if (count($sqlwhere) > 0) { - $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -425,8 +425,8 @@ class Mo extends CommonObject return $records; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } @@ -490,51 +490,51 @@ class Mo extends CommonObject { global $conf, $langs, $hookmanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = '' . $langs->trans("MO") . ''; - $label.= '
    '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("MO").''; + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/mrp/mo_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMo"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMo"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('modao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -589,10 +589,10 @@ class Mo extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -603,7 +603,7 @@ class Mo extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -617,7 +617,7 @@ class Mo extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); @@ -651,7 +651,7 @@ class Mo extends CommonObject */ public function getLinesArray() { - $this->lines=array(); + $this->lines = array(); $objectline = new MoLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_mo = '.$this->id)); @@ -682,16 +682,16 @@ class Mo extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("mrp"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'standard'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->MO_ADDON_PDF)) { + } elseif (!empty($conf->global->MO_ADDON_PDF)) { $modele = $conf->global->MO_ADDON_PDF; } } @@ -716,7 +716,7 @@ class Mo extends CommonObject $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; dol_syslog(__METHOD__, LOG_DEBUG); From df664e790bdfdf788507fdf11a2f7fb66fc51442 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 11 Nov 2019 23:15:34 +0000 Subject: [PATCH 179/299] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/compta/accounting-files.php | 306 ++-- htdocs/compta/bank/annuel.php | 248 ++-- htdocs/compta/bank/releve.php | 296 ++-- htdocs/compta/charges/index.php | 248 ++-- htdocs/compta/deplacement/card.php | 94 +- htdocs/compta/facture/card-rec.php | 418 +++--- htdocs/compta/facture/card.php | 1650 +++++++++++----------- htdocs/compta/localtax/index.php | 172 +-- htdocs/compta/localtax/list.php | 24 +- htdocs/compta/localtax/quadri_detail.php | 264 ++-- htdocs/compta/paiement/cheque/card.php | 186 +-- htdocs/compta/prelevement/factures.php | 48 +- htdocs/compta/recap-compta.php | 88 +- htdocs/compta/resultat/clientfourn.php | 562 ++++---- htdocs/compta/tva/clients.php | 246 ++-- htdocs/compta/tva/index.php | 174 +-- htdocs/compta/tva/list.php | 142 +- htdocs/compta/tva/quadri_detail.php | 276 ++-- htdocs/contrat/index.php | 360 ++--- htdocs/don/index.php | 66 +- htdocs/fourn/commande/index.php | 144 +- htdocs/fourn/contact.php | 24 +- htdocs/fourn/recap-fourn.php | 42 +- htdocs/loan/createschedule.php | 94 +- htdocs/loan/schedule.php | 104 +- htdocs/printing/admin/printing.php | 62 +- htdocs/product/card.php | 552 ++++---- htdocs/product/index.php | 242 ++-- htdocs/product/price.php | 884 ++++++------ htdocs/product/stats/card.php | 210 +-- htdocs/product/traduction.php | 72 +- htdocs/reception/card.php | 668 ++++----- htdocs/takepos/invoice.php | 316 ++--- htdocs/takepos/send.php | 32 +- htdocs/user/bank.php | 102 +- htdocs/website/index.php | 984 ++++++------- 36 files changed, 5200 insertions(+), 5200 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index eec09bb94cc..1d238a7b852 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -34,24 +34,24 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $langs->loadLangs(array("accountancy", "bills", "companies", "salaries", "compta")); -$date_start =GETPOST('date_start', 'alpha'); -$date_startDay= GETPOST('date_startday', 'int'); -$date_startMonth= GETPOST('date_startmonth', 'int'); -$date_startYear= GETPOST('date_startyear', 'int'); -$date_start=($date_startDay)?dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear):strtotime($date_start); -$date_stop =GETPOST('date_stop', 'alpha'); -$date_stopDay= GETPOST('date_stopday', 'int'); -$date_stopMonth= GETPOST('date_stopmonth', 'int'); -$date_stopYear= GETPOST('date_stopyear', 'int'); +$date_start = GETPOST('date_start', 'alpha'); +$date_startDay = GETPOST('date_startday', 'int'); +$date_startMonth = GETPOST('date_startmonth', 'int'); +$date_startYear = GETPOST('date_startyear', 'int'); +$date_start = ($date_startDay) ?dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear) : strtotime($date_start); +$date_stop = GETPOST('date_stop', 'alpha'); +$date_stopDay = GETPOST('date_stopday', 'int'); +$date_stopMonth = GETPOST('date_stopmonth', 'int'); +$date_stopYear = GETPOST('date_stopyear', 'int'); //FIXME doldate -$date_stop=($date_stopDay)?dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear):strtotime($date_stop); -$action =GETPOST('action', 'alpha'); +$date_stop = ($date_stopDay) ?dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear) : strtotime($date_stop); +$action = GETPOST('action', 'alpha'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('comptafileslist','globallist')); +$hookmanager->initHooks(array('comptafileslist', 'globallist')); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -59,11 +59,11 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="date,item"; // Set here default search field -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "date,item"; // Set here default search field +if (!$sortorder) $sortorder = "DESC"; -$arrayfields=array( +$arrayfields = array( 'type'=>array('label'=>"Type", 'checked'=>1), 'date'=>array('label'=>"Date", 'checked'=>1), //... @@ -77,7 +77,7 @@ if ($user->socid > 0) { accessforbidden(); } -$entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; +$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; /* @@ -89,9 +89,9 @@ $entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks //if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -$filesarray=array(); -$result=false; -if (($action=="searchfiles" || $action=="dl" )) { +$filesarray = array(); +$result = false; +if (($action == "searchfiles" || $action == "dl")) { if (empty($date_start)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")), null, 'errors'); @@ -103,159 +103,159 @@ if (($action=="searchfiles" || $action=="dl" )) { $error++; } - if (! $error) + if (!$error) { - $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; + $wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; - $sql="SELECT t.rowid as id, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; - $sql.=" WHERE datef between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND t.fk_statut <> ".Facture::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT t.rowid as id, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; - $sql.=" WHERE datef between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT t.rowid as id, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; - $sql.=" WHERE date_fin between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT t.rowid as id, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; - $sql.=" WHERE datedon between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND t.fk_statut <> ".Don::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT t.rowid as id, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; - $sql.=" WHERE datep between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; + $sql = "SELECT t.rowid as id, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " WHERE datef between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; + $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " WHERE datef between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; + $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; + $sql .= " WHERE date_fin between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; + $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; + $sql .= " WHERE datedon between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; + $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT t.rowid as id, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."chargesociales as t"; - $sql.=" WHERE date_creation between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; + $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; + $sql .= " WHERE date_creation between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; - $sql.= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); //print $sql; $resd = $db->query($sql); - $files=array(); - $link=''; + $files = array(); + $link = ''; if ($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; + $upload_dir = ''; + $i = 0; while ($i < $numd) { $objd = $db->fetch_object($resd); - switch($objd->item) + switch ($objd->item) { case "Invoice": $subdir = ''; - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); $upload_dir = $conf->facture->dir_output.'/'.$subdir; - $link="document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; + $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; break; case "SupplierInvoice": $tmpinvoicesupplier->fetch($objd->id); - $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; - $link="document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; + $link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; break; case "ExpenseReport": $subdir = ''; - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; - $link="document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; + $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; break; case "SalaryPayment": $subdir = ''; - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); $upload_dir = $conf->salaries->dir_output.'/'.$subdir; - $link="document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; + $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; break; case "Donation": $tmpdonation->fetch($objp->id); - $subdir=get_exdir(0, 0, 0, 0, $tmpdonation, 'donation'); - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->don->dir_output . '/' . $subdir; - $link="document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; + $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation'); + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->don->dir_output.'/'.$subdir; + $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; break; case "SocialContributions": $subdir = ''; - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->tax->dir_output . '/' . $subdir; - $link="document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->tax->dir_output.'/'.$subdir; + $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; break; default: - $subdir=''; - $upload_dir=''; - $link=''; + $subdir = ''; + $upload_dir = ''; + $link = ''; break; } if (!empty($upload_dir)) { - $result=true; - $files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); + $result = true; + $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); //var_dump($upload_dir); if (count($files) < 1) { - $nofile['id']=$objd->id; - $nofile['date']=$db->idate($objd->date); - $nofile['paid']=$objd->paid; - $nofile['amount_ht']=$objd->total_ht; - $nofile['amount_ttc']=$objd->total_ttc; - $nofile['amount_vat']=$objd->total_vat; - $nofile['ref']=($objd->ref ? $objd->ref : $objd->id); - $nofile['fk']=$objd->fk_soc; - $nofile['item']=$objd->item; - $nofile['thirdparty_name']=$objd->thirdparty_name; - $nofile['thirdparty_code']=$objd->thirdparty_code; - $nofile['country_code']=$objd->country_code; - $nofile['vatnum']=$objd->vatnum; + $nofile['id'] = $objd->id; + $nofile['date'] = $db->idate($objd->date); + $nofile['paid'] = $objd->paid; + $nofile['amount_ht'] = $objd->total_ht; + $nofile['amount_ttc'] = $objd->total_ttc; + $nofile['amount_vat'] = $objd->total_vat; + $nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id); + $nofile['fk'] = $objd->fk_soc; + $nofile['item'] = $objd->item; + $nofile['thirdparty_name'] = $objd->thirdparty_name; + $nofile['thirdparty_code'] = $objd->thirdparty_code; + $nofile['country_code'] = $objd->country_code; + $nofile['vatnum'] = $objd->vatnum; - $filesarray[]=$nofile; + $filesarray[] = $nofile; } else { foreach ($files as $key => $file) { - $file['id']=$objd->id; - $file['date']=$db->idate($objd->date); - $file['paid']=$objd->paid; - $file['amount_ht']=$objd->total_ht; - $file['amount_ttc']=$objd->total_ttc; - $file['amount_vat']=$objd->total_vat; - $file['ref']=($objd->ref ? $objd->ref : $objd->id); - $file['fk']=$objd->fk_soc; - $file['item']=$objd->item; + $file['id'] = $objd->id; + $file['date'] = $db->idate($objd->date); + $file['paid'] = $objd->paid; + $file['amount_ht'] = $objd->total_ht; + $file['amount_ttc'] = $objd->total_ttc; + $file['amount_vat'] = $objd->total_vat; + $file['ref'] = ($objd->ref ? $objd->ref : $objd->id); + $file['fk'] = $objd->fk_soc; + $file['item'] = $objd->item; - $file['thirdparty_name']=$objd->thirdparty_name; - $file['thirdparty_code']=$objd->thirdparty_code; - $file['country_code']=$objd->country_code; - $file['vatnum']=$objd->vatnum; + $file['thirdparty_name'] = $objd->thirdparty_name; + $file['thirdparty_code'] = $objd->thirdparty_code; + $file['country_code'] = $objd->country_code; + $file['vatnum'] = $objd->vatnum; - $file['link']=$link.$file['name']; + $file['link'] = $link.$file['name']; $file['relpathnamelang'] = $langs->trans($file['item']).'/'.$file['name']; - $filesarray[]=$file; + $filesarray[] = $file; } } } @@ -284,9 +284,9 @@ if (empty($dirfortmpfile)) } -if ($result && $action == "dl" && ! $error) +if ($result && $action == "dl" && !$error) { - if (! extension_loaded('zip')) + if (!extension_loaded('zip')) { setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors'); exit; @@ -295,41 +295,41 @@ if ($result && $action == "dl" && ! $error) dol_mkdir($dirfortmpfile); $log = $langs->transnoentitiesnoconv("Type"); - $log .= ',' . $langs->transnoentitiesnoconv("Date"); - $log .= ',' . $langs->transnoentitiesnoconv("Ref"); - $log .= ',' . $langs->transnoentitiesnoconv("TotalHT"); - $log .= ',' . $langs->transnoentitiesnoconv("TotalTTC"); - $log .= ',' . $langs->transnoentitiesnoconv("TotalVAT"); - $log .= ',' . $langs->transnoentitiesnoconv("Paid"); + $log .= ','.$langs->transnoentitiesnoconv("Date"); + $log .= ','.$langs->transnoentitiesnoconv("Ref"); + $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); + $log .= ','.$langs->transnoentitiesnoconv("TotalTTC"); + $log .= ','.$langs->transnoentitiesnoconv("TotalVAT"); + $log .= ','.$langs->transnoentitiesnoconv("Paid"); $log .= ',filename,item_id'; - $log .= ',' . $langs->transnoentitiesnoconv("ThirdParty"); - $log .= ',' . $langs->transnoentitiesnoconv("Code"); - $log .= ',' . $langs->transnoentitiesnoconv("Country"); - $log .= ',' . $langs->transnoentitiesnoconv("VATIntra")."\n"; + $log .= ','.$langs->transnoentitiesnoconv("ThirdParty"); + $log .= ','.$langs->transnoentitiesnoconv("Code"); + $log .= ','.$langs->transnoentitiesnoconv("Country"); + $log .= ','.$langs->transnoentitiesnoconv("VATIntra")."\n"; $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; dol_delete_file($zipname); $zip = new ZipArchive; - $res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE); + $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE); if ($res) { foreach ($filesarray as $key => $file) { if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); $log .= $file['item']; - $log .= ',' . dol_print_date($file['date'], 'dayrfc'); - $log .= ',' . $file['ref']; - $log .= ',' . $file['amount_ht']; - $log .= ',' . $file['amount_ttc']; - $log .= ',' . $file['amount_vat']; - $log .= ',' . $file['paid']; - $log .= ',' . $file["name"]; - $log .= ',' . $file['fk']; - $log .= ',' . $file['thirdparty_name']; - $log .= ',' . $file['thirdparty_code']; - $log .= ',' . $file['country_code']; - $log .= ',"' . $file['vatnum'].'"'."\n"; + $log .= ','.dol_print_date($file['date'], 'dayrfc'); + $log .= ','.$file['ref']; + $log .= ','.$file['amount_ht']; + $log .= ','.$file['amount_ttc']; + $log .= ','.$file['amount_vat']; + $log .= ','.$file['paid']; + $log .= ','.$file["name"]; + $log .= ','.$file['fk']; + $log .= ','.$file['thirdparty_name']; + $log .= ','.$file['thirdparty_code']; + $log .= ','.$file['country_code']; + $log .= ',"'.$file['vatnum'].'"'."\n"; } $zip->addFromString('transactions.csv', $log); $zip->close(); @@ -337,7 +337,7 @@ if ($result && $action == "dl" && ! $error) ///Then download the zipped file. header('Content-Type: application/zip'); header('Content-disposition: attachment; filename='.basename($zipname)); - header('Content-Length: ' . filesize($zipname)); + header('Content-Length: '.filesize($zipname)); readfile($zipname); dol_delete_file($zipname); @@ -356,13 +356,13 @@ if ($result && $action == "dl" && ! $error) */ $form = new Form($db); -$userstatic=new User($db); +$userstatic = new User($db); -$title=$langs->trans("ComptaFiles").' - '.$langs->trans("List"); +$title = $langs->trans("ComptaFiles").' - '.$langs->trans("List"); llxHeader('', $title, $help_url); -$h=0; +$h = 0; $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; $head[$h][1] = $langs->trans("AccountantFiles"); $head[$h][2] = 'AccountancyFiles'; @@ -376,7 +376,7 @@ print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_st print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n"; // Export is for current company only ! -if (! empty($conf->multicompany->enabled) && is_object($mc)) +if (!empty($conf->multicompany->enabled) && is_object($mc)) { print '('.$langs->trans("Entity").' : '; $mc->dao->getEntities(); @@ -393,13 +393,13 @@ dol_fiche_end(); if (!empty($date_start) && !empty($date_stop)) { - $param='action=searchfiles'; - $param.='&date_startday='.GETPOST('date_startday', 'int'); - $param.='&date_startmonth='.GETPOST('date_startmonth', 'int'); - $param.='&date_startyear='.GETPOST('date_startyear', 'int'); - $param.='&date_stopday='.GETPOST('date_stopday', 'int'); - $param.='&date_stopmonth='.GETPOST('date_stopmonth', 'int'); - $param.='&date_stopyear='.GETPOST('date_stopyear', 'int'); + $param = 'action=searchfiles'; + $param .= '&date_startday='.GETPOST('date_startday', 'int'); + $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int'); + $param .= '&date_startyear='.GETPOST('date_startyear', 'int'); + $param .= '&date_stopday='.GETPOST('date_stopday', 'int'); + $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); + $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); print '
    '."\n"; print ''; @@ -422,7 +422,7 @@ if (!empty($date_start) && !empty($date_stop)) print '
    '; - print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'nowrap '); @@ -457,7 +457,7 @@ if (!empty($date_start) && !empty($date_stop)) $totalCredit = 0; // Display array - foreach($TData as $data) + foreach ($TData as $data) { $html_class = ''; //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index d10374e4c8d..1f6e5e6620c 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -32,28 +32,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories')); -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width', 380); // Large for one graph in a smarpthone. -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height', 160); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 380); // Large for one graph in a smarpthone. +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 160); -$id=GETPOST('account')?GETPOST('account', 'alpha'):GETPOST('id'); -$ref=GETPOST('ref'); +$id = GETPOST('account') ?GETPOST('account', 'alpha') : GETPOST('id'); +$ref = GETPOST('ref'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); -$fieldtype = (! empty($ref) ? 'ref' :'rowid'); -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); -$year_start=GETPOST('year_start'); +$year_start = GETPOST('year_start'); $year_current = strftime("%Y", time()); -if (! $year_start) +if (!$year_start) { $year_start = $year_current - 2; $year_end = $year_current; } else { - $year_end=$year_start+2; + $year_end = $year_start + 2; } @@ -70,15 +70,15 @@ $form = new Form($db); // Get account informations $object = new Account($db); -if ($id > 0 && ! preg_match('/,/', $id)) // if for a particular account and not a list +if ($id > 0 && !preg_match('/,/', $id)) // if for a particular account and not a list { - $result=$object->fetch($id); - $id=$object->id; + $result = $object->fetch($id); + $id = $object->id; } -if (! empty($ref)) +if (!empty($ref)) { - $result=$object->fetch(0, $ref); - $id=$object->id; + $result = $object->fetch(0, $ref); + $id = $object->id; } @@ -86,17 +86,17 @@ if (! empty($ref)) // plutot que sur llx_paiement + llx_paiementfourn $sql = "SELECT SUM(b.amount)"; -$sql.= ", date_format(b.dateo,'%Y-%m') as dm"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; -$sql.= " WHERE b.fk_account = ba.rowid"; -$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; -$sql.= " AND b.amount >= 0"; -if (! empty($id)) +$sql .= ", date_format(b.dateo,'%Y-%m') as dm"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; +$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; +$sql .= " WHERE b.fk_account = ba.rowid"; +$sql .= " AND ba.entity IN (".getEntity('bank_account').")"; +$sql .= " AND b.amount >= 0"; +if (!empty($id)) $sql .= " AND b.fk_account IN (".$db->escape($id).")"; -$sql.= " GROUP BY dm"; +$sql .= " GROUP BY dm"; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -114,17 +114,17 @@ else } $sql = "SELECT SUM(b.amount)"; -$sql.= ", date_format(b.dateo,'%Y-%m') as dm"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; -$sql.= " WHERE b.fk_account = ba.rowid"; -$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; -$sql.= " AND b.amount <= 0"; -if (! empty($id)) +$sql .= ", date_format(b.dateo,'%Y-%m') as dm"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; +$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; +$sql .= " WHERE b.fk_account = ba.rowid"; +$sql .= " AND ba.entity IN (".getEntity('bank_account').")"; +$sql .= " AND b.amount <= 0"; +if (!empty($id)) $sql .= " AND b.fk_account IN (".$db->escape($id).")"; -$sql.= " GROUP BY dm"; +$sql .= " GROUP BY dm"; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -143,31 +143,31 @@ else // Onglets -$head=bank_prepare_head($object); +$head = bank_prepare_head($object); dol_fiche_head($head, 'annual', $langs->trans("FinancialAccount"), 0, 'account'); -$title=$langs->trans("FinancialAccount")." : ".$object->label; -$link=($year_start?"".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"')."":""); +$title = $langs->trans("FinancialAccount")." : ".$object->label; +$link = ($year_start ? "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"')."" : ""); $linkback = ''.$langs->trans("BackToList").''; if (!empty($id)) { - if (! preg_match('/,/', $id)) + if (!preg_match('/,/', $id)) { dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); } else { - $bankaccount=new Account($db); - $listid=explode(',', $id); - foreach($listid as $key => $aId) + $bankaccount = new Account($db); + $listid = explode(',', $id); + foreach ($listid as $key => $aId) { $bankaccount->fetch($aId); - $bankaccount->label=$bankaccount->ref; + $bankaccount->label = $bankaccount->ref; print $bankaccount->getNomUrl(1); - if ($key < (count($listid)-1)) print ', '; + if ($key < (count($listid) - 1)) print ', '; } } } @@ -182,11 +182,11 @@ dol_fiche_end(); // Affiche tableau print load_fiche_titre('', $link, ''); -print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
    '; print ''; -for ($annee = $year_start ; $annee <= $year_end ; $annee++) +for ($annee = $year_start; $annee <= $year_end; $annee++) { print ''; } @@ -194,33 +194,33 @@ print ''; print ''; print ''; -for ($annee = $year_start ; $annee <= $year_end ; $annee++) +for ($annee = $year_start; $annee <= $year_end; $annee++) { print ''; } print ''; -for ($mois = 1 ; $mois < 13 ; $mois++) +for ($mois = 1; $mois < 13; $mois++) { print ''; print ""; - for ($annee = $year_start ; $annee <= $year_end ; $annee++) + for ($annee = $year_start; $annee <= $year_end; $annee++) { $case = sprintf("%04s-%02s", $annee, $mois); print '"; print '"; } @@ -229,7 +229,7 @@ for ($mois = 1 ; $mois < 13 ; $mois++) // Total debit-credit print '"; -for ($annee = $year_start ; $annee <= $year_end ; $annee++) +for ($annee = $year_start; $annee <= $year_end; $annee++) { print ''; } @@ -242,21 +242,21 @@ print '
    '; // Current balance -$balance=0; +$balance = 0; $sql = "SELECT SUM(b.amount) as total"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; -$sql.= " WHERE b.fk_account = ba.rowid"; -$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; -if (! empty($id)) - $sql.= " AND b.fk_account IN (".$db->escape($id).")"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; +$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; +$sql .= " WHERE b.fk_account = ba.rowid"; +$sql .= " AND ba.entity IN (".getEntity('bank_account').")"; +if (!empty($id)) + $sql .= " AND b.fk_account IN (".$db->escape($id).")"; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $balance=$obj->total; + if ($obj) $balance = $obj->total; } else { dol_print_error($db); @@ -274,7 +274,7 @@ print "
    '.$langs->trans("Month").''.$annee.'
     '.$langs->trans("Debit").''.$langs->trans("Credit").'
    ".dol_print_date(dol_mktime(1, 1, 1, $mois, 1, 2000), "%B")." '; - if ($decaiss[$case]>0) + if ($decaiss[$case] > 0) { print price($decaiss[$case]); - $totsorties[$annee]+=$decaiss[$case]; + $totsorties[$annee] += $decaiss[$case]; } print " '; - if ($encaiss[$case]>0) + if ($encaiss[$case] > 0) { print price($encaiss[$case]); - $totentrees[$annee]+=$encaiss[$case]; + $totentrees[$annee] += $encaiss[$case]; } print "
    '.$langs->trans("Total")."'.price($totsorties[$annee]).''.price($totentrees[$annee]).'
    "; $year = $year_end; -$result=dol_mkdir($conf->bank->dir_temp); +$result = dol_mkdir($conf->bank->dir_temp); if ($result < 0) { $langs->load("errors"); @@ -285,11 +285,11 @@ else { // Calcul de $min et $max $sql = "SELECT MIN(b.datev) as min, MAX(b.datev) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")"; $resql = $db->query($sql); if ($resql) @@ -303,7 +303,7 @@ else { dol_print_error($db); } - $log="graph.php: min=".$min." max=".$max; + $log = "graph.php: min=".$min." max=".$max; dol_syslog($log); // CRED PART @@ -312,18 +312,18 @@ else $tblyear[1] = array(); $tblyear[2] = array(); - for ($annee=0;$annee<3;$annee++) + for ($annee = 0; $annee < 3; $annee++) { $sql = "SELECT date_format(b.datev,'%m')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'"; - $sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'"; - $sql.= " AND b.amount > 0"; - if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'"; + $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'"; + $sql .= " AND b.amount > 0"; + if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")"; $sql .= " GROUP BY date_format(b.datev,'%m');"; $resql = $db->query($sql); @@ -350,38 +350,38 @@ else $data_year_1 = array(); $data_year_2 = array(); - for ($i = 0 ; $i < 12 ; $i++) + for ($i = 0; $i < 12; $i++) { - $data_year_0[$i] = isset($tblyear[0][substr("0".($i+1), -2)]) ? $tblyear[0][substr("0".($i+1), -2)] : 0; - $data_year_1[$i] = isset($tblyear[1][substr("0".($i+1), -2)]) ? $tblyear[1][substr("0".($i+1), -2)] : 0; - $data_year_2[$i] = isset($tblyear[2][substr("0".($i+1), -2)]) ? $tblyear[2][substr("0".($i+1), -2)] : 0; - $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i+1)); + $data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0; + $data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0; + $data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0; + $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i + 1)); $datamin[$i] = 0; } // Fabrication tableau 4b - $file= $conf->bank->dir_temp."/credmovement".$id."-".$year.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/credmovement".$id."-".$year.".png"; - $title=$langs->transnoentities("Credit").' - '.$langs->transnoentities("Year").': '.($year-2).' - '.($year-1)." - ".$year; - $graph_datas=array(); - for($i=0;$i<12;$i++) + $file = $conf->bank->dir_temp."/credmovement".$id."-".$year.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/credmovement".$id."-".$year.".png"; + $title = $langs->transnoentities("Credit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year; + $graph_datas = array(); + for ($i = 0; $i < 12; $i++) { - $graph_datas[$i]=array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]); + $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]); } $px1 = new DolGraph(); $px1->SetData($graph_datas); - $px1->SetLegend(array(($year),($year-1),($year-2))); + $px1->SetLegend(array(($year), ($year - 1), ($year - 2))); $px1->SetLegendWidthMin(180); - $px1->SetMaxValue($px1->GetCeilMaxValue()<0?0:$px1->GetCeilMaxValue()); - $px1->SetMinValue($px1->GetFloorMinValue()>0?0:$px1->GetFloorMinValue()); + $px1->SetMaxValue($px1->GetCeilMaxValue() < 0 ? 0 : $px1->GetCeilMaxValue()); + $px1->SetMinValue($px1->GetFloorMinValue() > 0 ? 0 : $px1->GetFloorMinValue()); $px1->SetTitle($title); $px1->SetWidth($WIDTH); $px1->SetHeight($HEIGHT); - $px1->SetType(array('line','line','line')); + $px1->SetType(array('line', 'line', 'line')); $px1->SetShading(3); $px1->setBgColor('onglet'); - $px1->setBgColorGrid(array(255,255,255)); + $px1->setBgColorGrid(array(255, 255, 255)); $px1->SetHorizTickIncrement(1); $px1->draw($file, $fileurl); @@ -399,18 +399,18 @@ else $tblyear[1] = array(); $tblyear[2] = array(); - for ($annee=0;$annee<3;$annee++) + for ($annee = 0; $annee < 3; $annee++) { $sql = "SELECT date_format(b.datev,'%m')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'"; - $sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'"; - $sql.= " AND b.amount < 0"; - if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'"; + $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'"; + $sql .= " AND b.amount < 0"; + if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")"; $sql .= " GROUP BY date_format(b.datev,'%m');"; $resql = $db->query($sql); @@ -437,37 +437,37 @@ else $data_year_1 = array(); $data_year_2 = array(); - for ($i = 0 ; $i < 12 ; $i++) + for ($i = 0; $i < 12; $i++) { - $data_year_0[$i] = isset($tblyear[0][substr("0".($i+1), -2)]) ? $tblyear[0][substr("0".($i+1), -2)] : 0; - $data_year_1[$i] = isset($tblyear[1][substr("0".($i+1), -2)]) ? $tblyear[1][substr("0".($i+1), -2)] : 0; - $data_year_2[$i] = isset($tblyear[2][substr("0".($i+1), -2)]) ? $tblyear[2][substr("0".($i+1), -2)] : 0; - $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i+1)); + $data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0; + $data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0; + $data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0; + $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i + 1)); $datamin[$i] = 0; } - $file= $conf->bank->dir_temp."/debmovement".$id."-".$year.".png"; - $fileurl= DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/debmovement".$id."-".$year.".png"; - $title=$langs->transnoentities("Debit").' - '.$langs->transnoentities("Year").': '.($year-2).' - '.($year-1)." - ".$year; - $graph_datas=array(); - for($i=0;$i<12;$i++) + $file = $conf->bank->dir_temp."/debmovement".$id."-".$year.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/debmovement".$id."-".$year.".png"; + $title = $langs->transnoentities("Debit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year; + $graph_datas = array(); + for ($i = 0; $i < 12; $i++) { - $graph_datas[$i]=array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]); + $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]); } $px2 = new DolGraph(); $px2->SetData($graph_datas); - $px2->SetLegend(array(($year),($year-1),($year-2))); + $px2->SetLegend(array(($year), ($year - 1), ($year - 2))); $px2->SetLegendWidthMin(180); - $px2->SetMaxValue($px2->GetCeilMaxValue()<0?0:$px2->GetCeilMaxValue()); - $px2->SetMinValue($px2->GetFloorMinValue()>0?0:$px2->GetFloorMinValue()); + $px2->SetMaxValue($px2->GetCeilMaxValue() < 0 ? 0 : $px2->GetCeilMaxValue()); + $px2->SetMinValue($px2->GetFloorMinValue() > 0 ? 0 : $px2->GetFloorMinValue()); $px2->SetTitle($title); $px2->SetWidth($WIDTH); $px2->SetHeight($HEIGHT); - $px2->SetType(array('line','line','line')); + $px2->SetType(array('line', 'line', 'line')); $px2->SetShading(3); $px2->setBgColor('onglet'); - $px2->setBgColorGrid(array(255,255,255)); + $px2->setBgColorGrid(array(255, 255, 255)); $px2->SetHorizTickIncrement(1); $px2->draw($file, $fileurl); @@ -479,9 +479,9 @@ else unset($tblyear[1]); unset($tblyear[2]); - print '
    '; // do not use class="center" here, it will have no effect for the js graph inside. + print '
    '; // do not use class="center" here, it will have no effect for the js graph inside. print $show1; - print '
    '; // do not use class="center" here, it will have no effect for the js graph inside. + print '
    '; // do not use class="center" here, it will have no effect for the js graph inside. print $show2; print '
    '; print '
    '; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index d267f55f640..8920d5eff9b 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -43,38 +43,38 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","categories","companies","bills","trips")); +$langs->loadLangs(array("banks", "categories", "companies", "bills", "trips")); -$action=GETPOST('action', 'alpha'); -$id=GETPOST('account', 'int'); -$ref=GETPOST('ref', 'alpha'); -$dvid=GETPOST('dvid', 'alpha'); -$numref=GETPOST('num', 'alpha'); -$ve=GETPOST("ve", 'alpha'); -$brref=GETPOST('brref', 'alpha'); -$oldbankreceipt=GETPOST('oldbankreceipt', 'alpha'); -$newbankreceipt=GETPOST('newbankreceipt', 'alpha'); +$action = GETPOST('action', 'alpha'); +$id = GETPOST('account', 'int'); +$ref = GETPOST('ref', 'alpha'); +$dvid = GETPOST('dvid', 'alpha'); +$numref = GETPOST('num', 'alpha'); +$ve = GETPOST("ve", 'alpha'); +$brref = GETPOST('brref', 'alpha'); +$oldbankreceipt = GETPOST('oldbankreceipt', 'alpha'); +$newbankreceipt = GETPOST('newbankreceipt', 'alpha'); // Security check -$fieldid = (! empty($ref)?$ref:$id); -$fieldname = isset($ref)?'ref':'rowid'; -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'banque', $fieldid, 'bank_account', '', '', $fieldname); +$fieldid = (!empty($ref) ? $ref : $id); +$fieldname = isset($ref) ? 'ref' : 'rowid'; +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'banque', $fieldid, 'bank_account', '', '', $fieldname); -if ($user->rights->banque->consolidate && $action == 'dvnext' && ! empty($dvid)) +if ($user->rights->banque->consolidate && $action == 'dvnext' && !empty($dvid)) { $al = new AccountLine($db); $al->datev_next($dvid); } -if ($user->rights->banque->consolidate && $action == 'dvprev' && ! empty($dvid)) +if ($user->rights->banque->consolidate && $action == 'dvprev' && !empty($dvid)) { $al = new AccountLine($db); $al->datev_previous($dvid); } -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -84,31 +84,31 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="s.nom"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "s.nom"; $object = new Account($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { - $result=$object->fetch($id, $ref); - $account = $object->id; // Force the search field on id of account + $result = $object->fetch($id, $ref); + $account = $object->id; // Force the search field on id of account } // Initialize technical object to manage context to save list fields -$contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); +$contextpage = 'banktransactionlist'.(empty($object->ref) ? '' : '-'.$object->id); // Define number of receipt to show (current, previous or next one ?) -$found=false; +$found = false; if ($_GET["rel"] == 'prev') { // Recherche valeur pour num = numero releve precedent $sql = "SELECT DISTINCT(b.num_releve) as num"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve < '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $sql.= " ORDER BY b.num_releve DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.num_releve < '".$db->escape($numref)."'"; + $sql .= " AND b.fk_account = ".$object->id; + $sql .= " ORDER BY b.num_releve DESC"; dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); $resql = $db->query($sql); @@ -119,7 +119,7 @@ if ($_GET["rel"] == 'prev') { $obj = $db->fetch_object($resql); $numref = $obj->num; - $found=true; + $found = true; } } } @@ -127,10 +127,10 @@ elseif ($_GET["rel"] == 'next') { // Recherche valeur pour num = numero releve precedent $sql = "SELECT DISTINCT(b.num_releve) as num"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve > '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $sql.= " ORDER BY b.num_releve ASC"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.num_releve > '".$db->escape($numref)."'"; + $sql .= " AND b.fk_account = ".$object->id; + $sql .= " ORDER BY b.num_releve ASC"; dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); $resql = $db->query($sql); @@ -141,29 +141,29 @@ elseif ($_GET["rel"] == 'next') { $obj = $db->fetch_object($resql); $numref = $obj->num; - $found=true; + $found = true; } } } else { // On veut le releve num - $found=true; + $found = true; } $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; -$sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; -$sql.= " b.fk_bordereau,"; -$sql.= " bc.ref,"; -$sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; -$sql.= ", ".MAIN_DB_PREFIX."bank as b"; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; -$sql.= " WHERE b.num_releve='".$db->escape($numref)."'"; -if (empty($numref)) $sql.= " OR b.num_releve is null"; -$sql.= " AND b.fk_account = ".$object->id; -$sql.= " AND b.fk_account = ba.rowid"; -$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day +$sql .= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; +$sql .= " b.fk_bordereau,"; +$sql .= " bc.ref,"; +$sql .= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; +$sql .= ", ".MAIN_DB_PREFIX."bank as b"; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; +$sql .= " WHERE b.num_releve='".$db->escape($numref)."'"; +if (empty($numref)) $sql .= " OR b.num_releve is null"; +$sql .= " AND b.fk_account = ".$object->id; +$sql .= " AND b.fk_account = ba.rowid"; +$sql .= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day $sqlrequestforbankline = $sql; @@ -173,14 +173,14 @@ $sqlrequestforbankline = $sql; * Actions */ -if ($action == 'confirm_editbankreceipt' && ! empty($oldbankreceipt) && ! empty($newbankreceipt)) +if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt)) { // TODO Add a test to check newbankreceipt does not exists yet $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'"'; $result = $db->query($sqlupdate); if ($result < 0) dol_print_error($db); - $action='view'; + $action = 'view'; } @@ -193,33 +193,33 @@ $helpurl = ""; llxHeader('', $title, $helpurl); $form = new Form($db); -$societestatic=new Societe($db); -$chargestatic=new ChargeSociales($db); -$memberstatic=new Adherent($db); -$paymentstatic=new Paiement($db); -$paymentsupplierstatic=new PaiementFourn($db); -$paymentvatstatic=new TVA($db); -$bankstatic=new Account($db); -$banklinestatic=new AccountLine($db); +$societestatic = new Societe($db); +$chargestatic = new ChargeSociales($db); +$memberstatic = new Adherent($db); +$paymentstatic = new Paiement($db); +$paymentsupplierstatic = new PaiementFourn($db); +$paymentvatstatic = new TVA($db); +$bankstatic = new Account($db); +$banklinestatic = new AccountLine($db); $remisestatic = new RemiseCheque($db); // Must be before button action -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($id > 0) $param.='&id='.urlencode($id); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($id > 0) $param .= '&id='.urlencode($id); if (empty($numref)) { - $sortfield='numr'; - $sortorder='DESC'; + $sortfield = 'numr'; + $sortorder = 'DESC'; // List of all standing receipts $sql = "SELECT DISTINCT(b.num_releve) as numr"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.fk_account = ".$object->id; - $sql.=$db->order($sortfield, $sortorder); + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.fk_account = ".$object->id; + $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -229,7 +229,7 @@ if (empty($numref)) $nbtotalofrecords = $db->num_rows($result); } - $sql.= $db->plimit($conf->liste_limit+1, $offset); + $sql .= $db->plimit($conf->liste_limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -238,7 +238,7 @@ if (empty($numref)) $i = 0; // Onglets - $head=bank_prepare_head($object); + $head = bank_prepare_head($object); dol_fiche_head($head, 'statement', $langs->trans("FinancialAccount"), 0, 'account'); $linkback = ''.$langs->trans("BackToList").''; @@ -279,14 +279,14 @@ if (empty($numref)) print '
    '.price(($balancestart[$objp->numr]+$content[$objp->numr]), '', $langs, 1, -1, -1, $conf->currency).''.price(($balancestart[$objp->numr] + $content[$objp->numr]), '', $langs, 1, -1, -1, $conf->currency).''; if ($user->rights->banque->consolidate && $action != 'editbankreceipt') { @@ -362,20 +362,20 @@ else */ // Onglets - $head=account_statement_prepare_head($object, $numref); + $head = account_statement_prepare_head($object, $numref); dol_fiche_head($head, 'statement', $langs->trans("FinancialAccount"), 0, 'account'); - $mesprevnext=''; - $mesprevnext.=''; - $title=$langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); + $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); print load_fiche_titre($title, $mesprevnext, 'title_bank.png'); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'title_bank.png', 0, '', '', 0, 1); @@ -398,14 +398,14 @@ else // Calcul du solde de depart du releve $sql = "SELECT sum(b.amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve < '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.num_releve < '".$db->escape($numref)."'"; + $sql .= " AND b.fk_account = ".$object->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $total = $obj->amount; $db->free($resql); } @@ -437,142 +437,142 @@ else // Date de valeur print ''; - print dol_print_date($db->jdate($objp->dv), "day") .' '; + print dol_print_date($db->jdate($objp->dv), "day").' '; print ''; - print img_edit_remove() . " "; + print img_edit_remove()." "; print ''; - print img_edit_add() .""; + print img_edit_add().""; print "'.$type_label.' '.($objp->num_chq?$objp->num_chq:'').$link.''.$type_label.' '.($objp->num_chq ? $objp->num_chq : '').$link.''; - $reg=array(); - preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthese on tente recherche de traduction - if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); + $reg = array(); + preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthese on tente recherche de traduction + if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) print $langs->trans($reg[1]); else print $objp->label; print ''; /* * Ajout les liens (societe, company...) */ - $newline=1; + $newline = 1; $links = $object->get_url($objp->rowid); - foreach($links as $key=>$val) + foreach ($links as $key=>$val) { - if (! $newline) print ' - '; + if (!$newline) print ' - '; else print '
    '; - if ($links[$key]['type']=='payment') + if ($links[$key]['type'] == 'payment') { - $paymentstatic->id=$links[$key]['url_id']; - $paymentstatic->ref=$langs->trans("Payment"); + $paymentstatic->id = $links[$key]['url_id']; + $paymentstatic->ref = $langs->trans("Payment"); print ' '.$paymentstatic->getNomUrl(1); - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='payment_supplier') + elseif ($links[$key]['type'] == 'payment_supplier') { - $paymentsupplierstatic->id=$links[$key]['url_id']; - $paymentsupplierstatic->ref=$langs->trans("Payment"); + $paymentsupplierstatic->id = $links[$key]['url_id']; + $paymentsupplierstatic->ref = $langs->trans("Payment"); print ' '.$paymentsupplierstatic->getNomUrl(1); - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='payment_sc') + elseif ($links[$key]['type'] == 'payment_sc') { print ''; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; print $langs->trans("SocialContributionPayment"); print ''; - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='payment_vat') + elseif ($links[$key]['type'] == 'payment_vat') { - $paymentvatstatic->id=$links[$key]['url_id']; - $paymentvatstatic->ref=$langs->trans("Payment"); + $paymentvatstatic->id = $links[$key]['url_id']; + $paymentvatstatic->ref = $langs->trans("Payment"); print ' '.$paymentvatstatic->getNomUrl(1); } - elseif ($links[$key]['type']=='payment_salary') + elseif ($links[$key]['type'] == 'payment_salary') { print ''; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; print $langs->trans("Payment"); print ''; - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='banktransfert') { + elseif ($links[$key]['type'] == 'banktransfert') { // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. if ($objp->amount > 0) { $banklinestatic->fetch($links[$key]['url_id']); - $bankstatic->id=$banklinestatic->fk_account; - $bankstatic->label=$banklinestatic->bank_account_label; + $bankstatic->id = $banklinestatic->fk_account; + $bankstatic->label = $banklinestatic->bank_account_label; print ' ('.$langs->trans("from").' '; print $bankstatic->getNomUrl(1, 'transactions'); print ' '.$langs->trans("toward").' '; - $bankstatic->id=$objp->bankid; - $bankstatic->label=$objp->bankref; + $bankstatic->id = $objp->bankid; + $bankstatic->label = $objp->bankref; print $bankstatic->getNomUrl(1, ''); print ')'; } else { - $bankstatic->id=$objp->bankid; - $bankstatic->label=$objp->bankref; + $bankstatic->id = $objp->bankid; + $bankstatic->label = $objp->bankref; print ' ('.$langs->trans("from").' '; print $bankstatic->getNomUrl(1, ''); print ' '.$langs->trans("toward").' '; $banklinestatic->fetch($links[$key]['url_id']); - $bankstatic->id=$banklinestatic->fk_account; - $bankstatic->label=$banklinestatic->bank_account_label; + $bankstatic->id = $banklinestatic->fk_account; + $bankstatic->label = $banklinestatic->bank_account_label; print $bankstatic->getNomUrl(1, 'transactions'); print ')'; } } - elseif ($links[$key]['type']=='company') { + elseif ($links[$key]['type'] == 'company') { $societestatic->id = $links[$key]['url_id']; $societestatic->name = $links[$key]['label']; print $societestatic->getNomUrl(1, 'company', 24); - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='member') { + elseif ($links[$key]['type'] == 'member') { print ''; print img_object($langs->trans('ShowMember'), 'user').' '; print $links[$key]['label']; print ''; - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='user') { + elseif ($links[$key]['type'] == 'user') { print ''; print img_object($langs->trans('ShowUser'), 'user').' '; print $links[$key]['label']; print ''; - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='sc') { + elseif ($links[$key]['type'] == 'sc') { print ''; print img_object($langs->trans('ShowBill'), 'bill').' '; print $langs->trans("SocialContribution"); print ''; - $newline=0; + $newline = 0; } else { print ''; print $links[$key]['label']; print ''; - $newline=0; + $newline = 0; } } @@ -580,18 +580,18 @@ else if ($ve) { $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ as ct"; - $sql.= ", ".MAIN_DB_PREFIX."bank_class as cl"; - $sql.= " WHERE ct.rowid = cl.fk_categ"; - $sql.= " AND ct.entity = ".$conf->entity; - $sql.= " AND cl.lineid = ".$objp->rowid; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as ct"; + $sql .= ", ".MAIN_DB_PREFIX."bank_class as cl"; + $sql .= " WHERE ct.rowid = cl.fk_categ"; + $sql .= " AND ct.entity = ".$conf->entity; + $sql .= " AND cl.lineid = ".$objp->rowid; $resc = $db->query($sql); if ($resc) { $numc = $db->num_rows($resc); $ii = 0; - if ($numc && ! $newline) print '
    '; + if ($numc && !$newline) print '
    '; while ($ii < $numc) { $objc = $db->fetch_object($resc); diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index bd333110e51..fd270cba3f1 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -45,17 +45,17 @@ $hookmanager->initHooks(array('specialexpensesindex')); $langs->loadLangs(array('compta', 'bills')); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); -$mode=GETPOST("mode", 'alpha'); -$year=GETPOST("year", 'int'); -$filtre=GETPOST("filtre", 'alpha'); -if (! $year && $mode != 'sconly') { $year=date("Y", time()); } +$mode = GETPOST("mode", 'alpha'); +$year = GETPOST("year", 'int'); +$filtre = GETPOST("filtre", 'alpha'); +if (!$year && $mode != 'sconly') { $year = date("Y", time()); } $search_account = GETPOST('search_account', 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -63,8 +63,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="cs.date_ech"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "cs.date_ech"; +if (!$sortorder) $sortorder = "DESC"; /* @@ -72,22 +72,22 @@ if (! $sortorder) $sortorder="DESC"; */ $tva_static = new Tva($db); -$socialcontrib=new ChargeSociales($db); -$payment_sc_static=new PaymentSocialContribution($db); +$socialcontrib = new ChargeSociales($db); +$payment_sc_static = new PaymentSocialContribution($db); $sal_static = new PaymentSalary($db); $accountstatic = new Account($db); llxHeader('', $langs->trans("SpecialExpensesArea")); -$title=$langs->trans("SpecialExpensesArea"); -if ($mode == 'sconly') $title=$langs->trans("SocialContributionsPayments"); +$title = $langs->trans("SpecialExpensesArea"); +if ($mode == 'sconly') $title = $langs->trans("SocialContributionsPayments"); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($mode == 'sconly') $param='&mode=sconly'; -if ($sortfield) $param.='&sortfield='.$sortfield; -if ($sortorder) $param.='&sortorder='.$sortorder; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($mode == 'sconly') $param = '&mode=sconly'; +if ($sortfield) $param .= '&sortfield='.$sortfield; +if ($sortorder) $param .= '&sortorder='.$sortorder; print ''; @@ -101,7 +101,7 @@ print ''; if ($mode != 'sconly') { - $center=($year?''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."":""); + $center = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); } else @@ -109,7 +109,7 @@ else print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit); } -if ($year) $param.='&year='.$year; +if ($year) $param .= '&year='.$year; if ($mode != 'sconly') { @@ -117,12 +117,12 @@ if ($mode != 'sconly') print "
    "; } -if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { // Social contributions only if ($mode != 'sconly') { - print load_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("SocialContributionsPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); } print ''; @@ -134,23 +134,23 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) 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); + 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, 'class="right"', $sortfield, $sortorder); print "\n"; $sql = "SELECT c.id, c.libelle as label,"; - $sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; - $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; - $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; - $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql.= " WHERE cs.fk_type = c.id"; - $sql.= " AND cs.entity IN (".getEntity("tax").")"; + $sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; + $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; + $sql .= " pct.code as payment_code,"; + $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; + $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " WHERE cs.fk_type = c.id"; + $sql .= " AND cs.entity IN (".getEntity("tax").")"; if ($year > 0) { $sql .= " AND ("; @@ -160,12 +160,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; $sql .= ")"; } - if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); //$sql.= $db->plimit($limit+1,$offset); //print $sql; dol_syslog("compta/charges/index.php: select payment", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -179,14 +179,14 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $obj = $db->fetch_object($resql); print ''; // Date - $date=$obj->periode; - if (empty($date)) $date=$obj->date_ech; + $date = $obj->periode; + if (empty($date)) $date = $obj->date_ech; print ''; // Label print ''; // Type @@ -194,8 +194,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) // Expected to pay print ''; // Ref payment - $payment_sc_static->id=$obj->pid; - $payment_sc_static->ref=$obj->pid; + $payment_sc_static->id = $obj->pid; + $payment_sc_static->ref = $obj->pid; print '\n"; // Date payment print ''; @@ -204,18 +204,18 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; print $obj->num_payment.''; // Account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''; - print ''; // A total here has no sense + print ''; // A total here has no sense print ''; print ''; print ''; - if (! empty($conf->banque->enabled)) print ''; + if (!empty($conf->banque->enabled)) print ''; print '"; print ""; } @@ -249,38 +249,38 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) } // VAT -if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { print "
    "; $tva = new Tva($db); - print load_fiche_titre($langs->trans("VATPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("VATPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.fk_bank,"; - $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; - $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id"; - $sql.= " WHERE pv.entity IN (".getEntity("tax").")"; + $sql .= " pct.code as payment_code,"; + $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as pv"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id"; + $sql .= " WHERE pv.entity IN (".getEntity("tax").")"; if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } - if (preg_match('/^pv\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^pv\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print '
    '.dol_print_date($date, 'day').''; - $socialcontrib->id=$obj->rowid; - $socialcontrib->ref=$obj->label; - $socialcontrib->label=$obj->label; + $socialcontrib->id = $obj->rowid; + $socialcontrib->ref = $obj->label; + $socialcontrib->label = $obj->label; print $socialcontrib->getNomUrl(1, '20'); print ''.price($obj->total).''.$payment_sc_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; if ($obj->fk_bank > 0) { //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id=$obj->bid; - $accountstatic->ref=$obj->bref; - $accountstatic->number=$obj->bnumber; - $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->accountancy_journal=$obj->accountancy_journal; - $accountstatic->label=$obj->blabel; + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); } else print ' '; @@ -233,11 +233,11 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $i++; } print '
    '.$langs->trans("Total").'   '.price($totalpaye)."
    '; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder); @@ -289,10 +289,10 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pv.rowid", "", $param, '', $sortfield, $sortorder); 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); + 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, 'class="right"', $sortfield, $sortorder); print "\n"; - $var=1; + $var = 1; while ($i < $num) { $obj = $db->fetch_object($result); @@ -308,8 +308,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print '"; // Ref payment - $tva_static->id=$obj->rowid; - $tva_static->ref=$obj->rowid; + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; print '\n"; // Date @@ -321,18 +321,18 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print $obj->num_payment.''; // Account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print '"; print ''; // Who print ""; print ''; // Date @@ -397,8 +397,8 @@ elseif ($id) } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
    '.price($obj->amount)."'.$tva_static->getNomUrl(1)."'; if ($obj->fk_bank > 0) { //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id=$obj->bid; - $accountstatic->ref=$obj->bref; - $accountstatic->number=$obj->bnumber; - $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->accountancy_journal=$obj->accountancy_journal; - $accountstatic->label=$obj->blabel; + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); } else print ' '; @@ -365,55 +365,55 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) } // Localtax -if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") +if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { - $j=1; - $numlt=3; + $j = 1; + $numlt = 3; } -elseif($mysoc->localtax1_assuj=="1") +elseif ($mysoc->localtax1_assuj == "1") { - $j=1; - $numlt=2; + $j = 1; + $numlt = 2; } -elseif($mysoc->localtax2_assuj=="1") +elseif ($mysoc->localtax2_assuj == "1") { - $j=2; - $numlt=3; + $j = 2; + $numlt = 3; } else { - $j=0; - $numlt=0; + $j = 0; + $numlt = 0; } -while($j<$numlt) +while ($j < $numlt) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { print "
    "; $tva = new Tva($db); - print load_fiche_titre($langs->transcountry(($j==1?"LT1Payments":"LT2Payments"), $mysoc->country_code).($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->transcountry(($j == 1 ? "LT1Payments" : "LT2Payments"), $mysoc->country_code).($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp"; - $sql.= " FROM ".MAIN_DB_PREFIX."localtax as pv"; - $sql.= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j ; + $sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv"; + $sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j; if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } - if (preg_match('/^pv/', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^pv/', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print ''; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="120"', $sortfield, $sortorder); @@ -435,8 +435,8 @@ while($j<$numlt) print "\n"; // Ref payment - $tva_static->id=$obj->rowid; - $tva_static->ref=$obj->rowid; + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; print '\n"; print '\n"; @@ -462,39 +462,39 @@ while($j<$numlt) // Payment Salary -if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) +if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { $sal = new PaymentSalary($db); print "
    "; - print load_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("SalariesPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, s.fk_bank, u.salary as current_salary,"; - $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id"; - $sql.= " , ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE s.entity IN (".getEntity('user').")"; - $sql.= " AND u.rowid = s.fk_user"; + $sql .= " pct.code as payment_code,"; + $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id"; + $sql .= " , ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE s.entity IN (".getEntity('user').")"; + $sql .= " AND u.rowid = s.fk_user"; if ($year > 0) { - $sql.= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')"; + $sql .= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')"; } - if (preg_match('/^s\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^s\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print '
    ".$obj->label."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dp), 'day')."
    '; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "s.dateep", "", $param, 'width="140px"', $sortfield, $sortorder); @@ -502,7 +502,7 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.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); + 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"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; @@ -520,8 +520,8 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) print "\n"; // Ref payment - $sal_static->id=$obj->rowid; - $sal_static->ref=$obj->rowid; + $sal_static->id = $obj->rowid; + $sal_static->ref = $obj->rowid; print '\n"; // Date @@ -533,18 +533,18 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) print $obj->num_payment.''; // Account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print '"; print ''; // Km - print ''; + print ''; // Company print ""; @@ -300,8 +300,8 @@ if ($action == 'create') } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
    ".$obj->label."'.$sal_static->getNomUrl(1)."'; if ($obj->fk_bank > 0) { //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id=$obj->bid; - $accountstatic->ref=$obj->bref; - $accountstatic->number=$obj->bnumber; - $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->accountancy_journal=$obj->accountancy_journal; - $accountstatic->label=$obj->blabel; + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); } else print ' '; diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 488a5a86cf7..5f469a2cef6 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -29,7 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/trip.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -40,7 +40,7 @@ $langs->load("trips"); // Security check $id = GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'deplacement', $id, ''); $action = GETPOST('action', 'alpha'); @@ -49,16 +49,16 @@ $confirm = GETPOST('confirm', 'alpha'); $object = new Deplacement($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('tripsandexpensescard','globalcard')); +$hookmanager->initHooks(array('tripsandexpensescard', 'globalcard')); -$permissionnote=$user->rights->deplacement->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->deplacement->creer; // Used by the include of actions_setnotes.inc.php /* * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once if ($action == 'validate' && $user->rights->deplacement->creer) { @@ -68,7 +68,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer) $result = $object->setStatut(1); if ($result > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else @@ -86,7 +86,7 @@ elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer) $result = $object->setStatut(2); if ($result > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else @@ -98,7 +98,7 @@ elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer) elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer) { - $result=$object->delete($id); + $result = $object->delete($id); if ($result >= 0) { header("Location: index.php"); @@ -112,20 +112,20 @@ elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->depla elseif ($action == 'add' && $user->rights->deplacement->creer) { - if (! GETPOST('cancel', 'alpha')) + if (!GETPOST('cancel', 'alpha')) { - $error=0; + $error = 0; $object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount + $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount $object->type = GETPOST('type', 'alpha'); - $object->socid = GETPOST('socid', 'int'); - $object->fk_user = GETPOST('fk_user', 'int'); - $object->note_private = GETPOST('note_private', 'alpha'); + $object->socid = GETPOST('socid', 'int'); + $object->fk_user = GETPOST('fk_user', 'int'); + $object->note_private = GETPOST('note_private', 'alpha'); $object->note_public = GETPOST('note_public', 'alpha'); $object->statut = 0; - if (! $object->date) + if (!$object->date) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $error++; @@ -135,30 +135,30 @@ elseif ($action == 'add' && $user->rights->deplacement->creer) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); $error++; } - if (! ($object->fk_user > 0)) + if (!($object->fk_user > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Person")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $id = $object->create($user); if ($id > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); - $action='create'; + $action = 'create'; } } else { - $action='create'; + $action = 'create'; } } else @@ -171,23 +171,23 @@ elseif ($action == 'add' && $user->rights->deplacement->creer) // Update record elseif ($action == 'update' && $user->rights->deplacement->creer) { - if (! GETPOST('cancel', 'alpha')) + if (!GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); $object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount + $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount $object->type = GETPOST('type', 'alpha'); - $object->socid = GETPOST('socid', 'int'); - $object->fk_user = GETPOST('fk_user', 'int'); - $object->note_private = GETPOST('note_private', 'alpha'); - $object->note_public = GETPOST('note_public', 'alpha'); + $object->socid = GETPOST('socid', 'int'); + $object->fk_user = GETPOST('fk_user', 'int'); + $object->note_private = GETPOST('note_private', 'alpha'); + $object->note_public = GETPOST('note_public', 'alpha'); $result = $object->update($user); if ($result > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else @@ -197,7 +197,7 @@ elseif ($action == 'update' && $user->rights->deplacement->creer) } else { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } } @@ -206,22 +206,22 @@ elseif ($action == 'update' && $user->rights->deplacement->creer) elseif ($action == 'classin' && $user->rights->deplacement->creer) { $object->fetch($id); - $result=$object->setProject(GETPOST('projectid', 'int')); + $result = $object->setProject(GETPOST('projectid', 'int')); if ($result < 0) dol_print_error($db, $object->error); } // Set fields elseif ($action == 'setdated' && $user->rights->deplacement->creer) { - $dated=dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int')); + $dated = dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int')); $object->fetch($id); - $result=$object->setValueFrom('dated', $dated, '', '', 'date', '', $user, 'DEPLACEMENT_MODIFY'); + $result = $object->setValueFrom('dated', $dated, '', '', 'date', '', $user, 'DEPLACEMENT_MODIFY'); if ($result < 0) dol_print_error($db, $object->error); } elseif ($action == 'setkm' && $user->rights->deplacement->creer) { $object->fetch($id); - $result=$object->setValueFrom('km', GETPOST('km', 'int'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY'); + $result = $object->setValueFrom('km', GETPOST('km', 'int'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY'); if ($result < 0) dol_print_error($db, $object->error); } @@ -246,7 +246,7 @@ if ($action == 'create') $datec = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - print '' . "\n"; + print ''."\n"; print ''; print ''; @@ -264,11 +264,11 @@ if ($action == 'create') print "
    '.$langs->trans("Date").''; - print $form->selectDate($datec?$datec:-1, '', '', '', '', 'add', 1, 1); + print $form->selectDate($datec ? $datec : -1, '', '', '', '', 'add', 1, 1); print '
    '.$langs->trans("FeesKilometersOrAmout").'
    '.$langs->trans("FeesKilometersOrAmout").'
    '; @@ -334,7 +334,7 @@ elseif ($id) $soc->fetch($object->socid); } - print '' . "\n"; + print ''."\n"; print ''; print ''; print ''; @@ -350,13 +350,13 @@ elseif ($id) // Type print "
    '.$langs->trans("Type").''; - $form->select_type_fees(GETPOST('type', 'int')?GETPOST('type', 'int'):$object->type, 'type', 0); + $form->select_type_fees(GETPOST('type', 'int') ?GETPOST('type', 'int') : $object->type, 'type', 0); print '
    '.$langs->trans("Person").''; - print $form->select_dolusers(GETPOST('fk_user', 'int')?GETPOST('fk_user', 'int'):$object->fk_user, 'fk_user', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print $form->select_dolusers(GETPOST('fk_user', 'int') ?GETPOST('fk_user', 'int') : $object->fk_user, 'fk_user', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print '
    '; @@ -428,7 +428,7 @@ elseif ($id) print ''; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; // Ref print ''; @@ -472,7 +472,7 @@ elseif ($id) print ''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load('projects'); print ''; @@ -505,8 +505,8 @@ elseif ($id) print ''; // Other attributes - $parameters=array('socid'=>$object->id); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('socid'=>$object->id); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print "
    '.$langs->trans("Ref").''; @@ -446,7 +446,7 @@ elseif ($id) // Who print '
    '.$langs->trans("Person").''; - $userfee=new User($db); + $userfee = new User($db); $userfee->fetch($object->fk_user); print $userfee->getNomUrl(1); print '
    '.$langs->trans("Status").''.$object->getLibStatut(4).'

    "; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index e13693e7411..e5139b061aa 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -34,14 +34,14 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (! empty($conf->projet->enabled)) { - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; //include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; } -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page $langs->loadLangs(array('bills', 'compta', 'admin', 'other', 'products')); @@ -52,29 +52,29 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoicetemplatelist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search // Security check -$id=(GETPOST('facid', 'int')?GETPOST('facid', 'int'):GETPOST('id', 'int')); -$lineid=GETPOST('lineid', 'int'); -$ref=GETPOST('ref', 'alpha'); -if ($user->socid) $socid=$user->socid; +$id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); +$lineid = GETPOST('lineid', 'int'); +$ref = GETPOST('ref', 'alpha'); +if ($user->socid) $socid = $user->socid; $objecttype = 'facture_rec'; if ($action == "create" || $action == "add") $objecttype = ''; $result = restrictedArea($user, 'facture', $id, $objecttype); $projectid = GETPOST('projectid', 'int'); -$year_date_when=GETPOST('year_date_when'); -$month_date_when=GETPOST('month_date_when'); +$year_date_when = GETPOST('year_date_when'); +$month_date_when = GETPOST('month_date_when'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$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) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (! $sortorder) $sortorder='DESC'; -if (! $sortfield) $sortfield='f.titre'; +if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) $sortfield = 'f.titre'; $pageprev = $page - 1; $pagenext = $page + 1; @@ -89,26 +89,26 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add') } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('invoicereccard','globalcard')); +$hookmanager->initHooks(array('invoicereccard', 'globalcard')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $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 +$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 $usercanread = $user->rights->facture->lire; $usercancreate = $user->rights->facture->creer; $usercanissuepayment = $user->rights->facture->paiement; $usercandelete = $user->rights->facture->supprimer; -$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate))); +$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate))); $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send); $usercanreopen = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->reopen); -$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))); +$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate))); $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); $usercancreatemargin = $user->rights->margins->creer; @@ -122,8 +122,8 @@ $now = dol_now(); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -131,17 +131,17 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if (GETPOST('cancel', 'alpha')) $action=''; + if (GETPOST('cancel', 'alpha')) $action = ''; // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Set note - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Mass actions /*$objectclass='MyObject'; @@ -154,20 +154,20 @@ if (empty($reshook)) // Create predefined invoice if ($action == 'add') { - if (! GETPOST('titre', 'nohtml')) + if (!GETPOST('titre', 'nohtml')) { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Title")), null, 'errors'); $action = "create"; $error++; } - $frequency=GETPOST('frequency', 'int'); - $reyear=GETPOST('reyear', 'int'); - $remonth=GETPOST('remonth', 'int'); - $reday=GETPOST('reday', 'int'); - $rehour=GETPOST('rehour', 'int'); - $remin=GETPOST('remin', 'int'); - $nb_gen_max=GETPOST('nb_gen_max', 'int'); + $frequency = GETPOST('frequency', 'int'); + $reyear = GETPOST('reyear', 'int'); + $remonth = GETPOST('remonth', 'int'); + $reday = GETPOST('reday', 'int'); + $rehour = GETPOST('rehour', 'int'); + $remin = GETPOST('remin', 'int'); + $nb_gen_max = GETPOST('nb_gen_max', 'int'); //if (empty($nb_gen_max)) $nb_gen_max =0; if (GETPOST('frequency', 'int')) @@ -186,12 +186,12 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { - $object->titre = GETPOST('titre', 'nohtml'); // deprecated + $object->titre = GETPOST('titre', 'nohtml'); // deprecated $object->title = GETPOST('titre', 'nohtml'); $object->note_private = GETPOST('note_private', 'none'); - $object->note_public = GETPOST('note_public', 'none'); + $object->note_public = GETPOST('note_public', 'none'); $object->modelpdf = GETPOST('modelpdf', 'alpha'); $object->usenewprice = GETPOST('usenewprice', 'alpha'); @@ -213,7 +213,7 @@ if (empty($reshook)) $srcObject->fetchObjectLinked(); - if (! empty($srcObject->linkedObjectsIds['contrat'])) + if (!empty($srcObject->linkedObjectsIds['contrat'])) { $contractidid = reset($srcObject->linkedObjectsIds['contrat']); @@ -231,7 +231,7 @@ if (empty($reshook)) $result = $object->create($user, $oldinvoice->id); if ($result > 0) { - $result=$oldinvoice->delete($user, 1); + $result = $oldinvoice->delete($user, 1); if ($result < 0) { $error++; @@ -246,11 +246,11 @@ if (empty($reshook)) $action = "create"; } - if (! $error) + if (!$error) { $db->commit(); - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $object->id); + header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$object->id); exit; } else @@ -269,7 +269,7 @@ if (empty($reshook)) { $object->delete($user); - header("Location: " . DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php'); + header("Location: ".DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php'); exit; } @@ -278,12 +278,12 @@ if (empty($reshook)) // Set condition if ($action == 'setconditions' && $user->rights->facture->creer) { - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } // Set mode elseif ($action == 'setmode' && $user->rights->facture->creer) { - $result=$object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); } // Set project elseif ($action == 'classin' && $user->rights->facture->creer) @@ -294,10 +294,10 @@ if (empty($reshook)) elseif ($action == 'setref' && $user->rights->facture->creer) { //var_dump(GETPOST('ref', 'alpha'));exit; - $result=$object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); + $result = $object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); if ($result > 0) { - $object->titre = GETPOST('ref', 'alpha'); // deprecated + $object->titre = GETPOST('ref', 'alpha'); // deprecated $object->title = GETPOST('ref', 'alpha'); $object->ref = $object->title; } @@ -306,7 +306,7 @@ if (empty($reshook)) // Set bank account elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } // Set frequency and unit frequency elseif ($action == 'setfrequency' && $user->rights->facture->creer) @@ -353,7 +353,7 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $db->commit(); } @@ -377,7 +377,7 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $db->commit(); } @@ -405,19 +405,19 @@ if (empty($reshook)) $db->begin(); - $line=new FactureLigneRec($db); + $line = new FactureLigneRec($db); // For triggers $line->id = $lineid; if ($line->delete($user) > 0) { - $result=$object->update_price(1); + $result = $object->update_price(1); if ($result > 0) { $db->commit(); - $object->fetch($object->id); // Reload lines + $object->fetch($object->id); // Reload lines } else { @@ -439,7 +439,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { $result = $object->insertExtraFields('BILLREC_MODIFY'); if ($result < 0) @@ -457,24 +457,24 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $predef = ''; + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); $price_ht = GETPOST('price_ht'); $price_ht_devise = GETPOST('multicurrency_price_ht'); $prod_entry_mode = GETPOST('prod_entry_mode', 'alpha'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); + $qty = GETPOST('qty'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -484,38 +484,38 @@ if (empty($reshook)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key . $predef]); + unset($_POST["options_".$key.$predef]); } } if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error ++; + $error++; } if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); - $error ++; + $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + if ($prod_entry_mode == 'free' && empty($idprod) && (!($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); - $error ++; + $error++; } if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error ++; + $error++; } if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); - $error ++; + $error++; } if ($qty < 0) { $langs->load("errors"); setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); - $error ++; + $error++; } - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) + if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { $ret = $object->fetch($id); if ($ret < 0) { @@ -525,8 +525,8 @@ if (empty($reshook)) $ret = $object->fetch_thirdparty(); // Clean parameters - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); // Define special_code for special lines @@ -538,7 +538,7 @@ if (empty($reshook)) // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit // Replaces $fk_unit with the product's - if (! empty($idprod)) + if (!empty($idprod)) { $prod = new Product($db); $prod->fetch($idprod); @@ -548,7 +548,7 @@ if (empty($reshook)) // Update if prices fields are defined $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp']. $pqp = (GETPOST('pbq', 'int') ? GETPOST('pbq', 'int') : 0); @@ -566,7 +566,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? - if (! empty($price_ht)) + if (!empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); @@ -588,7 +588,7 @@ if (empty($reshook)) $desc = ''; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; @@ -596,13 +596,13 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'aZ09'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; } else { @@ -612,27 +612,27 @@ if (empty($reshook)) $desc = dol_concatdesc($desc, $product_desc); // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) { $tmptxt = '('; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'alpha')) $newlang = GETPOST('lang_id', 'alpha'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - if (! empty($prod->customcode)) $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $outputlangs, 0); + if (!empty($prod->customcode)) $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; + if (!empty($prod->country_code)) $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $outputlangs, 0); } else { - if (! empty($prod->customcode)) $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + if (!empty($prod->customcode)) $tmptxt .= $langs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; + if (!empty($prod->country_code)) $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $langs, 0); } $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); @@ -647,19 +647,19 @@ if (empty($reshook)) $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $desc = $product_desc; $type = GETPOST('type'); - $fk_unit= GETPOST('units', 'alpha'); + $fk_unit = GETPOST('units', 'alpha'); } $date_start_fill = GETPOST('date_start_fill', 'int'); $date_end_fill = GETPOST('date_end_fill', 'int'); // Margin - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value + $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); + $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we must keep this value // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); @@ -669,7 +669,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if ($usercanproductignorepricemin && (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { + if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); setEventMessages($mesg, null, 'errors'); } @@ -698,7 +698,7 @@ if (empty($reshook)) $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); }*/ - $object->fetch($object->id); // Reload lines + $object->fetch($object->id); // Reload lines unset($_POST['prod_entry_mode']); @@ -749,9 +749,9 @@ if (empty($reshook)) } } - elseif ($action == 'updateline' && $usercancreate && ! GETPOST('cancel', 'alpha')) + elseif ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) { - if (! $object->fetch($id) > 0) dol_print_error($db); + if (!$object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); // Clean parameters @@ -776,7 +776,7 @@ if (empty($reshook)) // Add buying price $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value + $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -785,8 +785,8 @@ if (empty($reshook)) $objectline = new FactureLigneRec($db); if ($objectline->fetch(GETPOST('lineid', 'int'))) { - $objectline->array_options=$array_options; - $result=$objectline->insertExtraFields(); + $objectline->array_options = $array_options; + $result = $objectline->insertExtraFields(); if ($result < 0) { setEventMessages($langs->trans('Error').$result, null, 'errors'); @@ -801,13 +801,13 @@ if (empty($reshook)) // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } // Define special_code for special lines - $special_code=GETPOST('special_code', 'int'); - if (! GETPOST('qty', 'alpha')) $special_code=3; + $special_code = GETPOST('special_code', 'int'); + if (!GETPOST('qty', 'alpha')) $special_code = 3; /*$line = new FactureLigne($db); $line->fetch(GETPOST('lineid')); @@ -823,7 +823,7 @@ if (empty($reshook)) // Check minimum price $productid = GETPOST('productid', 'int'); - if (! empty($productid)) + if (!empty($productid)) { $product = new Product($db); $product->fetch($productid); @@ -831,16 +831,16 @@ if (empty($reshook)) $type = $product->type; $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) $price_min = $product->multiprices_min[$object->thirdparty->price_level]; $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); // Check price is not lower than minimum (check is done only for standard or replacement invoices) - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); - $error ++; + $error++; } } else { $type = GETPOST('type', 'int'); @@ -849,20 +849,20 @@ if (empty($reshook)) // Check parameters if (GETPOST('type', 'int') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error ++; + $error++; } } if ($qty < 0) { $langs->load("errors"); setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); - $error ++; + $error++; } $date_start_fill = GETPOST('date_start_fill', 'int'); $date_end_fill = GETPOST('date_end_fill', 'int'); // Update line - if (! $error) + if (!$error) { $result = $object->updateline( GETPOST('lineid'), @@ -910,7 +910,7 @@ if (empty($reshook)) $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); }*/ - $object->fetch($object->id); // Reload lines + $object->fetch($object->id); // Reload lines unset($_POST['qty']); unset($_POST['type']); @@ -965,13 +965,13 @@ llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-factur $form = new Form($db); $formother = new FormOther($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $companystatic = new Societe($db); $invoicerectmp = new FactureRec($db); $now = dol_now(); -$tmparray=dol_getdate($now); -$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day +$tmparray = dol_getdate($now); +$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day /* @@ -981,7 +981,7 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("CreateRepeatableInvoice"), '', 'invoicing'); - $object = new Facture($db); // Source invoice + $object = new Facture($db); // Source invoice $product_static = new Product($db); if ($object->fetch($id, $ref) > 0) @@ -995,8 +995,8 @@ if ($action == 'create') dol_fiche_head(null, '', '', 0); - $rowspan=4; - if (! empty($conf->projet->enabled)) $rowspan++; + $rowspan = 4; + if (!empty($conf->projet->enabled)) $rowspan++; if ($object->fk_account > 0) $rowspan++; print ''; @@ -1012,8 +1012,8 @@ if ($action == 'create') print ''; print ''; - $note_public=GETPOST('note_public', 'none')?GETPOST('note_public', 'none'):$object->note_public; - $note_private=GETPOST('note_private', 'none')?GETPOST('note_private', 'none'):$object->note_private; + $note_public = GETPOST('note_public', 'none') ?GETPOST('note_public', 'none') : $object->note_public; + $note_private = GETPOST('note_private', 'none') ?GETPOST('note_private', 'none') : $object->note_private; // Help of substitution key $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); @@ -1025,18 +1025,18 @@ if ($action == 'create') $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%B').')'; $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')'; $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y').')'; - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')'; + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')'; $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y').')'; // Only on template invoices $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')'; $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency), 'dayhour').')'; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
    '; - foreach($substitutionarray as $key => $val) + foreach ($substitutionarray as $key => $val) { - $htmltext.=$key.' = '.$langs->trans($val).'
    '; + $htmltext .= $key.' = '.$langs->trans($val).'
    '; } - $htmltext.='
    '; + $htmltext .= ''; // Public note print ''; @@ -1075,13 +1075,13 @@ if ($action == 'create') print ""; // Project - if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) + if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) { - $projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project; + $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project; $langs->load('projects'); - print ''; } @@ -1095,7 +1095,7 @@ if ($action == 'create') // Model pdf print ""; @@ -1115,7 +1115,7 @@ if ($action == 'create') // Frequency + unit print '"; // Date next run @@ -1131,15 +1131,15 @@ if ($action == 'create') // Auto validate the invoice print ""; // Auto generate document - if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) + if (!empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) { print ""; } @@ -1167,12 +1167,12 @@ if ($action == 'create') print '
    '; print '
    '.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1, 'customer').'
    ' . $langs->trans('Project') . ''; + print '
    '.$langs->trans('Project').''; $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); - print '   thirdparty->id.(!empty($id)?'&id='.$id:'')).'">' . $langs->trans("AddProject") . ''; + print '   thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.$langs->trans("AddProject").''; print '
    ".$langs->trans('Model').""; - include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; $list = ModelePDFFactures::liste_modeles($db); print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); print "
    '.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency')).""; - print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m')); + print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency') ?GETPOST('unit_frequency') : 'm')); print "
    ".$langs->trans("StatusOfGeneratedInvoices").""; - $select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated')); + $select = array('0'=>$langs->trans('BillStatusDraft'), '1'=>$langs->trans('BillStatusValidated')); print $form->selectarray('auto_validate', $select, GETPOST('auto_validate')); print "
    ".$langs->trans("StatusOfGeneratedDocuments").""; - $select = array('0'=>$langs->trans('DoNotGenerateDoc'),'1'=>$langs->trans('AutoGenerateDoc')); + $select = array('0'=>$langs->trans('DoNotGenerateDoc'), '1'=>$langs->trans('AutoGenerateDoc')); print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf')); print "
    '; // Show object lines - if (! empty($object->lines)) + if (!empty($object->lines)) { - $disableedit=1; - $disablemove=1; - $disableremove=1; - $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice + $disableedit = 1; + $disablemove = 1; + $disableremove = 1; + $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } print "
    \n"; @@ -1193,7 +1193,7 @@ if ($action == 'create') print '
    '; print '     '; - print ''; + print ''; print '
    '; print "\n"; } @@ -1213,12 +1213,12 @@ else // Confirmation de la suppression d'une ligne produit if ($action == 'ask_deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); } // Confirm delete of repeatable invoice if ($action == 'ask_deleteinvoice') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); } print $formconfirm; @@ -1226,58 +1226,58 @@ else $author = new User($db); $author->fetch($object->user_author); - $head=invoice_rec_prepare_head($object); + $head = invoice_rec_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill'); // Add a div + dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill'); // Add a div // Recurring invoice content - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref=''; - if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); - else $morehtmlref.= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); + $morehtmlref = ''; + if ($action != 'editref') $morehtmlref .= $form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); + else $morehtmlref .= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); - $morehtmlref.='
    '; + $morehtmlref .= '
    '; // Ref customer //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
    '.$langs->trans('Project') . ' '; + $morehtmlref .= '
    '.$langs->trans('Project').' '; if ($user->rights->facture->creer) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
    '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; dol_banner_tab($object, 'ref', $linkback, 1, 'titre', 'none', $morehtmlref, '', 0, '', $morehtmlright); @@ -1299,13 +1299,13 @@ else // Amount Local Taxes if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 { - print '
    ' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
    ' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
    '.$langs->trans("AmountTTC").''.price($object->total_ttc, '', $langs, 1, -1, -1, $conf->currency).'id . '">' . img_edit($langs->trans('SetConditions'), 1) . 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
    '; print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE) { if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none'); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none'); } } else { print ' '; @@ -1342,7 +1342,7 @@ else print $langs->trans('PaymentMode'); print ''; if ($action != 'editmode' && $user->rights->facture->creer) - print 'id . '">' . img_edit($langs->trans('SetMode'), 1) . ''; + print 'id.'">'.img_edit($langs->trans('SetMode'), 1).''; print ''; print ''; if ($action == 'editmode') @@ -1356,7 +1356,7 @@ else print ''; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print ''; @@ -1364,13 +1364,13 @@ else print ''; - if ($usercancreate && $action != 'editmulticurrencycode' && ! empty($object->brouillon)) { - print ''; + if ($usercancreate && $action != 'editmulticurrencycode' && !empty($object->brouillon)) { + print ''; } print '
    '; print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
    '; print ''; - $htmlname = (($usercancreate && $action == 'editmulticurrencycode')?'multicurrency_code':'none'); - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, $htmlname); + $htmlname = (($usercancreate && $action == 'editmulticurrencycode') ? 'multicurrency_code' : 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, $htmlname); print ''; // Multicurrency rate @@ -1381,19 +1381,19 @@ else print ''; - if ($usercancreate && $action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print ''; + if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print ''; } print '
    '; print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
    '; print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - if($action == 'actualizemulticurrencyrate') { + if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, ($usercancreate?'multicurrency_tx':'none'), $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, ($usercancreate ? 'multicurrency_tx' : 'none'), $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '
            '; print ''.$langs->trans("ActualizeCurrency").''; print '
    '; @@ -1404,8 +1404,8 @@ else } // Help of substitution key - $dateexample=dol_now(); - if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when; + $dateexample = dol_now(); + if (!empty($object->frequency) && !empty($object->date_when)) $dateexample = $object->date_when; $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); @@ -1416,18 +1416,18 @@ else $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')'; $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')'; $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')'; - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')'; + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')'; $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')'; // Only on template invoices - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')'; - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when?$object->date_when:dol_now()), $object->frequency, $object->unit_frequency), 'dayhour').')'; + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when ? $object->date_when : dol_now()), 'dayhour').')'; + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when ? $object->date_when : dol_now()), $object->frequency, $object->unit_frequency), 'dayhour').')'; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
    '; - foreach($substitutionarray as $key => $val) + foreach ($substitutionarray as $key => $val) { - $htmltext.=$key.' = '.$langs->trans($val).'
    '; + $htmltext .= $key.' = '.$langs->trans($val).'
    '; } - $htmltext.='
    '; + $htmltext .= ''; // Note public print ''; @@ -1480,11 +1480,11 @@ else print ''; if ($action == 'editmodelpdf') { - include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; $list = array(); $models = ModelePDFFactures::liste_modeles($db); foreach ($models as $k => $model) { - $list[] = str_replace(':', '|', $k) . ':' . $model; + $list[] = str_replace(':', '|', $k).':'.$model; } $select = 'select;'.implode(',', $list); print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->modelpdf, $object, $user->rights->facture->creer, $select); @@ -1498,7 +1498,7 @@ else // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; @@ -1524,17 +1524,17 @@ else print $langs->trans('Frequency'); print ''; if ($action != 'editfrequency' && $user->rights->facture->creer) - print 'id . '">' . img_edit($langs->trans('Edit'), 1) . ''; + print 'id.'">'.img_edit($langs->trans('Edit'), 1).''; print ''; print ''; if ($action == 'editfrequency') { - print '
    '; + print ''; print ''; print ''; print ''; print ''; print ''; print '
    '; - print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m')); + print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency ? $object->unit_frequency : 'm')); print '
    '; @@ -1568,9 +1568,9 @@ else print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached'); } //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour')); - if (! $object->isMaxNbGenReached()) + if (!$object->isMaxNbGenReached()) { - if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); + if (!$object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); } else { @@ -1592,7 +1592,7 @@ else print ''; if ($action == 'nb_gen_max' || $object->frequency > 0) { - print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max?$object->nb_gen_max:'', $object, $user->rights->facture->creer); + print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->rights->facture->creer); } else { @@ -1615,7 +1615,7 @@ else } print ''; // Auto generate documents - if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) + if (!empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) { print ''; print ''; @@ -1656,7 +1656,7 @@ else // Nb of generation already done print ''.$langs->trans("NbOfGenerationDone").''; print ''; - print $object->nb_gen_done?$object->nb_gen_done:'0'; + print $object->nb_gen_done ? $object->nb_gen_done : '0'; print ''; print ''; @@ -1681,25 +1681,25 @@ else // Lines - print '
    - - + print ' + + - + '; - if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
    '; print ''; // Show object lines - if (! empty($object->lines)) + if (!empty($object->lines)) { //$disableedit=1; //$disablemove=1; - $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice + $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } // Form to add new line @@ -1708,7 +1708,7 @@ else if ($action != 'editline') { // Add free products/services - $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice + $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1732,7 +1732,7 @@ else { if ($user->rights->facture->creer) { - if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) + if (!empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) { print ''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 10f54e538a2..48cd8e81054 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -37,38 +37,38 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture-rec.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmargin.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -if (! empty($conf->commande->enabled)) - require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->commande->enabled)) + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } -if (! empty($conf->accounting->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +if (!empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; } // Load translation files required by the page -$langs->loadLangs(array('bills','companies','compta','products','banks','main','withdrawals')); -if (! empty($conf->incoterm->enabled)) $langs->load('incoterm'); -if (! empty($conf->margin->enabled)) $langs->load('margins'); +$langs->loadLangs(array('bills', 'companies', 'compta', 'products', 'banks', 'main', 'withdrawals')); +if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); +if (!empty($conf->margin->enabled)) $langs->load('margins'); $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0); @@ -86,37 +86,37 @@ $search_montant_ht = GETPOST('search_montant_ht', 'alpha'); $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility -$fac_rec=GETPOST('fac_rec', 'int'); +$fac_rec = GETPOST('fac_rec', 'int'); // PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Nombre de ligne pour choix de produit/service predefinis $NBLINES = 4; -$usehm = (! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0); +$usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0); $object = new Facture($db); $extrafields = new ExtraFields($db); // Load object -if ($id > 0 || ! empty($ref)) { +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('invoicecard','globalcard')); +$hookmanager->initHooks(array('invoicecard', 'globalcard')); $usercanread = $user->rights->facture->lire; $usercancreate = $user->rights->facture->creer; $usercanissuepayment = $user->rights->facture->paiement; $usercandelete = $user->rights->facture->supprimer; -$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate))); +$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate))); $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send); $usercanreopen = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->reopen); -$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))); +$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate))); $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); $usercancreatemargin = $user->rights->margins->creer; @@ -124,12 +124,12 @@ $usercanreadallmargin = $user->rights->margins->liretous; $usercancreatewithdrarequest = $user->rights->prelevement->bons->creer; $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php +$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdonw.inc.php $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php // Security check -$fieldid = (! empty($ref) ? 'ref' : 'rowid'); +$fieldid = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) $socid = $user->socid; $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft); @@ -146,30 +146,30 @@ if (empty($reshook)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; } include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); $objectutil->socid = $socid; $result = $objectutil->createFromClone($user, $id); if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); + header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); exit(); } else { $langs->load("errors"); @@ -185,7 +185,7 @@ if (empty($reshook)) if ($object->statut == Facture::STATUS_CLOSED || ($object->statut == Facture::STATUS_ABANDONED && ($object->close_code != 'replaced' || $object->getIdReplacingInvoice() == 0)) || ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted $result = $object->set_unpaid($user); if ($result > 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit(); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -207,18 +207,18 @@ if (empty($reshook)) $qualified_for_stock_change = $object->hasProductsOrServices(1); } - $isErasable=$object->is_erasable(); + $isErasable = $object->is_erasable(); if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1)) { $result = $object->delete($user, 0, $idwarehouse); if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php?restore_lastsearch_values=1'); + header('Location: '.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'); exit(); } else { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } } @@ -234,11 +234,11 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); @@ -248,7 +248,7 @@ if (empty($reshook)) $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } if ($result >= 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit(); } } else { @@ -294,7 +294,7 @@ if (empty($reshook)) $object->fetch($id); $object->setValueFrom('fk_soc', $socid, '', null, 'int', '', $user, 'BILL_MODIFY'); - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit(); } @@ -365,7 +365,7 @@ if (empty($reshook)) header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate'); exit; } - $object->date=$date; + $object->date = $date; $new_date_lim_reglement = $object->calculate_date_lim_reglement(); if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; @@ -377,7 +377,7 @@ if (empty($reshook)) { $object->fetch($id); $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); - $object->date_pointoftax=$date_pointoftax; + $object->date_pointoftax = $date_pointoftax; $result = $object->update($user); if ($result < 0) dol_print_error($db, $object->error); } @@ -430,7 +430,7 @@ if (empty($reshook)) // bank account elseif ($action == 'setbankaccount' && $usercancreate) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } elseif ($action == 'setremisepercent' && $usercancreate) @@ -444,7 +444,7 @@ if (empty($reshook)) // POST[remise_id] or POST[remise_id_for_payment] // We use the credit to reduce amount of invoice - if (! empty($_POST["remise_id"])) { + if (!empty($_POST["remise_id"])) { $ret = $object->fetch($id); if ($ret > 0) { $result = $object->insert_discount($_POST["remise_id"]); @@ -456,9 +456,9 @@ if (empty($reshook)) } } // We use the credit to reduce remain to pay - if (! empty($_POST["remise_id_for_payment"])) + if (!empty($_POST["remise_id_for_payment"])) { - require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($db); $discount->fetch($_POST["remise_id_for_payment"]); @@ -471,7 +471,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorDiscountLargerThanRemainToPaySplitItBefore"), null, 'errors'); } - if (! $error) + if (!$error) { $result = $discount->link_to_invoice(0, $id); if ($result < 0) { @@ -486,7 +486,7 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -514,12 +514,12 @@ if (empty($reshook)) // Check parameters // Check for mandatory fields in thirdparty (defined into setup) - $array_to_check=array('IDPROF1','IDPROF2','IDPROF3','IDPROF4','IDPROF5','IDPROF6','EMAIL'); - foreach($array_to_check as $key) + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); + foreach ($array_to_check as $key) { - $keymin=strtolower($key); - $i=(int) preg_replace('/[^0-9]/', '', $key); - $vallabel=$object->thirdparty->$keymin; + $keymin = strtolower($key); + $i = (int) preg_replace('/[^0-9]/', '', $key); + $vallabel = $object->thirdparty->$keymin; if ($i > 0) { @@ -528,8 +528,8 @@ if (empty($reshook)) // Check for mandatory prof id (but only if country is other than ours) if ($mysoc->country_id > 0 && $object->thirdparty->country_id == $mysoc->country_id) { - $idprof_mandatory ='SOCIETE_'.$key.'_INVOICE_MANDATORY'; - if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) + $idprof_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; + if (!$vallabel && !empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); $error++; @@ -544,7 +544,7 @@ if (empty($reshook)) if ($key == 'EMAIL') { // Check for mandatory - if (! empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && ! isValidEMail($object->thirdparty->email)) + if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($object->thirdparty->email)) { $langs->load("errors"); $error++; @@ -555,15 +555,15 @@ if (empty($reshook)) } // Check for mandatory fields in invoice - $array_to_check=array('REF_CUSTOMER'=>'RefCustomer'); - foreach($array_to_check as $key => $val) + $array_to_check = array('REF_CUSTOMER'=>'RefCustomer'); + foreach ($array_to_check as $key => $val) { - $keymin=strtolower($key); - $vallabel=$object->$keymin; + $keymin = strtolower($key); + $vallabel = $object->$keymin; // Check for mandatory - $keymandatory ='INVOICE_'.$key.'_MANDATORY_FOR_VALIDATION'; - if (! $vallabel && ! empty($conf->global->$keymandatory)) + $keymandatory = 'INVOICE_'.$key.'_MANDATORY_FOR_VALIDATION'; + if (!$vallabel && !empty($conf->global->$keymandatory)) { $langs->load("errors"); $error++; @@ -572,7 +572,7 @@ if (empty($reshook)) } // Check for warehouse - if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { @@ -583,7 +583,7 @@ if (empty($reshook)) if ($qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == - 1) { + if (!$idwarehouse || $idwarehouse == - 1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action = ''; @@ -591,7 +591,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $result = $object->validate($user, '', $idwarehouse); if ($result >= 0) @@ -603,12 +603,12 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -632,7 +632,7 @@ if (empty($reshook)) $object->fetch_thirdparty(); // Check parameters - if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { @@ -643,7 +643,7 @@ if (empty($reshook)) if ($qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == - 1) { + if (!$idwarehouse || $idwarehouse == - 1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action = ''; @@ -651,11 +651,11 @@ if (empty($reshook)) } } - if (! $error) { + if (!$error) { // On verifie si la facture a des paiements $sql = 'SELECT pf.amount'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf'; - $sql .= ' WHERE pf.fk_facture = ' . $object->id; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf'; + $sql .= ' WHERE pf.fk_facture = '.$object->id; $result = $db->query($sql); if ($result) { @@ -665,7 +665,7 @@ if (empty($reshook)) while ($i < $num) { $objp = $db->fetch_object($result); $totalpaye += $objp->amount; - $i ++; + $i++; } } else { dol_print_error($db, ''); @@ -679,10 +679,10 @@ if (empty($reshook)) // On verifie si aucun paiement n'a ete effectue if ($ventilExportCompta == 0) { - if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) + if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) { - $result=$object->setDraft($user, $idwarehouse); - if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); + $result = $object->setDraft($user, $idwarehouse); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -691,12 +691,12 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -711,7 +711,7 @@ if (empty($reshook)) { $object->fetch($id); $result = $object->set_paid($user); - if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Classif "paid partialy" elseif ($action == 'confirm_paid_partially' && $confirm == 'yes' && $usercanissuepayment) { @@ -720,7 +720,7 @@ if (empty($reshook)) $close_note = GETPOST("close_note", 'none'); if ($close_code) { $result = $object->set_paid($user, $close_code, $close_note); - if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors'); } @@ -731,7 +731,7 @@ if (empty($reshook)) $close_note = GETPOST("close_note", 'none'); if ($close_code) { $result = $object->set_canceled($user, $close_code, $close_note); - if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors'); } @@ -745,12 +745,12 @@ if (empty($reshook)) //$object->fetch_lines(); // Already done into fetch // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) - $discountcheck=new DiscountAbsolute($db); - $result=$discountcheck->fetch(0, $object->id); + $discountcheck = new DiscountAbsolute($db); + $result = $discountcheck->fetch(0, $object->id); - $canconvert=0; - if ($object->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) - if (($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) + $canconvert = 0; + if ($object->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) + if (($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) if ($canconvert) { $db->begin(); @@ -796,13 +796,13 @@ if (empty($reshook)) // Total payments $sql = 'SELECT SUM(pf.amount) as total_paiements'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql.= ' WHERE pf.fk_facture = '.$object->id; - $sql.= ' AND pf.fk_paiement = p.rowid'; - $sql.= ' AND p.entity IN ('.getEntity('invoice').')'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql .= ' WHERE pf.fk_facture = '.$object->id; + $sql .= ' AND pf.fk_paiement = p.rowid'; + $sql .= ' AND p.entity IN ('.getEntity('invoice').')'; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); $res = $db->fetch_object($resql); $total_paiements = $res->total_paiements; @@ -811,8 +811,8 @@ if (empty($reshook)) $total_creditnote_and_deposit = 0; $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; - $sql .= " WHERE fk_facture = " . $object->id; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_facture = ".$object->id; $resql = $db->query($sql); if (!empty($resql)) { while ($obj = $db->fetch_object($resql)) { @@ -853,7 +853,7 @@ if (empty($reshook)) if (empty($error)) { - if($object->type != Facture::TYPE_DEPOSIT) { + if ($object->type != Facture::TYPE_DEPOSIT) { // Classe facture $result = $object->set_paid($user); if ($result >= 0) @@ -884,9 +884,9 @@ if (empty($reshook)) if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0) { $paiement = new Paiement($db); - $result=$paiement->fetch(GETPOST('paiement_id')); + $result = $paiement->fetch(GETPOST('paiement_id')); if ($result > 0) { - $result=$paiement->delete(); // If fetch ok and found + $result = $paiement->delete(); // If fetch ok and found header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); } if ($result < 0) { @@ -920,32 +920,32 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); } - if (! ($_POST['fac_replacement'] > 0)) { + if (!($_POST['fac_replacement'] > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), null, 'errors'); } $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); - if (! $error) { + if (!$error) { // This is a replacement invoice $result = $object->fetch($_POST['fac_replacement']); $object->fetch_thirdparty(); - $object->date = $dateinvoice; - $object->date_pointoftax = $date_pointoftax; + $object->date = $dateinvoice; + $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'none')); // We do not copy the private note $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = $_POST['cond_reglement_id']; $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->fk_account = GETPOST('fk_account', 'int'); + $object->fk_account = GETPOST('fk_account', 'int'); $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); @@ -965,7 +965,7 @@ if (empty($reshook)) if ($_POST['type'] == Facture::TYPE_CREDIT_NOTE) { $sourceinvoice = GETPOST('fac_avoir'); - if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) + if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors'); @@ -980,27 +980,27 @@ if (empty($reshook)) $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); - if (! $error) + if (!$error) { if (!empty($originentity)) { $object->entity = $originentity; } - $object->socid = GETPOST('socid', 'int'); - $object->number = $_POST['ref']; - $object->date = $dateinvoice; - $object->date_pointoftax = $date_pointoftax; + $object->socid = GETPOST('socid', 'int'); + $object->number = $_POST['ref']; + $object->date = $dateinvoice; + $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'none')); // We do not copy the private note $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = 0; $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->fk_account = GETPOST('fk_account', 'int'); + $object->fk_account = GETPOST('fk_account', 'int'); $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); @@ -1010,24 +1010,24 @@ if (empty($reshook)) $object->type = Facture::TYPE_CREDIT_NOTE; $facture_source = new Facture($db); // fetch origin object - if ($facture_source->fetch($object->fk_facture_source)>0) + if ($facture_source->fetch($object->fk_facture_source) > 0) { if ($facture_source->type == Facture::TYPE_SITUATION) { - $object->situation_counter = $facture_source->situation_counter; + $object->situation_counter = $facture_source->situation_counter; $object->situation_cycle_ref = $facture_source->situation_cycle_ref; $facture_source->fetchPreviousNextSituationInvoice(); } } $id = $object->create($user); - if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) + if (GETPOST('invoiceAvoirWithLines', 'int') == 1 && $id > 0) { if (!empty($facture_source->lines)) { $fk_parent_line = 0; - foreach($facture_source->lines as $line) + foreach ($facture_source->lines as $line) { // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($line, 'fetch_optionals')) { @@ -1043,21 +1043,21 @@ if (empty($reshook)) - if($facture_source->type == Facture::TYPE_SITUATION) + if ($facture_source->type == Facture::TYPE_SITUATION) { $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id $line->fk_prev_id = $line->id; // Credit note line need to be linked to the situation invoice it is create from - if(!empty($facture_source->tab_previous_situation_invoice)) + if (!empty($facture_source->tab_previous_situation_invoice)) { // search the last invoice in cycle $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; $searchPreviousInvoice = true; - while( $searchPreviousInvoice ) + while ($searchPreviousInvoice) { - if($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) { - $searchPreviousInvoice=false; // find, exit; + $searchPreviousInvoice = false; // find, exit; break; } else @@ -1068,9 +1068,9 @@ if (empty($reshook)) $maxPrevSituationPercent = 0; - foreach($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { - if($prevLine->id == $source_fk_prev_id) + if ($prevLine->id == $source_fk_prev_id) { $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); @@ -1081,8 +1081,8 @@ if (empty($reshook)) $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; - $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; + $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; } @@ -1097,7 +1097,7 @@ if (empty($reshook)) $line->fk_parent_line = $fk_parent_line; $line->subprice = -$line->subprice; // invert price for object - $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here + $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here $line->total_ht = -$line->total_ht; $line->total_tva = -$line->total_tva; $line->total_ttc = -$line->total_ttc; @@ -1109,7 +1109,7 @@ if (empty($reshook)) $line->multicurrency_total_tva = -$line->multicurrency_total_tva; $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; - $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked + $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked $object->lines[] = $line; // insert new line in current object @@ -1123,9 +1123,9 @@ if (empty($reshook)) } } - if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) + if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) { - if ($facture_source->fetch($object->fk_facture_source)>0) + if ($facture_source->fetch($object->fk_facture_source) > 0) { $totalpaye = $facture_source->getSommePaiement(); $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); @@ -1137,12 +1137,12 @@ if (empty($reshook)) } // Add link between credit note and origin - if(! empty($object->fk_facture_source)) { + if (!empty($object->fk_facture_source)) { $facture_source->fetch($object->fk_facture_source); $facture_source->fetchObjectLinked(); - if(! empty($facture_source->linkedObjectsIds)) { - foreach($facture_source->linkedObjectsIds as $sourcetype => $TIds) { + if (!empty($facture_source->linkedObjectsIds)) { + foreach ($facture_source->linkedObjectsIds as $sourcetype => $TIds) { $object->add_object_linked($sourcetype, current($TIds)); } } @@ -1162,26 +1162,26 @@ if (empty($reshook)) $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); - if (! $error) + if (!$error) { - $object->socid = GETPOST('socid', 'int'); + $object->socid = GETPOST('socid', 'int'); $object->type = $_POST['type']; $object->number = $_POST['ref']; $object->date = $dateinvoice; $object->date_pointoftax = $date_pointoftax; - $object->note_public = trim(GETPOST('note_public', 'none')); + $object->note_public = trim(GETPOST('note_public', 'none')); $object->note_private = trim(GETPOST('note_private', 'none')); $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; + $object->ref_int = $_POST['ref_int']; $object->modelpdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); + $object->fk_project = $_POST['projectid']; + $object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']); $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->fk_account = GETPOST('fk_account', 'int'); - $object->amount = $_POST['amount']; + $object->fk_account = GETPOST('fk_account', 'int'); + $object->amount = $_POST['amount']; $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); @@ -1189,7 +1189,7 @@ if (empty($reshook)) // Source facture $object->fac_rec = GETPOST('fac_rec', 'int'); - $id = $object->create($user); // This include recopy of links from recurring invoice and recurring invoice lines + $id = $object->create($user); // This include recopy of links from recurring invoice and recurring invoice lines } } @@ -1211,27 +1211,27 @@ if (empty($reshook)) $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); - if (! $error) + if (!$error) { // Si facture standard - $object->socid = GETPOST('socid', 'int'); + $object->socid = GETPOST('socid', 'int'); $object->type = GETPOST('type'); - $object->number = $_POST['ref']; + $object->number = $_POST['ref']; $object->date = $dateinvoice; - $object->date_pointoftax = $date_pointoftax; + $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'none')); - $object->note_private = trim(GETPOST('note_private', 'none')); + $object->note_private = trim(GETPOST('note_private', 'none')); $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); + $object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']); $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->fk_account = GETPOST('fk_account', 'int'); - $object->amount = $_POST['amount']; + $object->fk_account = GETPOST('fk_account', 'int'); + $object->amount = $_POST['amount']; $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); @@ -1243,11 +1243,11 @@ if (empty($reshook)) $object->situation_cycle_ref = $object->newCycle(); - $object->retained_warranty = GETPOST('retained_warranty', 'int'); - $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + $object->retained_warranty = GETPOST('retained_warranty', 'int'); + $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); - if(!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)){ + if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); } $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); @@ -1256,7 +1256,7 @@ if (empty($reshook)) $object->fetch_thirdparty(); // If creation from another object of another module (Example: origin=propal, originid=1) - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -1291,32 +1291,32 @@ if (empty($reshook)) // link with order if it is a shipping invoice if ($object->origin == 'shipping') { - require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $exp = new Expedition($db); $exp->fetch($object->origin_id); $exp->fetchObjectLinked(); if (is_array($exp->linkedObjectsIds['commande']) && count($exp->linkedObjectsIds['commande']) > 0) { - foreach ($exp->linkedObjectsIds['commande'] as $key => $value){ + foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $object->linked_objects['commande'] = $value; } } } - if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) + if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } - $id = $object->create($user); // This include class to add_object_linked() and add add_contact() + $id = $object->create($user); // This include class to add_object_linked() and add add_contact() if ($id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines or deposit lines"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines or deposit lines"); $result = $srcobject->fetch($object->origin_id); // If deposit invoice @@ -1334,8 +1334,8 @@ if (empty($reshook)) $TTotalByTva = array(); foreach ($srcobject->lines as &$line) { - if(! empty($line->special_code)) continue; - $TTotalByTva[$line->tva_tx] += $line->total_ttc ; + if (!empty($line->special_code)) continue; + $TTotalByTva[$line->tva_tx] += $line->total_ttc; } foreach ($TTotalByTva as $tva => &$total) @@ -1358,20 +1358,20 @@ if (empty($reshook)) { $totalamount = 0; $lines = $srcobject->lines; - $numlines=count($lines); - for ($i=0; $i<$numlines; $i++) + $numlines = count($lines); + for ($i = 0; $i < $numlines; $i++) { - $qualified=1; - if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option - if (! empty($lines[$i]->special_code)) $qualified=0; // We discard special_code (frais port, ecotaxe, option, ...) - if ($qualified){ + $qualified = 1; + if (empty($lines[$i]->qty)) $qualified = 0; // We discard qty=0, it is an option + if (!empty($lines[$i]->special_code)) $qualified = 0; // We discard special_code (frais port, ecotaxe, option, ...) + if ($qualified) { $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? $tva_tx = $lines[$i]->tva_tx; $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $valuedeposit) / 100; } } - if($totalamount == 0) { + if ($totalamount == 0) { $amountdeposit[0] = 0; } } else { @@ -1386,33 +1386,33 @@ if (empty($reshook)) { if (empty($amount)) continue; - $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); + $arraylist = array('amount' => 'FixAmount', 'variable' => 'VarAmount'); $descline = $langs->trans('Deposit'); //$descline.= ' - '.$langs->trans($arraylist[$typeamount]); - if ($typeamount=='amount') { - $descline.= ' ('. price($valuedeposit, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).')'; - } elseif ($typeamount=='variable') { - $descline.= ' ('. $valuedeposit.'%)'; + if ($typeamount == 'amount') { + $descline .= ' ('.price($valuedeposit, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).')'; + } elseif ($typeamount == 'variable') { + $descline .= ' ('.$valuedeposit.'%)'; } - $descline.= ' - '.$srcobject->ref; + $descline .= ' - '.$srcobject->ref; $result = $object->addline( $descline, - $amount, // subprice - 1, // quantity - $tva, // vat rate - 0, // localtax1_tx - 0, // localtax2_tx - (empty($conf->global->INVOICE_PRODUCTID_DEPOSIT)?0:$conf->global->INVOICE_PRODUCTID_DEPOSIT), // fk_product - 0, // remise_percent - 0, // date_start - 0, // date_end + $amount, // subprice + 1, // quantity + $tva, // vat rate + 0, // localtax1_tx + 0, // localtax2_tx + (empty($conf->global->INVOICE_PRODUCTID_DEPOSIT) ? 0 : $conf->global->INVOICE_PRODUCTID_DEPOSIT), // fk_product + 0, // remise_percent + 0, // date_start + 0, // date_end 0, - $lines[$i]->info_bits, // info_bits + $lines[$i]->info_bits, // info_bits 0, 'HT', 0, - 0, // product_type + 0, // product_type 1, $lines[$i]->special_code, $object->origin, @@ -1444,19 +1444,19 @@ if (empty($reshook)) $lines = $srcobject->lines; } - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) + $fk_parent_line = 0; + $num = count($lines); + for ($i = 0; $i < $num; $i++) { // Don't add lines with qty 0 when coming from a shipment including all order lines - if($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; + if ($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; // Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines) - if (! isset($conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5'; + if (!isset($conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5'; if ($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) continue; - $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); - $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); - if ($object->situation_counter == 1) $lines[$i]->situation_percent = 0; + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); + $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle); + if ($object->situation_counter == 1) $lines[$i]->situation_percent = 0; if ($lines[$i]->subprice < 0 && empty($conf->global->INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN)) { @@ -1511,7 +1511,7 @@ if (empty($reshook)) } $tva_tx = $lines[$i]->tva_tx; - if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; // View third's localtaxes for NOW and do not use value from origin. // TODO Is this really what we want ? Yes if source if template invoice but what if proposal or order ? @@ -1590,13 +1590,13 @@ if (empty($reshook)) { // If some invoice's lines coming from page $id = $object->create($user); - for ($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST['idprod' . $i]) { + for ($i = 1; $i <= $NBLINES; $i++) { + if ($_POST['idprod'.$i]) { $product = new Product($db); - $product->fetch($_POST['idprod' . $i]); - $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); - $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); - $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit); + $product->fetch($_POST['idprod'.$i]); + $startday = dol_mktime(12, 0, 0, $_POST['date_start'.$i.'month'], $_POST['date_start'.$i.'day'], $_POST['date_start'.$i.'year']); + $endday = dol_mktime(12, 0, 0, $_POST['date_end'.$i.'month'], $_POST['date_end'.$i.'day'], $_POST['date_end'.$i.'year']); + $result = $object->addline($product->description, $product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit); } } } @@ -1637,13 +1637,13 @@ if (empty($reshook)) $line->origin_id = $line->id; $line->fk_prev_id = $line->id; $line->fetch_optionals($line->id); - $line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note + $line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note // Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée if ($line->fk_remise_except) { - $discount=new DiscountAbsolute($line->db); - $result=$discount->fetch($line->fk_remise_except); + $discount = new DiscountAbsolute($line->db); + $result = $discount->fetch($line->fk_remise_except); if ($result > 0) { // Check if discount not already affected to another invoice @@ -1694,7 +1694,7 @@ if (empty($reshook)) } // End of object creation, we show it - if ($id > 0 && ! $error) + if ($id > 0 && !$error) { $db->commit(); @@ -1705,19 +1705,19 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit(); } else @@ -1737,24 +1737,24 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc', 'none')?GETPOST('dp_desc', 'none'):''); + $predef = ''; + $product_desc = (GETPOST('dp_desc', 'none') ?GETPOST('dp_desc', 'none') : ''); $price_ht = GETPOST('price_ht'); $price_ht_devise = GETPOST('multicurrency_price_ht'); $prod_entry_mode = GETPOST('prod_entry_mode', 'alpha'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); + $qty = GETPOST('qty'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -1763,7 +1763,7 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key . $predef]); + unset($_POST["options_".$key.$predef]); } } @@ -1773,7 +1773,7 @@ if (empty($reshook)) } if (!$prod_entry_mode) { - if (GETPOST('type') < 0 && ! GETPOST('search_idprod')) + if (GETPOST('type') < 0 && !GETPOST('search_idprod')) { setEventMessages($langs->trans('ErrorChooseBetweenFreeEntryOrPredefinedProduct'), null, 'errors'); $error++; @@ -1827,7 +1827,7 @@ if (empty($reshook)) } } - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { $ret = $object->fetch($id); if ($ret < 0) { dol_print_error($db, $object->error); @@ -1836,8 +1836,8 @@ if (empty($reshook)) $ret = $object->fetch_thirdparty(); // Clean parameters - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); // Define special_code for special lines @@ -1849,7 +1849,7 @@ if (empty($reshook)) // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit // Replaces $fk_unit with the product's - if (! empty($idprod)) + if (!empty($idprod)) { $prod = new Product($db); $prod->fetch($idprod); @@ -1872,7 +1872,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? - if (! empty($price_ht)) + if (!empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); @@ -1894,56 +1894,56 @@ if (empty($reshook)) $desc = ''; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; } else { $desc = $prod->description; } - if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc= $product_desc; + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) { $tmptxt = '('; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'alpha')) $newlang = GETPOST('lang_id', 'alpha'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - if (! empty($prod->customcode)) - $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) + if (!empty($prod->customcode)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $outputlangs, 0); + if (!empty($prod->country_code)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $outputlangs, 0); } else { - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) + if (!empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + if (!empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $langs, 0); } $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); @@ -1956,17 +1956,17 @@ if (empty($reshook)) $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $desc = $product_desc; $type = GETPOST('type'); - $fk_unit= GETPOST('units', 'alpha'); + $fk_unit = GETPOST('units', 'alpha'); $pu_ht_devise = price2num($price_ht_devise, 'MU'); } // Margin - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value + $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); + $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we must keep this value // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); @@ -1976,7 +1976,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if ($usercanproductignorepricemin && (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { + if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); setEventMessages($mesg, null, 'errors'); } else { @@ -1992,12 +1992,12 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -2048,9 +2048,9 @@ if (empty($reshook)) } } - elseif ($action == 'updateline' && $usercancreate && ! GETPOST('cancel', 'alpha')) + elseif ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) { - if (! $object->fetch($id) > 0) dol_print_error($db); + if (!$object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); // Clean parameters @@ -2075,7 +2075,7 @@ if (empty($reshook)) // Add buying price $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value + $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -2084,22 +2084,22 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } // Define special_code for special lines - $special_code=GETPOST('special_code'); - if (! GETPOST('qty')) $special_code=3; + $special_code = GETPOST('special_code'); + if (!GETPOST('qty')) $special_code = 3; $line = new FactureLigne($db); $line->fetch(GETPOST('lineid')); $percent = $line->get_prev_progress($object->id); - if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref>0) + if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref > 0) { // in case of situation credit note - if(GETPOST('progress') >= 0 ) + if (GETPOST('progress') >= 0) { $mesg = $langs->trans("CantBeNullOrPositive"); setEventMessages($mesg, null, 'warnings'); @@ -2116,7 +2116,7 @@ if (empty($reshook)) } elseif (GETPOST('progress') < $percent) { - $mesg = '
    ' . $langs->trans("CantBeLessThanMinPercent") . '
    '; + $mesg = '
    '.$langs->trans("CantBeLessThanMinPercent").'
    '; setEventMessages($mesg, null, 'warnings'); $error++; $result = -1; @@ -2124,7 +2124,7 @@ if (empty($reshook)) // Check minimum price $productid = GETPOST('productid', 'int'); - if (! empty($productid)) + if (!empty($productid)) { $product = new Product($db); $product->fetch($productid); @@ -2132,7 +2132,7 @@ if (empty($reshook)) $type = $product->type; $price_min = $product->price_min; - if ((! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && ! empty($object->thirdparty->price_level)) + if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) $price_min = $product->multiprices_min [$object->thirdparty->price_level]; $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); @@ -2174,7 +2174,7 @@ if (empty($reshook)) // Update line - if (! $error) { + if (!$error) { if (empty($usercancreatemargin)) { foreach ($object->lines as &$line) @@ -2202,7 +2202,7 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); @@ -2263,7 +2263,7 @@ if (empty($reshook)) { $percent = $line->get_prev_progress($object->id); if (floatval($all_progress) < floatval($percent)) { - $mesg = $langs->trans("Line") . ' ' . $i . ' '. $line->ref .' : ' . $langs->trans("CantBeLessThanMinPercent"); + $mesg = $langs->trans("Line").' '.$i.' '.$line->ref.' : '.$langs->trans("CantBeLessThanMinPercent"); setEventMessages($mesg, null, 'warnings'); $result = -1; } else @@ -2273,7 +2273,7 @@ if (empty($reshook)) } elseif ($action == 'updateline' && $usercancreate && $_POST['cancel'] == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // Pour reaffichage de la fiche en cours d'edition exit(); } @@ -2292,7 +2292,7 @@ if (empty($reshook)) { $outingError = 0; $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle - if($newCycle > 1) + if ($newCycle > 1) { // Search credit notes $lastCycle = $object->situation_cycle_ref; @@ -2301,12 +2301,12 @@ if (empty($reshook)) if (count($object->tab_next_situation_invoice) > 0) { foreach ($object->tab_next_situation_invoice as $next_invoice) { - if($next_invoice->type == Facture::TYPE_CREDIT_NOTE + if ($next_invoice->type == Facture::TYPE_CREDIT_NOTE && $next_invoice->situation_counter == $object->situation_counter && $next_invoice->fk_facture_source == $object->id ) { - $linkedCreditNotesList[] = $next_invoice->id ; + $linkedCreditNotesList[] = $next_invoice->id; } } } @@ -2314,38 +2314,38 @@ if (empty($reshook)) $object->situation_cycle_ref = $newCycle; $object->situation_counter = 1; $object->situation_final = 0; - if($object->update($user) > 0) + if ($object->update($user) > 0) { $errors = 0; - if(count($linkedCreditNotesList) > 0) + if (count($linkedCreditNotesList) > 0) { // now, credit note must follow $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; - $sql.= ' SET situation_cycle_ref='.$newCycle; - $sql.= ' , situation_final=0'; - $sql.= ' , situation_counter='.$object->situation_counter; - $sql.= ' WHERE rowid IN ('.implode(',', $linkedCreditNotesList).')'; + $sql .= ' SET situation_cycle_ref='.$newCycle; + $sql .= ' , situation_final=0'; + $sql .= ' , situation_counter='.$object->situation_counter; + $sql .= ' WHERE rowid IN ('.implode(',', $linkedCreditNotesList).')'; - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) $errors++; // Change each progression persent on each lines - foreach($object->lines as $line) + foreach ($object->lines as $line) { // no traitement for special product - if ($line->product_type == 9 ) continue; + if ($line->product_type == 9) continue; - if(!empty($object->tab_previous_situation_invoice)) + if (!empty($object->tab_previous_situation_invoice)) { // search the last invoice in cycle $lineIndex = count($object->tab_previous_situation_invoice) - 1; $searchPreviousInvoice = true; - while( $searchPreviousInvoice ) + while ($searchPreviousInvoice) { - if($object->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + if ($object->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) { - $searchPreviousInvoice=false; // find, exit; + $searchPreviousInvoice = false; // find, exit; break; } else @@ -2356,9 +2356,9 @@ if (empty($reshook)) $maxPrevSituationPercent = 0; - foreach($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + foreach ($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { - if($prevLine->id == $line->fk_prev_id) + if ($prevLine->id == $line->fk_prev_id) { $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); } @@ -2367,7 +2367,7 @@ if (empty($reshook)) $line->situation_percent = $line->situation_percent - $maxPrevSituationPercent; - if($line->update()<0) $errors++; + if ($line->update() < 0) $errors++; } } } @@ -2395,7 +2395,7 @@ if (empty($reshook)) } // add lines from objectlinked - elseif($action == 'import_lines_from_object' + elseif ($action == 'import_lines_from_object' && $usercancreate && $object->statut == Facture::STATUS_DRAFT && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) @@ -2404,14 +2404,14 @@ if (empty($reshook)) $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); - if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) { - if($fromElement == 'commande') + if ($fromElement == 'commande') { dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'OrderLine'; } - elseif($fromElement == 'propal') + elseif ($fromElement == 'propal') { dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'PropaleLigne'; @@ -2419,11 +2419,11 @@ if (empty($reshook)) $nextRang = count($object->lines) + 1; $importCount = 0; $error = 0; - foreach($importLines as $lineId) + foreach ($importLines as $lineId) { $lineId = intval($lineId); $originLine = new $lineClassName($db); - if(intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) { $originLine->fetch_optionals($lineId); $desc = $originLine->desc; @@ -2439,15 +2439,15 @@ if (empty($reshook)) $ventil = 0; $info_bits = $originLine->info_bits; $fk_remise_except = $originLine->fk_remise_except; - $price_base_type='HT'; - $pu_ttc=0; + $price_base_type = 'HT'; + $pu_ttc = 0; $type = $originLine->product_type; - $rang=$nextRang++; + $rang = $nextRang++; $special_code = $originLine->special_code; $origin = $originLine->element; $origin_id = $originLine->id; - $fk_parent_line=0; - $fk_fournprice=$originLine->fk_fournprice; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; $pa_ht = $originLine->pa_ht; $label = $originLine->label; $array_options = $originLine->array_options; @@ -2458,18 +2458,18 @@ if (empty($reshook)) $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit, $pu_ht_devise); - if($res > 0){ + if ($res > 0) { $importCount++; - }else{ + } else { $error++; } } - else{ + else { $error++; } } - if($error) + if ($error) { setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); } @@ -2480,16 +2480,16 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - if (empty($id)) $id=$facid; - $trigger_name='BILL_SENTBYMAIL'; - $paramname='id'; - $autocopy='MAIN_MAIL_AUTOCOPY_INVOICE_TO'; - $trackid='inv'.$object->id; + if (empty($id)) $id = $facid; + $trigger_name = 'BILL_SENTBYMAIL'; + $paramname = 'id'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_INVOICE_TO'; + $trackid = 'inv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc $upload_dir = $conf->facture->multidir_output[$object->entity]; - $permissiontoadd=$usercancreate; + $permissiontoadd = $usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -2500,7 +2500,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('BILL_MODIFY'); @@ -2515,7 +2515,7 @@ if (empty($reshook)) $action = 'edit_extras'; } - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { if ($action == 'addcontact') { $result = $object->fetch($id); @@ -2570,13 +2570,13 @@ $formother = new FormOther($db); $formfile = new FormFile($db); $formmargin = new FormMargin($db); $soc = new Societe($db); -$paymentstatic=new Paiement($db); +$paymentstatic = new Paiement($db); $bankaccountstatic = new Account($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $now = dol_now(); -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Card'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Card'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); @@ -2596,7 +2596,7 @@ if ($action == 'create') // Load objectsrc $remise_absolue = 0; - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -2620,7 +2620,7 @@ if ($action == 'create') } if (!$dateinvoice) { // Do not set 0 here (0 for a date is 1970) - $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); + $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice); } } else { // For compatibility @@ -2638,7 +2638,7 @@ if ($action == 'create') $element = $subelement = 'expedition'; } - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($db); @@ -2647,18 +2647,18 @@ if ($action == 'create') $objectsrc->fetch_lines(); $objectsrc->fetch_thirdparty(); - $projectid = (! empty($projectid) ? $projectid : $objectsrc->fk_project); - $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : (! empty($objectsrc->ref_customer) ? $objectsrc->ref_customer:'')); - $ref_int = (! empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); + $projectid = (!empty($projectid) ? $projectid : $objectsrc->fk_project); + $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : (!empty($objectsrc->ref_customer) ? $objectsrc->ref_customer : '')); + $ref_int = (!empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); // only if socid not filled else it's allready done upper if (empty($socid)) $soc = $objectsrc->thirdparty; - $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); + $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice); if ($element == 'expedition') { - $ref_client = (! empty($objectsrc->ref_customer)?$objectsrc->ref_customer:''); + $ref_client = (!empty($objectsrc->ref_customer) ? $objectsrc->ref_customer : ''); $elem = $subelem = $objectsrc->origin; $expeoriginid = $objectsrc->origin_id; @@ -2668,23 +2668,23 @@ if ($action == 'create') $expesrc = new $classname($db); $expesrc->fetch($expeoriginid); - $cond_reglement_id = (! empty($expesrc->cond_reglement_id)?$expesrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); - $mode_reglement_id = (! empty($expesrc->mode_reglement_id)?$expesrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $fk_account = (! empty($expesrc->fk_account)?$expesrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $remise_percent = (! empty($expesrc->remise_percent)?$expesrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (! empty($expesrc->remise_absolue)?$expesrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $cond_reglement_id = (!empty($expesrc->cond_reglement_id) ? $expesrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 1)); + $mode_reglement_id = (!empty($expesrc->mode_reglement_id) ? $expesrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $fk_account = (!empty($expesrc->fk_account) ? $expesrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $remise_percent = (!empty($expesrc->remise_percent) ? $expesrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); + $remise_absolue = (!empty($expesrc->remise_absolue) ? $expesrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); //Replicate extrafields $expesrc->fetch_optionals($expeoriginid); - $object->array_options=$expesrc->array_options; + $object->array_options = $expesrc->array_options; } else { - $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); - $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); if (!empty($conf->multicurrency->enabled)) { @@ -2705,18 +2705,18 @@ if ($action == 'create') $fk_account = $soc->fk_account; $remise_percent = $soc->remise_percent; $remise_absolue = 0; - $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); // Do not set 0 here (0 for a date is 1970) + $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice); // Do not set 0 here (0 for a date is 1970) if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } if (!empty($soc->id)) $absolute_discount = $soc->getAvailableDiscounts(); - $note_public = $object->getDefaultCreateValueFor('note_public', ((! empty($origin) && ! empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM))?$objectsrc->note_public:null)); - $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM))?$objectsrc->note_private:null)); + $note_public = $object->getDefaultCreateValueFor('note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_public : null)); + $note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_private : null)); - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; print ajax_combobox('fac_replacement'); print ajax_combobox('fac_avoir'); print ajax_combobox('situations'); @@ -2725,35 +2725,35 @@ if ($action == 'create') if ($origin == 'contrat') { $langs->load("admin"); - $text=$langs->trans("ToCreateARecurringInvoice"); - $text.=' '.$langs->trans("ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv("MenuFinancial"), $langs->transnoentitiesnoconv("BillsCustomers"), $langs->transnoentitiesnoconv("ListOfTemplates")); + $text = $langs->trans("ToCreateARecurringInvoice"); + $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv("MenuFinancial"), $langs->transnoentitiesnoconv("BillsCustomers"), $langs->transnoentitiesnoconv("ListOfTemplates")); if (empty($conf->global->INVOICE_DISABLE_AUTOMATIC_RECURRING_INVOICE)) { - $text.=' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); + $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); } print info_admin($text, 0, 0, 0).'
    '; } - print ''; - print ''; + print ''; + print ''; print ''; - if ($soc->id > 0) print '' . "\n"; + if ($soc->id > 0) print ''."\n"; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (!empty($currency_tx)) print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($currency_tx)) print ''; dol_fiche_head(''); print '
    '; // Ref - print ''; + print ''; - $exampletemplateinvoice=new FactureRec($db); + $exampletemplateinvoice = new FactureRec($db); $invoice_predefined = new FactureRec($db); if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) { @@ -2761,30 +2761,30 @@ if ($action == 'create') } // Thirdparty - if ($soc->id > 0 && (! GETPOST('fac_rec', 'int') || ! empty($invoice_predefined->frequency))) + if ($soc->id > 0 && (!GETPOST('fac_rec', 'int') || !empty($invoice_predefined->frequency))) { // If thirdparty known and not a predefined invoiced without a recurring rule - print ''; + print ''; print ''; - print '' . "\n"; + print ''."\n"; } else { - print ''; + print ''; print ''; - print '' . "\n"; + print ''."\n"; } // Overwrite some values if creation of invoice is from a predefined invoice @@ -2811,7 +2811,7 @@ if ($action == 'create') { $invoice_predefined->fetch(GETPOST('fac_rec', 'int')); - $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later + $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later if (empty($projectid)) $projectid = $invoice_predefined->fk_project; $cond_reglement_id = $invoice_predefined->cond_reglement_id; $mode_reglement_id = $invoice_predefined->mode_reglement_id; @@ -2819,12 +2819,12 @@ if ($action == 'create') $note_public = $invoice_predefined->note_public; $note_private = $invoice_predefined->note_private; - if (! empty($invoice_predefined->multicurrency_code)) $currency_code = $invoice_predefined->multicurrency_code; - if (! empty($invoice_predefined->multicurrency_tx)) $currency_tx = $invoice_predefined->multicurrency_tx; + if (!empty($invoice_predefined->multicurrency_code)) $currency_code = $invoice_predefined->multicurrency_code; + if (!empty($invoice_predefined->multicurrency_tx)) $currency_tx = $invoice_predefined->multicurrency_tx; $sql = 'SELECT r.rowid, r.titre as title, r.total_ttc'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as r'; - $sql .= ' WHERE r.fk_soc = ' . $invoice_predefined->socid; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as r'; + $sql .= ' WHERE r.fk_soc = '.$invoice_predefined->socid; $resql = $db->query($sql); if ($resql) @@ -2834,21 +2834,21 @@ if ($action == 'create') if ($num > 0) { - print '
    ' . $langs->trans('Ref') . '' . $langs->trans('Draft') . '
    '.$langs->trans('Ref').''.$langs->trans('Draft').'
    ' . $langs->trans('Customer') . '
    '.$langs->trans('Customer').''; print $soc->getNomUrl(1); - print ''; + print ''; // Outstanding Bill $arrayoutstandingbills = $soc->getOutstandingBills(); $outstandingBills = $arrayoutstandingbills['opened']; - print ' (' . $langs->trans('CurrentOutstandingBill') . ': '; + print ' ('.$langs->trans('CurrentOutstandingBill').': '; print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency); if ($soc->outstanding_limit != '') { if ($outstandingBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); - print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency); + print ' / '.price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency); } print ')'; print '
    ' . $langs->trans('Customer') . '
    '.$langs->trans('Customer').''; print $form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // Option to reload page to retrieve customer informations. Note, this clear other input @@ -2801,9 +2801,9 @@ if ($action == 'create') }); '; } - if (! GETPOST('fac_rec', 'int')) print ' '.$langs->trans("AddThirdParty").''; + if (!GETPOST('fac_rec', 'int')) print ' '.$langs->trans("AddThirdParty").''; print '
    ' . $langs->trans('CreateFromRepeatableInvoice') . ''; + print '
    '.$langs->trans('CreateFromRepeatableInvoice').''; //print ''; - print ''; // We may want to change the template to use print ''; while ($i < $num) { $objp = $db->fetch_object($resql); - print ''; - $i ++; + print '>'.$objp->title.' ('.price($objp->total_ttc).' '.$langs->trans("TTC").')'; + $i++; } print ''; // Option to reload page to retrieve customer informations. Note, this clear other input @@ -2874,25 +2874,25 @@ if ($action == 'create') } } - print '
    ' . $langs->trans('Type') . ''; + print '
    '.$langs->trans('Type').''; - print '
    ' . "\n"; + print '
    '."\n"; // Standard invoice print '
    '; - $tmp=' '; + $tmp = ' '; $tmp = $tmp.''; $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3); print $desc; print '
    '; - if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) + if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (!empty($originid)))) { // Deposit if (empty($conf->global->INVOICE_DISABLE_DEPOSIT)) { print '
    '; - $tmp=' '; + $tmp = ' '; print ''; - $text = ''; + $text = ''; $text .= ''; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); @@ -3003,29 +3003,29 @@ if ($action == 'create') } else { - if (! empty($conf->global->INVOICE_USE_SITUATION)) + if (!empty($conf->global->INVOICE_USE_SITUATION)) { print '
    '; - $tmp=' '; - $text = ' '; - $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); print $desc; print '
    '; print '
    '; - $tmp=' '; - $text = ' '; - $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); print $desc; print '
    '; } print '
    '; - $tmp=' '; - $text = ' '; - $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); print $desc; print '
    '; @@ -3040,7 +3040,7 @@ if ($action == 'create') if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) { // Show link for credit note - $facids=$facturestatic->list_qualified_avoir_invoices($soc->id); + $facids = $facturestatic->list_qualified_avoir_invoices($soc->id); if ($facids < 0) { dol_print_error($db, $facturestatic); @@ -3056,19 +3056,19 @@ if ($action == 'create') $newinvoice_static->type = $valarray ['type']; $newinvoice_static->paye = $valarray ['paye']; - $optionsav .= ''; } print '
    '; - $tmp='global->INVOICE_CREDIT_NOTE_STANDALONE)) || $invoice_predefined->id > 0) $tmp.=' disabled'; - $tmp.= '> '; + $tmp = 'global->INVOICE_CREDIT_NOTE_STANDALONE)) || $invoice_predefined->id > 0) $tmp .= ' disabled'; + $tmp .= '> '; // Show credit note options only if we checked credit note print ''; - $text = ' '; + $text = ' '; // $text.=''; $text .= ''; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; print '
    '; - print '    0 ? 'checked':'').' /> "; - print '
        0 ? 'checked':'').' /> "; + print '    0 ? 'checked' : '').' /> "; + print '
        0 ? 'checked' : '').' /> "; print '
    '; print '
    '; @@ -3111,20 +3111,20 @@ if ($action == 'create') else { print '
    '; - if (empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) $tmp=' '; - else $tmp=' '; - $text = ' '; - $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + if (empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) $tmp = ' '; + else $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; - print '
    ' . "\n"; + print '
    '."\n"; } } // Template invoice print '
    '; - $tmp=' '; - $text = ' '; + $tmp = ' '; + $text = ' '; //$text.= '('.$langs->trans("YouMustCreateStandardInvoiceFirst").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("YouMustCreateStandardInvoiceFirstDesc"), 1, 'help', '', 0, 3); print $desc; @@ -3133,16 +3133,16 @@ if ($action == 'create') print '
    '; - if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf + if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf { // Add auto select default document model - $listtType=array(Facture::TYPE_STANDARD,Facture::TYPE_REPLACEMENT,Facture::TYPE_CREDIT_NOTE,Facture::TYPE_DEPOSIT,Facture::TYPE_SITUATION); - $jsListType=''; + $listtType = array(Facture::TYPE_STANDARD, Facture::TYPE_REPLACEMENT, Facture::TYPE_CREDIT_NOTE, Facture::TYPE_DEPOSIT, Facture::TYPE_SITUATION); + $jsListType = ''; foreach ($listtType as $type) { $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; - $curent = !empty($conf->global->{$thisTypeConfName})?$conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; - $jsListType.=(!empty($jsListType)?',':'').'"'.$type.'":"'.$curent.'"'; + $curent = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; + $jsListType .= (!empty($jsListType) ? ',' : '').'"'.$type.'":"'.$curent.'"'; } print ' id . '" method="POST">'; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; //dol_fiche_head('', '', '', -1); - if ((! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { - print $langs->trans('UseMultipriceRules'). ' price_autogen ? 'checked' : '').'>

    '; + if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { + print $langs->trans('UseMultipriceRules').' price_autogen ? 'checked' : '').'>

    '; } print ''; @@ -1346,48 +1346,48 @@ if ($action == 'edit_price' && $object->getRights()->creer) print ''; - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { print ''; print ''; // VAT if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { print ''; } else { // This option is kept for backward compatibility but has no sense print ''; } // Selling price print ''; // Min price print ''; } @@ -1403,9 +1403,9 @@ if ($action == 'edit_price' && $object->getRights()->creer) //dol_fiche_end(); print '
    '; - print ''; + print ''; print '   '; - print '
    '; + print ''; print ''; } } @@ -1413,17 +1413,17 @@ if ($action == 'edit_price' && $object->getRights()->creer) // List of price changes - log historic (ordered by descending date) -if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_price') && ! in_array($action, array('edit_price','edit_vat'))) +if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_default_price') && !in_array($action, array('edit_price', 'edit_vat'))) { $sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.default_vat_code, p.recuperableonly, p.localtax1_tx, p.localtax1_type, p.localtax2_tx, p.localtax2_type,"; $sql .= " p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,"; $sql .= " p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price as p,"; - $sql .= " " . MAIN_DB_PREFIX . "user as u"; - $sql .= " WHERE fk_product = " . $object->id; - $sql .= " AND p.entity IN (" . getEntity('productprice') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price as p,"; + $sql .= " ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE fk_product = ".$object->id; + $sql .= " AND p.entity IN (".getEntity('productprice').")"; $sql .= " AND p.fk_user_author = u.rowid"; - if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES)) $sql .= " AND p.price_level = " . $soc->price_level; + if (!empty($socid) && !empty($conf->global->PRODUIT_MULTIPRICES)) $sql .= " AND p.price_level = ".$soc->price_level; $sql .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; // $sql .= $db->plimit(); @@ -1434,15 +1434,15 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ $num = $db->num_rows($result); - if (! $num) + if (!$num) { $db->free($result); // Il doit au moins y avoir la ligne de prix initial. // On l'ajoute donc pour remettre a niveau (pb vieilles versions) //$object->updatePrice($object->price, $object->price_base_type, $user, $object->tva_tx, $object->price_min); - if (! empty($conf->global->PRODUIT_MULTIPRICES)) { - $object->updatePrice($object->multiprices[1], $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1])?0:$object->multiprices_tva_tx[1]), $object->multiprices_min[1], 1); + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + $object->updatePrice($object->multiprices[1], $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1]) ? 0 : $object->multiprices_tva_tx[1]), $object->multiprices_min[1], 1); } else { $object->updatePrice($object->price, $object->price_base_type, $user, $object->tva_tx, $object->price_min); } @@ -1455,9 +1455,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ { // Default prices or // Log of previous customer prices - $backbutton='' . $langs->trans("Back") . ''; + $backbutton = ''.$langs->trans("Back").''; - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($langs->trans("DefaultPrice"), 0, $_SERVER["PHP_SELF"], '', '', '', $backbutton, 0, $num, 'title_accountancy.png'); + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($langs->trans("DefaultPrice"), 0, $_SERVER["PHP_SELF"], '', '', '', $backbutton, 0, $num, 'title_accountancy.png'); else print_barre_liste($langs->trans("PriceByCustomerLog"), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, $num, 'title_accountancy.png'); //if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($langs->trans("DefaultPrice"),'','','','','',$backbutton, 0, 0, 'title_accountancy.png'); //else print_barre_liste($langs->trans("PriceByCustomerLog"),'','','','','','', 0, 0, 'title_accountancy.png'); @@ -1466,31 +1466,31 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print '
    '; - print $form->textwithpicto($langs->trans('SellingPrice') . ' ' . $i, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); + print $form->textwithpicto($langs->trans('SellingPrice').' '.$i, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; - print $form->load_tva("tva_tx[" . $i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id, false, $object->type, false, 1); + print $form->load_tva("tva_tx[".$i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id, false, $object->type, false, 1); print ''; if ($object->multiprices_base_type [$i] == 'TTC') { - print ''; + print ''; } else { - print ''; + print ''; } - print ' '.$form->selectPriceBaseType($object->multiprices_base_type [$i], "multiprices_base_type[" . $i."]"); + print ' '.$form->selectPriceBaseType($object->multiprices_base_type [$i], "multiprices_base_type[".$i."]"); print ''; if ($object->multiprices_base_type [$i] == 'TTC') { - print ''; + print ''; } else { - print ''; + print ''; } - if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { print ''.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'
    '; print ''; - print ''; + print ''; - if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - print ''; + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + print ''; } - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - print ''; + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + print ''; } - print ''; + print ''; print $conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL; - if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) print ''; - print ''; - print ''; - if (! empty($conf->dynamicprices->enabled)) { - print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) print ''; + print ''; + print ''; + if (!empty($conf->dynamicprices->enabled)) { + print ''; } - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if ($user->rights->produit->supprimer) print ''; print ''; - $notfirstlineforlevel=array(); + $notfirstlineforlevel = array(); $i = 0; while ($i < $num) @@ -1499,17 +1499,17 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print ''; // Date - print ""; + print ""; // Price level - if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - print '"; + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + print '"; } // Price by quantity - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { $type = ($objp->price_by_qty == 1) ? 'PriceByQuantity' : 'Standard'; - print '"; + print '"; } print ''; print ''; - print '"; + print '"; } else { @@ -1562,7 +1562,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print price($objp->price_ttc); } print ""; - if (! empty($conf->dynamicprices->enabled)) { //Only if module is enabled + if (!empty($conf->dynamicprices->enabled)) { //Only if module is enabled print ''; } } @@ -1580,23 +1580,23 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print ''; // User - print ''; + print ''; // Action if ($user->rights->produit->supprimer) { - $candelete=0; - if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + $candelete = 0; + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - if (empty($notfirstlineforlevel[$objp->price_level])) $notfirstlineforlevel[$objp->price_level]=1; - else $candelete=1; + if (empty($notfirstlineforlevel[$objp->price_level])) $notfirstlineforlevel[$objp->price_level] = 1; + else $candelete = 1; } - elseif ($i > 0) $candelete=1; + elseif ($i > 0) $candelete = 1; print '
    ' . $langs->trans("AppliedPricesFrom") . ''.$langs->trans("AppliedPricesFrom").'' . $langs->trans("PriceLevel") . ''.$langs->trans("PriceLevel").'' . $langs->trans("Type") . ''.$langs->trans("Type").'' . $langs->trans("PriceBase") . ''.$langs->trans("PriceBase").'' . $langs->trans("DefaultTaxRate") . '' . $langs->trans("HT") . '' . $langs->trans("TTC") . '' . $langs->trans("PriceExpressionSelected") . ''.$langs->trans("DefaultTaxRate").''.$langs->trans("HT").''.$langs->trans("TTC").''.$langs->trans("PriceExpressionSelected").'' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '' . $langs->trans("ChangedBy") . ''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.$langs->trans("ChangedBy").' 
    " . dol_print_date($db->jdate($objp->dp), "dayhour") . "".dol_print_date($db->jdate($objp->dp), "dayhour")."' . $objp->price_level . "'.$objp->price_level."' . $langs->trans($type) . "'.$langs->trans($type)."'; @@ -1523,12 +1523,12 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print ''; if (empty($objp->price_by_qty)) { - $positiverates=''; - if (price2num($objp->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($objp->tva_tx); - if (price2num($objp->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax1_tx); - if (price2num($objp->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax2_tx); - if (empty($positiverates)) $positiverates='0'; - echo vatrate($positiverates.($objp->default_vat_code?' ('.$objp->default_vat_code.')':''), '%', $objp->tva_npr); + $positiverates = ''; + if (price2num($objp->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($objp->tva_tx); + if (price2num($objp->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($objp->localtax1_tx); + if (price2num($objp->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($objp->localtax2_tx); + if (empty($positiverates)) $positiverates = '0'; + echo vatrate($positiverates.($objp->default_vat_code ? ' ('.$objp->default_vat_code.')' : ''), '%', $objp->tva_npr); /* if ($objp->default_vat_code) { @@ -1541,14 +1541,14 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ } // Price - if (! empty($objp->fk_price_expression) && ! empty($conf->dynamicprices->enabled)) + if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) { $price_expression = new PriceExpression($db); $res = $price_expression->fetch($objp->fk_price_expression); $title = $price_expression->title; print '' . $title . "'.$title."' . img_object($langs->trans("ShowUser"), 'user') . ' ' . $objp->login . ''.img_object($langs->trans("ShowUser"), 'user').' '.$objp->login.''; if ($candelete) { - print 'id . '&lineid=' . $objp->rowid . '">'; + print 'id.'&lineid='.$objp->rowid.'">'; print img_delete(); print ''; } else @@ -1622,26 +1622,26 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ // Add area to show/add/edit a price for a dedicated customer -if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $prodcustprice = new Productcustomerprice($db); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); - $page = (GETPOST("page", 'int')?GETPOST("page", 'int'):0); + $page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - if (! $sortorder) + if (!$sortorder) $sortorder = "ASC"; - if (! $sortfield) + if (!$sortfield) $sortfield = "soc.nom"; // Build filter to diplay only concerned lines $filter = array('t.fk_product' => $object->id); - if (! empty($search_soc)) { + if (!empty($search_soc)) { $filter['soc.nom'] = $search_soc; } @@ -1652,23 +1652,23 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print load_fiche_titre($langs->trans('PriceByCustomer')); - print '
    '; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; dol_fiche_head(); print ''; print ''; - print ''; + print ''; print ''; print ''; // VAT - print ''; @@ -1687,9 +1687,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; @@ -1698,11 +1698,11 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $text = $langs->trans('MinPrice'); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); if ($object->price_base_type == 'TTC') { - print ''; } @@ -1720,9 +1720,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $langs->trans('ForceUpdateChildPriceSoc'); print ''; - print ''; + print ''; print '     '; - print ''; + print ''; print ''; print ''; @@ -1739,23 +1739,23 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } - print ''; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; dol_fiche_head(); print '
    ' . $langs->trans('ThirdParty') . ''.$langs->trans('ThirdParty').''; print $form->select_company('', 'socid', 's.client IN (1,2,3)', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); print '
    ' . $langs->trans("DefaultTaxRate") . ''; + print '
    '.$langs->trans("DefaultTaxRate").''; print $form->load_tva("tva_tx", $object->default_vat_code ? $object->tva_tx.' ('.$object->default_vat_code.')' : $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, $object->type, false, 1); print '
    '; if ($object->price_base_type == 'TTC') { - print ''; + print ''; } else { - print ''; + print ''; } print '
    '; + print ''; } else { - print ''; + print ''; } - if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { print ''.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'
    '; print ''; - print ''; + print ''; $staticsoc = new Societe($db); $staticsoc->fetch($prodcustprice->fk_soc); - print ""; + print ""; print ''; // VAT - print ''; @@ -1774,9 +1774,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; @@ -1786,12 +1786,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; - if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { print ''; } @@ -1814,9 +1814,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $langs->trans('ForceUpdateChildPriceSoc'); print ""; - print ''; + print ''; print '     '; - print ''; + print ''; print ''; print '
    '; @@ -1826,7 +1826,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // List of all log of prices by customers print ''."\n"; - $filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int')); + $filter = array('t.fk_product' => $object->id, 't.fk_soc' => GETPOST('socid', 'int')); // Count total nb of records $nbtotalofrecords = ''; @@ -1839,43 +1839,43 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } - $option = '&socid=' . GETPOST('socid', 'int') . '&id=' . $object->id; + $option = '&socid='.GETPOST('socid', 'int').'&id='.$object->id; $staticsoc = new Societe($db); $staticsoc->fetch(GETPOST('socid', 'int')); - $title=$langs->trans('PriceByCustomerLog'); - $title.=' - '.$staticsoc->getNomUrl(1); + $title = $langs->trans('PriceByCustomerLog'); + $title .= ' - '.$staticsoc->getNomUrl(1); - $backbutton='' . $langs->trans("Back") . ''; + $backbutton = ''.$langs->trans("Back").''; print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords, 'title_accountancy.png'); if (count($prodcustprice->lines) > 0) { - print ''; - print ''; + print ''; + print ''; print '
    ' . $langs->trans('ThirdParty') . ''.$langs->trans('ThirdParty').'" . $staticsoc->getNomUrl(1) . "".$staticsoc->getNomUrl(1)."
    ' . $langs->trans("DefaultTaxRate") . ''; + print '
    '.$langs->trans("DefaultTaxRate").''; print $form->load_tva("tva_tx", $prodcustprice->default_vat_code ? $prodcustprice->tva_tx.' ('.$prodcustprice->default_vat_code.')' : $prodcustprice->tva_tx, $mysoc, '', $object->id, $prodcustprice->recuperableonly, $object->type, false, 1); print '
    '; if ($prodcustprice->price_base_type == 'TTC') { - print ''; + print ''; } else { - print ''; + print ''; } print '
    '; if ($prodcustprice->price_base_type == 'TTC') { - print ''; + print ''; } else { - print ''; + print ''; } print ''.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'
    '; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print ''; - print ''; + print ''; } else { - print ''; + print ''; } - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; @@ -1888,19 +1888,19 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx; // Line for default price - if ($line->price_base_type=='HT') + if ($line->price_base_type == 'HT') { - $pu=$line->price; + $pu = $line->price; } else { - $pu=$line->price_ttc; + $pu = $line->price_ttc; } // Local tax is not saved into table of product. We use value linked to VAT code. - $localtaxarray=getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), 0, $staticsoc, $mysoc); + $localtaxarray = getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), 0, $staticsoc, $mysoc); // Define part of HT, VAT, TTC - $resultarray=calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); + $resultarray = calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; $total_vat = $resultarray[1]; @@ -1910,35 +1910,35 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; - print ""; - print ""; - print '"; + print ""; + print ""; + print '"; print '"; - print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '"; - print ''; + print ''; } else { - print '"; + print '"; } - print ''; - print ''; + print ''; + print ''; // User $userstatic = new User($db); @@ -1969,67 +1969,67 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } - $option = '&search_soc=' . $search_soc . '&id=' . $object->id; + $option = '&search_soc='.$search_soc.'&id='.$object->id; print_barre_liste($langs->trans('PriceByCustomer'), $page, $_SERVER ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, 'title_accountancy.png'); - print ''; - print ''; + print ''; + print ''; print '
    ' . $langs->trans("ThirdParty") . '' . $langs->trans("AppliedPricesFrom") . '' . $langs->trans("PriceBase") . '' . $langs->trans("DefaultTaxRate") . '' . $langs->trans("HT") . ''.$langs->trans("ThirdParty").''.$langs->trans("AppliedPricesFrom").''.$langs->trans("PriceBase").''.$langs->trans("DefaultTaxRate").''.$langs->trans("HT").'' . $langs->trans("INCVATONLY") . '' . $langs->trans("INCT") . ''.$langs->trans("INCT").'' . $langs->trans("TTC") . ''.$langs->trans("TTC").'' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '' . $langs->trans("ChangedBy") . ''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.$langs->trans("ChangedBy").' 
    " . $staticsoc->getNomUrl(1) . "" . dol_print_date($line->datec, "dayhour") . "' . $langs->trans($line->price_base_type) . "".$staticsoc->getNomUrl(1)."".dol_print_date($line->datec, "dayhour")."'.$langs->trans($line->price_base_type)."'; - $positiverates=''; - if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); - if (price2num($line->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); - if (price2num($line->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); - if (empty($positiverates)) $positiverates='0'; + $positiverates = ''; + if (price2num($line->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); + if (price2num($line->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); + if (price2num($line->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); + if (empty($positiverates)) $positiverates = '0'; - echo vatrate($positiverates.($line->default_vat_code?' ('.$line->default_vat_code.')':''), '%', ($line->tva_npr?$line->tva_npr:$line->recuperableonly)); + echo vatrate($positiverates.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), '%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly)); //. vatrate($tva_tx, true, $line->recuperableonly) . print "' . price($line->price) . "'.price($line->price)."' . price($line->price_ttc) . "' . price($resultarray[2]) . ''.price($resultarray[2]).'' . price($line->price_ttc) . "'.price($line->price_ttc)."' . price($line->price_min) . '' . price($line->price_min_ttc) . ''.price($line->price_min).''.price($line->price_min_ttc).'
    '; if (count($prodcustprice->lines) > 0 || $search_soc) { - $colspan=8; + $colspan = 8; //if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++; print ''; - print ''; + print ''; print ''; // Print the search button print ''; print ''; } print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print ''; - print ''; + print ''; } else { - print ''; + print ''; } - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; // Line for default price - if ($object->price_base_type=='HT') + if ($object->price_base_type == 'HT') { - $pu=$object->price; + $pu = $object->price; } else { - $pu=$object->price_ttc; + $pu = $object->price_ttc; } // Local tax is not saved into table of product. We use value linked to VAT code. - $localtaxarray=getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code?' ('.$object->default_vat_code.')':''), 0, $mysoc, $mysoc); + $localtaxarray = getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), 0, $mysoc, $mysoc); // Define part of HT, VAT, TTC - $resultarray=calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray); + $resultarray = calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; $total_vat = $resultarray[1]; @@ -2038,48 +2038,48 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $total_ttc = $resultarray[2]; print ''; - print ""; - print ""; + print ""; + print ""; - print '"; + print '"; print '"; - print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '"; - print ''; + print ''; } else { - print '"; + print '"; } - print ''; - print ''; + print ''; + print ''; print ''; if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { print ''; - print ""; - print ""; + print ""; + print ""; - print '"; + print '"; print '"; - print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '"; - print ''; + print ''; } else { - print '"; + print '"; } - print ''; - print ''; + print ''; + print ''; // User $userstatic = new User($db); @@ -2161,15 +2161,15 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { print ''; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index d87b6f7604f..5ca7992be31 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -33,33 +33,33 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width', 380); -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height', 160); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 380); +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 160); // Load translation files required by the page $langs->loadLangs(array('companies', 'products', 'stocks', 'bills', 'other')); -$id = GETPOST('id', 'int'); // For this page, id can also be 'all' +$id = GETPOST('id', 'int'); // For this page, id can also be 'all' $ref = GETPOST('ref', 'alpha'); -$mode = (GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'byunit'); +$mode = (GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'byunit'); $search_year = GETPOST('search_year', 'int'); $search_categ = GETPOST('search_categ', 'int'); -$error = 0; +$error = 0; $mesg = ''; -$graphfiles=array(); +$graphfiles = array(); -$socid=''; -if (! empty($user->socid)) $socid=$user->socid; +$socid = ''; +if (!empty($user->socid)) $socid = $user->socid; // Security check -$fieldvalue = (! empty($id) ? $id : $ref); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +$fieldvalue = (!empty($id) ? $id : $ref); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -$tmp=dol_getdate(dol_now()); -$currentyear=$tmp['year']; -if (empty($search_year)) $search_year=$currentyear; +$tmp = dol_getdate(dol_now()); +$currentyear = $tmp['year']; +if (empty($search_year)) $search_year = $currentyear; /* @@ -77,30 +77,30 @@ $form = new Form($db); $htmlother = new FormOther($db); $object = new Product($db); -if (! $id && empty($ref)) +if (!$id && empty($ref)) { llxHeader("", $langs->trans("ProductStatistics")); $type = GETPOST('type', 'int'); - $helpurl=''; + $helpurl = ''; if ($type == '0') { - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; //$title=$langs->trans("StatisticsOfProducts"); - $title=$langs->trans("Statistics"); + $title = $langs->trans("Statistics"); } elseif ($type == '1') { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; //$title=$langs->trans("StatisticsOfServices"); - $title=$langs->trans("Statistics"); + $title = $langs->trans("Statistics"); } else { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; //$title=$langs->trans("StatisticsOfProductsOrServices"); - $title=$langs->trans("Statistics"); + $title = $langs->trans("Statistics"); } print load_fiche_titre($title, $mesg, 'products'); @@ -114,39 +114,39 @@ else $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Statistics'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Statistics'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Statistics'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Statistics'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); } -if ($result && (! empty($id) || ! empty($ref))) +if ($result && (!empty($id) || !empty($ref))) { - $head=product_prepare_head($object); - $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type==Product::TYPE_SERVICE?'service':'product'); + $head = product_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'stats', $titre, -1, $picto); $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', '', '', '', 0, '', '', 1); + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1); dol_fiche_end(); } if (empty($id) & empty($ref)) { - $h=0; + $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != ''?'?type='.$type:''); + $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != '' ? '?type='.$type : ''); $head[$h][1] = $langs->trans("Chart"); $head[$h][2] = 'chart'; $h++; @@ -159,7 +159,7 @@ if (empty($id) & empty($ref)) $title = $langs->trans("ListProductByPopularity"); } - $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != ''?'?type='.$type:''); + $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != '' ? '?type='.$type : ''); $head[$h][1] = $title; $head[$h][2] = 'popularityprop'; $h++; @@ -180,7 +180,7 @@ if ($result || empty($id)) { // Type print ''; @@ -189,7 +189,7 @@ if ($result || empty($id)) { print ''; @@ -198,13 +198,13 @@ if ($result || empty($id)) // Year print ''; @@ -216,32 +216,32 @@ if ($result || empty($id)) // Choice of stats mode (byunit or bynumber) - if (! empty($conf->dol_use_jmobile)) print "\n".''; else print '
    '; print '
    '; //print '
     '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
    ' . $langs->trans("ThirdParty") . '' . $langs->trans("AppliedPricesFrom") . '' . $langs->trans("PriceBase") . '' . $langs->trans("DefaultTaxRate") . '' . $langs->trans("HT") . ''.$langs->trans("ThirdParty").''.$langs->trans("AppliedPricesFrom").''.$langs->trans("PriceBase").''.$langs->trans("DefaultTaxRate").''.$langs->trans("HT").'' . $langs->trans("INCVATONLY") . '' . $langs->trans("INCT") . ''.$langs->trans("INCT").'' . $langs->trans("TTC") . ''.$langs->trans("TTC").'' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '' . $langs->trans("ChangedBy") . ''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.$langs->trans("ChangedBy").' 
    " . $langs->trans("Default") . "" . "".$langs->trans("Default").""."' . $langs->trans($object->price_base_type) . "'.$langs->trans($object->price_base_type)."'; - $positiverates=''; - if (price2num($object->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($object->tva_tx); - if (price2num($object->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax1_tx); - if (price2num($object->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax2_tx); - if (empty($positiverates)) $positiverates='0'; - echo vatrate($positiverates.($object->default_vat_code?' ('.$object->default_vat_code.')':''), '%', $object->tva_npr); + $positiverates = ''; + if (price2num($object->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); + if (price2num($object->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); + if (price2num($object->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); + if (empty($positiverates)) $positiverates = '0'; + echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr); //print vatrate($object->tva_tx, true, $object->tva_npr); //print $object->default_vat_code?' ('.$object->default_vat_code.')':''; print "' . price($object->price) . "'.price($object->price)."' . price($object->price_ttc) . "' . price($resultarray[2]) . ''.price($resultarray[2]).'' . price($object->price_ttc) . "'.price($object->price_ttc)."' . price($object->price_min) . '' . price($object->price_min_ttc) . ''.price($object->price_min).''.price($object->price_min_ttc).''; print ''; - print 'id . '">'; + print 'id.'">'; print img_info($langs->trans('PriceByCustomerLog')); print ''; print ' '; - print 'id . '">'; + print 'id.'">'; print img_edit('default', 0, 'style="vertical-align: middle;"'); print ''; print '   '; @@ -2098,19 +2098,19 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx; // Line for default price - if ($line->price_base_type=='HT') + if ($line->price_base_type == 'HT') { - $pu=$line->price; + $pu = $line->price; } else { - $pu=$line->price_ttc; + $pu = $line->price_ttc; } // Local tax is not saved into table of product. We use value linked to VAT code. - $localtaxarray=getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), 0, $staticsoc, $mysoc); + $localtaxarray = getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), 0, $staticsoc, $mysoc); // Define part of HT, VAT, TTC - $resultarray=calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); + $resultarray = calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; $total_vat = $resultarray[1]; @@ -2120,34 +2120,34 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '
    " . $staticsoc->getNomUrl(1) . "" . dol_print_date($line->datec, "dayhour") . "".$staticsoc->getNomUrl(1)."".dol_print_date($line->datec, "dayhour")."' . $langs->trans($line->price_base_type) . "'.$langs->trans($line->price_base_type)."'; - $positiverates=''; - if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); - if (price2num($line->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); - if (price2num($line->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); - if (empty($positiverates)) $positiverates='0'; - echo vatrate($positiverates.($line->default_vat_code?' ('.$line->default_vat_code.')':''), '%', ($line->tva_npr?$line->tva_npr:$line->recuperableonly)); + $positiverates = ''; + if (price2num($line->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); + if (price2num($line->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); + if (price2num($line->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); + if (empty($positiverates)) $positiverates = '0'; + echo vatrate($positiverates.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), '%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly)); print "' . price($line->price) . "'.price($line->price)."' . price($line->price_ttc) . "' . price($resultarray[2]) . ''.price($resultarray[2]).'' . price($line->price_ttc) . "'.price($line->price_ttc)."' . price($line->price_min) . '' . price($line->price_min_ttc) . ''.price($line->price_min).''.price($line->price_min_ttc).''; - print 'id . '&socid=' . $line->fk_soc . '">'; + print 'id.'&socid='.$line->fk_soc.'">'; print img_info($langs->trans('PriceByCustomerLog')); print ''; print ' '; - print 'id . '&lineid=' . $line->id . '">'; + print 'id.'&lineid='.$line->id.'">'; print img_edit('default', 0, 'style="vertical-align: middle;"'); print ''; print ' '; - print 'id . '&lineid=' . $line->id . '">'; + print 'id.'&lineid='.$line->id.'">'; print img_delete('default', 'style="vertical-align: middle;"'); print ''; print '
    '.$langs->trans("ProductsAndServices").''; - $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); + $array = array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); print $form->selectarray('type', $array, $type); print '
    '.$langs->trans("Categories").''; //$moreforfilter.='
    '; - $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); //$moreforfilter.='
    '; print $moreforfilter; print '
    '.$langs->trans("Year").''; - $arrayyears=array(); - for ($year = $currentyear - 10; $year < $currentyear + 10 ; $year++) + $arrayyears = array(); + for ($year = $currentyear - 10; $year < $currentyear + 10; $year++) { - $arrayyears[$year]=$year; + $arrayyears[$year] = $year; } - if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; - if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear; + if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; + if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; arsort($arrayyears); print $form->selectarray('search_year', $arrayyears, $search_year, 0); print '
    '; // Generation des graphs - $dir = (! empty($conf->product->multidir_temp[$object->entity])?$conf->product->multidir_temp[$object->entity]:$conf->service->multidir_temp[$object->entity]); + $dir = (!empty($conf->product->multidir_temp[$object->entity]) ? $conf->product->multidir_temp[$object->entity] : $conf->service->multidir_temp[$object->entity]); if ($object->id > 0) // We are on statistics for a dedicated product { - if (! file_exists($dir.'/'.$object->id)) + if (!file_exists($dir.'/'.$object->id)) { if (dol_mkdir($dir.'/'.$object->id) < 0) { @@ -251,78 +251,78 @@ if ($result || empty($id)) } } - if($conf->propal->enabled) { - $graphfiles['propal']=array('modulepart'=>'productstats_proposals', - 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsProposals"):$langs->transnoentitiesnoconv("NumberOfProposals"))); + if ($conf->propal->enabled) { + $graphfiles['propal'] = array('modulepart'=>'productstats_proposals', + 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsProposals") : $langs->transnoentitiesnoconv("NumberOfProposals"))); } - if($conf->supplier_proposal->enabled) { - $graphfiles['proposalssuppliers']=array('modulepart'=>'productstats_proposalssuppliers', - 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals"):$langs->transnoentitiesnoconv("NumberOfSupplierProposals"))); + if ($conf->supplier_proposal->enabled) { + $graphfiles['proposalssuppliers'] = array('modulepart'=>'productstats_proposalssuppliers', + 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals") : $langs->transnoentitiesnoconv("NumberOfSupplierProposals"))); } - if($conf->order->enabled) { - $graphfiles['orders']=array('modulepart'=>'productstats_orders', - 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders"):$langs->transnoentitiesnoconv("NumberOfCustomerOrders"))); + if ($conf->order->enabled) { + $graphfiles['orders'] = array('modulepart'=>'productstats_orders', + 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders") : $langs->transnoentitiesnoconv("NumberOfCustomerOrders"))); } - if($conf->supplier_order->enabled) { - $graphfiles['orderssuppliers']=array('modulepart'=>'productstats_orderssuppliers', - 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders"):$langs->transnoentitiesnoconv("NumberOfSupplierOrders"))); + if ($conf->supplier_order->enabled) { + $graphfiles['orderssuppliers'] = array('modulepart'=>'productstats_orderssuppliers', + 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders") : $langs->transnoentitiesnoconv("NumberOfSupplierOrders"))); } - if($conf->facture->enabled) { - $graphfiles['invoices']=array('modulepart'=>'productstats_invoices', - 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices"):$langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))); + if ($conf->facture->enabled) { + $graphfiles['invoices'] = array('modulepart'=>'productstats_invoices', + 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices") : $langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))); } - if($conf->supplier_invoice->enabled) { - $graphfiles['invoicessuppliers']=array('modulepart'=>'productstats_invoicessuppliers', - 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices"):$langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))); + if ($conf->supplier_invoice->enabled) { + $graphfiles['invoicessuppliers'] = array('modulepart'=>'productstats_invoicessuppliers', + 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices") : $langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))); } - if($conf->contrat->enabled) { - $graphfiles['contracts']=array('modulepart'=>'productstats_contracts', - 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsContracts"):$langs->transnoentitiesnoconv("NumberOfContracts"))); + if ($conf->contrat->enabled) { + $graphfiles['contracts'] = array('modulepart'=>'productstats_contracts', + 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsContracts") : $langs->transnoentitiesnoconv("NumberOfContracts"))); } $px = new DolGraph(); - if (! $error && count($graphfiles)>0) + if (!$error && count($graphfiles) > 0) { $mesg = $px->isGraphKo(); - if (! $mesg) + if (!$mesg) { - foreach($graphfiles as $key => $val) + foreach ($graphfiles as $key => $val) { - if (! $graphfiles[$key]['file']) continue; + if (!$graphfiles[$key]['file']) continue; $graph_data = array(); - if (dol_is_file($dir . '/' . $graphfiles[$key]['file'])) + if (dol_is_file($dir.'/'.$graphfiles[$key]['file'])) { // TODO Load cachefile $graphfiles[$key]['file'] } else { - $morefilters=''; + $morefilters = ''; if ($search_categ > 0) { - $categ=new Categorie($db); + $categ = new Categorie($db); $categ->fetch($search_categ); $listofprodids = $categ->getObjectsInCateg('product', 1); - $morefilters=' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids):'0').')'; + $morefilters = ' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')'; } if ($search_categ == -2) { - $morefilters=' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)'; + $morefilters = ' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)'; } if ($key == 'propal') $graph_data = $object->get_nb_propal($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); @@ -340,18 +340,18 @@ if ($result || empty($id)) { $px->SetData($graph_data); $px->SetYLabel($graphfiles[$key]['label']); - $px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue()); - $px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue()); + $px->SetMaxValue($px->GetCeilMaxValue() < 0 ? 0 : $px->GetCeilMaxValue()); + $px->SetMinValue($px->GetFloorMinValue() > 0 ? 0 : $px->GetFloorMinValue()); $px->SetWidth($WIDTH); $px->SetHeight($HEIGHT); $px->SetHorizTickIncrement(1); $px->SetShading(3); //print 'x '.$key.' '.$graphfiles[$key]['file']; - $url=DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.$object->entity.'&file='.urlencode($graphfiles[$key]['file']); + $url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.$object->entity.'&file='.urlencode($graphfiles[$key]['file']); $px->draw($dir."/".$graphfiles[$key]['file'], $url); - $graphfiles[$key]['output']=$px->show(); + $graphfiles[$key]['output'] = $px->show(); } else { @@ -364,19 +364,19 @@ if ($result || empty($id)) } // Show graphs - $i=0; - if ( count($graphfiles)>0) + $i = 0; + if (count($graphfiles) > 0) { - foreach($graphfiles as $key => $val) + foreach ($graphfiles as $key => $val) { - if (! $graphfiles[$key]['file']) continue; + if (!$graphfiles[$key]['file']) continue; - if ($graphfiles == 'propal' && ! $user->rights->propale->lire) continue; - if ($graphfiles == 'order' && ! $user->rights->commande->lire) continue; - if ($graphfiles == 'invoices' && ! $user->rights->facture->lire) continue; - if ($graphfiles == 'proposals_suppliers' && ! $user->rights->supplier_proposal->lire) continue; - if ($graphfiles == 'invoices_suppliers' && ! $user->rights->fournisseur->facture->lire) continue; - if ($graphfiles == 'orders_suppliers' && ! $user->rights->fournisseur->commande->lire) continue; + if ($graphfiles == 'propal' && !$user->rights->propale->lire) continue; + if ($graphfiles == 'order' && !$user->rights->commande->lire) continue; + if ($graphfiles == 'invoices' && !$user->rights->facture->lire) continue; + if ($graphfiles == 'proposals_suppliers' && !$user->rights->supplier_proposal->lire) continue; + if ($graphfiles == 'invoices_suppliers' && !$user->rights->fournisseur->facture->lire) continue; + if ($graphfiles == 'orders_suppliers' && !$user->rights->fournisseur->commande->lire) continue; if ($i % 2 == 0) @@ -389,16 +389,16 @@ if ($result || empty($id)) } // Date generation - if ($graphfiles[$key]['output'] && ! $px->isGraphKo()) + if ($graphfiles[$key]['output'] && !$px->isGraphKo()) { - if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated=$langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour")); - else $dategenerated=$langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour")); + if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour")); + else $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour")); } else { - $dategenerated=($mesg?''.$mesg.'':$langs->trans("ChartNotGenerated")); + $dategenerated = ($mesg ? ''.$mesg.'' : $langs->trans("ChartNotGenerated")); } - $linktoregenerate='id).((string) $type != ''?'&type='.$type:'').'&action=recalcul&mode='.$mode.'&search_year='.$search_year.'&search_categ='.$search_categ.'">'.img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh').''; + $linktoregenerate = 'id).((string) $type != '' ? '&type='.$type : '').'&action=recalcul&mode='.$mode.'&search_year='.$search_year.'&search_categ='.$search_categ.'">'.img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh').''; // Show graph print '
    '; @@ -436,7 +436,7 @@ if ($result || empty($id)) } } -if (! $id) +if (!$id) { dol_fiche_end(); } diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index efdaebab889..bab78114fed 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -36,14 +36,14 @@ $langs->loadLangs(array('products', 'languages')); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); /* @@ -73,21 +73,21 @@ $cancel != $langs->trans("Cancel") && $current_lang = $langs->getDefaultLang(); // update de l'objet - if ( $_POST["forcelangprod"] == $current_lang ) + if ($_POST["forcelangprod"] == $current_lang) { $object->label = $_POST["libelle"]; - $object->description = dol_htmlcleanlastbr($_POST["desc"]); + $object->description = dol_htmlcleanlastbr($_POST["desc"]); $object->other = dol_htmlcleanlastbr($_POST["other"]); } else { $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; - $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); + $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); $object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]); } // sauvegarde en base - if ( $object->setMultiLangs($user) > 0 ) + if ($object->setMultiLangs($user) > 0) { $action = ''; } @@ -109,21 +109,21 @@ $cancel != $langs->trans("Cancel") && foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet { - if ( $key == $current_lang ) + if ($key == $current_lang) { $object->label = $_POST["libelle-".$key]; - $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->other = dol_htmlcleanlastbr($_POST["other-".$key]); } else { $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; - $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]); } } - if ( $object->setMultiLangs($user) > 0 ) + if ($object->setMultiLangs($user) > 0) { $action = ''; } @@ -141,10 +141,10 @@ $cancel != $langs->trans("Cancel") && { $object = new Product($db); $object->fetch($id); - $langtodelete=GETPOST('langdel', 'alpha'); + $langtodelete = GETPOST('langdel', 'alpha'); - if ( $object->delMultiLangs($langtodelete, $user) > 0 ) + if ($object->delMultiLangs($langtodelete, $user) > 0) { $action = ''; } @@ -168,28 +168,28 @@ $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Translation'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Translation'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Translation'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Translation'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); -$head=product_prepare_head($object); -$titre=$langs->trans("CardProduct".$object->type); -$picto=($object->type==Product::TYPE_SERVICE?'service':'product'); +$head = product_prepare_head($object); +$titre = $langs->trans("CardProduct".$object->type); +$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); // Calculate $cnt_trans $cnt_trans = 0; -if (! empty($object->multilangs)) +if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { @@ -203,7 +203,7 @@ dol_fiche_head($head, 'translation', $titre, 0, $picto); $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; -if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; +if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 1); @@ -242,12 +242,12 @@ if ($action == 'edit') print ''; print ''; - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { - $s=picto_from_langcode($key); - print "
    ".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"')."
    "; + $s = picto_from_langcode($key); + print "
    ".($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"')."
    "; print '
    '; print '
    '; @@ -256,7 +256,7 @@ if ($action == 'edit') $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); print ''; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { print '
    '.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'; $doleditor = new DolEditor("other-$key", $object->multilangs[$key]["other"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); @@ -279,19 +279,19 @@ if ($action == 'edit') } elseif ($action != 'add') { - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { - $s=picto_from_langcode($key); - print ($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; + $s = picto_from_langcode($key); + print ($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; print '
    '; print '
    '; print ''; print ''; print ''; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { print ''; } @@ -299,7 +299,7 @@ elseif ($action != 'add') print ''; } } - if (! $cnt_trans && $action != 'add') print '
    '. $langs->trans('NoTranslation').'
    '; + if (!$cnt_trans && $action != 'add') print '
    '.$langs->trans('NoTranslation').'
    '; } @@ -331,7 +331,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service $doleditor->Create(); print ''; // Other field (not used) - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { print ''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { - $projectid = GETPOST('projectid', 'int')?GETPOST('projectid', 'int'):0; - if(empty($projectid) && ! empty($object->fk_project)) $projectid = $object->fk_project; + $projectid = GETPOST('projectid', 'int') ?GETPOST('projectid', 'int') : 0; + if (empty($projectid) && !empty($object->fk_project)) $projectid = $object->fk_project; if ($origin == 'project') $projectid = ($originid ? $originid : 0); $langs->load("projects"); print ''; - print ''; print ''; } @@ -807,8 +807,8 @@ if ($action == 'create') print ''; print '\n"; print ''; @@ -820,7 +820,7 @@ if ($action == 'create') print ""; // Note Private - if ($object->note_private && ! $user->socid) + if ($object->note_private && !$user->socid) { print ''; print ''; // Dim @@ -844,8 +844,8 @@ if ($action == 'create') print ' x '; print ' x '; print ' '; - $text=$formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); - $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); + $text = $formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); + $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print ''; @@ -865,12 +865,12 @@ if ($action == 'create') // Other attributes $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Here $object can be of an object Order $extrafields->fetch_name_optionals_label($object->table_element); - if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element]['label'])) { + if (empty($reshook) && !empty($extrafields->attributes[$object->table_element]['label'])) { // copy from order if ($object->fetch_optionals() > 0) { $recept->array_options = array_merge($recept->array_options, $object->array_options); @@ -884,12 +884,12 @@ if ($action == 'create') print ''; print ''; print ''; } // Document model - include_once DOL_DOCUMENT_ROOT . '/core/modules/reception/modules_reception.php'; + include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; $liste = ModelePdfReception::liste_modeles($db); if (count($liste) > 1) @@ -906,14 +906,14 @@ if ($action == 'create') // Reception lines - $numAsked=0; + $numAsked = 0; $dispatchLines = array(); foreach ($_POST as $key => $value) { // without batch module enabled if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) { - $numAsked ++; + $numAsked++; // $numline=$reg[2] + 1; // line of product $numline = $numAsked; @@ -922,7 +922,7 @@ if ($action == 'create') $ent = "entrepot_".$reg[1].'_'.$reg[2]; $pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount $fk_commandefourndet = "fk_commandefourndet_".$reg[1].'_'.$reg[2]; - $dispatchLines[$numAsked]=array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'),'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int')); + $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int')); } // with batch module enabled @@ -941,7 +941,7 @@ if ($action == 'create') $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$reg[1].'_'.$reg[2].'month'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'day'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'year']); $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$reg[1].'_'.$reg[2].'month'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'day'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'year']); $fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2]; - $dispatchLines[$numAsked]=array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'),'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'),'DLC'=> $dDLC,'DLUO'=> $dDLUO,'lot'=> GETPOST($lot, 'alpha')); + $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha')); } } @@ -949,16 +949,16 @@ if ($action == 'create') print ''; + if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink .= ''; } /* @@ -469,9 +469,9 @@ $form = new Form($db); '."\n"; + print ''."\n"; } @@ -589,7 +589,7 @@ print ''; } -if ($_SESSION["basiclayout"]!=1) +if ($_SESSION["basiclayout"] != 1) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } print "\n"; -if ($_SESSION["basiclayout"]==1) +if ($_SESSION["basiclayout"] == 1) { - if ($mobilepage=="cats") + if ($mobilepage == "cats") { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $categorie = new Categorie($db); $categories = $categorie->get_full_arbo('product'); $htmlforlines = ''; - foreach ($categories as $row){ - $htmlforlines.= ''; - $htmlforlines.= ''; - $htmlforlines.= ''."\n"; + foreach ($categories as $row) { + $htmlforlines .= ''; + $htmlforlines .= ''; + $htmlforlines .= ''."\n"; } - $htmlforlines.= '
    '.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
    '.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
    '.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'.$object->multilangs[$key]["other"].'
    '.$langs->trans('Other').' ('.$langs->trans("NotUsed").''; $doleditor = new DolEditor('other', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index c641007ecf1..cc4fad1cb60 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -44,40 +44,40 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->fournisseur->enabled)){ +if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->fournisseur->enabled)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; } -if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; -if (! empty($conf->projet->enabled)) { +if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -$langs->loadLangs(array("receptions","companies","bills",'deliveries','orders','stocks','other','propal','sendings')); +$langs->loadLangs(array("receptions", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal', 'sendings')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -if (! empty($conf->productbatch->enabled)) $langs->load('productbatch'); +if (!empty($conf->productbatch->enabled)) $langs->load('productbatch'); -$origin = GETPOST('origin', 'alpha')?GETPOST('origin', 'alpha'):'reception'; // Example: commande, propal -$origin_id = GETPOST('id', 'int')?GETPOST('id', 'int'):''; +$origin = GETPOST('origin', 'alpha') ?GETPOST('origin', 'alpha') : 'reception'; // Example: commande, propal +$origin_id = GETPOST('id', 'int') ?GETPOST('id', 'int') : ''; $id = $origin_id; -if (empty($origin_id)) $origin_id = GETPOST('origin_id', 'int'); // Id of order or propal -if (empty($origin_id)) $origin_id = GETPOST('object_id', 'int'); // Id of order or propal -if (empty($origin_id)) $origin_id = GETPOST('originid', 'int'); // Id of order or propal -$ref=GETPOST('ref', 'alpha'); -$line_id = GETPOST('lineid', 'int')?GETPOST('lineid', 'int'):''; +if (empty($origin_id)) $origin_id = GETPOST('origin_id', 'int'); // Id of order or propal +if (empty($origin_id)) $origin_id = GETPOST('object_id', 'int'); // Id of order or propal +if (empty($origin_id)) $origin_id = GETPOST('originid', 'int'); // Id of order or propal +$ref = GETPOST('ref', 'alpha'); +$line_id = GETPOST('lineid', 'int') ?GETPOST('lineid', 'int') : ''; // Security check -$socid=''; -if ($user->socid) $socid=$user->socid; +$socid = ''; +if ($user->socid) $socid = $user->socid; -if ($origin == 'reception') $result=restrictedArea($user, $origin, $id); +if ($origin == 'reception') $result = restrictedArea($user, $origin, $id); else { - $result=restrictedArea($user, 'reception'); - if($origin == 'supplierorder'){ + $result = restrictedArea($user, 'reception'); + if ($origin == 'supplierorder') { if (empty($user->rights->fournisseur->commande->lire) && empty($user->rights->fournisseur->commande->read)) accessforbidden(); }elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) accessforbidden(); } @@ -88,12 +88,12 @@ if (GETPOST('modelselected')) { $action = 'presend'; } $confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); //PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); $object = new Reception($db); $extrafields = new ExtraFields($db); @@ -103,12 +103,12 @@ $extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element_line); // Load object. Make an object->fetch -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('receptioncard','globalcard')); +$hookmanager->initHooks(array('receptioncard', 'globalcard')); -$permissiondellink=$user->rights->reception->creer; // Used by the include of actions_dellink.inc.php +$permissiondellink = $user->rights->reception->creer; // Used by the include of actions_dellink.inc.php //var_dump($object->lines[0]->detail_batch); @@ -116,8 +116,8 @@ $permissiondellink=$user->rights->reception->creer; // Used by the include of ac * Actions */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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)) @@ -128,7 +128,7 @@ if (empty($reshook)) $object->fetch($id); // show reception also after canceling modification } - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once // Reopen if ($action == 'reopen' && $user->rights->reception->creer) @@ -150,11 +150,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } @@ -190,7 +190,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! @@ -248,7 +248,7 @@ if (empty($reshook)) $object->socid = $objectsrc->socid; $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); $object->model_pdf = GETPOST('model'); - $object->date_delivery = $date_delivery; // Date delivery planed + $object->date_delivery = $date_delivery; // Date delivery planed $object->fk_delivery_address = $objectsrc->fk_delivery_address; $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->tracking_number = GETPOST('tracking_number', 'alpha'); @@ -306,8 +306,8 @@ if (empty($reshook)) for ($i = 1; $i <= $num; $i++) { $lineToTest = ''; - foreach($objectsrc->lines as $linesrc){ - if($linesrc->id == GETPOST($idl, 'int'))$lineToTest=$linesrc; + foreach ($objectsrc->lines as $linesrc) { + if ($linesrc->id == GETPOST($idl, 'int'))$lineToTest = $linesrc; } $qty = "qtyl".$i; $comment = "comment".$i; @@ -350,9 +350,9 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (! $error) + if (!$error) { - $ret=$object->create($user); // This create reception (like Odoo picking) and line of receptions. Stock movement will when validating reception. + $ret = $object->create($user); // This create reception (like Odoo picking) and line of receptions. Stock movement will when validating reception. if ($ret <= 0) { @@ -367,7 +367,7 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $db->commit(); header("Location: card.php?id=".$object->id); @@ -376,14 +376,14 @@ if (empty($reshook)) else { $db->rollback(); - $_GET["commande_id"]=GETPOST('commande_id', 'int'); - $action='create'; + $_GET["commande_id"] = GETPOST('commande_id', 'int'); + $action = 'create'; } } elseif ($action == 'confirm_valid' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->reception_advance->validate))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))) ) { $object->fetch_thirdparty(); @@ -404,14 +404,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } } @@ -443,10 +443,10 @@ if (empty($reshook)) elseif ($action == 'setdate_livraison' && $user->rights->reception->creer) { //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datedelivery=dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); + $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object->fetch($id); - $result=$object->set_date_livraison($user, $datedelivery); + $result = $object->set_date_livraison($user, $datedelivery); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -461,23 +461,23 @@ if (empty($reshook)) || $action == 'settrueDepth' || $action == 'setshipping_method_id') { - $error=0; + $error = 0; if ($action == 'settracking_number') $object->tracking_number = trim(GETPOST('tracking_number', 'alpha')); if ($action == 'settracking_url') $object->tracking_url = trim(GETPOST('tracking_url', 'int')); - if ($action == 'settrueWeight') { + if ($action == 'settrueWeight') { $object->trueWeight = trim(GETPOST('trueWeight', 'int')); $object->weight_units = GETPOST('weight_units', 'int'); } if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth', 'int')); - if ($action == 'settrueHeight'){ + if ($action == 'settrueHeight') { $object->trueHeight = trim(GETPOST('trueHeight', 'int')); $object->size_units = GETPOST('size_units', 'int'); } if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth', 'int')); if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id', 'int')); - if (! $error) + if (!$error) { if ($object->update($user) >= 0) { @@ -487,7 +487,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - $action=""; + $action = ""; } // Build document @@ -498,10 +498,10 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$reception->thirdparty->default_lang; - if (! empty($newlang)) + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $reception->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -510,7 +510,7 @@ if (empty($reshook)) if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } @@ -519,9 +519,9 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $upload_dir = $conf->reception->dir_output ; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file, 0, 0, 0, $object); + $upload_dir = $conf->reception->dir_output; + $file = $upload_dir.'/'.GETPOST('file'); + $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); } @@ -530,8 +530,8 @@ if (empty($reshook)) { $object->fetch($id); $result = $object->set_billed(); - if($result >= 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + if ($result >= 0) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } } @@ -540,8 +540,8 @@ if (empty($reshook)) { $object->fetch($id); $result = $object->setClosed(); - if($result >= 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + if ($result >= 0) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } } @@ -549,20 +549,20 @@ if (empty($reshook)) /* * delete a line */ - elseif ($action == 'deleteline' && ! empty($line_id)) + elseif ($action == 'deleteline' && !empty($line_id)) { $object->fetch($id); $lines = $object->lines; $line = new CommandeFournisseurDispatch($db); $num_prod = count($lines); - for ($i = 0 ; $i < $num_prod ; $i++) + for ($i = 0; $i < $num_prod; $i++) { if ($lines[$i]->id == $line_id) { // delete single warehouse line $line->id = $line_id; - if (! $error && $line->delete($user) < 0) + if (!$error && $line->delete($user) < 0) { $error++; } @@ -570,8 +570,8 @@ if (empty($reshook)) unset($_POST["lineid"]); } - if(! $error) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + if (!$error) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } else @@ -619,7 +619,7 @@ if (empty($reshook)) $line->qty = GETPOST($qty, 'int'); $line->comment = GETPOST($comment, 'alpha'); - if(!empty($conf->productbatch->enabled)){ + if (!empty($conf->productbatch->enabled)) { $batch = "batch".$line_id; $dlc = "dlc".$line_id; $dluo = "dluo".$line_id; @@ -656,7 +656,7 @@ if (empty($reshook)) unset($_POST["lineid"]); - if (! $error) { + if (!$error) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -665,7 +665,7 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -676,22 +676,22 @@ if (empty($reshook)) } else { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } } elseif ($action == 'updateline' && $user->rights->reception->creer && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - if (empty($id)) $id=$facid; - $trigger_name='RECEPTION_SENTBYMAIL'; - $paramname='id'; - $mode='emailfromreception'; - $trackid='shi'.$object->id; + if (empty($id)) $id = $facid; + $trigger_name = 'RECEPTION_SENTBYMAIL'; + $paramname = 'id'; + $mode = 'emailfromreception'; + $trackid = 'shi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -705,7 +705,7 @@ llxHeader('', $langs->trans('Reception'), 'Reception'); $form = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $product_static = new Product($db); $reception_static = new Reception($db); @@ -715,7 +715,7 @@ if ($action == 'create2') { print load_fiche_titre($langs->trans("CreateReception")).'
    '; print $langs->trans("ReceptionCreationIsDoneFromOrder"); - $action=''; $id=''; $ref=''; + $action = ''; $id = ''; $ref = ''; } // Mode creation. @@ -724,14 +724,14 @@ if ($action == 'create') $recept = new Reception($db); print load_fiche_titre($langs->trans("CreateReception")); - if (! $origin) + if (!$origin) { setEventMessages($langs->trans("ErrorBadParameters"), null, 'errors'); } if ($origin) { - if($origin == 'supplierorder')$classname = 'CommandeFournisseur'; + if ($origin == 'supplierorder')$classname = 'CommandeFournisseur'; else $classname = ucfirst($origin); $object = new $classname($db); @@ -743,7 +743,7 @@ if ($action == 'create') $author = new User($db); $author->fetch($object->user_author_id); - if (! empty($conf->stock->enabled)) $entrepot = new Entrepot($db); + if (!empty($conf->stock->enabled)) $entrepot = new Entrepot($db); print ''; print ''; @@ -762,11 +762,11 @@ if ($action == 'create') // Ref print '
    '; - if ($origin == 'supplierorder' && ! empty($conf->fournisseur->enabled)) + if ($origin == 'supplierorder' && !empty($conf->fournisseur->enabled)) { print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"), 'order').' '.$object->ref; } - if ($origin == 'propal' && ! empty($conf->propal->enabled)) + if ($origin == 'propal' && !empty($conf->propal->enabled)) { print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"), 'propal').' '.$object->ref; } @@ -788,17 +788,17 @@ if ($action == 'create') print '
    ' . $langs->trans("Project") . ''; + print ''.$langs->trans("Project").''; $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id).'">'.$langs->trans("AddProject").''; print '
    '.$langs->trans("DateDeliveryPlanned").''; //print dol_print_date($object->date_livraison,"day"); // date_livraison come from order and will be stored into date_delivery planed. - $date_delivery = ($date_delivery?$date_delivery:$object->date_livraison); // $date_delivery comes from GETPOST - print $form->selectDate($date_delivery?$date_delivery:-1, 'date_delivery', 1, 1, 1); + $date_delivery = ($date_delivery ? $date_delivery : $object->date_livraison); // $date_delivery comes from GETPOST + print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); print "
    '.$langs->trans("NotePrivate").''; @@ -833,8 +833,8 @@ if ($action == 'create') print '
    '; print $langs->trans("Weight"); print ' '; - $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); - $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); + $text = $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); + $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print '
    '; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:'')); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print '
    '; print ''; if ($conf->global->TAKEPOS_BAR_RESTAURANT) { - $sql="SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); + $sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); $resql = $db->query($sql); $obj = $db->fetch_object($resql); if ($obj) @@ -598,83 +598,83 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) $floor = $obj->floor; } // In phone version only show when is invoice page - if ($mobilepage=="invoice" || $mobilepage=="") { - print $langs->trans('Place') . " " . $label . " - "; - print $langs->trans('Floor') . " " . $floor . " - "; + if ($mobilepage == "invoice" || $mobilepage == "") { + print $langs->trans('Place')." ".$label." - "; + print $langs->trans('Floor')." ".$floor." - "; } } // In phone version only show when is invoice page -if ($mobilepage=="invoice" || $mobilepage=="") { +if ($mobilepage == "invoice" || $mobilepage == "") { print $langs->trans('TotalTTC'); - print ' : ' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . ''; - print '
    ' . $sectionwithinvoicelink; + print ' : '.price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency).''; + print '
    '.$sectionwithinvoicelink; print '
    ' . $langs->trans('ReductionShort') . '' . $langs->trans('Qty') . '' . $langs->trans('TotalTTCShort') . ''.$langs->trans('ReductionShort').''.$langs->trans('Qty').''.$langs->trans('TotalTTCShort').'
    '; - $htmlforlines.= $row['label']; - $htmlforlines.= '
    '; + $htmlforlines .= $row['label']; + $htmlforlines .= '
    '; - $htmlforlines.= '
    '; + $htmlforlines .= '
    '; + $htmlforlines .= '
    '; print $htmlforlines; } - if ($mobilepage=="products") + if ($mobilepage == "products") { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $object = new Categorie($db); $catid = GETPOST('catid', 'int'); - $result=$object->fetch($catid); + $result = $object->fetch($catid); $prods = $object->getObjectsInCateg("product"); $htmlforlines = ''; foreach ($prods as $row) { - $htmlforlines.= ''; - $htmlforlines.= ''; - $htmlforlines.= $row->label; - $htmlforlines.= ''; - $htmlforlines.= ''."\n"; + $htmlforlines .= ''; + $htmlforlines .= ''; + $htmlforlines .= $row->label; + $htmlforlines .= ''; + $htmlforlines .= ''."\n"; } - $htmlforlines.= ''; + $htmlforlines .= ''; print $htmlforlines; } - if ($mobilepage=="places") + if ($mobilepage == "places") { - $sql="SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables"; + $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables"; $resql = $db->query($sql); $rows = array(); $htmlforlines = ''; - while($row = $db->fetch_array($resql)){ + while ($row = $db->fetch_array($resql)) { $rows[] = $row; - $htmlforlines.= ''; - $htmlforlines.= ''; - $htmlforlines.= $row['label']; - $htmlforlines.= ''; - $htmlforlines.= ''."\n"; + $htmlforlines .= ''; + $htmlforlines .= ''; + $htmlforlines .= $row['label']; + $htmlforlines .= ''; + $htmlforlines .= ''."\n"; } - $htmlforlines.= ''; + $htmlforlines .= ''; print $htmlforlines; } } @@ -682,50 +682,50 @@ if ($_SESSION["basiclayout"]==1) if ($placeid > 0) { //In Phone basic layout hide some content depends situation - if ($_SESSION["basiclayout"]==1 && $mobilepage!="invoice" && $action!="order") return; + if ($_SESSION["basiclayout"] == 1 && $mobilepage != "invoice" && $action != "order") return; if (is_array($invoice->lines) && count($invoice->lines)) { $tmplines = array_reverse($invoice->lines); - foreach($tmplines as $line) + foreach ($tmplines as $line) { $htmlforlines = ''; - $htmlforlines.= 'special_code == "4") { - $htmlforlines.= ' order'; + $htmlforlines .= ' order'; } - $htmlforlines.= '" id="' . $line->id . '">'; - $htmlforlines.= ''; + $htmlforlines .= '" id="'.$line->id.'">'; + $htmlforlines .= ''; //if ($line->product_label) $htmlforlines.= ''.$line->product_label.''; if (isset($line->product_type)) { - if (empty($line->product_type)) $htmlforlines.=img_object('', 'product').' '; - else $htmlforlines.=img_object('', 'service').' '; + if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' '; + else $htmlforlines .= img_object('', 'service').' '; } - if ($line->product_label) $htmlforlines.= $line->product_label; - if ($line->product_label && $line->desc) $htmlforlines.= '
    '; + if ($line->product_label) $htmlforlines .= $line->product_label; + if ($line->product_label && $line->desc) $htmlforlines .= '
    '; if ($line->product_label != $line->desc) { $firstline = dolGetFirstLineOfText($line->desc); if ($firstline != $line->desc) { - $htmlforlines.= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); + $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); } else { - $htmlforlines.= $line->desc; + $htmlforlines .= $line->desc; } } - if (!empty($line->array_options['options_order_notes'])) $htmlforlines.= "
    (".$line->array_options['options_order_notes'].")"; - if ($_SESSION["basiclayout"]!=1) + if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "
    (".$line->array_options['options_order_notes'].")"; + if ($_SESSION["basiclayout"] != 1) { - $htmlforlines.= ''; - $htmlforlines.= '' . vatrate($line->remise_percent, true) . ''; - $htmlforlines.= '' . $line->qty . ''; - $htmlforlines.= '' . price($line->total_ttc) . ''; + $htmlforlines .= ''; + $htmlforlines .= ''.vatrate($line->remise_percent, true).''; + $htmlforlines .= ''.$line->qty.''; + $htmlforlines .= ''.price($line->total_ttc).''; } - $htmlforlines.= ''."\n"; + $htmlforlines .= ''."\n"; print $htmlforlines; } @@ -743,7 +743,7 @@ print ''; if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) { - $constforcompanyid='CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; + $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; $soc = new Societe($db); if ($invoice->socid > 0) $soc->fetch($invoice->socid); else $soc->fetch($conf->global->$constforcompanyid); @@ -752,7 +752,7 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep print $langs->trans("Customer").': '.$soc->name; $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if (! empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") + if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; $warehouse = new Entrepot($db); @@ -761,16 +761,16 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep } // Module Adherent - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $langs->load("members"); print '
    '.$langs->trans("Member").': '; - $adh=new Adherent($db); - $result=$adh->fetch('', '', $invoice->socid); + $adh = new Adherent($db); + $result = $adh->fetch('', '', $invoice->socid); if ($result > 0) { - $adh->ref=$adh->getFullName($langs); + $adh->ref = $adh->getFullName($langs); print $adh->getFullName($langs); print '
    '.$langs->trans("Type").': '.$adh->type; if ($adh->datefin) @@ -797,7 +797,7 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep if ($action == "search") { print '
    - '; } diff --git a/htdocs/takepos/send.php b/htdocs/takepos/send.php index 93fb753c2f3..7c5676c5a1f 100644 --- a/htdocs/takepos/send.php +++ b/htdocs/takepos/send.php @@ -25,15 +25,15 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -require '../main.inc.php'; // Load $user and permissions +require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $invoiceid = GETPOST('facid', 'int'); @@ -48,16 +48,16 @@ if ($invoiceid > 0) } else { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); $obj = $db->fetch_object($resql); if ($obj) { $invoiceid = $obj->rowid; } - if (! $invoiceid) + if (!$invoiceid) { - $invoiceid=0; // Invoice does not exist yet + $invoiceid = 0; // Invoice does not exist yet } else { @@ -82,7 +82,7 @@ if ($invoice->id > 0) } $alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0); -if ($conf->global->TAKEPOS_NUMPAD==0) print "var received='';"; +if ($conf->global->TAKEPOS_NUMPAD == 0) print "var received='';"; else print "var received=0;"; ?> @@ -98,10 +98,10 @@ else print "var received=0;"; $('.change1').val(parseFloat(received)); alreadypaydplusreceived=price2numjs(alreadypayed + parseFloat(received)); //console.log("already+received = "+alreadypaydplusreceived); - //console.log("total_ttc = "+total_ttc;?>); - if (alreadypaydplusreceived > total_ttc;?>) + //console.log("total_ttc = "+total_ttc; ?>); + if (alreadypaydplusreceived > total_ttc; ?>) { - var change=parseFloat(alreadypayed + parseFloat(received) - total_ttc;?>); + var change=parseFloat(alreadypayed + parseFloat(received) - total_ttc; ?>); $('.change2').html(pricejs(change, 'MT')); $('.change2').val(change); $('.change1').removeClass('colorred'); @@ -113,7 +113,7 @@ else print "var received=0;"; { $('.change2').html(pricejs(0, 'MT')); $('.change2').val(0); - if (alreadypaydplusreceived == total_ttc;?>) + if (alreadypaydplusreceived == total_ttc; ?>) { $('.change1').removeClass('colorred'); $('.change1').addClass('colorgreen'); @@ -140,7 +140,7 @@ function Print(id){
    -
    +

    diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index fd7de709fe4..9df1afb01de 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -32,9 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php'; -if (! empty($conf->holiday->enabled)) require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; -if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; -if (! empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; +if (!empty($conf->holiday->enabled)) require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; +if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; // Load translation files required by page $langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries')); @@ -45,23 +45,23 @@ $action = GETPOST("action", 'alpha'); $cancel = GETPOST('cancel', 'alpha'); // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) $socid = $user->socid; -$feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); +$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); // Ok if user->rights->salaries->read or user->rights->hrm->read //$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2); -$ok=false; -if ($user->id == $id) $ok=true; // A user can always read its own card -if (! empty($user->rights->salaries->read)) $ok=true; -if (! empty($user->rights->hrm->read)) $ok=true; -if (! empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) $ok=true; -if (! $ok) +$ok = false; +if ($user->id == $id) $ok = true; // A user can always read its own card +if (!empty($user->rights->salaries->read)) $ok = true; +if (!empty($user->rights->hrm->read)) $ok = true; +if (!empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) $ok = true; +if (!$ok) { accessforbidden(); } $object = new User($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref, '', 1); $object->getrights(); @@ -72,7 +72,7 @@ if ($id > 0 || ! empty($ref)) * Actions */ -if ($action == 'add' && ! $cancel) +if ($action == 'add' && !$cancel) { // Modification $account = new UserBankAccount($db); @@ -94,10 +94,10 @@ if ($action == 'add' && ! $cancel) $result = $account->create($user); - if (! $result) + if (!$result) { setEventMessages($account->error, $account->errors, 'errors'); - $action='edit'; // Force chargement page edition + $action = 'edit'; // Force chargement page edition } else { @@ -106,14 +106,14 @@ if ($action == 'add' && ! $cancel) } } -if ($action == 'update' && ! $cancel) +if ($action == 'update' && !$cancel) { // Modification $account = new UserBankAccount($db); $account->fetch($bankid); - $account->userid = $object->id; + $account->userid = $object->id; $account->bank = GETPOST('bank', 'alpha'); $account->label = GETPOST('label', 'alpha'); @@ -130,10 +130,10 @@ if ($action == 'update' && ! $cancel) $result = $account->update($user); - if (! $result) + if (!$result) { setEventMessages($account->error, $account->errors, 'errors'); - $action='edit'; // Force chargement page edition + $action = 'edit'; // Force chargement page edition } else { @@ -154,7 +154,7 @@ llxHeader(null, $langs->trans("BankAccounts")); $head = user_prepare_head($object); $account = new UserBankAccount($db); -if (! $bankid) +if (!$bankid) { $account->fetch(0, '', $id); } @@ -162,7 +162,7 @@ else { $account->fetch($bankid); } -if (empty($account->userid)) $account->userid=$object->id; +if (empty($account->userid)) $account->userid = $object->id; if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) @@ -239,9 +239,9 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco } print ''.$langs->trans("IBAN").''; - print ''.$account->iban . ' '; - if (! empty($account->iban)) { - if (! checkIbanForAccount($account)) { + print ''.$account->iban.' '; + if (!empty($account->iban)) { + if (!checkIbanForAccount($account)) { print img_picto($langs->trans("IbanNotValid"), 'warning'); } else { print img_picto($langs->trans("IbanValid"), 'info'); @@ -251,8 +251,8 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print ''.$langs->trans("BIC").''; print ''.$account->bic.' '; - if (! empty($account->bic)) { - if (! checkSwiftForAccount($account)) { + if (!empty($account->bic)) { + if (!checkSwiftForAccount($account)) { print img_picto($langs->trans("SwiftNotValid"), 'warning'); } else { print img_picto($langs->trans("SwiftValid"), 'info'); @@ -275,7 +275,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print ''; // Check BBAN - if ($account->label && ! checkBanForAccount($account)) + if ($account->label && !checkBanForAccount($account)) { print '
    '.$langs->trans("RIBControlError").'
    '; } @@ -283,24 +283,24 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print '
    '; // Nbre max d'elements des petites listes - $MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT; + $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; /* * Last salaries */ - if (! empty($conf->salaries->enabled) && + if (!empty($conf->salaries->enabled) && ($user->rights->salaries->read && $object->id == $user->id) ) { $salary = new PaymentSalary($db); $sql = "SELECT ps.rowid, ps.datesp, ps.dateep, ps.amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as ps"; - $sql.= " WHERE ps.fk_user = ".$object->id; - $sql.= " AND ps.entity = ".$conf->entity; - $sql.= " ORDER BY ps.datesp DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as ps"; + $sql .= " WHERE ps.fk_user = ".$object->id; + $sql .= " AND ps.entity = ".$conf->entity; + $sql .= " ORDER BY ps.datesp DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -308,7 +308,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print ''; print ''; - print ''; + print ''; } } From 16c50c212cdd5ca88c7068c1af60cc14cd0f1817 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Nov 2019 19:16:10 +0100 Subject: [PATCH 229/299] Update paymentmodes.php --- htdocs/societe/paymentmodes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index fc9068b8127..23a7c30f77e 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1316,7 +1316,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' foreach ($balance->available as $cpt) { $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) { + if (!in_array($cpt->currency, $arrayzerounitcurrency)) { $currencybalance[$cpt->currency]['available'] = $cpt->amount / 100; } else { $currencybalance[$cpt->currency]['available'] = $cpt->amount; @@ -1330,7 +1330,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' foreach ($balance->pending as $cpt) { $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) { + if (!in_array($cpt->currency, $arrayzerounitcurrency)) { $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available']+$cpt->amount / 100; } else { $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available']+$cpt->amount; From 545c2207b27338e329b4729502212a2244658703 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Nov 2019 19:32:27 +0100 Subject: [PATCH 230/299] Fix on exact date when we don't know the second is useless --- htdocs/core/tpl/extrafields_list_search_input.tpl.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/htdocs/core/tpl/extrafields_list_search_input.tpl.php b/htdocs/core/tpl/extrafields_list_search_input.tpl.php index fb0a0dea3aa..141ae5ac34d 100644 --- a/htdocs/core/tpl/extrafields_list_search_input.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_input.tpl.php @@ -34,12 +34,8 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ } elseif (in_array($typeofextrafield, array('datetime','timestamp'))) { - // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') - $morecss=''; - if ($typeofextrafield == 'sellist') $morecss='maxwidth200'; - $keyprefix=$search_options_pattern; - if (substr($search_options_pattern, -8) === 'options_') $keyprefix = substr($search_options_pattern, 0, -8); - echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$tmpkey], '', '', $keyprefix, $morecss); + // TODO + // Use showInputField in a particular manner to have input with a comparison operator, not input for a specific value date-hour-minutes } else { From f4aaa8d9bb3bd8919c86b2948a975c7b2f3458ad Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Wed, 13 Nov 2019 18:34:37 +0000 Subject: [PATCH 231/299] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/accountancy/customer/index.php | 106 +- htdocs/accountancy/customer/lines.php | 182 +- htdocs/accountancy/supplier/index.php | 106 +- htdocs/accountancy/supplier/lines.php | 180 +- htdocs/api/class/api_setup.class.php | 502 ++-- htdocs/bom/tpl/objectline_view.tpl.php | 36 +- htdocs/core/class/ccountry.class.php | 106 +- htdocs/core/class/commonobject.class.php | 2522 ++++++++--------- htdocs/core/class/cunits.class.php | 146 +- htdocs/mrp/ajax/ajax_bom.php | 16 +- .../product/class/html.formproduct.class.php | 92 +- htdocs/projet/card.php | 380 +-- htdocs/takepos/ajax/ajax.php | 14 +- 13 files changed, 2194 insertions(+), 2194 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 2aa6072f2c2..3d73ea531b7 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -27,13 +27,13 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -41,16 +41,16 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); -$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); +$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -77,20 +77,20 @@ if ($action == 'clean' || $action == 'validatehistory') { // Clean database $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; $sql1 .= " SET fk_code_ventilation = 0"; $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN'; $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')'; - $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture WHERE entity = '.$conf->entity.')'; + $sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; + $sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')'; + $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture WHERE entity = '.$conf->entity.')'; $sql1 .= ' AND fk_code_ventilation <> 0'; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -121,26 +121,26 @@ if ($action == 'validatehistory') { // Customer Invoice lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; - $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; - $sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; - $sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; - $sql.= " co.code as country_code, co.label as country_label,"; - $sql.= " s.tva_intra"; - $sql.= " FROM " . MAIN_DB_PREFIX . "facture as f"; - $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; - $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; - $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; - $sql.= " AND l.product_type <= 2"; + $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; + $sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; + $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; + $sql .= " co.code as country_code, co.label as country_label,"; + $sql .= " s.tva_intra"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql .= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/customer/index.php'); $result = $db->query($sql); - if (! $result) { + if (!$result) { $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -172,12 +172,12 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { - $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; - $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; - $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; $resqlupdate = $db->query($sqlupdate); - if (! $resqlupdate) + if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); @@ -278,11 +278,11 @@ if ($resql) { } else print $row[1]; print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -338,7 +338,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -413,11 +413,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } $db->free($resql); @@ -465,11 +465,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } $db->free($resql); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 9d32bbaebf4..10742b863d2 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -26,16 +26,16 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","compta","accountancy","productbatch")); +$langs->loadLangs(array("bills", "compta", "accountancy", "productbatch")); $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); @@ -48,14 +48,14 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); -$search_day=GETPOST("search_day", "int"); -$search_month=GETPOST("search_month", "int"); -$search_year=GETPOST("search_year", "int"); +$search_day = GETPOST("search_day", "int"); +$search_month = GETPOST("search_month", "int"); +$search_year = GETPOST("search_year", "int"); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -63,9 +63,9 @@ if (empty($page) || $page < 0) $page = 0; $pageprev = $page - 1; $pagenext = $page + 1; $offset = $limit * $page; -if (! $sortfield) +if (!$sortfield) $sortfield = "f.datef, f.ref, fd.rowid"; -if (! $sortorder) { +if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { $sortorder = "DESC"; } @@ -74,7 +74,7 @@ if (! $sortorder) { // Security check if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); $formaccounting = new FormAccounting($db); @@ -105,27 +105,27 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; - if (! (GETPOST('account_parent', 'int') >= 0)) + if (!(GETPOST('account_parent', 'int') >= 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); } - if (! $error) + if (!$error) { $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); - $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as l"; + $sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); + $sql1 .= ' WHERE l.rowid IN ('.implode(',', $changeaccount).')'; - dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); + dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; setEventMessages($db->lasterror(), null, 'errors'); } - if (! $error) { + if (!$error) { $db->commit(); setEventMessages($langs->trans('Save'), null, 'mesgs'); } else { @@ -133,7 +133,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { setEventMessages($db->lasterror(), null, 'errors'); } - $account_parent = ''; // Protection to avoid to mass apply it a second time + $account_parent = ''; // Protection to avoid to mass apply it a second time } } @@ -145,7 +145,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $form = new Form($db); $formother = new FormOther($db); -llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched")); +llxHeader('', $langs->trans("CustomersVentilation").' - '.$langs->trans("Dispatched")); print ''."\n"; -print ''; -print ''; +print ''; +print ''; print ''; /* @@ -197,7 +197,7 @@ print ''; print '
    '; + print ''; print ''; @@ -342,19 +342,19 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco /* * Last holidays */ - if (! empty($conf->holiday->enabled) && + if (!empty($conf->holiday->enabled) && ($user->rights->holiday->read_all || ($user->rights->holiday->read && $object->id == $user->id)) ) { $holiday = new Holiday($db); $sql = "SELECT h.rowid, h.statut, h.fk_type, h.date_debut, h.date_fin, h.halfday"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as h"; - $sql.= " WHERE h.fk_user = ".$object->id; - $sql.= " AND h.entity = ".$conf->entity; - $sql.= " ORDER BY h.date_debut DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as h"; + $sql .= " WHERE h.fk_user = ".$object->id; + $sql .= " AND h.entity = ".$conf->entity; + $sql .= " ORDER BY h.date_debut DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -362,7 +362,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print '
    '.$langs->trans("LastSalaries", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllSalaries").''.$num.''; print '
    '.$langs->trans("LastSalaries", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllSalaries").''.$num.'
    '; print ''; - print ''.$langs->trans($val).''; + print ''.$langs->trans($val).''; print ''; print ''; } @@ -1843,7 +1843,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print ''; print '
    '; + print ''; print ''; @@ -376,7 +376,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco $holiday->id = $objp->rowid; $holiday->ref = $objp->rowid; $holiday->fk_type = $objp->fk_type; - $nbopenedday=num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday); + $nbopenedday = num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday); print $holiday->getNomUrl(1); print '\n"; @@ -398,19 +398,19 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco /* * Last expense report */ - if (! empty($conf->expensereport->enabled) && + if (!empty($conf->expensereport->enabled) && ($user->rights->expensereport->readall || ($user->rights->expensereport->lire && $object->id == $user->id)) ) { $exp = new ExpenseReport($db); $sql = "SELECT e.rowid, e.ref, e.fk_statut, e.date_debut, e.total_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e"; - $sql.= " WHERE e.fk_user_author = ".$object->id; - $sql.= " AND e.entity = ".$conf->entity; - $sql.= " ORDER BY e.date_debut DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e"; + $sql .= " WHERE e.fk_user_author = ".$object->id; + $sql .= " AND e.entity = ".$conf->entity; + $sql .= " ORDER BY e.date_debut DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -418,7 +418,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print '
    '.$langs->trans("LastHolidays", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllHolidays").''.$num.''; print '
    '.$langs->trans("LastHolidays", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllHolidays").''.$num.'
    '.dol_print_date($db->jdate($objp->date_debut), 'day')."
    '; print ''; - print ''; } - elseif($mysoc->localtax1_assuj=="1") + elseif ($mysoc->localtax1_assuj == "1") { print ''; } - elseif($mysoc->localtax2_assuj=="1") + elseif ($mysoc->localtax2_assuj == "1") { print ''; } // Type - Size print ''; @@ -1485,10 +1485,10 @@ else print ''; - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { print ''; print ''; } @@ -1499,18 +1499,18 @@ else print ''; print ''; print ''; } // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { $langs->load('categories'); // Customer //if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { - print '"; @@ -1518,7 +1518,7 @@ else // Supplier //if ($object->fournisseur) { - print '"; @@ -1526,7 +1526,7 @@ else } // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; print ''; @@ -1536,8 +1536,8 @@ else } // Other attributes - $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1550,7 +1550,7 @@ else print ''; @@ -1568,7 +1568,7 @@ else print '
    '; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -1576,7 +1576,7 @@ else else { print '     '; - print ''; + print ''; } print '
    '."\n"; @@ -1588,21 +1588,21 @@ else if ($socid) { - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); //if ($res < 0) { dol_print_error($db); exit; } $head = societe_prepare_head($object); // Load object modCodeTiers - $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); + $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module)-4); + $module = substr($module, 0, dol_strlen($module) - 4); } - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeClient = new $module($db); @@ -1611,15 +1611,15 @@ else { $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed(); } - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module)-4); + $module = substr($module, 0, dol_strlen($module) - 4); } - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeFournisseur = new $module($db); @@ -1634,25 +1634,25 @@ else if (GETPOSTISSET('name')) { // We overwrite with values if posted - $object->name = GETPOST('name', 'alpha'); + $object->name = GETPOST('name', 'alpha'); $object->prefix_comm = GETPOST('prefix_comm', 'alpha'); - $object->client = GETPOST('client', 'int'); + $object->client = GETPOST('client', 'int'); $object->code_client = GETPOST('customer_code', 'alpha'); $object->fournisseur = GETPOST('fournisseur', 'int'); - $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); - $object->address = GETPOST('address', 'alpha'); - $object->zip = GETPOST('zipcode', 'alpha'); - $object->town = GETPOST('town', 'alpha'); - $object->country_id = GETPOST('country_id')?GETPOST('country_id', 'int'):$mysoc->country_id; - $object->state_id = GETPOST('state_id', 'int'); + $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); + $object->address = GETPOST('address', 'alpha'); + $object->zip = GETPOST('zipcode', 'alpha'); + $object->town = GETPOST('town', 'alpha'); + $object->country_id = GETPOST('country_id') ?GETPOST('country_id', 'int') : $mysoc->country_id; + $object->state_id = GETPOST('state_id', 'int'); //$object->skype = GETPOST('skype', 'alpha'); //$object->twitter = GETPOST('twitter', 'alpha'); //$object->facebook = GETPOST('facebook', 'alpha'); //$object->linkedin = GETPOST('linkedin', 'alpha'); $object->socialnetworks = array(); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } @@ -1668,15 +1668,15 @@ else $object->idprof4 = GETPOST('idprof4', 'alpha'); $object->idprof5 = GETPOST('idprof5', 'alpha'); $object->idprof6 = GETPOST('idprof6', 'alpha'); - $object->typent_id = GETPOST('typent_id', 'int'); - $object->effectif_id = GETPOST('effectif_id', 'int'); + $object->typent_id = GETPOST('typent_id', 'int'); + $object->effectif_id = GETPOST('effectif_id', 'int'); $object->barcode = GETPOST('barcode', 'alpha'); - $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); - $object->default_lang = GETPOST('default_lang', 'alpha'); + $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); + $object->default_lang = GETPOST('default_lang', 'alpha'); $object->tva_assuj = GETPOST('assujtva_value', 'int'); $object->tva_intra = GETPOST('tva_intra', 'alpha'); - $object->status = GETPOST('status', 'int'); + $object->status = GETPOST('status', 'int'); // Webservices url/key $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL); @@ -1685,32 +1685,32 @@ else //Incoterms if (!empty($conf->incoterm->enabled)) { - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - $object->location_incoterms = GETPOST('lcoation_incoterms', 'alpha'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->location_incoterms = GETPOST('lcoation_incoterms', 'alpha'); } //Local Taxes $object->localtax1_assuj = GETPOST('localtax1assuj_value'); $object->localtax2_assuj = GETPOST('localtax2assuj_value'); - $object->localtax1_value =GETPOST('lt1'); - $object->localtax2_value =GETPOST('lt2'); + $object->localtax1_value = GETPOST('lt1'); + $object->localtax2_value = GETPOST('lt2'); // We set country_id, and country_code label of the chosen country if ($object->country_id > 0) { - $tmparray=getCountry($object->country_id, 'all'); - $object->country_code = $tmparray['code']; - $object->country = $tmparray['label']; + $tmparray = getCountry($object->country_id, 'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; } } - if($object->localtax1_assuj==0){ - $sub=0; - }else{$sub=1;} - if($object->localtax2_assuj==0){ - $sub2=0; - }else{$sub2=1;} + if ($object->localtax1_assuj == 0) { + $sub = 0; + } else {$sub = 1; } + if ($object->localtax2_assuj == 0) { + $sub2 = 0; + } else {$sub2 = 1; } if ($conf->use_javascript_ajax) { @@ -1755,7 +1755,7 @@ else }); function init_customer_categ() { console.log("is customer or prospect = "+jQuery("#customerprospect").val()); - if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || '.(empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER)?'1':'0').')) + if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || '.(empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER) ? '1' : '0').')) { jQuery(".visibleifcustomer").hide(); } @@ -1804,7 +1804,7 @@ else print '
    '; + print ''; print ''; @@ -472,7 +472,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco } // Edit -if ($id && ($action == 'edit' || $action == 'create' ) && $user->rights->user->user->creer) +if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->user->creer) { $title = $langs->trans("User"); dol_fiche_head($head, 'bank', $title, 0, 'user'); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 62aa5027cf4..3d80906003d 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -96,19 +96,19 @@ $pagenext = $page + 1; //if (! $sortfield) $sortfield='name'; //if (! $sortorder) $sortorder='ASC'; -if (empty($action)) $action='preview'; +if (empty($action)) $action = 'preview'; -$object=new Website($db); -$objectpage=new WebsitePage($db); +$object = new Website($db); +$objectpage = new WebsitePage($db); -$object->fetchAll(); // Init $object->records with list of websites +$object->fetchAll(); // Init $object->records with list of websites // If website not defined, we take first found -if (! ($websiteid > 0) && empty($websitekey)) +if (!($websiteid > 0) && empty($websitekey)) { - foreach($object->records as $key => $valwebsite) + foreach ($object->records as $key => $valwebsite) { - $websitekey=$valwebsite->ref; + $websitekey = $valwebsite->ref; break; } } @@ -137,15 +137,15 @@ if (($pageid > 0 || $pageref) && $action != 'addcontainer') { if ($object->fk_default_home > 0) { - $res = $objectpage->fetch($object->fk_default_home, $object->id, ''); // We search first page of web site + $res = $objectpage->fetch($object->fk_default_home, $object->id, ''); // We search first page of web site if ($res > 0) $pageid = $object->fk_default_home; } else { - $res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site + $res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site if ($res == 0) // Page was not found, we reset it { - $objectpage=new WebsitePage($db); + $objectpage = new WebsitePage($db); } else // We found a page, we set pageid to it. { @@ -166,61 +166,61 @@ if (empty($pageid) && empty($pageref) && $object->id > 0 && $action != 'createco $pageid = $object->fk_default_home; if (empty($pageid)) { - $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); - if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); - $atleastonepage=(is_array($array) && count($array) > 0); + $array = $objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); + if (!is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); + $atleastonepage = (is_array($array) && count($array) > 0); - $firstpageid=0;$homepageid=0; - foreach($array as $key => $valpage) + $firstpageid = 0; $homepageid = 0; + foreach ($array as $key => $valpage) { - if (empty($firstpageid)) $firstpageid=$valpage->id; - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; + if (empty($firstpageid)) $firstpageid = $valpage->id; + if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid = $valpage->id; } - $pageid=($homepageid?$homepageid:$firstpageid); // We choose home page and if not defined yet, we take first page + $pageid = ($homepageid ? $homepageid : $firstpageid); // We choose home page and if not defined yet, we take first page } } global $dolibarr_main_data_root; -$pathofwebsite=$dolibarr_main_data_root.'/website/'.$websitekey; -$filehtmlheader=$pathofwebsite.'/htmlheader.html'; -$filecss=$pathofwebsite.'/styles.css.php'; -$filejs=$pathofwebsite.'/javascript.js.php'; -$filerobot=$pathofwebsite.'/robots.txt'; -$filehtaccess=$pathofwebsite.'/.htaccess'; -$filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; -$fileindex=$pathofwebsite.'/index.php'; -$filewrapper=$pathofwebsite.'/wrapper.php'; -$filemanifestjson=$pathofwebsite.'/manifest.json.php'; -$filereadme=$pathofwebsite.'/README.md'; +$pathofwebsite = $dolibarr_main_data_root.'/website/'.$websitekey; +$filehtmlheader = $pathofwebsite.'/htmlheader.html'; +$filecss = $pathofwebsite.'/styles.css.php'; +$filejs = $pathofwebsite.'/javascript.js.php'; +$filerobot = $pathofwebsite.'/robots.txt'; +$filehtaccess = $pathofwebsite.'/.htaccess'; +$filetpl = $pathofwebsite.'/page'.$pageid.'.tpl.php'; +$fileindex = $pathofwebsite.'/index.php'; +$filewrapper = $pathofwebsite.'/wrapper.php'; +$filemanifestjson = $pathofwebsite.'/manifest.json.php'; +$filereadme = $pathofwebsite.'/README.md'; // Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current $permtouploadfile = $user->rights->website->write; $diroutput = $conf->medias->multidir_output[$conf->entity]; -$relativepath=$section_dir; +$relativepath = $section_dir; $upload_dir = $diroutput.'/'.$relativepath; $htmlheadercontentdefault = ''; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; $manifestjsoncontentdefault = ''; -$manifestjsoncontentdefault.= '{ +$manifestjsoncontentdefault .= '{ "name": "MyWebsite", "short_name": "MyWebsite", "start_url": "/", @@ -305,17 +305,17 @@ if ($cancel) } $savbacktopage = $backtopage; -$backtopage = $_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid.(GETPOST('section_dir', 'alpha')?'§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')):''); // used after a confirm_deletefile into actions_linkedfiles.inc.php +$backtopage = $_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid.(GETPOST('section_dir', 'alpha') ? '§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')) : ''); // used after a confirm_deletefile into actions_linkedfiles.inc.php include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $backtopage = $savbacktopage; -if ($action == 'renamefile') $action='file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' +if ($action == 'renamefile') $action = 'file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' if ($action == 'seteditinline') { dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 1); setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings'); - dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content' + dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content' header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); exit; } @@ -328,7 +328,7 @@ if ($action == 'unseteditinline') if ($action == 'setshowsubcontainers') { dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 1); - dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 0); // Force disable of edit inline + dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 0); // Force disable of edit inline header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); exit; } @@ -374,28 +374,28 @@ if ($action == 'addsite') { $db->begin(); - if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) + if (GETPOST('virtualhost', 'alpha') && !preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) { $error++; setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); } - if (! $error && ! GETPOST('WEBSITE_REF', 'alpha')) + if (!$error && !GETPOST('WEBSITE_REF', 'alpha')) { $error++; $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); } - if (! $error && ! preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF', 'alpha'))) + if (!$error && !preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF', 'alpha'))) { $error++; $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("Ref")), null, 'errors'); } - if (! $error) + if (!$error) { - $tmpobject=new Website($db); + $tmpobject = new Website($db); $tmpobject->ref = GETPOST('WEBSITE_REF', 'alpha'); $tmpobject->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); $tmpobject->virtualhost = GETPOST('virtualhost', 'alpha'); @@ -408,11 +408,11 @@ if ($action == 'addsite') } } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SiteAdded", $object->ref), null, 'mesgs'); - $action=''; + $action = ''; header("Location: ".$_SERVER["PHP_SELF"].'?website='.$tmpobject->ref); exit; @@ -420,10 +420,10 @@ if ($action == 'addsite') else { $db->rollback(); - $action='createsite'; + $action = 'createsite'; } - if (! $error) + if (!$error) { $action = 'preview'; $id = $object->id; @@ -440,9 +440,9 @@ if ($action == 'addcontainer') $objectpage->fk_website = $object->id; if (GETPOSTISSET('fetchexternalurl')) { - $urltograb=GETPOST('externalurl', 'alpha'); - $grabimages=GETPOST('grabimages', 'alpha'); - $grabimagesinto=GETPOST('grabimagesinto', 'alpha'); + $urltograb = GETPOST('externalurl', 'alpha'); + $grabimages = GETPOST('grabimages', 'alpha'); + $grabimagesinto = GETPOST('grabimagesinto', 'alpha'); //var_dump($grabimages);exit; } @@ -457,7 +457,7 @@ if ($action == 'addcontainer') setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); $action = 'createcontainer'; } - elseif (! preg_match('/^http/', $urltograb)) + elseif (!preg_match('/^http/', $urltograb)) { $error++; $langs->load("errors"); @@ -465,16 +465,16 @@ if ($action == 'addcontainer') $action = 'createcontainer'; } - if (! $error) + if (!$error) { // Clean url to grab, so url can be // http://www.example.com/ or http://www.example.com/dir1/ or http://www.example.com/dir1/aaa $urltograbwithoutdomainandparam = preg_replace('/^https?:\/\/[^\/]+\/?/i', '', $urltograb); //$urltograbwithoutdomainandparam = preg_replace('/^file:\/\/[^\/]+\/?/i', '', $urltograb); $urltograbwithoutdomainandparam = preg_replace('/\?.*$/', '', $urltograbwithoutdomainandparam); - if (empty($urltograbwithoutdomainandparam) && ! preg_match('/\/$/', $urltograb)) + if (empty($urltograbwithoutdomainandparam) && !preg_match('/\/$/', $urltograb)) { - $urltograb.='/'; + $urltograb .= '/'; } $pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/', '-', preg_replace('/\/+$/', '', $urltograbwithoutdomainandparam))); @@ -493,31 +493,31 @@ if ($action == 'addcontainer') { setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors'); $error++; - $action='createcontainer'; + $action = 'createcontainer'; } } - if (! $error) + if (!$error) { $tmp = getURLContent($urltograb); if ($tmp['curl_error_no']) { $error++; setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors'); - $action='createcontainer'; + $action = 'createcontainer'; } elseif ($tmp['http_code'] != '200') { $error++; setEventMessages('Error getting '.$urltograb.': '.$tmp['http_code'], null, 'errors'); - $action='createcontainer'; + $action = 'createcontainer'; } else { // Remove comments $tmp['content'] = removeHtmlComment($tmp['content']); - $regs=array(); + $regs = array(); preg_match('/(.*)<\/head>/ims', $tmp['content'], $regs); $head = $regs[1]; @@ -527,21 +527,21 @@ if ($action == 'addcontainer') if (empty($objectpage->pageurl)) { $tmpdomain = getDomainFromURL($urltograb); - $objectpage->pageurl=$tmpdomain.'-home'; + $objectpage->pageurl = $tmpdomain.'-home'; } $objectpage->aliasalt = ''; if (preg_match('/^(\d+)\-/', basename($urltograb), $regs)) $objectpage->aliasalt = $regs[1]; - $regtmp=array(); + $regtmp = array(); if (preg_match('/(.*)<\/title>/ims', $head, $regtmp)) { $objectpage->title = $regtmp[1]; } if (preg_match('/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) { - if (empty($objectpage->title)) $objectpage->title = $regtmp[1]; // If title not found into <title>, we get it from <meta title> + if (empty($objectpage->title)) $objectpage->title = $regtmp[1]; // If title not found into <title>, we get it from <meta title> } if (preg_match('/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) { @@ -553,7 +553,7 @@ if ($action == 'addcontainer') } if (preg_match('/<html\s+lang="([^"]+)"/ims', $tmp['content'], $regtmp)) { - $tmplang=explode('-', $regtmp[1]); + $tmplang = explode('-', $regtmp[1]); $objectpage->lang = $tmplang[0].($tmplang[1] ? '_'.strtoupper($tmplang[1]) : ''); } @@ -563,7 +563,7 @@ if ($action == 'addcontainer') $objectpage->content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $objectpage->content); $objectpage->content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $objectpage->content); - $absoluteurlinaction=$urltograbdirwithoutslash; + $absoluteurlinaction = $urltograbdirwithoutslash; // TODO Replace 'action="$urltograbdirwithoutslash' into action="/" // TODO Replace 'action="$urltograbdirwithoutslash..."' into action="..." // TODO Replace 'a href="$urltograbdirwithoutslash' into a href="/" @@ -598,11 +598,11 @@ if ($action == 'addcontainer') $linkwithoutdomain = $regs[2][$key]; if (preg_match('/^\//', $regs[2][$key])) { - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot } else { - $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file + $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file } //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; @@ -667,11 +667,11 @@ if ($action == 'addcontainer') $linkwithoutdomain = $regs[2][$key]; if (preg_match('/^\//', $regs[2][$key])) { - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot } else { - $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file + $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file } //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; @@ -696,14 +696,14 @@ if ($action == 'addcontainer') $errorforsubresource++; setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']); - $action='createcontainer'; + $action = 'createcontainer'; } elseif ($tmpgeturl['http_code'] != '200') { $errorforsubresource++; setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']); - $action='createcontainer'; + $action = 'createcontainer'; } else { @@ -726,7 +726,7 @@ if ($action == 'addcontainer') // @chmod($file, octdec($conf->global->MAIN_UMASK)); // $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; - $pagecsscontent.='/* Content of file '.$urltograbbis.' */'."\n"; + $pagecsscontent .= '/* Content of file '.$urltograbbis.' */'."\n"; getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl['content'], $action, 1, $grabimages, $grabimagesinto); @@ -738,19 +738,19 @@ if ($action == 'addcontainer') $contentforlessc = $lesscobj->compile($contentforlessc); //var_dump($contentforlessc); exit; - $pagecsscontent.=$contentforlessc."\n"; + $pagecsscontent .= $contentforlessc."\n"; //$pagecsscontent.=$tmpgeturl['content']."\n"; } catch (exception $e) { //echo "failed to compile lessc"; dol_syslog("Failed to compile the CSS from URL ".$urltograbbis." with lessc: ".$e->getMessage(), LOG_WARNING); - $pagecsscontent.=$tmpgeturl['content']."\n"; + $pagecsscontent .= $tmpgeturl['content']."\n"; } $objectpage->htmlheader = preg_replace('/'.preg_quote($regs[0][$key], '/').'\n*/ims', '', $objectpage->htmlheader); } } - $pagecsscontent.='</style>'; + $pagecsscontent .= '</style>'; //var_dump($pagecsscontent); //print dol_escape_htmltag($tmp);exit; @@ -786,11 +786,11 @@ if ($action == 'addcontainer') $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); $objectpage->htmlheader = GETPOST('htmlheader', 'none'); - $substitutionarray=array(); - $substitutionarray['__WEBSITE_CREATE_BY__']=$user->getFullName($langs); + $substitutionarray = array(); + $substitutionarray['__WEBSITE_CREATE_BY__'] = $user->getFullName($langs); $sample = GETPOST('sample', 'alpha'); - if (empty($sample)) $sample='empty'; + if (empty($sample)) $sample = 'empty'; $pathtosample = DOL_DOCUMENT_ROOT.'/website/samples/page-sample-'.$sample.'.html'; @@ -798,57 +798,57 @@ if ($action == 'addcontainer') $objectpage->content = make_substitutions(@file_get_contents($pathtosample), $substitutionarray); } - if (! $error) + if (!$error) { if (empty($objectpage->pageurl)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); $error++; - $action='createcontainer'; + $action = 'createcontainer'; } - elseif (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) + elseif (!preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) { $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); $error++; - $action='createcontainer'; + $action = 'createcontainer'; } if (empty($objectpage->title)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE")), null, 'errors'); $error++; - $action='createcontainer'; + $action = 'createcontainer'; } } - if (! $error) + if (!$error) { $res = $objectpage->create($user); if ($res <= 0) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); - $action='createcontainer'; + $action = 'createcontainer'; } } - if (! $error) + if (!$error) { - if (! empty($objectpage->content)) + if (!empty($objectpage->content)) { - $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; - $filetpl=$pathofwebsite.'/page'.$objectpage->id.'.tpl.php'; + $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; + $filetpl = $pathofwebsite.'/page'.$objectpage->id.'.tpl.php'; // Save page alias - $result=dolSavePageAlias($filealias, $object, $objectpage); - if (! $result) + $result = dolSavePageAlias($filealias, $object, $objectpage); + if (!$result) { setEventMessages('Failed to write file '.$filealias, null, 'errors'); } // Save page of content - $result=dolSavePageContent($filetpl, $object, $objectpage); + $result = dolSavePageContent($filetpl, $object, $objectpage); if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); @@ -860,75 +860,75 @@ if ($action == 'addcontainer') } } } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs'); - $action=''; + $action = ''; } else { $db->rollback(); } - if (! $error) + if (!$error) { $pageid = $objectpage->id; // To generate the CSS, robot and htmlheader file. // Check symlink to medias and restore it if ko - $pathtomedias=DOL_DATA_ROOT.'/medias'; - $pathtomediasinwebsite=$pathofwebsite.'/medias'; - if (! is_link(dol_osencode($pathtomediasinwebsite))) + $pathtomedias = DOL_DATA_ROOT.'/medias'; + $pathtomediasinwebsite = $pathofwebsite.'/medias'; + if (!is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); - dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists $result = symlink($pathtomedias, $pathtomediasinwebsite); } - if (! dol_is_file($filehtmlheader)) + if (!dol_is_file($filehtmlheader)) { - $htmlheadercontent ="<html>\n"; - $htmlheadercontent.=$htmlheadercontentdefault; - $htmlheadercontent.="</html>"; - $result=dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); + $htmlheadercontent = "<html>\n"; + $htmlheadercontent .= $htmlheadercontentdefault; + $htmlheadercontent .= "</html>"; + $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); } - if (! dol_is_file($filecss)) + if (!dol_is_file($filecss)) { $csscontent = "/* CSS content (all pages) */\nbody.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; - $result=dolSaveCssFile($filecss, $csscontent); + $result = dolSaveCssFile($filecss, $csscontent); } - if (! dol_is_file($filejs)) + if (!dol_is_file($filejs)) { $jscontent = "/* JS content (all pages) */\n"; - $result=dolSaveJsFile($filejs, $jscontent); + $result = dolSaveJsFile($filejs, $jscontent); } - if (! dol_is_file($filerobot)) + if (!dol_is_file($filerobot)) { $robotcontent = "# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/"; - $result=dolSaveRobotFile($filerobot, $robotcontent); + $result = dolSaveRobotFile($filerobot, $robotcontent); } - if (! dol_is_file($filehtaccess)) + if (!dol_is_file($filehtaccess)) { $htaccesscontent = "# Order allow,deny\n# Deny from all"; - $result=dolSaveHtaccessFile($filehtaccess, $htaccesscontent); + $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent); } - if (! dol_is_file($filemanifestjson)) + if (!dol_is_file($filemanifestjson)) { $manifestjsoncontent = ""; - $result=dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); + $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); } - if (! dol_is_file($filereadme)) + if (!dol_is_file($filereadme)) { $readmecontent = "Website generated by Dolibarr ERP CRM"; - $result=dolSaveReadme($filereadme, $readmecontent); + $result = dolSaveReadme($filereadme, $readmecontent); } $action = 'preview'; @@ -954,23 +954,23 @@ if ($action == 'confirm_deletesite' && $confirm == 'yes') setEventMessages($object->error, $object->errors, 'errors'); } } - if (! $error) + if (!$error) { if (GETPOST('delete_also_js', 'alpha') == 'on') { - $pathofwebsitejs=DOL_DATA_ROOT.'/medias/js/'.$object->ref; + $pathofwebsitejs = DOL_DATA_ROOT.'/medias/js/'.$object->ref; dol_delete_dir_recursive($pathofwebsitejs); } if (GETPOST('delete_also_medias', 'alpha') == 'on') { - $pathofwebsitemedias=DOL_DATA_ROOT.'/medias/image/'.$object->ref; + $pathofwebsitemedias = DOL_DATA_ROOT.'/medias/image/'.$object->ref; dol_delete_dir_recursive($pathofwebsitemedias); } } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SiteDeleted", $object->ref), null, 'mesgs'); @@ -1007,7 +1007,7 @@ if ($action == 'delete') } } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $websitekey), null, 'mesgs'); @@ -1026,9 +1026,9 @@ if ($action == 'delete') if ($action == 'updatecss') { // If we tried to reload another site/page, we stay on editcss mode. - if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) + if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) { - $action='editcss'; + $action = 'editcss'; } else { @@ -1037,14 +1037,14 @@ if ($action == 'updatecss') if (GETPOSTISSET('virtualhost')) { - if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) + if (GETPOST('virtualhost', 'alpha') && !preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) { $error++; setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); - $action='editcss'; + $action = 'editcss'; } - if (! $error) + if (!$error) { $object->virtualhost = GETPOST('virtualhost', 'alpha'); @@ -1053,15 +1053,15 @@ if ($action == 'updatecss') { $error++; setEventMessages($object->error, $object->errors, 'errors'); - $action='editcss'; + $action = 'editcss'; } } } - if (! $error) + if (!$error) { // Save master.inc.php file - $filemaster=$pathofwebsite.'/master.inc.php'; + $filemaster = $pathofwebsite.'/master.inc.php'; dol_syslog("Save master file ".$filemaster); @@ -1069,7 +1069,7 @@ if ($action == 'updatecss') // Now generate the master.inc.php page $result = dolSaveMasterFile($filemaster); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filemaster, null, 'errors'); @@ -1077,7 +1077,7 @@ if ($action == 'updatecss') // Html header file - $htmlheadercontent =''; + $htmlheadercontent = ''; /* We disable php code since htmlheader is never executed as an include but only read by fgets_content. $htmlheadercontent.= "<?php // BEGIN PHP\n"; @@ -1089,7 +1089,7 @@ if ($action == 'updatecss') // $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page $htmlheadercontent.= "// END PHP ?>\n";*/ - $htmlheadercontent.= preg_replace(array('/<html>\n*/ims','/<\/html>\n*/ims'), array('',''), GETPOST('WEBSITE_HTML_HEADER', 'none')); + $htmlheadercontent .= preg_replace(array('/<html>\n*/ims', '/<\/html>\n*/ims'), array('', ''), GETPOST('WEBSITE_HTML_HEADER', 'none')); /*$htmlheadercontent.= "\n".'<?php // BEGIN PHP'."\n"; $htmlheadercontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n"; @@ -1098,7 +1098,7 @@ if ($action == 'updatecss') $htmlheadercontent = trim($htmlheadercontent)."\n"; $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); @@ -1106,30 +1106,30 @@ if ($action == 'updatecss') // Css file - $csscontent =''; + $csscontent = ''; - $csscontent.= "<?php // BEGIN PHP\n"; - $csscontent.= '$websitekey=basename(__DIR__);'."\n"; - $csscontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. - $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; - $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; - $csscontent.= "ob_start();\n"; - $csscontent.= "if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n"; - $csscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; - $csscontent.= "header('Content-type: text/css');\n"; - $csscontent.= "}\n"; - $csscontent.= "// END PHP ?>\n"; + $csscontent .= "<?php // BEGIN PHP\n"; + $csscontent .= '$websitekey=basename(__DIR__);'."\n"; + $csscontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. + $csscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; + $csscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; + $csscontent .= "ob_start();\n"; + $csscontent .= "if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n"; + $csscontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; + $csscontent .= "header('Content-type: text/css');\n"; + $csscontent .= "}\n"; + $csscontent .= "// END PHP ?>\n"; - $csscontent.= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n"; + $csscontent .= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n"; - $csscontent.= '<?php // BEGIN PHP'."\n"; - $csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n"; - $csscontent.= "// END PHP ?>"."\n"; + $csscontent .= '<?php // BEGIN PHP'."\n"; + $csscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n"; + $csscontent .= "// END PHP ?>"."\n"; dol_syslog("Save css content into ".$filecss); $result = dolSaveCssFile($filecss, $csscontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filecss, null, 'errors'); @@ -1137,26 +1137,26 @@ if ($action == 'updatecss') // Js file - $jscontent =''; + $jscontent = ''; - $jscontent.= "<?php // BEGIN PHP\n"; - $jscontent.= '$websitekey=basename(__DIR__);'."\n"; - $jscontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. - $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; - $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; - $jscontent.= "ob_start();\n"; - $jscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; - $jscontent.= "header('Content-type: application/javascript');\n"; - $jscontent.= "// END PHP ?>\n"; + $jscontent .= "<?php // BEGIN PHP\n"; + $jscontent .= '$websitekey=basename(__DIR__);'."\n"; + $jscontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. + $jscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; + $jscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; + $jscontent .= "ob_start();\n"; + $jscontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; + $jscontent .= "header('Content-type: application/javascript');\n"; + $jscontent .= "// END PHP ?>\n"; - $jscontent.= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n"; + $jscontent .= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n"; - $jscontent.= '<?php // BEGIN PHP'."\n"; - $jscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n"; - $jscontent.= "// END PHP ?>"."\n"; + $jscontent .= '<?php // BEGIN PHP'."\n"; + $jscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n"; + $jscontent .= "// END PHP ?>"."\n"; $result = dolSaveJsFile($filejs, $jscontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filejs, null, 'errors'); @@ -1164,7 +1164,7 @@ if ($action == 'updatecss') // Robot file - $robotcontent =''; + $robotcontent = ''; /*$robotcontent.= "<?php // BEGIN PHP\n"; $robotcontent.= '$websitekey=basename(__DIR__);'."\n"; @@ -1176,14 +1176,14 @@ if ($action == 'updatecss') $robotcontent.= "header('Content-type: text/css');\n"; $robotcontent.= "// END PHP ?>\n";*/ - $robotcontent.= trim(GETPOST('WEBSITE_ROBOT', 'none'))."\n"; + $robotcontent .= trim(GETPOST('WEBSITE_ROBOT', 'none'))."\n"; /*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n"; $robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n"; $robotcontent.= "// END PHP ?>"."\n";*/ $result = dolSaveRobotFile($filerobot, $robotcontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filerobot, null, 'errors'); @@ -1191,11 +1191,11 @@ if ($action == 'updatecss') // Htaccess file - $htaccesscontent =''; - $htaccesscontent.= trim(GETPOST('WEBSITE_HTACCESS', 'none'))."\n"; + $htaccesscontent = ''; + $htaccesscontent .= trim(GETPOST('WEBSITE_HTACCESS', 'none'))."\n"; $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); @@ -1203,26 +1203,26 @@ if ($action == 'updatecss') // manifest.json file - $manifestjsoncontent =''; + $manifestjsoncontent = ''; - $manifestjsoncontent.= "<?php // BEGIN PHP\n"; - $manifestjsoncontent.= '$websitekey=basename(__DIR__);'."\n"; - $manifestjsoncontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. - $manifestjsoncontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; - $manifestjsoncontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; - $manifestjsoncontent.= "ob_start();\n"; - $manifestjsoncontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; - $manifestjsoncontent.= "header('Content-type: application/manifest+json');\n"; - $manifestjsoncontent.= "// END PHP ?>\n"; + $manifestjsoncontent .= "<?php // BEGIN PHP\n"; + $manifestjsoncontent .= '$websitekey=basename(__DIR__);'."\n"; + $manifestjsoncontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. + $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; + $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; + $manifestjsoncontent .= "ob_start();\n"; + $manifestjsoncontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; + $manifestjsoncontent .= "header('Content-type: application/manifest+json');\n"; + $manifestjsoncontent .= "// END PHP ?>\n"; - $manifestjsoncontent.= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n"; + $manifestjsoncontent .= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n"; - $manifestjsoncontent.= '<?php // BEGIN PHP'."\n"; - $manifestjsoncontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; - $manifestjsoncontent.= "// END PHP ?>"."\n"; + $manifestjsoncontent .= '<?php // BEGIN PHP'."\n"; + $manifestjsoncontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; + $manifestjsoncontent .= "// END PHP ?>"."\n"; $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors'); @@ -1230,7 +1230,7 @@ if ($action == 'updatecss') // README.md file - $readmecontent =''; + $readmecontent = ''; /*$readmecontent.= "<?php // BEGIN PHP\n"; $readmecontent.= '$websitekey=basename(__DIR__);'."\n"; @@ -1242,14 +1242,14 @@ if ($action == 'updatecss') $readmecontent.= "header('Content-type: application/manifest+json');\n"; $readmecontent.= "// END PHP ?>\n";*/ - $readmecontent.= trim(GETPOST('WEBSITE_README', 'none'))."\n"; + $readmecontent .= trim(GETPOST('WEBSITE_README', 'none'))."\n"; /*$readmecontent.= '<?php // BEGIN PHP'."\n"; $readmecontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; $readmecontent.= "// END PHP ?>"."\n";*/ $result = dolSaveReadme($filereadme, $readmecontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filereadme, null, 'errors'); @@ -1257,14 +1257,14 @@ if ($action == 'updatecss') // Message if no error - if (! $error) + if (!$error) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); } - if (! GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect + if (!GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect { - $action='preview'; + $action = 'preview'; if ($backtopage) { header("Location: ".$backtopage); @@ -1288,13 +1288,13 @@ if ($action == 'setashome') $object->fk_default_home = $pageid; $res = $object->update($user); - if (! $res > 0) + if (!$res > 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } - if (! $error) + if (!$error) { $db->commit(); @@ -1305,7 +1305,7 @@ if ($action == 'setashome') if ($result) setEventMessages($langs->trans("Saved"), null, 'mesgs'); else setEventMessages('Failed to write file '.$fileindex, null, 'errors'); - $action='preview'; + $action = 'preview'; } else { @@ -1324,12 +1324,12 @@ if ($action == 'updatemeta') $objectpage->fk_website = $object->id; // Check parameters - if (! preg_match('/^[a-z0-9\-\_]+$/i', GETPOST('WEBSITE_PAGENAME', 'alpha'))) + if (!preg_match('/^[a-z0-9\-\_]+$/i', GETPOST('WEBSITE_PAGENAME', 'alpha'))) { $error++; $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); - $action='editmeta'; + $action = 'editmeta'; } $res = $objectpage->fetch($pageid, $object->id); @@ -1340,9 +1340,9 @@ if ($action == 'updatemeta') } // Check alias not exists - if (! $error && GETPOST('WEBSITE_PAGENAME', 'alpha')) + if (!$error && GETPOST('WEBSITE_PAGENAME', 'alpha')) { - $websitepagetemp=new WebsitePage($db); + $websitepagetemp = new WebsitePage($db); $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, GETPOST('WEBSITE_PAGENAME', 'alpha')); if ($result < 0) { @@ -1359,11 +1359,11 @@ if ($action == 'updatemeta') $action = 'editmeta'; } } - if (! $error && GETPOST('WEBSITE_ALIASALT', 'alpha')) + if (!$error && GETPOST('WEBSITE_ALIASALT', 'alpha')) { - $arrayofaliastotest=explode(',', GETPOST('WEBSITE_ALIASALT', 'alpha')); - $websitepagetemp=new WebsitePage($db); - foreach($arrayofaliastotest as $aliastotest) + $arrayofaliastotest = explode(',', GETPOST('WEBSITE_ALIASALT', 'alpha')); + $websitepagetemp = new WebsitePage($db); + foreach ($arrayofaliastotest as $aliastotest) { $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, $aliastotest); if ($result < 0) @@ -1385,7 +1385,7 @@ if ($action == 'updatemeta') } } - if (! $error) + if (!$error) { $objectpage->old_object = clone $objectpage; @@ -1400,11 +1400,11 @@ if ($action == 'updatemeta') $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); $objectpage->fk_page = GETPOST('pageidfortranslation', 'int'); - $newdatecreation=dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int')); + $newdatecreation = dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int')); if ($newdatecreation) $objectpage->date_creation = $newdatecreation; $res = $objectpage->update($user); - if (! ($res > 0)) + if (!($res > 0)) { $langs->load("errors"); if ($db->lasterrno == 'DB_ERROR_RECORD_ALREADY_EXISTS') @@ -1424,7 +1424,7 @@ if ($action == 'updatemeta') } } - if (! $error) + if (!$error) { $db->commit(); } @@ -1433,32 +1433,32 @@ if ($action == 'updatemeta') $db->rollback(); } - if (! $error) + if (!$error) { - $filemaster=$pathofwebsite.'/master.inc.php'; - $fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; - $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; + $filemaster = $pathofwebsite.'/master.inc.php'; + $fileoldalias = $pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; + $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; dol_mkdir($pathofwebsite); // Now generate the master.inc.php page $result = dolSaveMasterFile($filemaster); - if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); + if (!$result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); // Now delete the alias.php page - if (! empty($fileoldalias)) + if (!empty($fileoldalias)) { dol_syslog("We delete old alias page name=".$fileoldalias." to build a new alias page=".$filealias); dol_delete_file($fileoldalias); } // Now delete the alternative alias.php pages - if (! empty($objectpage->old_object->aliasalt)) + if (!empty($objectpage->old_object->aliasalt)) { - $tmpaltaliases=explode(',', $objectpage->old_object->aliasalt); + $tmpaltaliases = explode(',', $objectpage->old_object->aliasalt); if (is_array($tmpaltaliases)) { - foreach($tmpaltaliases as $tmpaliasalt) + foreach ($tmpaltaliases as $tmpaliasalt) { dol_syslog("We delete old alt alias pages name=".trim($tmpaliasalt)); dol_delete_file($pathofwebsite.'/'.trim($tmpaliasalt).'.php'); @@ -1467,20 +1467,20 @@ if ($action == 'updatemeta') } // Save page alias - $result=dolSavePageAlias($filealias, $object, $objectpage); - if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); + $result = dolSavePageAlias($filealias, $object, $objectpage); + if (!$result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); // Save alt aliases - if (! empty($objectpage->aliasalt)) + if (!empty($objectpage->aliasalt)) { - $tmpaltaliases=explode(',', $objectpage->aliasalt); + $tmpaltaliases = explode(',', $objectpage->aliasalt); if (is_array($tmpaltaliases)) { - foreach($tmpaltaliases as $tmpaliasalt) + foreach ($tmpaltaliases as $tmpaliasalt) { if (trim($tmpaliasalt)) { - $result=dolSavePageAlias($pathofwebsite.'/'.trim($tmpaliasalt).'.php', $object, $objectpage); - if (! $result) setEventMessages('Failed to write file '.$pathofwebsite.'/'.trim($tmpaliasalt).'.php', null, 'errors'); + $result = dolSavePageAlias($pathofwebsite.'/'.trim($tmpaliasalt).'.php', $object, $objectpage); + if (!$result) setEventMessages('Failed to write file '.$pathofwebsite.'/'.trim($tmpaliasalt).'.php', null, 'errors'); } } } @@ -1488,7 +1488,7 @@ if ($action == 'updatemeta') // Save page of content - $result=dolSavePageContent($filetpl, $object, $objectpage); + $result = dolSavePageContent($filetpl, $object, $objectpage); if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); @@ -1502,7 +1502,7 @@ if ($action == 'updatemeta') //exit; } - $action='preview'; + $action = 'preview'; } } @@ -1518,12 +1518,12 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $db->begin(); $objectnew = new Website($db); - $result = $objectnew->createFromClone($user, GETPOST('id', 'int'), GETPOST('siteref', 'aZ09'), (GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):'')); + $result = $objectnew->createFromClone($user, GETPOST('id', 'int'), GETPOST('siteref', 'aZ09'), (GETPOST('newlang', 'aZ09') ?GETPOST('newlang', 'aZ09') : '')); if ($result < 0) { $error++; setEventMessages($objectnew->error, $objectnew->errors, 'errors'); - $action='preview'; + $action = 'preview'; $db->rollback(); } @@ -1540,25 +1540,25 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf if ($action == 'confirm_createpagefromclone') { - $istranslation=(GETPOST('is_a_translation', 'aZ09')=='on'?1:0); + $istranslation = (GETPOST('is_a_translation', 'aZ09') == 'on' ? 1 : 0); if ($istranslation) { if (GETPOST('newlang', 'aZ09') == $objectpage->lang) { $error++; setEventMessages($langs->trans("LanguageMustNotBeSameThanClonedPage"), null, 'errors'); - $action='preview'; + $action = 'preview'; } } - if (! $error) + if (!$error) { $db->begin(); $newwebsiteid = GETPOST('newwebsite', 'int'); $pathofwebsitenew = $pathofwebsite; - $tmpwebsite=new Website($db); + $tmpwebsite = new Website($db); if ($newwebsiteid > 0 && $newwebsiteid != $object->id) { $tmpwebsite->fetch($newwebsiteid); @@ -1570,20 +1570,20 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf } $objectpage = new WebsitePage($db); - $resultpage = $objectpage->createFromClone($user, $pageid, GETPOST('pageurl', 'aZ09'), (GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):''), $istranslation, $newwebsiteid); + $resultpage = $objectpage->createFromClone($user, $pageid, GETPOST('pageurl', 'aZ09'), (GETPOST('newlang', 'aZ09') ?GETPOST('newlang', 'aZ09') : ''), $istranslation, $newwebsiteid); if ($resultpage < 0) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); - $action='createpagefromclone'; + $action = 'createpagefromclone'; $db->rollback(); } else { - $fileindex=$pathofwebsitenew.'/index.php'; - $filetpl=$pathofwebsitenew.'/page'.$resultpage->id.'.tpl.php'; - $filewrapper=$pathofwebsitenew.'/wrapper.php'; + $fileindex = $pathofwebsitenew.'/index.php'; + $filetpl = $pathofwebsitenew.'/page'.$resultpage->id.'.tpl.php'; + $filewrapper = $pathofwebsitenew.'/wrapper.php'; //var_dump($pathofwebsitenew); //var_dump($filetpl); @@ -1604,15 +1604,15 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $res = 0; - if (! $error) + if (!$error) { // Check symlink to medias and restore it if ko - $pathtomedias=DOL_DATA_ROOT.'/medias'; - $pathtomediasinwebsite=$pathofwebsite.'/medias'; - if (! is_link(dol_osencode($pathtomediasinwebsite))) + $pathtomedias = DOL_DATA_ROOT.'/medias'; + $pathtomediasinwebsite = $pathofwebsite.'/medias'; + if (!is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); - dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists $result = symlink($pathtomedias, $pathtomediasinwebsite); } @@ -1630,19 +1630,19 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf } else { - $res=0; + $res = 0; if ($object->fk_default_home > 0) { $res = $objectpage->fetch($object->fk_default_home); } - if (! ($res > 0)) + if (!($res > 0)) { $res = $objectpage->fetch(0, $object->id); } } } - if (! $error && $res > 0) + if (!$error && $res > 0) { if ($action == 'updatesource' || $action == 'updatecontent') { @@ -1655,12 +1655,12 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf // Security analysis $phpfullcodestring = dolKeepOnlyPhpCode($objectpage->content); //print dol_escape_htmltag($phpfullcodestring);exit; - $forbiddenphpcommands=array("exec", "passthru", "system", "shell_exec", "proc_open"); + $forbiddenphpcommands = array("exec", "passthru", "system", "shell_exec", "proc_open"); if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) // If option is not on, we disallow functions to write files { - $forbiddenphpcommands=array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); + $forbiddenphpcommands = array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); } - foreach($forbiddenphpcommands as $forbiddenphpcommand) + foreach ($forbiddenphpcommands as $forbiddenphpcommand) { if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring)) { @@ -1696,13 +1696,13 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf if ($action == 'updatecontent') $action = 'editcontent'; } - if (! $error) + if (!$error) { $db->commit(); - $filemaster=$pathofwebsite.'/master.inc.php'; + $filemaster = $pathofwebsite.'/master.inc.php'; //$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; - $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; + $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; dol_mkdir($pathofwebsite); @@ -1710,22 +1710,22 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf // Now generate the master.inc.php page $result = dolSaveMasterFile($filemaster); - if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); + if (!$result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); // Now generate the alias.php page - if (! empty($fileoldalias)) + if (!empty($fileoldalias)) { dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias); dol_delete_file($fileoldalias); } // Save page alias - $result=dolSavePageAlias($filealias, $object, $objectpage); - if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); + $result = dolSavePageAlias($filealias, $object, $objectpage); + if (!$result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); // Save page content - $result=dolSavePageContent($filetpl, $object, $objectpage); + $result = dolSavePageContent($filetpl, $object, $objectpage); if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); @@ -1752,7 +1752,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf } else { - if (! $error) + if (!$error) { if (empty($websitekey) || $websitekey == '-1') { @@ -1778,7 +1778,7 @@ if ($action == 'exportsite') header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=".$file_name); - header("Content-Length: " . filesize($fileofzip)); + header("Content-Length: ".filesize($fileofzip)); readfile($fileofzip); exit; @@ -1793,24 +1793,24 @@ if ($action == 'exportsite') // Import site if ($action == 'importsiteconfirm') { - if (empty($_FILES) && ! GETPOSTISSET('templateuserfile')) + if (empty($_FILES) && !GETPOSTISSET('templateuserfile')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); $action = 'importsite'; } else { - if (! empty($_FILES) || GETPOSTISSET('templateuserfile')) + if (!empty($_FILES) || GETPOSTISSET('templateuserfile')) { // Check symlink to medias and restore it if ko - $pathtomedias=DOL_DATA_ROOT.'/medias'; - $pathtomediasinwebsite=$pathofwebsite.'/medias'; - if (! is_link(dol_osencode($pathtomediasinwebsite))) + $pathtomedias = DOL_DATA_ROOT.'/medias'; + $pathtomediasinwebsite = $pathofwebsite.'/medias'; + if (!is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); - dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists $result = symlink($pathtomedias, $pathtomediasinwebsite); - if (! $result) + if (!$result) { setEventMessages($langs->trans("ErrorFieldToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null, 'errors'); $action = 'importsite'; @@ -1822,17 +1822,17 @@ if ($action == 'importsiteconfirm') { $fileofzip = DOL_DATA_ROOT.'/doctemplates/websites/'.GETPOST('templateuserfile', 'alpha'); } - elseif (! empty($_FILES)) + elseif (!empty($_FILES)) { - if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; - else $userfiles=array($_FILES['userfile']['tmp_name']); + if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; + else $userfiles = array($_FILES['userfile']['tmp_name']); - foreach($userfiles as $key => $userfile) + foreach ($userfiles as $key => $userfile) { if (empty($_FILES['userfile']['tmp_name'][$key])) { $error++; - if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){ + if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); $action = 'importsite'; } @@ -1843,7 +1843,7 @@ if ($action == 'importsiteconfirm') } } - if (! $error) + if (!$error) { $upload_dir = $conf->website->dir_temp; $result = dol_add_file_process($upload_dir, 1, -1, 'userfile', ''); @@ -1851,16 +1851,16 @@ if ($action == 'importsiteconfirm') // Get name of file (take last one if several name provided) $fileofzip = $upload_dir.'/unknown'; - foreach($_FILES as $key => $ifile) + foreach ($_FILES as $key => $ifile) { - foreach($ifile['name'] as $key2 => $ifile2) + foreach ($ifile['name'] as $key2 => $ifile2) { - $fileofzip = $upload_dir . '/' .$ifile2; + $fileofzip = $upload_dir.'/'.$ifile2; } } } - if (! $error) + if (!$error) { $result = $object->importWebSite($fileofzip); if ($result < 0) @@ -1893,7 +1893,7 @@ $formadmin = new FormAdmin($db); $formwebsite = new FormWebsite($db); $formother = new FormOther($db); -$help_url=''; +$help_url = ''; $arrayofjs = array( '/includes/ace/src/ace.js', @@ -1904,16 +1904,16 @@ $arrayofjs = array( ); $arrayofcss = array(); -$moreheadcss=''; -$moreheadjs=''; +$moreheadcss = ''; +$moreheadjs = ''; -$arrayofjs[]='includes/jquery/plugins/blockUI/jquery.blockUI.js'; -$arrayofjs[]='core/js/blockUI.js'; // Used by ecm/tpl/enabledfiletreeajax.tpl.php -if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $arrayofjs[]="includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; +$arrayofjs[] = 'includes/jquery/plugins/blockUI/jquery.blockUI.js'; +$arrayofjs[] = 'core/js/blockUI.js'; // Used by ecm/tpl/enabledfiletreeajax.tpl.php +if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $arrayofjs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; -$moreheadjs.='<script type="text/javascript">'."\n"; -$moreheadjs.='var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n"; -$moreheadjs.='</script>'."\n"; +$moreheadjs .= '<script type="text/javascript">'."\n"; +$moreheadjs .= 'var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n"; +$moreheadjs .= '</script>'."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("WebsiteSetup"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss, '', '', '<!-- Begin div class="fiche" -->'."\n".'<div class="fichebutwithotherclass">'); @@ -1978,11 +1978,11 @@ if ($action == 'replacesiteconfirm') print '<div>'; // Add a margin under toolbar ? -$style=''; -if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource') $style=' margin-bottom: 5px;'; +$style = ''; +if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource') $style = ' margin-bottom: 5px;'; -if (! GETPOST('hide_websitemenu')) +if (!GETPOST('hide_websitemenu')) { $disabled=''; if (empty($user->rights->website->write)) $disabled=' disabled="disabled"'; @@ -2004,24 +2004,24 @@ if (! GETPOST('hide_websitemenu')) // List of website print '<span class="websiteselection">'; - $out=''; - $out.='<select name="website" class="minwidth100 maxwidth300" id="website">'; - if (empty($object->records)) $out.='<option value="-1"> </option>'; + $out = ''; + $out .= '<select name="website" class="minwidth100 maxwidth300" id="website">'; + if (empty($object->records)) $out .= '<option value="-1"> </option>'; // Loop on each sites - $i=0; - foreach($object->records as $key => $valwebsite) + $i = 0; + foreach ($object->records as $key => $valwebsite) { - if (empty($websitekey)) $websitekey=$valwebsite->ref; + if (empty($websitekey)) $websitekey = $valwebsite->ref; - $out.='<option value="'.$valwebsite->ref.'"'; - if ($websitekey == $valwebsite->ref) $out.=' selected'; // To preselect a value - $out.='>'; - $out.=$valwebsite->ref; - $out.='</option>'; + $out .= '<option value="'.$valwebsite->ref.'"'; + if ($websitekey == $valwebsite->ref) $out .= ' selected'; // To preselect a value + $out .= '>'; + $out .= $valwebsite->ref; + $out .= '</option>'; $i++; } - $out.='</select>'; - $out.=ajax_combobox('website'); + $out .= '</select>'; + $out .= ajax_combobox('website'); print $out; //print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">'; print '<input type="image" class="valignmiddle" src="'.img_picto('', 'refresh', '', 0, 1).'" name="refreshsite" value="'.$langs->trans("Load").'">'; @@ -2062,7 +2062,7 @@ if (! GETPOST('hide_websitemenu')) print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ExportSite")).'" name="exportsite">'; print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("CloneSite")).'" name="createfromclone">'; - print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans("Delete").'"'.($atleastonepage?' disabled="disabled"':'').'>'; + print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans("Delete").'"'.($atleastonepage ? ' disabled="disabled"' : '').'>'; print '   '; @@ -2098,48 +2098,48 @@ if (! GETPOST('hide_websitemenu')) if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') { - $urlext=$virtualurl; - $urlint=$urlwithroot.'/public/website/index.php?website='.$websitekey; + $urlext = $virtualurl; + $urlint = $urlwithroot.'/public/website/index.php?website='.$websitekey; print '<span class="websiteinputurl valignmiddle" id="websiteinputurl">'; - $linktotestonwebserver = '<a href="'.($virtualurl?$virtualurl:'#').'" class="valignmiddle">'; - $linktotestonwebserver.= $langs->trans("TestDeployOnWeb", $virtualurl).' '.img_picto('', 'globe'); - $linktotestonwebserver.= '</a>'; + $linktotestonwebserver = '<a href="'.($virtualurl ? $virtualurl : '#').'" class="valignmiddle">'; + $linktotestonwebserver .= $langs->trans("TestDeployOnWeb", $virtualurl).' '.img_picto('', 'globe'); + $linktotestonwebserver .= '</a>'; $htmltext = ''; if (empty($object->fk_default_home)) { - $htmltext.= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>'; + $htmltext .= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>'; } elseif (empty($virtualurl)) { - $htmltext.= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>'; + $htmltext .= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>'; } else { - $htmltext.= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>'; + $htmltext .= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>'; } - if (! empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) + if (!empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) { - $htmltext.= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); + $htmltext .= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); } else { - $htmltext.=$langs->trans("SetHereVirtualHost", $dataroot); - $htmltext.='<br>'; - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); - $htmltext.='<br>'; - $htmltext.='<br>'; - $htmltext.=$langs->trans("YouCanAlsoTestWithPHPS", $dataroot); - $htmltext.='<br>'; - $htmltext.='<br>'; - $htmltext.=$langs->trans("YouCanAlsoDeployToAnotherWHP"); + $htmltext .= $langs->trans("SetHereVirtualHost", $dataroot); + $htmltext .= '<br>'; + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); + $htmltext .= '<br>'; + $htmltext .= '<br>'; + $htmltext .= $langs->trans("YouCanAlsoTestWithPHPS", $dataroot); + $htmltext .= '<br>'; + $htmltext .= '<br>'; + $htmltext .= $langs->trans("YouCanAlsoDeployToAnotherWHP"); } print $form->textwithpicto($linktotestonwebserver, $htmltext, 1, 'none', 'valignmiddle', 0, 3, 'helpvirtualhost'); print '</span>'; } - if (in_array($action, array('editcss','editmenu','file_manager','replacesite','replacesiteconfirm'))) + if (in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm'))) { if ($action == 'editcss' && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefilean stay" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("SaveAndStay")).'" name="updateandstay">'; if (preg_match('/^create/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; @@ -2152,12 +2152,12 @@ if (! GETPOST('hide_websitemenu')) // Toolbar for pages - if ($websitekey && $websitekey != '-1' && ! in_array($action, array('editcss','editmenu','importsite'))) + if ($websitekey && $websitekey != '-1' && !in_array($action, array('editcss', 'editmenu', 'importsite'))) { - print '</div>'; // Close current websitebar to open a new one + print '</div>'; // Close current websitebar to open a new one print '<!-- Bar for websitepage -->'; - print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">'; + print '<div class="centpercent websitebar"'.($style ? ' style="'.$style.'"' : '').'">'; print '<span class="websiteselection hideonsmartphoneimp minwidth100 tdoverflowmax100">'; print $langs->trans("PageContainer").': '; @@ -2180,12 +2180,12 @@ if (! GETPOST('hide_websitemenu')) } //print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>'; - print '<input type="image" class="valignmiddle" src="'.img_picto('', 'refresh', '', 0, 1).'" name="refreshpage" value="'.$langs->trans("Load").'"'.(($atleastonepage && $action != 'editsource')?'':' disabled="disabled"').'>'; + print '<input type="image" class="valignmiddle" src="'.img_picto('', 'refresh', '', 0, 1).'" name="refreshpage" value="'.$langs->trans("Load").'"'.(($atleastonepage && $action != 'editsource') ? '' : ' disabled="disabled"').'>'; // Print nav arrows - $pagepreviousid=0; - $pagenextid=0; + $pagepreviousid = 0; + $pagenextid = 0; if ($pageid) { $sql = 'SELECT MAX(rowid) as pagepreviousid FROM '.MAIN_DB_PREFIX.'website_page WHERE rowid < '.$pageid.' AND fk_website = '.$object->id; @@ -2225,8 +2225,8 @@ if (! GETPOST('hide_websitemenu')) if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') { - $disabled=''; - if (empty($user->rights->website->write)) $disabled=' disabled="disabled"'; + $disabled = ''; + if (empty($user->rights->website->write)) $disabled = ' disabled="disabled"'; // Confirmation delete site if ($action == 'deletesite') { @@ -2238,7 +2238,7 @@ if (! GETPOST('hide_websitemenu')) //array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)) ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id='.$object->id, $langs->trans('DeleteWebsite'), '', 'confirm_deletesite', $formquestion, 0, 1, 200); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteWebsite'), '', 'confirm_deletesite', $formquestion, 0, 1, 200); print $formconfirm; } @@ -2247,13 +2247,13 @@ if (! GETPOST('hide_websitemenu')) if ($action == 'createfromclone') { // Create an array for form $formquestion = array( - array('type' => 'text', 'name' => 'siteref', 'label'=> $langs->trans("WebSite") ,'value'=> 'copy_of_'.$object->ref), + array('type' => 'text', 'name' => 'siteref', 'label'=> $langs->trans("WebSite"), 'value'=> 'copy_of_'.$object->ref), //array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("SiteIsANewTranslation"), 'value' => 0), //array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')), //array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)) ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id='.$object->id, $langs->trans('CloneSite'), '', 'confirm_createfromclone', $formquestion, 0, 1, 200); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloneSite'), '', 'confirm_createfromclone', $formquestion, 0, 1, 200); print $formconfirm; } @@ -2267,12 +2267,12 @@ if (! GETPOST('hide_websitemenu')) $formquestion = array( array('type' => 'hidden', 'name' => 'sourcepageurl', 'value'=> $objectpage->pageurl), array('type' => 'checkbox', 'tdclass'=>'maxwidth200', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), - array('type' => 'other','name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language($preselectedlanguage, 'newlang', 0, null, 1, 0, 0, 'minwidth200', 0, 1)), - array('type' => 'other','name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), + array('type' => 'other', 'name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language($preselectedlanguage, 'newlang', 0, null, 1, 0, 0, 'minwidth200', 0, 1)), + array('type' => 'other', 'name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), array('type' => 'text', 'tdclass'=>'maxwidth200 fieldrequired', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME"), 'value'=> 'copy_of_'.$objectpage->pageurl), ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?website='.$object->ref.'&pageid=' . $pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550); print $formconfirm; } @@ -2291,7 +2291,7 @@ if (! GETPOST('hide_websitemenu')) print '<!-- Code to enabled edit inline ckeditor -->'."\n"; print '<script type="text/javascript"> $(document).ready(function() { - var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE?'true':'false').'; + var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE ? 'true' : 'false').'; if (isEditingEnabled) { switchEditorOnline(true); @@ -2389,7 +2389,7 @@ if (! GETPOST('hide_websitemenu')) print '<a href="'.$_SERVER["PHP_SEFL"].'?action=setashome&website='.$website->ref.'&pageid='.$pageid.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'"><span class="fa fa-home valignmiddle btnTitle-icon"><span></a>'; } print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ClonePage")).'" name="createpagefromclone">'; - print '<input type="submit" class="buttonDelete bordertransp" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>'; + print '<input type="submit" class="buttonDelete bordertransp" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage ? '' : ' disabled="disabled"').'>'; } } @@ -2399,48 +2399,48 @@ if (! GETPOST('hide_websitemenu')) if (($pageid > 0 && $atleastonepage) && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) { - $realpage=$urlwithroot.'/public/website/index.php?website='.$websitekey.'&pageref='.$websitepage->pageurl; + $realpage = $urlwithroot.'/public/website/index.php?website='.$websitekey.'&pageref='.$websitepage->pageurl; $pagealias = $websitepage->pageurl; $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$websitekey.'" alt="'.dol_escape_htmltag($htmltext).'">'; print $form->textwithpicto('', $htmltext, 1, 'preview'); - print '</a>'; // View page in new Tab + print '</a>'; // View page in new Tab print '<div class="websiteinputurl" id="websiteinputpage">'; print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="'.$pagealias.'" disabled="disabled">'; - $htmltext=$langs->trans("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta")); + $htmltext = $langs->trans("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta")); print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helppagealias'); print '</div>'; - $urlext=$virtualurl.'/'.$pagealias.'.php'; - $urlint=$urlwithroot.'/public/website/index.php?website='.$websitekey; + $urlext = $virtualurl.'/'.$pagealias.'.php'; + $urlint = $urlwithroot.'/public/website/index.php?website='.$websitekey; - $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'); + $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl ? $urlext : '<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'); - print '<a class="websitebuttonsitepreview'.($virtualurl?'':' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewpageext" href="'.$urlext.'" target="tab'.$websitekey.'ext" alt="'.dol_escape_htmltag($htmltext).'">'; + print '<a class="websitebuttonsitepreview'.($virtualurl ? '' : ' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewpageext" href="'.$urlext.'" target="tab'.$websitekey.'ext" alt="'.dol_escape_htmltag($htmltext).'">'; print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print '</a>'; //print '<input type="submit" class="button" name="previewpage" target="tab'.$websitekey.'"value="'.$langs->trans("ViewPageInNewTab").'">'; // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext } - if (! in_array($action, array('editcss','editmenu','file_manager','replacesite','replacesiteconfirm','createsite','createcontainer','createfromclone','createpagefromclone','deletesite'))) + if (!in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm', 'createsite', 'createcontainer', 'createfromclone', 'createpagefromclone', 'deletesite'))) { if (preg_match('/^create/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^edit/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">'; } - print '</span>'; // end websitetools + print '</span>'; // end websitetools print '<span class="websitehelp">'; if (GETPOST('editsource', 'alpha') || GETPOST('editcontent', 'alpha')) { - $htmltext=$langs->transnoentitiesnoconv("YouCanEditHtmlSource").'<br>'; + $htmltext = $langs->transnoentitiesnoconv("YouCanEditHtmlSource").'<br>'; if ($conf->browser->layout == 'phone') { print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution'); @@ -2451,14 +2451,14 @@ if (! GETPOST('hide_websitemenu')) print $form->textwithpicto($langs->trans("SyntaxHelp").' '.img_help(2, $langs->trans("SyntaxHelp")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution'); } } - print '</span>'; // end websitehelp + print '</span>'; // end websitehelp if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') { // Adding jquery code to change on the fly url of preview ext - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print '<script type="text/javascript" language="javascript"> jQuery(document).ready(function() { @@ -2506,7 +2506,7 @@ if (! GETPOST('hide_websitemenu')) } } - print '</div>'; // end current websitebar + print '</div>'; // end current websitebar } @@ -2524,7 +2524,7 @@ if ($action == 'editcss') print '<br>'; - if (! GETPOSTISSET('WEBSITE_CSS_INLINE')) + if (!GETPOSTISSET('WEBSITE_CSS_INLINE')) { $csscontent = @file_get_contents($filecss); // Clean the php css file to remove php code and get only css part @@ -2534,9 +2534,9 @@ if ($action == 'editcss') { $csscontent = GETPOST('WEBSITE_CSS_INLINE', 'none'); } - if (! trim($csscontent)) $csscontent='/* CSS content (all pages) */'."\n"."body.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; + if (!trim($csscontent)) $csscontent = '/* CSS content (all pages) */'."\n"."body.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; - if (! GETPOSTISSET('WEBSITE_JS_INLINE')) + if (!GETPOSTISSET('WEBSITE_JS_INLINE')) { $jscontent = @file_get_contents($filejs); // Clean the php js file to remove php code and get only js part @@ -2546,9 +2546,9 @@ if ($action == 'editcss') { $jscontent = GETPOST('WEBSITE_JS_INLINE', 'none'); } - if (! trim($jscontent)) $jscontent='/* JS content (all pages) */'."\n"; + if (!trim($jscontent)) $jscontent = '/* JS content (all pages) */'."\n"; - if (! GETPOSTISSET('WEBSITE_HTML_HEADER')) + if (!GETPOSTISSET('WEBSITE_HTML_HEADER')) { $htmlheadercontent = @file_get_contents($filehtmlheader); // Clean the php htmlheader file to remove php code and get only html part @@ -2558,20 +2558,20 @@ if ($action == 'editcss') { $htmlheadercontent = GETPOST('WEBSITE_HTML_HEADER', 'none'); } - if (! trim($htmlheadercontent)) + if (!trim($htmlheadercontent)) { - $htmlheadercontent ="<html>\n"; - $htmlheadercontent.=$htmlheadercontentdefault; - $htmlheadercontent.="</html>"; + $htmlheadercontent = "<html>\n"; + $htmlheadercontent .= $htmlheadercontentdefault; + $htmlheadercontent .= "</html>"; } else { $htmlheadercontent = preg_replace('/^\s*<html>/ims', '', $htmlheadercontent); $htmlheadercontent = preg_replace('/<\/html>\s*$/ims', '', $htmlheadercontent); - $htmlheadercontent='<html>'."\n".trim($htmlheadercontent)."\n".'</html>'; + $htmlheadercontent = '<html>'."\n".trim($htmlheadercontent)."\n".'</html>'; } - if (! GETPOSTISSET('WEBSITE_ROBOT')) + if (!GETPOSTISSET('WEBSITE_ROBOT')) { $robotcontent = @file_get_contents($filerobot); // Clean the php htmlheader file to remove php code and get only html part @@ -2581,15 +2581,15 @@ if ($action == 'editcss') { $robotcontent = GETPOST('WEBSITE_ROBOT', 'nothtml'); } - if (! trim($robotcontent)) + if (!trim($robotcontent)) { - $robotcontent.="# Robot file. Generated with ".DOL_APPLICATION_TITLE."\n"; - $robotcontent.="User-agent: *\n"; - $robotcontent.="Allow: /public/\n"; - $robotcontent.="Disallow: /administrator/\n"; + $robotcontent .= "# Robot file. Generated with ".DOL_APPLICATION_TITLE."\n"; + $robotcontent .= "User-agent: *\n"; + $robotcontent .= "Allow: /public/\n"; + $robotcontent .= "Disallow: /administrator/\n"; } - if (! GETPOSTISSET('WEBSITE_HTACCESS')) + if (!GETPOSTISSET('WEBSITE_HTACCESS')) { $htaccesscontent = @file_get_contents($filehtaccess); // Clean the php htaccesscontent file to remove php code and get only html part @@ -2599,14 +2599,14 @@ if ($action == 'editcss') { $htaccesscontent = GETPOST('WEBSITE_HTACCESS', 'nohtml'); } - if (! trim($htaccesscontent)) + if (!trim($htaccesscontent)) { - $htaccesscontent.="# Order allow,deny\n"; - $htaccesscontent.="# Deny from all\n"; + $htaccesscontent .= "# Order allow,deny\n"; + $htaccesscontent .= "# Deny from all\n"; } - if (! GETPOSTISSET('WEBSITE_MANIFEST_JSON')) + if (!GETPOSTISSET('WEBSITE_MANIFEST_JSON')) { $manifestjsoncontent = @file_get_contents($filemanifestjson); // Clean the manifestjson file to remove php code and get only html part @@ -2616,12 +2616,12 @@ if ($action == 'editcss') { $manifestjsoncontent = GETPOST('WEBSITE_MANIFEST_JSON', 'none'); } - if (! trim($manifestjsoncontent)) + if (!trim($manifestjsoncontent)) { //$manifestjsoncontent.=""; } - if (! GETPOSTISSET('WEBSITE_README')) + if (!GETPOSTISSET('WEBSITE_README')) { $readmecontent = @file_get_contents($filereadme); // Clean the readme file to remove php code and get only html part @@ -2631,7 +2631,7 @@ if ($action == 'editcss') { $readmecontent = GETPOST('WEBSITE_README', 'none'); } - if (! trim($readmecontent)) + if (!trim($readmecontent)) { //$readmecontent.=""; } @@ -2652,9 +2652,9 @@ if ($action == 'editcss') print '<tr><td class="tdtop">'; $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>'.$websitekey.'</i>'); - $htmltext.='<br>'; - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); + $htmltext .= '<br>'; + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'virtualhosttooltip'); print '</td><td>'; @@ -2664,11 +2664,11 @@ if ($action == 'editcss') // CSS file print '<tr><td class="tdtop">'; - $htmlhelp=$langs->trans("CSSContentTooltipHelp"); + $htmlhelp = $langs->trans("CSSContentTooltipHelp"); print $form->textwithpicto($langs->trans('WEBSITE_CSS_INLINE'), $htmlhelp, 1, 'help', '', 0, 2, 'csstooltip'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, 'CSS', 'css'); print '</td></tr>'; @@ -2678,7 +2678,7 @@ if ($action == 'editcss') print $langs->trans('WEBSITE_JS_INLINE'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_JS_INLINE', $jscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_JS_INLINE', $jscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, 'JS', 'javascript'); print '</td></tr>'; @@ -2686,14 +2686,14 @@ if ($action == 'editcss') // Common HTML header print '<tr><td class="tdtop">'; print $langs->trans('WEBSITE_HTML_HEADER'); - $htmlhelp=$langs->trans("Example").' :<br>'; - $htmlhelp.=dol_htmlentitiesbr($htmlheadercontentdefault); + $htmlhelp = $langs->trans("Example").' :<br>'; + $htmlhelp .= dol_htmlentitiesbr($htmlheadercontentdefault); $textwithhelp = $form->textwithpicto('', $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip'); - $htmlhelp2=$langs->trans("LinkAndScriptsHereAreNotLoadedInEditor").'<br>'; + $htmlhelp2 = $langs->trans("LinkAndScriptsHereAreNotLoadedInEditor").'<br>'; print $form->textwithpicto($textwithhelp, $htmlhelp2, 1, 'warning', '', 0, 2, 'htmlheadertooltip2'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_HTML_HEADER', $htmlheadercontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_HTML_HEADER', $htmlheadercontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, 'HTML Header', 'html'); print '</td></tr>'; @@ -2703,7 +2703,7 @@ if ($action == 'editcss') print $langs->trans('WEBSITE_ROBOT'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_ROBOT', $robotcontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_ROBOT', $robotcontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, 'Robot file', 'text'); print '</td></tr>'; @@ -2713,30 +2713,30 @@ if ($action == 'editcss') print $langs->trans('WEBSITE_HTACCESS'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_HTACCESS', $htaccesscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_HTACCESS', $htaccesscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, $langs->trans("File").' .htaccess', 'text'); print '</td></tr>'; // Manifest.json print '<tr><td class="tdtop">'; - $htmlhelp=$langs->trans("Example").' :<br>'; - $htmlhelp.=dol_htmlentitiesbr($manifestjsoncontentdefault); + $htmlhelp = $langs->trans("Example").' :<br>'; + $htmlhelp .= dol_htmlentitiesbr($manifestjsoncontentdefault); print $form->textwithpicto($langs->trans('WEBSITE_MANIFEST_JSON'), $htmlhelp, 1, 'help', '', 0, 2, 'manifestjsontooltip'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_MANIFEST_JSON', $manifestjsoncontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_MANIFEST_JSON', $manifestjsoncontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, $langs->trans("File").' manifest.json', 'text'); print '</td></tr>'; // README.md print '<tr><td class="tdtop">'; - $htmlhelp=$langs->trans("EnterHereLicenseInformation"); + $htmlhelp = $langs->trans("EnterHereLicenseInformation"); print $form->textwithpicto($langs->trans('WEBSITE_README'), $htmlhelp, 1, 'help', '', 0, 2, 'readmetooltip'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_README', $readmecontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_README', $readmecontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, $langs->trans("File").' README.md', 'text'); print '</td></tr>'; @@ -2774,8 +2774,8 @@ if ($action == 'createsite') print '<table class="border centpercent">'; - if (GETPOST('WEBSITE_REF')) $siteref=GETPOST('WEBSITE_REF', 'alpha'); - if (GETPOST('WEBSITE_DESCRIPTION')) $sitedesc=GETPOST('WEBSITE_DESCRIPTION', 'alpha'); + if (GETPOST('WEBSITE_REF')) $siteref = GETPOST('WEBSITE_REF', 'alpha'); + if (GETPOST('WEBSITE_DESCRIPTION')) $sitedesc = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); print '<tr><td class="titlefieldcreate fieldrequired">'; print $langs->trans('Ref'); @@ -2792,9 +2792,9 @@ if ($action == 'createsite') print '<tr><td>'; $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'); - $htmltext.='<br>'; - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); + $htmltext .= '<br>'; + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'virtualhosttooltip'); print '</td><td>'; @@ -2882,15 +2882,15 @@ if ($action == 'editmeta' || $action == 'createcontainer') if (GETPOST('radiocreatefrom') == 'checkboxcreatemanually') $hiddenmanuallyafterload = ''; if ($action == 'editmeta' || empty($conf->use_javascript_ajax)) { // No autohide/show in such case - $hiddenfromfetchingafterload=''; - $hiddenmanuallyafterload=''; + $hiddenfromfetchingafterload = ''; + $hiddenmanuallyafterload = ''; } if ($action == 'createcontainer') { print '<br>'; - if (! empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> '; + if (!empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> '; print '<label for="checkboxcreatefromfetching"><span class="opacitymedium">'.$langs->trans("CreateByFetchingExternalPage").'</span></label><br>'; print '<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">'; print '<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">'; @@ -2902,8 +2902,8 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans("GrabImagesInto"); print ' '; print $langs->trans("ImagesShouldBeSavedInto").' '; - $arraygrabimagesinto=array('root'=>$langs->trans("WebsiteRootOfImages"), 'subpage'=>$langs->trans("SubdirOfPage")); - print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto')?GETPOST('grabimagesinto'):'root'); + $arraygrabimagesinto = array('root'=>$langs->trans("WebsiteRootOfImages"), 'subpage'=>$langs->trans("SubdirOfPage")); + print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto') ?GETPOST('grabimagesinto') : 'root'); print '<br>'; print '<input class="button" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans("FetchAndCreate")).'">'; print '</td></tr>'; @@ -2911,7 +2911,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<br>'; - if (! empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> '; + if (!empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> '; print '<label for="checkboxcreatemanually"><span class="opacitymedium">'.$langs->trans("OrEnterPageInfoManually").'</span></label><br>'; print '<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">'; } @@ -2933,35 +2933,35 @@ if ($action == 'editmeta' || $action == 'createcontainer') //if ($objectpage->grabbed_from) print ' - <span class="opacitymedium">'.$langs->trans('InitiallyGrabbedFrom').' '.$objectpage->grabbed_from.'</span>'; print '</td></tr>'; - $type_container=$objectpage->type_container; - $pageurl=$objectpage->pageurl; - $pagealiasalt=$objectpage->aliasalt; - $pagetitle=$objectpage->title; - $pagedescription=$objectpage->description; - $pageimage=$objectpage->image; - $pagekeywords=$objectpage->keywords; - $pagelang=$objectpage->lang; - $pagehtmlheader=$objectpage->htmlheader; - $pagedatecreation=$objectpage->date_creation; - $pagedatemodification=$objectpage->date_modification; - $pageauthorid=$objectpage->fk_user_creat; - $pageusermodifid=$objectpage->fk_user_modif; + $type_container = $objectpage->type_container; + $pageurl = $objectpage->pageurl; + $pagealiasalt = $objectpage->aliasalt; + $pagetitle = $objectpage->title; + $pagedescription = $objectpage->description; + $pageimage = $objectpage->image; + $pagekeywords = $objectpage->keywords; + $pagelang = $objectpage->lang; + $pagehtmlheader = $objectpage->htmlheader; + $pagedatecreation = $objectpage->date_creation; + $pagedatemodification = $objectpage->date_modification; + $pageauthorid = $objectpage->fk_user_creat; + $pageusermodifid = $objectpage->fk_user_modif; } else { $type_container = 'page'; - $pagedatecreation=dol_now(); - $pageauthorid=$user->id; - $pageusermodifid=0; + $pagedatecreation = dol_now(); + $pageauthorid = $user->id; + $pageusermodifid = 0; } - if (GETPOST('WEBSITE_TITLE', 'alpha')) $pagetitle=GETPOST('WEBSITE_TITLE', 'alpha'); - if (GETPOST('WEBSITE_PAGENAME', 'alpha')) $pageurl=GETPOST('WEBSITE_PAGENAME', 'alpha'); - if (GETPOST('WEBSITE_ALIASALT', 'alpha')) $pagealiasalt=GETPOST('WEBSITE_ALIASALT', 'alpha'); - if (GETPOST('WEBSITE_DESCRIPTION', 'alpha')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION', 'alpha'); - if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage=GETPOST('WEBSITE_IMAGE', 'alpha'); - if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS', 'alpha'); - if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang=GETPOST('WEBSITE_LANG', 'aZ09'); - if (GETPOST('htmlheader', 'none')) $pagehtmlheader=GETPOST('htmlheader', 'none'); + if (GETPOST('WEBSITE_TITLE', 'alpha')) $pagetitle = GETPOST('WEBSITE_TITLE', 'alpha'); + if (GETPOST('WEBSITE_PAGENAME', 'alpha')) $pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); + if (GETPOST('WEBSITE_ALIASALT', 'alpha')) $pagealiasalt = GETPOST('WEBSITE_ALIASALT', 'alpha'); + if (GETPOST('WEBSITE_DESCRIPTION', 'alpha')) $pagedescription = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); + if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage = GETPOST('WEBSITE_IMAGE', 'alpha'); + if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); + if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang = GETPOST('WEBSITE_LANG', 'aZ09'); + if (GETPOST('htmlheader', 'none')) $pagehtmlheader = GETPOST('htmlheader', 'none'); // Title print '<tr><td class="fieldrequired">'; @@ -2981,7 +2981,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<tr><td class="titlefield fieldrequired">'; print $langs->trans('WEBSITE_TYPE_CONTAINER'); print '</td><td>'; - print $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha')?GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'):$type_container)); + print $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') ?GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') : $type_container)); print '</td></tr>'; if ($action == 'createcontainer') @@ -2989,7 +2989,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<tr><td class="titlefield fieldrequired">'; print $langs->trans('WEBSITE_PAGE_EXAMPLE'); print '</td><td>'; - print $formwebsite->selectSampleOfContainer('sample', (GETPOSTISSET('sample')?GETPOST('sample', 'alpha'):'empty')); + print $formwebsite->selectSampleOfContainer('sample', (GETPOSTISSET('sample') ?GETPOST('sample', 'alpha') : 'empty')); print '</td></tr>'; } @@ -3000,7 +3000,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '</td></tr>'; print '<tr><td>'; - $htmlhelp=$langs->trans("WEBSITE_IMAGEDesc"); + $htmlhelp = $langs->trans("WEBSITE_IMAGEDesc"); print $form->textwithpicto($langs->trans('WEBSITE_IMAGE'), $htmlhelp, 1, 'help', '', 0, 2, 'imagetooltip'); print '</td><td>'; print '<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).'">'; @@ -3015,19 +3015,19 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<tr><td>'; print $langs->trans('Language'); print '</td><td>'; - print $formadmin->select_language($pagelang?$pagelang:$langs->defaultlang, 'WEBSITE_LANG', 0, null, '1'); + print $formadmin->select_language($pagelang ? $pagelang : $langs->defaultlang, 'WEBSITE_LANG', 0, null, '1'); print '</td></tr>'; // Translation of - $translationof=0; - $translatedby=0; + $translationof = 0; + $translatedby = 0; print '<!-- Translation of --><tr><td>'; print $langs->trans('TranslationLinks'); print '</td><td>'; if ($action != 'createcontainer') { // Has translation pages - $sql='SELECT rowid, lang from '.MAIN_DB_PREFIX.'website_page where fk_page = '.$objectpage->id; + $sql = 'SELECT rowid, lang from '.MAIN_DB_PREFIX.'website_page where fk_page = '.$objectpage->id; $resql = $db->query($sql); if ($resql) { @@ -3035,10 +3035,10 @@ if ($action == 'editmeta' || $action == 'createcontainer') if ($num_rows > 0) { print '<span class="opacitymedium">'.$langs->trans('ThisPageHasTranslationPages').':</span><br>'; - $i=0; + $i = 0; while ($obj = $db->fetch_object($resql)) { - $tmppage=new WebsitePage($db); + $tmppage = new WebsitePage($db); $tmppage->fetch($obj->rowid); if ($i > 0) print ' - '; print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')<br>'; @@ -3051,7 +3051,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') } if (empty($translatedby) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) { - $sourcepage=new WebsitePage($db); + $sourcepage = new WebsitePage($db); $result = $sourcepage->fetch($objectpage->fk_page); if ($result == 0) { @@ -3067,13 +3067,13 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '</td></tr>'; print '<tr><td class="titlefieldcreate">'; - $htmlhelp=$langs->trans("WEBSITE_ALIASALTDesc"); + $htmlhelp = $langs->trans("WEBSITE_ALIASALTDesc"); print $form->textwithpicto($langs->trans('WEBSITE_ALIASALT'), $htmlhelp, 1, 'help', '', 0, 2, 'aliastooltip'); print '</td><td>'; print '<input type="text" class="flat minwidth300" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).'">'; print '</td></tr>'; - $fuser=new User($db); + $fuser = new User($db); print '<tr><td>'; print $langs->trans('Author'); @@ -3112,12 +3112,12 @@ if ($action == 'editmeta' || $action == 'createcontainer') } print '<tr><td class="tdhtmlheader tdtop">'; - $htmlhelp =$langs->trans("EditTheWebSiteForACommonHeader").'<br><br>'; - $htmlhelp.=$langs->trans("Example").' :<br>'; - $htmlhelp.=dol_htmlentitiesbr($htmlheadercontentdefault); + $htmlhelp = $langs->trans("EditTheWebSiteForACommonHeader").'<br><br>'; + $htmlhelp .= $langs->trans("Example").' :<br>'; + $htmlhelp .= dol_htmlentitiesbr($htmlheadercontentdefault); print $form->textwithpicto($langs->trans('HtmlHeaderPage'), $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip'); print '</td><td>'; - $doleditor=new DolEditor('htmlheader', $pagehtmlheader, '', '120', 'ace', 'In', true, false, 'ace', ROWS_3, '100%', ''); + $doleditor = new DolEditor('htmlheader', $pagehtmlheader, '', '120', 'ace', 'In', true, false, 'ace', ROWS_3, '100%', ''); print $doleditor->Create(1, '', true, 'HTML Header', 'html'); print '</td></tr>'; @@ -3185,7 +3185,7 @@ if ($action == 'editfile' || $action == 'file_manager') //print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>'; $module = 'medias'; - if (empty($url)) $url=DOL_URL_ROOT.'/website/index.php'; // Must be an url without param + if (empty($url)) $url = DOL_URL_ROOT.'/website/index.php'; // Must be an url without param include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php'; print '</div>'; @@ -3207,15 +3207,15 @@ if ($action == 'editsource') //$contentforedit.='</style>'."\n"; $contentforedit .= $objectpage->content; //var_dump($_SESSION["dol_screenheight"]); - $maxheightwin=480; + $maxheightwin = 480; if (isset($_SESSION["dol_screenheight"])) { - if ($_SESSION["dol_screenheight"] > 680) $maxheightwin = $_SESSION["dol_screenheight"]-400; - if ($_SESSION["dol_screenheight"] > 800) $maxheightwin = $_SESSION["dol_screenheight"]-490; + if ($_SESSION["dol_screenheight"] > 680) $maxheightwin = $_SESSION["dol_screenheight"] - 400; + if ($_SESSION["dol_screenheight"] > 800) $maxheightwin = $_SESSION["dol_screenheight"] - 490; } //var_dump($_SESSION["dol_screenheight"]); require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('PAGE_CONTENT', $contentforedit, '', $maxheightwin, 'Full', '', true, true, 'ace', ROWS_5, '40%'); + $doleditor = new DolEditor('PAGE_CONTENT', $contentforedit, '', $maxheightwin, 'Full', '', true, true, 'ace', ROWS_5, '40%'); $doleditor->Create(0, '', false, 'HTML Source', 'php'); } @@ -3262,9 +3262,9 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print $langs->trans("SearchReplaceInto"); print '</div>'; print '<div class="tagtd">'; - print '<input type="checkbox" name="optioncontent" value="content"'.((! GETPOSTISSET('buttonreplacesitesearch') || GETPOST('optioncontent', 'aZ09'))?' checked':'').'> '.$langs->trans("Content"); - print '<input type="checkbox" class="marginleftonly" name="optionmeta" value="meta"'.(GETPOST('optionmeta', 'aZ09')?' checked':'').'> '.$langs->trans("Title").' | '.$langs->trans("Description").' | '.$langs->trans("Keywords"); - print '<input type="checkbox" class="marginleftonly" name="optionsitefiles" value="sitefiles"'.(GETPOST('optionsitefiles', 'aZ09')?' checked':'').'> '.$langs->trans("GlobalCSSorJS"); + print '<input type="checkbox" name="optioncontent" value="content"'.((!GETPOSTISSET('buttonreplacesitesearch') || GETPOST('optioncontent', 'aZ09')) ? ' checked' : '').'> '.$langs->trans("Content"); + print '<input type="checkbox" class="marginleftonly" name="optionmeta" value="meta"'.(GETPOST('optionmeta', 'aZ09') ? ' checked' : '').'> '.$langs->trans("Title").' | '.$langs->trans("Description").' | '.$langs->trans("Keywords"); + print '<input type="checkbox" class="marginleftonly" name="optionsitefiles" value="sitefiles"'.(GETPOST('optionsitefiles', 'aZ09') ? ' checked' : '').'> '.$langs->trans("GlobalCSSorJS"); print '</div>'; print '</div>'; @@ -3286,9 +3286,9 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') if ($action == 'replacesiteconfirm') { $algo = ''; - if (GETPOST('optionmeta')) $algo.='meta'; - if (GETPOST('optioncontent')) $algo.='content'; - if (GETPOST('optionsitefiles')) $algo.='sitefiles'; + if (GETPOST('optionmeta')) $algo .= 'meta'; + if (GETPOST('optioncontent')) $algo .= 'content'; + if (GETPOST('optionsitefiles')) $algo .= 'sitefiles'; $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000); @@ -3322,7 +3322,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print '<th>'.$langs->trans("Description").'</th>'; print '</tr>'; - foreach($listofpages['list'] as $answerrecord) + foreach ($listofpages['list'] as $answerrecord) { if (get_class($answerrecord) == 'WebsitePage') { @@ -3383,11 +3383,11 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa { $out .= "<iframe><body></html>"; }*/ - $out.="\n<html><head>\n"; - $out.="<!-- htmlheader/style of page from database -->\n"; - $out.=dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1, 'htmlheader'); + $out .= "\n<html><head>\n"; + $out .= "<!-- htmlheader/style of page from database -->\n"; + $out .= dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1, 'htmlheader'); - $out.="<!-- htmlheader/style of website from files -->\n"; + $out .= "<!-- htmlheader/style of website from files -->\n"; // TODO Keep only the <link> or the <script> tags /* $htmlheadercontent = @file_get_contents($filehtmlheader); @@ -3405,51 +3405,51 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa } */ - $out.="</head>\n"; - $out.="\n<body>"; + $out .= "</head>\n"; + $out .= "\n<body>"; - $out.='<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'."\n"; + $out .= '<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'."\n"; // REPLACEMENT OF LINKS When page called by website editor - $out.='<!-- style of website from file -->'."\n"; - $out.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". No more supported by browsers, snif ! - $tmpout=''; - $tmpout.= '/* Include website CSS file */'."\n"; + $out .= '<!-- style of website from file -->'."\n"; + $out .= '<style scoped>'."\n"; // "scoped" means "apply to parent element only". No more supported by browsers, snif ! + $tmpout = ''; + $tmpout .= '/* Include website CSS file */'."\n"; //$csscontent = @file_get_contents($filecss); ob_start(); include $filecss; $csscontent = ob_get_contents(); ob_end_clean(); - $tmpout.= dolWebsiteReplacementOfLinks($object, $csscontent, 1, 'css'); - $tmpout.= '/* Include style from the HTML header of page */'."\n"; + $tmpout .= dolWebsiteReplacementOfLinks($object, $csscontent, 1, 'css'); + $tmpout .= '/* Include style from the HTML header of page */'."\n"; // Clean the html header of page to get only <style> content $tmp = preg_split('(<style[^>]*>|</style>)', $objectpage->htmlheader); - $tmpstyleinheader =''; - $i=0; - foreach($tmp as $valtmp) + $tmpstyleinheader = ''; + $i = 0; + foreach ($tmp as $valtmp) { $i++; - if ($i % 2 == 0) $tmpstyleinheader.=$valtmp."\n"; + if ($i % 2 == 0) $tmpstyleinheader .= $valtmp."\n"; } - $tmpout.= $tmpstyleinheader."\n"; + $tmpout .= $tmpstyleinheader."\n"; // Clean style that may affect global style of Dolibarr - $tmpout=preg_replace('/}[\s\n]*body\s*{[^}]+}/ims', '}', $tmpout); - $out.=$tmpout; - $out.='</style>'."\n"; + $tmpout = preg_replace('/}[\s\n]*body\s*{[^}]+}/ims', '}', $tmpout); + $out .= $tmpout; + $out .= '</style>'."\n"; // Note: <div> or <section> with contenteditable="true" inside this can be edited with inline ckeditor // Do not enable the contenteditable when page was grabbed, ckeditor is removing span and adding borders, // so editable will be available only from container created from scratch //$out.='<div id="bodywebsite" class="bodywebsite"'.($objectpage->grabbed_from ? ' contenteditable="true"' : '').'>'."\n"; - $out.='<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n"; + $out .= '<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n"; $newcontent = $objectpage->content; // If mode WEBSITE_SUBCONTAINERSINLINE is on - if (! empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) + if (!empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) { //var_dump($filetpl); $filephp = $filetpl; @@ -3469,12 +3469,12 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa { // Keep the contenteditable="true" when mode Edit Inline is on } - $out.=dolWebsiteReplacementOfLinks($object, $newcontent, 0, 'html', $objectpage->id)."\n"; + $out .= dolWebsiteReplacementOfLinks($object, $newcontent, 0, 'html', $objectpage->id)."\n"; //$out.=$newcontent; - $out.='</div>'; + $out .= '</div>'; - $out.='</div> <!-- End div id=websitecontentundertopmenu -->'; + $out .= '</div> <!-- End div id=websitecontentundertopmenu -->'; /*if ($includepageintoaframeoradiv == 'iframe') { @@ -3482,7 +3482,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa }*/ $out .= "\n</body></html>\n"; - $out.= "\n".'<!-- End page content '.$filetpl.' -->'."\n\n"; + $out .= "\n".'<!-- End page content '.$filetpl.' -->'."\n\n"; print $out; From 8be0a6d470ed5d7f7326dd6ad711582d4d20447d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 00:43:26 +0100 Subject: [PATCH 180/299] Fix: Can set savingdocmask by caller. Fix permissions names. Fix: Disable crop on svg images. --- htdocs/core/lib/images.lib.php | 2 + .../tpl/document_actions_post_headers.tpl.php | 56 ++++++++++++++----- htdocs/mrp/mo_document.php | 6 +- htdocs/zapier/hook_document.php | 12 ---- 4 files changed, 45 insertions(+), 31 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index d8163e7f763..4c089640915 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -40,6 +40,7 @@ function image_format_supported($file) $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php // Case filename is not a format image + $reg = array(); if (! preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1; // Case filename is a format image but not supported by this PHP @@ -51,6 +52,7 @@ function image_format_supported($file) if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp'; if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm'; if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; + if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available if ($imgfonction) { if (! function_exists($imgfonction)) diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index f2d84a3a796..3261cde553a 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -20,10 +20,13 @@ */ // Following var can be set -// $permission = permission or not to add a file -// $permtoedit = permission or not to edit file name, crop file +// $permissiontoadd = permission or not to add a file (can use also $permission) and permission or not to edit file name or crop file (can use also $permtoedit) // $modulepart = for download // $param = param to add to download links +// $upload_dir +// $object +// $filearray +// $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__'; // Protection to avoid direct call of template if (empty($langs) || ! is_object($langs)) @@ -35,7 +38,9 @@ if (empty($langs) || ! is_object($langs)) $langs->load("link"); if (empty($relativepathwithnofile)) $relativepathwithnofile=''; -if (empty($permtoedit)) $permtoedit=-1; + +if (! isset($permission)) $permission = $permissiontoadd; +if (! isset($permtoedit)) $permtoedit = $permissiontoadd; // Drag and drop for up and down allowed on product, thirdparty, ... // The drag and drop call the page core/ajax/row.php @@ -66,19 +71,40 @@ if ($action == 'delete') $formfile=new FormFile($db); -// We define var to enable the feature to add prefix of uploaded files -$savingdocmask=''; -if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) -{ - //var_dump($modulepart); - if (in_array($modulepart, array('facture_fournisseur','commande_fournisseur','facture','commande','propal','supplier_proposal','ficheinter','contract','expedition','project','project_task','expensereport','tax', 'produit', 'product_batch'))) - { - $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__'; +// We define var to enable the feature to add prefix of uploaded files. +// Caller of this include can make +// $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__'; +if (!isset($savingdocmask) || !empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) { + $savingdocmask=''; + if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) { + //var_dump($modulepart); + if (in_array($modulepart, array( + 'facture_fournisseur', + 'commande_fournisseur', + 'facture', + 'commande', + 'propal', + 'supplier_proposal', + 'ficheinter', + 'contract', + 'expedition', + 'project', + 'project_task', + 'expensereport', + 'tax', + 'produit', + 'product_batch', + 'bom', + 'mrp' + ))) + { + $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__'; + } + /*if (in_array($modulepart,array('member'))) + { + $savingdocmask=$object->login.'___file__'; + }*/ } - /*if (in_array($modulepart,array('member'))) - { - $savingdocmask=$object->login.'___file__'; - }*/ } // Show upload form (document and links) diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index 2c4d1b36c99..72fab7c3517 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -133,10 +133,8 @@ if ($object->id) dol_fiche_end(); $modulepart = 'mrp'; - //$permission = $user->rights->mrp->create; - $permission = 1; - //$permtoedit = $user->rights->mrp->create; - $permtoedit = 1; + $permission = $user->rights->mrp->write; + $permtoedit = $user->rights->mrp->write; $param = '&id=' . $object->id; //$relativepathwithnofile='mo/' . dol_sanitizeFileName($object->id).'/'; diff --git a/htdocs/zapier/hook_document.php b/htdocs/zapier/hook_document.php index 6ad31221cc4..b081a60b3ae 100644 --- a/htdocs/zapier/hook_document.php +++ b/htdocs/zapier/hook_document.php @@ -144,18 +144,6 @@ if ($object->id) print '</div>'; dol_fiche_end(); - - $modulepart = 'mymodule'; - //$permission = $user->rights->mymodule->create; - $permission = 1; - //$permtoedit = $user->rights->mymodule->create; - $permtoedit = 1; - $param = '&id=' . $object->id; - - //$relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->id).'/'; - $relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->ref).'/'; - - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } else { From dc77a58a7327a185d0b4fc6da7e40f7ba84b0322 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 01:48:12 +0100 Subject: [PATCH 181/299] Work on MO --- htdocs/bom/class/bom.class.php | 2 +- htdocs/bom/tpl/objectline_create.tpl.php | 8 +- htdocs/bom/tpl/objectline_edit.tpl.php | 6 +- htdocs/bom/tpl/objectline_title.tpl.php | 2 +- htdocs/bom/tpl/objectline_view.tpl.php | 10 +-- htdocs/core/class/commonobject.class.php | 38 +++++----- htdocs/core/tpl/originproductline.tpl.php | 4 +- htdocs/mrp/class/mo.class.php | 90 +++++++++++++++++++++++ htdocs/mrp/mo_card.php | 33 ++++++++- htdocs/mrp/tpl/originproductline.tpl.php | 44 +++++++++++ 10 files changed, 198 insertions(+), 39 deletions(-) create mode 100644 htdocs/mrp/tpl/originproductline.tpl.php diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 4dce2533bdc..524fd5c0f93 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1051,7 +1051,7 @@ class BOMLine extends CommonObject 'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',), 'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'), 'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'), - 'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), + //'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'), 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), ); diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index d3aaabbad80..e05c1865ab3 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -128,10 +128,10 @@ $coldisplay++; print '<td class="bordertop nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOST("disable_stock_change", 'alpha')?' checked="checked"':'').'">'; print '</td>'; -$coldisplay++; -print '<td class="bordertop nobottom nowrap linecollost right">'; -print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.(GETPOSTISSET("efficiency")?GETPOST("efficiency", 'alpha'):1).'">'; -print '</td>'; +//$coldisplay++; +//print '<td class="bordertop nobottom nowrap linecollost right">'; +//print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.(GETPOSTISSET("efficiency")?GETPOST("efficiency", 'alpha'):1).'">'; +//print '</td>'; $coldisplay += $colspan; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index c7fc4f73cd7..1695f643964 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -124,9 +124,9 @@ $coldisplay++; print '<td class="nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOSTISSET('disablestockchange')?(GETPOST("disable_stock_change", 'int')?' checked="checked"':''):($line->disable_stock_change?' checked="checked"':'')).'">'; print '</td>'; -$coldisplay++; -print '<td class="nobottom nowrap linecollost right">'; -print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.$line->efficiency.'"></td>'; +//$coldisplay++; +//print '<td class="nobottom nowrap linecollost right">'; +//print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.$line->efficiency.'"></td>'; $coldisplay+=$colspan; print '<td class="nobottom linecoledit center valignmiddle" colspan="'.$colspan.'">'; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 138a0b9aa58..706f71af7ec 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -66,7 +66,7 @@ print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('QtyFro print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>'; // Efficiency -print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>'; +//print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('XXX')).'</td>'; print '<td class="linecoledit"></td>'; // No width to allow autodim diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 330f8ef8a33..6f79f7640df 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -97,12 +97,12 @@ $coldisplay++; echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price print '</td>'; -print '<td class="linecolqty nowrap right">'; -$coldisplay++; -echo $line->efficiency; -print '</td>'; +//print '<td class="linecolqty nowrap right">'; +//$coldisplay++; +//echo $line->efficiency; +//print '</td>'; -if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) { +if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) { print '<td class="linecoledit center">'; $coldisplay++; if (($line->info_bits & 2) == 2 || ! empty($disableedit)) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 127e12f919e..140d41c9a62 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4018,7 +4018,7 @@ abstract class CommonObject public function formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir = '/core/tpl') { global $conf,$user,$langs,$object,$hookmanager,$extrafields; - global $form,$bcnd,$var; + global $form; // Line extrafield if (! is_object($extrafields)) @@ -4116,7 +4116,6 @@ abstract class CommonObject } } - $var = true; $i = 0; print "<tbody>\n"; @@ -4130,18 +4129,18 @@ abstract class CommonObject { if (empty($line->fk_parent_line)) { - $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'table_element_line'=>$line->table_element); + $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element); $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } else { - $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line); + $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line); $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } } if (empty($reshook)) { - $this->printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafields, $defaulttpldir); + $this->printObjectLine($action, $line, '', $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafields, $defaulttpldir); } $i++; @@ -4153,23 +4152,23 @@ abstract class CommonObject * Return HTML content of a detail line * TODO Move this into an output class file (htmlline.class.php) * - * @param string $action GET/POST action - * @param CommonObjectLine $line Selected object line to output - * @param string $var Is it a an odd line (true) - * @param int $num Number of line (0) - * @param int $i I - * @param int $dateSelector 1=Show also date range input fields - * @param string $seller Object of seller third party - * @param string $buyer Object of buyer third party - * @param int $selected Object line selected - * @param Extrafields $extrafields Object of extrafields - * @param string $defaulttpldir Directory where to find the template + * @param string $action GET/POST action + * @param CommonObjectLine $line Selected object line to output + * @param string $var Is it a an odd line (true) + * @param int $num Number of line (0) + * @param int $i I + * @param int $dateSelector 1=Show also date range input fields + * @param string $seller Object of seller third party + * @param string $buyer Object of buyer third party + * @param int $selected Object line selected + * @param Extrafields $extrafields Object of extrafields + * @param string $defaulttpldir Directory where to find the template * @return void */ public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl') { global $conf,$langs,$user,$object,$hookmanager; - global $form,$bc,$bcdd; + global $form; global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! $object_rights = $this->getRights(); @@ -4319,7 +4318,6 @@ abstract class CommonObject print '<td class="right">'.$langs->trans('ReductionShort').'</td>'; print '<td class="center">'.$form->showCheckAddButtons('checkforselect', 1).'</td>'; print '</tr>'; - $var = true; $i = 0; if (! empty($this->lines)) @@ -4330,14 +4328,14 @@ abstract class CommonObject { if (empty($line->fk_parent_line)) { - $parameters=array('line'=>$line,'var'=>$var,'i'=>$i); + $parameters=array('line'=>$line, 'i'=>$i); $action=''; $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } } else { - $this->printOriginLine($line, $var, $restrictlist, '/core/tpl', $selectedLines); + $this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines); } $i++; diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index 2fd33c25cc5..bfc1456e005 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -43,7 +43,9 @@ print '<td class="right">'.$this->tpl['remise_percent'].'</td>'; $selected=1; if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0; -print '<td class="center"><input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'></td>'; +print '<td class="center">'; +print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'>'; +print '</td>'; print '</tr>'."\n"; ?> <!-- END PHP TEMPLATE originproductline.tpl.php --> diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 96cb662fe0b..c4f0b6d4e83 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -730,6 +730,96 @@ class Mo extends CommonObject return $error; } + + /** + * Return HTML table table of source object lines + * TODO Move this and previous function into output html class file (htmlline.class.php). + * If lines are into a template, title must also be into a template + * But for the moment we don't know if it's possible, so we keep the method available on overloaded objects. + * + * @param string $restrictlist ''=All lines, 'services'=Restrict to services only + * @param array $selectedLines Array of lines id for selected lines + * @return void + */ + public function printOriginLinesList($restrictlist = '', $selectedLines = array()) + { + global $langs, $hookmanager, $conf, $form; + + print '<tr class="liste_titre">'; + print '<td>'.$langs->trans('Ref').'</td>'; + print '<td class="right">'.$langs->trans('Qty').'</td>'; + print '<td class="center">'.$langs->trans('QtyFrozen').'</td>'; + print '<td class="center">'.$langs->trans('DisableStockChange').'</td>'; + //print '<td class="right">'.$langs->trans('Efficiency').'</td>'; + //print '<td class="center">'.$form->showCheckAddButtons('checkforselect', 1).'</td>'; + print '<td class="center"></td>'; + print '</tr>'; + $i = 0; + + if (! empty($this->lines)) + { + foreach ($this->lines as $line) + { + if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) + { + if (empty($line->fk_parent_line)) + { + $parameters=array('line'=>$line, 'i'=>$i); + $action=''; + $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + } + } + else + { + $this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines); + } + + $i++; + } + } + } + + + /** + * Return HTML with a line of table array of source object lines + * TODO Move this and previous function into output html class file (htmlline.class.php). + * If lines are into a template, title must also be into a template + * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. + * + * @param CommonObjectLine $line Line + * @param string $var Var + * @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not) + * @param string $defaulttpldir Directory where to find the template + * @param array $selectedLines Array of lines id for selected lines + * @return void + */ + public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl', $selectedLines = array()) + { + global $langs, $conf; + + $this->tpl['id'] = $line->id; + + $this->tpl['label']=''; + if (! empty($line->fk_product)) + { + $productstatic = new Product($this->db); + $productstatic->fetch($line->fk_product); + $this->tpl['label'].= $productstatic->getNomUrl(1); + //$this->tpl['label'].= ' - '.$productstatic->label; + } + else + { + + } + + $this->tpl['qty'] = $line->qty; + $this->tpl['qty_frozen'] = $line->qty_frozen; + $this->tpl['disable_stock_change'] = $line->disable_stock_change; + //$this->tpl['efficiency'] = $line->efficiency; + + $tpl = DOL_DOCUMENT_ROOT.'/mrp/tpl/originproductline.tpl.php'; + $res = include $tpl; + } } /** diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 7294d5cb04d..1408162b111 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -47,8 +47,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -dol_include_once('/mrp/class/mo.class.php'); -dol_include_once('/mrp/lib/mrp_mo.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp_mo.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; // Load translation files required by the page $langs->loadLangs(array("mrp", "other")); @@ -65,6 +66,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects $object = new Mo($db); +$objectbom = new BOM($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('mocard', 'globalcard')); // Note that conf->hooks_modules contains array @@ -87,6 +89,16 @@ if (empty($action) && empty($id) && empty($ref)) $action = 'view'; // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. +if (GETPOST('fk_bom', 'int')) +{ + $objectbom->fetch(GETPOST('fk_bom', 'int')); + + $_POST['fk_product'] = $objectbom->fk_product; + $_POST['qty'] = $objectbom->qty; + $_POST['fk_warehouse'] = $objectbom->fk_warehouse; + $_POST['note_private'] = $objectbom->note_private; +} + // Security check - Protection if external user //if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) $socid = $user->socid; @@ -212,6 +224,9 @@ if ($action == 'create') console.log('We change value of BOM with BOM of id '+jQuery('#fk_bom').val()); if (jQuery('#fk_bom').val() > 0) { + // Redirect to page with fk_bom set + window.location.href = '<?php echo $_SERVER["PHP_SELF"] ?>?action=create&fk_bom='+jQuery('#fk_bom').val(); + /* $.getJSON('<?php echo DOL_URL_ROOT ?>/mrp/ajax/ajax_bom.php?action=getBoms&idbom='+jQuery('#fk_bom').val(), function(data) { console.log(data); if (typeof data.rowid != "undefined") { @@ -234,7 +249,7 @@ if ($action == 'create') } else { console.log("Failed to get BOM"); } - }); + });*/ } else { /* @@ -249,7 +264,7 @@ if ($action == 'create') } }); - jQuery('#fk_bom').trigger('change'); + //jQuery('#fk_bom').trigger('change'); }) </script> <?php @@ -260,6 +275,16 @@ if ($action == 'create') print '<input type="'.($backtopage ? "submit" : "button").'" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage print '</div>'; + print load_fiche_titre($langs->trans("ToConsume")); + + print '<table class="noborder centpercent">'; + + $object->lines = $objectbom->lines; + + $object->printOriginLinesList('', array()); + + print '</table>'; + print '</form>'; } diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php new file mode 100644 index 00000000000..67032eea7fe --- /dev/null +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -0,0 +1,44 @@ +<?php +/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com> +/* Copyright (C) 2017 Charlie Benke <charlie@patas-monkey.com> + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + +?> + +<!-- BEGIN PHP TEMPLATE originproductline.tpl.php --> +<?php +print '<tr class="oddeven'.(empty($this->tpl['strike'])?'':' strikefordisabled').'">'; +print '<td>'.$this->tpl['label'].'</td>'; +print '<td class="right">'.$this->tpl['qty'].'</td>'; +print '<td class="center">'.yn($this->tpl['qty_frozen']).'</td>'; +print '<td class="center">'.yn($this->tpl['disable_stock_change']).'</td>'; +//print '<td class="right">'.$this->tpl['efficiency'].'</td>'; + +$selected=1; +if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0; +print '<td class="center">'; +//print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'>'; +print '</td>'; +print '</tr>'."\n"; +?> +<!-- END PHP TEMPLATE originproductline.tpl.php --> From e2680f763791c2582a2e62e84c9fec7b19eca8b6 Mon Sep 17 00:00:00 2001 From: gauthier <gauthier.verdol@atm-consulting.fr> Date: Tue, 12 Nov 2019 09:42:27 +0100 Subject: [PATCH 182/299] FIX : limit 20 prevent to see all products/services --- htdocs/adherents/admin/adherent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index 4511ee0e8a7..ad41dd1dff8 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -208,7 +208,7 @@ if ($conf->facture->enabled) { print '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>'; print '<td>'; - $form->select_produits($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS'); + $form->select_produits($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0); print '</td>'; } print "</tr>\n"; From c85e54b08cd413c5c35ef59853355e823d8d4925 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com> Date: Tue, 12 Nov 2019 08:46:08 +0000 Subject: [PATCH 183/299] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/accountancy/customer/list.php | 250 +-- htdocs/accountancy/expensereport/list.php | 162 +- htdocs/accountancy/supplier/list.php | 242 +-- htdocs/adherents/list.php | 634 +++---- htdocs/admin/emailcollector_list.php | 286 ++-- htdocs/admin/mails_senderprofile_list.php | 286 ++-- htdocs/admin/system/filecheck.php | 292 ++-- htdocs/admin/triggers.php | 12 +- htdocs/asset/list.php | 248 +-- htdocs/bom/bom_list.php | 286 ++-- htdocs/comm/action/list.php | 534 +++--- htdocs/comm/propal/card.php | 776 ++++----- htdocs/comm/propal/list.php | 744 ++++---- htdocs/commande/card.php | 824 ++++----- htdocs/commande/list.php | 664 +++---- htdocs/compta/bank/bankentries_list.php | 794 ++++----- .../compta/cashcontrol/cashcontrol_list.php | 300 ++-- .../facture/class/facture-rec.class.php | 1044 ++++++------ htdocs/compta/facture/list.php | 838 ++++----- htdocs/contact/list.php | 258 +-- htdocs/contrat/class/contrat.class.php | 1518 ++++++++--------- htdocs/contrat/list.php | 526 +++--- htdocs/core/actions_massactions.inc.php | 606 +++---- htdocs/core/boxes/box_contacts.php | 56 +- .../core/boxes/box_last_modified_ticket.php | 38 +- htdocs/core/boxes/box_last_ticket.php | 18 +- htdocs/core/boxes/box_lastlogin.php | 16 +- htdocs/core/boxes/box_services_expired.php | 48 +- htdocs/core/class/html.formfile.class.php | 796 ++++----- htdocs/core/class/interfaces.class.php | 122 +- htdocs/cron/list.php | 282 +-- htdocs/expedition/list.php | 380 ++--- htdocs/expensereport/list.php | 316 ++-- htdocs/fichinter/list.php | 326 ++-- htdocs/fourn/commande/card.php | 798 ++++----- htdocs/fourn/commande/list.php | 666 ++++---- htdocs/fourn/facture/list.php | 610 +++---- htdocs/holiday/list.php | 280 +-- .../template/myobject_agenda.php | 98 +- .../template/myobject_document.php | 66 +- .../modulebuilder/template/myobject_list.php | 298 ++-- .../modulebuilder/template/myobject_note.php | 54 +- htdocs/mrp/mo_list.php | 302 ++-- htdocs/opensurvey/list.php | 110 +- htdocs/product/inventory/list.php | 304 ++-- htdocs/product/list.php | 708 ++++---- htdocs/product/stock/list.php | 262 +-- htdocs/product/stock/movement_card.php | 578 +++---- htdocs/product/stock/productlot_list.php | 252 +-- htdocs/projet/list.php | 576 +++---- htdocs/projet/tasks.php | 326 ++-- htdocs/projet/tasks/list.php | 548 +++--- htdocs/societe/list.php | 722 ++++---- htdocs/societe/website.php | 296 ++-- htdocs/supplier_proposal/card.php | 578 +++---- htdocs/supplier_proposal/list.php | 508 +++--- htdocs/ticket/list.php | 408 ++--- htdocs/zapier/hook_list.php | 332 ++-- 58 files changed, 12101 insertions(+), 12101 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index e3f1415c6f1..867c79099a6 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -27,22 +27,22 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","compta","accountancy","other","productbatch")); +$langs->loadLangs(array("bills", "compta", "accountancy", "other", "productbatch")); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Select Box @@ -57,16 +57,16 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); -$search_day=GETPOST("search_day", "int"); -$search_month=GETPOST("search_month", "int"); -$search_year=GETPOST("search_year", "int"); +$search_day = GETPOST("search_day", "int"); +$search_month = GETPOST("search_month", "int"); +$search_year = GETPOST("search_year", "int"); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -74,9 +74,9 @@ if (empty($page) || $page < 0) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) +if (!$sortfield) $sortfield = "f.datef, f.ref, l.rowid"; -if (! $sortorder) { +if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = "DESC"; } @@ -85,7 +85,7 @@ if (! $sortorder) { // Security check if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -100,11 +100,11 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -128,7 +128,7 @@ if (empty($reshook)) } // Mass actions - $objectclass='AccountingAccount'; + $objectclass = 'AccountingAccount'; $permissiontoread = $user->rights->accounting->read; $permissiontodelete = $user->rights->accounting->delete; $uploaddir = $conf->accounting->dir_output; @@ -137,15 +137,15 @@ if (empty($reshook)) if ($massaction == 'ventil') { - $msg=''; + $msg = ''; //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; - if (! empty($mesCasesCochees)) { - $msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'</div>'; - $msg.='<div class="detail">'; + if (!empty($mesCasesCochees)) { + $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>'; + $msg .= '<div class="detail">'; $cpt = 0; - $ok=0; - $ko=0; + $ok = 0; + $ko = 0; foreach ($mesCasesCochees as $maLigneCochee) { $maLigneCourante = explode("_", $maLigneCochee); @@ -154,32 +154,32 @@ if ($massaction == 'ventil') { if ($monCompte <= 0) { - $msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>'; + $msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>'; $ko++; } else { - $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; - $sql .= " SET fk_code_ventilation = " . $monCompte; - $sql .= " WHERE rowid = " . $monId; + $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " WHERE rowid = ".$monId; $accountventilated = new AccountingAccount($db); $accountventilated->fetch($monCompte, ''); - dol_syslog("accountancy/customer/list.php sql=" . $sql, LOG_DEBUG); + dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG); if ($db->query($sql)) { - $msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>'; + $msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>'; $ok++; } else { - $msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br> <pre>' . $sql . '</pre></font></div>'; + $msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br> <pre>'.$sql.'</pre></font></div>'; $ko++; } } $cpt++; } - $msg.='</div>'; - $msg.= '<div>' . $langs->trans("EndProcessing") . '</div>'; + $msg .= '</div>'; + $msg .= '<div>'.$langs->trans("EndProcessing").'</div>'; } } @@ -205,25 +205,25 @@ if (empty($chartaccountcode)) // Customer Invoice lines $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; -$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; -$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; -$sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; -$sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; -$sql.= " co.code as country_code, co.label as country_label,"; -$sql.= " s.tva_intra"; -$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 . "facture as f"; -$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; -$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; -$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; -$sql.= " AND l.product_type <= 2"; +$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; +$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; +$sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; +$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; +$sql .= " co.code as country_code, co.label as country_label,"; +$sql .= " s.tva_intra"; +$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."facture as f"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; +$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; +$sql .= " AND l.product_type <= 2"; // Add search filter like if ($search_lineid) { $sql .= natural_search("l.rowid", $search_lineid, 1); @@ -249,35 +249,35 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } -$sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); +$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); if (strlen(trim($search_country))) { $arrayofcode = getCountriesInEEC(); $country_code_in_EEC = $country_code_in_EEC_without_me = ''; foreach ($arrayofcode as $key => $value) { - $country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'"; - if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; + $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'"; + if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; } if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'"; elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")"; elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")"; elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")"; - else $sql .= natural_search(array("co.code","co.label"), $search_country); + else $sql .= natural_search(array("co.code", "co.label"), $search_country); } if (strlen(trim($search_tvaintra))) { $sql .= natural_search("s.tva_intra", $search_tvaintra); } -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } -$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); @@ -307,33 +307,33 @@ if ($result) { $num_lines = $db->num_rows($result); $i = 0; - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $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_lineid) $param.='&search_lineid='.urlencode($search_lineid); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_invoice) $param.='&search_invoice='.urlencode($search_invoice); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_desc) $param.='&search_desc='.urlencode($search_desc); - if ($search_amount) $param.='&search_amount='.urlencode($search_amount); - if ($search_vat) $param.='&search_vat='.urlencode($search_vat); - if ($search_country) $param.= "&search_country=".urlencode($search_country); - if ($search_tvaintra) $param.= "&search_tvaintra=".urlencode($search_tvaintra); + $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_lineid) $param .= '&search_lineid='.urlencode($search_lineid); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_invoice) $param .= '&search_invoice='.urlencode($search_invoice); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); + if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); + if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); + if ($search_country) $param .= "&search_country=".urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); - $arrayofmassactions = array( + $arrayofmassactions = array( 'ventil'=>$langs->trans("Ventilate") //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); + $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); - print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; + print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n"; print '<input type="hidden" name="action" value="ventil">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; @@ -344,7 +344,7 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer") . '</span></br><br>'; + print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>'; /*$topicmail="Information"; $modelmail="project"; @@ -357,33 +357,33 @@ if ($result) { $moreforfilter = ''; print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // We add search filter print '<tr class="liste_titre_filter">'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'""></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>'; print '<td class="liste_titre center nowraponall">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; } print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">'; $formother->select_year($search_year, 'search_year', 1, 20, 5); print '</td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>'; //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; - print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>'; - print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; + print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>'; + print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre">'; print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1); //print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">'; print '</td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>'; print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>'; print '<td class="center liste_titre">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'; @@ -401,8 +401,8 @@ if ($result) { print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center '); print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); - $checkpicto=''; - if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); + $checkpicto = ''; + if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "</tr>\n"; @@ -429,39 +429,39 @@ if ($result) { $facture_static->type = $objp->ftype; $code_sell_p_notset = ''; - $objp->aarowid_suggest = ''; // Will be set later + $objp->aarowid_suggest = ''; // Will be set later $isBuyerInEEC = isInEEC($objp); $suggestedaccountingaccountbydefaultfor = ''; if ($objp->type_l == 1) { if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'eec'; } else { // Foreign sale - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'export'; } } } elseif ($objp->type_l == 0) { if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'eec'; } else { - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'export'; } } } - if ($objp->code_sell_l == -1) $objp->code_sell_l=''; + if ($objp->code_sell_l == -1) $objp->code_sell_l = ''; // Search suggested account for product/service $suggestedaccountingaccountfor = ''; @@ -494,12 +494,12 @@ if ($result) { print '<tr class="oddeven">'; // Line id - print '<td>' . $objp->rowid . '</td>'; + print '<td>'.$objp->rowid.'</td>'; // Ref Invoice - print '<td class="nowraponall">' . $facture_static->getNomUrl(1) . '</td>'; + print '<td class="nowraponall">'.$facture_static->getNomUrl(1).'</td>'; - print '<td class="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>'; + print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>'; // Ref Product print '<td>'; @@ -521,34 +521,34 @@ if ($result) { // Vat rate if ($objp->vat_tx_l != $objp->vat_tx_p) $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; - print '<td style="' . $code_vat_differ . '" class="right">'; - print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')); + print '<td style="'.$code_vat_differ.'" class="right">'; + print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')); print '</td>'; // Country print '<td>'; - $labelcountry=($objp->country_code && ($langs->trans("Country".$objp->country_code)!="Country".$objp->country_code))?$langs->trans("Country".$objp->country_code):$objp->country_label; + $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; print $labelcountry; print '</td>'; - print '<td>' . $objp->tva_intra . '</td>'; + print '<td>'.$objp->tva_intra.'</td>'; // Current account - print '<td class="center" style="' . $code_sell_p_notset . '">'; - $s = (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")).': '; + print '<td class="center" style="'.$code_sell_p_notset.'">'; + $s = (($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; $shelp = ''; - if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp.= $langs->trans("SaleEEC"); - elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp.= $langs->trans("SaleExport"); - $s.= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("NotDefined")); + if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); + elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); + $s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("NotDefined")); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); if ($objp->product_id > 0) { print '<br>'; - $s = (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")).': '; + $s = (($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); - $s.= (empty($objp->code_sell_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_sell_p)); + $s .= (empty($objp->code_sell_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_sell_p)); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); } print '</td>'; @@ -582,11 +582,11 @@ if ($result) { print '<td class="center">'; //var_dump($objp->aarowid);var_dump($objp->aarowid_intra);var_dump($objp->aarowid_export);var_dump($objp->aarowid_suggest); $ischecked = $objp->aarowid_suggest; - print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($ischecked ? "checked" : "") . '/>'; + print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="'.$objp->rowid."_".$i.'"'.($ischecked ? "checked" : "").'/>'; print '</td>'; print '</tr>'; - $i ++; + $i++; } print '</table>'; print "</div>"; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index a1c354f010b..29b58d76c78 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -27,20 +27,20 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","compta","accountancy","other","trips","productbatch")); +$langs->loadLangs(array("bills", "compta", "accountancy", "other", "trips", "productbatch")); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Select Box @@ -53,14 +53,14 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); -$search_day=GETPOST("search_day", "int"); -$search_month=GETPOST("search_month", "int"); -$search_year=GETPOST("search_year", "int"); +$search_day = GETPOST("search_day", "int"); +$search_month = GETPOST("search_month", "int"); +$search_year = GETPOST("search_year", "int"); $btn_ventil = GETPOST('ventil', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -68,9 +68,9 @@ if (empty($page) || $page < 0) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) +if (!$sortfield) $sortfield = "erd.date, erd.rowid"; -if (! $sortorder) { +if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = "DESC"; } @@ -79,7 +79,7 @@ if (! $sortorder) { // Security check if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); $formaccounting = new FormAccounting($db); @@ -92,8 +92,8 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco * Action */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers @@ -110,23 +110,23 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' } // Mass actions -$objectclass='ExpenseReport'; -$objectlabel='ExpenseReport'; +$objectclass = 'ExpenseReport'; +$objectlabel = 'ExpenseReport'; $permissiontoread = $user->rights->expensereport->read; $permissiontodelete = $user->rights->expensereport->delete; $uploaddir = $conf->expensereport->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; if ($massaction == 'ventil') { - $msg=''; + $msg = ''; //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; - if (! empty($mesCasesCochees)) { - $msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'</div>'; - $msg.='<div class="detail">'; + if (!empty($mesCasesCochees)) { + $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>'; + $msg .= '<div class="detail">'; $mesCodesVentilChoisis = $codeventil; $cpt = 0; - $ok=0; - $ko=0; + $ok = 0; + $ko = 0; foreach ($mesCasesCochees as $maLigneCochee) { $maLigneCourante = explode("_", $maLigneCochee); @@ -135,32 +135,32 @@ if ($massaction == 'ventil') { if ($monCompte <= 0) { - $msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>'; + $msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>'; $ko++; } else { - $sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det"; - $sql .= " SET fk_code_ventilation = " . $monCompte; - $sql .= " WHERE rowid = " . $monId; + $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; + $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " WHERE rowid = ".$monId; $accountventilated = new AccountingAccount($db); $accountventilated->fetch($monCompte, ''); - dol_syslog('accountancy/expensereport/list.php:: sql=' . $sql, LOG_DEBUG); + dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); if ($db->query($sql)) { - $msg.= '<div><font color="green">' . $langs->trans("LineOfExpenseReport") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>'; + $msg .= '<div><font color="green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>'; $ok++; } else { - $msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>'; + $msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>'; $ko++; } } $cpt++; } - $msg.='</div>'; - $msg.= '<div>' . $langs->trans("EndProcessing") . '</div>'; + $msg .= '</div>'; + $msg .= '<div>'.$langs->trans("EndProcessing").'</div>'; } } @@ -186,14 +186,14 @@ if (empty($chartaccountcode)) // Expense report lines $sql = "SELECT er.ref, er.rowid as erid, er.date_debut,"; -$sql.= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, erd.vat_src_code, erd.date,"; -$sql.= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label, f.accountancy_code as code_buy,"; -$sql.= " aa.rowid as aarowid"; -$sql.= " FROM " . MAIN_DB_PREFIX . "expensereport as er"; -$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport_det as erd ON er.rowid = erd.fk_expensereport"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; -$sql.= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0"; +$sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, erd.vat_src_code, erd.date,"; +$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label, f.accountancy_code as code_buy,"; +$sql .= " aa.rowid as aarowid"; +$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; +$sql .= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0"; // Add search filter like if (strlen(trim($search_expensereport))) { $sql .= natural_search("er.ref", $search_expensereport); @@ -213,8 +213,8 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("erd.tva_tx", $search_vat, 1); } -$sql.=dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year); -$sql.= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy +$sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year); +$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); @@ -239,32 +239,32 @@ if ($result) { $num_lines = $db->num_rows($result); $i = 0; - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_expensereport) $param.='&search_expensereport='.urlencode($search_expensereport); - if ($search_label) $param.='&search_label='.urlencode($search_label); - if ($search_desc) $param.='&search_desc='.urlencode($search_desc); - if ($search_amount) $param.='&search_amount='.urlencode($search_amount); - if ($search_vat) $param.='&search_vat='.urlencode($search_vat); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_expensereport) $param .= '&search_expensereport='.urlencode($search_expensereport); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); + if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); + if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); - $arrayofmassactions = array( + $arrayofmassactions = array( 'ventil'=>$langs->trans("Ventilate") //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); + $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); - print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; + print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n"; print '<input type="hidden" name="action" value="ventil">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; @@ -275,7 +275,7 @@ if ($result) { print_barre_liste($langs->trans("ExpenseReportLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoExpenseReport") . '</span></br><br>'; + print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoExpenseReport").'</span></br><br>'; /*$topicmail="Information"; $modelmail="project"; @@ -288,25 +288,25 @@ if ($result) { $moreforfilter = ''; print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // We add search filter print '<tr class="liste_titre_filter">'; print '<td class="liste_titre"></td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="' . dol_escape_htmltag($search_expensereport) . '"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>'; print '<td class="liste_titre center">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">'; $formother->select_year($search_year, 'search_year', 1, 20, 5); print '</td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; - print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>'; - print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; + print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>'; + print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>'; print '<td class="center" class="liste_titre">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'; @@ -321,8 +321,8 @@ if ($result) { print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', $sortfield, $sortorder, 'center '); print_liste_field_titre("IntoAccount", '', '', '', '', '', $sortfield, $sortorder, 'center '); - $checkpicto=''; - if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); + $checkpicto = ''; + if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "</tr>\n"; @@ -330,7 +330,7 @@ if ($result) { $expensereport_static = new ExpenseReport($db); $form = new Form($db); - while ( $i < min($num_lines, $limit) ) { + while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); $objp->aarowid_suggest = ''; @@ -342,13 +342,13 @@ if ($result) { print '<tr class="oddeven">'; // Line id - print '<td>' . $objp->rowid . '</td>'; + print '<td>'.$objp->rowid.'</td>'; // Ref Expense report - print '<td>' . $expensereport_static->getNomUrl(1) . '</td>'; + print '<td>'.$expensereport_static->getNomUrl(1).'</td>'; // Date - print '<td class="center">' . dol_print_date($db->jdate($objp->date), 'day') . '</td>'; + print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>'; // Fees label print '<td>'; @@ -368,7 +368,7 @@ if ($result) { // Vat rate print '<td class="right">'; - print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')); + print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')); print '</td>'; // Current account @@ -382,11 +382,11 @@ if ($result) { print '</td>'; print '<td class="center">'; - print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>'; + print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="'.$objp->rowid."_".$i.'"'.($objp->aarowid ? "checked" : "").'/>'; print '</td>'; print "</tr>"; - $i ++; + $i++; } print '</table>'; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 249cb920c47..bf27dcf650d 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -27,22 +27,22 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","compta","accountancy","other","productbatch")); +$langs->loadLangs(array("bills", "compta", "accountancy", "other", "productbatch")); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Select Box @@ -57,16 +57,16 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); -$search_day=GETPOST("search_day", "int"); -$search_month=GETPOST("search_month", "int"); -$search_year=GETPOST("search_year", "int"); +$search_day = GETPOST("search_day", "int"); +$search_month = GETPOST("search_month", "int"); +$search_year = GETPOST("search_year", "int"); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -74,9 +74,9 @@ if (empty($page) || $page < 0) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) +if (!$sortfield) $sortfield = "f.datef, f.ref, l.rowid"; -if (! $sortorder) { +if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = "DESC"; } @@ -85,7 +85,7 @@ if (! $sortorder) { // Security check if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -104,11 +104,11 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -132,7 +132,7 @@ if (empty($reshook)) } // Mass actions - $objectclass='AccountingAccount'; + $objectclass = 'AccountingAccount'; $permissiontoread = $user->rights->accounting->read; $permissiontodelete = $user->rights->accounting->delete; $uploaddir = $conf->accounting->dir_output; @@ -141,15 +141,15 @@ if (empty($reshook)) if ($massaction == 'ventil') { - $msg=''; + $msg = ''; //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; - if (! empty($mesCasesCochees)) { - $msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'</div>'; - $msg.='<div class="detail">'; + if (!empty($mesCasesCochees)) { + $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>'; + $msg .= '<div class="detail">'; $cpt = 0; - $ok=0; - $ko=0; + $ok = 0; + $ko = 0; foreach ($mesCasesCochees as $maLigneCochee) { $maLigneCourante = explode("_", $maLigneCochee); @@ -158,32 +158,32 @@ if ($massaction == 'ventil') { if ($monCompte <= 0) { - $msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>'; + $msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>'; $ko++; } else { - $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sql .= " SET fk_code_ventilation = " . $monCompte; - $sql .= " WHERE rowid = " . $monId; + $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; + $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " WHERE rowid = ".$monId; $accountventilated = new AccountingAccount($db); $accountventilated->fetch($monCompte, ''); - dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG); + dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG); if ($db->query($sql)) { - $msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>'; + $msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>'; $ok++; } else { - $msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>'; + $msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>'; $ko++; } } $cpt++; } - $msg.='</div>'; - $msg.= '<div>' . $langs->trans("EndProcessing") . '</div>'; + $msg .= '</div>'; + $msg .= '<div>'.$langs->trans("EndProcessing").'</div>'; } } @@ -209,22 +209,22 @@ if (empty($chartaccountcode)) // Supplier Invoice Lines $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; -$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; -$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; -$sql.= " aa.rowid as aarowid,"; -$sql.= " co.code as country_code, co.label as country_label,"; -$sql.= " s.tva_intra"; -$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 . "facture_fourn as f"; -$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; -$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; -$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; -$sql.= " AND l.product_type <= 2"; +$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; +$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; +$sql .= " aa.rowid as aarowid,"; +$sql .= " co.code as country_code, co.label as country_label,"; +$sql .= " s.tva_intra"; +$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."facture_fourn as f"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; +$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; +$sql .= " AND l.product_type <= 2"; // Add search filter like if ($search_lineid) { $sql .= natural_search("l.rowid", $search_lineid, 1); @@ -250,35 +250,35 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } -$sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); +$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); if (strlen(trim($search_country))) { $arrayofcode = getCountriesInEEC(); $country_code_in_EEC = $country_code_in_EEC_without_me = ''; foreach ($arrayofcode as $key => $value) { - $country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'"; - if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; + $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'"; + if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; } if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'"; elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")"; elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")"; elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")"; - else $sql .= natural_search(array("co.code","co.label"), $search_country); + else $sql .= natural_search(array("co.code", "co.label"), $search_country); } if (strlen(trim($search_tvaintra))) { $sql .= natural_search("s.tva_intra", $search_tvaintra); } -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.",".FactureFournisseur::TYPE_SITUATION.")"; } -$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); @@ -304,34 +304,34 @@ if ($result) { $num_lines = $db->num_rows($result); $i = 0; - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $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_lineid) $param.='&search_lineid='.urlencode($search_lineid); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_invoice) $param.='&search_invoice='.urlencode($search_invoice); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_label) $param.='&search_label='.urlencode($search_label); - if ($search_desc) $param.='&search_desc='.urlencode($search_desc); - if ($search_amount) $param.='&search_amount='.urlencode($search_amount); - if ($search_vat) $param.='&search_vat='.urlencode($search_vat); - if ($search_country) $param.="&search_country=".urlencode($search_country); - if ($search_tvaintra) $param.="&search_tvaintra=".urlencode($search_tvaintra); + $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_lineid) $param .= '&search_lineid='.urlencode($search_lineid); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_invoice) $param .= '&search_invoice='.urlencode($search_invoice); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); + if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); + if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); + if ($search_country) $param .= "&search_country=".urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); - $arrayofmassactions = array( + $arrayofmassactions = array( 'ventil'=>$langs->trans("Ventilate") //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); + $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); - print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; + print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n"; print '<input type="hidden" name="action" value="ventil">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; @@ -342,7 +342,7 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer") . '</span></br><br>'; + print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>'; /*$topicmail="Information"; $modelmail="project"; @@ -355,31 +355,31 @@ if ($result) { $moreforfilter = ''; print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // We add search filter print '<tr class="liste_titre_filter">'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'""></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>'; print '<td class="liste_titre center nowraponall">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">'; $formother->select_year($search_year, 'search_year', 1, 20, 5); print '</td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; - print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>'; - print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; + print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>'; + print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre">'; print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1); //print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">'; print '</td>'; - print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>'; + print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>'; print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>'; print '<td class="center liste_titre">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; @@ -398,8 +398,8 @@ if ($result) { print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center '); print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); - $checkpicto=''; - if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); + $checkpicto = ''; + if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "</tr>\n"; @@ -429,18 +429,18 @@ if ($result) { $objp->aarowid_suggest = $objp->aarowid; if ($objp->type_l == 1) { - $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : ''); + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : ''); if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_s; } elseif ($objp->type_l == 0) { - $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : ''); + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : ''); if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_p; } - if ($objp->code_buy_l == -1) $objp->code_buy_l=''; + if ($objp->code_buy_l == -1) $objp->code_buy_l = ''; - if (! empty($objp->code_buy)) { - $objp->code_buy_p = $objp->code_buy; // Code on product + if (!empty($objp->code_buy)) { + $objp->code_buy_p = $objp->code_buy; // Code on product } else { $code_buy_p_notset = 'color:orange'; } @@ -452,16 +452,16 @@ if ($result) { print '<tr class="oddeven">'; // Line id - print '<td>' . $objp->rowid . '</td>'; + print '<td>'.$objp->rowid.'</td>'; // Ref Invoice - print '<td class="nowraponall">' . $facturefourn_static->getNomUrl(1) . '</td>'; + print '<td class="nowraponall">'.$facturefourn_static->getNomUrl(1).'</td>'; print '<td class="tdoverflowonsmartphone">'; print $objp->invoice_label; print '</td>'; - print '<td class="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>'; + print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>'; // Ref Product print '<td>'; @@ -484,35 +484,35 @@ if ($result) { // Vat rate if ($objp->vat_tx_l != $objp->vat_tx_p) $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; - print '<td style="' . $code_vat_differ . '" class="right">'; - print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')); + print '<td style="'.$code_vat_differ.'" class="right">'; + print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')); print '</td>'; // Country print '<td>'; - $labelcountry=($objp->country_code && ($langs->trans("Country".$objp->country_code)!="Country".$objp->country_code))?$langs->trans("Country".$objp->country_code):$objp->country_label; + $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; print $labelcountry; print '</td>'; // VAT Num - print '<td>' . $objp->tva_intra . '</td>'; + print '<td>'.$objp->tva_intra.'</td>'; // Current account - print '<td class="center" style="' . $code_buy_p_notset . '">'; - $s = (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")).': '; + print '<td class="center" style="'.$code_buy_p_notset.'">'; + $s = (($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; $shelp = ''; - if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp.= $langs->trans("SaleEEC"); - elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp.= $langs->trans("SaleExport"); - $s.= ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("NotDefined")); + if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); + elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); + $s .= ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("NotDefined")); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); if ($objp->product_id > 0) { print '<br>'; - $s = (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")).': '; + $s = (($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); - $s.= (empty($objp->code_buy_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_buy_p)); + $s .= (empty($objp->code_buy_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_buy_p)); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); } print '</td>'; @@ -526,11 +526,11 @@ if ($result) { // Column with checkbox print '<td class="center">'; $ischecked = $objp->aarowid_suggest; - print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($ischecked ? "checked" : "") . '/>'; + print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="'.$objp->rowid."_".$i.'"'.($ischecked ? "checked" : "").'/>'; print '</td>'; print '</tr>'; - $i ++; + $i++; } print '</table>'; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 81d6b7625b7..1cf99284074 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -32,55 +32,55 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -$langs->loadLangs(array("members","companies")); +$langs->loadLangs(array("members", "companies")); -$action=GETPOST('action', 'aZ09'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'memberslist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'memberslist'; // To manage different context of search // Security check -$result=restrictedArea($user, 'adherent'); +$result = restrictedArea($user, 'adherent'); -$filter=GETPOST("filter", 'alpha'); -$statut=GETPOST("statut", 'intcomma'); -$search=GETPOST("search", 'alpha'); -$search_ref=GETPOST("search_ref", 'alpha'); -$search_lastname=GETPOST("search_lastname", 'alpha'); -$search_firstname=GETPOST("search_firstname", 'alpha'); -$search_gender=GETPOST("search_gender", 'alpha'); -$search_civility=GETPOST("search_civility", 'alpha'); -$search_login=GETPOST("search_login", 'alpha'); -$search_address=GETPOST("search_address", 'alpha'); -$search_zip=GETPOST("search_zip", 'alpha'); -$search_town=GETPOST("search_town", 'alpha'); -$search_state=GETPOST("search_state", 'alpha'); -$search_country=GETPOST("search_country", 'alpha'); -$search_phone=GETPOST("search_phone", 'alpha'); -$search_phone_perso=GETPOST("search_phone_perso", 'alpha'); -$search_phone_mobile=GETPOST("search_phone_mobile", 'alpha'); -$search_type=GETPOST("search_type", 'alpha'); -$search_email=GETPOST("search_email", 'alpha'); +$filter = GETPOST("filter", 'alpha'); +$statut = GETPOST("statut", 'intcomma'); +$search = GETPOST("search", 'alpha'); +$search_ref = GETPOST("search_ref", 'alpha'); +$search_lastname = GETPOST("search_lastname", 'alpha'); +$search_firstname = GETPOST("search_firstname", 'alpha'); +$search_gender = GETPOST("search_gender", 'alpha'); +$search_civility = GETPOST("search_civility", 'alpha'); +$search_login = GETPOST("search_login", 'alpha'); +$search_address = GETPOST("search_address", 'alpha'); +$search_zip = GETPOST("search_zip", 'alpha'); +$search_town = GETPOST("search_town", 'alpha'); +$search_state = GETPOST("search_state", 'alpha'); +$search_country = GETPOST("search_country", 'alpha'); +$search_phone = GETPOST("search_phone", 'alpha'); +$search_phone_perso = GETPOST("search_phone_perso", 'alpha'); +$search_phone_mobile = GETPOST("search_phone_mobile", 'alpha'); +$search_type = GETPOST("search_type", 'alpha'); +$search_email = GETPOST("search_email", 'alpha'); $search_categ = GETPOST("search_categ", 'int'); $catid = GETPOST("catid", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); if ($statut < -1) $statut = ''; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$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) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page ; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); } -if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); } +if (!$sortorder) { $sortorder = ($filter == 'outofdate' ? "DESC" : "ASC"); } +if (!$sortfield) { $sortfield = ($filter == 'outofdate' ? "d.datefin" : "d.lastname"); } $object = new Adherent($db); @@ -91,7 +91,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -108,8 +108,8 @@ $fieldstosearchall = array( 'd.note_public'=>'NotePublic', 'd.note_private'=>'NotePrivate', ); -if($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']); -$arrayfields=array( +if ($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']); +$arrayfields = array( 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0), 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), @@ -139,10 +139,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } @@ -151,11 +151,11 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) @@ -166,48 +166,48 @@ if (empty($reshook)) // 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=""; - $search_ref=""; - $search_lastname=""; - $search_firstname=""; - $search_gender=""; - $search_civility=""; - $search_login=""; - $search_company=""; - $search_type=""; - $search_email=""; - $search_address=""; - $search_zip=""; - $search_town=""; - $search_state=""; - $search_country=''; - $search_phone=''; - $search_phone_perso=''; - $search_phone_mobile=''; - $search_morphy=""; - $search_categ=""; - $catid=""; - $sall=""; - $statut=''; - $toselect=''; - $search_array_options=array(); + $search = ""; + $search_ref = ""; + $search_lastname = ""; + $search_firstname = ""; + $search_gender = ""; + $search_civility = ""; + $search_login = ""; + $search_company = ""; + $search_type = ""; + $search_email = ""; + $search_address = ""; + $search_zip = ""; + $search_town = ""; + $search_state = ""; + $search_country = ''; + $search_phone = ''; + $search_phone_perso = ''; + $search_phone_mobile = ''; + $search_morphy = ""; + $search_categ = ""; + $catid = ""; + $sall = ""; + $statut = ''; + $toselect = ''; + $search_array_options = array(); } // Close if ($massaction == 'close' && $user->rights->adherent->creer) { $tmpmember = new Adherent($db); - $error=0; - $nbclose=0; + $error = 0; + $nbclose = 0; $db->begin(); - foreach($toselect as $idtoclose) + foreach ($toselect as $idtoclose) { $tmpmember->fetch($idtoclose); - $result=$tmpmember->resiliate($user); + $result = $tmpmember->resiliate($user); - if ($result < 0 && ! count($tmpmember->errors)) + if ($result < 0 && !count($tmpmember->errors)) { setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); } @@ -217,7 +217,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); @@ -230,8 +230,8 @@ if (empty($reshook)) } // Mass actions - $objectclass='Adherent'; - $objectlabel='Members'; + $objectclass = 'Adherent'; + $objectlabel = 'Members'; $permissiontoread = $user->rights->adherent->lire; $permissiontodelete = $user->rights->adherent->supprimer; $uploaddir = $conf->adherent->dir_output; @@ -243,69 +243,69 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$formother=new FormOther($db); -$membertypestatic=new AdherentType($db); -$memberstatic=new Adherent($db); +$form = new Form($db); +$formother = new FormOther($db); +$membertypestatic = new AdherentType($db); +$memberstatic = new Adherent($db); -$now=dol_now(); +$now = dol_now(); $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,"; -$sql.= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; -$sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,"; -$sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; -$sql.= " t.libelle as type, t.subscription,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; +$sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,"; +$sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; +$sql .= " t.libelle as type, t.subscription,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=preg_replace('/^,/', '', $hookmanager->resPrint); -$sql =preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; -if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)"; -$sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; -$sql.= " WHERE d.fk_adherent_type = t.rowid "; -if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid); -if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL"; -if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; -$sql.= " AND d.entity IN (".getEntity('adherent').")"; -if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall); -if ($search_type > 0) $sql.=" AND t.rowid=".$db->escape($search_type); -if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; +if (!empty($search_categ) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)"; +$sql .= ", ".MAIN_DB_PREFIX."adherent_type as t"; +$sql .= " WHERE d.fk_adherent_type = t.rowid "; +if ($catid > 0) $sql .= " AND cm.fk_categorie = ".$db->escape($catid); +if ($catid == -2) $sql .= " AND cm.fk_categorie IS NULL"; +if ($search_categ > 0) $sql .= " AND cm.fk_categorie = ".$db->escape($search_categ); +if ($search_categ == -2) $sql .= " AND cm.fk_categorie IS NULL"; +$sql .= " AND d.entity IN (".getEntity('adherent').")"; +if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_type > 0) $sql .= " AND t.rowid=".$db->escape($search_type); +if ($statut != '') $sql .= " AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules if ($search_ref) { - if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$db->escape($search_ref).")"; - else $sql.=" AND 1 = 2"; // Always wrong + if (is_numeric($search_ref)) $sql .= " AND (d.rowid = ".$db->escape($search_ref).")"; + else $sql .= " AND 1 = 2"; // Always wrong } -if ($search_civility) $sql.= natural_search("d.civility", $search_civility); -if ($search_firstname) $sql.= natural_search("d.firstname", $search_firstname); -if ($search_lastname) $sql.= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname); -if ($search_gender != '' && $search_gender != '-1') $sql.= " AND d.gender = '".$search_gender."'"; -if ($search_login) $sql.= natural_search("d.login", $search_login); -if ($search_email) $sql.= natural_search("d.email", $search_email); -if ($search_town) $sql.= natural_search("d.town", $search_town); -if ($search_zip) $sql.= natural_search("d.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_civility) $sql .= natural_search("d.civility", $search_civility); +if ($search_firstname) $sql .= natural_search("d.firstname", $search_firstname); +if ($search_lastname) $sql .= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname); +if ($search_gender != '' && $search_gender != '-1') $sql .= " AND d.gender = '".$search_gender."'"; +if ($search_login) $sql .= natural_search("d.login", $search_login); +if ($search_email) $sql .= natural_search("d.email", $search_email); +if ($search_town) $sql .= natural_search("d.town", $search_town); +if ($search_zip) $sql .= natural_search("d.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND d.country IN (".$search_country.')'; -if ($filter == 'uptodate') $sql.=" AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)"; -if ($filter == 'outofdate') $sql.=" AND ((datefin IS NULL OR datefin < '".$db->idate($now)."') AND t.subscription = 1)"; +if ($filter == 'uptodate') $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)"; +if ($filter == 'outofdate') $sql .= " AND ((datefin IS NULL OR datefin < '".$db->idate($now)."') AND t.subscription = 1)"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records with no order and no limits $nbtotalofrecords = ''; @@ -321,11 +321,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } // Add limit -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); dol_syslog("get list", LOG_DEBUG); $resql = $db->query($sql); -if (! $resql) +if (!$resql) { dol_print_error($db); exit; @@ -333,9 +333,9 @@ if (! $resql) $num = $db->num_rows($resql); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -345,69 +345,69 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); -$titre=$langs->trans("MembersList"); +$titre = $langs->trans("MembersList"); if (GETPOSTISSET("statut")) { - if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); } - if ($statut == '-1') { $titre=$langs->trans("MembersListToValid"); } - if ($statut == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); } - if ($statut == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); } - if ($statut == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } - if ($statut == '0') { $titre=$langs->trans("MembersListResiliated"); } + if ($statut == '-1,1') { $titre = $langs->trans("MembersListQualified"); } + if ($statut == '-1') { $titre = $langs->trans("MembersListToValid"); } + if ($statut == '1' && !$filter) { $titre = $langs->trans("MembersListValid"); } + if ($statut == '1' && $filter == 'uptodate') { $titre = $langs->trans("MembersListUpToDate"); } + if ($statut == '1' && $filter == 'outofdate') { $titre = $langs->trans("MembersListNotUpToDate"); } + if ($statut == '0') { $titre = $langs->trans("MembersListResiliated"); } } elseif ($action == 'search') { - $titre=$langs->trans("MembersListQualified"); + $titre = $langs->trans("MembersListQualified"); } if ($search_type > 0) { - $membertype=new AdherentType($db); - $result=$membertype->fetch(GETPOST("type", 'int')); - $titre.=" (".$membertype->label.")"; + $membertype = new AdherentType($db); + $result = $membertype->fetch(GETPOST("type", 'int')); + $titre .= " (".$membertype->label.")"; } -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -if ($sall != "") $param.="&sall=".urlencode($sall); -if ($statut != "") $param.="&statut=".urlencode($statut); -if ($search_ref) $param.="&search_ref=".urlencode($search_ref); -if ($search_civility) $param.="&search_civility=".urlencode($search_civility); -if ($search_firstname) $param.="&search_firstname=".urlencode($search_firstname); -if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname); -if ($search_gender) $param.="&search_gender=".urlencode($search_gender); -if ($search_login) $param.="&search_login=".urlencode($search_login); -if ($search_email) $param.="&search_email=".urlencode($search_email); -if ($search_company) $param.="&search_company=".urlencode($search_company); -if ($search_address != '') $param.= "&search_address=".urlencode($search_address); -if ($search_town != '') $param.= "&search_town=".urlencode($search_town); -if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); -if ($search_state != '') $param.= "&search_state=".urlencode($search_state); -if ($search_country != '') $param.= "&search_country=".urlencode($search_country); -if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone); -if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso); -if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile); -if ($filter) $param.="&filter=".urlencode($filter); -if ($search_type > 0) $param.="&search_type=".urlencode($search_type); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($sall != "") $param .= "&sall=".urlencode($sall); +if ($statut != "") $param .= "&statut=".urlencode($statut); +if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); +if ($search_civility) $param .= "&search_civility=".urlencode($search_civility); +if ($search_firstname) $param .= "&search_firstname=".urlencode($search_firstname); +if ($search_lastname) $param .= "&search_lastname=".urlencode($search_lastname); +if ($search_gender) $param .= "&search_gender=".urlencode($search_gender); +if ($search_login) $param .= "&search_login=".urlencode($search_login); +if ($search_email) $param .= "&search_email=".urlencode($search_email); +if ($search_company) $param .= "&search_company=".urlencode($search_company); +if ($search_address != '') $param .= "&search_address=".urlencode($search_address); +if ($search_town != '') $param .= "&search_town=".urlencode($search_town); +if ($search_zip != '') $param .= "&search_zip=".urlencode($search_zip); +if ($search_state != '') $param .= "&search_state=".urlencode($search_state); +if ($search_country != '') $param .= "&search_country=".urlencode($search_country); +if ($search_phone != '') $param .= "&search_phone=".urlencode($search_phone); +if ($search_phone_perso != '') $param .= "&search_phone_perso=".urlencode($search_phone_perso); +if ($search_phone_mobile != '') $param .= "&search_phone_mobile=".urlencode($search_phone_mobile); +if ($filter) $param .= "&filter=".urlencode($filter); +if ($search_type > 0) $param .= "&search_type=".urlencode($search_type); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->adherent->creer) $arrayofmassactions['close']=$langs->trans("Resiliate"); -if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->adherent->creer) $arrayofmassactions['close'] = $langs->trans("Resiliate"); +if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->adherent->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); } print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; @@ -422,164 +422,164 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit); -$topicmail="Information"; -$modelmail="member"; -$objecttmp=new Adherent($db); -$trackid='mem'.$object->id; +$topicmail = "Information"; +$modelmail = "member"; +$objecttmp = new Adherent($db); +$trackid = 'mem'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } // Filter on categories -$moreforfilter=''; -if (! empty($conf->categorie->enabled)) +$moreforfilter = ''; +if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1); - $moreforfilter.='</div>'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter .= $formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1); + $moreforfilter .= '</div>'; } -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Line for filters fields print '<tr class="liste_titre_filter">'; // Line numbering -if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) +if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print '<td class="liste_titre"> </td>'; } // Ref -if (! empty($arrayfields['d.ref']['checked'])) +if (!empty($arrayfields['d.ref']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth75imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } -if (! empty($arrayfields['d.civility']['checked'])) +if (!empty($arrayfields['d.civility']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth50imp" type="text" name="search_civility" value="'.dol_escape_htmltag($search_civility).'"></td>'; } -if (! empty($arrayfields['d.firstname']['checked'])) +if (!empty($arrayfields['d.firstname']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>'; } -if (! empty($arrayfields['d.lastname']['checked'])) +if (!empty($arrayfields['d.lastname']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>'; } -if (! empty($arrayfields['d.gender']['checked'])) +if (!empty($arrayfields['d.gender']['checked'])) { print '<td class="liste_titre">'; - $arraygender=array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); print $form->selectarray('search_gender', $arraygender, $search_gender, 1); print '</td>'; } -if (! empty($arrayfields['d.company']['checked'])) +if (!empty($arrayfields['d.company']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>'; } -if (! empty($arrayfields['d.login']['checked'])) +if (!empty($arrayfields['d.login']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>'; } -if (! empty($arrayfields['d.morphy']['checked'])) +if (!empty($arrayfields['d.morphy']['checked'])) { print '<td class="liste_titre left">'; print '</td>'; } -if (! empty($arrayfields['t.libelle']['checked'])) +if (!empty($arrayfields['t.libelle']['checked'])) { print '<td class="liste_titre">'; - $listetype=$membertypestatic->liste_array(); + $listetype = $membertypestatic->liste_array(); print $form->selectarray("search_type", $listetype, $type, 1, 0, 0, '', 0, 32); print '</td>'; } -if (! empty($arrayfields['d.address']['checked'])) +if (!empty($arrayfields['d.address']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_address" value="'.$search_address.'"></td>'; } -if (! empty($arrayfields['d.zip']['checked'])) +if (!empty($arrayfields['d.zip']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth50imp" type="text" name="search_zip" value="'.$search_zip.'"></td>'; } -if (! empty($arrayfields['d.town']['checked'])) +if (!empty($arrayfields['d.town']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_town" value="'.$search_town.'"></td>'; } // State -if (! empty($arrayfields['state.nom']['checked'])) +if (!empty($arrayfields['state.nom']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat searchstring maxwidth75imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country -if (! empty($arrayfields['country.code_iso']['checked'])) +if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="liste_titre center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Phone pro -if (! empty($arrayfields['d.phone']['checked'])) +if (!empty($arrayfields['d.phone']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_phone" value="'.$search_phone.'"></td>'; } // Phone perso -if (! empty($arrayfields['d.phone_perso']['checked'])) +if (!empty($arrayfields['d.phone_perso']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth50" type="text" name="search_phone_perso" value="'.$search_phone_perso.'"></td>'; } // Phone mobile -if (! empty($arrayfields['d.phone_mobile']['checked'])) +if (!empty($arrayfields['d.phone_mobile']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_phone_mobile" value="'.$search_phone_mobile.'"></td>'; } // Email -if (! empty($arrayfields['d.email']['checked'])) +if (!empty($arrayfields['d.email']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_email" value="'.$search_email.'"></td>'; } -if (! empty($arrayfields['d.datefin']['checked'])) +if (!empty($arrayfields['d.datefin']['checked'])) { print '<td class="liste_titre left">'; print '</td>'; @@ -588,32 +588,32 @@ if (! empty($arrayfields['d.datefin']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (! empty($arrayfields['d.datec']['checked'])) +if (!empty($arrayfields['d.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } //Birthday -if (! empty($arrayfields['d.birth']['checked'])) +if (!empty($arrayfields['d.birth']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification -if (! empty($arrayfields['d.tms']['checked'])) +if (!empty($arrayfields['d.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status -if (! empty($arrayfields['d.statut']['checked'])) +if (!empty($arrayfields['d.statut']['checked'])) { print '<td class="liste_titre right maxwidthonsmartphone">'; - $liststatus=array( + $liststatus = array( '-1'=>$langs->trans("Draft"), '1'=>$langs->trans("Validated"), '0'=>$langs->trans("Resiliated") @@ -623,229 +623,229 @@ if (! empty($arrayfields['d.statut']['checked'])) } // Action column print '<td class="liste_titre middle">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; -if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.rowid', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.gender']['checked'])) print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder); -if (! empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER["PHP_SELF"], 'd.societe', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], 'd.login', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.address']['checked'])) print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.zip']['checked'])) print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.town']['checked'])) print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['d.phone']['checked'])) print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.phone_perso']['checked'])) print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.email']['checked'])) print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, 'align="center"', $sortfield, $sortorder); +if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder); +if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.rowid', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.gender']['checked'])) print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder); +if (!empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER["PHP_SELF"], 'd.societe', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], 'd.login', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.address']['checked'])) print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.zip']['checked'])) print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.town']['checked'])) print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); +if (!empty($arrayfields['d.phone']['checked'])) print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.phone_perso']['checked'])) print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.email']['checked'])) print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, 'align="center"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$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 +$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; -if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['d.birth']['checked'])) print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['d.statut']['checked'])) print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder); +if (!empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); +if (!empty($arrayfields['d.birth']['checked'])) print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); +if (!empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); +if (!empty($arrayfields['d.statut']['checked'])) print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "</tr>\n"; $i = 0; -$totalarray=array(); +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $datefin=$db->jdate($obj->datefin); - $memberstatic->id=$obj->rowid; - $memberstatic->ref=$obj->rowid; - $memberstatic->civility_id=$obj->civility; - $memberstatic->lastname=$obj->lastname; - $memberstatic->firstname=$obj->firstname; - $memberstatic->gender=$obj->gender; - $memberstatic->statut=$obj->statut; - $memberstatic->datefin= $datefin; + $datefin = $db->jdate($obj->datefin); + $memberstatic->id = $obj->rowid; + $memberstatic->ref = $obj->rowid; + $memberstatic->civility_id = $obj->civility; + $memberstatic->lastname = $obj->lastname; + $memberstatic->firstname = $obj->firstname; + $memberstatic->gender = $obj->gender; + $memberstatic->statut = $obj->statut; + $memberstatic->datefin = $datefin; $memberstatic->socid = $obj->fk_soc; $memberstatic->photo = $obj->photo; $memberstatic->morphy = $obj->morphy; - if (! empty($obj->fk_soc)) { + if (!empty($obj->fk_soc)) { $memberstatic->fetch_thirdparty(); - $companyname=$memberstatic->thirdparty->name; + $companyname = $memberstatic->thirdparty->name; } else { - $companyname=$obj->company; + $companyname = $obj->company; } $memberstatic->company = $companyname; print '<tr class="oddeven">'; - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print '<td class="center">'.$obj->rowid.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref - if (! empty($arrayfields['d.ref']['checked'])) + if (!empty($arrayfields['d.ref']['checked'])) { print "<td>"; print $memberstatic->getNomUrl(-1, 0, 'card', 'ref'); print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Civility - if (! empty($arrayfields['d.civility']['checked'])) + if (!empty($arrayfields['d.civility']['checked'])) { print "<td>"; print $obj->civility; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Firstname - if (! empty($arrayfields['d.firstname']['checked'])) + if (!empty($arrayfields['d.firstname']['checked'])) { print "<td>"; print $obj->firstname; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Lastname - if (! empty($arrayfields['d.lastname']['checked'])) + if (!empty($arrayfields['d.lastname']['checked'])) { print "<td>"; print $obj->lastname; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Gender - if (! empty($arrayfields['d.gender']['checked'])) + if (!empty($arrayfields['d.gender']['checked'])) { print '<td>'; if ($obj->gender) print $langs->trans("Gender".$obj->gender); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Company - if (! empty($arrayfields['d.company']['checked'])) + if (!empty($arrayfields['d.company']['checked'])) { print "<td>"; print $companyname; print "</td>\n"; } // Login - if (! empty($arrayfields['d.login']['checked'])) + if (!empty($arrayfields['d.login']['checked'])) { print "<td>".$obj->login."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Moral/Physique - if (! empty($arrayfields['d.morphy']['checked'])) + if (!empty($arrayfields['d.morphy']['checked'])) { print "<td>".$memberstatic->getmorphylib($obj->morphy)."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type label - if (! empty($arrayfields['t.libelle']['checked'])) + if (!empty($arrayfields['t.libelle']['checked'])) { - $membertypestatic->id=$obj->type_id; - $membertypestatic->label=$obj->type; + $membertypestatic->id = $obj->type_id; + $membertypestatic->label = $obj->type; print '<td class="nowrap">'; print $membertypestatic->getNomUrl(1, 32); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Address - if (! empty($arrayfields['d.address']['checked'])) + if (!empty($arrayfields['d.address']['checked'])) { print '<td class="nocellnopadd">'; print $obj->address; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['d.zip']['checked'])) + if (!empty($arrayfields['d.zip']['checked'])) { print '<td class="nocellnopadd">'; print $obj->zip; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['d.town']['checked'])) + if (!empty($arrayfields['d.town']['checked'])) { print '<td class="nocellnopadd">'; print $obj->town; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "<td>".$obj->state_name."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="center">'; - $tmparray=getCountry($obj->country, 'all'); + $tmparray = getCountry($obj->country, 'all'); print $tmparray['label']; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Phone pro - if (! empty($arrayfields['d.phone']['checked'])) + if (!empty($arrayfields['d.phone']['checked'])) { print '<td class="nocellnopadd">'; print $obj->phone; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Phone perso - if (! empty($arrayfields['d.phone_perso']['checked'])) + if (!empty($arrayfields['d.phone_perso']['checked'])) { print '<td class="nocellnopadd">'; print $obj->phone_perso; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Phone mobile - if (! empty($arrayfields['d.phone_mobile']['checked'])) + if (!empty($arrayfields['d.phone_mobile']['checked'])) { print '<td class="nocellnopadd">'; print $obj->phone_mobile; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // EMail - if (! empty($arrayfields['d.email']['checked'])) + if (!empty($arrayfields['d.email']['checked'])) { print "<td>".dol_print_email($obj->email, 0, 0, 1)."</td>\n"; } // End of subscription date - $datefin=$db->jdate($obj->datefin); - if (! empty($arrayfields['d.datefin']['checked'])) + $datefin = $db->jdate($obj->datefin); + if (!empty($arrayfields['d.datefin']['checked'])) { if ($datefin) { print '<td class="nowrap center">'; print dol_print_date($datefin, 'day'); if ($memberstatic->hasDelay()) { - $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay/60/60/24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay/60/60/24).' '.$langs->trans("days").')'; + $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; print " ".img_warning($langs->trans("SubscriptionLate").$textlate); } print '</td>'; @@ -868,51 +868,51 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['d.datec']['checked'])) + if (!empty($arrayfields['d.datec']['checked'])) { print '<td class="nowrap center">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Birth - if (! empty($arrayfields['d.birth']['checked'])) + if (!empty($arrayfields['d.birth']['checked'])) { print '<td class="nowrap center">'; print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['d.tms']['checked'])) + if (!empty($arrayfields['d.tms']['checked'])) { print '<td class="nowrap center">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['d.statut']['checked'])) + if (!empty($arrayfields['d.statut']['checked'])) { print '<td class="nowrap right">'; print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print '<td class="center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "</tr>\n"; $i++; @@ -925,15 +925,15 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } $db->free($resql); -$parameters=array('sql' => $sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('sql' => $sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "</table>\n"; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 9cb83e3784b..add400b6aef 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -26,9 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; dol_include_once('/emailcollector/class/emailcollector.class.php'); if (!$user->admin) accessforbidden(); @@ -37,20 +37,20 @@ if (empty($conf->emailcollector->enabled)) accessforbidden(); // Load traductions files required by page $langs->loadLangs(array("admin", "other")); -$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'):'emailcollectorlist'; // 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') +$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') : 'emailcollectorlist'; // 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') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -64,7 +64,7 @@ $pagenext = $page + 1; // Initialize technical objects $object = new EmailCollector($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration/' . $user->id; +$diroutputmassaction = $conf->emailcollector->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('emailcollectorlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels @@ -73,11 +73,11 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -86,34 +86,34 @@ if ($user->socid > 0) // Protection if external user //$result = restrictedArea($user, 'emailcollector', $id, ''); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -125,11 +125,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -138,24 +138,24 @@ if (empty($reshook)) 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 + 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='EmailCollector'; - $objectlabel='EmailCollector'; + $objectclass = 'EmailCollector'; + $objectlabel = 'EmailCollector'; $permissiontoread = $user->rights->emailcollector->read; $permissiontodelete = $user->rights->emailcollector->delete; $uploaddir = $conf->emailcollector->dir_output; @@ -168,47 +168,47 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_EmailCollector|FR:Module_EmailCollector_FR|ES:Módulo_EmailCollector"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector")); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -226,7 +226,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -247,10 +247,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -260,7 +260,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -289,27 +289,27 @@ jQuery(document).ready(function() { }); </script>'; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -321,10 +321,10 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; -$newcardbutton=''; +$newcardbutton = ''; //if ($user->rights->emailcollector->creer) //{ -$newcardbutton.= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'])); +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'])); //} print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); @@ -338,8 +338,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; @@ -347,47 +347,47 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$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 '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -396,66 +396,66 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print '</tr>'."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print '<tr class="oddeven">'; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'; if ($cssforfield || $val['css']) print ' class="'; @@ -466,10 +466,10 @@ while ($i < min($num, $limit)) print '>'; print $object->showOutputField($val, $key, $obj->$key, ''); print '</td>'; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -477,19 +477,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'; @@ -503,16 +503,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -522,19 +522,19 @@ print '</form>'."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->emailcollector->read; - $delallowed=$user->rights->emailcollector->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->emailcollector->read; + $delallowed = $user->rights->emailcollector->create; print $formfile->showdocuments('massfilesarea_emailcollector', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 028de9a32a5..4d5eed40ff0 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -30,22 +30,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php'; // Load translation files required by the page -$langs->loadLangs(array("errors","admin","mails","languages")); +$langs->loadLangs(array("errors", "admin", "mails", "languages")); -$action = GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'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'):'emailsenderprofilelist'; // 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') +$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : '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') : 'emailsenderprofilelist'; // 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') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -55,22 +55,22 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object=new EmailSenderProfile($db); +$object = new EmailSenderProfile($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->admin->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('emailsenderprofilelist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->admin->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('emailsenderprofilelist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Protection if external user -$socid=0; +$socid = 0; if ($user->socid > 0) { //$socid = $user->socid; @@ -78,34 +78,34 @@ if ($user->socid > 0) } // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']); } // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -117,11 +117,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -130,24 +130,24 @@ if (empty($reshook)) 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 + 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='EmailSenderProfile'; - $objectlabel='EmailSenderProfile'; + $objectclass = 'EmailSenderProfile'; + $objectlabel = 'EmailSenderProfile'; $permissiontoread = $user->admin; $permissiontodelete = $user->admin; $uploaddir = $conf->admin->dir_output.'/senderprofiles'; @@ -160,20 +160,20 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_EmailSenderProfile|FR:Module_EmailSenderProfile_FR|ES:Módulo_EmailSenderProfile"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailSenderProfiles")); llxHeader(); -$titre=$langs->trans("EMailsSetup"); -$linkback=''; -$titlepicto='title_setup'; +$titre = $langs->trans("EMailsSetup"); +$linkback = ''; +$titlepicto = 'title_setup'; print load_fiche_titre($titre, $linkback, $titlepicto); @@ -184,34 +184,34 @@ dol_fiche_head($head, 'senderprofiles', '', -1); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('emailsenderprofile').")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('emailsenderprofile').")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -228,7 +228,7 @@ $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // $sql.=$hookmanager->resPrint; */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -243,10 +243,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); -if (! $resql) +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); exit; @@ -255,7 +255,7 @@ if (! $resql) $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -279,27 +279,27 @@ jQuery(document).ready(function() { }); </script>'; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->monmodule->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -313,9 +313,9 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); -$topicmail="Information"; +$topicmail = "Information"; //$modelmail="subscription"; -$objecttmp=new EmailSenderProfile($db); +$objecttmp = new EmailSenderProfile($db); //$trackid='sub'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; @@ -324,46 +324,46 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$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 '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -372,68 +372,68 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; print '</tr>'."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print '<tr class="oddeven">'; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'; if ($align) print ' class="'.$align.'"'; print '>'; print $object->showOutputField($val, $key, $obj->$key, ''); print '</td>'; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -441,19 +441,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="nowrap" align="center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'; @@ -467,16 +467,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -489,16 +489,16 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->monmodule->read; - $delallowed=$user->rights->monmodule->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->monmodule->read; + $delallowed = $user->rights->monmodule->create; print $formfile->showdocuments('massfilesarea_monmodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index b0da228e7a8..7f2ae92851b 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -33,7 +33,7 @@ $langs->load("admin"); if (!$user->admin) accessforbidden(); -$error=0; +$error = 0; /* @@ -75,19 +75,19 @@ print '<br>'; $file_list = array('missing' => array(), 'updated' => array()); // Local file to compare to -$xmlshortfile = GETPOST('xmlshortfile', 'alpha')?GETPOST('xmlshortfile', 'alpha'):'/install/filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX)?'':$conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml'; +$xmlshortfile = GETPOST('xmlshortfile', 'alpha') ?GETPOST('xmlshortfile', 'alpha') : '/install/filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX) ? '' : $conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml'; $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; // Remote file to compare to $xmlremote = GETPOST('xmlremote'); -if (empty($xmlremote) && ! empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL; -$param='MAIN_FILECHECK_URL_'.DOL_VERSION; -if (empty($xmlremote) && ! empty($conf->global->$param)) $xmlremote = $conf->global->$param; +if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL; +$param = 'MAIN_FILECHECK_URL_'.DOL_VERSION; +if (empty($xmlremote) && !empty($conf->global->$param)) $xmlremote = $conf->global->$param; if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; // Test if remote test is ok $enableremotecheck = true; -if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || ! empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck=false; +if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || !empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck = false; $enableremotecheck = true; print '<form name="check" action="'.$_SERVER["PHP_SELF"].'">'; @@ -95,7 +95,7 @@ print $langs->trans("MakeIntegrityAnalysisFrom").':<br>'; print '<!-- for a local check target=local&xmlshortfile=... -->'."\n"; if (dol_is_file($xmlfile)) { - print '<input type="radio" name="target" value="local"'.((! GETPOST('target') || GETPOST('target') == 'local') ? 'checked="checked"':'').'"> '.$langs->trans("LocalSignature").' = '; + print '<input type="radio" name="target" value="local"'.((!GETPOST('target') || GETPOST('target') == 'local') ? 'checked="checked"' : '').'"> '.$langs->trans("LocalSignature").' = '; print '<input name="xmlshortfile" class="flat minwidth400" value="'.dol_escape_htmltag($xmlshortfile).'">'; print '<br>'; } @@ -109,13 +109,13 @@ else print '<!-- for a remote target=remote&xmlremote=... -->'."\n"; if ($enableremotecheck) { - print '<input type="radio" name="target" value="remote"'.(GETPOST('target') == 'remote' ? 'checked="checked"':'').'> '.$langs->trans("RemoteSignature").' = '; + print '<input type="radio" name="target" value="remote"'.(GETPOST('target') == 'remote' ? 'checked="checked"' : '').'> '.$langs->trans("RemoteSignature").' = '; print '<input name="xmlremote" class="flat minwidth400" value="'.dol_escape_htmltag($xmlremote).'"><br>'; } else { print '<input type="radio" name="target" value="remote" disabled="disabled"> '.$langs->trans("RemoteSignature").' = '.$xmlremote; - if (! GETPOST('xmlremote')) print ' <span class="warning">('.$langs->trans("FeatureAvailableOnlyOnStable").')</span>'; + if (!GETPOST('xmlremote')) print ' <span class="warning">('.$langs->trans("FeatureAvailableOnlyOnStable").')</span>'; print '<br>'; } print '<br><div class="center"><input type="submit" name="check" class="button" value="'.$langs->trans("Check").'"></div>'; @@ -131,7 +131,7 @@ if (GETPOST('target') == 'local') } else { - print $langs->trans('XmlNotFound') . ': ' . $xmlfile; + print $langs->trans('XmlNotFound').': '.$xmlfile; $error++; } } @@ -140,7 +140,7 @@ if (GETPOST('target') == 'remote') $xmlarray = getURLContent($xmlremote); // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) - if (! $xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') + if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; //print "xmlfilestart".$xmlfile."xmlfileend"; @@ -148,14 +148,14 @@ if (GETPOST('target') == 'remote') } else { - $errormsg=$langs->trans('XmlNotFound') . ': ' . $xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; + $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; setEventMessages($errormsg, null, 'errors'); $error++; } } -if (! $error && $xml) +if (!$error && $xml) { $checksumconcat = array(); $file_list = array(); @@ -164,84 +164,84 @@ if (! $error && $xml) // Forced constants if (is_object($xml->dolibarr_constants[0])) { - $out.=load_fiche_titre($langs->trans("ForcedConstants")); + $out .= load_fiche_titre($langs->trans("ForcedConstants")); - $out.='<div class="div-table-responsive-no-min">'; - $out.='<table class="noborder">'; - $out.='<tr class="liste_titre">'; - $out.='<td>#</td>'; - $out.='<td>' . $langs->trans("Constant") . '</td>'; - $out.='<td class="center">' . $langs->trans("ExpectedValue") . '</td>'; - $out.='<td class="center">' . $langs->trans("Value") . '</td>'; - $out.='</tr>'."\n"; + $out .= '<div class="div-table-responsive-no-min">'; + $out .= '<table class="noborder">'; + $out .= '<tr class="liste_titre">'; + $out .= '<td>#</td>'; + $out .= '<td>'.$langs->trans("Constant").'</td>'; + $out .= '<td class="center">'.$langs->trans("ExpectedValue").'</td>'; + $out .= '<td class="center">'.$langs->trans("Value").'</td>'; + $out .= '</tr>'."\n"; $i = 0; foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement { - $constname=$constant['name']; - $constvalue=(string) $constant; - $constvalue = (empty($constvalue)?'0':$constvalue); + $constname = $constant['name']; + $constvalue = (string) $constant; + $constvalue = (empty($constvalue) ? '0' : $constvalue); // Value found - $value=''; - if ($constname && $conf->global->$constname != '') $value=$conf->global->$constname; - $valueforchecksum=(empty($value)?'0':$value); + $value = ''; + if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; + $valueforchecksum = (empty($value) ? '0' : $value); - $checksumconcat[]=$valueforchecksum; + $checksumconcat[] = $valueforchecksum; $i++; - $out.='<tr class="oddeven">'; - $out.='<td>'.$i.'</td>' . "\n"; - $out.='<td>'.$constname.'</td>' . "\n"; - $out.='<td class="center">'.$constvalue.'</td>' . "\n"; - $out.='<td class="center">'.$valueforchecksum.'</td>' . "\n"; - $out.="</tr>\n"; + $out .= '<tr class="oddeven">'; + $out .= '<td>'.$i.'</td>'."\n"; + $out .= '<td>'.$constname.'</td>'."\n"; + $out .= '<td class="center">'.$constvalue.'</td>'."\n"; + $out .= '<td class="center">'.$valueforchecksum.'</td>'."\n"; + $out .= "</tr>\n"; } - if ($i==0) + if ($i == 0) { - $out.='<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; + $out .= '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; } - $out.='</table>'; - $out.='</div>'; + $out .= '</table>'; + $out .= '</div>'; - $out.='<br>'; + $out .= '<br>'; } // Scan htdocs if (is_object($xml->dolibarr_htdocs_dir[0])) { //var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit; - $includecustom=(empty($xml->dolibarr_htdocs_dir[0]['includecustom'])?0:$xml->dolibarr_htdocs_dir[0]['includecustom']); + $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); // Defined qualified files (must be same than into generate_filelist_xml.php) - $regextoinclude='\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$'; - $regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs + $regextoinclude = '\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$'; + $regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); // Fill file_list with files in signature, new files, modified files - $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list + $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list // Complete with list of new files foreach ($scanfiles as $keyfile => $valfile) { - $tmprelativefilename=preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); - if (! in_array($tmprelativefilename, $file_list['insignature'])) + $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); + if (!in_array($tmprelativefilename, $file_list['insignature'])) { - $md5newfile=@md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file - $file_list['added'][]=array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); + $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file + $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); } } // Files missings - $out.=load_fiche_titre($langs->trans("FilesMissing")); + $out .= load_fiche_titre($langs->trans("FilesMissing")); - $out.='<div class="div-table-responsive-no-min">'; - $out.='<table class="noborder">'; - $out.='<tr class="liste_titre">'; - $out.='<td>#</td>'; - $out.='<td>' . $langs->trans("Filename") . '</td>'; - $out.='<td class="right">' . $langs->trans("ExpectedSize") . '</td>'; - $out.='<td class="center">' . $langs->trans("ExpectedChecksum") . '</td>'; - $out.='</tr>'."\n"; + $out .= '<div class="div-table-responsive-no-min">'; + $out .= '<table class="noborder">'; + $out .= '<tr class="liste_titre">'; + $out .= '<td>#</td>'; + $out .= '<td>'.$langs->trans("Filename").'</td>'; + $out .= '<td class="right">'.$langs->trans("ExpectedSize").'</td>'; + $out .= '<td class="center">'.$langs->trans("ExpectedChecksum").'</td>'; + $out .= '</tr>'."\n"; $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); if (is_array($tmpfilelist) && count($tmpfilelist)) { @@ -249,40 +249,40 @@ if (! $error && $xml) foreach ($tmpfilelist as $file) { $i++; - $out.='<tr class="oddeven">'; - $out.='<td>'.$i.'</td>' . "\n"; - $out.='<td>'.$file['filename'].'</td>' . "\n"; - $out.='<td class="right">'; - if (! empty($file['expectedsize'])) $out.=dol_print_size($file['expectedsize']); - $out.='</td>' . "\n"; - $out.='<td class="center">'.$file['expectedmd5'].'</td>' . "\n"; - $out.="</tr>\n"; + $out .= '<tr class="oddeven">'; + $out .= '<td>'.$i.'</td>'."\n"; + $out .= '<td>'.$file['filename'].'</td>'."\n"; + $out .= '<td class="right">'; + if (!empty($file['expectedsize'])) $out .= dol_print_size($file['expectedsize']); + $out .= '</td>'."\n"; + $out .= '<td class="center">'.$file['expectedmd5'].'</td>'."\n"; + $out .= "</tr>\n"; } } else { - $out.='<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; + $out .= '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; } - $out.='</table>'; - $out.='</div>'; + $out .= '</table>'; + $out .= '</div>'; - $out.='<br>'; + $out .= '<br>'; // Files modified - $out.=load_fiche_titre($langs->trans("FilesModified")); + $out .= load_fiche_titre($langs->trans("FilesModified")); - $totalsize=0; - $out.='<div class="div-table-responsive-no-min">'; - $out.='<table class="noborder">'; - $out.='<tr class="liste_titre">'; - $out.='<td>#</td>'; - $out.='<td>' . $langs->trans("Filename") . '</td>'; - $out.='<td class="center">' . $langs->trans("ExpectedChecksum") . '</td>'; - $out.='<td class="center">' . $langs->trans("CurrentChecksum") . '</td>'; - $out.='<td class="right">' . $langs->trans("ExpectedSize") . '</td>'; - $out.='<td class="right">' . $langs->trans("CurrentSize") . '</td>'; - $out.='<td class="right">' . $langs->trans("DateModification") . '</td>'; - $out.='</tr>'."\n"; + $totalsize = 0; + $out .= '<div class="div-table-responsive-no-min">'; + $out .= '<table class="noborder">'; + $out .= '<tr class="liste_titre">'; + $out .= '<td>#</td>'; + $out .= '<td>'.$langs->trans("Filename").'</td>'; + $out .= '<td class="center">'.$langs->trans("ExpectedChecksum").'</td>'; + $out .= '<td class="center">'.$langs->trans("CurrentChecksum").'</td>'; + $out .= '<td class="right">'.$langs->trans("ExpectedSize").'</td>'; + $out .= '<td class="right">'.$langs->trans("CurrentSize").'</td>'; + $out .= '<td class="right">'.$langs->trans("DateModification").'</td>'; + $out .= '</tr>'."\n"; $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); if (is_array($tmpfilelist2) && count($tmpfilelist2)) { @@ -290,53 +290,53 @@ if (! $error && $xml) foreach ($tmpfilelist2 as $file) { $i++; - $out.='<tr class="oddeven">'; - $out.='<td>'.$i.'</td>' . "\n"; - $out.='<td>'.$file['filename'].'</td>' . "\n"; - $out.='<td class="center">'.$file['expectedmd5'].'</td>' . "\n"; - $out.='<td class="center">'.$file['md5'].'</td>' . "\n"; - $out.='<td class="right">'; - if ($file['expectedsize']) $out.=dol_print_size($file['expectedsize']); - $out.='</td>' . "\n"; + $out .= '<tr class="oddeven">'; + $out .= '<td>'.$i.'</td>'."\n"; + $out .= '<td>'.$file['filename'].'</td>'."\n"; + $out .= '<td class="center">'.$file['expectedmd5'].'</td>'."\n"; + $out .= '<td class="center">'.$file['md5'].'</td>'."\n"; + $out .= '<td class="right">'; + if ($file['expectedsize']) $out .= dol_print_size($file['expectedsize']); + $out .= '</td>'."\n"; $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); $totalsize += $size; - $out.='<td class="right">'.dol_print_size($size).'</td>' . "\n"; - $out.='<td class="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>' . "\n"; - $out.="</tr>\n"; + $out .= '<td class="right">'.dol_print_size($size).'</td>'."\n"; + $out .= '<td class="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>'."\n"; + $out .= "</tr>\n"; } - $out.='<tr class="liste_total">'; - $out.='<td></td>' . "\n"; - $out.='<td>'.$langs->trans("Total").'</td>' . "\n"; - $out.='<td class="center"></td>' . "\n"; - $out.='<td class="center"></td>' . "\n"; - $out.='<td class="center"></td>' . "\n"; - $out.='<td class="right">'.dol_print_size($totalsize).'</td>' . "\n"; - $out.='<td class="right"></td>' . "\n"; - $out.="</tr>\n"; + $out .= '<tr class="liste_total">'; + $out .= '<td></td>'."\n"; + $out .= '<td>'.$langs->trans("Total").'</td>'."\n"; + $out .= '<td class="center"></td>'."\n"; + $out .= '<td class="center"></td>'."\n"; + $out .= '<td class="center"></td>'."\n"; + $out .= '<td class="right">'.dol_print_size($totalsize).'</td>'."\n"; + $out .= '<td class="right"></td>'."\n"; + $out .= "</tr>\n"; } else { - $out.='<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; + $out .= '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; } - $out.='</table>'; - $out.='</div>'; + $out .= '</table>'; + $out .= '</div>'; - $out.='<br>'; + $out .= '<br>'; // Files added - $out.=load_fiche_titre($langs->trans("FilesAdded")); + $out .= load_fiche_titre($langs->trans("FilesAdded")); $totalsize = 0; - $out.='<div class="div-table-responsive-no-min">'; - $out.='<table class="noborder">'; - $out.='<tr class="liste_titre">'; - $out.='<td>#</td>'; - $out.='<td>' . $langs->trans("Filename") . '</td>'; - $out.='<td class="center">' . $langs->trans("ExpectedChecksum") . '</td>'; - $out.='<td class="center">' . $langs->trans("CurrentChecksum") . '</td>'; - $out.='<td class="right">' . $langs->trans("Size") . '</td>'; - $out.='<td class="right">' . $langs->trans("DateModification") . '</td>'; - $out.='</tr>'."\n"; + $out .= '<div class="div-table-responsive-no-min">'; + $out .= '<table class="noborder">'; + $out .= '<tr class="liste_titre">'; + $out .= '<td>#</td>'; + $out .= '<td>'.$langs->trans("Filename").'</td>'; + $out .= '<td class="center">'.$langs->trans("ExpectedChecksum").'</td>'; + $out .= '<td class="center">'.$langs->trans("CurrentChecksum").'</td>'; + $out .= '<td class="right">'.$langs->trans("Size").'</td>'; + $out .= '<td class="right">'.$langs->trans("DateModification").'</td>'; + $out .= '</tr>'."\n"; $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); if (is_array($tmpfilelist3) && count($tmpfilelist3)) { @@ -344,37 +344,37 @@ if (! $error && $xml) foreach ($tmpfilelist3 as $file) { $i++; - $out.='<tr class="oddeven">'; - $out.='<td>'.$i.'</td>' . "\n"; - $out.='<td>'.$file['filename']; - if (! preg_match('/^win/i', PHP_OS)) { - $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] - $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); + $out .= '<tr class="oddeven">'; + $out .= '<td>'.$i.'</td>'."\n"; + $out .= '<td>'.$file['filename']; + if (!preg_match('/^win/i', PHP_OS)) { + $htmltext = $langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] + $out .= ' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); } - $out.='</td>' . "\n"; - $out.='<td class="center">'.$file['expectedmd5'].'</td>' . "\n"; - $out.='<td class="center">'.$file['md5'].'</td>' . "\n"; + $out .= '</td>'."\n"; + $out .= '<td class="center">'.$file['expectedmd5'].'</td>'."\n"; + $out .= '<td class="center">'.$file['md5'].'</td>'."\n"; $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); $totalsize += $size; - $out.='<td class="right">'.dol_print_size($size).'</td>' . "\n"; - $out.='<td class="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>' . "\n"; - $out.="</tr>\n"; + $out .= '<td class="right">'.dol_print_size($size).'</td>'."\n"; + $out .= '<td class="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>'."\n"; + $out .= "</tr>\n"; } - $out.='<tr class="liste_total">'; - $out.='<td></td>' . "\n"; - $out.='<td>'.$langs->trans("Total").'</td>' . "\n"; - $out.='<td class="center"></td>' . "\n"; - $out.='<td class="center"></td>' . "\n"; - $out.='<td class="right">'.dol_print_size($totalsize).'</td>' . "\n"; - $out.='<td class="right"></td>' . "\n"; - $out.="</tr>\n"; + $out .= '<tr class="liste_total">'; + $out .= '<td></td>'."\n"; + $out .= '<td>'.$langs->trans("Total").'</td>'."\n"; + $out .= '<td class="center"></td>'."\n"; + $out .= '<td class="center"></td>'."\n"; + $out .= '<td class="right">'.dol_print_size($totalsize).'</td>'."\n"; + $out .= '<td class="right"></td>'."\n"; + $out .= "</tr>\n"; } else { - $out.='<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; + $out .= '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; } - $out.='</table>'; - $out.='</div>'; + $out .= '</table>'; + $out .= '</div>'; // Show warning @@ -419,26 +419,26 @@ if (! $error && $xml) if (count($file_list['added'])) { $resultcode = 'warning'; - $resultcomment='FileIntegrityIsOkButFilesWereAdded'; - $outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>'; + $resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; + $outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>'; } else { $resultcode = 'ok'; - $resultcomment='Success'; + $resultcomment = 'Success'; $outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>'; } } else { $resultcode = 'error'; - $resultcomment='Error'; + $resultcomment = 'Error'; $outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>'; } print load_fiche_titre($langs->trans("GlobalChecksum")).'<br>'; - print $langs->trans("ExpectedChecksum").' = '. $outexpectedchecksum .'<br>'; - print $langs->trans("CurrentChecksum").' = '. $outcurrentchecksum; + print $langs->trans("ExpectedChecksum").' = '.$outexpectedchecksum.'<br>'; + print $langs->trans("CurrentChecksum").' = '.$outcurrentchecksum; print '<br>'; print '<br>'; diff --git a/htdocs/admin/triggers.php b/htdocs/admin/triggers.php index bdc5ee5961d..ce7f525e8b3 100644 --- a/htdocs/admin/triggers.php +++ b/htdocs/admin/triggers.php @@ -28,8 +28,8 @@ $langs->load("admin"); if (!$user->admin) accessforbidden(); -$sortfield='file'; -$sortorder='ASC'; +$sortfield = 'file'; +$sortorder = 'ASC'; /* @@ -61,9 +61,9 @@ print '<div class="div-table-responsive-no-min">'; print '<table class="noborder">'; print '<tr class="liste_titre">'; print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], 'none', "", $param, '', $sortfield, $sortorder, '', 1)."\n"; -print getTitleFieldOfList($langs->trans("File"), 0, $_SERVER["PHP_SELF"], 'file', "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder, '', 1)."\n"; +print getTitleFieldOfList($langs->trans("File"), 0, $_SERVER["PHP_SELF"], 'file', "", $param, ($align ? 'align="'.$align.'"' : ''), $sortfield, $sortorder, '', 1)."\n"; print getTitleFieldOfList($langs->trans("Active"), 0, $_SERVER["PHP_SELF"], 'active', "", $param, 'align="center"', $sortfield, $sortorder, '', 1)."\n"; -print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], 'none', "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder, '', 1)."\n"; +print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], 'none', "", $param, ($align ? 'align="'.$align.'"' : ''), $sortfield, $sortorder, '', 1)."\n"; print '</tr>'; foreach ($triggers as $trigger) @@ -73,8 +73,8 @@ foreach ($triggers as $trigger) print '<td class="tdtop">'.$trigger['file'].'</td>'; print '<td valign="top" align="center">'.$trigger['status'].'</td>'; print '<td class="tdtop">'; - $text=$trigger['info']; - $text.="<br>\n<strong>".$langs->trans("File")."</strong>:<br>\n".$trigger['relpath']; + $text = $trigger['info']; + $text .= "<br>\n<strong>".$langs->trans("File")."</strong>:<br>\n".$trigger['relpath']; //$text.="\n".$langs->trans("ExternalModule",$trigger['isocreorexternal']); print $form->textwithpicto('', $text); print '</td>'; diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index c43bd73eae8..9d480eccebe 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -33,20 +33,20 @@ require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; // Load translation files required by the page $langs->loadLangs(array("assets")); -$action = GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'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'):'assetslist'; // 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') +$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : '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') : 'assetslist'; // 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') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -56,22 +56,22 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object=new Asset($db); +$object = new Asset($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Protection if external user -$socid=0; +$socid = 0; if ($user->socid > 0) { //$socid = $user->socid; @@ -80,34 +80,34 @@ if ($user->socid > 0) //$result = restrictedArea($user, 'asset', $id,''); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -121,11 +121,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Put here all code to do according to value of "$action" parameter */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -134,24 +134,24 @@ if (empty($reshook)) 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 + 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Asset'; - $objectlabel='Asset'; + $objectclass = 'Asset'; + $objectlabel = 'Asset'; $permissiontoread = $user->rights->asset->read; $permissiontodelete = $user->rights->asset->delete; $uploaddir = $conf->asset->dir_output; @@ -166,46 +166,46 @@ if (empty($reshook)) * Put here all code to render page */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_Asset|FR:Module_Asset_FR|ES:Módulo_Asset"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Assets")); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('assets').")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('assets').")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -222,7 +222,7 @@ $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // $sql.=$hookmanager->resPrint; */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -237,10 +237,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); -if (! $resql) +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); exit; @@ -249,7 +249,7 @@ if (! $resql) $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -278,34 +278,34 @@ jQuery(document).ready(function() { }); </script>'; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->asset->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->asset->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->asset->write) { - $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/asset/card.php?action=create"><span class="valignmiddle text-plus-circle">'.$langs->trans('NewAsset').'</span>'; - $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; - $newcardbutton.= '</a>'; + $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/asset/card.php?action=create"><span class="valignmiddle text-plus-circle">'.$langs->trans('NewAsset').'</span>'; + $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>'; + $newcardbutton .= '</a>'; } print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; @@ -321,16 +321,16 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'accountancy', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendAssetsRef"; -$modelmail="asset"; -$objecttmp=new Asset($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendAssetsRef"; +$modelmail = "asset"; +$objecttmp = new Asset($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; @@ -338,47 +338,47 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$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 '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -459,19 +459,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="nowrap" align="center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'; @@ -482,11 +482,11 @@ while ($i < min($num, $limit)) if (isset($totalarray['pos'])) { print '<tr class="liste_total">'; - $i=0; + $i = 0; while ($i < $totalarray['nbfield']) { $i++; - if (! empty($totalarray['pos'][$i])) print '<td class="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; + if (!empty($totalarray['pos'][$i])) print '<td class="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; else { if ($i == 1) @@ -503,16 +503,16 @@ if (isset($totalarray['pos'])) // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -528,12 +528,12 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->asset->read; - $delallowed=$user->rights->asset->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->asset->read; + $delallowed = $user->rights->asset->create; print $formfile->showdocuments('massfilesarea_asset', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, ''); } diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index c61efc84591..0ff7ed8c672 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -31,20 +31,20 @@ require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; // Load translation files required by the page $langs->loadLangs(array("mrp", "other")); -$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'):'bomlist'; // 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') +$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') : 'bomlist'; // 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') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -58,8 +58,8 @@ $pagenext = $page + 1; // Initialize technical objects $object = new BOM($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bom->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bomlist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('bomlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -67,11 +67,11 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -80,34 +80,34 @@ if ($user->socid > 0) // Protection if external user //$result = restrictedArea($user, 'bom', $id, ''); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -122,11 +122,11 @@ $permissiontodelete = $user->rights->bom->delete; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -135,24 +135,24 @@ if (empty($reshook)) 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 + 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='BOM'; - $objectlabel='BillOfMaterials'; + $objectclass = 'BOM'; + $objectlabel = 'BillOfMaterials'; $permissiontoread = $user->rights->bom->read; $permissiontodelete = $user->rights->bom->delete; $uploaddir = $conf->bom->dir_output; @@ -160,18 +160,18 @@ if (empty($reshook)) // Validate records - if (! $error && $massaction == 'disable' && $permissiontoadd) + if (!$error && $massaction == 'disable' && $permissiontoadd) { - $objecttmp=new $objectclass($db); + $objecttmp = new $objectclass($db); - if (! $error) + if (!$error) { $db->begin(); $nbok = 0; - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $result=$objecttmp->fetch($toselectid); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { if ($objecttmp->status != $objecttmp::STATUS_VALIDATED) @@ -200,7 +200,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); @@ -275,48 +275,48 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_BillOfMaterials|FR:Module_BillOfMaterials_FR|ES:Módulo_BillOfMaterials"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOfBOMs'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -335,7 +335,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -356,10 +356,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -369,7 +369,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -437,16 +437,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle' print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cubes', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendBillOfMaterialsRef"; -$modelmail="bom"; -$objecttmp=new BOM($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendBillOfMaterialsRef"; +$modelmail = "bom"; +$objecttmp = new BOM($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; @@ -454,39 +454,39 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'">'; + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; print '</td>'; @@ -496,12 +496,12 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$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 '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -510,23 +510,23 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -534,56 +534,56 @@ print '</tr>'."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print '<tr class="oddeven">'; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print '</td>'; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -591,19 +591,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'; @@ -617,16 +617,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -637,19 +637,19 @@ print '</form>'."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->bom->read; - $delallowed=$user->rights->bom->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->bom->read; + $delallowed = $user->rights->bom->create; print $formfile->showdocuments('massfilesarea_bom', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 48faa5ca2c0..fdaac89eda0 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -26,7 +26,7 @@ * \brief Page to list actions */ -if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); +if (!defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; @@ -37,43 +37,43 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->loadLangs(array("users","companies","agenda","commercial")); +$langs->loadLangs(array("users", "companies", "agenda", "commercial")); -$action=GETPOST('action', 'alpha'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'actioncommlist'; // To manage different context of search -$resourceid=GETPOST("search_resourceid", "int")?GETPOST("search_resourceid", "int"):GETPOST("resourceid", "int"); -$pid=GETPOST("search_projectid", 'int', 3)?GETPOST("search_projectid", 'int', 3):GETPOST("projectid", 'int', 3); -$status=(GETPOST("search_status", 'alpha') != '')?GETPOST("search_status", 'alpha'):GETPOST("status", 'alpha'); -$type=GETPOST('search_type', 'alphanohtml')?GETPOST('search_type', 'alphanohtml'):GETPOST('type', 'alphanohtml'); +$action = GETPOST('action', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search +$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int"); +$pid = GETPOST("search_projectid", 'int', 3) ?GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3); +$status = (GETPOST("search_status", 'alpha') != '') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); +$type = GETPOST('search_type', 'alphanohtml') ?GETPOST('search_type', 'alphanohtml') : GETPOST('type', 'alphanohtml'); $optioncss = GETPOST('optioncss', 'alpha'); -$year=GETPOST("year", 'int'); -$month=GETPOST("month", 'int'); -$day=GETPOST("day", 'int'); +$year = GETPOST("year", 'int'); +$month = GETPOST("month", 'int'); +$day = GETPOST("day", 'int'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode=GETPOST('search_actioncode', 'array', 3); - if (! count($actioncode)) $actioncode='0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode=GETPOST("search_actioncode", "alpha", 3)?GETPOST("search_actioncode", "alpha", 3):(GETPOST("search_actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } -if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); -$search_id=GETPOST('search_id', 'alpha'); -$search_title=GETPOST('search_title', 'alpha'); -$search_note=GETPOST('search_note', 'alpha'); +if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); +$search_id = GETPOST('search_id', 'alpha'); +$search_title = GETPOST('search_title', 'alpha'); +$search_note = GETPOST('search_note', 'alpha'); -$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); -$datestart=dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int')); -$dateend=dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int')); -if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); -if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); +$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); +$datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int')); +$dateend = dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int')); +if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); +if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); -$filter = GETPOST("search_filter", 'alpha', 3)?GETPOST("search_filter", 'alpha', 3):GETPOST("filter", 'alpha', 3); -$filtert = GETPOST("search_filtert", "int", 3)?GETPOST("search_filtert", "int", 3):GETPOST("filtert", "int", 3); -$usergroup = GETPOST("search_usergroup", "int", 3)?GETPOST("search_usergroup", "int", 3):GETPOST("usergroup", "int", 3); -$showbirthday = empty($conf->use_javascript_ajax)?(GETPOST("search_showbirthday", "int")?GETPOST("search_showbirthday", "int"):GETPOST("showbirthday", "int")):1; +$filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); +$filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); +$usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); +$showbirthday = empty($conf->use_javascript_ajax) ? (GETPOST("search_showbirthday", "int") ?GETPOST("search_showbirthday", "int") : GETPOST("showbirthday", "int")) : 1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new ActionComm($db); @@ -84,45 +84,45 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // If not choice done on calendar owner, we filter on user. if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { - $filtert=$user->id; + $filtert = $user->id; } -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -if ($page == -1 || $page == null) { $page = 0 ; } -$offset = $limit * $page ; -if (! $sortorder) +if ($page == -1 || $page == null) { $page = 0; } +$offset = $limit * $page; +if (!$sortorder) { - $sortorder="DESC,DESC"; - if ($status == 'todo') $sortorder="DESC,DESC"; + $sortorder = "DESC,DESC"; + if ($status == 'todo') $sortorder = "DESC,DESC"; } -if (! $sortfield) +if (!$sortfield) { - $sortfield="a.datep,a.id"; - if ($status == 'todo') $sortfield="a.datep,a.id"; + $sortfield = "a.datep,a.id"; + if ($status == 'todo') $sortfield = "a.datep,a.id"; } // Security check -$socid = GETPOST("search_socid", 'int')?GETPOST("search_socid", 'int'):GETPOST("socid", 'int'); -if ($user->socid) $socid=$user->socid; +$socid = GETPOST("search_socid", 'int') ?GETPOST("search_socid", 'int') : GETPOST("socid", 'int'); +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); -if ($socid < 0) $socid=''; +if ($socid < 0) $socid = ''; -$canedit=1; -if (! $user->rights->agenda->myactions->read) accessforbidden(); -if (! $user->rights->agenda->allactions->read) $canedit=0; -if (! $user->rights->agenda->allactions->read || $filter=='mine') // If no permission to see all, we show only affected to me +$canedit = 1; +if (!$user->rights->agenda->myactions->read) accessforbidden(); +if (!$user->rights->agenda->allactions->read) $canedit = 0; +if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me { - $filtert=$user->id; + $filtert = $user->id; } -$arrayfields=array( +$arrayfields = array( 'a.id'=>array('label'=>"Ref", 'checked'=>1), 'owner'=>array('label'=>"Owner", 'checked'=>1), 'c.libelle'=>array('label'=>"Type", 'checked'=>1), @@ -132,7 +132,7 @@ $arrayfields=array( 'a.datep2'=>array('label'=>"DateEnd", 'checked'=>1), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 'a.fk_contact'=>array('label'=>"Contact", 'checked'=>1), - 'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>0, 'enabled'=>(! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))), + 'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>0, 'enabled'=>(!empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))), 'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'a.datec'=>array('label'=>'DateCreation', 'checked'=>0), 'a.tms'=>array('label'=>'DateModification', 'checked'=>0) @@ -140,10 +140,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -156,12 +156,12 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { - $param=''; + $param = ''; if (is_array($_POST)) { - foreach($_POST as $key => $val) + foreach ($_POST as $key => $val) { - $param.='&'.$key.'='.urlencode($val); + $param .= '&'.$key.'='.urlencode($val); } } //print $param; @@ -169,8 +169,8 @@ if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) exit; } -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid); +$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'); // Selection of new fields @@ -179,13 +179,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; 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 { //$actioncode=''; - $search_id=''; - $search_title=''; - $search_note=''; - $datestart=''; - $dateend=''; - $status=''; - $search_array_options=array(); + $search_id = ''; + $search_title = ''; + $search_note = ''; + $datestart = ''; + $dateend = ''; + $status = ''; + $search_array_options = array(); } @@ -193,154 +193,154 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' * View */ -$form=new Form($db); -$userstatic=new User($db); -$formactions=new FormActions($db); +$form = new Form($db); +$userstatic = new User($db); +$formactions = new FormActions($db); $nav = ''; $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -$nav .=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">'; +$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">'; -$now=dol_now(); +$now = dol_now(); -$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('', $langs->trans("Agenda"), $help_url); // Define list of all external calendars -$listofextcals=array(); +$listofextcals = array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($actioncode != '') { - if(is_array($actioncode)) { - foreach($actioncode as $str_action) $param.="&search_actioncode[]=".urlencode($str_action); - } else $param.="&search_actioncode=".urlencode($actioncode); + if (is_array($actioncode)) { + foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); + } else $param .= "&search_actioncode=".urlencode($actioncode); } -if ($resourceid > 0) $param.="&search_resourceid=".urlencode($resourceid); -if ($status != '' && $status > -1) $param.="&search_status=".urlencode($status); -if ($filter) $param.="&search_filter=".urlencode($filter); -if ($filtert) $param.="&search_filtert=".urlencode($filtert); -if ($socid) $param.="&search_socid=".urlencode($socid); -if ($showbirthday) $param.="&search_showbirthday=1"; -if ($pid) $param.="&search_projectid=".urlencode($pid); -if ($type) $param.="&search_type=".urlencode($type); -if ($usergroup) $param.="&search_usergroup=".urlencode($usergroup); -if ($search_id != '') $param.='&search_title='.urlencode($search_id); -if ($search_title != '') $param.='&search_title='.urlencode($search_title); -if ($search_note != '') $param.='&search_note='.$search_note; -if (GETPOST('datestartday', 'int')) $param.='&datestartday='.GETPOST('datestartday', 'int'); -if (GETPOST('datestartmonth', 'int')) $param.='&datestartmonth='.GETPOST('datestartmonth', 'int'); -if (GETPOST('datestartyear', 'int')) $param.='&datestartyear='.GETPOST('datestartyear', 'int'); -if (GETPOST('dateendday', 'int')) $param.='&dateendday='.GETPOST('dateendday', 'int'); -if (GETPOST('dateendmonth', 'int')) $param.='&dateendmonth='.GETPOST('dateendmonth', 'int'); -if (GETPOST('dateendyear', 'int')) $param.='&dateendyear='.GETPOST('dateendyear', 'int'); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); +if ($status != '' && $status > -1) $param .= "&search_status=".urlencode($status); +if ($filter) $param .= "&search_filter=".urlencode($filter); +if ($filtert) $param .= "&search_filtert=".urlencode($filtert); +if ($socid) $param .= "&search_socid=".urlencode($socid); +if ($showbirthday) $param .= "&search_showbirthday=1"; +if ($pid) $param .= "&search_projectid=".urlencode($pid); +if ($type) $param .= "&search_type=".urlencode($type); +if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); +if ($search_id != '') $param .= '&search_title='.urlencode($search_id); +if ($search_title != '') $param .= '&search_title='.urlencode($search_title); +if ($search_note != '') $param .= '&search_note='.$search_note; +if (GETPOST('datestartday', 'int')) $param .= '&datestartday='.GETPOST('datestartday', 'int'); +if (GETPOST('datestartmonth', 'int')) $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int'); +if (GETPOST('datestartyear', 'int')) $param .= '&datestartyear='.GETPOST('datestartyear', 'int'); +if (GETPOST('dateendday', 'int')) $param .= '&dateendday='.GETPOST('dateendday', 'int'); +if (GETPOST('dateendmonth', 'int')) $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int'); +if (GETPOST('dateendyear', 'int')) $param .= '&dateendyear='.GETPOST('dateendyear', 'int'); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $sql = "SELECT"; -if ($usergroup > 0) $sql.=" DISTINCT"; -$sql.= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,"; -$sql.= " a.id, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,"; -$sql.= ' a.fk_user_author,a.fk_user_action,'; -$sql.= " a.fk_contact, a.note, a.percent as percent,"; -$sql.= " a.fk_element, a.elementtype, a.datec, a.tms as datem,"; -$sql.= " c.code as type_code, c.libelle as type_label,"; -$sql.= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id"; +if ($usergroup > 0) $sql .= " DISTINCT"; +$sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,"; +$sql .= " a.id, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,"; +$sql .= ' a.fk_user_author,a.fk_user_action,'; +$sql .= " a.fk_contact, a.note, a.percent as percent,"; +$sql .= " a.fk_element, a.elementtype, a.datec, a.tms as datem,"; +$sql .= " c.code as type_code, c.libelle as type_label,"; +$sql .= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$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."actioncomm as a"; -$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) "; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; -$sql.=" ,".MAIN_DB_PREFIX."c_actioncomm as c"; +$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) "; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; +$sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c"; // We must filter on resource table -if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; +if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; -if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; -$sql.= " WHERE c.id = a.fk_action"; -$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; +if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; +$sql .= " WHERE c.id = a.fk_action"; +$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode -if (! empty($actioncode)) +if (!empty($actioncode)) { if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; else { - if ($actioncode == 'AC_OTH') $sql.= " AND c.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; } } else { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; else { if (is_array($actioncode)) { - $sql.=" AND c.code IN ('".implode("','", $actioncode)."')"; + $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; } else { - $sql.=" AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; + $sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; } } } } -if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); -if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; -if ($socid > 0) $sql.= " AND s.rowid = ".$socid; +if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); +if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; +if ($socid > 0) $sql .= " AND s.rowid = ".$socid; // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; -if ($type) $sql.= " AND c.id = ".$type; -if ($status == '0') { $sql.= " AND a.percent = 0"; } -if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable -if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started -if ($status == '100') { $sql.= " AND a.percent = 100"; } -if ($status == 'done') { $sql.= " AND (a.percent = 100)"; } -if ($status == 'todo') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; } -if ($search_id) $sql.=natural_search("a.id", $search_id, 1); -if ($search_title) $sql.=natural_search("a.label", $search_title); -if ($search_note) $sql.=natural_search('a.note', $search_note); +if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; +if ($type) $sql .= " AND c.id = ".$type; +if ($status == '0') { $sql .= " AND a.percent = 0"; } +if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable +if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started +if ($status == '100') { $sql .= " AND a.percent = 100"; } +if ($status == 'done') { $sql .= " AND (a.percent = 100)"; } +if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } +if ($search_id) $sql .= natural_search("a.id", $search_id, 1); +if ($search_title) $sql .= natural_search("a.label", $search_title); +if ($search_note) $sql .= natural_search('a.note', $search_note); // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql.= " AND ("; - if ($filtert > 0) $sql.= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility - if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; - $sql.= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case) -if ($dateselect > 0) $sql.= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect-3600)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."'))"; -if ($datestart > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart+3600*24-1)."'"; -if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'"; +if ($dateselect > 0) $sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))"; +if ($datestart > 0) $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'"; +if ($dateend > 0) $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -354,23 +354,23 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; dol_syslog("comm/action/list.php", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { - $actionstatic=new ActionComm($db); - $societestatic=new Societe($db); + $actionstatic = new ActionComm($db); + $societestatic = new Societe($db); $num = $db->num_rows($resql); // Local calendar - $newtitle ='<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").'   </div>'; + $newtitle = '<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").'   </div>'; //$newtitle=$langs->trans($title); - $tabactive='cardlist'; + $tabactive = 'cardlist'; $head = calendars_prepare_head($param); @@ -384,14 +384,14 @@ if ($resql) print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="type" value="'.$type.'">'; - $nav=''; + $nav = ''; //if ($actioncode) $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">'; //if ($resourceid) $nav.='<input type="hidden" name="resourceid" value="'.$resourceid.'">'; - if ($filter) $nav.='<input type="hidden" name="search_filter" value="'.$filter.'">'; + if ($filter) $nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">'; //if ($filtert) $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">'; //if ($socid) $nav.='<input type="hidden" name="socid" value="'.$socid.'">'; - if ($showbirthday) $nav.='<input type="hidden" name="search_showbirthday" value="1">'; + if ($showbirthday) $nav .= '<input type="hidden" name="search_showbirthday" value="1">'; //if ($pid) $nav.='<input type="hidden" name="projectid" value="'.$pid.'">'; //if ($usergroup) $nav.='<input type="hidden" name="usergroup" value="'.$usergroup.'">'; print $nav; @@ -401,7 +401,7 @@ if ($resql) dol_fiche_end(); // Add link to show birthdays - $link=''; + $link = ''; /* if (empty($conf->use_javascript_ajax)) { @@ -417,76 +417,76 @@ if ($resql) } */ - $s=$newtitle; + $s = $newtitle; // Calendars from hooks - $parameters=array(); $object=null; - $reshook=$hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); + $parameters = array(); $object = null; + $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); if (empty($reshook)) { - $s.= $hookmanager->resPrint; + $s .= $hookmanager->resPrint; } elseif ($reshook > 1) { $s = $hookmanager->resPrint; } - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { - $tmpforcreatebutton=dol_getdate(dol_now(), true); + $tmpforcreatebutton = dol_getdate(dol_now(), true); - $newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; //$param='month='.$monthshown.'&year='.$year; - $hourminsec='100000'; - $newcardbutton.= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:''))); + $hourminsec = '100000'; + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); } print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit); - $moreforfilter=''; + $moreforfilter = ''; - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); $i = 0; print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<tr class="liste_titre_filter">'; - if (! empty($arrayfields['a.id']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>'; - if (! empty($arrayfields['owner']['checked'])) print '<td class="liste_titre"></td>'; - if (! empty($arrayfields['c.libelle']['checked'])) print '<td class="liste_titre"></td>'; - if (! empty($arrayfields['a.label']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>'; - if (! empty($arrayfields['a.note']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>'; - if (! empty($arrayfields['a.datep']['checked'])) { + if (!empty($arrayfields['a.id']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>'; + if (!empty($arrayfields['owner']['checked'])) print '<td class="liste_titre"></td>'; + if (!empty($arrayfields['c.libelle']['checked'])) print '<td class="liste_titre"></td>'; + if (!empty($arrayfields['a.label']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>'; + if (!empty($arrayfields['a.note']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>'; + if (!empty($arrayfields['a.datep']['checked'])) { print '<td class="liste_titre nowraponall" align="center">'; print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0); print '</td>'; } - if (! empty($arrayfields['a.datep2']['checked'])) { + if (!empty($arrayfields['a.datep2']['checked'])) { print '<td class="liste_titre nowraponall" align="center">'; print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0); print '</td>'; } - if (! empty($arrayfields['s.nom']['checked'])) { + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre"></td>'; } - if (! empty($arrayfields['a.fk_contact']['checked'])) print '<td class="liste_titre"></td>'; - if (! empty($arrayfields['a.fk_element']['checked'])) print '<td class="liste_titre"></td>'; + if (!empty($arrayfields['a.fk_contact']['checked'])) print '<td class="liste_titre"></td>'; + if (!empty($arrayfields['a.fk_element']['checked'])) print '<td class="liste_titre"></td>'; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['a.datec']['checked'])) print '<td class="liste_titre"></td>'; - if (! empty($arrayfields['a.tms']['checked'])) print '<td class="liste_titre"></td>'; - if (! empty($arrayfields['a.percent']['checked'])) { + if (!empty($arrayfields['a.datec']['checked'])) print '<td class="liste_titre"></td>'; + if (!empty($arrayfields['a.tms']['checked'])) print '<td class="liste_titre"></td>'; + if (!empty($arrayfields['a.percent']['checked'])) { print '<td class="liste_titre center">'; $formactions->form_select_status_action('formaction', $status, 1, 'status', 1, 2, 'minwidth100imp maxwidth125'); print ajax_combobox('selectstatus'); @@ -494,46 +494,46 @@ if ($resql) } // Action column print '<td class="liste_titre" align="middle">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; - if (! empty($arrayfields['a.id']['checked'])) print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['a.note']['checked'])) print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.id']['checked'])) print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.note']['checked'])) print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) - if (! empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['a.datec']['checked'])) print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['a.tms']['checked'])) print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.datec']['checked'])) print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.tms']['checked'])) print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['a.percent']['checked']))print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.percent']['checked']))print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "</tr>\n"; $contactstatic = new Contact($db); - $now=dol_now(); - $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; + $now = dol_now(); + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; - $caction=new CActionComm($db); - $arraylist=$caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0), '', 1); + $caction = new CActionComm($db); + $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); $contactListCache = array(); while ($i < min($num, $limit)) @@ -541,34 +541,34 @@ if ($resql) $obj = $db->fetch_object($resql); // Discard auto action if option is on - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') { $i++; continue; } - $actionstatic->id=$obj->id; - $actionstatic->ref=$obj->id; - $actionstatic->type_code=$obj->type_code; - $actionstatic->type_label=$obj->type_label; - $actionstatic->type_picto=$obj->type_picto; - $actionstatic->label=$obj->label; + $actionstatic->id = $obj->id; + $actionstatic->ref = $obj->id; + $actionstatic->type_code = $obj->type_code; + $actionstatic->type_label = $obj->type_label; + $actionstatic->type_picto = $obj->type_picto; + $actionstatic->label = $obj->label; $actionstatic->location = $obj->location; - $actionstatic->note=dol_htmlentitiesbr($obj->note); + $actionstatic->note = dol_htmlentitiesbr($obj->note); print '<tr class="oddeven">'; // Ref - if (! empty($arrayfields['a.id']['checked'])) { + if (!empty($arrayfields['a.id']['checked'])) { print '<td>'; print $actionstatic->getNomUrl(1, -1); print '</td>'; } // User owner - if (! empty($arrayfields['owner']['checked'])) + if (!empty($arrayfields['owner']['checked'])) { - print '<td class="tdoverflowmax150">'; // With edge and chrome the td overflow is not supported correctly when content is not full text. + print '<td class="tdoverflowmax150">'; // With edge and chrome the td overflow is not supported correctly when content is not full text. if ($obj->fk_user_action > 0) { $userstatic->fetch($obj->fk_user_action); @@ -579,10 +579,10 @@ if ($resql) } // Type - if (! empty($arrayfields['c.libelle']['checked'])) + if (!empty($arrayfields['c.libelle']['checked'])) { print '<td>'; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($actionstatic->type_picto) print img_picto('', $actionstatic->type_picto); else { @@ -591,60 +591,60 @@ if ($resql) elseif ($actionstatic->type_code == 'AC_FAX') print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; elseif ($actionstatic->type_code == 'AC_EMAIL') print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; elseif ($actionstatic->type_code == 'AC_INT') print img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; - elseif (! preg_match('/_AUTO/', $actionstatic->type_code)) print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; + elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; } } - $labeltype=$obj->type_code; - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype='AC_OTH'; - if (! empty($arraylist[$labeltype])) $labeltype=$arraylist[$labeltype]; + $labeltype = $obj->type_code; + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH'; + if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; print dol_trunc($labeltype, 28); print '</td>'; } // Label - if (! empty($arrayfields['a.label']['checked'])) { + if (!empty($arrayfields['a.label']['checked'])) { print '<td class="tdoverflowmax200">'; print $actionstatic->label; print '</td>'; } // Description - if (! empty($arrayfields['a.note']['checked'])) { + if (!empty($arrayfields['a.note']['checked'])) { print '<td class="tdoverflowonsmartphone">'; $text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note, 0)); print $form->textwithtooltip(dol_trunc($text, 40), $actionstatic->note); print '</td>'; } - $formatToUse = $obj->fulldayevent?'day':'dayhour'; + $formatToUse = $obj->fulldayevent ? 'day' : 'dayhour'; // Start date - if (! empty($arrayfields['a.datep']['checked'])) { + if (!empty($arrayfields['a.datep']['checked'])) { print '<td align="center">'; print dol_print_date($db->jdate($obj->dp), $formatToUse); - $late=0; - if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1; - if ($obj->percent == 0 && ! $obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1; - if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late=1; - if ($obj->percent > 0 && $obj->percent < 100 && ! $obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1; + $late = 0; + if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; + if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; + if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late = 1; + if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; if ($late) print img_warning($langs->trans("Late")).' '; print '</td>'; } // End date - if (! empty($arrayfields['a.datep2']['checked'])) { + if (!empty($arrayfields['a.datep2']['checked'])) { print '<td align="center">'; print dol_print_date($db->jdate($obj->dp2), $formatToUse); print '</td>'; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) { + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="tdoverflowmax150">'; if ($obj->socid > 0) { - $societestatic->id=$obj->socid; - $societestatic->client=$obj->client; - $societestatic->name=$obj->societe; - $societestatic->email=$obj->socemail; + $societestatic->id = $obj->socid; + $societestatic->client = $obj->client; + $societestatic->name = $obj->societe; + $societestatic->email = $obj->socemail; print $societestatic->getNomUrl(1, '', 28); } @@ -653,44 +653,44 @@ if ($resql) } // Contact - if (! empty($arrayfields['a.fk_contact']['checked'])) { + if (!empty($arrayfields['a.fk_contact']['checked'])) { print '<td>'; $actionstatic->fetchResources(); - if(!empty($actionstatic->socpeopleassigned)) + if (!empty($actionstatic->socpeopleassigned)) { $contactList = array(); foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) { - if(!isset($contactListCache[$socpeopleassigned['id']])) + if (!isset($contactListCache[$socpeopleassigned['id']])) { // if no cache found we fetch it $contact = new Contact($db); - if($contact->fetch($socpeopleassigned['id'])>0) + if ($contact->fetch($socpeopleassigned['id']) > 0) { $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); $contactList[] = $contact->getNomUrl(1, '', 0); } } - else{ + else { // use cache $contactList[] = $contactListCache[$socpeopleassigned['id']]; } } - if(!empty($contactList)){ + if (!empty($contactList)) { print implode(', ', $contactList); } } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event { - $contactstatic->id=$obj->fk_contact; - $contactstatic->email=$obj->email; - $contactstatic->lastname=$obj->lastname; - $contactstatic->firstname=$obj->firstname; - $contactstatic->phone_pro=$obj->phone_pro; - $contactstatic->phone_mobile=$obj->phone_mobile; - $contactstatic->phone_perso=$obj->phone_perso; - $contactstatic->country_id=$obj->country_id; + $contactstatic->id = $obj->fk_contact; + $contactstatic->email = $obj->email; + $contactstatic->lastname = $obj->lastname; + $contactstatic->firstname = $obj->firstname; + $contactstatic->phone_pro = $obj->phone_pro; + $contactstatic->phone_mobile = $obj->phone_mobile; + $contactstatic->phone_perso = $obj->phone_perso; + $contactstatic->country_id = $obj->country_id; print $contactstatic->getNomUrl(1, '', 0); } else @@ -701,10 +701,10 @@ if ($resql) } // Linked object - if (! empty($arrayfields['a.fk_element']['checked'])) { + if (!empty($arrayfields['a.fk_element']['checked'])) { print '<td>'; //var_dump($obj->fkelement.' '.$obj->elementtype); - if ($obj->fk_element > 0 && ! empty($obj->elementtype)) { + if ($obj->fk_element > 0 && !empty($obj->elementtype)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); } else { @@ -716,22 +716,22 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['a.datec']['checked'])) { + if (!empty($arrayfields['a.datec']['checked'])) { // Status/Percent print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datec), 'dayhour').'</td>'; } // Date update - if (! empty($arrayfields['a.tms']['checked'])) { + if (!empty($arrayfields['a.tms']['checked'])) { print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>'; } - if (! empty($arrayfields['a.percent']['checked'])) { + if (!empty($arrayfields['a.percent']['checked'])) { // Status/Percent - $datep=$db->jdate($obj->datep); + $datep = $db->jdate($obj->datep); print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 3, 0, $datep).'</td>'; } print '<td></td>'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 11d57eabbfc..b3d8360e39a 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -36,21 +36,21 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formpropal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmargin.class.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/propale/modules_propale.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/propal.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/signature.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } if (!empty($conf->variants->enabled)) { @@ -60,7 +60,7 @@ if (!empty($conf->variants->enabled)) { // Load translation files required by the page $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'sendings', 'other')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -if (! empty($conf->margin->enabled)) +if (!empty($conf->margin->enabled)) $langs->load('margins'); $error = 0; @@ -78,15 +78,15 @@ $contactid = GETPOST('contactid', 'int'); $projectid = GETPOST('projectid', 'int'); // PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Nombre de ligne pour choix de produit/service predefinis $NBLINES = 4; // Security check -if (! empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'propal', $id); $object = new Propal($db); @@ -96,7 +96,7 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || ! empty($ref)) { +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); if ($ret > 0) $ret = $object->fetch_thirdparty(); @@ -108,13 +108,13 @@ 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('propalcard','globalcard')); +$hookmanager->initHooks(array('propalcard', 'globalcard')); $usercanread = $user->rights->propal->lire; $usercancreate = $user->rights->propal->creer; $usercanclose = $user->rights->propal->cloturer; $usercandelete = $user->rights->propal->supprimer; -$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate))); +$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate))); $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send); $usercancreateorder = $user->rights->commande->creer; @@ -124,7 +124,7 @@ $usercancreateintervention = $user->rights->ficheinter->creer; $usercancreatepurchaseorder = $user->rights->fournisseur->commande->creer; $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php +$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php @@ -140,24 +140,24 @@ if (empty($reshook)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; } include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { - if (! GETPOST('socid', 3)) + if (!GETPOST('socid', 3)) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } @@ -195,7 +195,7 @@ if (empty($reshook)) $result = $object->createFromClone($user, $socid); if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit(); } else { if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); @@ -210,7 +210,7 @@ if (empty($reshook)) { $result = $object->delete($user); if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1'); + header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php?restore_lastsearch_values=1'); exit(); } else { $langs->load("errors"); @@ -229,7 +229,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -238,7 +238,7 @@ if (empty($reshook)) $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } @@ -254,11 +254,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -275,11 +275,11 @@ if (empty($reshook)) $datep = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datep)) { - $error ++; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); } - if (! $error) { + if (!$error) { $result = $object->set_date($user, $datep); if ($result < 0) dol_print_error($db, $object->error); @@ -327,22 +327,22 @@ if (empty($reshook)) if (empty($datep)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = 'create'; - $error ++; + $error++; } if (empty($duration)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ValidityDuration")), null, 'errors'); $action = 'create'; - $error ++; + $error++; } if ($socid < 1) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors'); $action = 'create'; - $error ++; + $error++; } - if (! $error) + if (!$error) { $db->begin(); @@ -413,12 +413,12 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error ++; + $error++; $action = 'create'; } } - if (! $error) + if (!$error) { if ($origin && $originid) { @@ -452,19 +452,19 @@ if (empty($reshook)) // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { + if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } $id = $object->create($user); if ($id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); if ($result > 0) @@ -476,12 +476,12 @@ if (empty($reshook)) $lines = $srcobject->lines; } - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) + $fk_parent_line = 0; + $num = count($lines); + for ($i = 0; $i < $num; $i++) { - $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); - $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); + $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle); // Positive line $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); @@ -516,7 +516,7 @@ if (empty($reshook)) } $tva_tx = $lines[$i]->tva_tx; - if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); @@ -524,7 +524,7 @@ if (empty($reshook)) $lineid = $result; } else { $lineid = 0; - $error ++; + $error++; break; } @@ -539,14 +539,14 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) - $error ++; + $error++; } else { setEventMessages($srcobject->error, $srcobject->errors, 'errors'); - $error ++; + $error++; } } else { setEventMessages($object->error, $object->errors, 'errors'); - $error ++; + $error++; } } // Standard creation else @@ -567,7 +567,7 @@ if (empty($reshook)) } } - if (! empty($conf->global->PROPOSAL_AUTO_ADD_AUTHOR_AS_CONTACT)) + if (!empty($conf->global->PROPOSAL_AUTO_ADD_AUTHOR_AS_CONTACT)) { $result = $object->add_contact($user->id, 'SALESREPFOLL', 'internal'); if ($result < 0) @@ -577,7 +577,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $db->commit(); @@ -588,31 +588,31 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit(); } else { $db->rollback(); - $action='create'; + $action = 'create'; } } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); - $action='create'; + $action = 'create'; } } } @@ -623,14 +623,14 @@ if (empty($reshook)) { $db->begin(); - $result=$object->cloture($user, Propal::STATUS_BILLED, ''); + $result = $object->cloture($user, Propal::STATUS_BILLED, ''); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->commit(); } @@ -641,8 +641,8 @@ if (empty($reshook)) } // Close proposal - elseif ($action == 'setstatut' && $usercanclose && ! GETPOST('cancel', 'alpha')) { - if (! (GETPOST('statut', 'int') > 0)) { + elseif ($action == 'setstatut' && $usercanclose && !GETPOST('cancel', 'alpha')) { + if (!(GETPOST('statut', 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors'); $action = 'statut'; } else { @@ -651,14 +651,14 @@ if (empty($reshook)) { $db->begin(); - $result=$object->cloture($user, GETPOST('statut', 'int'), GETPOST('note_private', 'none')); + $result = $object->cloture($user, GETPOST('statut', 'int'), GETPOST('note_private', 'none')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->commit(); } @@ -671,20 +671,20 @@ if (empty($reshook)) } // Reopen proposal - elseif ($action == 'confirm_reopen' && $usercanclose && ! GETPOST('cancel', 'alpha')) { + elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) { // prevent browser refresh from reopening proposal several times if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) { $db->begin(); - $result=$object->reopen($user, 1); + $result = $object->reopen($user, 1); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->commit(); } @@ -696,7 +696,7 @@ if (empty($reshook)) } // add lines from objectlinked - elseif($action == 'import_lines_from_object' + elseif ($action == 'import_lines_from_object' && $user->rights->propal->creer && $object->statut == Propal::STATUS_DRAFT ) @@ -705,14 +705,14 @@ if (empty($reshook)) $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); - if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) { - if($fromElement == 'commande') + if ($fromElement == 'commande') { dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'OrderLine'; } - elseif($fromElement == 'propal') + elseif ($fromElement == 'propal') { dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'PropaleLigne'; @@ -720,11 +720,11 @@ if (empty($reshook)) $nextRang = count($object->lines) + 1; $importCount = 0; $error = 0; - foreach($importLines as $lineId) + foreach ($importLines as $lineId) { $lineId = intval($lineId); $originLine = new $lineClassName($db); - if(intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) { $originLine->fetch_optionals($lineId); $desc = $originLine->desc; @@ -740,15 +740,15 @@ if (empty($reshook)) $ventil = 0; $info_bits = $originLine->info_bits; $fk_remise_except = $originLine->fk_remise_except; - $price_base_type='HT'; - $pu_ttc=0; + $price_base_type = 'HT'; + $pu_ttc = 0; $type = $originLine->product_type; - $rang=$nextRang++; + $rang = $nextRang++; $special_code = $originLine->special_code; $origin = $originLine->element; $origin_id = $originLine->id; - $fk_parent_line=0; - $fk_fournprice=$originLine->fk_fournprice; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; $pa_ht = $originLine->pa_ht; $label = $originLine->label; $array_options = $originLine->array_options; @@ -759,18 +759,18 @@ if (empty($reshook)) $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $date_start, $date_end, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise, $fk_remise_except); - if($res > 0){ + if ($res > 0) { $importCount++; - }else{ + } else { $error++; } } - else{ + else { $error++; } } - if($error) + if ($error) { setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); } @@ -780,10 +780,10 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $actiontypecode='AC_OTH_AUTO'; - $trigger_name='PROPAL_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_PROPOSAL_TO'; - $trackid='pro'.$object->id; + $actiontypecode = 'AC_OTH_AUTO'; + $trigger_name = 'PROPAL_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_PROPOSAL_TO'; + $trackid = 'pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; @@ -796,7 +796,7 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -820,25 +820,25 @@ if (empty($reshook)) // Add line elseif ($action == 'addline' && $usercancreate) { // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $predef = ''; + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); $price_ht = GETPOST('price_ht'); $price_ht_devise = GETPOST('multicurrency_price_ht'); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); - if (empty($remise_percent)) $remise_percent=0; + $qty = GETPOST('qty'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); + if (empty($remise_percent)) $remise_percent = 0; // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -847,23 +847,23 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error ++; + $error++; } if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); - $error ++; + $error++; } if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); - $error ++; + $error++; } if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') { @@ -875,12 +875,12 @@ if (empty($reshook)) $idprod = $res->fk_product_child; } else { setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors'); - $error ++; + $error++; } } } - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { $pu_ht = 0; $pu_ttc = 0; $price_min = 0; @@ -894,7 +894,7 @@ if (empty($reshook)) // Ecrase $desc par celui du produit // Ecrase $tva_tx par celui du produit // Replaces $fk_unit with the product unit - if (! empty($idprod)) { + if (!empty($idprod)) { $prod = new Product($db); $prod->fetch($idprod); @@ -903,7 +903,7 @@ if (empty($reshook)) // Update if prices fields are defined $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; // Price unique per product $pu_ht = $prod->price; @@ -912,22 +912,22 @@ if (empty($reshook)) $price_base_type = $prod->price_base_type; // If price per segment - if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level) { $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } // If price per customer - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); @@ -940,15 +940,15 @@ if (empty($reshook)) $pu_ht = price($prodcustprice->lines[0]->price); $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; - $tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx . ' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx); - if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx); + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; } } } // If price per quantity - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity { @@ -956,7 +956,7 @@ if (empty($reshook)) $pqp = GETPOST('pbq', 'int'); // Search price into product_price_by_qty from $prod->id - foreach($prod->prices_by_qty_list[0] as $priceforthequantityarray) + foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -974,7 +974,7 @@ if (empty($reshook)) } } // If price per quantity and customer - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($prod->prices_by_qty[$object->thirdparty->price_level]) // yes, this product has some prices per quantity { @@ -982,7 +982,7 @@ if (empty($reshook)) $pqp = GETPOST('pbq', 'int'); // Search price into product_price_by_qty from $prod->id - foreach($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) + foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -1004,7 +1004,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? - if (! empty($price_ht)) { + if (!empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } @@ -1021,24 +1021,24 @@ if (empty($reshook)) $desc = ''; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; } else { $desc = $prod->description; } - if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc= $product_desc; + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); // Add dimensions into product description @@ -1054,35 +1054,35 @@ if (empty($reshook)) }*/ // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) { $tmptxt = '('; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'alpha')) $newlang = GETPOST('lang_id', 'alpha'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - if (! empty($prod->customcode)) - $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) + if (!empty($prod->customcode)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $outputlangs, 0); + if (!empty($prod->country_code)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $outputlangs, 0); } else { - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) + if (!empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + if (!empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $langs, 0); } $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); @@ -1104,11 +1104,11 @@ if (empty($reshook)) } // Margin - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we muste keep this value + $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); + $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we muste keep this value - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr); @@ -1118,7 +1118,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) ) && (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); setEventMessages($mesg, null, 'errors'); } else { @@ -1131,7 +1131,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -1201,7 +1201,7 @@ if (empty($reshook)) // Add buying price $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value + $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value $pu_ht_devise = GETPOST('multicurrency_subprice'); @@ -1215,30 +1215,30 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } // Define special_code for special lines - $special_code=GETPOST('special_code'); - if (! GETPOST('qty')) $special_code=3; + $special_code = GETPOST('special_code'); + if (!GETPOST('qty')) $special_code = 3; // Check minimum price $productid = GETPOST('productid', 'int'); - if (! empty($productid)) { + if (!empty($productid)) { $product = new Product($db); $res = $product->fetch($productid); $type = $product->type; $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) $price_min = $product->multiprices_min [$object->thirdparty->price_level]; $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); - $error ++; + $error++; } } else { $type = GETPOST('type'); @@ -1247,11 +1247,11 @@ if (empty($reshook)) // Check parameters if (GETPOST('type') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error ++; + $error++; } } - if (! $error) { + if (!$error) { $db->begin(); if (empty($user->rights->margins->creer)) @@ -1274,7 +1274,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -1316,7 +1316,7 @@ if (empty($reshook)) } } } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha')) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } @@ -1365,12 +1365,12 @@ if (empty($reshook)) // bank account elseif ($action == 'setbankaccount' && $usercancreate) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } // shipping method elseif ($action == 'setshippingmethod' && $usercancreate) { - $result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int')); + $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); } elseif ($action == 'update_extras') { @@ -1379,7 +1379,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { $result = $object->insertExtraFields('PROPAL_MODIFY'); if ($result < 0) @@ -1391,7 +1391,7 @@ if (empty($reshook)) if ($error) $action = 'edit_extras'; } - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { if ($action == 'addcontact') { @@ -1401,7 +1401,7 @@ if (empty($reshook)) } if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit(); } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { @@ -1428,7 +1428,7 @@ if (empty($reshook)) $result = $object->delete_contact($lineid); if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit(); } else { dol_print_error($db); @@ -1455,7 +1455,7 @@ $formfile = new FormFile($db); $formpropal = new FormPropal($db); $formmargin = new FormMargin($db); $companystatic = new Societe($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $now = dol_now(); @@ -1471,7 +1471,7 @@ if ($action == 'create') $res = $soc->fetch($socid); // Load objectsrc - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -1498,7 +1498,7 @@ if ($action == 'create') $element = $subelement = 'expedition'; } - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($db); @@ -1509,17 +1509,17 @@ if ($action == 'create') } $objectsrc->fetch_thirdparty(); - $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : 0); - $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); - $ref_int = (! empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); + $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : 0); + $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); + $ref_int = (!empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); $soc = $objectsrc->thirdparty; - $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); // TODO maybe add default value option - $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); // TODO maybe add default value option + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice); // Replicate extrafields $objectsrc->fetch_optionals($originid); @@ -1539,14 +1539,14 @@ if ($action == 'create') $object = new Propal($db); - print '<form name="addprop" action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; + print '<form name="addprop" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; + print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">'; print '<input type="hidden" name="action" value="add">'; if ($origin != 'project' && $originid) { - print '<input type="hidden" name="origin" value="' . $origin . '">'; - print '<input type="hidden" name="originid" value="' . $originid . '">'; + print '<input type="hidden" name="origin" value="'.$origin.'">'; + print '<input type="hidden" name="originid" value="'.$originid.'">'; } elseif ($origin == 'project' && !empty($projectid)) { - print '<input type="hidden" name="projectid" value="' . $projectid . '">'; + print '<input type="hidden" name="projectid" value="'.$projectid.'">'; } dol_fiche_head(); @@ -1554,22 +1554,22 @@ if ($action == 'create') print '<table class="border centpercent">'; // Reference - print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans('Ref') . '</td><td>' . $langs->trans("Draft") . '</td></tr>'; + print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td>'.$langs->trans("Draft").'</td></tr>'; // Ref customer - print '<tr><td>' . $langs->trans('RefCustomer') . '</td><td>'; + print '<tr><td>'.$langs->trans('RefCustomer').'</td><td>'; print '<input type="text" name="ref_client" value="'.GETPOST('ref_client').'"></td>'; print '</tr>'; // Third party print '<tr>'; - print '<td class="fieldrequired">' . $langs->trans('Customer') . '</td>'; + print '<td class="fieldrequired">'.$langs->trans('Customer').'</td>'; if ($socid > 0) { print '<td>'; print $soc->getNomUrl(1); - print '<input type="hidden" name="socid" value="' . $soc->id . '">'; + print '<input type="hidden" name="socid" value="'.$soc->id.'">'; print '</td>'; - if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && ! empty($soc->shipping_method_id)) { + if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) { $shipping_method_id = $soc->shipping_method_id; } } else { @@ -1591,71 +1591,71 @@ if ($action == 'create') print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>'; print '</td>'; } - print '</tr>' . "\n"; + print '</tr>'."\n"; if ($socid > 0) { // Contacts (ask contact only if thirdparty already defined). - print "<tr><td>" . $langs->trans("DefaultContact") . '</td><td>'; + print "<tr><td>".$langs->trans("DefaultContact").'</td><td>'; $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist); print '</td></tr>'; // Third party discounts info line - print '<tr><td>' . $langs->trans('Discounts') . '</td><td>'; + print '<tr><td>'.$langs->trans('Discounts').'</td><td>'; $absolute_discount = $soc->getAvailableDiscounts(); $thirdparty = $soc; $discount_type = 0; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '</td></tr>'; } // Date - print '<tr><td class="fieldrequired">' . $langs->trans('Date') . '</td><td>'; + print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>'; print $form->selectDate('', '', '', '', '', "addprop", 1, 1); print '</td></tr>'; // Validaty duration - print '<tr><td class="fieldrequired">' . $langs->trans("ValidityDuration") . '</td><td><input name="duree_validite" class="width50" value="' . (GETPOST('duree_validite', 'int') ? GETPOST('duree_validite', 'int') : $conf->global->PROPALE_VALIDITY_DURATION) . '"> ' . $langs->trans("days") . '</td></tr>'; + print '<tr><td class="fieldrequired">'.$langs->trans("ValidityDuration").'</td><td><input name="duree_validite" class="width50" value="'.(GETPOST('duree_validite', 'int') ? GETPOST('duree_validite', 'int') : $conf->global->PROPALE_VALIDITY_DURATION).'"> '.$langs->trans("days").'</td></tr>'; // Terms of payment - print '<tr><td class="nowrap">' . $langs->trans('PaymentConditionsShort') . '</td><td>'; + print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>'; $form->select_conditions_paiements($soc->cond_reglement_id, 'cond_reglement_id', -1, 1); print '</td></tr>'; // Mode of payment - print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td>'; + print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>'; $form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id'); print '</td></tr>'; // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) { - print '<tr><td>' . $langs->trans('BankAccount') . '</td><td>'; + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) { + print '<tr><td>'.$langs->trans('BankAccount').'</td><td>'; $form->select_comptes($soc->fk_account, 'fk_account', 0, '', 1); print '</td></tr>'; } // What trigger creation - print '<tr><td>' . $langs->trans('Source') . '</td><td>'; + print '<tr><td>'.$langs->trans('Source').'</td><td>'; $form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1); print '</td></tr>'; // Delivery delay - print '<tr class="fielddeliverydelay"><td>' . $langs->trans('AvailabilityPeriod') . '</td><td>'; + print '<tr class="fielddeliverydelay"><td>'.$langs->trans('AvailabilityPeriod').'</td><td>'; $form->selectAvailabilityDelay('', 'availability_id', '', 1); print '</td></tr>'; // Shipping Method - if (! empty($conf->expedition->enabled)) { - print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>'; + if (!empty($conf->expedition->enabled)) { + print '<tr><td>'.$langs->trans('SendingMethod').'</td><td>'; print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); print '</td></tr>'; } // Delivery date (or manufacturing) - print '<tr><td>' . $langs->trans("DeliveryDate") . '</td>'; + print '<tr><td>'.$langs->trans("DeliveryDate").'</td>'; print '<td>'; if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); @@ -1669,13 +1669,13 @@ if ($action == 'create') print '</td></tr>'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); print '<tr>'; - print '<td>' . $langs->trans("Project") . '</td><td>'; + print '<td>'.$langs->trans("Project").'</td><td>'; $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1); - print '   <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="valignmiddle text-plus-circle">' . $langs->trans("AddProject") . '</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>'; + print '   <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>'; print '</td>'; print '</tr>'; } @@ -1686,20 +1686,20 @@ if ($action == 'create') print '<tr>'; print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->label_incoterms, 1).'</label></td>'; print '<td class="maxwidthonsmartphone">'; - print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:'')); + print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms) ? $soc->location_incoterms : '')); print '</td></tr>'; } // Template to use by default print '<tr>'; - print '<td>' . $langs->trans("DefaultModel") . '</td>'; + print '<td>'.$langs->trans("DefaultModel").'</td>'; print '<td>'; $liste = ModelePDFPropales::liste_modeles($db); print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF)); print "</td></tr>"; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print '<tr>'; print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>'; @@ -1710,9 +1710,9 @@ if ($action == 'create') // Public note print '<tr>'; - print '<td class="tdtop">' . $langs->trans('NotePublic') . '</td>'; + print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>'; print '<td valign="top">'; - $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc)?$objectsrc->note_public:null)); + $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc) ? $objectsrc->note_public : null)); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -1720,9 +1720,9 @@ if ($action == 'create') if (empty($user->socid)) { print '<tr>'; - print '<td class="tdtop">' . $langs->trans('NotePrivate') . '</td>'; + print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>'; print '<td valign="top">'; - $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null)); + $note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null)); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea> @@ -1730,10 +1730,10 @@ if ($action == 'create') } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Lines from source - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { // TODO for compatibility if ($origin == 'contrat') { @@ -1743,13 +1743,13 @@ if ($action == 'create') $objectsrc->update_price(1, - 1, 1); } - print "\n<!-- " . $classname . " info -->"; + print "\n<!-- ".$classname." info -->"; print "\n"; - print '<input type="hidden" name="amount" value="' . $objectsrc->total_ht . '">' . "\n"; - print '<input type="hidden" name="total" value="' . $objectsrc->total_ttc . '">' . "\n"; - print '<input type="hidden" name="tva" value="' . $objectsrc->total_tva . '">' . "\n"; - print '<input type="hidden" name="origin" value="' . $objectsrc->element . '">'; - print '<input type="hidden" name="originid" value="' . $objectsrc->id . '">'; + print '<input type="hidden" name="amount" value="'.$objectsrc->total_ht.'">'."\n"; + print '<input type="hidden" name="total" value="'.$objectsrc->total_ttc.'">'."\n"; + print '<input type="hidden" name="tva" value="'.$objectsrc->total_tva.'">'."\n"; + print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">'; + print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">'; $newclassname = $classname; if ($newclassname == 'Propal') @@ -1761,25 +1761,25 @@ if ($action == 'create') elseif ($newclassname == 'Fichinter') $newclassname = 'Intervention'; - print '<tr><td>' . $langs->trans($newclassname) . '</td><td>' . $objectsrc->getNomUrl(1) . '</td></tr>'; - print '<tr><td>' . $langs->trans('AmountHT') . '</td><td>' . price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency) . '</td></tr>'; - print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td>' . price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>"; - if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0 ) // Localtax1 + print '<tr><td>'.$langs->trans($newclassname).'</td><td>'.$objectsrc->getNomUrl(1).'</td></tr>'; + print '<tr><td>'.$langs->trans('AmountHT').'</td><td>'.price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency).'</td></tr>'; + print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency)."</td></tr>"; + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 { - print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>"; + print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency)."</td></tr>"; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 { - print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>"; + print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency)."</td></tr>"; } - print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td>' . price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>"; + print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency)."</td></tr>"; if (!empty($conf->multicurrency->enabled)) { - print '<tr><td>' . $langs->trans('MulticurrencyAmountHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>'; - print '<tr><td>' . $langs->trans('MulticurrencyAmountVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>"; - print '<tr><td>' . $langs->trans('MulticurrencyAmountTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>"; + print '<tr><td>'.$langs->trans('MulticurrencyAmountHT').'</td><td>'.price($objectsrc->multicurrency_total_ht).'</td></tr>'; + print '<tr><td>'.$langs->trans('MulticurrencyAmountVAT').'</td><td>'.price($objectsrc->multicurrency_total_tva)."</td></tr>"; + print '<tr><td>'.$langs->trans('MulticurrencyAmountTTC').'</td><td>'.price($objectsrc->multicurrency_total_ttc)."</td></tr>"; } } @@ -1792,21 +1792,21 @@ if ($action == 'create') if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print '<input type="hidden" name="createmode" value="empty">'; - if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) + if (!empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) { print '<br><table>'; // For backward compatibility print '<tr>'; print '<td><input type="radio" name="createmode" value="copy"></td>'; - print '<td>' . $langs->trans("CopyPropalFrom") . ' </td>'; + print '<td>'.$langs->trans("CopyPropalFrom").' </td>'; print '<td>'; $liste_propal = array(); $liste_propal [0] = ''; $sql = "SELECT p.rowid as id, p.ref, s.nom"; - $sql .= " FROM " . MAIN_DB_PREFIX . "propal p"; - $sql .= ", " . MAIN_DB_PREFIX . "societe s"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal p"; + $sql .= ", ".MAIN_DB_PREFIX."societe s"; $sql .= " WHERE s.rowid = p.fk_soc"; $sql .= " AND p.entity IN (".getEntity('propal').")"; $sql .= " AND p.fk_statut <> 0"; @@ -1818,9 +1818,9 @@ if ($action == 'create') $i = 0; while ($i < $num) { $row = $db->fetch_row($resql); - $propalRefAndSocName = $row [1] . " - " . $row [2]; + $propalRefAndSocName = $row [1]." - ".$row [2]; $liste_propal [$row [0]] = $propalRefAndSocName; - $i ++; + $i++; } print $form->selectarray("copie_propal", $liste_propal, 0); } else { @@ -1829,25 +1829,25 @@ if ($action == 'create') print '</td></tr>'; print '<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>'; - print '<td valign="top" colspan="2">' . $langs->trans("CreateEmptyPropal") . '</td></tr>'; + print '<td valign="top" colspan="2">'.$langs->trans("CreateEmptyPropal").'</td></tr>'; } - if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print '</table>'; + if (!empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print '</table>'; dol_fiche_end(); $langs->load("bills"); print '<div class="center">'; - print '<input type="submit" class="button" value="' . $langs->trans("CreateDraft") . '">'; + print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">'; print '     '; - print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; + print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; print '</div>'; print "</form>"; // Show origin lines - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { print '<br>'; $title = $langs->trans('ProductsAndServices'); @@ -1880,47 +1880,47 @@ if ($action == 'create') // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => // 1), - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->date_livraison)) { - $formquestion[] = array('type' => 'date','name' => 'date_delivery','label' => $langs->trans("DeliveryDate"),'value' => $object->date_livraison); + $formquestion[] = array('type' => 'date', 'name' => 'date_delivery', 'label' => $langs->trans("DeliveryDate"), 'value' => $object->date_livraison); } // Incomplete payment. We ask if reason = discount or other - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } if ($action == 'statut') { //Form to close proposal (signed or not) $formquestion = array( - array('type' => 'select','name' => 'statut','label' => $langs->trans("CloseAs"),'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))), - array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '') // Field to complete private note (not replace) + array('type' => 'select', 'name' => 'statut', 'label' => $langs->trans("CloseAs"), 'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))), + array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace) ); - if (! empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $formquestion = array_merge($formquestion, array( array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)), )); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('SetAcceptedRefused'), $text, 'setstatut', $formquestion, '', 1, 250); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'setstatut', $formquestion, '', 1, 250); } // Confirm delete elseif ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp', $object->ref), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp', $object->ref), 'confirm_delete', '', 0, 1); } // Confirm reopen elseif ($action == 'reopen') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp', $object->ref), 'confirm_reopen', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp', $object->ref), 'confirm_reopen', '', 0, 1); } // Confirmation delete product/service line elseif ($action == 'ask_deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } // Confirm validate proposal @@ -1932,7 +1932,7 @@ if ($action == 'create') if ($ref == 'PROV') { $numref = $object->getNextNumRef($soc); if (empty($numref)) { - $error ++; + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } else { @@ -1940,22 +1940,22 @@ if ($action == 'create') } $text = $langs->trans('ConfirmValidateProp', $numref); - if (! empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + if (!empty($conf->notification->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '<br>'; $text .= $notify->confirmMessage('PROPAL_VALIDATE', $object->socid, $object); } - if (! $error) - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate', '', 0, 1); + if (!$error) + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate', '', 0, 1); } // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -1963,48 +1963,48 @@ if ($action == 'create') // Proposal card - $linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; + $linkback = '<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; - $morehtmlref='<div class="refidno">'; + $morehtmlref = '<div class="refidno">'; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherProposals").'</a>)'; + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherProposals").'</a>)'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; + $morehtmlref .= '<br>'.$langs->trans('Project').' '; if ($usercancreate) { if ($action != 'classify') - $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; + $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref.='<input type="hidden" name="action" value="classin">'; - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref.='</form>'; + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref .= '</form>'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; - $morehtmlref.=$proj->ref; - $morehtmlref.='</a>'; + $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; + $morehtmlref .= $proj->ref; + $morehtmlref .= '</a>'; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='</div>'; + $morehtmlref .= '</div>'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -2017,7 +2017,7 @@ if ($action == 'create') print '<table class="border tableforfield" width="100%">'; // Link for thirdparty discounts - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -2025,7 +2025,7 @@ if ($action == 'create') $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } - print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>'; + print '<tr><td class="titlefield">'.$langs->trans('Discounts').'</td><td>'; $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); @@ -2034,7 +2034,7 @@ if ($action == 'create') $thirdparty = $soc; $discount_type = 0; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '</td></tr>'; @@ -2046,15 +2046,15 @@ if ($action == 'create') print $langs->trans('Date'); print '</td>'; if ($action != 'editdate' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editdate&id=' . $object->id . '">' . img_edit($langs->trans('SetDate'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate&id='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>'; print '</tr></table>'; print '</td><td>'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdate' && $usercancreate) { - print '<form name="editdate" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post">'; - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; + print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">'; print '<input type="hidden" name="action" value="setdate">'; print $form->selectDate($object->date, 're', '', '', 0, "editdate"); - print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">'; + print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '</form>'; } else { if ($object->date) { @@ -2072,18 +2072,18 @@ if ($action == 'create') print $langs->trans('DateEndPropal'); print '</td>'; if ($action != 'editecheance' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editecheance&id=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editecheance&id='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>'; print '</tr></table>'; print '</td><td>'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editecheance' && $usercancreate) { - print '<form name="editecheance" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post">'; - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; + print '<form name="editecheance" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">'; print '<input type="hidden" name="action" value="setecheance">'; print $form->selectDate($object->fin_validite, 'ech', '', '', '', "editecheance"); - print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">'; + print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '</form>'; } else { - if (! empty($object->fin_validite)) { + if (!empty($object->fin_validite)) { print dol_print_date($object->fin_validite, 'day'); if ($object->statut == Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); @@ -2100,13 +2100,13 @@ if ($action == 'create') print $langs->trans('PaymentConditionsShort'); print '</td>'; if ($action != 'editconditions' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetConditions'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).'</a></td>'; print '</tr></table>'; print '</td><td>'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editconditions' && $usercancreate) { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none'); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); } print '</td>'; print '</tr>'; @@ -2124,24 +2124,24 @@ if ($action == 'create') print '<tr class="fielddeliverydelay"><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('AvailabilityPeriod'); - if (! empty($conf->commande->enabled)) - print ' (' . $langs->trans('AfterOrder') . ')'; + if (!empty($conf->commande->enabled)) + print ' ('.$langs->trans('AfterOrder').')'; print '</td>'; if ($action != 'editavailability' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editavailability&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editavailability&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1).'</a></td>'; print '</tr></table>'; print '</td><td>'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editavailability' && $usercancreate) { - $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'availability_id', 1); + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { - $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'none', 1); + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'none', 1); } print '</td>'; print '</tr>'; // Shipping Method - if (! empty($conf->expedition->enabled)) { + if (!empty($conf->expedition->enabled)) { print '<tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>'; print $langs->trans('SendingMethod'); @@ -2165,13 +2165,13 @@ if ($action == 'create') print $langs->trans('Source'); print '</td>'; if ($action != 'editdemandreason' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editdemandreason&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1).'</a></td>'; print '</tr></table>'; print '</td><td>'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdemandreason' && $usercancreate) { - $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'demand_reason_id', 1); + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { - $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'none'); + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'none'); } print '</td>'; print '</tr>'; @@ -2183,18 +2183,18 @@ if ($action == 'create') print $langs->trans('PaymentMode'); print '</td>'; if ($action != 'editmode' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editmode&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMode'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).'</a></td>'; print '</tr></table>'; print '</td><td>'; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editmode' && $usercancreate) { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); } print '</td></tr>'; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print '<tr>'; @@ -2203,13 +2203,13 @@ if ($action == 'create') print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print '</td>'; if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT && $usercancreate) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencycode&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencycode&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; print '</tr></table>'; print '</td><td>'; if ($object->statut == $object::STATUS_DRAFT && $action == 'editmulticurrencycode' && $usercancreate) { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); } print '</td></tr>'; @@ -2223,16 +2223,16 @@ if ($action == 'create') print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print '</td>'; if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencyrate&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; print '</tr></table>'; print '</td><td>'; - if ($object->statut ==$object::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { - if($action == 'actualizemulticurrencyrate') { + if ($object->statut == $object::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { + if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '<div class="inline-block">         '; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>'; @@ -2250,13 +2250,13 @@ if ($action == 'create') print $langs->trans('OutstandingBill'); print '</td><td class="right">'; $arrayoutstandingbills = $soc->getOutstandingBills(); - print price($arrayoutstandingbills['opened']) . ' / '; + print price($arrayoutstandingbills['opened']).' / '; print price($soc->outstanding_limit, 0, $langs, 1, - 1, - 1, $conf->currency); print '</td>'; print '</tr>'; } - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) { // Bank Account print '<tr><td>'; @@ -2276,19 +2276,19 @@ if ($action == 'create') print '</tr>'; } - $tmparray=$object->getTotalWeightVolume(); - $totalWeight=$tmparray['weight']; - $totalVolume=$tmparray['volume']; + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; if ($totalWeight) { - print '<tr><td>' . $langs->trans("CalculatedWeight") . '</td>'; + print '<tr><td>'.$langs->trans("CalculatedWeight").'</td>'; print '<td>'; - print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); + print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print '</td></tr>'; } if ($totalVolume) { - print '<tr><td>' . $langs->trans("CalculatedVolume") . '</td>'; + print '<tr><td>'.$langs->trans("CalculatedVolume").'</td>'; print '<td>'; - print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); + print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print '</td></tr>'; } @@ -2310,13 +2310,13 @@ if ($action == 'create') } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print '</td></tr>'; } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '</table>'; @@ -2330,48 +2330,48 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print '<tr><td class="titlefieldmiddle">' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . '</td>'; - print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>'; + print '<td class="nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount VAT - print '<tr><td>' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . '</td>'; - print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>'; + print '<td class="nowrap">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount TTC - print '<tr><td>' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . '</td>'; - print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>'; + print '<td class="nowrap">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; } // Amount HT - print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>'; - print '<td class="nowrap">' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; + print '<tr><td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>'; + print '<td class="nowrap">'.price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; // Amount VAT - print '<tr><td>' . $langs->trans('AmountVAT') . '</td>'; - print '<td class="nowrap">' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; + print '<tr><td>'.$langs->trans('AmountVAT').'</td>'; + print '<td class="nowrap">'.price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { - print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>'; - print '<td class="nowrap">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; + print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>'; + print '<td class="nowrap">'.price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 { - print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>'; - print '<td class="nowrap">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; + print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>'; + print '<td class="nowrap">'.price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; } // Amount TTC - print '<tr><td>' . $langs->trans('AmountTTC') . '</td>'; - print '<td class="nowrap">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; + print '<tr><td>'.$langs->trans('AmountTTC').'</td>'; + print '<td class="nowrap">'.price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; // Statut @@ -2380,7 +2380,7 @@ if ($action == 'create') print '</table>'; // Margin Infos - if (! empty($conf->margin->enabled)) + if (!empty($conf->margin->enabled)) { $formmargin->displayMarginInfos($object); } @@ -2391,16 +2391,16 @@ if ($action == 'create') print '<div class="clearboth"></div><br>'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } /* @@ -2410,24 +2410,24 @@ if ($action == 'create') // Show object lines $result = $object->getLinesArray(); - print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#addline' : '#line_' . GETPOST('lineid')) . '" method="POST"> - <input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '"> - <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '"> + print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid')).'" method="POST"> + <input type="hidden" name="token" value="' . $_SESSION ['newtoken'].'"> + <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'"> <input type="hidden" name="mode" value=""> - <input type="hidden" name="id" value="' . $object->id . '"> + <input type="hidden" name="id" value="' . $object->id.'"> '; - if (! empty($conf->use_javascript_ajax) && $object->statut == Propal::STATUS_DRAFT) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->statut == Propal::STATUS_DRAFT) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '<div class="div-table-responsive-no-min">'; - if (! empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) + if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { print '<table id="tablelines" class="noborder noshadow" width="100%">'; } - if (! empty($object->lines)) + if (!empty($object->lines)) { $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); } @@ -2445,7 +2445,7 @@ if ($action == 'create') } } - if (! empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) + if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { print '</table>'; } @@ -2475,10 +2475,10 @@ if ($action == 'create') { if ($usercanvalidate) { - print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=validate">' . $langs->trans('Validate') . '</a>'; + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=validate">'.$langs->trans('Validate').'</a>'; } else - print '<a class="butActionRefused classfortooltip" href="#">' . $langs->trans('Validate') . '</a>'; + print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('Validate').'</a>'; } // 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. @@ -2487,45 +2487,45 @@ if ($action == 'create') }*/ // Edit if ($object->statut == Propal::STATUS_VALIDATED && $usercancreate) { - print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=modif">' . $langs->trans('Modify') . '</a>'; + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=modif">'.$langs->trans('Modify').'</a>'; } // ReOpen if (($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) && $usercanclose) { - print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=reopen' . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#reopen') . '"'; - print '>' . $langs->trans('ReOpen') . '</a>'; + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#reopen').'"'; + print '>'.$langs->trans('ReOpen').'</a>'; } // Send if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED || !empty($conf->global->PROPOSAL_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { - print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'; + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'; } else - print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">' . $langs->trans('SendMail') . '</a>'; + print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('SendMail').'</a>'; } // Create a sale order - if (! empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) { + if (!empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreateorder) { - print '<a class="butAction" href="' . DOL_URL_ROOT . '/commande/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans("AddOrder") . '</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a>'; } } // Create a purchase order - if (! empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) + if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) { - if (! empty($conf->fournisseur->enabled) && $object->statut == Propal::STATUS_SIGNED) { + if (!empty($conf->fournisseur->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreatepurchaseorder) { - print '<a class="butAction" href="' . DOL_URL_ROOT . '/fourn/commande/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans("AddPurchaseOrder") . '</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddPurchaseOrder").'</a>'; } } } // Create an intervention - if (! empty($conf->service->enabled) && ! empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) { + if (!empty($conf->service->enabled) && !empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreateintervention) { $langs->load("interventions"); - print '<a class="butAction" href="' . DOL_URL_ROOT . '/fichinter/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans("AddIntervention") . '</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddIntervention").'</a>'; } } @@ -2534,16 +2534,16 @@ if ($action == 'create') $langs->load("contracts"); if ($usercancreatecontract) { - print '<a class="butAction" href="' . DOL_URL_ROOT . '/contrat/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans('AddContract') . '</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans('AddContract').'</a>'; } } // Create an invoice and classify billed if ($object->statut == Propal::STATUS_SIGNED) { - if (! empty($conf->facture->enabled) && $usercancreateinvoice) + if (!empty($conf->facture->enabled) && $usercancreateinvoice) { - print '<a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans("AddBill") . '</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddBill").'</a>'; } $arrayofinvoiceforpropal = $object->getInvoiceArrayList(); @@ -2551,30 +2551,30 @@ if ($action == 'create') { if ($usercanclose) { - print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=classifybilled&socid=' . $object->socid . '">' . $langs->trans("ClassifyBilled") . '</a>'; + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled&socid='.$object->socid.'">'.$langs->trans("ClassifyBilled").'</a>'; } else { - print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">' . $langs->trans("ClassifyBilled") . '</a>'; + print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("ClassifyBilled").'</a>'; } } } // Set accepted/refused if ($object->statut == Propal::STATUS_VALIDATED && $usercanclose) { - print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=statut' . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close') . '"'; - print '>' . $langs->trans('SetAcceptedRefused') . '</a>'; + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=statut'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close').'"'; + print '>'.$langs->trans('SetAcceptedRefused').'</a>'; } // Clone if ($usercancreate) { - print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&socid=' . $object->socid . '&action=clone&object=' . $object->element . '">' . $langs->trans("ToClone") . '</a>'; + print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object='.$object->element.'">'.$langs->trans("ToClone").'</a>'; } // Delete if ($usercandelete) { - print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=delete"'; - print '>' . $langs->trans('Delete') . '</a>'; + print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete"'; + print '>'.$langs->trans('Delete').'</a>'; } } } @@ -2593,8 +2593,8 @@ if ($action == 'create') * Documents generes */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $filedir = $conf->propal->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; @@ -2604,14 +2604,14 @@ if ($action == 'create') $linktoelem = $form->showLinkToObjectBlock($object, null, array('propal')); $compatibleImportElementsList = false; - if($user->rights->propal->creer && $object->statut == Propal::STATUS_DRAFT) + if ($user->rights->propal->creer && $object->statut == Propal::STATUS_DRAFT) { - $compatibleImportElementsList = array('commande','propal'); // import from linked elements + $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); // Show online signature link - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok + $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok if ($object->statut != Propal::STATUS_DRAFT && $useonlinesignature) { @@ -2621,7 +2621,7 @@ if ($action == 'create') } // Show direct download link - if ($object->statut != Propal::STATUS_DRAFT && ! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) + if ($object->statut != Propal::STATUS_DRAFT && !empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) { print '<br><!-- Link to download main doc -->'."\n"; print showDirectDownloadLink($object).'<br>'; @@ -2630,7 +2630,7 @@ if ($action == 'create') print '</div><div class="fichehalfright"><div class="ficheaddleft">'; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'propal', $socid, 1); @@ -2638,8 +2638,8 @@ if ($action == 'create') } // Presend form - $modelmail='propal_send'; - $defaulttopic='SendPropalRef'; + $modelmail = 'propal_send'; + $defaulttopic = 'SendPropalRef'; $diroutput = $conf->propal->multidir_output[$object->entity]; $trackid = 'pro'.$object->id; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index bccc742aa8e..4a38ff4096a 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -47,57 +47,57 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories')); -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'proposallist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'proposallist'; -$search_user=GETPOST('search_user', 'int'); -$search_sale=GETPOST('search_sale', 'int'); -$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref', 'alpha'):GETPOST('search_ref', 'alpha'); -$search_refcustomer=GETPOST('search_refcustomer', 'alpha'); +$search_user = GETPOST('search_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); +$search_refcustomer = GETPOST('search_refcustomer', 'alpha'); -$search_refproject=GETPOST('search_refproject', 'alpha'); -$search_project=GETPOST('search_project', 'alpha'); +$search_refproject = GETPOST('search_refproject', 'alpha'); +$search_project = GETPOST('search_project', 'alpha'); -$search_societe=GETPOST('search_societe', 'alpha'); -$search_montant_ht=GETPOST('search_montant_ht', 'alpha'); -$search_montant_vat=GETPOST('search_montant_vat', 'alpha'); -$search_montant_ttc=GETPOST('search_montant_ttc', 'alpha'); -$search_login=GETPOST('search_login', 'alpha'); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_day=GETPOST("search_day", "int"); -$search_month=GETPOST("search_month", "int"); -$search_year=GETPOST("search_year", "int"); -$search_dayfin=GETPOST("search_dayfin", "int"); -$search_month_end=GETPOST("search_month_end", "int"); -$search_yearfin=GETPOST("search_yearfin", "int"); -$search_daydelivery=GETPOST("search_daydelivery", "int"); -$search_monthdelivery=GETPOST("search_monthdelivery", "int"); -$search_yeardelivery=GETPOST("search_yeardelivery", "int"); -$search_availability=GETPOST('search_availability', 'int'); -$search_categ_cus=trim(GETPOST("search_categ_cus", 'int')); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); +$search_societe = GETPOST('search_societe', 'alpha'); +$search_montant_ht = GETPOST('search_montant_ht', 'alpha'); +$search_montant_vat = GETPOST('search_montant_vat', 'alpha'); +$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); +$search_login = GETPOST('search_login', 'alpha'); +$search_product_category = GETPOST('search_product_category', 'int'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_day = GETPOST("search_day", "int"); +$search_month = GETPOST("search_month", "int"); +$search_year = GETPOST("search_year", "int"); +$search_dayfin = GETPOST("search_dayfin", "int"); +$search_month_end = GETPOST("search_month_end", "int"); +$search_yearfin = GETPOST("search_yearfin", "int"); +$search_daydelivery = GETPOST("search_daydelivery", "int"); +$search_monthdelivery = GETPOST("search_monthdelivery", "int"); +$search_yeardelivery = GETPOST("search_yeardelivery", "int"); +$search_availability = GETPOST('search_availability', 'int'); +$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); -$viewstatut=GETPOST('viewstatut', 'alpha'); +$viewstatut = GETPOST('viewstatut', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); -$object_statut=GETPOST('search_statut', 'alpha'); +$object_statut = GETPOST('search_statut', 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -105,23 +105,23 @@ if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='p.ref'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'p.ref'; +if (!$sortorder) $sortorder = 'DESC'; // Security check -$module='propal'; -$dbtable=''; -$objectid=''; -if (! empty($user->socid)) $socid=$user->socid; -if (! empty($socid)) +$module = 'propal'; +$dbtable = ''; +$objectid = ''; +if (!empty($user->socid)) $socid = $user->socid; +if (!empty($socid)) { - $objectid=$socid; - $module='societe'; - $dbtable='&societe'; + $objectid = $socid; + $module = 'societe'; + $dbtable = '&societe'; } $result = restrictedArea($user, $module, $objectid, $dbtable); -$diroutputmassaction=$conf->propal->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->propal->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Propal($db); @@ -131,7 +131,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -142,15 +142,15 @@ $fieldstosearchall = array( 's.name_alias'=>"AliasNameShort", 'p.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["p.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'p.ref'=>array('label'=>"Ref", 'checked'=>1), 'p.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1), - 'pr.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled)?0:1)), - 'pr.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)), + 'pr.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 'pr.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 's.town'=>array('label'=>"Town", 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'checked'=>1), @@ -176,10 +176,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } @@ -188,11 +188,11 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -200,47 +200,47 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on 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_categ=''; - $search_user=''; - $search_sale=''; - $search_ref=''; - $search_refcustomer=''; - $search_refproject=''; - $search_project=''; - $search_societe=''; - $search_montant_ht=''; - $search_montant_vat=''; - $search_montant_ttc=''; - $search_login=''; - $search_product_category=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_year=''; - $search_month=''; - $search_day=''; - $search_yearfin=''; - $search_month_end=''; - $search_dayfin=''; - $search_yeardelivery=''; - $search_monthdelivery=''; - $search_daydelivery=''; - $search_availability=''; - $viewstatut=''; - $object_statut=''; - $toselect=''; - $search_array_options=array(); - $search_categ_cus=0; + $search_categ = ''; + $search_user = ''; + $search_sale = ''; + $search_ref = ''; + $search_refcustomer = ''; + $search_refproject = ''; + $search_project = ''; + $search_societe = ''; + $search_montant_ht = ''; + $search_montant_vat = ''; + $search_montant_ttc = ''; + $search_login = ''; + $search_product_category = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_year = ''; + $search_month = ''; + $search_day = ''; + $search_yearfin = ''; + $search_month_end = ''; + $search_dayfin = ''; + $search_yeardelivery = ''; + $search_monthdelivery = ''; + $search_daydelivery = ''; + $search_availability = ''; + $viewstatut = ''; + $object_statut = ''; + $toselect = ''; + $search_array_options = array(); + $search_categ_cus = 0; } -if ($object_statut != '') $viewstatut=$object_statut; +if ($object_statut != '') $viewstatut = $object_statut; if (empty($reshook)) { - $objectclass='Propal'; - $objectlabel='Proposals'; + $objectclass = 'Propal'; + $objectlabel = 'Proposals'; $permissiontoread = $user->rights->propal->lire; $permissiontodelete = $user->rights->propal->supprimer; $permissiontoclose = $user->rights->propal->cloturer; @@ -254,68 +254,68 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $formpropal = new FormPropal($db); -$companystatic=new Societe($db); -$projectstatic=new Project($db); -$formcompany=new FormCompany($db); +$companystatic = new Societe($db); +$projectstatic = new Project($db); +$formcompany = new FormCompany($db); -$help_url='EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'; +$help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'; //llxHeader('',$langs->trans('Proposal'),$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; -$sql.= " typent.code as typent_code,"; -$sql.= " ava.rowid as availability,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; -$sql.= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,'; -$sql.= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; -$sql.= ' u.login'; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; +$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql .= " typent.code as typent_code,"; +$sql .= " ava.rowid as availability,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; +$sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,'; +$sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; +$sql .= ' u.login'; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; -$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)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ -$sql.= ', '.MAIN_DB_PREFIX.'propal as p'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; -if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; +$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)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +$sql .= ', '.MAIN_DB_PREFIX.'propal as p'; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; +if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as c"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as c"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE p.fk_soc = s.rowid'; -$sql.= ' AND p.entity IN ('.getEntity('propal').')'; -if (! $user->rights->societe->client->voir && ! $socid) //restriction +$sql .= ' WHERE p.fk_soc = s.rowid'; +$sql .= ' AND p.entity IN ('.getEntity('propal').')'; +if (!$user->rights->societe->client->voir && !$socid) //restriction { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')'; if ($search_ref) $sql .= natural_search('p.ref', $search_ref); @@ -326,39 +326,39 @@ if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($sea if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_login) $sql .= natural_search("u.login", $search_login); -if ($search_montant_ht != '') $sql.= natural_search("p.total_ht", $search_montant_ht, 1); -if ($search_montant_vat != '') $sql.= natural_search("p.tva", $search_montant_vat, 1); -if ($search_montant_ttc != '') $sql.= natural_search("p.total", $search_montant_ttc, 1); +if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1); +if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1); +if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1); if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } -if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); -if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; +if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category); -if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$db->escape($search_product_category); +if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; if ($viewstatut != '' && $viewstatut != '-1') { - $sql.= ' AND p.fk_statut IN ('.$db->escape($viewstatut).')'; + $sql .= ' AND p.fk_statut IN ('.$db->escape($viewstatut).')'; } -$sql.= dolSqlDateFilter("p.datep", $search_day, $search_month, $search_year); -$sql.= dolSqlDateFilter("p.fin_validite", $search_dayfin, $search_month_end, $search_yearfin); -$sql.= dolSqlDateFilter("p.date_livraison", $search_daydelivery, $search_monthdelivery, $search_yeardelivery); -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale); +$sql .= dolSqlDateFilter("p.datep", $search_day, $search_month, $search_year); +$sql .= dolSqlDateFilter("p.fin_validite", $search_dayfin, $search_month_end, $search_yearfin); +$sql .= dolSqlDateFilter("p.date_livraison", $search_daydelivery, $search_monthdelivery, $search_yeardelivery); +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale); if ($search_user > 0) { - $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$db->escape($search_user); + $sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$db->escape($search_user); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); -$sql.=', p.ref DESC'; +$sql .= $db->order($sortfield, $sortorder); +$sql .= ', p.ref DESC'; // Count total nb of records $nbtotalofrecords = ''; @@ -374,20 +374,20 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { - $objectstatic=new Propal($db); - $userstatic=new User($db); + $objectstatic = new Propal($db); + $userstatic = new User($db); if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); - $title = $langs->trans('ListOfProposals') . ' - '.$soc->name; + $title = $langs->trans('ListOfProposals').' - '.$soc->name; if (empty($search_societe)) $search_societe = $soc->name; } else @@ -397,9 +397,9 @@ if ($resql) $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); @@ -411,46 +411,46 @@ if ($resql) llxHeader('', $langs->trans('Proposal'), $help_url); - $param='&viewstatut='.urlencode($viewstatut); - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.='&sall='.urlencode($sall); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_refcustomer) $param.='&search_refcustomer='.urlencode($search_refcustomer); - if ($search_refproject) $param.='&search_refproject='.urlencode($search_refproject); - if ($search_societe) $param.='&search_societe='.urlencode($search_societe); - if ($search_user > 0) $param.='&search_user='.urlencode($search_user); - if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); - if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht); - if ($search_login) $param.='&search_login='.urlencode($search_login); - if ($search_town) $param.='&search_town='.urlencode($search_town); - if ($search_zip) $param.='&search_zip='.urlencode($search_zip); - if ($socid > 0) $param.='&socid='.urlencode($socid); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); - if ($search_product_category != '') $param.='&search_product_category='.$search_product_category; + $param = '&viewstatut='.urlencode($viewstatut); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= '&sall='.urlencode($sall); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_refcustomer) $param .= '&search_refcustomer='.urlencode($search_refcustomer); + if ($search_refproject) $param .= '&search_refproject='.urlencode($search_refproject); + if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); + if ($search_montant_ht) $param .= '&search_montant_ht='.urlencode($search_montant_ht); + if ($search_login) $param .= '&search_login='.urlencode($search_login); + if ($search_town) $param .= '&search_town='.urlencode($search_town); + if ($search_zip) $param .= '&search_zip='.urlencode($search_zip); + if ($socid > 0) $param .= '&socid='.urlencode($socid); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); + if ($search_product_category != '') $param .= '&search_product_category='.$search_product_category; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->propal->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if ($user->rights->propal->cloturer) $arrayofmassactions['closed']=$langs->trans("Close"); - if (in_array($massaction, array('presend','predelete','closed'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->propal->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + if ($user->rights->propal->cloturer) $arrayofmassactions['closed'] = $langs->trans("Close"); + if (in_array($massaction, array('presend', 'predelete', 'closed'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->propal->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/propal/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/propal/card.php?action=create'); } // Fields title search @@ -466,213 +466,213 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'commercial', 0, $newcardbutton, '', $limit); - $topicmail="SendPropalRef"; - $modelmail="proposal_send"; - $objecttmp=new Propal($db); - $trackid='pro'.$object->id; + $topicmail = "SendPropalRef"; + $modelmail = "proposal_send"; + $objecttmp = new Propal($db); + $trackid = 'pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } $i = 0; - $moreforfilter=''; + $moreforfilter = ''; // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view products if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='</div>'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '</div>'; } - if (! empty($conf->categorie->enabled)) + if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); - $moreforfilter.='</div>'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $moreforfilter .= '</div>'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } - $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) : ''); + $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) : ''); print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<tr class="liste_titre_filter">'; - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } - if (! empty($arrayfields['p.ref_client']['checked'])) + if (!empty($arrayfields['p.ref_client']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="6" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).'">'; print '</td>'; } - if (! empty($arrayfields['pr.ref']['checked'])) + if (!empty($arrayfields['pr.ref']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="6" type="text" name="search_refproject" value="'.dol_escape_htmltag($search_refproject).'">'; print '</td>'; } - if (! empty($arrayfields['pr.title']['checked'])) + if (!empty($arrayfields['pr.title']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="6" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).'">'; print '</td>'; } - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre" align="left">'; print '<input class="flat" type="text" size="10" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">'; print '</td>'; } - if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; - if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>'; + if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; + if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>'; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="liste_titre" align="center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone" align="center">'; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print ajax_combobox('search_type_thirdparty'); print '</td>'; } // Date - if (! empty($arrayfields['p.date']['checked'])) + if (!empty($arrayfields['p.date']['checked'])) { print '<td class="liste_titre nowraponall" align="center">'; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">'; print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">'; //print ' '.$langs->trans('Year').': '; $formother->select_year($search_year, 'search_year', 1, 20, 5); print '</td>'; } // Date end - if (! empty($arrayfields['p.fin_validite']['checked'])) + if (!empty($arrayfields['p.fin_validite']['checked'])) { print '<td class="liste_titre nowraponall" align="center">'; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" maxlength="2" name="search_dayfin" value="'.dol_escape_htmltag($search_dayfin).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" maxlength="2" name="search_dayfin" value="'.dol_escape_htmltag($search_dayfin).'">'; print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_month_end" value="'.dol_escape_htmltag($search_month_end).'">'; //print ' '.$langs->trans('Year').': '; $formother->select_year($search_yearfin, 'search_yearfin', 1, 20, 5); print '</td>'; } // Date delivery - if (! empty($arrayfields['p.date_livraison']['checked'])) + if (!empty($arrayfields['p.date_livraison']['checked'])) { print '<td class="liste_titre nowraponall" align="center">'; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" size="1" maxlength="2" name="search_daydelivery" value="'.dol_escape_htmltag($search_daydelivery).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" size="1" maxlength="2" name="search_daydelivery" value="'.dol_escape_htmltag($search_daydelivery).'">'; print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_monthdelivery" value="'.dol_escape_htmltag($search_monthdelivery).'">'; //print ' '.$langs->trans('Year').': '; $formother->select_year($search_yeardelivery, 'search_yeardelivery', 1, 20, 5); print '</td>'; } // Availability - if (! empty($arrayfields['ava.rowid']['checked'])) + if (!empty($arrayfields['ava.rowid']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone" align="center">'; print $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1); print ajax_combobox('search_availability'); print '</td>'; } - if (! empty($arrayfields['p.total_ht']['checked'])) + if (!empty($arrayfields['p.total_ht']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">'; print '</td>'; } - if (! empty($arrayfields['p.total_vat']['checked'])) + if (!empty($arrayfields['p.total_vat']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">'; print '</td>'; } - if (! empty($arrayfields['p.total_ttc']['checked'])) + if (!empty($arrayfields['p.total_ttc']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; print '</td>'; } - if (! empty($arrayfields['p.total_ht_invoiced']['checked'])) + if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { // Amount invoiced print '<td class="liste_titre right">'; print '</td>'; } - if (! empty($arrayfields['p.total_invoiced']['checked'])) + if (!empty($arrayfields['p.total_invoiced']['checked'])) { // Amount invoiced print '<td class="liste_titre right">'; print '</td>'; } - if (! empty($arrayfields['u.login']['checked'])) + if (!empty($arrayfields['u.login']['checked'])) { // Author print '<td class="liste_titre" align="center">'; print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">'; print '</td>'; } - if (! empty($arrayfields['sale_representative']['checked'])) + if (!empty($arrayfields['sale_representative']['checked'])) { print '<td class="liste_titre"></td>'; } @@ -680,29 +680,29 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date cloture - if (! empty($arrayfields['p.date_cloture']['checked'])) + if (!empty($arrayfields['p.date_cloture']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status - if (! empty($arrayfields['p.fk_statut']['checked'])) + if (!empty($arrayfields['p.fk_statut']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone right">'; $formpropal->selectProposalStatus($viewstatut, 1, 0, 1, 'customer', 'search_statut'); @@ -710,7 +710,7 @@ if ($resql) } // Action column print '<td class="liste_titre" align="middle">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; @@ -719,65 +719,65 @@ if ($resql) // Fields title print '<tr class="liste_titre">'; - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.ref_client']['checked'])) print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['pr.title']['checked'])) print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); - 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['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, 'align="center"', $sortfield, $sortorder); - 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, '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['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $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); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.ref_client']['checked'])) print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['pr.title']['checked'])) print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); + 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['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, 'align="center"', $sortfield, $sortorder); + 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, '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['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $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 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - 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.date_cloture']['checked'])) print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $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, 'class="right"', $sortfield, $sortorder); + 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.date_cloture']['checked'])) print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $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, 'class="right"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print '</tr>'."\n"; $now = dol_now(); - $i=0; - $totalarray=array(); - $typenArray=null; + $i = 0; + $totalarray = array(); + $typenArray = null; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $objectstatic->id=$obj->rowid; - $objectstatic->ref=$obj->ref; + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->code_client=$obj->code_client; - $companystatic->email=$obj->email; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->email = $obj->email; - $projectstatic->id=$obj->project_id; - $projectstatic->ref=$obj->project_ref; - $projectstatic->title=$obj->project_label; + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; print '<tr class="oddeven">'; - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="nowrap">'; @@ -787,14 +787,14 @@ if ($resql) print $objectstatic->getNomUrl(1, '', '', 0, 1); print '</td>'; // Warning - $warnornote=''; - if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); - if (! empty($obj->note_private)) + $warnornote = ''; + if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) $warnornote .= img_warning($langs->trans("Late")); + if (!empty($obj->note_private)) { - $warnornote.=($warnornote?' ':''); - $warnornote.= '<span class="note">'; - $warnornote.= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>'; - $warnornote.= '</span>'; + $warnornote .= ($warnornote ? ' ' : ''); + $warnornote .= '<span class="note">'; + $warnornote .= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>'; + $warnornote .= '</span>'; } if ($warnornote) { @@ -804,26 +804,26 @@ if ($resql) } // Other picto tool print '<td width="16" class="nobordernopadding right">'; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print '</td></tr></table>'; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.ref_client']['checked'])) + if (!empty($arrayfields['p.ref_client']['checked'])) { // Customer ref print '<td class="nowrap">'; print $obj->ref_client; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['pr.ref']['checked'])) + if (!empty($arrayfields['pr.ref']['checked'])) { // Project ref print '<td class="nowrap">'; @@ -831,10 +831,10 @@ if ($resql) print $projectstatic->getNomUrl(1); } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['pr.title']['checked'])) + if (!empty($arrayfields['pr.title']['checked'])) { // Project label print '<td class="nowrap">'; @@ -842,71 +842,71 @@ if ($resql) print $projectstatic->title; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Thirdparty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="tdoverflowmax200">'; print $companystatic->getNomUrl(1, 'customer'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['s.town']['checked'])) + if (!empty($arrayfields['s.town']['checked'])) { print '<td class="nocellnopadd">'; print $obj->town; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['s.zip']['checked'])) + if (!empty($arrayfields['s.zip']['checked'])) { print '<td class="nocellnopadd">'; print $obj->zip; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "<td>".$obj->state_name."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td align="center">'; - $tmparray=getCountry($obj->fk_pays, 'all'); + $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { - if (! is_array($typenArray) || empty($typenArray)) $typenArray = $formcompany->typent_array(1); + if (!is_array($typenArray) || empty($typenArray)) $typenArray = $formcompany->typent_array(1); print '<td align="center">'; print $typenArray[$obj->typent_code]; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date proposal - if (! empty($arrayfields['p.date']['checked'])) + if (!empty($arrayfields['p.date']['checked'])) { print '<td align="center">'; print dol_print_date($db->jdate($obj->dp), 'day'); print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date end validity - if (! empty($arrayfields['p.fin_validite']['checked'])) + if (!empty($arrayfields['p.fin_validite']['checked'])) { if ($obj->dfv) { @@ -917,10 +917,10 @@ if ($resql) { print '<td> </td>'; } - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date delivery - if (! empty($arrayfields['p.date_livraison']['checked'])) + if (!empty($arrayfields['p.date_livraison']['checked'])) { if ($obj->ddelivery) { @@ -1038,17 +1038,17 @@ if ($resql) } elseif ($nbofsalesrepresentative > 0) { - $userstatic=new User($db); - $j=0; - foreach($listsalesrepresentatives as $val) + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { - $userstatic->id=$val['id']; - $userstatic->lastname=$val['lastname']; - $userstatic->firstname=$val['firstname']; - $userstatic->email=$val['email']; - $userstatic->statut=$val['statut']; - $userstatic->entity=$val['entity']; - $userstatic->photo=$val['photo']; + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; //print '<div class="float">': print $userstatic->getNomUrl(-2); @@ -1064,55 +1064,55 @@ if ($resql) print ' '; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print '<td align="center" class="nowrap">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print '<td align="center" class="nowrap">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date cloture - if (! empty($arrayfields['p.date_cloture']['checked'])) + if (!empty($arrayfields['p.date_cloture']['checked'])) { print '<td align="center" class="nowrap">'; print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['p.fk_statut']['checked'])) + if (!empty($arrayfields['p.fk_statut']['checked'])) { print '<td class="nowrap right">'.$objectstatic->LibStatut($obj->fk_statut, 5).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print '<td class="nowrap" align="center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "</tr>\n"; @@ -1124,8 +1124,8 @@ if ($resql) $db->free($resql); - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -1133,16 +1133,16 @@ if ($resql) print '</form>'."\n"; - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->propal->lire; - $delallowed=$user->rights->propal->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->propal->lire; + $delallowed = $user->rights->propal->creer; print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0daf73db702..f949e118599 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -35,34 +35,34 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formorder.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmargin.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/commande/modules_commande.php'; -require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/order.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -if (! empty($conf->propal->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->propal->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; } -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } // Load translation files required by the page -$langs->loadLangs(array('orders','sendings','companies','bills','propal','deliveries','products','other')); +$langs->loadLangs(array('orders', 'sendings', 'companies', 'bills', 'propal', 'deliveries', 'products', 'other')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -if (! empty($conf->margin->enabled)) $langs->load('margins'); -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->margin->enabled)) $langs->load('margins'); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('orderid', 'int')); $ref = GETPOST('ref', 'alpha'); @@ -77,12 +77,12 @@ $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility // PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Security check -if (! empty($user->socid)) +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'commande', $id); @@ -126,24 +126,24 @@ if (empty($reshook)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; } - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { - if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } @@ -154,7 +154,7 @@ if (empty($reshook)) // Because createFromClone modifies the object, we must clone it so that we can restore it later $orig = clone $object; - $result=$object->createFromClone($user, $socid); + $result = $object->createFromClone($user, $socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -164,7 +164,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $object = $orig; - $action=''; + $action = ''; } } } @@ -215,7 +215,7 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -258,7 +258,7 @@ if (empty($reshook)) $error++; } - if (! $error) { + if (!$error) { $object->socid = $socid; $object->fetch_thirdparty(); @@ -286,14 +286,14 @@ if (empty($reshook)) $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); // Fill array 'array_options' with data from add form - if (! $error) + if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; } // If creation from another object of another module (Example: origin=propal, originid=1) - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -320,22 +320,22 @@ if (empty($reshook)) // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; $other_linked_objects = GETPOST('other_linked_objects', 'array'); - if (! empty($other_linked_objects)) { + if (!empty($other_linked_objects)) { $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); } - if (! $error) + if (!$error) { $object_id = $object->create($user); if ($object_id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); if ($result > 0) { @@ -349,13 +349,13 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); - for($i = 0; $i < $num; $i ++) + for ($i = 0; $i < $num; $i++) { - if(!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines - $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); - $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : ''); - $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); + $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : ''); + $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); // Dates // TODO mutualiser @@ -383,7 +383,7 @@ if (empty($reshook)) } $tva_tx = $lines[$i]->tva_tx; - if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, @@ -449,17 +449,17 @@ if (empty($reshook)) $action = 'create'; } } else { - if (! $error) + if (!$error) { $object_id = $object->create($user); // If some invoice's lines already known $NBLINES = 8; - for($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST['idprod' . $i]) { - $xid = 'idprod' . $i; - $xqty = 'qty' . $i; - $xremise = 'remise_percent' . $i; + for ($i = 1; $i <= $NBLINES; $i++) { + if ($_POST['idprod'.$i]) { + $xid = 'idprod'.$i; + $xqty = 'qty'.$i; + $xremise = 'remise_percent'.$i; $object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]); } } @@ -483,10 +483,10 @@ if (empty($reshook)) } // End of object creation, we show it - if ($object_id > 0 && ! $error) + if ($object_id > 0 && !$error) { $db->commit(); - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object_id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object_id); exit(); } else { $db->rollback(); @@ -498,7 +498,7 @@ if (empty($reshook)) elseif ($action == 'classifybilled' && $usercancreate) { - $ret=$object->classifyBilled($user); + $ret = $object->classifyBilled($user); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -506,7 +506,7 @@ if (empty($reshook)) } elseif ($action == 'classifyunbilled' && $usercancreate) { - $ret=$object->classifyUnBilled(); + $ret = $object->classifyUnBilled(); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -598,7 +598,7 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'alpha'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -620,7 +620,7 @@ if (empty($reshook)) // bank account elseif ($action == 'setbankaccount' && $usercancreate) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -657,23 +657,23 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $predef = ''; + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); $price_ht = GETPOST('price_ht'); $price_ht_devise = GETPOST('multicurrency_price_ht'); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } - $qty = GETPOST('qty' . $predef); + $qty = GETPOST('qty'.$predef); $remise_percent = (GETPOST('remise_percent'.$predef) != '' ? GETPOST('remise_percent'.$predef) : 0); // Extrafields @@ -683,7 +683,7 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } @@ -720,22 +720,22 @@ if (empty($reshook)) else { setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors'); - $error ++; + $error++; } } } - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { // Clean parameters - $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $price_base_type = (GETPOST('price_base_type', 'alpha') ?GETPOST('price_base_type', 'alpha') : 'HT'); // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit - if (! empty($idprod)) { + if (!empty($idprod)) { $prod = new Product($db); $prod->fetch($idprod); @@ -744,7 +744,7 @@ if (empty($reshook)) // Update if prices fields are defined $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; @@ -752,26 +752,26 @@ if (empty($reshook)) $price_base_type = $prod->price_base_type; // If price per segment - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) { $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } // If price per customer - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); + $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result >= 0) @@ -782,9 +782,9 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = $prodcustprice->lines[0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; } } else @@ -793,7 +793,7 @@ if (empty($reshook)) } } // If price per quantity - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity { @@ -801,7 +801,7 @@ if (empty($reshook)) $pqp = GETPOST('pbq', 'int'); // Search price into product_price_by_qty from $prod->id - foreach($prod->prices_by_qty_list[0] as $priceforthequantityarray) + foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -819,14 +819,14 @@ if (empty($reshook)) } } // If price per quantity and customer - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($prod->prices_by_qty[$object->thirdparty->price_level]) // yes, this product has some prices per quantity { // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp']. $pqp = GETPOST('pbq', 'int'); // Search price into product_price_by_qty from $prod->id - foreach($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) + foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -848,7 +848,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? - if (! empty($price_ht)) { + if (!empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } @@ -865,55 +865,55 @@ if (empty($reshook)) $desc = ''; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; } else { $desc = $prod->description; } - if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc= $product_desc; + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) { $tmptxt = '('; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'alpha')) $newlang = GETPOST('lang_id', 'alpha'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - if (! empty($prod->customcode)) - $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) + if (!empty($prod->customcode)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $outputlangs, 0); + if (!empty($prod->country_code)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $outputlangs, 0); } else { - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) + if (!empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + if (!empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $langs, 0); } $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); @@ -929,13 +929,13 @@ if (empty($reshook)) $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $desc = $product_desc; $type = GETPOST('type'); - $fk_unit=GETPOST('units', 'alpha'); + $fk_unit = GETPOST('units', 'alpha'); $pu_ht_devise = price2num($price_ht_devise, 'MU'); } // Margin - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we muste keep this value + $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); + $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we muste keep this value // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); @@ -947,7 +947,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); setEventMessages($mesg, null, 'errors'); } else { @@ -961,9 +961,9 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = GETPOST('lang_id', 'alpha'); - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) + if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -1016,13 +1016,13 @@ if (empty($reshook)) elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) { // Clean parameters - $date_start=''; - $date_end=''; - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $description=dol_htmlcleanlastbr(GETPOST('product_desc', 'none')); - $pu_ht=GETPOST('price_ht'); - $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + $date_start = ''; + $date_end = ''; + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'none')); + $pu_ht = GETPOST('price_ht'); + $vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0); $pu_ht_devise = GETPOST('multicurrency_subprice'); // Define info_bits @@ -1037,7 +1037,7 @@ if (empty($reshook)) // Add buying price $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value + $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value // Extrafields Lines $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -1045,29 +1045,29 @@ if (empty($reshook)) // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } // Define special_code for special lines - $special_code=GETPOST('special_code'); - if (! GETPOST('qty')) $special_code=3; + $special_code = GETPOST('special_code'); + if (!GETPOST('qty')) $special_code = 3; // Check minimum price $productid = GETPOST('productid', 'int'); - if (! empty($productid)) { + if (!empty($productid)) { $product = new Product($db); $product->fetch($productid); $type = $product->type; $price_min = $product->price_min; - if ((! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && ! empty($object->thirdparty->price_level)) + if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) $price_min = $product->multiprices_min[$object->thirdparty->price_level]; $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } @@ -1082,7 +1082,7 @@ if (empty($reshook)) } } - if (! $error) { + if (!$error) { if (empty($user->rights->margins->creer)) { foreach ($object->lines as &$line) @@ -1106,7 +1106,7 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -1146,7 +1146,7 @@ if (empty($reshook)) } } } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } @@ -1154,28 +1154,28 @@ if (empty($reshook)) { $idwarehouse = GETPOST('idwarehouse'); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } - if (! $error) { + if (!$error) { $result = $object->valid($user, $idwarehouse); if ($result >= 0) { @@ -1186,11 +1186,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1207,28 +1207,28 @@ if (empty($reshook)) elseif ($action == 'confirm_modif' && $usercancreate) { $idwarehouse = GETPOST('idwarehouse'); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } - if (! $error) { + if (!$error) { $result = $object->setDraft($user, $idwarehouse); if ($result >= 0) { @@ -1239,11 +1239,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1263,28 +1263,28 @@ if (empty($reshook)) { $idwarehouse = GETPOST('idwarehouse'); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } - if (! $error) { + if (!$error) { $result = $object->cancel($idwarehouse); if ($result < 0) { @@ -1301,7 +1301,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('ORDER_MODIFY'); @@ -1320,12 +1320,12 @@ if (empty($reshook)) $object->fetch($id); $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit(); } // add lines from objectlinked - if($action == 'import_lines_from_object' + if ($action == 'import_lines_from_object' && $usercancreate && $object->statut == Commande::STATUS_DRAFT ) @@ -1334,14 +1334,14 @@ if (empty($reshook)) $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); - if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) { - if($fromElement == 'commande') + if ($fromElement == 'commande') { dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'OrderLine'; } - elseif($fromElement == 'propal') + elseif ($fromElement == 'propal') { dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'PropaleLigne'; @@ -1349,11 +1349,11 @@ if (empty($reshook)) $nextRang = count($object->lines) + 1; $importCount = 0; $error = 0; - foreach($importLines as $lineId) + foreach ($importLines as $lineId) { $lineId = intval($lineId); $originLine = new $lineClassName($db); - if(intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) { $originLine->fetch_optionals($lineId); $desc = $originLine->desc; @@ -1369,15 +1369,15 @@ if (empty($reshook)) $ventil = 0; $info_bits = $originLine->info_bits; $fk_remise_except = $originLine->fk_remise_except; - $price_base_type='HT'; - $pu_ttc=0; + $price_base_type = 'HT'; + $pu_ttc = 0; $type = $originLine->product_type; - $rang=$nextRang++; + $rang = $nextRang++; $special_code = $originLine->special_code; $origin = $originLine->element; $origin_id = $originLine->id; - $fk_parent_line=0; - $fk_fournprice=$originLine->fk_fournprice; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; $pa_ht = $originLine->pa_ht; $label = $originLine->label; $array_options = $originLine->array_options; @@ -1388,18 +1388,18 @@ if (empty($reshook)) $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $date_start, $date_end, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise); - if($res > 0){ + if ($res > 0) { $importCount++; - }else{ + } else { $error++; } } - else{ + else { $error++; } } - if($error) + if ($error) { setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); } @@ -1415,14 +1415,14 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails - $trigger_name='ORDER_SENTBYMAIL'; - $paramname='id'; - $autocopy='MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add - $trackid='ord'.$object->id; + $trigger_name = 'ORDER_SENTBYMAIL'; + $paramname = 'id'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add + $trackid = 'ord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) + if (!$error && !empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { if ($action == 'addcontact') { @@ -1432,7 +1432,7 @@ if (empty($reshook)) } if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit(); } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { @@ -1460,7 +1460,7 @@ if (empty($reshook)) $result = $object->delete_contact($lineid); if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit(); } else { dol_print_error($db); @@ -1480,7 +1480,7 @@ $form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $formmargin = new FormMargin($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } // Mode creation if ($action == 'create' && $usercancreate) @@ -1495,7 +1495,7 @@ if ($action == 'create' && $usercancreate) $currency_code = $conf->currency; - if (! empty($origin) && ! empty($originid)) { + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { @@ -1517,7 +1517,7 @@ if ($action == 'create' && $usercancreate) } if (!$dateorder) { // Do not set 0 here (0 for a date is 1970) - $dateorder = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE_ODER)?-1:''):$dateorder); + $dateorder = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE_ODER) ?-1 : '') : $dateorder); } } else { // For compatibility @@ -1532,7 +1532,7 @@ if ($action == 'create' && $usercancreate) $element = $subelement = 'contrat'; } - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($db); @@ -1545,22 +1545,22 @@ if ($action == 'create' && $usercancreate) $objectsrc->fetch_optionals($originid); $object->array_options = $objectsrc->array_options; - $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); - $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); + $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); + $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); $soc = $objectsrc->thirdparty; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); // TODO maybe add default value option - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); - $shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0)); - $warehouse_id = (! empty($objectsrc->warehouse_id)?$objectsrc->warehouse_id:(! empty($soc->warehouse_id)?$soc->warehouse_id:0)); - $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER)?-1:''; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); // TODO maybe add default value option + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0)); + $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0)); + $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0)); + $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0)); + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : ''; - $datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); + $datedelivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); if (!empty($conf->multicurrency->enabled)) { @@ -1568,11 +1568,11 @@ if ($action == 'create' && $usercancreate) if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; } - $note_private = $object->getDefaultCreateValueFor('note_private', (! empty($objectsrc->note_private) ? $objectsrc->note_private : null)); - $note_public = $object->getDefaultCreateValueFor('note_public', (! empty($objectsrc->note_public) ? $objectsrc->note_public : null)); + $note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null)); + $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null)); // Object source contacts list - $srccontactslist = $objectsrc->liste_contact(- 1, 'external', 1); + $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); } } else @@ -1586,7 +1586,7 @@ if ($action == 'create' && $usercancreate) $demand_reason_id = $soc->demand_reason_id; $remise_percent = $soc->remise_percent; $remise_absolue = 0; - $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER)?-1:''; + $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : ''; if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; @@ -1620,11 +1620,11 @@ if ($action == 'create' && $usercancreate) // Thirdparty print '<tr>'; - print '<td class="fieldrequired">' . $langs->trans('Customer') . '</td>'; + print '<td class="fieldrequired">'.$langs->trans('Customer').'</td>'; if ($socid > 0) { print '<td>'; print $soc->getNomUrl(1); - print '<input type="hidden" name="socid" value="' . $soc->id . '">'; + print '<input type="hidden" name="socid" value="'.$soc->id.'">'; print '</td>'; } else { print '<td>'; @@ -1645,96 +1645,96 @@ if ($action == 'create' && $usercancreate) print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>'; print '</td>'; } - print '</tr>' . "\n"; + print '</tr>'."\n"; // Contact of order if ($socid > 0) { // Contacts (ask contact only if thirdparty already defined). - print "<tr><td>" . $langs->trans("DefaultContact") . '</td><td>'; + print "<tr><td>".$langs->trans("DefaultContact").'</td><td>'; $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist, '', 1); print '</td></tr>'; // Ligne info remises tiers - print '<tr><td>' . $langs->trans('Discounts') . '</td><td>'; + print '<tr><td>'.$langs->trans('Discounts').'</td><td>'; $absolute_discount = $soc->getAvailableDiscounts(); $thirdparty = $soc; $discount_type = 0; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '</td></tr>'; } // Date - print '<tr><td class="fieldrequired">' . $langs->trans('Date') . '</td><td>'; - print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date + print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>'; + print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date print '</td></tr>'; // Delivery date planed print "<tr><td>".$langs->trans("DateDeliveryPlanned").'</td><td>'; if (empty($datedelivery)) { - if (! empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) $datedelivery = time() + ((7*$conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); - else $datedelivery=empty($conf->global->MAIN_AUTOFILL_DATE_DELIVERY)?-1:''; + if (!empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) $datedelivery = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); + else $datedelivery = empty($conf->global->MAIN_AUTOFILL_DATE_DELIVERY) ?-1 : ''; } print $form->selectDate($datedelivery, 'liv_', '', '', '', "crea_commande", 1, 1); print "</td></tr>"; // terms of the settlement - print '<tr><td class="nowrap">' . $langs->trans('PaymentConditionsShort') . '</td><td>'; + print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>'; $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1); print '</td></tr>'; // Mode de reglement - print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td>'; + print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>'; $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id'); print '</td></tr>'; // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled)) { - print '<tr><td>' . $langs->trans('BankAccount') . '</td><td>'; + print '<tr><td>'.$langs->trans('BankAccount').'</td><td>'; $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print '</td></tr>'; } // Delivery delay - print '<tr class="fielddeliverydelay"><td>' . $langs->trans('AvailabilityPeriod') . '</td><td>'; + print '<tr class="fielddeliverydelay"><td>'.$langs->trans('AvailabilityPeriod').'</td><td>'; $form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1); print '</td></tr>'; // Shipping Method - if (! empty($conf->expedition->enabled)) { - print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>'; + if (!empty($conf->expedition->enabled)) { + print '<tr><td>'.$langs->trans('SendingMethod').'</td><td>'; print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); print '</td></tr>'; } // Warehouse - if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct=new FormProduct($db); - print '<tr><td>' . $langs->trans('Warehouse') . '</td><td>'; + $formproduct = new FormProduct($db); + print '<tr><td>'.$langs->trans('Warehouse').'</td><td>'; print $formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1); print '</td></tr>'; } // What trigger creation - print '<tr><td>' . $langs->trans('Channel') . '</td><td>'; + print '<tr><td>'.$langs->trans('Channel').'</td><td>'; $form->selectInputReason($demand_reason_id, 'demand_reason_id', '', 1); print '</td></tr>'; // TODO How record was recorded OrderMode (llx_c_input_method) // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); print '<tr>'; - print '<td>' . $langs->trans("Project") . '</td><td>'; + print '<td>'.$langs->trans("Project").'</td><td>'; $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0); - print '   <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="valignmiddle text-plus-circle">' . $langs->trans("AddProject") . '</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; + print '   <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; print '</td>'; print '</tr>'; } @@ -1762,7 +1762,7 @@ if ($action == 'create' && $usercancreate) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; if (empty($reshook)) { - if (! empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER)) { + if (!empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER)) { // copy from thirdparty $tpExtrafields = new Extrafields($db); $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element); @@ -1775,15 +1775,15 @@ if ($action == 'create' && $usercancreate) } // Template to use by default - print '<tr><td>' . $langs->trans('DefaultModel') . '</td>'; + print '<tr><td>'.$langs->trans('DefaultModel').'</td>'; print '<td>'; - include_once DOL_DOCUMENT_ROOT . '/core/modules/commande/modules_commande.php'; + include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; $liste = ModelePDFCommandes::liste_modeles($db); print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF); print "</td></tr>"; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print '<tr>'; print '<td>'.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).'</td>'; @@ -1794,7 +1794,7 @@ if ($action == 'create' && $usercancreate) // Note public print '<tr>'; - print '<td class="tdtop">' . $langs->trans('NotePublic') . '</td>'; + print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>'; print '<td>'; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); @@ -1805,7 +1805,7 @@ if ($action == 'create' && $usercancreate) // Note private if (empty($user->socid)) { print '<tr>'; - print '<td class="tdtop">' . $langs->trans('NotePrivate') . '</td>'; + print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>'; print '<td>'; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); @@ -1814,7 +1814,7 @@ if ($action == 'create' && $usercancreate) print '</td></tr>'; } - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { // TODO for compatibility if ($origin == 'contrat') { @@ -1824,13 +1824,13 @@ if ($action == 'create' && $usercancreate) $objectsrc->update_price(1); } - print "\n<!-- " . $classname . " info -->"; + print "\n<!-- ".$classname." info -->"; print "\n"; - print '<input type="hidden" name="amount" value="' . $objectsrc->total_ht . '">' . "\n"; - print '<input type="hidden" name="total" value="' . $objectsrc->total_ttc . '">' . "\n"; - print '<input type="hidden" name="tva" value="' . $objectsrc->total_tva . '">' . "\n"; - print '<input type="hidden" name="origin" value="' . $objectsrc->element . '">'; - print '<input type="hidden" name="originid" value="' . $objectsrc->id . '">'; + print '<input type="hidden" name="amount" value="'.$objectsrc->total_ht.'">'."\n"; + print '<input type="hidden" name="total" value="'.$objectsrc->total_ttc.'">'."\n"; + print '<input type="hidden" name="tva" value="'.$objectsrc->total_tva.'">'."\n"; + print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">'; + print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">'; switch ($classname) { case 'Propal': @@ -1849,28 +1849,28 @@ if ($action == 'create' && $usercancreate) $newclassname = $classname; } - print '<tr><td>' . $langs->trans($newclassname) . '</td><td>' . $objectsrc->getNomUrl(1) . '</td></tr>'; + print '<tr><td>'.$langs->trans($newclassname).'</td><td>'.$objectsrc->getNomUrl(1).'</td></tr>'; // Amount - print '<tr><td>' . $langs->trans('AmountHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>'; - print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>"; + print '<tr><td>'.$langs->trans('AmountHT').'</td><td>'.price($objectsrc->total_ht).'</td></tr>'; + print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($objectsrc->total_tva)."</td></tr>"; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE { - print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1) . "</td></tr>"; + print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax1)."</td></tr>"; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF { - print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2) . "</td></tr>"; + print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax2)."</td></tr>"; } - print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td>' . price($objectsrc->total_ttc) . "</td></tr>"; + print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($objectsrc->total_ttc)."</td></tr>"; if (!empty($conf->multicurrency->enabled)) { - print '<tr><td>' . $langs->trans('MulticurrencyAmountHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>'; - print '<tr><td>' . $langs->trans('MulticurrencyAmountVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>"; - print '<tr><td>' . $langs->trans('MulticurrencyAmountTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>"; + print '<tr><td>'.$langs->trans('MulticurrencyAmountHT').'</td><td>'.price($objectsrc->multicurrency_total_ht).'</td></tr>'; + print '<tr><td>'.$langs->trans('MulticurrencyAmountVAT').'</td><td>'.price($objectsrc->multicurrency_total_tva)."</td></tr>"; + print '<tr><td>'.$langs->trans('MulticurrencyAmountTTC').'</td><td>'.price($objectsrc->multicurrency_total_ttc)."</td></tr>"; } } @@ -1880,13 +1880,13 @@ if ($action == 'create' && $usercancreate) // Button "Create Draft" print '<div class="center">'; - print '<input type="submit" class="button" name="bouton" value="' . $langs->trans('CreateDraft') . '">'; + print '<input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'">'; print '     '; - print '<input type="button" class="button" name="cancel" value="' . $langs->trans("Cancel") . '" onclick="javascript:history.go(-1)">'; + print '<input type="button" class="button" name="cancel" value="'.$langs->trans("Cancel").'" onclick="javascript:history.go(-1)">'; print '</div>'; // Show origin lines - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); @@ -1920,7 +1920,7 @@ if ($action == 'create' && $usercancreate) // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } // Confirmation of validation @@ -1935,81 +1935,81 @@ if ($action == 'create' && $usercancreate) } $text = $langs->trans('ConfirmValidateOrder', $numref); - if (! empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '<br>'; $text .= $notify->confirmMessage('ORDER_VALIDATE', $object->socid, $object); } - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } - $formquestion=array(); - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + $formquestion = array(); + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); - require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $forcecombo = 0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockDecrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse', 'int')?GETPOST('idwarehouse', 'int'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse', 'int') ?GETPOST('idwarehouse', 'int') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); } // Confirm back to draft status if ($action == 'modif') { - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } - $text=$langs->trans('ConfirmUnvalidateOrder', $object->ref); - $formquestion=array(); - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + $text = $langs->trans('ConfirmUnvalidateOrder', $object->ref); + $formquestion = array(); + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); - require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $forcecombo = 0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220); } /* * Confirmation de la cloture */ if ($action == 'shipped') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_shipped', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_shipped', '', 0, 1); } /* @@ -2017,57 +2017,57 @@ if ($action == 'create' && $usercancreate) */ if ($action == 'cancel') { - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } - $text=$langs->trans('ConfirmCancelOrder', $object->ref); - $formquestion=array(); - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + $text = $langs->trans('ConfirmCancelOrder', $object->ref); + $formquestion = array(); + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); - require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $forcecombo = 0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1); } // Confirmation to delete line if ($action == 'ask_deleteline') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } // Clone confirmation if ($action == 'clone') { // Create an array for form $formquestion = array( - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=3)')) + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=3)')) ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Call Hook formConfirm $parameters = array('lineid' => $lineid); // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -2075,49 +2075,49 @@ if ($action == 'create' && $usercancreate) // Order card - $linkback = '<a href="' . DOL_URL_ROOT . '/commande/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; + $linkback = '<a href="'.DOL_URL_ROOT.'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; - $morehtmlref='<div class="refidno">'; + $morehtmlref = '<div class="refidno">'; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)'; + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$soc->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; + $morehtmlref .= '<br>'.$langs->trans('Project').' '; if ($usercancreate) { if ($action != 'classify') - $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; + $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref.='<input type="hidden" name="action" value="classin">'; - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref.='</form>'; + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref .= '</form>'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; - $morehtmlref.=$proj->ref; - $morehtmlref.='</a>'; + $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; + $morehtmlref .= $proj->ref; + $morehtmlref .= '</a>'; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='</div>'; + $morehtmlref .= '</div>'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -2136,14 +2136,14 @@ if ($action == 'create' && $usercancreate) print $langs->trans('OutstandingBill'); print '</td><td>'; $arrayoutstandingbills = $soc->getOutstandingBills(); - print price($arrayoutstandingbills['opened']) . ' / '; + print price($arrayoutstandingbills['opened']).' / '; print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); print '</td>'; print '</tr>'; } // Relative and absolute discounts - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -2151,11 +2151,11 @@ if ($action == 'create' && $usercancreate) $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } - $addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditRelativeDiscounts") . '</a>'; - $addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>'; - $addcreditnote = '<a href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&socid=' . $soc->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>'; + $addrelativediscount = '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$soc->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?facid='.$object->id.'">'.$langs->trans("EditRelativeDiscounts").'</a>'; + $addabsolutediscount = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$soc->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?facid='.$object->id.'">'.$langs->trans("EditGlobalDiscounts").'</a>'; + $addcreditnote = '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$soc->id.'&type=2&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?facid='.$object->id.'">'.$langs->trans("AddCreditNote").'</a>'; - print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>'; + print '<tr><td class="titlefield">'.$langs->trans('Discounts').'</td><td>'; $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); @@ -2164,7 +2164,7 @@ if ($action == 'create' && $usercancreate) $thirdparty = $soc; $discount_type = 0; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '</td></tr>'; @@ -2175,15 +2175,15 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("Date", 'date', '', $object, $editenable); print '</td><td>'; if ($action == 'editdate') { - print '<form name="setdate" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post">'; - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; + print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">'; print '<input type="hidden" name="action" value="setdate">'; print $form->selectDate($object->date, 'order_', '', '', '', "setdate"); - print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">'; + print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '</form>'; } else { print $object->date ? dol_print_date($object->date, 'day') : ' '; - if ($object->hasDelay() && ! empty($object->date_livraison)) { + if ($object->hasDelay() && !empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } @@ -2196,15 +2196,15 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable); print '</td><td>'; if ($action == 'editdate_livraison') { - print '<form name="setdate_livraison" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post">'; - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; + print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">'; print '<input type="hidden" name="action" value="setdate_livraison">'; print $form->selectDate($object->date_livraison ? $object->date_livraison : - 1, 'liv_', '', '', '', "setdate_livraison"); - print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">'; + print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '</form>'; } else { print $object->date_livraison ? dol_print_date($object->date_livraison, 'daytext') : ' '; - if ($object->hasDelay() && ! empty($object->date_livraison)) { + if ($object->hasDelay() && !empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } @@ -2212,7 +2212,7 @@ if ($action == 'create' && $usercancreate) print '</tr>'; // Shipping Method - if (! empty($conf->expedition->enabled)) { + if (!empty($conf->expedition->enabled)) { print '<tr><td>'; $editenable = $usercancreate; print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); @@ -2227,10 +2227,10 @@ if ($action == 'create' && $usercancreate) } // Warehouse - if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct=new FormProduct($db); + $formproduct = new FormProduct($db); print '<tr><td>'; $editenable = $usercancreate; print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); @@ -2250,9 +2250,9 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable); print '</td><td>'; if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none', 1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1); } print '</td>'; @@ -2264,14 +2264,14 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable); print '</td><td>'; if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); } print '</td></tr>'; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print '<tr>'; @@ -2280,9 +2280,9 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable); print '</td><td>'; if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); } print '</td></tr>'; @@ -2295,13 +2295,13 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable); print '</td><td>'; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - if($action == 'actualizemulticurrencyrate') { + if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '<div class="inline-block">         '; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>'; print '</div>'; @@ -2317,9 +2317,9 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable); print '</td><td>'; if ($action == 'editavailability') { - $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'availability_id', 1); + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { - $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'none', 1); + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'none', 1); } print '</td></tr>'; @@ -2329,9 +2329,9 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable); print '</td><td>'; if ($action == 'editdemandreason') { - $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'demand_reason_id', 1); + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { - $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'none'); + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'none'); } print '</td></tr>'; @@ -2349,19 +2349,19 @@ if ($action == 'create' && $usercancreate) print '</td></tr>'; */ - $tmparray=$object->getTotalWeightVolume(); - $totalWeight=$tmparray['weight']; - $totalVolume=$tmparray['volume']; + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; if ($totalWeight) { print '<tr><td>'.$langs->trans("CalculatedWeight").'</td>'; print '<td>'; - print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); + print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print '</td></tr>'; } if ($totalVolume) { print '<tr><td>'.$langs->trans("CalculatedVolume").'</td>'; print '<td>'; - print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); + print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print '</td></tr>'; } @@ -2380,13 +2380,13 @@ if ($action == 'create' && $usercancreate) } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print '</td></tr>'; } // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) { + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled)) { print '<tr><td>'; $editenable = $usercancreate; print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable); @@ -2401,7 +2401,7 @@ if ($action == 'create' && $usercancreate) } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '</table>'; @@ -2415,46 +2415,46 @@ if ($action == 'create' && $usercancreate) if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print '<tr><td class="titlefieldmiddle">' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . '</td>'; - print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>'; + print '<td class="nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount VAT - print '<tr><td>' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . '</td>'; - print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>'; + print '<td class="nowrap">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount TTC - print '<tr><td>' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . '</td>'; - print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>'; + print '<td class="nowrap">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; } // Total HT $alert = ''; - if (! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) { - $alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount)); + if (!empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) { + $alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount)); } - print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>'; - print '<td>' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . $alert . '</td>'; + print '<tr><td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>'; + print '<td>'.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).$alert.'</td>'; // Total VAT - print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td>' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; + print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { - print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>'; - print '<td>' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; + print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>'; + print '<td>'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 IRPF { - print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>'; - print '<td>' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; + print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>'; + print '<td>'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; } // Total TTC - print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td>' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; + print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; // Statut //print '<tr><td>' . $langs->trans('Status') . '</td><td>' . $object->getLibStatut(4) . '</td></tr>'; @@ -2462,27 +2462,27 @@ if ($action == 'create' && $usercancreate) print '</table>'; // Margin Infos - if (! empty($conf->margin->enabled)) { + if (!empty($conf->margin->enabled)) { $formmargin->displayMarginInfos($object); } print '</div>'; print '</div>'; - print '</div>'; // Close fichecenter + print '</div>'; // Close fichecenter print '<div class="clearboth"></div><br>'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } /* @@ -2490,21 +2490,21 @@ if ($action == 'create' && $usercancreate) */ $result = $object->getLinesArray(); - print '<form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#addline' : '#line_' . GETPOST('lineid')) . '" method="POST"> - <input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '"> - <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '"> + print '<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid')).'" method="POST"> + <input type="hidden" name="token" value="' . $_SESSION ['newtoken'].'"> + <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'"> <input type="hidden" name="mode" value=""> - <input type="hidden" name="id" value="' . $object->id . '">'; + <input type="hidden" name="id" value="' . $object->id.'">'; - if (! empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '<div class="div-table-responsive-no-min">'; print '<table id="tablelines" class="noborder noshadow" width="100%">'; // Show object lines - if (! empty($object->lines)) + if (!empty($object->lines)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); $numlines = count($object->lines); @@ -2544,19 +2544,19 @@ if ($action == 'create' && $usercancreate) // Send if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { - print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'; + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'; } else - print '<a class="butActionRefused classfortooltip" href="#">' . $langs->trans('SendMail') . '</a>'; + print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a>'; } // Valid if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && $usercanvalidate) { - print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=validate">' . $langs->trans('Validate') . '</a>'; + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=validate">'.$langs->trans('Validate').'</a>'; } // Edit if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) { - print '<a class="butAction" href="card.php?id=' . $object->id . '&action=modif">' . $langs->trans('Modify') . '</a>'; + print '<a class="butAction" href="card.php?id='.$object->id.'&action=modif">'.$langs->trans('Modify').'</a>'; } // Create event /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) @@ -2568,11 +2568,11 @@ if ($action == 'create' && $usercancreate) }*/ // Create a purchase order - if (! empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) + if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) { - if (! empty($conf->fournisseur->enabled) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { + if (!empty($conf->fournisseur->enabled) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($usercancreatepurchaseorder) { - print '<a class="butAction" href="' . DOL_URL_ROOT . '/fourn/commande/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans("AddPurchaseOrder") . '</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddPurchaseOrder").'</a>'; } } } @@ -2583,9 +2583,9 @@ if ($action == 'create' && $usercancreate) if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($user->rights->ficheinter->creer) { - print '<a class="butAction" href="' . DOL_URL_ROOT . '/fichinter/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans('AddIntervention') . '</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans('AddIntervention').'</a>'; } else { - print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('AddIntervention') . '</a>'; + print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('AddIntervention').'</a>'; } } } @@ -2595,71 +2595,71 @@ if ($action == 'create' && $usercancreate) $langs->load("contracts"); if ($user->rights->contrat->creer) { - print '<a class="butAction" href="' . DOL_URL_ROOT . '/contrat/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans('AddContract') . '</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans('AddContract').'</a>'; } } // Ship $numshipping = 0; - if (! empty($conf->expedition->enabled)) { + if (!empty($conf->expedition->enabled)) { $numshipping = $object->nb_expedition(); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) { if ($user->rights->expedition->creer) { - print '<a class="butAction" href="' . DOL_URL_ROOT . '/expedition/shipment.php?id=' . $object->id . '">' . $langs->trans('CreateShipment') . '</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id.'">'.$langs->trans('CreateShipment').'</a>'; } else { - print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('CreateShipment') . '</a>'; + print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('CreateShipment').'</a>'; } } else { $langs->load("errors"); - print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Shipment"))) . '">' . $langs->trans('CreateShipment') . '</a>'; + print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Shipment"))).'">'.$langs->trans('CreateShipment').'</a>'; } } } // Reopen a closed order if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $usercancreate) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=reopen">' . $langs->trans('ReOpen') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen">'.$langs->trans('ReOpen').'</a></div>'; } // Set to shipped if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $usercanclose) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=shipped">' . $langs->trans('ClassifyShipped') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=shipped">'.$langs->trans('ClassifyShipped').'</a></div>'; } // Create bill and Classify billed // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed" - if ($object->statut > Commande::STATUS_DRAFT && ! $object->billed) { - if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans("CreateBill") . '</a></div>'; + if ($object->statut > Commande::STATUS_DRAFT && !$object->billed) { + if (!empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { + print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a></div>'; } if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=classifybilled">' . $langs->trans("ClassifyBilled") . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled">'.$langs->trans("ClassifyBilled").'</a></div>'; } } if ($object->statut > Commande::STATUS_DRAFT && $object->billed) { if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=classifyunbilled">' . $langs->trans("ClassifyUnBilled") . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifyunbilled">'.$langs->trans("ClassifyUnBilled").'</a></div>'; } } // Clone if ($usercancreate) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&socid=' . $object->socid . '&action=clone&object=order">' . $langs->trans("ToClone") . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=order">'.$langs->trans("ToClone").'</a></div>'; } // Cancel order - if ($object->statut == Commande::STATUS_VALIDATED && (! empty($usercanclose) || ! empty($usercancancel))) + if ($object->statut == Commande::STATUS_VALIDATED && (!empty($usercanclose) || !empty($usercancancel))) { - print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=cancel">' . $langs->trans('Cancel') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel">'.$langs->trans('Cancel').'</a></div>'; } // Delete order if ($usercandelete) { if ($numshipping == 0) { - print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=delete">' . $langs->trans('Delete') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'; } else { - print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans("ShippingExist") . '">' . $langs->trans("Delete") . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ShippingExist").'">'.$langs->trans("Delete").'</a></div>'; } } } @@ -2677,9 +2677,9 @@ if ($action == 'create' && $usercancreate) print '<a name="builddoc"></a>'; // ancre // Documents $comref = dol_sanitizeFileName($object->ref); - $relativepath = $comref . '/' . $comref . '.pdf'; - $filedir = $conf->commande->multidir_output[$object->entity] . '/' . $comref; - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $relativepath = $comref.'/'.$comref.'.pdf'; + $filedir = $conf->commande->multidir_output[$object->entity].'/'.$comref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; print $formfile->showdocuments('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); @@ -2689,16 +2689,16 @@ if ($action == 'create' && $usercancreate) $linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); $compatibleImportElementsList = false; - if($usercancreate + if ($usercancreate && $object->statut == Commande::STATUS_DRAFT) { - $compatibleImportElementsList = array('commande','propal'); // import from linked elements + $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); // Show online payment link - $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); - if (! empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) $useonlinepayment = 0; + $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); + if (!empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) $useonlinepayment = 0; if ($object->statut != Commande::STATUS_DRAFT && $useonlinepayment) { print '<br><!-- Link to pay -->'; @@ -2707,7 +2707,7 @@ if ($action == 'create' && $usercancreate) } // Show direct download link - if ($object->statut != Commande::STATUS_DRAFT && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) + if ($object->statut != Commande::STATUS_DRAFT && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { print '<br><!-- Link to download main doc -->'."\n"; print showDirectDownloadLink($object).'<br>'; @@ -2716,7 +2716,7 @@ if ($action == 'create' && $usercancreate) print '</div><div class="fichehalfright"><div class="ficheaddleft">'; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'order', $socid, 1); @@ -2724,8 +2724,8 @@ if ($action == 'create' && $usercancreate) } // Presend form - $modelmail='order_send'; - $defaulttopic='SendOrderRef'; + $modelmail = 'order_send'; + $defaulttopic = 'SendOrderRef'; $diroutput = $conf->commande->multidir_output[$object->entity]; $trackid = 'ord'.$object->id; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index dadc25737b6..1de1e64e0c7 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -47,54 +47,54 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page -$langs->loadLangs(array("orders",'sendings','deliveries','companies','compta','bills')); +$langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills')); -$action=GETPOST('action', 'aZ09'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'orderlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'orderlist'; -$search_orderyear=GETPOST("search_orderyear", "int"); -$search_ordermonth=GETPOST("search_ordermonth", "int"); -$search_orderday=GETPOST("search_orderday", "int"); -$search_deliveryyear=GETPOST("search_deliveryyear", "int"); -$search_deliverymonth=GETPOST("search_deliverymonth", "int"); -$search_deliveryday=GETPOST("search_deliveryday", "int"); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_ref=GETPOST('search_ref', 'alpha')!=''?GETPOST('search_ref', 'alpha'):GETPOST('sref', 'alpha'); -$search_ref_customer=GETPOST('search_ref_customer', 'alpha'); -$search_company=GETPOST('search_company', 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$socid=GETPOST('socid', 'int'); -$search_user=GETPOST('search_user', 'int'); -$search_sale=GETPOST('search_sale', 'int'); -$search_total_ht=GETPOST('search_total_ht', 'alpha'); -$search_total_ttc=GETPOST('search_total_ttc', 'alpha'); -$search_categ_cus=trim(GETPOST("search_categ_cus", 'int')); +$search_orderyear = GETPOST("search_orderyear", "int"); +$search_ordermonth = GETPOST("search_ordermonth", "int"); +$search_orderday = GETPOST("search_orderday", "int"); +$search_deliveryyear = GETPOST("search_deliveryyear", "int"); +$search_deliverymonth = GETPOST("search_deliverymonth", "int"); +$search_deliveryday = GETPOST("search_deliveryday", "int"); +$search_product_category = GETPOST('search_product_category', 'int'); +$search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha'); +$search_ref_customer = GETPOST('search_ref_customer', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$socid = GETPOST('socid', 'int'); +$search_user = GETPOST('search_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_total_ht = GETPOST('search_total_ht', 'alpha'); +$search_total_ttc = GETPOST('search_total_ttc', 'alpha'); +$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); $optioncss = GETPOST('optioncss', 'alpha'); $billed = GETPOST('billed', 'int'); -$viewstatut=GETPOST('viewstatut'); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); -$search_project_ref=GETPOST('search_project_ref', 'alpha'); -$search_project=GETPOST('search_project', 'alpha'); +$viewstatut = GETPOST('viewstatut'); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); +$search_project = GETPOST('search_project', 'alpha'); // Security check -$id = (GETPOST('orderid')?GETPOST('orderid', 'int'):GETPOST('id', 'int')); -if ($user->socid) $socid=$user->socid; +$id = (GETPOST('orderid') ?GETPOST('orderid', 'int') : GETPOST('id', 'int')); +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'commande', $id, ''); -$diroutputmassaction=$conf->commande->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -102,8 +102,8 @@ if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='c.ref'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'c.ref'; +if (!$sortorder) $sortorder = 'DESC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Commande($db); @@ -112,7 +112,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('commande'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -123,14 +123,14 @@ $fieldstosearchall = array( 's.name_alias'=>"AliasNameShort", 'c.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["c.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'c.ref'=>array('label'=>"Ref", 'checked'=>1), 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>1), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled)?0:1)), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 's.town'=>array('label'=>"Town", 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'checked'=>1), @@ -151,10 +151,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -166,11 +166,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) @@ -181,49 +181,49 @@ if (empty($reshook)) // 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_categ=''; - $search_user=''; - $search_sale=''; - $search_product_category=''; - $search_ref=''; - $search_ref_customer=''; - $search_company=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_total_ht=''; - $search_total_vat=''; - $search_total_ttc=''; - $search_orderyear=''; - $search_ordermonth=''; - $search_orderday=''; - $search_deliveryday=''; - $search_deliverymonth=''; - $search_deliveryyear=''; - $search_project_ref=''; - $search_project=''; - $viewstatut=''; - $billed=''; - $toselect=''; - $search_array_options=array(); - $search_categ_cus=0; + $search_categ = ''; + $search_user = ''; + $search_sale = ''; + $search_product_category = ''; + $search_ref = ''; + $search_ref_customer = ''; + $search_company = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_total_ht = ''; + $search_total_vat = ''; + $search_total_ttc = ''; + $search_orderyear = ''; + $search_ordermonth = ''; + $search_orderday = ''; + $search_deliveryday = ''; + $search_deliverymonth = ''; + $search_deliveryyear = ''; + $search_project_ref = ''; + $search_project = ''; + $viewstatut = ''; + $billed = ''; + $toselect = ''; + $search_array_options = array(); + $search_categ_cus = 0; } 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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Commande'; - $objectlabel='Orders'; + $objectclass = 'Commande'; + $objectlabel = 'Orders'; $permissiontoread = $user->rights->commande->lire; $permissiontodelete = $user->rights->commande->supprimer; $uploaddir = $conf->commande->multidir_output[$conf->entity]; - $trigger_name='ORDER_SENTBYMAIL'; + $trigger_name = 'ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -232,77 +232,77 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $companystatic = new Societe($db); -$formcompany=new FormCompany($db); -$projectstatic=new Project($db); +$formcompany = new FormCompany($db); +$projectstatic = new Project($db); -$title=$langs->trans("Orders"); -$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; +$title = $langs->trans("Orders"); +$help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; // llxHeader('',$title,$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,'; -$sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; -$sql.= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,'; -$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; +$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,'; +$sql .= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; +$sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,'; +$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); // Add fields from hooks -$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."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)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ -$sql.= ', '.MAIN_DB_PREFIX.'commande as c'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; -if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet"; +$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."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)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +$sql .= ', '.MAIN_DB_PREFIX.'commande as c'; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; +if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE c.fk_soc = s.rowid'; -$sql.= ' AND c.entity IN ('.getEntity('commande').')'; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; -if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql .= ' WHERE c.fk_soc = s.rowid'; +$sql .= ' AND c.entity IN ('.getEntity('commande').')'; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; +if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($search_ref) $sql .= natural_search('c.ref', $search_ref); -if ($search_ref_customer) $sql.= natural_search('c.ref_client', $search_ref_customer); +if ($search_ref_customer) $sql .= natural_search('c.ref_client', $search_ref_customer); if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($billed != '' && $billed >= 0) $sql.=' AND c.facture = '.$billed; +if ($billed != '' && $billed >= 0) $sql .= ' AND c.facture = '.$billed; if ($viewstatut <> '') { if ($viewstatut < 4 && $viewstatut > -3) { - if ($viewstatut == 1 && empty($conf->expedition->enabled)) $sql.= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' - else $sql.= ' AND c.fk_statut = '.$viewstatut; // brouillon, validee, en cours, annulee + if ($viewstatut == 1 && empty($conf->expedition->enabled)) $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' + else $sql .= ' AND c.fk_statut = '.$viewstatut; // brouillon, validee, en cours, annulee } if ($viewstatut == 4) { - $sql.= ' AND c.facture = 1'; // invoice created + $sql .= ' AND c.facture = 1'; // invoice created } if ($viewstatut == -2) // To process { //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0'; - $sql.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected + $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected } if ($viewstatut == -3) // To bill { @@ -311,30 +311,30 @@ if ($viewstatut <> '') $sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed } } -$sql.= dolSqlDateFilter("c.date_commande", $search_orderday, $search_ordermonth, $search_orderyear); -$sql.= dolSqlDateFilter("c.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +$sql .= dolSqlDateFilter("c.date_commande", $search_orderday, $search_ordermonth, $search_orderyear); +$sql .= dolSqlDateFilter("c.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; -if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; -if ($search_total_ht != '') $sql.= natural_search('c.total_ht', $search_total_ht, 1); -if ($search_total_ttc != '') $sql.= natural_search('c.total_ttc', $search_total_ttc, 1); -if ($search_project_ref != '') $sql.= natural_search("p.ref", $search_project_ref); -if ($search_project != '') $sql.= natural_search("p.title", $search_project); -if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); -if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; +if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; +if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1); +if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1); +if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); +if ($search_project != '') $sql .= natural_search("p.title", $search_project); +if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -350,7 +350,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); @@ -360,7 +360,7 @@ if ($resql) { $soc = new Societe($db); $soc->fetch($socid); - $title = $langs->trans('ListOfOrders') . ' - '.$soc->name; + $title = $langs->trans('ListOfOrders').' - '.$soc->name; if (empty($search_company)) $search_company = $soc->name; } else @@ -368,27 +368,27 @@ if ($resql) $title = $langs->trans('ListOfOrders'); } if (strval($viewstatut) == '0') - $title.=' - '.$langs->trans('StatusOrderDraftShort'); + $title .= ' - '.$langs->trans('StatusOrderDraftShort'); if ($viewstatut == 1) - $title.=' - '.$langs->trans('StatusOrderValidatedShort'); + $title .= ' - '.$langs->trans('StatusOrderValidatedShort'); if ($viewstatut == 2) - $title.=' - '.$langs->trans('StatusOrderSentShort'); + $title .= ' - '.$langs->trans('StatusOrderSentShort'); if ($viewstatut == 3) - $title.=' - '.$langs->trans('StatusOrderToBillShort'); + $title .= ' - '.$langs->trans('StatusOrderToBillShort'); if ($viewstatut == 4) - $title.=' - '.$langs->trans('StatusOrderProcessedShort'); + $title .= ' - '.$langs->trans('StatusOrderProcessedShort'); if ($viewstatut == -1) - $title.=' - '.$langs->trans('StatusOrderCanceledShort'); + $title .= ' - '.$langs->trans('StatusOrderCanceledShort'); if ($viewstatut == -2) - $title.=' - '.$langs->trans('StatusOrderToProcessShort'); + $title .= ' - '.$langs->trans('StatusOrderToProcessShort'); if ($viewstatut == -3) - $title.=' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled)?'':$langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); + $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled) ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -398,58 +398,58 @@ if ($resql) llxHeader('', $title, $help_url); - $param=''; + $param = ''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.='&sall='.urlencode($sall); - if ($socid > 0) $param.='&socid='.urlencode($socid); - if ($viewstatut != '') $param.='&viewstatut='.urlencode($viewstatut); - if ($search_orderday) $param.='&search_orderday='.urlencode($search_orderday); - if ($search_ordermonth) $param.='&search_ordermonth='.urlencode($search_ordermonth); - if ($search_orderyear) $param.='&search_orderyear='.urlencode($search_orderyear); - if ($search_deliveryday) $param.='&search_deliveryday='.urlencode($search_deliveryday); - if ($search_deliverymonth) $param.='&search_deliverymonth='.urlencode($search_deliverymonth); - if ($search_deliveryyear) $param.='&search_deliveryyear='.urlencode($search_deliveryyear); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_company) $param.='&search_company='.urlencode($search_company); - if ($search_ref_customer) $param.='&search_ref_customer='.urlencode($search_ref_customer); - if ($search_user > 0) $param.='&search_user='.urlencode($search_user); - if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); - if ($search_total_ht != '') $param.='&search_total_ht='.urlencode($search_total_ht); - if ($search_total_vat != '') $param.='&search_total_vat='.urlencode($search_total_vat); - if ($search_total_ttc != '') $param.='&search_total_ttc='.urlencode($search_total_ttc); - if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref); - if ($search_town != '') $param.='&search_town='.urlencode($search_town); - if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip); - if ($search_state != '') $param.='&search_state='.urlencode($search_state); - if ($search_country != '') $param.='&search_country='.urlencode($search_country); - if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty); - if ($search_product_category != '') $param.='&search_product_category='.urlencode($search_product_category); - if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); - if ($show_files) $param.='&show_files=' .urlencode($show_files); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($billed != '') $param.='&billed='.urlencode($billed); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= '&sall='.urlencode($sall); + if ($socid > 0) $param .= '&socid='.urlencode($socid); + if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut); + if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday); + if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth); + if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear); + if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday); + if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_company) $param .= '&search_company='.urlencode($search_company); + if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); + if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); + if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); + if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); + if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); + if ($search_town != '') $param .= '&search_town='.urlencode($search_town); + if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip); + if ($search_state != '') $param .= '&search_state='.urlencode($search_state); + if ($search_country != '') $param .= '&search_country='.urlencode($search_country); + if ($search_type_thirdparty != '') $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category); + if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); + if ($show_files) $param .= '&show_files='.urlencode($show_files); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($billed != '') $param .= '&billed='.urlencode($billed); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'cancelorders'=>$langs->trans("Cancel"), 'presend'=>$langs->trans("SendByMail"), ); - if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); - if ($user->rights->commande->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->facture->creer) $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisCustomer"); + if ($user->rights->commande->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; + $newcardbutton = ''; if ($contextpage == 'orderlist' && $user->rights->commande->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/commande/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/commande/card.php?action=create'); } // Lines of title fields @@ -468,10 +468,10 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'commercial', 0, $newcardbutton, '', $limit); - $topicmail="SendOrderRef"; - $modelmail="order_send"; - $objecttmp=new Commande($db); - $trackid='ord'.$object->id; + $topicmail = "SendOrderRef"; + $modelmail = "order_send"; + $objecttmp = new Commande($db); + $trackid = 'ord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($massaction == 'createbills') @@ -501,7 +501,7 @@ if ($resql) print $langs->trans('ValidateInvoices'); print '</td>'; print '<td>'; - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { print $form->selectyesno('validate_invoices', 0, 1, 1); print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; @@ -510,7 +510,7 @@ if ($resql) { print $form->selectyesno('validate_invoices', 0, 1); } - if (! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print '     <span class="opacitymedium">'.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").'</span>'; + if (!empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print '     <span class="opacitymedium">'.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").'</span>'; else print '     <span class="opacitymedium">'.$langs->trans("OptionToSetOrderBilledNotEnabled").'</span>'; print '</td>'; print '</tr>'; @@ -526,155 +526,155 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } - $moreforfilter=''; + $moreforfilter = ''; // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view other users if ($user->rights->user->user->lire) { - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view prospects other than his' if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='</div>'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '</div>'; } - if (! empty($conf->categorie->enabled)) + if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); - $moreforfilter.='</div>'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $moreforfilter .= '</div>'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<tr class="liste_titre_filter">'; // Ref - if (! empty($arrayfields['c.ref']['checked'])) + if (!empty($arrayfields['c.ref']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="6" type="text" name="search_ref" value="'.$search_ref.'">'; print '</td>'; } // Ref customer - if (! empty($arrayfields['c.ref_client']['checked'])) + if (!empty($arrayfields['c.ref_client']['checked'])) { print '<td class="liste_titre" align="left">'; print '<input class="flat" type="text" size="6" name="search_ref_customer" value="'.$search_ref_customer.'">'; print '</td>'; } // Project ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.$search_project_ref.'"></td>'; } // Project title - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.$search_project.'"></td>'; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre" align="left">'; print '<input class="flat" type="text" name="search_company" value="'.$search_company.'">'; print '</td>'; } // Town - if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.$search_town.'"></td>'; + if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.$search_town.'"></td>'; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>'; + if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>'; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="liste_titre" align="center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone" align="center">'; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print '</td>'; } // Date order - if (! empty($arrayfields['c.date_commande']['checked'])) + if (!empty($arrayfields['c.date_commande']['checked'])) { print '<td class="liste_titre nowraponall" align="center">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_orderday" value="'.$search_orderday.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_orderday" value="'.$search_orderday.'">'; print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_ordermonth" value="'.$search_ordermonth.'">'; - $formother->select_year($search_orderyear?$search_orderyear:-1, 'search_orderyear', 1, 20, 5); + $formother->select_year($search_orderyear ? $search_orderyear : -1, 'search_orderyear', 1, 20, 5); print '</td>'; } - if (! empty($arrayfields['c.date_delivery']['checked'])) + if (!empty($arrayfields['c.date_delivery']['checked'])) { print '<td class="liste_titre nowraponall" align="center">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliveryday" value="'.$search_deliveryday.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliveryday" value="'.$search_deliveryday.'">'; print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliverymonth" value="'.$search_deliverymonth.'">'; - $formother->select_year($search_deliveryyear?$search_deliveryyear:-1, 'search_deliveryyear', 1, 20, 5); + $formother->select_year($search_deliveryyear ? $search_deliveryyear : -1, 'search_deliveryyear', 1, 20, 5); print '</td>'; } - if (! empty($arrayfields['c.total_ht']['checked'])) + if (!empty($arrayfields['c.total_ht']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_total_ht" value="'.$search_total_ht.'">'; print '</td>'; } - if (! empty($arrayfields['c.total_vat']['checked'])) + if (!empty($arrayfields['c.total_vat']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_total_vat" value="'.$search_total_vat.'">'; print '</td>'; } - if (! empty($arrayfields['c.total_ttc']['checked'])) + if (!empty($arrayfields['c.total_ttc']['checked'])) { // Amount print '<td class="liste_titre right">'; @@ -684,32 +684,32 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['c.datec']['checked'])) + if (!empty($arrayfields['c.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (! empty($arrayfields['c.tms']['checked'])) + if (!empty($arrayfields['c.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date cloture - if (! empty($arrayfields['c.date_cloture']['checked'])) + if (!empty($arrayfields['c.date_cloture']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status - if (! empty($arrayfields['c.fk_statut']['checked'])) + if (!empty($arrayfields['c.fk_statut']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone right">'; - $liststatus=array( + $liststatus = array( Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), @@ -721,7 +721,7 @@ if ($resql) print '</td>'; } // Status billed - if (! empty($arrayfields['c.facture']['checked'])) + if (!empty($arrayfields['c.facture']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone" align="center">'; print $form->selectyesno('billed', $billed, 1, 0, 1); @@ -729,7 +729,7 @@ if ($resql) } // Action column print '<td class="liste_titre" align="middle">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; @@ -737,54 +737,54 @@ if ($resql) // Fields title print '<tr class="liste_titre">'; - if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['c.ref_client']['checked'])) print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['c.date_commande']['checked'])) print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['c.date_delivery']['checked'])) print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['c.ref_client']['checked'])) print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.date_commande']['checked'])) print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.date_delivery']['checked'])) print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['c.date_cloture']['checked'])) print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['c.date_cloture']['checked'])) print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); print '</tr>'."\n"; - $total=0; - $subtotal=0; - $productstat_cache=array(); - $getNomUrl_cache=array(); + $total = 0; + $subtotal = 0; + $productstat_cache = array(); + $getNomUrl_cache = array(); $generic_commande = new Commande($db); $generic_product = new Product($db); - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $notshippable=0; + $notshippable = 0; $warning = 0; - $text_info=''; - $text_warning=''; - $nbprod=0; + $text_info = ''; + $text_warning = ''; + $nbprod = 0; $companystatic->id = $obj->socid; $companystatic->code_client = $obj->code_client; @@ -795,8 +795,8 @@ if ($resql) $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer'); } - $generic_commande->id=$obj->rowid; - $generic_commande->ref=$obj->ref; + $generic_commande->id = $obj->rowid; + $generic_commande->ref = $obj->ref; $generic_commande->statut = $obj->fk_statut; $generic_commande->date = $db->jdate($obj->date_commande); $generic_commande->date_livraison = $db->jdate($obj->date_delivery); @@ -805,21 +805,21 @@ if ($resql) $generic_commande->total_tva = $obj->total_tva; $generic_commande->total_ttc = $obj->total_ttc; - $projectstatic->id=$obj->project_id; - $projectstatic->ref=$obj->project_ref; - $projectstatic->title=$obj->project_label; + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; print '<tr class="oddeven">'; // Ref - if (! empty($arrayfields['c.ref']['checked'])) + if (!empty($arrayfields['c.ref']['checked'])) { print '<td class="nowrap">'; - $generic_commande->lines=array(); + $generic_commande->lines = array(); $generic_commande->getLinesArray(); - print $generic_commande->getNomUrl(1, ($viewstatut != 2?0:$obj->fk_statut), 0, 0, 0, 1); + print $generic_commande->getNomUrl(1, ($viewstatut != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1); // Show shippable Icon (create subloop, so may be slow) if ($conf->stock->enabled) @@ -828,7 +828,7 @@ if ($resql) if (($obj->fk_statut > 0) && ($obj->fk_statut < 3)) { $numlines = count($generic_commande->lines); // Loop on each line of order - for ($lig=0; $lig < $numlines; $lig++) + for ($lig = 0; $lig < $numlines; $lig++) { if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) // If line is a product and not a service { @@ -860,11 +860,11 @@ if ($resql) } else { // Detailed code, looks bugged // stock order and stock order_supplier - $stock_order=0; - $stock_order_supplier=0; - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) // What about other options ? + $stock_order = 0; + $stock_order_supplier = 0; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) // What about other options ? { - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) { $generic_product->load_stats_commande(0, '1,2'); @@ -872,9 +872,9 @@ if ($resql) } else { $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer']; } - $stock_order=$generic_product->stats_commande['qty']; + $stock_order = $generic_product->stats_commande['qty']; } - if (! empty($conf->fournisseur->enabled)) + if (!empty($conf->fournisseur->enabled)) { if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { $generic_product->load_stats_commande_fournisseur(0, '3'); @@ -882,25 +882,25 @@ if ($resql) } else { $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier']; } - $stock_order_supplier=$generic_product->stats_commande_fournisseur['qty']; + $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; } } $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; - if ($stock_order > $generic_product->stock_reel && ! ($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { + if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { $warning++; - $text_warning.='<span class="warning">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>'; + $text_warning .= '<span class="warning">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>'; } if ($generic_product->stock_reel < $generic_commande->lines[$lig]->qty) { $notshippable++; - $text_info.='<span class="warning">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>'; + $text_info .= '<span class="warning">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>'; } else { - $text_info.='<span class="ok">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>'; + $text_info .= '<span class="ok">'.$langs->trans('Available').' : '.$text_stock_reel.'</span>'; } - if (! empty($conf->fournisseur->enabled)) { - $text_info.= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier.'<br>'; + if (!empty($conf->fournisseur->enabled)) { + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier.'<br>'; } else { - $text_info.= '<br>'; + $text_info .= '<br>'; } } } @@ -934,24 +934,24 @@ if ($resql) print '</span>'; } - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->multidir_output[$conf->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref customer - if (! empty($arrayfields['c.ref_client']['checked'])) + if (!empty($arrayfields['c.ref_client']['checked'])) { print '<td>'.$obj->ref_client.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="nowrap">'; if ($obj->project_id > 0) @@ -959,11 +959,11 @@ if ($resql) print $projectstatic->getNomUrl(1); } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project label - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print '<td class="nowrap">'; if ($obj->project_id > 0) @@ -971,17 +971,17 @@ if ($resql) print $projectstatic->title; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="tdoverflowmax200">'; print $getNomUrl_cache[$obj->socid]; // If module invoices enabled and user with invoice creation permissions - if (! empty($conf->facture->enabled) && ! empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) + if (!empty($conf->facture->enabled) && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { if ($user->rights->facture->creer) { @@ -1143,8 +1143,8 @@ if ($resql) $db->free($resql); - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -1152,16 +1152,16 @@ if ($resql) print '</form>'."\n"; - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->commande->lire; - $delallowed=$user->rights->commande->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->commande->lire; + $delallowed = $user->rights->commande->creer; print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 0912dfaba0a..bfbafc93bd5 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -52,51 +52,51 @@ require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","bills","categories","companies","margins","salaries","loan","donations","trips","members","compta","accountancy")); +$langs->loadLangs(array("banks", "bills", "categories", "companies", "margins", "salaries", "loan", "donations", "trips", "members", "compta", "accountancy")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); -$contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$contextpage = 'banktransactionlist'.(empty($object->ref) ? '' : '-'.$object->id); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); -$fieldtype = (! empty($ref) ? 'ref' :'rowid'); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($fielvalue) { - if ($user->socid) $socid=$user->socid; - $result=restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); + if ($user->socid) $socid = $user->socid; + $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); } else { - if ($user->socid) $socid=$user->socid; - $result=restrictedArea($user, 'banque'); + if ($user->socid) $socid = $user->socid; + $result = restrictedArea($user, 'banque'); } $dateop = dol_mktime(12, 0, 0, GETPOST("opmonth", 'int'), GETPOST("opday", 'int'), GETPOST("opyear", 'int')); -$search_debit=GETPOST("search_debit", 'alpha'); -$search_credit=GETPOST("search_credit", 'alpha'); -$search_type=GETPOST("search_type", 'alpha'); -$search_account=GETPOST("search_account", 'int')?GETPOST("search_account", 'int'):GETPOST("account", 'int'); -$search_accountancy_code=GETPOST('search_accountancy_code', 'alpha')?GETPOST('search_accountancy_code', 'alpha'):GETPOST('accountancy_code', 'alpha'); -$search_bid=GETPOST("search_bid", "int")?GETPOST("search_bid", "int"):GETPOST("bid", "int"); -$search_ref=GETPOST('search_ref', 'alpha'); -$search_description=GETPOST("search_description", 'alpha'); +$search_debit = GETPOST("search_debit", 'alpha'); +$search_credit = GETPOST("search_credit", 'alpha'); +$search_type = GETPOST("search_type", 'alpha'); +$search_account = GETPOST("search_account", 'int') ?GETPOST("search_account", 'int') : GETPOST("account", 'int'); +$search_accountancy_code = GETPOST('search_accountancy_code', 'alpha') ?GETPOST('search_accountancy_code', 'alpha') : GETPOST('accountancy_code', 'alpha'); +$search_bid = GETPOST("search_bid", "int") ?GETPOST("search_bid", "int") : GETPOST("bid", "int"); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_description = GETPOST("search_description", 'alpha'); $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); $search_dv_start = dol_mktime(0, 0, 0, GETPOST('search_start_dvmonth', 'int'), GETPOST('search_start_dvday', 'int'), GETPOST('search_start_dvyear', 'int')); $search_dv_end = dol_mktime(0, 0, 0, GETPOST('search_end_dvmonth', 'int'), GETPOST('search_end_dvday', 'int'), GETPOST('search_end_dvyear', 'int')); -$search_thirdparty=GETPOST("search_thirdparty", 'alpha')?GETPOST("search_thirdparty", 'alpha'):GETPOST("thirdparty", 'alpha'); -$search_req_nb=GETPOST("req_nb", 'alpha'); -$search_num_releve=GETPOST("search_num_releve", 'alpha'); -$search_conciliated=GETPOST("search_conciliated", 'int'); -$num_releve=GETPOST("num_releve", "alpha"); -$cat=GETPOST("cat"); -if (empty($dateop)) $dateop=-1; +$search_thirdparty = GETPOST("search_thirdparty", 'alpha') ?GETPOST("search_thirdparty", 'alpha') : GETPOST("thirdparty", 'alpha'); +$search_req_nb = GETPOST("req_nb", 'alpha'); +$search_num_releve = GETPOST("search_num_releve", 'alpha'); +$search_conciliated = GETPOST("search_conciliated", 'int'); +$num_releve = GETPOST("num_releve", "alpha"); +$cat = GETPOST("cat"); +if (empty($dateop)) $dateop = -1; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -106,24 +106,24 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder='desc,desc,desc'; -if (! $sortfield) $sortfield='b.datev,b.dateo,b.rowid'; +if (!$sortorder) $sortorder = 'desc,desc,desc'; +if (!$sortfield) $sortfield = 'b.datev,b.dateo,b.rowid'; -$mode_balance_ok=false; +$mode_balance_ok = false; //if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid')) // TODO Manage balance when account not selected if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid')) { $sortfield = 'b.datev,b.dateo,b.rowid'; - if ($id > 0 || ! empty($ref) || $search_account > 0) $mode_balance_ok = true; + if ($id > 0 || !empty($ref) || $search_account > 0) $mode_balance_ok = true; } $object = new Account($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { - $result=$object->fetch($id, $ref); - $search_account = $object->id; // Force the search field on id of account + $result = $object->fetch($id, $ref); + $search_account = $object->id; // Force the search field on id of account - if (! ($object->id > 0) ) + if (!($object->id > 0)) { $langs->load("errors"); print($langs->trans('ErrorRecordNotFound')); @@ -138,9 +138,9 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('banktransaction'); -$search_array_options=$extrafields->getOptionalsFromPost('banktransaction', '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost('banktransaction', '', 'search_'); -$arrayfields=array( +$arrayfields = array( 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'b.label'=>array('label'=>$langs->trans("Description"), 'checked'=>1), 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), @@ -148,21 +148,21 @@ $arrayfields=array( 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), 'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1), 'bu.label'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>500), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || ! empty($ref))?0:1), 'position'=>1000), + 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1), 'position'=>1000), 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), 'balancebefore'=>array('label'=>$langs->trans("BalanceBefore"), 'checked'=>0, 'position'=>1000), 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1001), 'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>1010), - 'b.conciliated'=>array('label'=>$langs->trans("Conciliated"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile'?1:0), 'position'=>1020), + 'b.conciliated'=>array('label'=>$langs->trans("Conciliated"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile' ? 1 : 0), 'position'=>1020), ); // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -174,41 +174,41 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; 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_dt_start=''; - $search_dt_end=''; - $search_dv_start=''; - $search_dv_end=''; - $search_type=""; - $search_debit=""; - $search_credit=""; - $search_bid=""; - $search_ref=""; - $search_req_nb=''; - $search_description=''; - $search_thirdparty=''; - $search_num_releve=''; - $search_conciliated=''; - $thirdparty=''; + $search_dt_start = ''; + $search_dt_end = ''; + $search_dv_start = ''; + $search_dv_end = ''; + $search_type = ""; + $search_debit = ""; + $search_credit = ""; + $search_bid = ""; + $search_ref = ""; + $search_req_nb = ''; + $search_description = ''; + $search_thirdparty = ''; + $search_num_releve = ''; + $search_conciliated = ''; + $thirdparty = ''; - $search_account=""; - if ($id > 0 || ! empty($ref)) $search_account=$object->id; + $search_account = ""; + if ($id > 0 || !empty($ref)) $search_account = $object->id; } if (empty($reshook)) { - $objectclass='Account'; - $objectlabel='BankTransaction'; + $objectclass = 'Account'; + $objectlabel = 'BankTransaction'; $permissiontoread = $user->rights->banque->lire; $permissiontodelete = $user->rights->banque->supprimer; $uploaddir = $conf->bank->dir_output; @@ -218,23 +218,23 @@ if (empty($reshook)) // Conciliation if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', 'alpha')) && $user->rights->banque->consolidate) { - $error=0; + $error = 0; // Definition, nettoyage parametres - $num_releve=trim(GETPOST("num_releve", "alpha")); + $num_releve = trim(GETPOST("num_releve", "alpha")); if ($num_releve) { - $bankline=new AccountLine($db); + $bankline = new AccountLine($db); if (isset($_POST['rowid']) && is_array($_POST['rowid'])) { - foreach($_POST['rowid'] as $row) + foreach ($_POST['rowid'] as $row) { if ($row > 0) { - $result=$bankline->fetch($row); - $bankline->num_releve=$num_releve; //$_POST["num_releve"]; - $result=$bankline->update_conciliation($user, GETPOST("cat"), GETPOST('confirm_reconcile', 'alpha')?1:0); // If we confirm_reconcile, we set flag 'rappro' to 1. + $result = $bankline->fetch($row); + $bankline->num_releve = $num_releve; //$_POST["num_releve"]; + $result = $bankline->update_conciliation($user, GETPOST("cat"), GETPOST('confirm_reconcile', 'alpha') ? 1 : 0); // If we confirm_reconcile, we set flag 'rappro' to 1. if ($result < 0) { setEventMessages($bankline->error, $bankline->errors, 'errors'); @@ -258,30 +258,30 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' setEventMessages($langs->trans("ErrorPleaseTypeBankTransactionReportName"), null, 'errors'); } - if (! $error) + if (!$error) { - $param='action=reconcile&contextpage=banktransactionlist&id='.$id.'&search_account='.$id; - $param.='&search_conciliated='.urlencode($search_conciliated); - if ($page) $param.='&page='.urlencode($page); - if ($offset) $param.='&offset='.urlencode($offset); - if ($search_thirdparty) $param.='&search_thirdparty='.urlencode($search_thirdparty); - if ($search_num_releve) $param.='&search_num_releve='.urlencode($search_num_releve); - if ($search_description) $param.='&search_description='.urlencode($search_description); - if ($search_start_dt) $param.='&search_start_dt='.urlencode($search_start_dt); - if ($search_end_dt) $param.='&search_end_dt='.urlencode($search_end_dt); - if ($search_start_dv) $param.='&search_start_dv='.urlencode($search_start_dv); - if ($search_end_dv) $param.='&search_end_dv='.urlencode($search_end_dv); - if ($search_type) $param.='&search_type='.urlencode($search_type); - if ($search_debit) $param.='&search_debit='.urlencode($search_debit); - if ($search_credit) $param.='&search_credit='.urlencode($search_credit); - $param.='&sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder); - header('Location: '.$_SERVER["PHP_SELF"].'?'.$param); // To avoid to submit twice and allow the back button + $param = 'action=reconcile&contextpage=banktransactionlist&id='.$id.'&search_account='.$id; + $param .= '&search_conciliated='.urlencode($search_conciliated); + if ($page) $param .= '&page='.urlencode($page); + if ($offset) $param .= '&offset='.urlencode($offset); + if ($search_thirdparty) $param .= '&search_thirdparty='.urlencode($search_thirdparty); + if ($search_num_releve) $param .= '&search_num_releve='.urlencode($search_num_releve); + if ($search_description) $param .= '&search_description='.urlencode($search_description); + if ($search_start_dt) $param .= '&search_start_dt='.urlencode($search_start_dt); + if ($search_end_dt) $param .= '&search_end_dt='.urlencode($search_end_dt); + if ($search_start_dv) $param .= '&search_start_dv='.urlencode($search_start_dv); + if ($search_end_dv) $param .= '&search_end_dv='.urlencode($search_end_dv); + if ($search_type) $param .= '&search_type='.urlencode($search_type); + if ($search_debit) $param .= '&search_debit='.urlencode($search_debit); + if ($search_credit) $param .= '&search_credit='.urlencode($search_credit); + $param .= '&sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder); + header('Location: '.$_SERVER["PHP_SELF"].'?'.$param); // To avoid to submit twice and allow the back button exit; } } -if (GETPOST('save') && ! $cancel && $user->rights->banque->modifier) +if (GETPOST('save') && !$cancel && $user->rights->banque->modifier) { $error = 0; @@ -302,23 +302,23 @@ if (GETPOST('save') && ! $cancel && $user->rights->banque->modifier) $bankaccountid = $id; if (GETPOST('add_account', 'int') > 0) $bankaccountid = GETPOST('add_account', 'int'); - if (! $dateop) { + if (!$dateop) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); } - if (! $operation) { + if (!$operation) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); } - if (! $label) { + if (!$label) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); } - if (! $amount) { + if (!$amount) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); } - if (! $bankaccountid > 0) + if (!$bankaccountid > 0) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); @@ -329,7 +329,7 @@ if (GETPOST('save') && ! $cancel && $user->rights->banque->modifier) $error++; }*/ - if (! $error && ! empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) + if (!$error && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) { $objecttmp = new Account($db); $objecttmp->fetch($bankaccountid); @@ -347,15 +347,15 @@ if (GETPOST('save') && ! $cancel && $user->rights->banque->modifier) } else { - $action='addline'; + $action = 'addline'; } } if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) { - $accline=new AccountLine($db); - $result=$accline->fetch(GETPOST("rowid")); - $result=$accline->delete($user); + $accline = new AccountLine($db); + $result = $accline->fetch(GETPOST("rowid")); + $result = $accline->delete($user); } @@ -368,52 +368,52 @@ $form = new Form($db); $formother = new FormOther($db); $formaccounting = new FormAccounting($db); -$companystatic=new Societe($db); -$bankaccountstatic=new Account($db); +$companystatic = new Societe($db); +$bankaccountstatic = new Account($db); -$banktransferstatic=new BonPrelevement($db); -$societestatic=new Societe($db); -$userstatic=new User($db); -$chargestatic=new ChargeSociales($db); -$loanstatic=new Loan($db); -$memberstatic=new Adherent($db); -$paymentstatic=new Paiement($db); -$paymentsupplierstatic=new PaiementFourn($db); -$paymentvatstatic=new TVA($db); -$paymentsalstatic=new PaymentSalary($db); -$paymentvariousstatic=new PaymentVarious($db); -$donstatic=new Don($db); -$paymentexpensereportstatic=new PaymentExpenseReport($db); -$bankstatic=new Account($db); -$banklinestatic=new AccountLine($db); +$banktransferstatic = new BonPrelevement($db); +$societestatic = new Societe($db); +$userstatic = new User($db); +$chargestatic = new ChargeSociales($db); +$loanstatic = new Loan($db); +$memberstatic = new Adherent($db); +$paymentstatic = new Paiement($db); +$paymentsupplierstatic = new PaiementFourn($db); +$paymentvatstatic = new TVA($db); +$paymentsalstatic = new PaymentSalary($db); +$paymentvariousstatic = new PaymentVarious($db); +$donstatic = new Don($db); +$paymentexpensereportstatic = new PaymentExpenseReport($db); +$bankstatic = new Account($db); +$banklinestatic = new AccountLine($db); $now = dol_now(); // Must be before button action -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -if ($id > 0) $param.='&id='.urlencode($id); -if (!empty($ref)) $param.='&ref='.urlencode($ref); -if (!empty($search_ref)) $param.='&search_ref='.urlencode($search_ref); -if (!empty($search_description)) $param.='&search_description='.urlencode($search_description); -if (!empty($search_type)) $param.='&type='.urlencode($search_type); -if (!empty($search_thirdparty)) $param.='&search_thirdparty='.urlencode($search_thirdparty); -if (!empty($search_debit)) $param.='&search_debit='.urlencode($search_debit); -if (!empty($search_credit)) $param.='&search_credit='.urlencode($search_credit); -if (!empty($search_account)) $param.='&search_account='.urlencode($search_account); -if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve); -if ($search_conciliated != '' && $search_conciliated != '-1') $param.='&search_conciliated='.urlencode($search_conciliated); -if ($search_bid > 0) $param.='&search_bid='.urlencode($search_bid); -if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); -if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); -if (dol_strlen($search_dv_start) > 0) $param .= '&search_start_dvmonth=' . GETPOST('search_start_dvmonth', 'int') . '&search_start_dvday=' . GETPOST('search_start_dvday', 'int') . '&search_start_dvyear=' . GETPOST('search_start_dvyear', 'int'); -if (dol_strlen($search_dv_end) > 0) $param .= '&search_end_dvmonth=' . GETPOST('search_end_dvmonth', 'int') . '&search_end_dvday=' . GETPOST('search_end_dvday', 'int') . '&search_end_dvyear=' . GETPOST('search_end_dvyear', 'int'); -if ($search_req_nb) $param.='&req_nb='.urlencode($search_req_nb); -if (GETPOST("search_thirdparty", 'int')) $param.='&thirdparty='.urlencode(GETPOST("search_thirdparty", 'int')); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); -if ($action == 'reconcile') $param.='&action=reconcile'; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($id > 0) $param .= '&id='.urlencode($id); +if (!empty($ref)) $param .= '&ref='.urlencode($ref); +if (!empty($search_ref)) $param .= '&search_ref='.urlencode($search_ref); +if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description); +if (!empty($search_type)) $param .= '&type='.urlencode($search_type); +if (!empty($search_thirdparty)) $param .= '&search_thirdparty='.urlencode($search_thirdparty); +if (!empty($search_debit)) $param .= '&search_debit='.urlencode($search_debit); +if (!empty($search_credit)) $param .= '&search_credit='.urlencode($search_credit); +if (!empty($search_account)) $param .= '&search_account='.urlencode($search_account); +if (!empty($search_num_releve)) $param .= '&search_num_releve='.urlencode($search_num_releve); +if ($search_conciliated != '' && $search_conciliated != '-1') $param .= '&search_conciliated='.urlencode($search_conciliated); +if ($search_bid > 0) $param .= '&search_bid='.urlencode($search_bid); +if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth='.GETPOST('search_start_dtmonth', 'int').'&search_start_dtday='.GETPOST('search_start_dtday', 'int').'&search_start_dtyear='.GETPOST('search_start_dtyear', 'int'); +if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth='.GETPOST('search_end_dtmonth', 'int').'&search_end_dtday='.GETPOST('search_end_dtday', 'int').'&search_end_dtyear='.GETPOST('search_end_dtyear', 'int'); +if (dol_strlen($search_dv_start) > 0) $param .= '&search_start_dvmonth='.GETPOST('search_start_dvmonth', 'int').'&search_start_dvday='.GETPOST('search_start_dvday', 'int').'&search_start_dvyear='.GETPOST('search_start_dvyear', 'int'); +if (dol_strlen($search_dv_end) > 0) $param .= '&search_end_dvmonth='.GETPOST('search_end_dvmonth', 'int').'&search_end_dvday='.GETPOST('search_end_dvday', 'int').'&search_end_dvyear='.GETPOST('search_end_dvyear', 'int'); +if ($search_req_nb) $param .= '&req_nb='.urlencode($search_req_nb); +if (GETPOST("search_thirdparty", 'int')) $param .= '&thirdparty='.urlencode(GETPOST("search_thirdparty", 'int')); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if ($action == 'reconcile') $param .= '&action=reconcile'; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -421,7 +421,7 @@ $options = array(); $buttonreconcile = ''; -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $title = $langs->trans("FinancialAccount").' - '.$langs->trans("Transactions"); $helpurl = ""; @@ -436,7 +436,7 @@ if ($id > 0 || ! empty($ref)) } // Bank card - $head=bank_prepare_head($object); + $head = bank_prepare_head($object); dol_fiche_head($head, 'journal', $langs->trans("FinancialAccount"), 0, 'account'); $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; @@ -471,43 +471,43 @@ else } $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,"; -$sql.= " b.fk_account, b.fk_type,"; -$sql.= " ba.rowid as bankid, ba.ref as bankref,"; -$sql.= " bu.url_id,"; -$sql.= " s.nom, s.name_alias, s.client, s.fournisseur, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; +$sql .= " b.fk_account, b.fk_type,"; +$sql .= " ba.rowid as bankid, ba.ref as bankref,"; +$sql .= " bu.url_id,"; +$sql .= " s.nom, s.name_alias, s.client, s.fournisseur, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " FROM "; -if ($search_bid>0) $sql.= MAIN_DB_PREFIX."bank_class as l,"; -$sql.= " ".MAIN_DB_PREFIX."bank_account as ba,"; -$sql.= " ".MAIN_DB_PREFIX."bank as b"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; -$sql.= " WHERE b.fk_account = ba.rowid"; -$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; -if ($search_account > 0) $sql.=" AND b.fk_account = ".$search_account; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM "; +if ($search_bid > 0) $sql .= MAIN_DB_PREFIX."bank_class as l,"; +$sql .= " ".MAIN_DB_PREFIX."bank_account as ba,"; +$sql .= " ".MAIN_DB_PREFIX."bank as b"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; +$sql .= " WHERE b.fk_account = ba.rowid"; +$sql .= " AND ba.entity IN (".getEntity('bank_account').")"; +if ($search_account > 0) $sql .= " AND b.fk_account = ".$search_account; // Search period criteria -if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'"; -if (dol_strlen($search_dt_end)>0) $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'"; +if (dol_strlen($search_dt_start) > 0) $sql .= " AND b.dateo >= '".$db->idate($search_dt_start)."'"; +if (dol_strlen($search_dt_end) > 0) $sql .= " AND b.dateo <= '".$db->idate($search_dt_end)."'"; // Search period criteria -if (dol_strlen($search_dv_start)>0) $sql .= " AND b.datev >= '" . $db->idate($search_dv_start) . "'"; -if (dol_strlen($search_dv_end)>0) $sql .= " AND b.datev <= '" . $db->idate($search_dv_end) . "'"; -if ($search_ref) $sql.=natural_search("b.rowid", $search_ref, 1); -if ($search_req_nb) $sql.= natural_search("b.num_chq", $search_req_nb); -if ($search_num_releve) $sql.= natural_search("b.num_releve", $search_num_releve); -if ($search_conciliated != '' && $search_conciliated != '-1') $sql.= " AND b.rappro = ".$search_conciliated; -if ($search_thirdparty) $sql.= natural_search("s.nom", $search_thirdparty); +if (dol_strlen($search_dv_start) > 0) $sql .= " AND b.datev >= '".$db->idate($search_dv_start)."'"; +if (dol_strlen($search_dv_end) > 0) $sql .= " AND b.datev <= '".$db->idate($search_dv_end)."'"; +if ($search_ref) $sql .= natural_search("b.rowid", $search_ref, 1); +if ($search_req_nb) $sql .= natural_search("b.num_chq", $search_req_nb); +if ($search_num_releve) $sql .= natural_search("b.num_releve", $search_num_releve); +if ($search_conciliated != '' && $search_conciliated != '-1') $sql .= " AND b.rappro = ".$search_conciliated; +if ($search_thirdparty) $sql .= natural_search("s.nom", $search_thirdparty); if ($search_description) { $search_description_to_use = $search_description; - $arrayoffixedlabels=array( + $arrayoffixedlabels = array( 'payment_salary', 'CustomerInvoicePayment', 'CustomerInvoicePaymentBack', 'SupplierInvoicePayment', 'SupplierInvoicePaymentBack', @@ -517,32 +517,32 @@ if ($search_description) 'SubscriptionPayment', 'WithdrawalPayment' ); - foreach($arrayoffixedlabels as $keyforlabel) + foreach ($arrayoffixedlabels as $keyforlabel) { $translatedlabel = $langs->transnoentitiesnoconv($keyforlabel); if (preg_match('/'.$search_description.'/i', $translatedlabel)) { - $search_description_to_use.="|".$keyforlabel; + $search_description_to_use .= "|".$keyforlabel; } } - $sql.= natural_search("b.label", $search_description_to_use); // Warning some text are just translation keys, not translated strings + $sql .= natural_search("b.label", $search_description_to_use); // Warning some text are just translation keys, not translated strings } -if ($search_bid > 0) $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$search_bid; -if (! empty($search_type)) $sql.= " AND b.fk_type = '".$db->escape($search_type)."' "; +if ($search_bid > 0) $sql .= " AND b.rowid=l.lineid AND l.fk_categ=".$search_bid; +if (!empty($search_type)) $sql .= " AND b.fk_type = '".$db->escape($search_type)."' "; // Search criteria amount $search_debit = price2num(str_replace('-', '', $search_debit)); $search_credit = price2num(str_replace('-', '', $search_credit)); -if ($search_debit) $sql.= natural_search('- b.amount', $search_debit, 1); -if ($search_credit) $sql.= natural_search('b.amount', $search_credit, 1); +if ($search_debit) $sql .= natural_search('- b.amount', $search_debit, 1); +if ($search_credit) $sql .= natural_search('b.amount', $search_credit, 1); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; $nbtotalofpages = 0; @@ -550,10 +550,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - $nbtotalofpages = ceil($nbtotalofrecords/$limit); + $nbtotalofpages = ceil($nbtotalofrecords / $limit); } -if (($id > 0 || ! empty($ref)) && ((string) $page == '')) +if (($id > 0 || !empty($ref)) && ((string) $page == '')) { // We open a list of transaction of a dedicated account and no page was set by defaut // We force on last page. @@ -564,22 +564,22 @@ if (($id > 0 || ! empty($ref)) && ((string) $page == '')) if ($page >= $nbtotalofpages) { // If we made a search and result has low page than the page number we were on - $page = ($nbtotalofpages -1); + $page = ($nbtotalofpages - 1); $offset = $limit * $page; if ($page < 0) $page = 0; } // If not account defined $mode_balance_ok=false -if (empty($search_account)) $mode_balance_ok=false; +if (empty($search_account)) $mode_balance_ok = false; // If a search is done $mode_balance_ok=false -if (! empty($search_ref)) $mode_balance_ok=false; -if (! empty($req_nb)) $mode_balance_ok=false; -if (! empty($search_type)) $mode_balance_ok=false; -if (! empty($debit)) $mode_balance_ok=false; -if (! empty($credit)) $mode_balance_ok=false; -if (! empty($thirdparty)) $mode_balance_ok=false; +if (!empty($search_ref)) $mode_balance_ok = false; +if (!empty($req_nb)) $mode_balance_ok = false; +if (!empty($search_type)) $mode_balance_ok = false; +if (!empty($debit)) $mode_balance_ok = false; +if (!empty($credit)) $mode_balance_ok = false; +if (!empty($thirdparty)) $mode_balance_ok = false; -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; dol_syslog('compta/bank/bankentries_list.php', LOG_DEBUG); $resql = $db->query($sql); @@ -587,21 +587,21 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->bank->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // Confirmation delete if ($action == 'delete') { - $text=$langs->trans('ConfirmDeleteTransaction'); + $text = $langs->trans('ConfirmDeleteTransaction'); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); } @@ -610,7 +610,7 @@ if ($resql) if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; - print '<input type="hidden" name="action" value="'.($action?$action:'search').'">'; + print '<input type="hidden" name="action" value="'.($action ? $action : 'search').'">'; print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; @@ -624,7 +624,7 @@ if ($resql) { print '<div class="valignmiddle inline-block" style="padding-right: 20px;">'; print '<strong>'.$langs->trans("InputReceiptNumber").'</strong>: '; - print '<input class="flat" id="num_releve" name="num_releve" type="text" value="'.(GETPOST('num_releve')?GETPOST('num_releve'):'').'" size="10">'; // The only default value is value we just entered + print '<input class="flat" id="num_releve" name="num_releve" type="text" value="'.(GETPOST('num_releve') ?GETPOST('num_releve') : '').'" size="10">'; // The only default value is value we just entered print '</div>'; if (is_array($options) && count($options)) { @@ -640,31 +640,31 @@ if ($resql) print '</div>'; // Show last bank statements - $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year) - $liste=""; + $nbmax = 15; // We accept to show last 15 receipts (so we can have more than one year) + $liste = ""; $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account=".$object->id." AND num_releve IS NOT NULL"; - $sql.= $db->order("num_releve", "DESC"); - $sql.= $db->plimit($nbmax+1); + $sql .= " WHERE fk_account=".$object->id." AND num_releve IS NOT NULL"; + $sql .= $db->order("num_releve", "DESC"); + $sql .= $db->plimit($nbmax + 1); print '<br>'; print $langs->trans("LastAccountStatements").' : '; - $resqlr=$db->query($sql); + $resqlr = $db->query($sql); if ($resqlr) { - $numr=$db->num_rows($resqlr); - $i=0; - $last_ok=0; + $numr = $db->num_rows($resqlr); + $i = 0; + $last_ok = 0; while (($i < $numr) && ($i < $nbmax)) { $objr = $db->fetch_object($resqlr); - if (! $last_ok) { + if (!$last_ok) { $last_releve = $objr->num_releve; - $last_ok=1; + $last_ok = 1; } $i++; - $liste='<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.$id.'&num='.$objr->num_releve.'">'.$objr->num_releve.'</a>   '.$liste; + $liste = '<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.$id.'&num='.$objr->num_releve.'">'.$objr->num_releve.'</a>   '.$liste; } - if ($numr >= $nbmax) $liste="...   ".$liste; + if ($numr >= $nbmax) $liste = "...   ".$liste; print $liste; if ($numr <= 0) print '<b>'.$langs->trans("None").'</b>'; } @@ -674,11 +674,11 @@ if ($resql) } // Using BANK_REPORT_LAST_NUM_RELEVE to automatically report last num (or not) - if (! empty($conf->global->BANK_REPORT_LAST_NUM_RELEVE)) + if (!empty($conf->global->BANK_REPORT_LAST_NUM_RELEVE)) { print ' <script type="text/javascript"> - $("#num_releve").val("' . $last_releve . '"); + $("#num_releve").val("' . $last_releve.'"); </script> '; } @@ -686,7 +686,7 @@ if ($resql) } // Form to add a transaction with no invoice - if ($user->rights->banque->modifier && $action == 'addline' && ! empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) + if ($user->rights->banque->modifier && $action == 'addline' && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) { print load_fiche_titre($langs->trans("AddBankRecordLong"), '', ''); @@ -723,11 +723,11 @@ if ($resql) } print '</td>'; print '<td class="nowrap">'; - print $form->selectDate(empty($dateop)?-1:$dateop, 'op', 0, 0, 0, 'transaction'); + print $form->selectDate(empty($dateop) ?-1 : $dateop, 'op', 0, 0, 0, 'transaction'); print '</td>'; print '<td> </td>'; print '<td class="nowrap">'; - $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')), 'operation', '1,2', 2, 1); + $form->select_types_paiements((GETPOST('operation') ?GETPOST('operation') : ($object->courant == Account::TYPE_CASH ? 'LIQ' : '')), 'operation', '1,2', 2, 1); print '</td>'; print '<td>'; print '<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST("num_chq", "alpha").'">'; @@ -735,7 +735,7 @@ if ($resql) //if (! $search_account > 0) //{ print '<td class=right>'; - $form->select_comptes(GETPOST('add_account', 'int')?GETPOST('add_account', 'int'):$search_account, 'add_account', 0, '', 1, ($id > 0 || ! empty($ref)?' disabled="disabled"':'')); + $form->select_comptes(GETPOST('add_account', 'int') ?GETPOST('add_account', 'int') : $search_account, 'add_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : '')); print '</td>'; //} print '<td class="right"><input name="adddebit" class="flat" type="text" size="4" value="'.GETPOST("adddebit", "alpha").'"></td>'; @@ -778,7 +778,7 @@ if ($resql) $i = 0; // Title - $bankcateg=new BankCateg($db); + $bankcateg = new BankCateg($db); $newcardbutton = ''; if ($action != 'addline' && $action != 'reconcile') @@ -800,63 +800,63 @@ if ($resql) } } - $morehtml='<div class="inline-block '.(($buttonreconcile || $newcardbutton)?'marginrightonly':'').'">'; - $morehtml.= '<label for="pageplusone">'.$langs->trans("Page")."</label> "; // ' Page '; - $morehtml.='<input type="text" name="pageplusone" id="pageplusone" class="flat right width25" value="'.($page+1).'">'; - $morehtml.='/'.$nbtotalofpages.' '; - $morehtml.='</div>'; + $morehtml = '<div class="inline-block '.(($buttonreconcile || $newcardbutton) ? 'marginrightonly' : '').'">'; + $morehtml .= '<label for="pageplusone">'.$langs->trans("Page")."</label> "; // ' Page '; + $morehtml .= '<input type="text" name="pageplusone" id="pageplusone" class="flat right width25" value="'.($page + 1).'">'; + $morehtml .= '/'.$nbtotalofpages.' '; + $morehtml .= '</div>'; if ($action != 'addline' && $action != 'reconcile') { - $morehtml.=$buttonreconcile; + $morehtml .= $buttonreconcile; } - $morehtml.=$newcardbutton; + $morehtml .= $newcardbutton; - $picto='title_bank'; - if ($id > 0 || ! empty($ref)) $picto=''; + $picto = 'title_bank'; + if ($id > 0 || !empty($ref)) $picto = ''; print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit); // We can add page now to param - if ($page != '') $param.='&page='.urlencode($page); + if ($page != '') $param .= '&page='.urlencode($page); $moreforfilter = ''; - $moreforfilter.='<div class="divsearchfield">'; + $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('DateOperationShort').' : '; - $moreforfilter .= '<div class="nowrap'.($conf->browser->layout=='phone'?' centpercent':'').' inline-block">'.$langs->trans('From') . ' '; + $moreforfilter .= '<div class="nowrap'.($conf->browser->layout == 'phone' ? ' centpercent' : '').' inline-block">'.$langs->trans('From').' '; $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0).'</div>'; //$moreforfilter .= ' - '; - $moreforfilter .= '<div class="nowrap'.($conf->browser->layout=='phone'?' centpercent':'').' inline-block">'.$langs->trans('to') . ' ' . $form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0).'</div>'; + $moreforfilter .= '<div class="nowrap'.($conf->browser->layout == 'phone' ? ' centpercent' : '').' inline-block">'.$langs->trans('to').' '.$form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0).'</div>'; $moreforfilter .= '</div>'; - $moreforfilter.='<div class="divsearchfield">'; + $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('DateValueShort').' : '; - $moreforfilter .= '<div class="nowrap'.($conf->browser->layout=='phone'?' centpercent':'').' inline-block">'.$langs->trans('From') . ' '; + $moreforfilter .= '<div class="nowrap'.($conf->browser->layout == 'phone' ? ' centpercent' : '').' inline-block">'.$langs->trans('From').' '; $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0).'</div>'; //$moreforfilter .= ' - '; - $moreforfilter .= '<div class="nowrap'.($conf->browser->layout=='phone'?' centpercent':'').' inline-block">'.$langs->trans('to') . ' ' . $form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0).'</div>'; + $moreforfilter .= '<div class="nowrap'.($conf->browser->layout == 'phone' ? ' centpercent' : '').' inline-block">'.$langs->trans('to').' '.$form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0).'</div>'; $moreforfilter .= '</div>'; - if (! empty($conf->categorie->enabled)) + if (!empty($conf->categorie->enabled)) { // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { $langs->load('categories'); // Bank line - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('RubriquesTransactions').' : '; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('RubriquesTransactions').' : '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_bid', $cate_arbo, $search_bid, 1); - $moreforfilter.='</div>'; + $moreforfilter .= $form->selectarray('search_bid', $cate_arbo, $search_bid, 1); + $moreforfilter .= '</div>'; } } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; @@ -957,39 +957,39 @@ if ($resql) print '<td class="liste_titre" align="middle">'; print '</td>'; print '<td class="liste_titre" align="middle">'; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print '</td>'; print "</tr>\n"; // Fields title print '<tr class="liste_titre">'; - if (! empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'], $_SERVER['PHP_SELF'], 'b.rowid', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER['PHP_SELF'], 'b.label', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['b.dateo']['checked'])) print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, '', $sortfield, $sortorder, "center "); - if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'], $_SERVER['PHP_SELF'], 'b.datev,b.dateo,b.rowid', '', $param, 'align="center"', $sortfield, $sortorder); - 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, '', $sortfield, $sortorder, "center "); - 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, '', $sortfield, $sortorder); - if (! empty($arrayfields['b.debit']['checked'])) print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right "); - if (! empty($arrayfields['b.credit']['checked'])) print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right "); - if (! empty($arrayfields['balancebefore']['checked'])) print_liste_field_titre($arrayfields['balancebefore']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right "); - if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right "); - if (! empty($arrayfields['b.num_releve']['checked'])) print_liste_field_titre($arrayfields['b.num_releve']['label'], $_SERVER['PHP_SELF'], 'b.num_releve', '', $param, '', $sortfield, $sortorder, "center "); - if (! empty($arrayfields['b.conciliated']['checked'])) print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, '', $sortfield, $sortorder, "center "); + if (!empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'], $_SERVER['PHP_SELF'], 'b.rowid', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER['PHP_SELF'], 'b.label', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['b.dateo']['checked'])) print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, '', $sortfield, $sortorder, "center "); + if (!empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'], $_SERVER['PHP_SELF'], 'b.datev,b.dateo,b.rowid', '', $param, 'align="center"', $sortfield, $sortorder); + 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, '', $sortfield, $sortorder, "center "); + 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, '', $sortfield, $sortorder); + if (!empty($arrayfields['b.debit']['checked'])) print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right "); + if (!empty($arrayfields['b.credit']['checked'])) print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right "); + if (!empty($arrayfields['balancebefore']['checked'])) print_liste_field_titre($arrayfields['balancebefore']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right "); + if (!empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right "); + if (!empty($arrayfields['b.num_releve']['checked'])) print_liste_field_titre($arrayfields['b.num_releve']['label'], $_SERVER['PHP_SELF'], 'b.num_releve', '', $param, '', $sortfield, $sortorder, "center "); + if (!empty($arrayfields['b.conciliated']['checked'])) print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, '', $sortfield, $sortorder, "center "); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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"], "", '', '', 'class="right"', $sortfield, $sortorder, 'maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "</tr>\n"; - $balance = 0; // For balance - $balancebefore = 0; // For balance + $balance = 0; // For balance + $balancebefore = 0; // For balance $balancecalculated = false; $posconciliatecol = 0; $cachebankaccount = array(); @@ -997,15 +997,15 @@ if ($resql) // Loop on each record $sign = 1; - $totalarray=array(); + $totalarray = array(); while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); // If we are in a situation where we need/can show balance, we calculate the start of balance - if (! $balancecalculated && (! empty($arrayfields['balancebefore']['checked']) || ! empty($arrayfields['balance']['checked'])) && $mode_balance_ok) + if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && $mode_balance_ok) { - if (! $search_account) + if (!$search_account) { dol_print_error('', 'account is not defined but $mode_balance_ok is true'); exit; @@ -1014,14 +1014,14 @@ if ($resql) // Loop on each record before $sign = 1; $i = 0; - $sqlforbalance='SELECT SUM(b.amount) as previoustotal'; - $sqlforbalance.= " FROM "; - $sqlforbalance.= " ".MAIN_DB_PREFIX."bank_account as ba,"; - $sqlforbalance.= " ".MAIN_DB_PREFIX."bank as b"; - $sqlforbalance.= " WHERE b.fk_account = ba.rowid"; - $sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sqlforbalance.= " AND b.fk_account = ".$search_account; - $sqlforbalance.= " AND (b.datev < '" . $db->idate($db->jdate($objp->dv)) . "' OR (b.datev = '" . $db->idate($db->jdate($objp->dv)) . "' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))"; + $sqlforbalance = 'SELECT SUM(b.amount) as previoustotal'; + $sqlforbalance .= " FROM "; + $sqlforbalance .= " ".MAIN_DB_PREFIX."bank_account as ba,"; + $sqlforbalance .= " ".MAIN_DB_PREFIX."bank as b"; + $sqlforbalance .= " WHERE b.fk_account = ba.rowid"; + $sqlforbalance .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sqlforbalance .= " AND b.fk_account = ".$search_account; + $sqlforbalance .= " AND (b.datev < '".$db->idate($db->jdate($objp->dv))."' OR (b.datev = '".$db->idate($db->jdate($objp->dv))."' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))"; $resqlforbalance = $db->query($sqlforbalance); //print $sqlforbalance; if ($resqlforbalance) @@ -1043,24 +1043,24 @@ if ($resql) } else dol_print_error($db); - $balancecalculated=true; + $balancecalculated = true; // Output a line with start balance if ($user->rights->banque->consolidate && $action == 'reconcile') { - $tmpnbfieldbeforebalance=0; - $tmpnbfieldafterbalance=0; - $balancefieldfound=0; - foreach($arrayfields as $key => $val) + $tmpnbfieldbeforebalance = 0; + $tmpnbfieldafterbalance = 0; + $balancefieldfound = 0; + foreach ($arrayfields as $key => $val) { if ($key == 'balancebefore' || $key == 'balance') { $balancefieldfound++; continue; } - if (! empty($arrayfields[$key]['checked'])) + if (!empty($arrayfields[$key]['checked'])) { - if (! $balancefieldfound) $tmpnbfieldbeforebalance++; + if (!$balancefieldfound) $tmpnbfieldbeforebalance++; else $tmpnbfieldafterbalance++; } } @@ -1068,13 +1068,13 @@ if ($resql) $element = 'banktransaction'; if (is_array($extrafields->attributes[$element]['label']) && count($extrafields->attributes[$element]['label'])) { - foreach($extrafields->attributes[$element]['label'] as $key => $val) + foreach ($extrafields->attributes[$element]['label'] as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (!empty($arrayfields["ef.".$key]['checked'])) { - if (! empty($arrayfields[$key]['checked'])) + if (!empty($arrayfields[$key]['checked'])) { - if (! $balancefieldfound) $tmpnbfieldbeforebalance++; + if (!$balancefieldfound) $tmpnbfieldbeforebalance++; else $tmpnbfieldafterbalance++; } } @@ -1089,13 +1089,13 @@ if ($resql) print '</td>'; } - if (! empty($arrayfields['balancebefore']['checked'])) + if (!empty($arrayfields['balancebefore']['checked'])) { print '<td class="right">'; print price(price2num($balance, 'MT'), 1, $langs); print '</td>'; } - if (! empty($arrayfields['balance']['checked'])) + if (!empty($arrayfields['balance']['checked'])) { print '<td class="right">'; print price(price2num($balance, 'MT'), 1, $langs); @@ -1120,12 +1120,12 @@ if ($resql) if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { - $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc) + $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc) $balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT'); } else { - $balancebefore = price2num($balance, 'MT'); // balancebefore = balance of previous line (sort is asc) + $balancebefore = price2num($balance, 'MT'); // balancebefore = balance of previous line (sort is asc) $balance = price2num($balance + ($sign * $objp->amount), 'MT'); } @@ -1133,7 +1133,7 @@ if ($resql) { $bankaccounttmp = new Account($db); $bankaccounttmp->fetch($objp->bankid); - $cachebankaccount[$objp->bankid]=$bankaccounttmp; + $cachebankaccount[$objp->bankid] = $bankaccounttmp; $bankaccount = $bankaccounttmp; } else @@ -1149,159 +1149,159 @@ if ($resql) if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR1)) { $color = '#fca955'; } else { - $color = '#' . $conf->global->BANK_COLORIZE_MOVEMENT_COLOR1; + $color = '#'.$conf->global->BANK_COLORIZE_MOVEMENT_COLOR1; } - $backgroundcolor = 'style="background-color: ' . $color . ';"'; + $backgroundcolor = 'style="background-color: '.$color.';"'; } else { if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR2)) { $color = '#7fdb86'; } else { - $color = '#' . $conf->global->BANK_COLORIZE_MOVEMENT_COLOR2; + $color = '#'.$conf->global->BANK_COLORIZE_MOVEMENT_COLOR2; } - $backgroundcolor = 'style="background-color: ' . $color . ';"'; + $backgroundcolor = 'style="background-color: '.$color.';"'; } } print '<tr class="oddeven" '.$backgroundcolor.'>'; // Ref - if (! empty($arrayfields['b.rowid']['checked'])) + if (!empty($arrayfields['b.rowid']['checked'])) { print '<td class="nowrap left">'; print "<a href=\"line.php?rowid=".$objp->rowid.'&save_lastsearch_values=1">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'account', 'class="classfortooltip"').' '.$objp->rowid."</a>   "; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Description - if (! empty($arrayfields['b.label']['checked'])) + if (!empty($arrayfields['b.label']['checked'])) { print "<td>"; //print "<a href=\"line.php?rowid=".$objp->rowid."&account=".$objp->fk_account."\">"; - $reg=array(); - preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthee on tente recherche de traduction - if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); + $reg = array(); + preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthee on tente recherche de traduction + if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) print $langs->trans($reg[1]); else print dol_trunc($objp->label, 40); //print "</a> "; // Add links after description $links = $bankaccountstatic->get_url($objp->rowid); - $cachebankaccount=array(); - foreach($links as $key=>$val) + $cachebankaccount = array(); + foreach ($links as $key=>$val) { - if ($links[$key]['type']=='withdraw') + if ($links[$key]['type'] == 'withdraw') { - $banktransferstatic->id=$links[$key]['url_id']; - $banktransferstatic->ref=$links[$key]['label']; + $banktransferstatic->id = $links[$key]['url_id']; + $banktransferstatic->ref = $links[$key]['label']; print ' '.$banktransferstatic->getNomUrl(0); } - elseif ($links[$key]['type']=='payment') + elseif ($links[$key]['type'] == 'payment') { - $paymentstatic->id=$links[$key]['url_id']; - $paymentstatic->ref=$links[$key]['url_id']; // FIXME This is id, not ref of payment + $paymentstatic->id = $links[$key]['url_id']; + $paymentstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment print ' '.$paymentstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='payment_supplier') + elseif ($links[$key]['type'] == 'payment_supplier') { - $paymentsupplierstatic->id=$links[$key]['url_id']; - $paymentsupplierstatic->ref=$links[$key]['url_id']; // FIXME This is id, not ref of payment + $paymentsupplierstatic->id = $links[$key]['url_id']; + $paymentsupplierstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment print ' '.$paymentsupplierstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='payment_sc') + elseif ($links[$key]['type'] == 'payment_sc') { print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">'; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; //print $langs->trans("SocialContributionPayment"); print '</a>'; } - elseif ($links[$key]['type']=='payment_vat') + elseif ($links[$key]['type'] == 'payment_vat') { - $paymentvatstatic->id=$links[$key]['url_id']; - $paymentvatstatic->ref=$links[$key]['url_id']; + $paymentvatstatic->id = $links[$key]['url_id']; + $paymentvatstatic->ref = $links[$key]['url_id']; print ' '.$paymentvatstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='payment_salary') + elseif ($links[$key]['type'] == 'payment_salary') { - $paymentsalstatic->id=$links[$key]['url_id']; - $paymentsalstatic->ref=$links[$key]['url_id']; + $paymentsalstatic->id = $links[$key]['url_id']; + $paymentsalstatic->ref = $links[$key]['url_id']; print ' '.$paymentsalstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='payment_loan') + elseif ($links[$key]['type'] == 'payment_loan') { print '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$links[$key]['url_id'].'">'; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; print '</a>'; } - elseif ($links[$key]['type']=='payment_donation') + elseif ($links[$key]['type'] == 'payment_donation') { print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$links[$key]['url_id'].'">'; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; print '</a>'; } - elseif ($links[$key]['type']=='payment_expensereport') + elseif ($links[$key]['type'] == 'payment_expensereport') { - $paymentexpensereportstatic->id=$links[$key]['url_id']; - $paymentexpensereportstatic->ref=$links[$key]['url_id']; + $paymentexpensereportstatic->id = $links[$key]['url_id']; + $paymentexpensereportstatic->ref = $links[$key]['url_id']; print ' '.$paymentexpensereportstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='payment_various') + elseif ($links[$key]['type'] == 'payment_various') { - $paymentvariousstatic->id=$links[$key]['url_id']; - $paymentvariousstatic->ref=$links[$key]['url_id']; + $paymentvariousstatic->id = $links[$key]['url_id']; + $paymentvariousstatic->ref = $links[$key]['url_id']; print ' '.$paymentvariousstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='banktransfert') + elseif ($links[$key]['type'] == 'banktransfert') { // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. if ($objp->amount > 0) { $banklinestatic->fetch($links[$key]['url_id']); - $bankstatic->id=$banklinestatic->fk_account; - $bankstatic->label=$banklinestatic->bank_account_ref; + $bankstatic->id = $banklinestatic->fk_account; + $bankstatic->label = $banklinestatic->bank_account_ref; print ' ('.$langs->trans("TransferFrom").' '; print $bankstatic->getNomUrl(1, 'transactions'); print ' '.$langs->trans("toward").' '; - $bankstatic->id=$objp->bankid; - $bankstatic->label=$objp->bankref; + $bankstatic->id = $objp->bankid; + $bankstatic->label = $objp->bankref; print $bankstatic->getNomUrl(1, ''); print ')'; } else { - $bankstatic->id=$objp->bankid; - $bankstatic->label=$objp->bankref; + $bankstatic->id = $objp->bankid; + $bankstatic->label = $objp->bankref; print ' ('.$langs->trans("TransferFrom").' '; print $bankstatic->getNomUrl(1, ''); print ' '.$langs->trans("toward").' '; $banklinestatic->fetch($links[$key]['url_id']); - $bankstatic->id=$banklinestatic->fk_account; - $bankstatic->label=$banklinestatic->bank_account_ref; + $bankstatic->id = $banklinestatic->fk_account; + $bankstatic->label = $banklinestatic->bank_account_ref; print $bankstatic->getNomUrl(1, 'transactions'); print ')'; } //var_dump($links); } - elseif ($links[$key]['type']=='company') + elseif ($links[$key]['type'] == 'company') { } - elseif ($links[$key]['type']=='user') + elseif ($links[$key]['type'] == 'user') { } - elseif ($links[$key]['type']=='member') + elseif ($links[$key]['type'] == 'member') { } - elseif ($links[$key]['type']=='sc') + elseif ($links[$key]['type'] == 'sc') { } else { // Show link with label $links[$key]['label'] - if (! empty($objp->label) && ! empty($links[$key]['label'])) print ' - '; + if (!empty($objp->label) && !empty($links[$key]['label'])) print ' - '; print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">'; if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { // Label generique car entre parentheses. On l'affiche en le traduisant - if ($reg[1]=='paiement') $reg[1]='Payment'; + if ($reg[1] == 'paiement') $reg[1] = 'Payment'; print ' '.$langs->trans($reg[1]); } else @@ -1312,75 +1312,75 @@ if ($resql) } } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date ope - if (! empty($arrayfields['b.dateo']['checked'])) + if (!empty($arrayfields['b.dateo']['checked'])) { print '<td align="center" class="nowrap">'; print '<span id="dateoperation_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->do), "day")."</span>"; print ' '; print '<span class="inline-block">'; print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=doprev&account='.$objp->bankid.'&rowid='.$objp->rowid.'">'; - print img_edit_remove() . "</a> "; + print img_edit_remove()."</a> "; print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=donext&account='.$objp->bankid.'&rowid='.$objp->rowid.'">'; - print img_edit_add() ."</a>"; + print img_edit_add()."</a>"; print '</span>'; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date value - if (! empty($arrayfields['b.datev']['checked'])) + if (!empty($arrayfields['b.datev']['checked'])) { print '<td align="center" class="nowrap">'; print '<span id="datevalue_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->dv), "day")."</span>"; print ' '; print '<span class="inline-block">'; print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&account='.$objp->bankid.'&rowid='.$objp->rowid.'">'; - print img_edit_remove() . "</a> "; + print img_edit_remove()."</a> "; print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&account='.$objp->bankid.'&rowid='.$objp->rowid.'">'; - print img_edit_add() ."</a>"; + print img_edit_add()."</a>"; print '</span>'; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Payment type - if (! empty($arrayfields['type']['checked'])) + if (!empty($arrayfields['type']['checked'])) { print '<td align="center" class="nowrap">'; - $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db, $objp->fk_type, 'c_paiement', 'code', 'libelle', '', 1); + $labeltype = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $langs->getLabelFromKey($db, $objp->fk_type, 'c_paiement', 'code', 'libelle', '', 1); if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance"); else print $labeltype; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Num cheque - if (! empty($arrayfields['b.num_chq']['checked'])) + if (!empty($arrayfields['b.num_chq']['checked'])) { - print '<td class="nowrap" align="center">'.($objp->num_chq?$objp->num_chq:"")."</td>\n"; - if (! $i) $totalarray['nbfield']++; + print '<td class="nowrap" align="center">'.($objp->num_chq ? $objp->num_chq : "")."</td>\n"; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['bu.label']['checked'])) + if (!empty($arrayfields['bu.label']['checked'])) { print "<td>"; if ($objp->url_id) { - $companystatic->id=$objp->url_id; - $companystatic->name=$objp->nom; - $companystatic->name_alias=$objp->name_alias; - $companystatic->client=$objp->client; - $companystatic->email=$objp->email; - $companystatic->fournisseur=$objp->fournisseur; - $companystatic->code_client=$objp->code_client; - $companystatic->code_fournisseur=$objp->code_fournisseur; - $companystatic->code_compta=$objp->code_compta; - $companystatic->code_compta_fournisseur=$objp->code_compta_fournisseur; + $companystatic->id = $objp->url_id; + $companystatic->name = $objp->nom; + $companystatic->name_alias = $objp->name_alias; + $companystatic->client = $objp->client; + $companystatic->email = $objp->email; + $companystatic->fournisseur = $objp->fournisseur; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->code_compta = $objp->code_compta; + $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; print $companystatic->getNomUrl(1); } else @@ -1388,20 +1388,20 @@ if ($resql) print ' '; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Bank account - if (! empty($arrayfields['ba.ref']['checked'])) + if (!empty($arrayfields['ba.ref']['checked'])) { print '<td class="nowrap">'; print $bankaccount->getNomUrl(1); print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Debit - if (! empty($arrayfields['b.debit']['checked'])) + if (!empty($arrayfields['b.debit']['checked'])) { print '<td class="nowrap right">'; if ($objp->amount < 0) @@ -1410,12 +1410,12 @@ if ($resql) $totalarray['totaldeb'] += $objp->amount; } print "</td>\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield']; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['totaldebfield'] = $totalarray['nbfield']; } // Credit - if (! empty($arrayfields['b.credit']['checked'])) + if (!empty($arrayfields['b.credit']['checked'])) { print '<td class="nowrap right">'; if ($objp->amount > 0) @@ -1424,12 +1424,12 @@ if ($resql) $totalarray['totalcred'] += $objp->amount; } print "</td>\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield']; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['totalcredfield'] = $totalarray['nbfield']; } // Balance before - if (! empty($arrayfields['balancebefore']['checked'])) + if (!empty($arrayfields['balancebefore']['checked'])) { if ($mode_balance_ok) { @@ -1446,10 +1446,10 @@ if ($resql) { print '<td class="right">-</td>'; } - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Balance - if (! empty($arrayfields['balance']['checked'])) + if (!empty($arrayfields['balance']['checked'])) { if ($mode_balance_ok) { @@ -1466,10 +1466,10 @@ if ($resql) { print '<td class="right">-</td>'; } - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['b.num_releve']['checked'])) + if (!empty($arrayfields['b.num_releve']['checked'])) { print '<td class="nowraponall" align="center">'; // Transaction reconciliated or edit link @@ -1479,26 +1479,26 @@ if ($resql) { print '<a href="releve.php?num='.$objp->num_releve.'&account='.$objp->bankid.'&save_lastsearch_values=1">'.$objp->num_releve.'</a>'; } - if (! $objp->conciliated && $action == 'reconcile') + if (!$objp->conciliated && $action == 'reconcile') { if ($objp->num_releve) print ' '; - print '<input class="flat" name="rowid['.$objp->rowid.']" type="checkbox" value="'.$objp->rowid.'" size="1"'.(! empty($_POST['rowid'][$objp->rowid])?' checked':'').'>'; + print '<input class="flat" name="rowid['.$objp->rowid.']" type="checkbox" value="'.$objp->rowid.'" size="1"'.(!empty($_POST['rowid'][$objp->rowid]) ? ' checked' : '').'>'; } } print '</td>'; - if (! $i) + if (!$i) { $totalarray['nbfield']++; $posconciliatecol = $totalarray['nbfield']; } } - if (! empty($arrayfields['b.conciliated']['checked'])) + if (!empty($arrayfields['b.conciliated']['checked'])) { print '<td class="nowraponall" align="center">'; - print $objp->conciliated?$langs->trans("Yes"):$langs->trans("No"); + print $objp->conciliated ? $langs->trans("Yes") : $langs->trans("No"); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action edit/delete @@ -1539,18 +1539,18 @@ if ($resql) } } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Action column print '<td class="nowrap" align="center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "</tr>"; @@ -1561,7 +1561,7 @@ if ($resql) if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield'])) { print '<tr class="liste_total">'; - $i=0; + $i = 0; while ($i < $totalarray['nbfield']) { $i++; @@ -1575,7 +1575,7 @@ if ($resql) elseif ($i == $posconciliatecol) { print '<td class="center">'; - if ($user->rights->banque->consolidate && $action == 'reconcile') print '<input class="button" name="confirm_reconcile" type="submit" value="' . $langs->trans("Conciliate") . '">'; + if ($user->rights->banque->consolidate && $action == 'reconcile') print '<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans("Conciliate").'">'; print '</td>'; } else print '<td></td>'; @@ -1586,9 +1586,9 @@ if ($resql) // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } - print '<tr><td colspan="'.($colspan+1).'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + print '<tr><td colspan="'.($colspan + 1).'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } print "</table>"; diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 7a40d6638ee..c32c11226dd 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -47,22 +47,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","other")); +$langs->loadLangs(array("banks", "other")); -$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'):'cashcontrol'; // 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') +$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') : 'cashcontrol'; // 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') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -74,22 +74,22 @@ $pagenext = $page + 1; //if (! $sortorder) $sortorder="DESC"; // Initialize technical objects -$object=new CashControl($db); +$object = new CashControl($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->monmodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->monmodule->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -98,34 +98,34 @@ if ($user->socid > 0) // Protection if external user //$result = restrictedArea($user, 'monmodule', $id, ''); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -137,11 +137,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -150,24 +150,24 @@ if (empty($reshook)) 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 + 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='CashControl'; - $objectlabel='CashControl'; + $objectclass = 'CashControl'; + $objectlabel = 'CashControl'; $permissiontoread = ($user->rights->cashdesk->use || $user->rights->takepos->use); $permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use); @@ -181,49 +181,49 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_pos_cash_fence|FR:Module_pos_cash_fence_FR|ES:Módulo_pos_cash_fence"; -$help_url=''; +$help_url = ''; $title = $langs->trans('CashControl'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) +if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -241,7 +241,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -262,10 +262,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -275,7 +275,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -304,27 +304,27 @@ jQuery(document).ready(function() { }); </script>'; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -343,16 +343,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle' print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cash-register', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendCashControlRef"; -$modelmail="cashcontrol"; -$objecttmp=new CashControl($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendCashControlRef"; +$modelmail = "cashcontrol"; +$objecttmp = new CashControl($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; @@ -360,39 +360,39 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'">'; + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; print '</td>'; @@ -402,12 +402,12 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$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 '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -416,79 +416,79 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; print '</tr>'."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print '<tr class="oddeven">'; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print '</td>'; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -496,19 +496,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="nowrap" align="center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'; @@ -522,15 +522,15 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -540,19 +540,19 @@ print '</form>'."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->monmodule->read; - $delallowed=$user->rights->monmodule->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->monmodule->read; + $delallowed = $user->rights->monmodule->create; print $formfile->showdocuments('massfilesarea_monmodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 408ce2c1303..8482ede3c3a 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -42,27 +42,27 @@ class FactureRec extends CommonInvoice /** * @var string ID to identify managed object */ - public $element='facturerec'; + public $element = 'facturerec'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='facture_rec'; + public $table_element = 'facture_rec'; /** * @var int Name of subtable line */ - public $table_element_line='facturedet_rec'; + public $table_element_line = 'facturedet_rec'; /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element='fk_facture'; + public $fk_element = 'fk_facture'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='bill'; + public $picto = 'bill'; /** * @var int Entity @@ -89,9 +89,9 @@ class FactureRec extends CommonInvoice public $rang; public $special_code; - public $usenewprice=0; + public $usenewprice = 0; - public $suspended; // status + public $suspended; // status const STATUS_NOTSUSPENDED = 0; const STATUS_SUSPENDED = 1; @@ -119,96 +119,96 @@ class FactureRec extends CommonInvoice { global $conf; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Clean parameters - $this->titre=trim($this->titre); // deprecated - $this->title=trim($this->title); - $this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice; - if (empty($this->suspended)) $this->suspended=0; + $this->titre = trim($this->titre); // deprecated + $this->title = trim($this->title); + $this->usenewprice = empty($this->usenewprice) ? 0 : $this->usenewprice; + if (empty($this->suspended)) $this->suspended = 0; // No frequency defined then no next date to execution if (empty($this->frequency)) { - $this->frequency=0; - $this->date_when=null; + $this->frequency = 0; + $this->date_when = null; } - $this->frequency=abs($this->frequency); - $this->nb_gen_done=0; - $this->nb_gen_max=empty($this->nb_gen_max)?0:$this->nb_gen_max; - $this->auto_validate=empty($this->auto_validate)?0:$this->auto_validate; - $this->generate_pdf = empty($this->generate_pdf)?0:$this->generate_pdf; + $this->frequency = abs($this->frequency); + $this->nb_gen_done = 0; + $this->nb_gen_max = empty($this->nb_gen_max) ? 0 : $this->nb_gen_max; + $this->auto_validate = empty($this->auto_validate) ? 0 : $this->auto_validate; + $this->generate_pdf = empty($this->generate_pdf) ? 0 : $this->generate_pdf; $this->db->begin(); // Charge facture modele - $facsrc=new Facture($this->db); - $result=$facsrc->fetch($facid); + $facsrc = new Facture($this->db); + $result = $facsrc->fetch($facid); if ($result > 0) { // On positionne en mode brouillon la facture $this->brouillon = 1; $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec ("; - $sql.= "titre"; - $sql.= ", fk_soc"; - $sql.= ", entity"; - $sql.= ", datec"; - $sql.= ", amount"; - $sql.= ", remise"; - $sql.= ", note_private"; - $sql.= ", note_public"; - $sql.= ", modelpdf"; - $sql.= ", fk_user_author"; - $sql.= ", fk_projet"; - $sql.= ", fk_account"; - $sql.= ", fk_cond_reglement"; - $sql.= ", fk_mode_reglement"; - $sql.= ", usenewprice"; - $sql.= ", frequency"; - $sql.= ", unit_frequency"; - $sql.= ", date_when"; - $sql.= ", date_last_gen"; - $sql.= ", nb_gen_done"; - $sql.= ", nb_gen_max"; - $sql.= ", auto_validate"; - $sql.= ", generate_pdf"; - $sql.= ", fk_multicurrency"; - $sql.= ", multicurrency_code"; - $sql.= ", multicurrency_tx"; - $sql.= ", suspended"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'"; - $sql.= ", ".$facsrc->socid; - $sql.= ", ".$conf->entity; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".(!empty($facsrc->amount)?$facsrc->amount:'0'); - $sql.= ", ".(!empty($facsrc->remise)?$this->remise:'0'); - $sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL"); - $sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL"); - $sql.= ", ".(!empty($this->modelpdf)?("'".$this->db->escape($this->modelpdf)."'"):"NULL"); - $sql.= ", '".$this->db->escape($user->id)."'"; - $sql.= ", ".(! empty($facsrc->fk_project)?"'".$facsrc->fk_project."'":"null"); - $sql.= ", ".(! empty($facsrc->fk_account)?"'".$facsrc->fk_account."'":"null"); - $sql.= ", ".($facsrc->cond_reglement_id > 0 ? $this->db->escape($facsrc->cond_reglement_id) : "null"); - $sql.= ", ".($facsrc->mode_reglement_id > 0 ? $this->db->escape($facsrc->mode_reglement_id) : "null"); - $sql.= ", ".$this->usenewprice; - $sql.= ", ".$this->frequency; - $sql.= ", '".$this->db->escape($this->unit_frequency)."'"; - $sql.= ", ".(!empty($this->date_when)?"'".$this->db->idate($this->date_when)."'":'NULL'); - $sql.= ", ".(!empty($this->date_last_gen)?"'".$this->db->idate($this->date_last_gen)."'":'NULL'); - $sql.= ", ".$this->db->escape($this->nb_gen_done); - $sql.= ", ".$this->db->escape($this->nb_gen_max); - $sql.= ", ".$this->db->escape($this->auto_validate); - $sql.= ", ".$this->db->escape($this->generate_pdf); - $sql.= ", ".$this->db->escape($facsrc->fk_multicurrency); - $sql.= ", '".$this->db->escape($facsrc->multicurrency_code)."'"; - $sql.= ", ".$this->db->escape($facsrc->multicurrency_tx); - $sql.= ", ".$this->db->escape($this->suspended); - $sql.= ")"; + $sql .= "titre"; + $sql .= ", fk_soc"; + $sql .= ", entity"; + $sql .= ", datec"; + $sql .= ", amount"; + $sql .= ", remise"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", modelpdf"; + $sql .= ", fk_user_author"; + $sql .= ", fk_projet"; + $sql .= ", fk_account"; + $sql .= ", fk_cond_reglement"; + $sql .= ", fk_mode_reglement"; + $sql .= ", usenewprice"; + $sql .= ", frequency"; + $sql .= ", unit_frequency"; + $sql .= ", date_when"; + $sql .= ", date_last_gen"; + $sql .= ", nb_gen_done"; + $sql .= ", nb_gen_max"; + $sql .= ", auto_validate"; + $sql .= ", generate_pdf"; + $sql .= ", fk_multicurrency"; + $sql .= ", multicurrency_code"; + $sql .= ", multicurrency_tx"; + $sql .= ", suspended"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'"; + $sql .= ", ".$facsrc->socid; + $sql .= ", ".$conf->entity; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".(!empty($facsrc->amount) ? $facsrc->amount : '0'); + $sql .= ", ".(!empty($facsrc->remise) ? $this->remise : '0'); + $sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL"); + $sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); + $sql .= ", ".(!empty($this->modelpdf) ? ("'".$this->db->escape($this->modelpdf)."'") : "NULL"); + $sql .= ", '".$this->db->escape($user->id)."'"; + $sql .= ", ".(!empty($facsrc->fk_project) ? "'".$facsrc->fk_project."'" : "null"); + $sql .= ", ".(!empty($facsrc->fk_account) ? "'".$facsrc->fk_account."'" : "null"); + $sql .= ", ".($facsrc->cond_reglement_id > 0 ? $this->db->escape($facsrc->cond_reglement_id) : "null"); + $sql .= ", ".($facsrc->mode_reglement_id > 0 ? $this->db->escape($facsrc->mode_reglement_id) : "null"); + $sql .= ", ".$this->usenewprice; + $sql .= ", ".$this->frequency; + $sql .= ", '".$this->db->escape($this->unit_frequency)."'"; + $sql .= ", ".(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL'); + $sql .= ", ".(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL'); + $sql .= ", ".$this->db->escape($this->nb_gen_done); + $sql .= ", ".$this->db->escape($this->nb_gen_max); + $sql .= ", ".$this->db->escape($this->auto_validate); + $sql .= ", ".$this->db->escape($this->generate_pdf); + $sql .= ", ".$this->db->escape($facsrc->fk_multicurrency); + $sql .= ", '".$this->db->escape($facsrc->multicurrency_code)."'"; + $sql .= ", ".$this->db->escape($facsrc->multicurrency_tx); + $sql .= ", ".$this->db->escape($this->suspended); + $sql .= ")"; if ($this->db->query($sql)) { @@ -220,11 +220,11 @@ class FactureRec extends CommonInvoice $this->multicurrency_tx = $facsrc->multicurrency_tx; // Add lines - $num=count($facsrc->lines); + $num = count($facsrc->lines); for ($i = 0; $i < $num; $i++) { $tva_tx = $facsrc->lines[$i]->tva_tx; - if (! empty($facsrc->lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; + if (!empty($facsrc->lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; $result_insert = $this->addline( $facsrc->lines[$i]->desc, @@ -253,24 +253,24 @@ class FactureRec extends CommonInvoice } } - if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) { - foreach($this->linked_objects as $origin => $tmp_origin_id) + foreach ($this->linked_objects as $origin => $tmp_origin_id) { if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) { - foreach($tmp_origin_id as $origin_id) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -279,9 +279,9 @@ class FactureRec extends CommonInvoice { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -300,7 +300,7 @@ class FactureRec extends CommonInvoice } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } @@ -327,27 +327,27 @@ class FactureRec extends CommonInvoice $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET"; - $sql.= " fk_soc = ".$this->fk_soc; + $sql .= " fk_soc = ".$this->fk_soc; // TODO Add missing fields - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BILLREC_UPDATE', $user); + $result = $this->call_trigger('BILLREC_UPDATE', $user); if ($result < 0) { $this->db->rollback(); @@ -360,7 +360,7 @@ class FactureRec extends CommonInvoice } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } @@ -378,25 +378,25 @@ class FactureRec extends CommonInvoice public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '') { $sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc'; - $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; - $sql.= ', f.date_lim_reglement as dlr'; - $sql.= ', f.note_private, f.note_public, f.fk_user_author'; - $sql.= ', f.modelpdf'; - $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project'; - $sql.= ', f.fk_account'; - $sql.= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate'; - $sql.= ', f.generate_pdf'; - $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; - $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; - $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; + $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; + $sql .= ', f.date_lim_reglement as dlr'; + $sql .= ', f.note_private, f.note_public, f.fk_user_author'; + $sql .= ', f.modelpdf'; + $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project'; + $sql .= ', f.fk_account'; + $sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate'; + $sql .= ', f.generate_pdf'; + $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; //$sql.= ', el.fk_source'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; - $sql.= ' WHERE f.entity IN ('.getEntity('invoice').')'; - if ($rowid) $sql.= ' AND f.rowid='.$rowid; - elseif ($ref) $sql.= " AND f.titre='".$this->db->escape($ref)."'"; + $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; + if ($rowid) $sql .= ' AND f.rowid='.$rowid; + elseif ($ref) $sql .= " AND f.titre='".$this->db->escape($ref)."'"; /* This field are not used for template invoice if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; @@ -411,7 +411,7 @@ class FactureRec extends CommonInvoice $this->id = $obj->rowid; $this->entity = $obj->entity; - $this->titre = $obj->title; // deprecated + $this->titre = $obj->title; // deprecated $this->title = $obj->title; $this->ref = $obj->title; $this->ref_client = $obj->ref_client; @@ -447,23 +447,23 @@ class FactureRec extends CommonInvoice $this->note_public = $obj->note_public; $this->user_author = $obj->fk_user_author; $this->modelpdf = $obj->modelpdf; - $this->rang = $obj->rang; - $this->special_code = $obj->special_code; + $this->rang = $obj->rang; + $this->special_code = $obj->special_code; $this->frequency = $obj->frequency; - $this->unit_frequency = $obj->unit_frequency; + $this->unit_frequency = $obj->unit_frequency; $this->date_when = $this->db->jdate($obj->date_when); - $this->date_last_gen = $this->db->jdate($obj->date_last_gen); + $this->date_last_gen = $this->db->jdate($obj->date_last_gen); $this->nb_gen_done = $obj->nb_gen_done; - $this->nb_gen_max = $obj->nb_gen_max; + $this->nb_gen_max = $obj->nb_gen_max; $this->usenewprice = $obj->usenewprice; - $this->auto_validate = $obj->auto_validate; - $this->generate_pdf = $obj->generate_pdf; + $this->auto_validate = $obj->auto_validate; + $this->generate_pdf = $obj->generate_pdf; // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_code = $obj->multicurrency_code; $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; @@ -476,24 +476,24 @@ class FactureRec extends CommonInvoice /* * Lines */ - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -3; } return 1; } else { - $this->error='Bill with id '.$rowid.' or ref '.$ref.' not found sql='.$sql; + $this->error = 'Bill with id '.$rowid.' or ref '.$ref.' not found sql='.$sql; dol_syslog('Facture::Fetch Error '.$this->error, LOG_ERR); return -2; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -521,31 +521,31 @@ class FactureRec extends CommonInvoice global $extrafields; // phpcs:enable - $this->lines=array(); + $this->lines = array(); // Retreive all extrafield for line // fetch optionals attributes and labels - if (! is_object($extrafields)) + if (!is_object($extrafields)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); + $extrafields = new ExtraFields($this->db); } $extrafields->fetch_name_optionals_label($this->table_element_line, true); $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, '; - $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; - $sql.= ' l.info_bits, l.date_start_fill, l.date_end_fill, l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; + $sql .= ' l.info_bits, l.date_start_fill, l.date_end_fill, l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; //$sql.= ' l.situation_percent, l.fk_prev_id,'; //$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; - $sql.= ' l.rang, l.special_code,'; + $sql .= ' l.rang, l.special_code,'; //$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; - $sql.= ' l.fk_unit, l.fk_contract_line,'; - $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; - $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql.= ' WHERE l.fk_facture = '.$this->id; - $sql.= ' ORDER BY l.rang'; + $sql .= ' l.fk_unit, l.fk_contract_line,'; + $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; + $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql .= ' WHERE l.fk_facture = '.$this->id; + $sql .= ' ORDER BY l.rang'; dol_syslog('FactureRec::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); @@ -558,21 +558,21 @@ class FactureRec extends CommonInvoice $objp = $this->db->fetch_object($result); $line = new FactureLigneRec($this->db); - $line->id = $objp->rowid; - $line->rowid = $objp->rowid; - $line->desc = $objp->description; // Description line - $line->description = $objp->description; // Description line - $line->product_type = $objp->product_type; // Type of line - $line->ref = $objp->product_ref; // Ref product - $line->product_ref = $objp->product_ref; // Ref product - $line->libelle = $objp->product_label; // deprecated - $line->product_label = $objp->product_label; // Label product - $line->product_desc = $objp->product_desc; // Description product - $line->fk_product_type = $objp->fk_product_type; // Type of product + $line->id = $objp->rowid; + $line->rowid = $objp->rowid; + $line->desc = $objp->description; // Description line + $line->description = $objp->description; // Description line + $line->product_type = $objp->product_type; // Type of line + $line->ref = $objp->product_ref; // Ref product + $line->product_ref = $objp->product_ref; // Ref product + $line->libelle = $objp->product_label; // deprecated + $line->product_label = $objp->product_label; // Label product + $line->product_desc = $objp->product_desc; // Description product + $line->fk_product_type = $objp->fk_product_type; // Type of product $line->qty = $objp->qty; $line->subprice = $objp->subprice; - $line->label = $objp->custom_label; // @deprecated + $line->label = $objp->custom_label; // @deprecated $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; @@ -590,14 +590,14 @@ class FactureRec extends CommonInvoice $line->total_tva = $objp->total_tva; $line->total_ttc = $objp->total_ttc; $line->code_ventilation = $objp->fk_code_ventilation; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; $line->marge_tx = $marginInfos[1]; $line->marque_tx = $marginInfos[2]; - $line->rang = $objp->rang; - $line->special_code = $objp->special_code; - $line->fk_unit = $objp->fk_unit; + $line->rang = $objp->rang; + $line->special_code = $objp->special_code; + $line->fk_unit = $objp->fk_unit; $line->fk_contract_line = $objp->fk_contract_line; // Ne plus utiliser @@ -607,8 +607,8 @@ class FactureRec extends CommonInvoice $line->fetch_optionals($line->id); // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; $line->multicurrency_subprice = $objp->multicurrency_subprice; $line->multicurrency_total_ht = $objp->multicurrency_total_ht; $line->multicurrency_total_tva = $objp->multicurrency_total_tva; @@ -624,7 +624,7 @@ class FactureRec extends CommonInvoice } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -3; } } @@ -640,11 +640,11 @@ class FactureRec extends CommonInvoice */ public function delete(User $user, $notrigger = 0, $idwarehouse = -1) { - $rowid=$this->id; + $rowid = $this->id; dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); - $error=0; + $error = 0; $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid; @@ -657,21 +657,21 @@ class FactureRec extends CommonInvoice { // Delete linked object $res = $this->deleteObjectLinked(); - if ($res < 0) $error=-3; + if ($res < 0) $error = -3; } else { - $this->error=$this->db->lasterror(); - $error=-1; + $this->error = $this->db->lasterror(); + $error = -1; } } else { - $this->error=$this->db->lasterror(); - $error=-2; + $this->error = $this->db->lasterror(); + $error = -2; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -715,7 +715,7 @@ class FactureRec extends CommonInvoice { global $mysoc; - $facid=$this->id; + $facid = $this->id; dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit,pu_ht_devise=$pu_ht_devise,date_start_fill=$date_start_fill,date_end_fill=$date_end_fill,pa_ht=$pa_ht", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -723,39 +723,39 @@ class FactureRec extends CommonInvoice // Check parameters if ($type < 0) return -1; - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } if ($this->brouillon) { // Clean parameters - $remise_percent=price2num($remise_percent); - if (empty($remise_percent)) $remise_percent=0; - $qty=price2num($qty); + $remise_percent = price2num($remise_percent); + if (empty($remise_percent)) $remise_percent = 0; + $qty = price2num($qty); $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); $txtva = price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - if (empty($txtva)) $txtva=0; - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; - if (empty($info_bits)) $info_bits=0; + if (empty($txtva)) $txtva = 0; + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; + if (empty($info_bits)) $info_bits = 0; - if ($price_base_type=='HT') + if ($price_base_type == 'HT') { - $pu=$pu_ht; + $pu = $pu_ht; } else { - $pu=$pu_ttc; + $pu = $pu_ttc; } // Calcul du total TTC et de la TVA pour la ligne a partir de @@ -763,12 +763,12 @@ class FactureRec extends CommonInvoice // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; - $total_localtax1=$tabprice[9]; - $total_localtax2=$tabprice[10]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; $pu_ht = $tabprice[3]; // MultiCurrency @@ -777,94 +777,94 @@ class FactureRec extends CommonInvoice $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; - $product_type=$type; + $product_type = $type; if ($fk_product) { - $product=new Product($this->db); - $result=$product->fetch($fk_product); - $product_type=$product->type; + $product = new Product($this->db); + $result = $product->fetch($fk_product); + $product_type = $product->type; } $sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet_rec ("; - $sql.= "fk_facture"; - $sql.= ", label"; - $sql.= ", description"; - $sql.= ", price"; - $sql.= ", qty"; - $sql.= ", tva_tx"; - $sql.= ", vat_src_code"; - $sql.= ", localtax1_tx"; - $sql.= ", localtax1_type"; - $sql.= ", localtax2_tx"; - $sql.= ", localtax2_type"; - $sql.= ", fk_product"; - $sql.= ", product_type"; - $sql.= ", remise_percent"; - $sql.= ", subprice"; - $sql.= ", remise"; - $sql.= ", total_ht"; - $sql.= ", total_tva"; - $sql.= ", total_localtax1"; - $sql.= ", total_localtax2"; - $sql.= ", total_ttc"; - $sql.= ", date_start_fill"; - $sql.= ", date_end_fill"; - $sql.= ", fk_product_fournisseur_price"; - $sql.= ", buy_price_ht"; - $sql.= ", info_bits"; - $sql.= ", rang"; - $sql.= ", special_code"; - $sql.= ", fk_unit"; - $sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; - $sql.= ") VALUES ("; - $sql.= "'".$facid."'"; - $sql.= ", ".(! empty($label)?"'".$this->db->escape($label)."'":"null"); - $sql.= ", '".$this->db->escape($desc)."'"; - $sql.= ", ".price2num($pu_ht); - $sql.= ", ".price2num($qty); - $sql.= ", ".price2num($txtva); - $sql.= ", '".$this->db->escape($vat_src_code)."'"; - $sql.= ", ".price2num($txlocaltax1); - $sql.= ", '".$this->db->escape($localtaxes_type[0])."'"; - $sql.= ", ".price2num($txlocaltax2); - $sql.= ", '".$this->db->escape($localtaxes_type[2])."'"; - $sql.= ", ".(! empty($fk_product)?"'".$fk_product."'":"null"); - $sql.= ", ".$product_type; - $sql.= ", ".price2num($remise_percent); - $sql.= ", ".price2num($pu_ht); - $sql.= ", null"; - $sql.= ", ".price2num($total_ht); - $sql.= ", ".price2num($total_tva); - $sql.= ", ".price2num($total_localtax1); - $sql.= ", ".price2num($total_localtax2); - $sql.= ", ".price2num($total_ttc); - $sql.= ", ".(int) $date_start_fill; - $sql.= ", ".(int) $date_end_fill; - $sql.= ", ".($fk_fournprice > 0 ? $fk_fournprice : 'null'); - $sql.= ", ".($pa_ht ? price2num($pa_ht) : 0); - $sql.= ", ".$info_bits; - $sql.= ", ".$rang; - $sql.= ", ".$special_code; - $sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".price2num($pu_ht_devise); - $sql.= ", ".price2num($multicurrency_total_ht); - $sql.= ", ".price2num($multicurrency_total_tva); - $sql.= ", ".price2num($multicurrency_total_ttc); - $sql.= ")"; + $sql .= "fk_facture"; + $sql .= ", label"; + $sql .= ", description"; + $sql .= ", price"; + $sql .= ", qty"; + $sql .= ", tva_tx"; + $sql .= ", vat_src_code"; + $sql .= ", localtax1_tx"; + $sql .= ", localtax1_type"; + $sql .= ", localtax2_tx"; + $sql .= ", localtax2_type"; + $sql .= ", fk_product"; + $sql .= ", product_type"; + $sql .= ", remise_percent"; + $sql .= ", subprice"; + $sql .= ", remise"; + $sql .= ", total_ht"; + $sql .= ", total_tva"; + $sql .= ", total_localtax1"; + $sql .= ", total_localtax2"; + $sql .= ", total_ttc"; + $sql .= ", date_start_fill"; + $sql .= ", date_end_fill"; + $sql .= ", fk_product_fournisseur_price"; + $sql .= ", buy_price_ht"; + $sql .= ", info_bits"; + $sql .= ", rang"; + $sql .= ", special_code"; + $sql .= ", fk_unit"; + $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; + $sql .= ") VALUES ("; + $sql .= "'".$facid."'"; + $sql .= ", ".(!empty($label) ? "'".$this->db->escape($label)."'" : "null"); + $sql .= ", '".$this->db->escape($desc)."'"; + $sql .= ", ".price2num($pu_ht); + $sql .= ", ".price2num($qty); + $sql .= ", ".price2num($txtva); + $sql .= ", '".$this->db->escape($vat_src_code)."'"; + $sql .= ", ".price2num($txlocaltax1); + $sql .= ", '".$this->db->escape($localtaxes_type[0])."'"; + $sql .= ", ".price2num($txlocaltax2); + $sql .= ", '".$this->db->escape($localtaxes_type[2])."'"; + $sql .= ", ".(!empty($fk_product) ? "'".$fk_product."'" : "null"); + $sql .= ", ".$product_type; + $sql .= ", ".price2num($remise_percent); + $sql .= ", ".price2num($pu_ht); + $sql .= ", null"; + $sql .= ", ".price2num($total_ht); + $sql .= ", ".price2num($total_tva); + $sql .= ", ".price2num($total_localtax1); + $sql .= ", ".price2num($total_localtax2); + $sql .= ", ".price2num($total_ttc); + $sql .= ", ".(int) $date_start_fill; + $sql .= ", ".(int) $date_end_fill; + $sql .= ", ".($fk_fournprice > 0 ? $fk_fournprice : 'null'); + $sql .= ", ".($pa_ht ? price2num($pa_ht) : 0); + $sql .= ", ".$info_bits; + $sql .= ", ".$rang; + $sql .= ", ".$special_code; + $sql .= ", ".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".price2num($pu_ht_devise); + $sql .= ", ".price2num($multicurrency_total_ht); + $sql .= ", ".price2num($multicurrency_total_tva); + $sql .= ", ".price2num($multicurrency_total_ttc); + $sql .= ")"; dol_syslog(get_class($this)."::addline", LOG_DEBUG); if ($this->db->query($sql)) { $lineId = $this->db->last_insert_id(MAIN_DB_PREFIX."facturedet_rec"); - $this->id=$facid; + $this->id = $facid; $this->update_price(); return $lineId; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -903,7 +903,7 @@ class FactureRec extends CommonInvoice { global $mysoc; - $facid=$this->id; + $facid = $this->id; dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -917,53 +917,53 @@ class FactureRec extends CommonInvoice if ($this->brouillon) { // Clean parameters - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - if (empty($info_bits)) $info_bits=0; + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + if (empty($info_bits)) $info_bits = 0; $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); - $pu_ht_devise = price2num($pu_ht_devise); - $txtva=price2num($txtva); + $pu_ht_devise = price2num($pu_ht_devise); + $txtva = price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; - if ($price_base_type=='HT') + if ($price_base_type == 'HT') { - $pu=$pu_ht; + $pu = $pu_ht; } else { - $pu=$pu_ttc; + $pu = $pu_ttc; } // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; - $total_localtax1=$tabprice[9]; - $total_localtax2=$tabprice[10]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; $pu_ht = $tabprice[3]; $pu_tva = $tabprice[4]; $pu_ttc = $tabprice[5]; @@ -974,59 +974,59 @@ class FactureRec extends CommonInvoice $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; - $product_type=$type; + $product_type = $type; if ($fk_product) { - $product=new Product($this->db); - $result=$product->fetch($fk_product); - $product_type=$product->type; + $product = new Product($this->db); + $result = $product->fetch($fk_product); + $product_type = $product->type; } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; - $sql.= "fk_facture = '".$facid."'"; - $sql.= ", label=".(! empty($label)?"'".$this->db->escape($label)."'":"null"); - $sql.= ", description='".$this->db->escape($desc)."'"; - $sql.= ", price=".price2num($pu_ht); - $sql.= ", qty=".price2num($qty); - $sql.= ", tva_tx=".price2num($txtva); - $sql.= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; - $sql.= ", localtax1_tx=".$txlocaltax1; - $sql.= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; - $sql.= ", localtax2_tx=".$txlocaltax2; - $sql.= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; - $sql.= ", fk_product=".(! empty($fk_product)?"'".$fk_product."'":"null"); - $sql.= ", product_type=".$product_type; - $sql.= ", remise_percent='".price2num($remise_percent)."'"; - $sql.= ", subprice='".price2num($pu_ht)."'"; - $sql.= ", total_ht='".price2num($total_ht)."'"; - $sql.= ", total_tva='".price2num($total_tva)."'"; - $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; - $sql.= ", total_localtax2='".price2num($total_localtax2)."'"; - $sql.= ", total_ttc='".price2num($total_ttc)."'"; - $sql.= ", date_start_fill=".((int) $date_start_fill); - $sql.= ", date_end_fill=".((int) $date_end_fill); - $sql.= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null'); - $sql.= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0); - $sql.= ", info_bits=".$info_bits; - $sql.= ", rang=".$rang; - $sql.= ", special_code=".$special_code; - $sql.= ", fk_unit=".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); - $sql.= ', multicurrency_subprice = '.$pu_ht_devise; - $sql.= ', multicurrency_total_ht = '.$multicurrency_total_ht; - $sql.= ', multicurrency_total_tva = '.$multicurrency_total_tva; - $sql.= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; - $sql.= " WHERE rowid = ".$rowid; + $sql .= "fk_facture = '".$facid."'"; + $sql .= ", label=".(!empty($label) ? "'".$this->db->escape($label)."'" : "null"); + $sql .= ", description='".$this->db->escape($desc)."'"; + $sql .= ", price=".price2num($pu_ht); + $sql .= ", qty=".price2num($qty); + $sql .= ", tva_tx=".price2num($txtva); + $sql .= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; + $sql .= ", localtax1_tx=".$txlocaltax1; + $sql .= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; + $sql .= ", localtax2_tx=".$txlocaltax2; + $sql .= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; + $sql .= ", fk_product=".(!empty($fk_product) ? "'".$fk_product."'" : "null"); + $sql .= ", product_type=".$product_type; + $sql .= ", remise_percent='".price2num($remise_percent)."'"; + $sql .= ", subprice='".price2num($pu_ht)."'"; + $sql .= ", total_ht='".price2num($total_ht)."'"; + $sql .= ", total_tva='".price2num($total_tva)."'"; + $sql .= ", total_localtax1='".price2num($total_localtax1)."'"; + $sql .= ", total_localtax2='".price2num($total_localtax2)."'"; + $sql .= ", total_ttc='".price2num($total_ttc)."'"; + $sql .= ", date_start_fill=".((int) $date_start_fill); + $sql .= ", date_end_fill=".((int) $date_end_fill); + $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null'); + $sql .= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0); + $sql .= ", info_bits=".$info_bits; + $sql .= ", rang=".$rang; + $sql .= ", special_code=".$special_code; + $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); + $sql .= ', multicurrency_subprice = '.$pu_ht_devise; + $sql .= ', multicurrency_total_ht = '.$multicurrency_total_ht; + $sql .= ', multicurrency_total_tva = '.$multicurrency_total_tva; + $sql .= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; + $sql .= " WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::updateline", LOG_DEBUG); if ($this->db->query($sql)) { - $this->id=$facid; + $this->id = $facid; $this->update_price(); return 1; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1065,7 +1065,7 @@ class FactureRec extends CommonInvoice public function strikeIfMaxNbGenReached($ret) { // Special case to strike the date - return ($this->isMaxNbGenReached()?'<strike>':'').$ret.($this->isMaxNbGenReached()?'</strike>':''); + return ($this->isMaxNbGenReached() ? '<strike>' : '').$ret.($this->isMaxNbGenReached() ? '</strike>' : ''); } /** @@ -1082,27 +1082,27 @@ class FactureRec extends CommonInvoice { global $conf, $langs, $db, $user, $hookmanager; - $error=0; - $nb_create=0; + $error = 0; + $nb_create = 0; // Load translation files required by the page - $langs->loadLangs(array("main","bills")); + $langs->loadLangs(array("main", "bills")); $now = dol_now(); - $tmparray=dol_getdate($now); - $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day + $tmparray = dol_getdate($now); + $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day dol_syslog("createRecurringInvoices restrictioninvoiceid=".$restrictioninvoiceid." forcevalidation=".$forcevalidation); $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_rec'; - $sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency - $sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')"; - $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; - $sql.= ' AND suspended = 0'; - $sql.= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here + $sql .= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency + $sql .= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')"; + $sql .= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; + $sql .= ' AND suspended = 0'; + $sql .= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here if ($restrictioninvoiceid > 0) - $sql.=' AND rowid = '.$restrictioninvoiceid; - $sql.= $db->order('entity', 'ASC'); + $sql .= ' AND rowid = '.$restrictioninvoiceid; + $sql .= $db->order('entity', 'ASC'); //print $sql;exit; $parameters = array( 'restrictioninvoiceid' => $restrictioninvoiceid, @@ -1113,13 +1113,13 @@ class FactureRec extends CommonInvoice $resql = $db->query($sql); if ($resql) { - $i=0; + $i = 0; $num = $db->num_rows($resql); if ($num) - $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; + $this->output .= $langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; else - $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); + $this->output .= $langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); $saventity = $conf->entity; @@ -1143,12 +1143,12 @@ class FactureRec extends CommonInvoice dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); $facture = new Facture($db); - $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice - $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice + $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice + $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice $facture->type = self::TYPE_STANDARD; $facture->brouillon = 1; - $facture->date = (empty($facturerec->date_when)?$now:$facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. + $facture->date = (empty($facturerec->date_when) ? $now : $facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; $invoiceidgenerated = $facture->create($user); @@ -1158,7 +1158,7 @@ class FactureRec extends CommonInvoice $this->error = $facture->error; $error++; } - if (! $error && ($facturerec->auto_validate || $forcevalidation)) + if (!$error && ($facturerec->auto_validate || $forcevalidation)) { $result = $facture->validate($user); if ($result <= 0) @@ -1168,7 +1168,7 @@ class FactureRec extends CommonInvoice $error++; } } - if (! $error && $facturerec->generate_pdf) + if (!$error && $facturerec->generate_pdf) { // We refresh the object in order to have all necessary data (like date_lim_reglement) $facture->fetch($facture->id); @@ -1184,17 +1184,17 @@ class FactureRec extends CommonInvoice else { $error++; - $this->error="Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity."\n"; - $this->errors[]="Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity; + $this->error = "Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity."\n"; + $this->errors[] = "Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity; dol_syslog("createRecurringInvoices Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity); } - if (! $error && $invoiceidgenerated >= 0) + if (!$error && $invoiceidgenerated >= 0) { $db->commit("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); dol_syslog("createRecurringInvoices Process invoice template ".$facturerec->ref." is finished with a success generation"); $nb_create++; - $this->output.=$langs->trans("InvoiceGeneratedFromTemplate", $facture->ref, $facturerec->ref)."\n"; + $this->output .= $langs->trans("InvoiceGeneratedFromTemplate", $facture->ref, $facturerec->ref)."\n"; } else { @@ -1206,21 +1206,21 @@ class FactureRec extends CommonInvoice 'total' => $num, 'errorCount' => $error, 'invoiceidgenerated' => $invoiceidgenerated, - 'facturerec' => $facturerec, // it's an object which PHP passes by "reference", so modifiable by hooks. - 'this' => $this, // it's an object which PHP passes by "reference", so modifiable by hooks. + 'facturerec' => $facturerec, // it's an object which PHP passes by "reference", so modifiable by hooks. + 'this' => $this, // it's an object which PHP passes by "reference", so modifiable by hooks. ); - $reshook = $hookmanager->executeHooks('afterCreationOfRecurringInvoice', $parameters, $facture); // note: $facture can be modified by hooks (warning: $facture can be null) + $reshook = $hookmanager->executeHooks('afterCreationOfRecurringInvoice', $parameters, $facture); // note: $facture can be modified by hooks (warning: $facture can be null) $i++; } - $conf->entity = $saventity; // Restore entity context + $conf->entity = $saventity; // Restore entity context } else dol_print_error($db); - $this->output=trim($this->output); + $this->output = trim($this->output); - return $error?$error:0; + return $error ? $error : 0; } /** @@ -1239,23 +1239,23 @@ class FactureRec extends CommonInvoice { global $langs; - $result=''; + $result = ''; - $label = '<u>' . $langs->trans("ShowInvoice") . '</u>'; - if (! empty($this->ref)) { - $label .= '<br><b>'.$langs->trans('Ref') . ':</b> ' . $this->ref; + $label = '<u>'.$langs->trans("ShowInvoice").'</u>'; + if (!empty($this->ref)) { + $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref; } if ($this->frequency > 0) { - $label .= '<br><b>'.$langs->trans('Frequency') . ':</b> ' . $langs->trans('FrequencyPer_'.$this->unit_frequency, $this->frequency); + $label .= '<br><b>'.$langs->trans('Frequency').':</b> '.$langs->trans('FrequencyPer_'.$this->unit_frequency, $this->frequency); } - if (! empty($this->date_last_gen)) { - $label .= '<br><b>'.$langs->trans('DateLastGeneration') . ':</b> ' . dol_print_date($this->date_last_gen, 'dayhour'); + if (!empty($this->date_last_gen)) { + $label .= '<br><b>'.$langs->trans('DateLastGeneration').':</b> '.dol_print_date($this->date_last_gen, 'dayhour'); } if ($this->frequency > 0) { - if (! empty($this->date_when)) { - $label .= '<br><b>'.$langs->trans('NextDateToExecution') . ':</b> '; - $label .= (empty($this->suspended)?'':'<strike>'). dol_print_date($this->date_when, 'day').(empty($this->suspended)?'':'</strike>'); // No hour for this property - if (! empty($this->suspended)) $label .= ' ('.$langs->trans("Disabled").')'; + if (!empty($this->date_when)) { + $label .= '<br><b>'.$langs->trans('NextDateToExecution').':</b> '; + $label .= (empty($this->suspended) ? '' : '<strike>').dol_print_date($this->date_when, 'day').(empty($this->suspended) ? '' : '</strike>'); // No hour for this property + if (!empty($this->suspended)) $label .= ' ('.$langs->trans("Disabled").')'; } } @@ -1266,17 +1266,17 @@ class FactureRec extends CommonInvoice if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } $linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; - $linkend='</a>'; + $linkend = '</a>'; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; return $result; @@ -1292,7 +1292,7 @@ class FactureRec extends CommonInvoice public function getLibStatut($mode = 0, $alreadypaid = -1) { - return $this->LibStatut($this->frequency?1:0, $this->suspended, $mode, $alreadypaid, empty($this->type)?0:$this->type); + return $this->LibStatut($this->frequency ? 1 : 0, $this->suspended, $mode, $alreadypaid, empty($this->type) ? 0 : $this->type); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1315,7 +1315,7 @@ class FactureRec extends CommonInvoice //print "$recur,$status,$mode,$alreadypaid,$type"; if ($mode == 0) { - $prefix=''; + $prefix = ''; if ($recur) { if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled'); @@ -1329,7 +1329,7 @@ class FactureRec extends CommonInvoice } elseif ($mode == 1) { - $prefix='Short'; + $prefix = 'Short'; if ($recur) { if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled'); @@ -1358,7 +1358,7 @@ class FactureRec extends CommonInvoice { if ($recur) { - $prefix='Short'; + $prefix = 'Short'; if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'), 'statut6'); else return img_picto($langs->trans('Active'), 'statut4'); } @@ -1370,7 +1370,7 @@ class FactureRec extends CommonInvoice } elseif ($mode == 4) { - $prefix=''; + $prefix = ''; if ($recur) { if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'), 'statut6').' '.$langs->trans('Disabled'); @@ -1384,8 +1384,8 @@ class FactureRec extends CommonInvoice } elseif ($mode == 5 || $mode == 6) { - $prefix=''; - if ($mode == 5) $prefix='Short'; + $prefix = ''; + if ($mode == 5) $prefix = 'Short'; if ($recur) { if ($status == self::STATUS_SUSPENDED) return '<span class="xhideonsmartphone">'.$langs->trans('Disabled').' </span>'.img_picto($langs->trans('Disabled'), 'statut6'); @@ -1409,19 +1409,19 @@ class FactureRec extends CommonInvoice */ public function initAsSpecimen($option = '') { - global $user,$langs,$conf; + global $user, $langs, $conf; - $now=dol_now(); - $arraynow=dol_getdate($now); - $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); + $now = dol_now(); + $arraynow = dol_getdate($now); + $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -1436,22 +1436,22 @@ class FactureRec extends CommonInvoice } // Initialize parameters - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->socid = 1; $this->date = $nownotime; - $this->date_lim_reglement = $nownotime + 3600 * 24 *30; + $this->date_lim_reglement = $nownotime + 3600 * 24 * 30; $this->cond_reglement_id = 1; $this->cond_reglement_code = 'RECEP'; - $this->date_lim_reglement=$this->calculate_date_lim_reglement(); - $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR - $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR - $this->note_public='This is a comment (public)'; - $this->note_private='This is a comment (private)'; - $this->note='This is a comment (private)'; - $this->fk_incoterms=0; - $this->location_incoterms=''; + $this->date_lim_reglement = $this->calculate_date_lim_reglement(); + $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR + $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR + $this->note_public = 'This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; + $this->note = 'This is a comment (private)'; + $this->fk_incoterms = 0; + $this->location_incoterms = ''; if (empty($option) || $option != 'nolines') { @@ -1460,51 +1460,51 @@ class FactureRec extends CommonInvoice $xnbp = 0; while ($xnbp < $nbp) { - $line=new FactureLigne($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->qty=1; - $line->subprice=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; - $line->remise_percent=0; + $line = new FactureLigne($this->db); + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->qty = 1; + $line->subprice = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; + $line->remise_percent = 0; if ($xnbp == 1) // Qty is negative (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->qty=-1; - $line->total_ht=-100; - $line->total_ttc=-119.6; - $line->total_tva=-19.6; + $line->fk_product = $prodids[$prodid]; + $line->qty = -1; + $line->total_ht = -100; + $line->total_ttc = -119.6; + $line->total_tva = -19.6; } elseif ($xnbp == 2) // UP is negative (free line) { - $line->subprice=-100; - $line->total_ht=-100; - $line->total_ttc=-119.6; - $line->total_tva=-19.6; - $line->remise_percent=0; + $line->subprice = -100; + $line->total_ht = -100; + $line->total_ttc = -119.6; + $line->total_tva = -19.6; + $line->remise_percent = 0; } elseif ($xnbp == 3) // Discount is 50% (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->total_ht=50; - $line->total_ttc=59.8; - $line->total_tva=9.8; - $line->remise_percent=50; + $line->fk_product = $prodids[$prodid]; + $line->total_ht = 50; + $line->total_ttc = 59.8; + $line->total_tva = 9.8; + $line->remise_percent = 50; } else // (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->total_ht=100; - $line->total_ttc=119.6; - $line->total_tva=19.6; - $line->remise_percent=00; + $line->fk_product = $prodids[$prodid]; + $line->total_ht = 100; + $line->total_ttc = 119.6; + $line->total_tva = 19.6; + $line->remise_percent = 00; } - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $xnbp++; $this->total_ht += $line->total_ht; @@ -1514,21 +1514,21 @@ class FactureRec extends CommonInvoice $this->revenuestamp = 0; // Add a line "offered" - $line=new FactureLigne($this->db); - $line->desc=$langs->trans("Description")." (offered line)"; - $line->qty=1; - $line->subprice=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; - $line->remise_percent=100; - $line->total_ht=0; - $line->total_ttc=0; // 90 * 1.196 - $line->total_tva=0; + $line = new FactureLigne($this->db); + $line->desc = $langs->trans("Description")." (offered line)"; + $line->qty = 1; + $line->subprice = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; + $line->remise_percent = 100; + $line->total_ht = 0; + $line->total_ttc = 0; // 90 * 1.196 + $line->total_tva = 0; $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + $line->fk_product = $prodids[$prodid]; - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $xnbp++; } @@ -1561,7 +1561,7 @@ class FactureRec extends CommonInvoice */ public function setFrequencyAndUnit($frequency, $unit) { - if (! $this->table_element) { + if (!$this->table_element) { dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); return -1; } @@ -1572,11 +1572,11 @@ class FactureRec extends CommonInvoice } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET frequency = '.($frequency?$this->db->escape($frequency):'null'); + $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null'); if (!empty($unit)) { - $sql.= ', unit_frequency = \''.$this->db->escape($unit).'\''; + $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\''; } - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); if ($this->db->query($sql)) { @@ -1600,21 +1600,21 @@ class FactureRec extends CommonInvoice */ public function setNextDate($date, $increment_nb_gen_done = 0) { - if (! $this->table_element) + if (!$this->table_element) { dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR); return -1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); - if ($increment_nb_gen_done>0) $sql.= ', nb_gen_done = nb_gen_done + 1'; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); + if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1'; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG); if ($this->db->query($sql)) { $this->date_when = $date; - if ($increment_nb_gen_done>0) $this->nb_gen_done++; + if ($increment_nb_gen_done > 0) $this->nb_gen_done++; return 1; } else @@ -1632,17 +1632,17 @@ class FactureRec extends CommonInvoice */ public function setMaxPeriod($nb) { - if (! $this->table_element) + if (!$this->table_element) { dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR); return -1; } - if (empty($nb)) $nb=0; + if (empty($nb)) $nb = 0; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET nb_gen_max = '.$nb; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET nb_gen_max = '.$nb; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); if ($this->db->query($sql)) @@ -1665,15 +1665,15 @@ class FactureRec extends CommonInvoice */ public function setAutoValidate($validate) { - if (! $this->table_element) + if (!$this->table_element) { dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR); return -1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET auto_validate = '.$validate; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET auto_validate = '.$validate; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); if ($this->db->query($sql)) @@ -1696,15 +1696,15 @@ class FactureRec extends CommonInvoice */ public function setGeneratePdf($validate) { - if (! $this->table_element) + if (!$this->table_element) { dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR); return -1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET generate_pdf = '.$validate; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET generate_pdf = '.$validate; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); if ($this->db->query($sql)) @@ -1727,15 +1727,15 @@ class FactureRec extends CommonInvoice */ public function setModelPdf($model) { - if (! $this->table_element) + if (!$this->table_element) { dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR); return -1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET modelpdf = "' . $model . '"'; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET modelpdf = "'.$model.'"'; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG); if ($this->db->query($sql)) @@ -1762,12 +1762,12 @@ class FactureLigneRec extends CommonInvoiceLine /** * @var string ID to identify managed object */ - public $element='facturedetrec'; + public $element = 'facturedetrec'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='facturedet_rec'; + public $table_element = 'facturedet_rec'; public $date_start_fill; public $date_end_fill; @@ -1782,25 +1782,25 @@ class FactureLigneRec extends CommonInvoiceLine */ public function delete(User $user, $notrigger = false) { - $error=0; + $error = 0; $this->db->begin(); - if (! $error) { - if (! $notrigger) { + if (!$error) { + if (!$notrigger) { // Call triggers - $result=$this->call_trigger('LINEBILLREC_DELETE', $user); + $result = $this->call_trigger('LINEBILLREC_DELETE', $user); if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail // End call triggers } } - if (! $error) + if (!$error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; $res = $this->db->query($sql); - if($res===false) { + if ($res === false) { $error++; $this->errors[] = $this->db->lasterror(); } @@ -1826,15 +1826,15 @@ class FactureLigneRec extends CommonInvoiceLine public function fetch($rowid) { $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; - $sql.= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; - $sql.= ' l.rang, l.special_code,'; - $sql.= ' l.fk_unit, l.fk_contract_line,'; - $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql.= ' WHERE l.rowid = '.$rowid; - $sql.= ' ORDER BY l.rang'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; + $sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; + $sql .= ' l.rang, l.special_code,'; + $sql .= ' l.fk_unit, l.fk_contract_line,'; + $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql .= ' WHERE l.rowid = '.$rowid; + $sql .= ' ORDER BY l.rang'; dol_syslog('FactureRec::fetch', LOG_DEBUG); $result = $this->db->query($sql); @@ -1842,21 +1842,21 @@ class FactureLigneRec extends CommonInvoiceLine { $objp = $this->db->fetch_object($result); - $this->id = $objp->rowid; - $this->label = $objp->custom_label; // Label line - $this->desc = $objp->description; // Description line - $this->description = $objp->description; // Description line - $this->product_type = $objp->product_type; // Type of line - $this->ref = $objp->product_ref; // Ref product - $this->product_ref = $objp->product_ref; // Ref product - $this->libelle = $objp->product_label; // deprecated - $this->product_label = $objp->product_label; // Label product - $this->product_desc = $objp->product_desc; // Description product - $this->fk_product_type = $objp->fk_product_type; // Type of product + $this->id = $objp->rowid; + $this->label = $objp->custom_label; // Label line + $this->desc = $objp->description; // Description line + $this->description = $objp->description; // Description line + $this->product_type = $objp->product_type; // Type of line + $this->ref = $objp->product_ref; // Ref product + $this->product_ref = $objp->product_ref; // Ref product + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; // Label product + $this->product_desc = $objp->product_desc; // Description product + $this->fk_product_type = $objp->fk_product_type; // Type of product $this->qty = $objp->qty; - $this->price = $objp->price; + $this->price = $objp->price; $this->subprice = $objp->subprice; - $this->fk_facture = $objp->fk_facture; + $this->fk_facture = $objp->fk_facture; $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; @@ -1873,8 +1873,8 @@ class FactureLigneRec extends CommonInvoiceLine $this->total_tva = $objp->total_tva; $this->total_ttc = $objp->total_ttc; $this->code_ventilation = $objp->fk_code_ventilation; - $this->rang = $objp->rang; - $this->special_code = $objp->special_code; + $this->rang = $objp->rang; + $this->special_code = $objp->special_code; $this->fk_unit = $objp->fk_unit; $this->fk_contract_line = $objp->fk_contract_line; @@ -1884,7 +1884,7 @@ class FactureLigneRec extends CommonInvoiceLine } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -3; } } @@ -1906,54 +1906,54 @@ class FactureLigneRec extends CommonInvoiceLine include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET"; - $sql.= " fk_facture = ".$this->fk_facture; - $sql.= ", label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); - $sql.= ", description='".$this->db->escape($this->desc)."'"; - $sql.= ", price=".price2num($this->price); - $sql.= ", qty=".price2num($this->qty); - $sql.= ", tva_tx=".price2num($this->tva_tx); - $sql.= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; - $sql.= ", localtax1_tx=".price2num($this->localtax1_tx); - $sql.= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql.= ", localtax2_tx=".price2num($this->localtax2_tx); - $sql.= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; - $sql.= ", fk_product=".($this->fk_product > 0 ? $this->fk_product :"null"); - $sql.= ", product_type=".$this->product_type; - $sql.= ", remise_percent='".price2num($this->remise_percent)."'"; - $sql.= ", subprice='".price2num($this->subprice)."'"; - $sql.= ", info_bits='".price2num($this->info_bits)."'"; - $sql.= ", date_start_fill=".(int) $this->date_start_fill; - $sql.= ", date_end_fill=".(int) $this->date_end_fill; + $sql .= " fk_facture = ".$this->fk_facture; + $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", description='".$this->db->escape($this->desc)."'"; + $sql .= ", price=".price2num($this->price); + $sql .= ", qty=".price2num($this->qty); + $sql .= ", tva_tx=".price2num($this->tva_tx); + $sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; + $sql .= ", localtax1_tx=".price2num($this->localtax1_tx); + $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql .= ", localtax2_tx=".price2num($this->localtax2_tx); + $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null"); + $sql .= ", product_type=".$this->product_type; + $sql .= ", remise_percent='".price2num($this->remise_percent)."'"; + $sql .= ", subprice='".price2num($this->subprice)."'"; + $sql .= ", info_bits='".price2num($this->info_bits)."'"; + $sql .= ", date_start_fill=".(int) $this->date_start_fill; + $sql .= ", date_end_fill=".(int) $this->date_end_fill; if (empty($this->skip_update_total)) { - $sql.= ", total_ht=".price2num($this->total_ht); - $sql.= ", total_tva=".price2num($this->total_tva); - $sql.= ", total_localtax1=".price2num($this->total_localtax1); - $sql.= ", total_localtax2=".price2num($this->total_localtax2); - $sql.= ", total_ttc=".price2num($this->total_ttc); + $sql .= ", total_ht=".price2num($this->total_ht); + $sql .= ", total_tva=".price2num($this->total_tva); + $sql .= ", total_localtax1=".price2num($this->total_localtax1); + $sql .= ", total_localtax2=".price2num($this->total_localtax2); + $sql .= ", total_ttc=".price2num($this->total_ttc); } - $sql.= ", rang=".$this->rang; - $sql.= ", special_code=".$this->special_code; - $sql.= ", fk_unit=".($this->fk_unit ?"'".$this->db->escape($this->fk_unit)."'":"null"); - $sql.= ", fk_contract_line=".($this->fk_contract_line?$this->fk_contract_line:"null"); - $sql.= " WHERE rowid = ".$this->id; + $sql .= ", rang=".$this->rang; + $sql .= ", special_code=".$this->special_code; + $sql .= ", fk_unit=".($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : "null"); + $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null"); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::updateline", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINEBILLREC_UPDATE', $user); + $result = $this->call_trigger('LINEBILLREC_UPDATE', $user); if ($result < 0) { $this->db->rollback(); @@ -1966,7 +1966,7 @@ class FactureLigneRec extends CommonInvoiceLine } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 75945106b72..ca8c78dd478 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -48,94 +48,94 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; // Load translation files required by the page $langs->loadLangs(array('bills', 'companies', 'products', 'categories')); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$projectid=(GETPOST('projectid')?GETPOST('projectid', 'int'):0); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$projectid = (GETPOST('projectid') ?GETPOST('projectid', 'int') : 0); -$id=(GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('facid', 'int')); // For backward compatibility -$ref=GETPOST('ref', 'alpha'); -$socid=GETPOST('socid', 'int'); +$id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility +$ref = GETPOST('ref', 'alpha'); +$socid = GETPOST('socid', 'int'); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoicelist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicelist'; if ($contextpage == 'poslist') { $_GET['optioncss'] = 'print'; } -$lineid=GETPOST('lineid', 'int'); -$userid=GETPOST('userid', 'int'); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref', 'alpha'):GETPOST('search_ref', 'alpha'); -$search_refcustomer=GETPOST('search_refcustomer', 'alpha'); -$search_type=GETPOST('search_type', 'int'); -$search_project_ref=GETPOST('search_project_ref', 'alpha'); -$search_project=GETPOST('search_project', 'alpha'); -$search_societe=GETPOST('search_societe', 'alpha'); -$search_montant_ht=GETPOST('search_montant_ht', 'alpha'); -$search_montant_vat=GETPOST('search_montant_vat', 'alpha'); -$search_montant_localtax1=GETPOST('search_montant_localtax1', 'alpha'); -$search_montant_localtax2=GETPOST('search_montant_localtax2', 'alpha'); -$search_montant_ttc=GETPOST('search_montant_ttc', 'alpha'); -$search_status=GETPOST('search_status', 'intcomma'); -$search_paymentmode=GETPOST('search_paymentmode', 'int'); -$search_paymentterms=GETPOST('search_paymentterms', 'int'); -$search_module_source=GETPOST('search_module_source', 'alpha'); -$search_pos_source=GETPOST('search_pos_source', 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); +$lineid = GETPOST('lineid', 'int'); +$userid = GETPOST('userid', 'int'); +$search_product_category = GETPOST('search_product_category', 'int'); +$search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); +$search_refcustomer = GETPOST('search_refcustomer', 'alpha'); +$search_type = GETPOST('search_type', 'int'); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); +$search_project = GETPOST('search_project', 'alpha'); +$search_societe = GETPOST('search_societe', 'alpha'); +$search_montant_ht = GETPOST('search_montant_ht', 'alpha'); +$search_montant_vat = GETPOST('search_montant_vat', 'alpha'); +$search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha'); +$search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha'); +$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); +$search_status = GETPOST('search_status', 'intcomma'); +$search_paymentmode = GETPOST('search_paymentmode', 'int'); +$search_paymentterms = GETPOST('search_paymentterms', 'int'); +$search_module_source = GETPOST('search_module_source', 'alpha'); +$search_pos_source = GETPOST('search_pos_source', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); -$search_day = GETPOST('search_day', 'int'); -$search_month = GETPOST('search_month', 'int'); +$search_day = GETPOST('search_day', 'int'); +$search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); $search_day_lim = GETPOST('search_day_lim', 'int'); -$search_month_lim = GETPOST('search_month_lim', 'int'); +$search_month_lim = GETPOST('search_month_lim', 'int'); $search_year_lim = GETPOST('search_year_lim', 'int'); -$search_categ_cus=trim(GETPOST("search_categ_cus", 'int')); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); +$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $option = GETPOST('search_option'); if ($option == 'late') { $search_status = '1'; } -$filtre = GETPOST('filtre', 'alpha'); +$filtre = GETPOST('filtre', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$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 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (! $sortorder && ! empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == '1') $sortorder=$conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER; -if (! $sortorder) $sortorder='DESC'; -if (! $sortfield) $sortfield='f.datef'; +if (!$sortorder && !empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == '1') $sortorder = $conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER; +if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) $sortfield = 'f.datef'; $pageprev = $page - 1; $pagenext = $page + 1; // Security check -$fieldid = (! empty($ref)?'ref':'rowid'); -if (! empty($user->socid)) $socid=$user->socid; +$fieldid = (!empty($ref) ? 'ref' : 'rowid'); +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); -$diroutputmassaction=$conf->facture->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->facture->dir_output.'/temp/massgeneration/'.$user->id; -$object=new Facture($db); +$object = new Facture($db); -$now=dol_now(); +$now = dol_now(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Facture($db); @@ -145,7 +145,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('facture'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -155,18 +155,18 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'f.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'f.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), 'f.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1, 'position'=>10), 'f.type'=>array('label'=>"Type", 'checked'=>0, 'position'=>15), 'f.date'=>array('label'=>"DateInvoice", 'checked'=>1, 'position'=>20), 'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1, 'position'=>25), 'f.date_closing'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>30), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled)?0:1), 'position'=>40), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1), 'position'=>40), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>40), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>40), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>50), 's.town'=>array('label'=>"Town", 'checked'=>1, 'position'=>55), 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>60), @@ -179,17 +179,17 @@ $arrayfields=array( 'f.pos_source'=>array('label'=>"Terminal", 'checked'=>($contextpage == 'poslist' ? 1 : 0), 'enabled'=>($conf->cashdesk->enabled || $conf->takepos->enabled || $conf->global->INVOICE_SHOW_POS), 'position'=>91), 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>95), 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>100), - 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1"), 'position'=>110), - 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj=="1"), 'position'=>120), + 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj == "1"), 'position'=>110), + 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj == "1"), 'position'=>120), 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>130), 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0, 'position'=>140), - 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow + 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); -if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) +if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) { $arrayfields['f.retained_warranty'] = array('label'=>$langs->trans("RetainedWarranty"), 'checked'=>0, 'position'=>86); } @@ -197,10 +197,10 @@ if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_ // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -211,11 +211,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -223,48 +223,48 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha')) // All tests are required to be compatible with all browsers { - $search_user=''; - $search_sale=''; - $search_product_category=''; - $search_ref=''; - $search_refcustomer=''; - $search_type=''; - $search_project_ref=''; - $search_project=''; - $search_societe=''; - $search_montant_ht=''; - $search_montant_vat=''; - $search_montant_localtax1=''; - $search_montant_localtax2=''; - $search_montant_ttc=''; - $search_status=''; - $search_paymentmode=''; - $search_paymentterms=''; - $search_module_source=''; - $search_pos_source=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_day=''; - $search_year=''; - $search_month=''; - $option=''; - $filter=''; - $search_day_lim=''; - $search_year_lim=''; - $search_month_lim=''; - $toselect=''; - $search_array_options=array(); - $search_categ_cus=0; + $search_user = ''; + $search_sale = ''; + $search_product_category = ''; + $search_ref = ''; + $search_refcustomer = ''; + $search_type = ''; + $search_project_ref = ''; + $search_project = ''; + $search_societe = ''; + $search_montant_ht = ''; + $search_montant_vat = ''; + $search_montant_localtax1 = ''; + $search_montant_localtax2 = ''; + $search_montant_ttc = ''; + $search_status = ''; + $search_paymentmode = ''; + $search_paymentterms = ''; + $search_module_source = ''; + $search_pos_source = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_day = ''; + $search_year = ''; + $search_month = ''; + $option = ''; + $filter = ''; + $search_day_lim = ''; + $search_year_lim = ''; + $search_month_lim = ''; + $toselect = ''; + $search_array_options = array(); + $search_categ_cus = 0; } if (empty($reshook)) { - $objectclass='Facture'; - $objectlabel='Invoices'; + $objectclass = 'Facture'; + $objectlabel = 'Invoices'; $permissiontoread = $user->rights->facture->lire; $permissiontoadd = $user->rights->facture->creer; $permissiontodelete = $user->rights->facture->supprimer; @@ -286,26 +286,26 @@ if ($massaction == 'withdrawrequest') //Checking error $error = 0; - $arrayofselected=is_array($toselect)?$toselect:array(); - $listofbills=array(); - foreach($arrayofselected as $toselectid) + $arrayofselected = is_array($toselect) ? $toselect : array(); + $listofbills = array(); + foreach ($arrayofselected as $toselectid) { - $objecttmp=new Facture($db); - $result=$objecttmp->fetch($toselectid); + $objecttmp = new Facture($db); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { - $totalpaye = $objecttmp->getSommePaiement(); + $totalpaye = $objecttmp->getSommePaiement(); $totalcreditnotes = $objecttmp->getSumCreditNotesUsed(); $totaldeposits = $objecttmp->getSumDepositsUsed(); $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - if($objecttmp->paye || $objecttmp->resteapayer==0){ + if ($objecttmp->paye || $objecttmp->resteapayer == 0) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors'); - } elseif($objecttmp->resteapayer<0){ + } elseif ($objecttmp->resteapayer < 0) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors'); } - if (!($objecttmp->statut > Facture::STATUS_DRAFT)){ + if (!($objecttmp->statut > Facture::STATUS_DRAFT)) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors'); } @@ -327,25 +327,25 @@ if ($massaction == 'withdrawrequest') $numprlv = $db->num_rows($result_sql); } - if ($numprlv>0){ + if ($numprlv > 0) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings'); } - elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'PRE'){ + elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'PRE') { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors'); } else { - $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done + $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done } } } //Massive withdraw request for request with no errors - if(!empty($listofbills)) + if (!empty($listofbills)) { - $nbwithdrawrequestok=0; - foreach($listofbills as $aBill) + $nbwithdrawrequestok = 0; + foreach ($listofbills as $aBill) { $db->begin(); $result = $aBill->demande_prelevement($user, $aBill->resteapayer); @@ -377,64 +377,64 @@ if ($massaction == 'withdrawrequest') $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); -$bankaccountstatic=new Account($db); -$facturestatic=new Facture($db); -$formcompany=new FormCompany($db); -$thirdpartystatic=new Societe($db); +$bankaccountstatic = new Account($db); +$facturestatic = new Facture($db); +$formcompany = new FormCompany($db); +$thirdpartystatic = new Societe($db); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; -$sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; -$sql.= ' f.datef as df, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,'; -$sql.= ' f.paye as paye, f.fk_statut,'; -$sql.= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; -$sql.= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; -$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= " country.code as country_code,"; -$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; +$sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; +$sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; +$sql .= ' f.datef as df, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,'; +$sql .= ' f.paye as paye, f.fk_statut,'; +$sql .= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; +$sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; +$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " country.code as country_code,"; +$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. -if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed'; +if (!$sall) $sql .= ', SUM(pf.amount) as dynamount_payed'; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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."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)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +$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."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)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ -$sql.= ', '.MAIN_DB_PREFIX.'facture as f'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)"; -if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; -if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture'; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; +$sql .= ', '.MAIN_DB_PREFIX.'facture as f'; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)"; +if (!$sall) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; +if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE f.fk_soc = s.rowid'; -$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category); -if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; +$sql .= ' WHERE f.fk_soc = s.rowid'; +$sql .= ' AND f.entity IN ('.getEntity('invoice').')'; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$db->escape($search_product_category); +if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; if ($userid) { - if ($userid == -1) $sql.=' AND f.fk_user_author IS NULL'; - else $sql.=' AND f.fk_user_author = '.$userid; + if ($userid == -1) $sql .= ' AND f.fk_user_author IS NULL'; + else $sql .= ' AND f.fk_user_author = '.$userid; } if ($filtre) { @@ -442,78 +442,78 @@ if ($filtre) foreach ($aFilter as $filter) { $filt = explode(':', $filter); - $sql .= ' AND ' . $db->escape(trim($filt[0])) . ' = ' . $db->escape(trim($filt[1])); + $sql .= ' AND '.$db->escape(trim($filt[0])).' = '.$db->escape(trim($filt[1])); } } if ($search_ref) $sql .= natural_search('f.ref', $search_ref); if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer); -if ($search_type != '' && $search_type != '-1') $sql.=" AND f.type IN (".$db->escape($search_type).")"; +if ($search_type != '' && $search_type != '-1') $sql .= " AND f.type IN (".$db->escape($search_type).")"; if ($search_project_ref) $sql .= natural_search('p.ref', $search_project_ref); if ($search_project) $sql .= natural_search('p.title', $search_project); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1); -if ($search_montant_localtax1 != '') $sql.= natural_search('f.localtax1', $search_montant_localtax1, 1); -if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $search_montant_localtax2, 1); -if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); -if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); -if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; +if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); +if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); +if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); +if ($search_montant_localtax2 != '') $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1); +if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); +if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; if ($search_status != '-1' && $search_status != '') { if (is_numeric($search_status) && $search_status >= 0) { - if ($search_status == '0') $sql.=" AND f.fk_statut = 0"; // draft - if ($search_status == '1') $sql.=" AND f.fk_statut = 1"; // unpayed - if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) - if ($search_status == '3') $sql.=" AND f.fk_statut = 3"; // abandonned + if ($search_status == '0') $sql .= " AND f.fk_statut = 0"; // draft + if ($search_status == '1') $sql .= " AND f.fk_statut = 1"; // unpayed + if ($search_status == '2') $sql .= " AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) + if ($search_status == '3') $sql .= " AND f.fk_statut = 3"; // abandonned } else { - $sql.= " AND f.fk_statut IN (".$db->escape($search_status).")"; // When search_status is '1,2' for example + $sql .= " AND f.fk_statut IN (".$db->escape($search_status).")"; // When search_status is '1,2' for example } } if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode); if ($search_paymentterms > 0) $sql .= " AND f.fk_cond_reglement = ".$db->escape($search_paymentterms); if ($search_module_source) $sql .= natural_search("f.module_source", $search_module_source); if ($search_pos_source) $sql .= natural_search("f.pos_source", $search_pos_source); -$sql.= dolSqlDateFilter("f.datef", $search_day, $search_month, $search_year); -$sql.= dolSqlDateFilter("f.date_lim_reglement", $search_day_lim, $search_month_lim, $search_year_lim); -if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .(int) $search_sale; +$sql .= dolSqlDateFilter("f.datef", $search_day, $search_month, $search_year); +$sql .= dolSqlDateFilter("f.date_lim_reglement", $search_day_lim, $search_month_lim, $search_year_lim); +if ($option == 'late') $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".(int) $search_sale; if ($search_user > 0) { - $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; + $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -if (! $sall) +if (!$sall) { - $sql.= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total, f.tva, f.total_ttc,'; - $sql.= ' f.localtax1, f.localtax2,'; - $sql.= ' f.datef, f.date_lim_reglement, f.module_source, f.pos_source,'; - $sql.= ' f.paye, f.fk_statut,'; - $sql.= ' f.datec, f.tms, f.date_closing,'; - $sql.= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; - $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; - $sql.= ' typent.code,'; - $sql.= ' state.code_departement, state.nom,'; - $sql.= ' country.code,'; - $sql.= " p.rowid, p.ref, p.title"; + $sql .= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total, f.tva, f.total_ttc,'; + $sql .= ' f.localtax1, f.localtax2,'; + $sql .= ' f.datef, f.date_lim_reglement, f.module_source, f.pos_source,'; + $sql .= ' f.paye, f.fk_statut,'; + $sql .= ' f.datec, f.tms, f.date_closing,'; + $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; + $sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; + $sql .= ' typent.code,'; + $sql .= ' state.code_departement, state.nom,'; + $sql .= ' country.code,'; + $sql .= " p.rowid, p.ref, p.title"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields - if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); + if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); } } else @@ -521,11 +521,11 @@ else $sql .= natural_search(array_keys($fieldstosearchall), $sall); } -$sql.= ' ORDER BY '; -$listfield=explode(',', $sortfield); -$listorder=explode(',', $sortorder); -foreach ($listfield as $key => $value) $sql.= $listfield[$key].' '.($listorder[$key]?$listorder[$key]:'DESC').','; -$sql.= ' f.rowid DESC '; +$sql .= ' ORDER BY '; +$listfield = explode(',', $sortfield); +$listorder = explode(',', $sortorder); +foreach ($listfield as $key => $value) $sql .= $listfield[$key].' '.($listorder[$key] ? $listorder[$key] : 'DESC').','; +$sql .= ' f.rowid DESC '; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -539,7 +539,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); @@ -547,9 +547,9 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->id; @@ -567,46 +567,46 @@ if ($resql) if (empty($search_societe)) $search_societe = $soc->name; } - $param='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.='&sall='.urlencode($sall); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year=' .urlencode($search_year); - if ($search_day_lim) $param.='&search_day_lim='.urlencode($search_day_lim); - if ($search_month_lim) $param.='&search_month_lim='.urlencode($search_month_lim); - if ($search_year_lim) $param.='&search_year_lim=' .urlencode($search_year_lim); - if ($search_ref) $param.='&search_ref=' .urlencode($search_ref); - if ($search_refcustomer) $param.='&search_refcustomer=' .urlencode($search_refcustomer); - if ($search_project_ref) $param.='&search_project_ref='.urlencode($search_project_ref); - if ($search_project) $param.='&search_project='.urlencode($search_project); - if ($search_type != '') $param.='&search_type='.urlencode($search_type); - if ($search_societe) $param.='&search_societe=' .urlencode($search_societe); - if ($search_town) $param.='&search_town='.urlencode($search_town); - if ($search_zip) $param.='&search_zip='.urlencode($search_zip); - if ($search_sale > 0) $param.='&search_sale=' .urlencode($search_sale); - if ($search_user > 0) $param.='&search_user=' .urlencode($search_user); - if ($search_product_category > 0) $param.='&search_product_category=' .urlencode($search_product_category); - if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht); - if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); - if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1); - if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2); - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); - if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if ($search_paymentmode > 0) $param.='&search_paymentmode='.urlencode($search_paymentmode); - if ($search_paymentterms > 0) $param.='&search_paymentterms='.urlencode($search_paymentterms); - if ($search_module_source) $param.='&search_module_source='.urlencode($search_module_source); - if ($search_pos_source) $param.='&search_pos_source='.urlencode($search_pos_source); - if ($show_files) $param.='&show_files='.urlencode($show_files); - if ($option) $param.="&search_option=".urlencode($option); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); + $param = '&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= '&sall='.urlencode($sall); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_day_lim) $param .= '&search_day_lim='.urlencode($search_day_lim); + if ($search_month_lim) $param .= '&search_month_lim='.urlencode($search_month_lim); + if ($search_year_lim) $param .= '&search_year_lim='.urlencode($search_year_lim); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_refcustomer) $param .= '&search_refcustomer='.urlencode($search_refcustomer); + if ($search_project_ref) $param .= '&search_project_ref='.urlencode($search_project_ref); + if ($search_project) $param .= '&search_project='.urlencode($search_project); + if ($search_type != '') $param .= '&search_type='.urlencode($search_type); + if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); + if ($search_town) $param .= '&search_town='.urlencode($search_town); + if ($search_zip) $param .= '&search_zip='.urlencode($search_zip); + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_product_category > 0) $param .= '&search_product_category='.urlencode($search_product_category); + if ($search_montant_ht != '') $param .= '&search_montant_ht='.urlencode($search_montant_ht); + if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); + if ($search_montant_localtax1 != '') $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1); + if ($search_montant_localtax2 != '') $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2); + if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); + if ($search_paymentmode > 0) $param .= '&search_paymentmode='.urlencode($search_paymentmode); + if ($search_paymentterms > 0) $param .= '&search_paymentterms='.urlencode($search_paymentterms); + if ($search_module_source) $param .= '&search_module_source='.urlencode($search_module_source); + if ($search_pos_source) $param .= '&search_pos_source='.urlencode($search_pos_source); + if ($show_files) $param .= '&show_files='.urlencode($show_files); + if ($option) $param .= "&search_option=".urlencode($option); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $arrayofmassactions=array( + $arrayofmassactions = array( 'validate'=>$langs->trans("Validate"), 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), @@ -625,12 +625,12 @@ if ($resql) } } if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; - if($user->rights->facture->creer && $contextpage != 'poslist') + $newcardbutton = ''; + if ($user->rights->facture->creer && $contextpage != 'poslist') { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/facture/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/facture/card.php?action=create'); } $i = 0; @@ -646,58 +646,58 @@ if ($resql) print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; - print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'invoicing', 0, $newcardbutton, '', $limit); + print_barre_liste($langs->trans('BillsCustomers').' '.($socid ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'invoicing', 0, $newcardbutton, '', $limit); - $topicmail="SendBillRef"; - $modelmail="facture_send"; - $objecttmp=new Facture($db); - $trackid='inv'.$object->id; + $topicmail = "SendBillRef"; + $modelmail = "facture_send"; + $objecttmp = new Facture($db); + $trackid = 'inv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } // If the user can view prospects other than his' - $moreforfilter=''; + $moreforfilter = ''; if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view prospects other than his' if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='</div>'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '</div>'; } - if (! empty($conf->categorie->enabled)) + if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); - $moreforfilter.='</div>'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $moreforfilter .= '</div>'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; @@ -708,40 +708,40 @@ if ($resql) print '</div>'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton && $contextpage != 'poslist') $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton && $contextpage != 'poslist') $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Filters lines print '<tr class="liste_titre_filter">'; // Ref - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print '<td class="liste_titre" align="left">'; print '<input class="flat maxwidth50imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } // Ref customer - if (! empty($arrayfields['f.ref_client']['checked'])) + if (!empty($arrayfields['f.ref_client']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth50imp" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).'">'; print '</td>'; } // Type - if (! empty($arrayfields['f.type']['checked'])) + if (!empty($arrayfields['f.type']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone">'; - $listtype=array( + $listtype = array( Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), ); - if (! empty($conf->global->INVOICE_USE_SITUATION)) + if (!empty($conf->global->INVOICE_USE_SITUATION)) { $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); } @@ -750,121 +750,121 @@ if ($resql) print '</td>'; } // Date invoice - if (! empty($arrayfields['f.date']['checked'])) + if (!empty($arrayfields['f.date']['checked'])) { print '<td class="liste_titre nowraponall" align="center">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">'; print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">'; - $formother->select_year($search_year?$search_year:-1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print '</td>'; } // Date due - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print '<td class="liste_titre nowraponall" align="center">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_lim" value="'.dol_escape_htmltag($search_day_lim).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_lim" value="'.dol_escape_htmltag($search_day_lim).'">'; print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_lim" value="'.dol_escape_htmltag($search_month_lim).'">'; - $formother->select_year($search_year_lim?$search_year_lim:-1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); - print '<br><input type="checkbox" name="search_option" value="late"'.($option == 'late'?' checked':'').'> '.$langs->trans("Alert"); + $formother->select_year($search_year_lim ? $search_year_lim : -1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + print '<br><input type="checkbox" name="search_option" value="late"'.($option == 'late' ? ' checked' : '').'> '.$langs->trans("Alert"); print '</td>'; } // Project ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project_ref" value="'.$search_project_ref.'"></td>'; } // Project label - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print '<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project" value="'.$search_project.'"></td>'; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_societe" value="'.$search_societe.'"></td>'; } // Town - if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>'; + if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>'; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>'; + if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>'; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="liste_titre" align="center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone" align="center">'; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100'); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100'); print '</td>'; } // Payment mode - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print '<td class="liste_titre">'; $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10); print '</td>'; } // Payment terms - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { print '<td class="liste_titre">'; $form->select_conditions_paiements($search_paymentterms, 'search_paymentterms', -1, 1, 1); print '</td>'; } // Module source - if (! empty($arrayfields['f.module_source']['checked'])) + if (!empty($arrayfields['f.module_source']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth75" type="text" name="search_module_source" value="'.dol_escape_htmltag($search_module_source).'">'; print '</td>'; } // POS Terminal - if (! empty($arrayfields['f.pos_source']['checked'])) + if (!empty($arrayfields['f.pos_source']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth50" type="text" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).'">'; print '</td>'; } - if (! empty($arrayfields['f.total_ht']['checked'])) + if (!empty($arrayfields['f.total_ht']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">'; print '</td>'; } - if (! empty($arrayfields['f.total_vat']['checked'])) + if (!empty($arrayfields['f.total_vat']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">'; print '</td>'; } - if (! empty($arrayfields['f.total_localtax1']['checked'])) + if (!empty($arrayfields['f.total_localtax1']['checked'])) { // Localtax1 print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_montant_localtax1" value="'.$search_montant_localtax1.'">'; print '</td>'; } - if (! empty($arrayfields['f.total_localtax2']['checked'])) + if (!empty($arrayfields['f.total_localtax2']['checked'])) { // Localtax2 print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_montant_localtax2" value="'.$search_montant_localtax2.'">'; print '</td>'; } - if (! empty($arrayfields['f.total_ttc']['checked'])) + if (!empty($arrayfields['f.total_ttc']['checked'])) { // Amount print '<td class="liste_titre right">'; @@ -872,23 +872,23 @@ if ($resql) print '</td>'; } - if(! empty($arrayfields['f.retained_warranty']['checked'])) + if (!empty($arrayfields['f.retained_warranty']['checked'])) { print '<td class="liste_titre" align="right">'; print '</td>'; } - if (! empty($arrayfields['dynamount_payed']['checked'])) + if (!empty($arrayfields['dynamount_payed']['checked'])) { print '<td class="liste_titre right">'; print '</td>'; } - if (! empty($arrayfields['rtp']['checked'])) + if (!empty($arrayfields['rtp']['checked'])) { print '<td class="liste_titre right">'; print '</td>'; } - if (! empty($arrayfields['f.date_closing']['checked'])) + if (!empty($arrayfields['f.date_closing']['checked'])) { print '<td class="liste_titre">'; print '</td>'; @@ -898,124 +898,124 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status - if (! empty($arrayfields['f.fk_statut']['checked'])) + if (!empty($arrayfields['f.fk_statut']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone right">'; - $liststatus=array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); + $liststatus = array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); print $form->selectarray('search_status', $liststatus, $search_status, 1); print '</td>'; } // Action column print '<td class="liste_titre" align="middle">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; - if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], 'f.ref_client', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); - 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['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.module_source']['checked'])) print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.pos_source']['checked'])) print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.retained_warranty']['checked'])) print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], 'f.ref_client', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); + 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['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.module_source']['checked'])) print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.pos_source']['checked'])) print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.retained_warranty']['checked'])) print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['f.date_closing']['checked'])) print_liste_field_titre($arrayfields['f.date_closing']['label'], $_SERVER["PHP_SELF"], "f.date_closing", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type,dynamount_payed", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['f.date_closing']['checked'])) print_liste_field_titre($arrayfields['f.date_closing']['label'], $_SERVER["PHP_SELF"], "f.date_closing", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type,dynamount_payed", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "</tr>\n"; - $projectstatic=new Project($db); + $projectstatic = new Project($db); $discount = new DiscountAbsolute($db); if ($num > 0) { - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $datelimit=$db->jdate($obj->datelimite); + $datelimit = $db->jdate($obj->datelimite); - $facturestatic->id=$obj->id; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; - $facturestatic->total_ht=$obj->total_ht; - $facturestatic->total_tva=$obj->total_vat; - $facturestatic->total_ttc=$obj->total_ttc; - $facturestatic->statut=$obj->fk_statut; - $facturestatic->total_ttc=$obj->total_ttc; - $facturestatic->paye=$obj->paye; - $facturestatic->fk_soc=$obj->fk_soc; - $facturestatic->date_lim_reglement=$db->jdate($obj->datelimite); - $facturestatic->note_public=$obj->note_public; - $facturestatic->note_private=$obj->note_private; - if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) + $facturestatic->id = $obj->id; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_vat; + $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->statut = $obj->fk_statut; + $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->paye = $obj->paye; + $facturestatic->fk_soc = $obj->fk_soc; + $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); + $facturestatic->note_public = $obj->note_public; + $facturestatic->note_private = $obj->note_private; + if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) { - $facturestatic->retained_warranty=$obj->retained_warranty; - $facturestatic->retained_warranty_date_limit=$obj->retained_warranty_date_limit; - $facturestatic->situation_final=$obj->retained_warranty_date_limit; - $facturestatic->situation_final=$obj->retained_warranty_date_limit; - $facturestatic->situation_cycle_ref=$obj->situation_cycle_ref; - $facturestatic->situation_counter=$obj->situation_counter; + $facturestatic->retained_warranty = $obj->retained_warranty; + $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit; + $facturestatic->situation_final = $obj->retained_warranty_date_limit; + $facturestatic->situation_final = $obj->retained_warranty_date_limit; + $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref; + $facturestatic->situation_counter = $obj->situation_counter; } - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; - $thirdpartystatic->client=$obj->client; - $thirdpartystatic->fournisseur=$obj->fournisseur; - $thirdpartystatic->code_client=$obj->code_client; - $thirdpartystatic->code_compta_client=$obj->code_compta_client; - $thirdpartystatic->code_fournisseur=$obj->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur=$obj->code_compta_fournisseur; - $thirdpartystatic->email=$obj->email; - $thirdpartystatic->country_code=$obj->country_code; + $thirdpartystatic->id = $obj->socid; + $thirdpartystatic->name = $obj->name; + $thirdpartystatic->client = $obj->client; + $thirdpartystatic->fournisseur = $obj->fournisseur; + $thirdpartystatic->code_client = $obj->code_client; + $thirdpartystatic->code_compta_client = $obj->code_compta_client; + $thirdpartystatic->code_fournisseur = $obj->code_fournisseur; + $thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + $thirdpartystatic->email = $obj->email; + $thirdpartystatic->country_code = $obj->country_code; - $projectstatic->id=$obj->project_id; - $projectstatic->ref=$obj->project_ref; - $projectstatic->title=$obj->project_label; + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; $paiement = $facturestatic->getSommePaiement(); $totalcreditnotes = $facturestatic->getSumCreditNotesUsed(); @@ -1034,7 +1034,7 @@ if ($resql) print ' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.'\', function() {parent.$.colorbox.close();});"'; } print '>'; - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print '<td class="nowrap">'; @@ -1049,49 +1049,49 @@ if ($resql) { print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); } - print empty($obj->increment)?'':' ('.$obj->increment.')'; + print empty($obj->increment) ? '' : ' ('.$obj->increment.')'; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->id; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->id; print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); print '</td>'; print '</tr>'; print '</table>'; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Customer ref - if (! empty($arrayfields['f.ref_client']['checked'])) + if (!empty($arrayfields['f.ref_client']['checked'])) { print '<td class="nowrap">'; print $obj->ref_client; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type - if (! empty($arrayfields['f.type']['checked'])) + if (!empty($arrayfields['f.type']['checked'])) { print '<td class="nowrap">'; print $facturestatic->getLibType(); print "</td>"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date - if (! empty($arrayfields['f.date']['checked'])) + if (!empty($arrayfields['f.date']['checked'])) { print '<td align="center" class="nowrap">'; print dol_print_date($db->jdate($obj->df), 'day'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date limit - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print '<td align="center" class="nowrap">'.dol_print_date($datelimit, 'day'); if ($facturestatic->hasDelay()) @@ -1099,11 +1099,11 @@ if ($resql) print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="nocellnopadd nowrap">'; if ($obj->project_id > 0) @@ -1111,11 +1111,11 @@ if ($resql) print $projectstatic->getNomUrl(1); } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project title - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print '<td class="nowrap">'; if ($obj->project_id > 0) @@ -1123,11 +1123,11 @@ if ($resql) print $projectstatic->title; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="tdoverflowmax200">'; if ($contextpage == 'poslist') @@ -1350,8 +1350,8 @@ if ($resql) $db->free($resql); - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "</table>\n"; @@ -1359,16 +1359,16 @@ if ($resql) print "</form>\n"; - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->facture->lire; + $delallowed = $user->rights->facture->creer; $title = ''; print $formfile->showdocuments('massfilesarea_invoices', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 43c6c9c7f1d..1f262b18f13 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -145,7 +145,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('contact'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -159,8 +159,8 @@ $fieldstosearchall = array( ); // Definition of fields for list -$arrayfields=array( - 'p.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)), +$arrayfields = array( + 'p.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0)), 'p.lastname'=>array('label'=>"Lastname", 'checked'=>1), 'p.firstname'=>array('label'=>"Firstname", 'checked'=>1), 'p.poste'=>array('label'=>"PostOrFunction", 'checked'=>1), @@ -193,19 +193,19 @@ if (! empty($conf->socialnetworks->enabled)) { // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -if (($id > 0 || ! empty($ref)) && $action != 'add') +if (($id > 0 || !empty($ref)) && $action != 'add') { - $result=$object->fetch($id, $ref); + $result = $object->fetch($id, $ref); if ($result < 0) dol_print_error($db); } @@ -214,11 +214,11 @@ if (($id > 0 || ! empty($ref)) && $action != 'add') * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -385,24 +385,24 @@ elseif ($type == "p") // filtre sur type { $sql .= " AND s.client IN (2, 3)"; } -if (! empty($socid)) +if (!empty($socid)) { $sql .= " AND s.rowid = ".$socid; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; // Add order if ($view == "recent") { - $sql.= $db->order("p.datec", "DESC"); + $sql .= $db->order("p.datec", "DESC"); } else { - $sql.= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); } // Count total nb of records @@ -418,10 +418,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); -if (! $result) +if (!$result) { dol_print_error($db); exit; @@ -429,9 +429,9 @@ if (! $result) $num = $db->num_rows($result); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $search_cti != '')) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $search_cti != '')) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -439,55 +439,55 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && exit; } -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; llxHeader('', $title, $help_url); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -$param.='&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); -$param.='&type='.urlencode($type).'&view='.urlencode($view); -if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ); -if (!empty($search_categ_thirdparty)) $param.='&search_categ_thirdparty='.urlencode($search_categ_thirdparty); -if (!empty($search_categ_supplier)) $param.='&search_categ_supplier='.urlencode($search_categ_supplier); -if ($sall != '') $param.='&sall='.urlencode($sall); -if ($search_id > 0) $param.= "&search_id=".urlencode($search_id); -if ($search_lastname != '') $param.='&search_lastname='.urlencode($search_lastname); -if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_firstname); -if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe); -if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip); -if ($search_town != '') $param.='&search_town='.urlencode($search_town); -if ($search_country != '') $param.= "&search_country=".urlencode($search_country); -if ($search_poste != '') $param.='&search_poste='.urlencode($search_poste); -if ($search_phone_pro != '') $param.='&search_phone_pro='.urlencode($search_phone_pro); -if ($search_phone_perso != '') $param.='&search_phone_perso='.urlencode($search_phone_perso); -if ($search_phone_mobile != '') $param.='&search_phone_mobile='.urlencode($search_phone_mobile); -if ($search_fax != '') $param.='&search_fax='.urlencode($search_fax); -if ($search_email != '') $param.='&search_email='.urlencode($search_email); -if ($search_no_email != '') $param.='&search_no_email='.urlencode($search_no_email); -if ($search_status != '') $param.='&search_status='.urlencode($search_status); -if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv); -if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key); -if ($optioncss != '') $param.='&optioncss='.$optioncss; -if (count($search_roles)>0) $param.=implode('&search_roles[]=', $search_roles); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +$param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); +$param .= '&type='.urlencode($type).'&view='.urlencode($view); +if (!empty($search_categ)) $param .= '&search_categ='.urlencode($search_categ); +if (!empty($search_categ_thirdparty)) $param .= '&search_categ_thirdparty='.urlencode($search_categ_thirdparty); +if (!empty($search_categ_supplier)) $param .= '&search_categ_supplier='.urlencode($search_categ_supplier); +if ($sall != '') $param .= '&sall='.urlencode($sall); +if ($search_id > 0) $param .= "&search_id=".urlencode($search_id); +if ($search_lastname != '') $param .= '&search_lastname='.urlencode($search_lastname); +if ($search_firstname != '') $param .= '&search_firstname='.urlencode($search_firstname); +if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); +if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip); +if ($search_town != '') $param .= '&search_town='.urlencode($search_town); +if ($search_country != '') $param .= "&search_country=".urlencode($search_country); +if ($search_poste != '') $param .= '&search_poste='.urlencode($search_poste); +if ($search_phone_pro != '') $param .= '&search_phone_pro='.urlencode($search_phone_pro); +if ($search_phone_perso != '') $param .= '&search_phone_perso='.urlencode($search_phone_perso); +if ($search_phone_mobile != '') $param .= '&search_phone_mobile='.urlencode($search_phone_mobile); +if ($search_fax != '') $param .= '&search_fax='.urlencode($search_fax); +if ($search_email != '') $param .= '&search_email='.urlencode($search_email); +if ($search_no_email != '') $param .= '&search_no_email='.urlencode($search_no_email); +if ($search_status != '') $param .= '&search_status='.urlencode($search_status); +if ($search_priv == '0' || $search_priv == '1') $param .= "&search_priv=".urlencode($search_priv); +if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key); +if ($optioncss != '') $param .= '&optioncss='.$optioncss; +if (count($search_roles) > 0) $param .= implode('&search_roles[]=', $search_roles); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( // 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->societe->contact->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create'); } print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">'; @@ -502,101 +502,101 @@ print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">'; print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit); -$topicmail="Information"; -$modelmail="contact"; -$objecttmp=new Contact($db); -$trackid='ctc'.$object->id; +$topicmail = "Information"; +$modelmail = "contact"; +$objecttmp = new Contact($db); +$trackid = 'ctc'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } if ($search_firstlast_only) { - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_firstlast_only) . $langs->trans("Lastname").", ".$langs->trans("Firstname").'</div>'; + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_firstlast_only).$langs->trans("Lastname").", ".$langs->trans("Firstname").'</div>'; } -$moreforfilter=''; -if (! empty($conf->categorie->enabled)) +$moreforfilter = ''; +if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$formother->select_categories(Categorie::TYPE_CONTACT, $search_categ, 'search_categ', 1); - $moreforfilter.='</div>'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ, 'search_categ', 1); + $moreforfilter .= '</div>'; if (empty($type) || $type == 'c' || $type == 'p') { - $moreforfilter.='<div class="divsearchfield">'; - if ($type == 'c') $moreforfilter.=$langs->trans('CustomersCategoriesShort'). ': '; - elseif ($type == 'p') $moreforfilter.=$langs->trans('ProspectsCategoriesShort'). ': '; - else $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort'). ': '; - $moreforfilter.=$formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty, 'search_categ_thirdparty', 1); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + if ($type == 'c') $moreforfilter .= $langs->trans('CustomersCategoriesShort').': '; + elseif ($type == 'p') $moreforfilter .= $langs->trans('ProspectsCategoriesShort').': '; + else $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty, 'search_categ_thirdparty', 1); + $moreforfilter .= '</div>'; } if (empty($type) || $type == 'f') { - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('SuppliersCategoriesShort'). ': '; - $moreforfilter.=$formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': '; + $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1); + $moreforfilter .= '</div>'; } - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('Roles'). ': '; - $moreforfilter.=$formcompany->showRoles("search_roles", $objecttmp, 'edit', $search_roles); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('Roles').': '; + $moreforfilter .= $formcompany->showRoles("search_roles", $objecttmp, 'edit', $search_roles); + $moreforfilter .= '</div>'; } if ($moreforfilter) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; - $parameters=array('type'=>$type); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</div>'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Lines for filter fields print '<tr class="liste_titre_filter">'; -if (! empty($arrayfields['p.rowid']['checked'])) +if (!empty($arrayfields['p.rowid']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">'; print '</td>'; } -if (! empty($arrayfields['p.lastname']['checked'])) +if (!empty($arrayfields['p.lastname']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" type="text" name="search_lastname" size="6" value="'.dol_escape_htmltag($search_lastname).'">'; print '</td>'; } -if (! empty($arrayfields['p.firstname']['checked'])) +if (!empty($arrayfields['p.firstname']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" type="text" name="search_firstname" size="6" value="'.dol_escape_htmltag($search_firstname).'">'; print '</td>'; } -if (! empty($arrayfields['p.poste']['checked'])) +if (!empty($arrayfields['p.poste']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" type="text" name="search_poste" size="5" value="'.dol_escape_htmltag($search_poste).'">'; print '</td>'; } -if (! empty($arrayfields['p.zip']['checked'])) +if (!empty($arrayfields['p.zip']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" type="text" name="search_zip" size="3" value="'.dol_escape_htmltag($search_zip).'">'; print '</td>'; } -if (! empty($arrayfields['p.town']['checked'])) +if (!empty($arrayfields['p.town']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" type="text" name="search_town" size="5" value="'.dol_escape_htmltag($search_town).'">'; @@ -688,29 +688,29 @@ if (! empty($arrayfields['p.priv']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (! empty($arrayfields['p.datec']['checked'])) +if (!empty($arrayfields['p.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification -if (! empty($arrayfields['p.tms']['checked'])) +if (!empty($arrayfields['p.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status -if (! empty($arrayfields['p.statut']['checked'])) +if (!empty($arrayfields['p.statut']['checked'])) { print '<td class="liste_titre center">'; - print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status); + print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status); print '</td>'; } -if (! empty($arrayfields['p.import_key']['checked'])) +if (!empty($arrayfields['p.import_key']['checked'])) { print '<td class="liste_titre center">'; print '<input class="flat searchstring" type="text" name="search_import_key" size="3" value="'.dol_escape_htmltag($search_import_key).'">'; @@ -718,7 +718,7 @@ if (! empty($arrayfields['p.import_key']['checked'])) } // Action column print '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterAndCheckAddButtons(0); +$searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '</td>'; @@ -761,18 +761,18 @@ $parameters = array( 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, ); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['p.datec']['checked'])) { +if (!empty($arrayfields['p.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } -if (! empty($arrayfields['p.tms']['checked'])) { +if (!empty($arrayfields['p.tms']['checked'])) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } -if (! empty($arrayfields['p.statut']['checked'])) { +if (!empty($arrayfields['p.statut']['checked'])) { print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center '); } -if (! empty($arrayfields['p.import_key']['checked'])) { +if (!empty($arrayfields['p.import_key']['checked'])) { print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center '); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -920,62 +920,62 @@ while ($i < min($num, $limit)) else print ' '; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Private/Public - if (! empty($arrayfields['p.priv']['checked'])) + if (!empty($arrayfields['p.priv']['checked'])) { print '<td class="center">'.$contactstatic->LibPubPriv($obj->priv).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['p.statut']['checked'])) + if (!empty($arrayfields['p.statut']['checked'])) { print '<td class="center">'.$contactstatic->getLibStatut(5).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.import_key']['checked'])) + if (!empty($arrayfields['p.import_key']['checked'])) { print '<td class="tdoverflowmax100">'; print $obj->import_key; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "</tr>\n"; $i++; @@ -983,8 +983,8 @@ while ($i < min($num, $limit)) $db->free($result); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "</table>"; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 8c6ca195755..47732d3459c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -32,10 +32,10 @@ * \brief File of class to manage contracts */ -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT."/core/class/commonobjectline.class.php"; -require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/margin/lib/margins.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; /** * Class to manage contracts @@ -45,27 +45,27 @@ class Contrat extends CommonObject /** * @var string ID to identify managed object */ - public $element='contrat'; + public $element = 'contrat'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='contrat'; + public $table_element = 'contrat'; /** * @var int Name of subtable line */ - public $table_element_line='contratdet'; + public $table_element_line = 'contratdet'; /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element='fk_contrat'; + public $fk_element = 'fk_contrat'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='contract'; + public $picto = 'contract'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -108,13 +108,13 @@ class Contrat extends CommonObject */ public $socid; - public $societe; // Objet societe + public $societe; // Objet societe /** * Status of the contract * @var int */ - public $statut=0; // 0=Draft, + public $statut = 0; // 0=Draft, public $product; @@ -175,18 +175,18 @@ class Contrat extends CommonObject */ public $fk_projet; - public $extraparams=array(); + public $extraparams = array(); /** * @var ContratLigne[] Contract lines */ - public $lines=array(); + public $lines = array(); /** * Maps ContratLigne IDs to $this->lines indexes * @var int[] */ - protected $lines_id_index_mapper=array(); + protected $lines_id_index_mapper = array(); const STATUS_DRAFT = 0; @@ -230,10 +230,10 @@ class Contrat extends CommonObject $dir = dol_buildpath($reldir."core/modules/contract/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } - if (! $mybool) + if (!$mybool) { dol_print_error('', "Failed to include file ".$file); return ''; @@ -242,7 +242,7 @@ class Contrat extends CommonObject $obj = new $classname(); $numref = $obj->getNextValue($soc, $this); - if ( $numref != "") + if ($numref != "") { return $numref; } @@ -298,7 +298,7 @@ class Contrat extends CommonObject public function close_line($user, $line_id, $date_end, $comment = '') { // phpcs:enable - $result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); if ($result < 0) { $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; @@ -324,12 +324,12 @@ class Contrat extends CommonObject $this->db->begin(); - $error=0; + $error = 0; // Load lines $this->fetch_lines(); - foreach($this->lines as $contratline) + foreach ($this->lines as $contratline) { // Open lines not already open if ($contratline->statut != ContratLigne::STATUS_OPEN) @@ -347,13 +347,13 @@ class Contrat extends CommonObject } } - if (! $error && $this->statut == 0) + if (!$error && $this->statut == 0) { - $result=$this->validate($user, '', $notrigger); + $result = $this->validate($user, '', $notrigger); if ($result < 0) $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -385,15 +385,15 @@ class Contrat extends CommonObject $error = 0; - foreach($this->lines as $contratline) + foreach ($this->lines as $contratline) { // Close lines not already closed if ($contratline->statut != ContratLigne::STATUS_CLOSED) { - $contratline->date_cloture=$now; - $contratline->fk_user_cloture=$user->id; - $contratline->statut=ContratLigne::STATUS_CLOSED; - $result=$contratline->close_line($user, $now, $comment, $notrigger); + $contratline->date_cloture = $now; + $contratline->fk_user_cloture = $user->id; + $contratline->statut = ContratLigne::STATUS_CLOSED; + $result = $contratline->close_line($user, $now, $comment, $notrigger); if ($result < 0) { $error++; @@ -404,13 +404,13 @@ class Contrat extends CommonObject } } - if (! $error && $this->statut == 0) + if (!$error && $this->statut == 0) { - $result=$this->validate($user, '', $notrigger); + $result = $this->validate($user, '', $notrigger); if ($result < 0) $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -435,9 +435,9 @@ class Contrat extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; global $langs, $conf; - $now=dol_now(); + $now = dol_now(); - $error=0; + $error = 0; dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number); @@ -448,7 +448,7 @@ class Contrat extends CommonObject // A contract is validated so we can move thirdparty to status customer if (empty($conf->global->CONTRACT_DISABLE_AUTOSET_AS_CLIENT_ON_CONTRACT_VALIDATION)) { - $result=$this->thirdparty->set_as_client(); + $result = $this->thirdparty->set_as_client(); } // Define new ref @@ -456,7 +456,7 @@ class Contrat extends CommonObject { $num = $force_number; } - elseif (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + elseif (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($this->thirdparty); } @@ -470,27 +470,27 @@ class Contrat extends CommonObject { $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET ref = '".$num."', statut = 1"; //$sql.= ", fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; - $sql .= " WHERE rowid = ".$this->id . " AND statut = 0"; + $sql .= " WHERE rowid = ".$this->id." AND statut = 0"; dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { dol_print_error($this->db); $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } // Trigger calls - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('CONTRACT_VALIDATE', $user); + $result = $this->call_trigger('CONTRACT_VALIDATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -498,17 +498,17 @@ class Contrat extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'contract/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'contract/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'contract/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'contract/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->contract->dir_output.'/'.$oldref; $dirdest = $conf->contract->dir_output.'/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); @@ -516,13 +516,13 @@ class Contrat extends CommonObject { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->contract->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->contract->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -531,7 +531,7 @@ class Contrat extends CommonObject } // Set new ref and define current statut - if (! $error) + if (!$error) { $this->ref = $num; $this->statut = 1; @@ -544,7 +544,7 @@ class Contrat extends CommonObject $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -568,9 +568,9 @@ class Contrat extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; global $langs, $conf; - $now=dol_now(); + $now = dol_now(); - $error=0; + $error = 0; dol_syslog(get_class($this).'::reopen user='.$user->id); $this->db->begin(); @@ -579,22 +579,22 @@ class Contrat extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 0"; //$sql.= ", fk_user_valid = null, date_valid = null"; - $sql .= " WHERE rowid = ".$this->id . " AND statut = 1"; + $sql .= " WHERE rowid = ".$this->id." AND statut = 1"; dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { dol_print_error($this->db); $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } // Trigger calls - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('CONTRACT_REOPEN', $user); + $result = $this->call_trigger('CONTRACT_REOPEN', $user); if ($result < 0) { $error++; } @@ -602,14 +602,14 @@ class Contrat extends CommonObject } // Set new ref and define current status - if (! $error) + if (!$error) { - $this->statut=0; - $this->brouillon=1; - $this->date_validation=$now; + $this->statut = 0; + $this->brouillon = 1; + $this->date_validation = $now; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -633,38 +633,38 @@ class Contrat extends CommonObject public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') { $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,"; - $sql.= " ref_supplier, ref_customer,"; - $sql.= " ref_ext,"; - $sql.= " entity,"; - $sql.= " fk_user_mise_en_service, date_contrat as datecontrat,"; - $sql.= " fk_user_author, fin_validite, date_cloture,"; - $sql.= " fk_projet as fk_project,"; - $sql.= " fk_commercial_signature, fk_commercial_suivi,"; - $sql.= " note_private, note_public, model_pdf, extraparams"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; - if (! $id) $sql.=" WHERE entity IN (".getEntity('contract').")"; - else $sql.= " WHERE rowid=".$id; + $sql .= " ref_supplier, ref_customer,"; + $sql .= " ref_ext,"; + $sql .= " entity,"; + $sql .= " fk_user_mise_en_service, date_contrat as datecontrat,"; + $sql .= " fk_user_author, fin_validite, date_cloture,"; + $sql .= " fk_projet as fk_project,"; + $sql .= " fk_commercial_signature, fk_commercial_suivi,"; + $sql .= " note_private, note_public, model_pdf, extraparams"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat"; + if (!$id) $sql .= " WHERE entity IN (".getEntity('contract').")"; + else $sql .= " WHERE rowid=".$id; if ($ref_customer) { - $sql.= " AND ref_customer = '".$this->db->escape($ref_customer)."'"; + $sql .= " AND ref_customer = '".$this->db->escape($ref_customer)."'"; } if ($ref_supplier) { - $sql.= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'"; + $sql .= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'"; } if ($ref) { - $sql.= " AND ref='".$this->db->escape($ref)."'"; + $sql .= " AND ref='".$this->db->escape($ref)."'"; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); + $num = $this->db->num_rows($resql); if ($num > 1) { - $this->error='Fetch found several records.'; + $this->error = 'Fetch found several records.'; dol_syslog($this->error, LOG_ERR); $result = -2; } @@ -673,14 +673,14 @@ class Contrat extends CommonObject $obj = $this->db->fetch_object($resql); if ($obj) { - $this->id = $obj->rowid; - $this->ref = (!isset($obj->ref) || !$obj->ref) ? $obj->rowid : $obj->ref; + $this->id = $obj->rowid; + $this->ref = (!isset($obj->ref) || !$obj->ref) ? $obj->rowid : $obj->ref; $this->ref_customer = $obj->ref_customer; $this->ref_supplier = $obj->ref_supplier; - $this->ref_ext = $obj->ref_ext; - $this->entity = $obj->entity; - $this->statut = $obj->statut; - $this->mise_en_service = $this->db->jdate($obj->datemise); + $this->ref_ext = $obj->ref_ext; + $this->entity = $obj->entity; + $this->statut = $obj->statut; + $this->mise_en_service = $this->db->jdate($obj->datemise); $this->date_contrat = $this->db->jdate($obj->datecontrat); $this->date_creation = $this->db->jdate($obj->datecontrat); @@ -689,20 +689,20 @@ class Contrat extends CommonObject $this->date_cloture = $this->db->jdate($obj->date_cloture); - $this->user_author_id = $obj->fk_user_author; + $this->user_author_id = $obj->fk_user_author; $this->commercial_signature_id = $obj->fk_commercial_signature; - $this->commercial_suivi_id = $obj->fk_commercial_suivi; + $this->commercial_suivi_id = $obj->fk_commercial_suivi; - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; $this->modelpdf = $obj->model_pdf; $this->fk_projet = $obj->fk_project; // deprecated - $this->fk_project = $obj->fk_project; + $this->fk_project = $obj->fk_project; - $this->socid = $obj->fk_soc; - $this->fk_soc = $obj->fk_soc; + $this->socid = $obj->fk_soc; + $this->fk_soc = $obj->fk_soc; $this->extraparams = (array) json_decode($obj->extraparams, true); @@ -713,10 +713,10 @@ class Contrat extends CommonObject $this->fetch_optionals(); // Lines - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -3; } @@ -726,14 +726,14 @@ class Contrat extends CommonObject else { dol_syslog(get_class($this)."::fetch Contract not found"); - $this->error="Contract not found"; + $this->error = "Contract not found"; return 0; } } else { dol_syslog(get_class($this)."::fetch Error searching contract"); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -753,47 +753,47 @@ class Contrat extends CommonObject // phpcs:enable global $langs, $conf, $extrafields; - $this->nbofserviceswait=0; - $this->nbofservicesopened=0; - $this->nbofservicesexpired=0; - $this->nbofservicesclosed=0; + $this->nbofserviceswait = 0; + $this->nbofservicesopened = 0; + $this->nbofservicesexpired = 0; + $this->nbofservicesclosed = 0; - $total_ttc=0; - $total_vat=0; - $total_ht=0; + $total_ttc = 0; + $total_vat = 0; + $total_ht = 0; - $now=dol_now(); + $now = dol_now(); - if (! is_object($extrafields)) + if (!is_object($extrafields)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); + $extrafields = new ExtraFields($this->db); } $line = new ContratLigne($this->db); $extrafields->fetch_name_optionals_label($line->table_element, true); - $this->lines=array(); + $this->lines = array(); $pos = 0; // Selects contract lines related to a product $sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,"; - $sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; - $sql.= " d.total_ht,"; - $sql.= " d.total_tva,"; - $sql.= " d.total_localtax1,"; - $sql.= " d.total_localtax2,"; - $sql.= " d.total_ttc,"; - $sql.= " d.info_bits, d.fk_product,"; - $sql.= " d.date_ouverture_prevue, d.date_ouverture,"; - $sql.= " d.date_fin_validite, d.date_cloture,"; - $sql.= " d.fk_user_author,"; - $sql.= " d.fk_user_ouverture,"; - $sql.= " d.fk_user_cloture,"; - $sql.= " d.fk_unit"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; - $sql.= " WHERE d.fk_contrat = ".$this->id; - $sql.= " ORDER by d.rowid ASC"; + $sql .= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; + $sql .= " d.total_ht,"; + $sql .= " d.total_tva,"; + $sql .= " d.total_localtax1,"; + $sql .= " d.total_localtax2,"; + $sql .= " d.total_ttc,"; + $sql .= " d.info_bits, d.fk_product,"; + $sql .= " d.date_ouverture_prevue, d.date_ouverture,"; + $sql .= " d.date_fin_validite, d.date_cloture,"; + $sql .= " d.fk_user_author,"; + $sql .= " d.fk_user_ouverture,"; + $sql .= " d.fk_user_cloture,"; + $sql .= " d.fk_unit"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as d LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; + $sql .= " WHERE d.fk_contrat = ".$this->id; + $sql .= " ORDER by d.rowid ASC"; dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $result = $this->db->query($sql); @@ -806,46 +806,46 @@ class Contrat extends CommonObject { $objp = $this->db->fetch_object($result); - $line = new ContratLigne($this->db); - $line->id = $objp->rowid; + $line = new ContratLigne($this->db); + $line->id = $objp->rowid; $line->ref = $objp->rowid; - $line->fk_contrat = $objp->fk_contrat; - $line->desc = $objp->description; // Description line + $line->fk_contrat = $objp->fk_contrat; + $line->desc = $objp->description; // Description line $line->qty = $objp->qty; - $line->vat_src_code = $objp->vat_src_code ; - $line->tva_tx = $objp->tva_tx; + $line->vat_src_code = $objp->vat_src_code; + $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; $line->localtax1_type = $objp->localtax1_type; $line->localtax2_type = $objp->localtax2_type; $line->subprice = $objp->subprice; - $line->statut = $objp->statut; + $line->statut = $objp->statut; $line->remise_percent = $objp->remise_percent; $line->price_ht = $objp->price_ht; - $line->price = $objp->price_ht; // For backward compatibility + $line->price = $objp->price_ht; // For backward compatibility $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; $line->total_localtax1 = $objp->total_localtax1; $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; - $line->fk_product = (($objp->fk_product > 0)?$objp->fk_product:0); + $line->fk_product = (($objp->fk_product > 0) ? $objp->fk_product : 0); $line->info_bits = $objp->info_bits; - $line->fk_fournprice = $objp->fk_fournprice; + $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; + $line->pa_ht = $marginInfos[0]; - $line->fk_user_author = $objp->fk_user_author; - $line->fk_user_ouverture= $objp->fk_user_ouverture; + $line->fk_user_author = $objp->fk_user_author; + $line->fk_user_ouverture = $objp->fk_user_ouverture; $line->fk_user_cloture = $objp->fk_user_cloture; - $line->fk_unit = $objp->fk_unit; + $line->fk_unit = $objp->fk_unit; - $line->ref = $objp->product_ref; // deprecated - $line->product_ref = $objp->product_ref; // Product Ref - $line->product_desc = $objp->product_desc; // Product Description + $line->ref = $objp->product_ref; // deprecated + $line->product_ref = $objp->product_ref; // Product Ref + $line->product_desc = $objp->product_desc; // Product Description $line->product_label = $objp->product_label; // Product Label - $line->description = $objp->description; + $line->description = $objp->description; $line->date_start = $this->db->jdate($objp->date_ouverture_prevue); $line->date_start_real = $this->db->jdate($objp->date_ouverture); @@ -866,7 +866,7 @@ class Contrat extends CommonObject $line->fetch_optionals(); // multilangs - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { $line = new Product($this->db); $line->fetch($objp->fk_product); $line->getMultiLangs(); @@ -880,12 +880,12 @@ class Contrat extends CommonObject if ($line->statut == ContratLigne::STATUS_INITIAL) $this->nbofserviceswait++; if ($line->statut == ContratLigne::STATUS_OPEN && (empty($line->date_fin_prevue) || $line->date_fin_prevue >= $now)) $this->nbofservicesopened++; - if ($line->statut == ContratLigne::STATUS_OPEN && (! empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++; + if ($line->statut == ContratLigne::STATUS_OPEN && (!empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++; if ($line->statut == ContratLigne::STATUS_CLOSED) $this->nbofservicesclosed++; - $total_ttc+=$objp->total_ttc; // TODO Not saved into database - $total_vat+=$objp->total_tva; - $total_ht+=$objp->total_ht; + $total_ttc += $objp->total_ttc; // TODO Not saved into database + $total_vat += $objp->total_tva; + $total_ht += $objp->total_ht; $i++; $pos++; @@ -898,10 +898,10 @@ class Contrat extends CommonObject return -3; } - $this->nbofservices=count($this->lines); - $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_vat = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->nbofservices = count($this->lines); + $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_vat = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products return $this->lines; } @@ -914,82 +914,82 @@ class Contrat extends CommonObject */ public function create($user) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Check parameters - $paramsok=1; + $paramsok = 1; if ($this->commercial_signature_id <= 0) { $langs->load("commercial"); - $this->error.=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SalesRepresentativeSignature")); - $paramsok=0; + $this->error .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SalesRepresentativeSignature")); + $paramsok = 0; } if ($this->commercial_suivi_id <= 0) { $langs->load("commercial"); - $this->error.=($this->error?"<br>":''); - $this->error.=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SalesRepresentativeFollowUp")); - $paramsok=0; + $this->error .= ($this->error ? "<br>" : ''); + $this->error .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SalesRepresentativeFollowUp")); + $paramsok = 0; } - if (! $paramsok) return -1; + if (!$paramsok) return -1; $this->db->begin(); - $now=dol_now(); + $now = dol_now(); // Insert contract $sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat,"; - $sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,"; - $sql.= " ref, entity, note_private, note_public, ref_customer, ref_supplier, ref_ext)"; - $sql.= " VALUES ('".$this->db->idate($now)."',".$this->socid.",".$user->id; - $sql.= ", ".(dol_strlen($this->date_contrat)!=0 ? "'".$this->db->idate($this->date_contrat)."'" : "NULL"); - $sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL"); - $sql.= ",".($this->commercial_suivi_id>0?$this->commercial_suivi_id:"NULL"); - $sql.= ",".($this->fk_project>0?$this->fk_project:"NULL"); - $sql.= ", ".(dol_strlen($this->ref)<=0 ? "null" : "'".$this->db->escape($this->ref)."'"); - $sql.= ", ".$conf->entity; - $sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL"); - $sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL"); - $sql.= ", ".(!empty($this->ref_customer)?("'".$this->db->escape($this->ref_customer)."'"):"NULL"); - $sql.= ", ".(!empty($this->ref_supplier)?("'".$this->db->escape($this->ref_supplier)."'"):"NULL"); - $sql.= ", ".(!empty($this->ref_ext)?("'".$this->db->escape($this->ref_ext)."'"):"NULL"); - $sql.= ")"; - $resql=$this->db->query($sql); + $sql .= " fk_commercial_signature, fk_commercial_suivi, fk_projet,"; + $sql .= " ref, entity, note_private, note_public, ref_customer, ref_supplier, ref_ext)"; + $sql .= " VALUES ('".$this->db->idate($now)."',".$this->socid.",".$user->id; + $sql .= ", ".(dol_strlen($this->date_contrat) != 0 ? "'".$this->db->idate($this->date_contrat)."'" : "NULL"); + $sql .= ",".($this->commercial_signature_id > 0 ? $this->commercial_signature_id : "NULL"); + $sql .= ",".($this->commercial_suivi_id > 0 ? $this->commercial_suivi_id : "NULL"); + $sql .= ",".($this->fk_project > 0 ? $this->fk_project : "NULL"); + $sql .= ", ".(dol_strlen($this->ref) <= 0 ? "null" : "'".$this->db->escape($this->ref)."'"); + $sql .= ", ".$conf->entity; + $sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL"); + $sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); + $sql .= ", ".(!empty($this->ref_customer) ? ("'".$this->db->escape($this->ref_customer)."'") : "NULL"); + $sql .= ", ".(!empty($this->ref_supplier) ? ("'".$this->db->escape($this->ref_supplier)."'") : "NULL"); + $sql .= ", ".(!empty($this->ref_ext) ? ("'".$this->db->escape($this->ref_ext)."'") : "NULL"); + $sql .= ")"; + $resql = $this->db->query($sql); if ($resql) { - $error=0; + $error = 0; $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."contrat"); // Load object modContract - $module=(! empty($conf->global->CONTRACT_ADDON)?$conf->global->CONTRACT_ADDON:'mod_contract_serpis'); + $module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module)-4); + $module = substr($module, 0, dol_strlen($module) - 4); } - $result=dol_include_once('/core/modules/contract/'.$module.'.php'); + $result = dol_include_once('/core/modules/contract/'.$module.'.php'); if ($result > 0) { $modCodeContract = new $module(); - if (! empty($modCodeContract->code_auto)) { + if (!empty($modCodeContract->code_auto)) { // Force the ref to a draft value if numbering module is an automatic numbering $sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; if ($this->db->query($sql)) { if ($this->id) { - $this->ref="(PROV".$this->id.")"; + $this->ref = "(PROV".$this->id.")"; } } } } - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -997,39 +997,39 @@ class Contrat extends CommonObject } // Insert business contacts ('SALESREPSIGN','contrat') - if (! $error) + if (!$error) { - $result=$this->add_contact($this->commercial_signature_id, 'SALESREPSIGN', 'internal'); + $result = $this->add_contact($this->commercial_signature_id, 'SALESREPSIGN', 'internal'); if ($result < 0) $error++; } // Insert business contacts ('SALESREPFOLL','contrat') - if (! $error) + if (!$error) { - $result=$this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); + $result = $this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); if ($result < 0) $error++; } - if (! $error) + if (!$error) { - if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) { - foreach($this->linked_objects as $origin => $tmp_origin_id) + foreach ($this->linked_objects as $origin => $tmp_origin_id) { if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) { - foreach($tmp_origin_id as $origin_id) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -1038,22 +1038,22 @@ class Contrat extends CommonObject { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } } } - if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object { $originforcontact = $this->origin; $originidforcontact = $this->origin_id; if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order { - require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $exp = new Expedition($db); $exp->fetch($this->origin_id); $exp->fetchObjectLinked(); @@ -1069,31 +1069,31 @@ class Contrat extends CommonObject } $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; + $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { - while($objcontact = $this->db->fetch_object($resqlcontact)) + while ($objcontact = $this->db->fetch_object($resqlcontact)) { - if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) continue; // ignore this, already forced previously + if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) continue; // ignore this, already forced previously //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object } } else dol_print_error($resqlcontact); } } - if (! $error) + if (!$error) { // Call trigger - $result=$this->call_trigger('CONTRACT_CREATE', $user); + $result = $this->call_trigger('CONTRACT_CREATE', $user); if ($result < 0) { $error++; } // End call triggers - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -1107,7 +1107,7 @@ class Contrat extends CommonObject } else { - $this->error="Failed to add contract"; + $this->error = "Failed to add contract"; dol_syslog(get_class($this)."::create - 20 - ".$this->error, LOG_ERR); $this->db->rollback(); return -2; @@ -1115,7 +1115,7 @@ class Contrat extends CommonObject } else { - $this->error=$langs->trans("UnknownError: ".$this->db->error()." -", LOG_DEBUG); + $this->error = $langs->trans("UnknownError: ".$this->db->error()." -", LOG_DEBUG); $this->db->rollback(); return -1; @@ -1132,18 +1132,18 @@ class Contrat extends CommonObject public function delete($user) { global $conf, $langs; - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; $this->db->begin(); // Call trigger - $result=$this->call_trigger('CONTRACT_DELETE', $user); + $result = $this->call_trigger('CONTRACT_DELETE', $user); if ($result < 0) { $error++; } // End call triggers - if (! $error) + if (!$error) { // Delete linked contacts $res = $this->delete_linked_contact(); @@ -1154,14 +1154,14 @@ class Contrat extends CommonObject } } - if (! $error) + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; } - if (! $error) + if (!$error) { // Delete contratdet_log /* @@ -1170,73 +1170,73 @@ class Contrat extends CommonObject $sql.= " WHERE cdl.fk_contratdet=cd.rowid AND cd.fk_contrat=".$this->id; */ $sql = "SELECT cdl.rowid as cdlrowid "; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet_log as cdl, ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " WHERE cdl.fk_contratdet=cd.rowid AND cd.fk_contrat=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet_log as cdl, ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " WHERE cdl.fk_contratdet=cd.rowid AND cd.fk_contrat=".$this->id; dol_syslog(get_class($this)."::delete contratdet_log", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $error++; } - $numressql=$this->db->num_rows($resql); - if (! $error && $numressql ) + $numressql = $this->db->num_rows($resql); + if (!$error && $numressql) { - $tab_resql=array(); - for($i=0;$i<$numressql;$i++) + $tab_resql = array(); + for ($i = 0; $i < $numressql; $i++) { - $objresql=$this->db->fetch_object($resql); - $tab_resql[]= $objresql->cdlrowid; + $objresql = $this->db->fetch_object($resql); + $tab_resql[] = $objresql->cdlrowid; } $this->db->free($resql); - $sql= "DELETE FROM ".MAIN_DB_PREFIX."contratdet_log "; - $sql.= " WHERE ".MAIN_DB_PREFIX."contratdet_log.rowid IN (".implode(",", $tab_resql).")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet_log "; + $sql .= " WHERE ".MAIN_DB_PREFIX."contratdet_log.rowid IN (".implode(",", $tab_resql).")"; dol_syslog(get_class($this)."::delete contratdet_log", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $error++; } } } - if (! $error) + if (!$error) { // Delete contratdet $sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet"; - $sql.= " WHERE fk_contrat=".$this->id; + $sql .= " WHERE fk_contrat=".$this->id; dol_syslog(get_class($this)."::delete contratdet", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $error++; } } - if (! $error) + if (!$error) { // Delete contrat $sql = "DELETE FROM ".MAIN_DB_PREFIX."contrat"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete contrat", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $error++; } } // Removed extrafields - if (! $error) { - $result=$this->deleteExtraFields(); + if (!$error) { + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -1244,33 +1244,33 @@ class Contrat extends CommonObject } } - if (! $error) + if (!$error) { // We remove directory $ref = dol_sanitizeFileName($this->ref); if ($conf->contrat->dir_output) { - $dir = $conf->contrat->dir_output . "/" . $ref; + $dir = $conf->contrat->dir_output."/".$ref; if (file_exists($dir)) { - $res=@dol_delete_dir_recursive($dir); - if (! $res) + $res = @dol_delete_dir_recursive($dir); + if (!$res) { - $this->error='ErrorFailToDeleteDir'; + $this->error = 'ErrorFailToDeleteDir'; $error++; } } } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -1286,7 +1286,7 @@ class Contrat extends CommonObject public function update($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters if (empty($this->fk_commercial_signature) && $this->commercial_signature_id > 0) $this->fk_commercial_signature = $this->commercial_signature_id; @@ -1294,20 +1294,20 @@ class Contrat extends CommonObject if (empty($this->fk_soc) && $this->socid > 0) $this->fk_soc = $this->socid; if (empty($this->fk_project) && $this->projet > 0) $this->fk_project = $this->projet; - if (isset($this->ref)) $this->ref=trim($this->ref); - if (isset($this->ref_customer)) $this->ref_customer=trim($this->ref_customer); - if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier); - if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext); - if (isset($this->entity)) $this->entity=trim($this->entity); - if (isset($this->statut)) $this->statut=(int) $this->statut; - if (isset($this->fk_soc)) $this->fk_soc=trim($this->fk_soc); - if (isset($this->fk_commercial_signature)) $this->fk_commercial_signature=trim($this->fk_commercial_signature); - if (isset($this->fk_commercial_suivi)) $this->fk_commercial_suivi=trim($this->fk_commercial_suivi); - if (isset($this->fk_user_mise_en_service)) $this->fk_user_mise_en_service=trim($this->fk_user_mise_en_service); - if (isset($this->fk_user_cloture)) $this->fk_user_cloture=trim($this->fk_user_cloture); - if (isset($this->note_private)) $this->note_private=trim($this->note_private); - if (isset($this->note_public)) $this->note_public=trim($this->note_public); - if (isset($this->import_key)) $this->import_key=trim($this->import_key); + if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->ref_customer)) $this->ref_customer = trim($this->ref_customer); + if (isset($this->ref_supplier)) $this->ref_supplier = trim($this->ref_supplier); + if (isset($this->ref_ext)) $this->ref_ext = trim($this->ref_ext); + if (isset($this->entity)) $this->entity = trim($this->entity); + if (isset($this->statut)) $this->statut = (int) $this->statut; + if (isset($this->fk_soc)) $this->fk_soc = trim($this->fk_soc); + if (isset($this->fk_commercial_signature)) $this->fk_commercial_signature = trim($this->fk_commercial_signature); + if (isset($this->fk_commercial_suivi)) $this->fk_commercial_suivi = trim($this->fk_commercial_suivi); + if (isset($this->fk_user_mise_en_service)) $this->fk_user_mise_en_service = trim($this->fk_user_mise_en_service); + if (isset($this->fk_user_cloture)) $this->fk_user_cloture = trim($this->fk_user_cloture); + if (isset($this->note_private)) $this->note_private = trim($this->note_private); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); + if (isset($this->import_key)) $this->import_key = trim($this->import_key); //if (isset($this->extraparams)) $this->extraparams=trim($this->extraparams); // Check parameters @@ -1315,46 +1315,46 @@ class Contrat extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET"; - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; - $sql.= " ref_customer=".(isset($this->ref_customer)?"'".$this->db->escape($this->ref_customer)."'":"null").","; - $sql.= " ref_supplier=".(isset($this->ref_supplier)?"'".$this->db->escape($this->ref_supplier)."'":"null").","; - $sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").","; - $sql.= " entity=".$conf->entity.","; - $sql.= " date_contrat=".(dol_strlen($this->date_contrat)!=0 ? "'".$this->db->idate($this->date_contrat)."'" : 'null').","; - $sql.= " statut=".(isset($this->statut)?$this->statut:"null").","; - $sql.= " mise_en_service=".(dol_strlen($this->mise_en_service)!=0 ? "'".$this->db->idate($this->mise_en_service)."'" : 'null').","; - $sql.= " fin_validite=".(dol_strlen($this->fin_validite)!=0 ? "'".$this->db->idate($this->fin_validite)."'" : 'null').","; - $sql.= " date_cloture=".(dol_strlen($this->date_cloture)!=0 ? "'".$this->db->idate($this->date_cloture)."'" : 'null').","; - $sql.= " fk_soc=".($this->fk_soc > 0 ? $this->fk_soc:"null").","; - $sql.= " fk_projet=".($this->fk_project > 0 ? $this->fk_project:"null").","; - $sql.= " fk_commercial_signature=".(isset($this->fk_commercial_signature)?$this->fk_commercial_signature:"null").","; - $sql.= " fk_commercial_suivi=".(isset($this->fk_commercial_suivi)?$this->fk_commercial_suivi:"null").","; - $sql.= " fk_user_mise_en_service=".(isset($this->fk_user_mise_en_service)?$this->fk_user_mise_en_service:"null").","; - $sql.= " fk_user_cloture=".(isset($this->fk_user_cloture)?$this->fk_user_cloture:"null").","; - $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; - $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").""; + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " ref_customer=".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").","; + $sql .= " ref_supplier=".(isset($this->ref_supplier) ? "'".$this->db->escape($this->ref_supplier)."'" : "null").","; + $sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").","; + $sql .= " entity=".$conf->entity.","; + $sql .= " date_contrat=".(dol_strlen($this->date_contrat) != 0 ? "'".$this->db->idate($this->date_contrat)."'" : 'null').","; + $sql .= " statut=".(isset($this->statut) ? $this->statut : "null").","; + $sql .= " mise_en_service=".(dol_strlen($this->mise_en_service) != 0 ? "'".$this->db->idate($this->mise_en_service)."'" : 'null').","; + $sql .= " fin_validite=".(dol_strlen($this->fin_validite) != 0 ? "'".$this->db->idate($this->fin_validite)."'" : 'null').","; + $sql .= " date_cloture=".(dol_strlen($this->date_cloture) != 0 ? "'".$this->db->idate($this->date_cloture)."'" : 'null').","; + $sql .= " fk_soc=".($this->fk_soc > 0 ? $this->fk_soc : "null").","; + $sql .= " fk_projet=".($this->fk_project > 0 ? $this->fk_project : "null").","; + $sql .= " fk_commercial_signature=".(isset($this->fk_commercial_signature) ? $this->fk_commercial_signature : "null").","; + $sql .= " fk_commercial_suivi=".(isset($this->fk_commercial_suivi) ? $this->fk_commercial_suivi : "null").","; + $sql .= " fk_user_mise_en_service=".(isset($this->fk_user_mise_en_service) ? $this->fk_user_mise_en_service : "null").","; + $sql .= " fk_user_cloture=".(isset($this->fk_user_cloture) ? $this->fk_user_cloture : "null").","; + $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; + $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; //$sql.= " extraparams=".(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").""; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger('CONTRACT_MODIFY', $user); + $result = $this->call_trigger('CONTRACT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -1362,13 +1362,13 @@ class Contrat extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -1404,66 +1404,66 @@ class Contrat extends CommonObject public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) { global $user, $langs, $conf, $mysoc; - $error=0; + $error = 0; dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $pu_ttc, $info_bits, $rang"); // Check parameters if ($fk_product <= 0 && empty($desc)) { - $this->error="ErrorDescRequiredForFreeProductLines"; + $this->error = "ErrorDescRequiredForFreeProductLines"; return -1; } if ($this->statut >= 0) { // Clean parameters - $pu_ht=price2num($pu_ht); - $pu_ttc=price2num($pu_ttc); - $pa_ht=price2num($pa_ht); + $pu_ht = price2num($pu_ht); + $pu_ttc = price2num($pu_ttc); + $pa_ht = price2num($pa_ht); if (!preg_match('/\((.*)\)/', $txtva)) { - $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' } - $txlocaltax1=price2num($txlocaltax1); - $txlocaltax2=price2num($txlocaltax2); - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - if (empty($qty)) $qty=1; - if (empty($info_bits)) $info_bits=0; - if (empty($pu_ht) || ! is_numeric($pu_ht)) $pu_ht=0; - if (empty($pu_ttc)) $pu_ttc=0; - if (empty($txtva) || ! is_numeric($txtva)) $txtva=0; - if (empty($txlocaltax1) || ! is_numeric($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2) || ! is_numeric($txlocaltax2)) $txlocaltax2=0; + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + if (empty($qty)) $qty = 1; + if (empty($info_bits)) $info_bits = 0; + if (empty($pu_ht) || !is_numeric($pu_ht)) $pu_ht = 0; + if (empty($pu_ttc)) $pu_ttc = 0; + if (empty($txtva) || !is_numeric($txtva)) $txtva = 0; + if (empty($txlocaltax1) || !is_numeric($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2) || !is_numeric($txlocaltax2)) $txlocaltax2 = 0; - if ($price_base_type=='HT') + if ($price_base_type == 'HT') { - $pu=$pu_ht; + $pu = $pu_ht; } else { - $pu=$pu_ttc; + $pu = $pu_ttc; } // Check parameters - if (empty($remise_percent)) $remise_percent=0; + if (empty($remise_percent)) $remise_percent = 0; if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } $this->db->begin(); - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } // Calcul du total TTC et de la TVA pour la ligne a partir de @@ -1471,15 +1471,15 @@ class Contrat extends CommonObject // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; - $total_localtax1= $tabprice[9]; - $total_localtax2= $tabprice[10]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; - $localtax1_type=$localtaxes_type[0]; - $localtax2_type=$localtaxes_type[2]; + $localtax1_type = $localtaxes_type[0]; + $localtax2_type = $localtaxes_type[2]; // TODO A virer // Anciens indicateurs: $price, $remise (a ne plus utiliser) @@ -1491,7 +1491,7 @@ class Contrat extends CommonObject $price = $pu_ht - $remise; } - if (empty($pa_ht)) $pa_ht=0; + if (empty($pa_ht)) $pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin @@ -1509,59 +1509,59 @@ class Contrat extends CommonObject // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet"; - $sql.= " (fk_contrat, label, description, fk_product, qty, tva_tx, vat_src_code,"; - $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,"; - $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; - $sql.= " info_bits,"; - $sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; - if ($date_start > 0) { $sql.= ",date_ouverture_prevue"; } - if ($date_end > 0) { $sql.= ",date_fin_validite"; } - $sql.= ", fk_unit"; - $sql.= ") VALUES ("; - $sql.= $this->id.", '', '" . $this->db->escape($desc) . "',"; - $sql.= ($fk_product>0 ? $fk_product : "null").","; - $sql.= " ".$qty.","; - $sql.= " ".$txtva.","; - $sql.= " ".($vat_src_code?"'".$vat_src_code."'":"null").","; - $sql.= " ".$txlocaltax1.","; - $sql.= " ".$txlocaltax2.","; - $sql.= " '".$localtax1_type."',"; - $sql.= " '".$localtax2_type."',"; - $sql.= " ".price2num($remise_percent).","; - $sql.= " ".price2num($pu_ht).","; - $sql.= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).","; - $sql.= " '".$info_bits."',"; - $sql.= " ".price2num($price).",".price2num($remise).","; - if (isset($fk_fournprice)) $sql.= ' '.$fk_fournprice.','; - else $sql.= ' null,'; - if (isset($pa_ht)) $sql.= ' '.price2num($pa_ht); - else $sql.= ' null'; - if ($date_start > 0) { $sql.= ",'".$this->db->idate($date_start)."'"; } - if ($date_end > 0) { $sql.= ",'".$this->db->idate($date_end)."'"; } - $sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); - $sql.= ")"; + $sql .= " (fk_contrat, label, description, fk_product, qty, tva_tx, vat_src_code,"; + $sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,"; + $sql .= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; + $sql .= " info_bits,"; + $sql .= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; + if ($date_start > 0) { $sql .= ",date_ouverture_prevue"; } + if ($date_end > 0) { $sql .= ",date_fin_validite"; } + $sql .= ", fk_unit"; + $sql .= ") VALUES ("; + $sql .= $this->id.", '', '".$this->db->escape($desc)."',"; + $sql .= ($fk_product > 0 ? $fk_product : "null").","; + $sql .= " ".$qty.","; + $sql .= " ".$txtva.","; + $sql .= " ".($vat_src_code ? "'".$vat_src_code."'" : "null").","; + $sql .= " ".$txlocaltax1.","; + $sql .= " ".$txlocaltax2.","; + $sql .= " '".$localtax1_type."',"; + $sql .= " '".$localtax2_type."',"; + $sql .= " ".price2num($remise_percent).","; + $sql .= " ".price2num($pu_ht).","; + $sql .= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).","; + $sql .= " '".$info_bits."',"; + $sql .= " ".price2num($price).",".price2num($remise).","; + if (isset($fk_fournprice)) $sql .= ' '.$fk_fournprice.','; + else $sql .= ' null,'; + if (isset($pa_ht)) $sql .= ' '.price2num($pa_ht); + else $sql .= ' null'; + if ($date_start > 0) { $sql .= ",'".$this->db->idate($date_start)."'"; } + if ($date_end > 0) { $sql .= ",'".$this->db->idate($date_end)."'"; } + $sql .= ", ".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); + $sql .= ")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $contractlineid = $this->db->last_insert_id(MAIN_DB_PREFIX."contratdet"); - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); - $contractline->array_options=$array_options; - $contractline->id=$contractlineid; - $result=$contractline->insertExtraFields(); + $contractline->array_options = $array_options; + $contractline->id = $contractlineid; + $result = $contractline->insertExtraFields(); if ($result < 0) { - $this->error[]=$contractline->error; + $this->error[] = $contractline->error; $error++; } } if (empty($error)) { // Call trigger - $result=$this->call_trigger('LINECONTRACT_INSERT', $user); + $result = $this->call_trigger('LINECONTRACT_INSERT', $user); if ($result < 0) { $error++; @@ -1583,7 +1583,7 @@ class Contrat extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; return -1; } } @@ -1621,18 +1621,18 @@ class Contrat extends CommonObject { global $user, $conf, $langs, $mysoc; - $error=0; + $error = 0; // Clean parameters - $qty=trim($qty); - $desc=trim($desc); - $desc=trim($desc); + $qty = trim($qty); + $desc = trim($desc); + $desc = trim($desc); $price = price2num($pu); $tvatx = price2num($tvatx); $localtax1tx = price2num($localtax1tx); $localtax2tx = price2num($localtax2tx); - $pa_ht=price2num($pa_ht); - if (empty($fk_fournprice)) $fk_fournprice=0; + $pa_ht = price2num($pa_ht); + if (empty($fk_fournprice)) $fk_fournprice = 0; $subprice = $price; $remise = 0; @@ -1643,12 +1643,12 @@ class Contrat extends CommonObject } else { - $remise_percent=0; + $remise_percent = 0; } if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } @@ -1661,18 +1661,18 @@ class Contrat extends CommonObject // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($tvatx, 0, $this->societe, $mysoc); - $tvatx = preg_replace('/\s*\(.*\)/', '', $tvatx); // Remove code into vatrate. + $localtaxes_type = getLocalTaxesFromRate($tvatx, 0, $this->societe, $mysoc); + $tvatx = preg_replace('/\s*\(.*\)/', '', $tvatx); // Remove code into vatrate. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtax1tx, $localtax2tx, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtax1tx, $localtax2tx, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; - $total_localtax1= $tabprice[9]; - $total_localtax2= $tabprice[10]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; - $localtax1_type=$localtaxes_type[0]; - $localtax2_type=$localtaxes_type[2]; + $localtax1_type = $localtaxes_type[0]; + $localtax2_type = $localtaxes_type[2]; // TODO A virer // Anciens indicateurs: $price, $remise (a ne plus utiliser) @@ -1684,7 +1684,7 @@ class Contrat extends CommonObject $price = $pu - $remise; } - if (empty($pa_ht)) $pa_ht=0; + if (empty($pa_ht)) $pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) @@ -1700,57 +1700,57 @@ class Contrat extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'"; - $sql.= ",price_ht='".price2num($price)."'"; - $sql.= ",subprice='".price2num($subprice)."'"; - $sql.= ",remise='".price2num($remise)."'"; - $sql.= ",remise_percent='".price2num($remise_percent)."'"; - $sql.= ",qty='".$qty."'"; - $sql.= ",tva_tx='".price2num($tvatx)."'"; - $sql.= ",localtax1_tx='".price2num($localtax1tx)."'"; - $sql.= ",localtax2_tx='".price2num($localtax2tx)."'"; - $sql.= ",localtax1_type='".$localtax1_type."'"; - $sql.= ",localtax2_type='".$localtax2_type."'"; - $sql.= ", total_ht='".price2num($total_ht)."'"; - $sql.= ", total_tva='".price2num($total_tva)."'"; - $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; - $sql.= ", total_localtax2='".price2num($total_localtax2)."'"; - $sql.= ", total_ttc='".price2num($total_ttc)."'"; - $sql.= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null"); - $sql.= ", buy_price_ht='".price2num($pa_ht)."'"; - if ($date_start > 0) { $sql.= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } - else { $sql.=",date_ouverture_prevue=null"; } - if ($date_end > 0) { $sql.= ",date_fin_validite='".$this->db->idate($date_end)."'"; } - else { $sql.=",date_fin_validite=null"; } - if ($date_debut_reel > 0) { $sql.= ",date_ouverture='".$this->db->idate($date_debut_reel)."'"; } - else { $sql.=",date_ouverture=null"; } - if ($date_fin_reel > 0) { $sql.= ",date_cloture='".$this->db->idate($date_fin_reel)."'"; } - else { $sql.=",date_cloture=null"; } - $sql .= ", fk_unit=".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); + $sql .= ",price_ht='".price2num($price)."'"; + $sql .= ",subprice='".price2num($subprice)."'"; + $sql .= ",remise='".price2num($remise)."'"; + $sql .= ",remise_percent='".price2num($remise_percent)."'"; + $sql .= ",qty='".$qty."'"; + $sql .= ",tva_tx='".price2num($tvatx)."'"; + $sql .= ",localtax1_tx='".price2num($localtax1tx)."'"; + $sql .= ",localtax2_tx='".price2num($localtax2tx)."'"; + $sql .= ",localtax1_type='".$localtax1_type."'"; + $sql .= ",localtax2_type='".$localtax2_type."'"; + $sql .= ", total_ht='".price2num($total_ht)."'"; + $sql .= ", total_tva='".price2num($total_tva)."'"; + $sql .= ", total_localtax1='".price2num($total_localtax1)."'"; + $sql .= ", total_localtax2='".price2num($total_localtax2)."'"; + $sql .= ", total_ttc='".price2num($total_ttc)."'"; + $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null"); + $sql .= ", buy_price_ht='".price2num($pa_ht)."'"; + if ($date_start > 0) { $sql .= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } + else { $sql .= ",date_ouverture_prevue=null"; } + if ($date_end > 0) { $sql .= ",date_fin_validite='".$this->db->idate($date_end)."'"; } + else { $sql .= ",date_fin_validite=null"; } + if ($date_debut_reel > 0) { $sql .= ",date_ouverture='".$this->db->idate($date_debut_reel)."'"; } + else { $sql .= ",date_ouverture=null"; } + if ($date_fin_reel > 0) { $sql .= ",date_cloture='".$this->db->idate($date_fin_reel)."'"; } + else { $sql .= ",date_cloture=null"; } + $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); $sql .= " WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::updateline", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $result=$this->update_statut($user); + $result = $this->update_statut($user); if ($result >= 0) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); - $contractline->array_options=$array_options; - $contractline->id= $rowid; - $result=$contractline->insertExtraFields(); + $contractline->array_options = $array_options; + $contractline->id = $rowid; + $result = $contractline->insertExtraFields(); if ($result < 0) { - $this->error[]=$contractline->error; + $this->error[] = $contractline->error; $error++; } } if (empty($error)) { // Call trigger - $result=$this->call_trigger('LINECONTRACT_UPDATE', $user); + $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); if ($result < 0) { $this->db->rollback(); @@ -1772,7 +1772,7 @@ class Contrat extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); dol_syslog(get_class($this)."::updateline Erreur -1"); return -1; } @@ -1789,25 +1789,25 @@ class Contrat extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; if ($this->statut >= 0) { // Call trigger - $result=$this->call_trigger('LINECONTRACT_DELETE', $user); + $result = $this->call_trigger('LINECONTRACT_DELETE', $user); if ($result < 0) return -1; // End call triggers $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; - $sql.= " WHERE rowid=".$idline; + $sql .= " WHERE rowid=".$idline; dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $error++; } @@ -1816,12 +1816,12 @@ class Contrat extends CommonObject if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); - $contractline->id= $idline; - $result=$contractline->deleteExtraFields(); + $contractline->id = $idline; + $result = $contractline->deleteExtraFields(); if ($result < 0) { $error++; - $this->error="Error ".get_class($this)."::deleteline deleteExtraFields error -4 ".$contractline->error; + $this->error = "Error ".get_class($this)."::deleteline deleteExtraFields error -4 ".$contractline->error; } } } @@ -1854,7 +1854,7 @@ class Contrat extends CommonObject public function update_statut($user) { // phpcs:enable - dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); + dol_syslog(__METHOD__." is deprecated", LOG_WARNING); // If draft, we keep it (should not happen) if ($this->statut == 0) return 1; @@ -1914,23 +1914,23 @@ class Contrat extends CommonObject if ($mode == 4 || $mode == 6 || $mode == 7) { - $text=''; + $text = ''; if ($mode == 4) { - $text ='<span class="hideonsmartphone">'; - $text.=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed); - $text.=' '.$langs->trans("Services"); - $text.=':     '; - $text.='</span>'; + $text = '<span class="hideonsmartphone">'; + $text .= ($this->nbofserviceswait + $this->nbofservicesopened + $this->nbofservicesexpired + $this->nbofservicesclosed); + $text .= ' '.$langs->trans("Services"); + $text .= ':     '; + $text .= '</span>'; } - $text.=($mode == 7?'<span class="nowraponall">':''); - $text.=($mode != 7 || $this->nbofserviceswait > 0) ? ($this->nbofserviceswait.ContratLigne::LibStatut(0, 3, -1, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; - $text.=($mode == 7?'</span><span class="nowraponall">':''); - $text.=($mode != 7 || $this->nbofservicesopened > 0) ? ($this->nbofservicesopened.ContratLigne::LibStatut(4, 3, 0, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; - $text.=($mode == 7?'</span><span class="nowraponall">':''); - $text.=($mode != 7 || $this->nbofservicesexpired > 0) ? ($this->nbofservicesexpired.ContratLigne::LibStatut(4, 3, 1, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesclosed)?'   ':'') : ''; - $text.=($mode == 7?'</span><span class="nowraponall">':''); - $text.=($mode != 7 || $this->nbofservicesclosed > 0) ? ($this->nbofservicesclosed.ContratLigne::LibStatut(5, 3, -1, 'class="marginleft2"')) : ''; - $text.=($mode == 7?'</span>':''); + $text .= ($mode == 7 ? '<span class="nowraponall">' : ''); + $text .= ($mode != 7 || $this->nbofserviceswait > 0) ? ($this->nbofserviceswait.ContratLigne::LibStatut(0, 3, -1, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed) ? '   ' : '') : ''; + $text .= ($mode == 7 ? '</span><span class="nowraponall">' : ''); + $text .= ($mode != 7 || $this->nbofservicesopened > 0) ? ($this->nbofservicesopened.ContratLigne::LibStatut(4, 3, 0, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesexpired || $this->nbofservicesclosed) ? '   ' : '') : ''; + $text .= ($mode == 7 ? '</span><span class="nowraponall">' : ''); + $text .= ($mode != 7 || $this->nbofservicesexpired > 0) ? ($this->nbofservicesexpired.ContratLigne::LibStatut(4, 3, 1, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesclosed) ? '   ' : '') : ''; + $text .= ($mode == 7 ? '</span><span class="nowraponall">' : ''); + $text .= ($mode != 7 || $this->nbofservicesclosed > 0) ? ($this->nbofservicesclosed.ContratLigne::LibStatut(5, 3, -1, 'class="marginleft2"')) : ''; + $text .= ($mode == 7 ? '</span>' : ''); return $text; } else @@ -1953,61 +1953,61 @@ class Contrat extends CommonObject { global $conf, $langs, $user, $hookmanager; - $result=''; + $result = ''; $url = DOL_URL_ROOT.'/contrat/card.php?id='.$this->id; //if ($option !== 'nolink') //{ // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; //} $label = ''; if ($user->rights->contrat->lire) { $label = '<u>'.$langs->trans("ShowContract").'</u>'; - $label .= '<br><b>'.$langs->trans('Ref').':</b> '.($this->ref?$this->ref:$this->id); + $label .= '<br><b>'.$langs->trans('Ref').':</b> '.($this->ref ? $this->ref : $this->id); $label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.($this->ref_customer ? $this->ref_customer : $this->ref_client); $label .= '<br><b>'.$langs->trans('RefSupplier').':</b> '.$this->ref_supplier; if (!empty($this->total_ht)) { $label .= '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); } if (!empty($this->total_tva)) { - $label .= '<br><b>'.$langs->trans('VAT').':</b> '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + $label .= '<br><b>'.$langs->trans('VAT').':</b> '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); } if (!empty($this->total_ttc)) { $label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); } } - $linkclose=''; + $linkclose = ''; if (empty($notooltip) && $user->rights->contrat->lire) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowOrder"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowOrder"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } $linkstart = '<a href="'.$url.'"'; - $linkstart.=$linkclose.'>'; - $linkend='</a>'; + $linkstart .= $linkclose.'>'; + $linkend = '</a>'; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= ($this->ref?$this->ref:$this->id); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($this->ref ? $this->ref : $this->id); $result .= $linkend; global $action; $hookmanager->initHooks(array('contractdao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; } else { @@ -2026,12 +2026,12 @@ class Contrat extends CommonObject public function info($id) { $sql = "SELECT c.rowid, c.ref, c.datec, c.date_cloture,"; - $sql.= " c.tms as date_modification,"; - $sql.= " fk_user_author, fk_user_cloture"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " WHERE c.rowid = ".$id; + $sql .= " c.tms as date_modification,"; + $sql .= " fk_user_author, fk_user_cloture"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " WHERE c.rowid = ".$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -2043,7 +2043,7 @@ class Contrat extends CommonObject if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_cloture) { @@ -2051,7 +2051,7 @@ class Contrat extends CommonObject $cuser->fetch($obj->fk_user_cloture); $this->user_cloture = $cuser; } - $this->ref = (! $obj->ref) ? $obj->rowid : $obj->ref; + $this->ref = (!$obj->ref) ? $obj->rowid : $obj->ref; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->date_modification); $this->date_cloture = $this->db->jdate($obj->date_cloture); @@ -2075,30 +2075,30 @@ class Contrat extends CommonObject public function array_detail($status = -1) { // phpcs:enable - $tab=array(); + $tab = array(); $sql = "SELECT cd.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " WHERE fk_contrat =".$this->id; - if ($status >= 0) $sql.= " AND statut = ".$status; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " WHERE fk_contrat =".$this->id; + if ($status >= 0) $sql .= " AND statut = ".$status; dol_syslog(get_class($this)."::array_detail()", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - $tab[$i]=$obj->rowid; + $tab[$i] = $obj->rowid; $i++; } return $tab; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2111,32 +2111,32 @@ class Contrat extends CommonObject */ public function getListOfContracts($option = 'all') { - $tab=array(); + $tab = array(); $sql = "SELECT c.rowid, c.ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " WHERE fk_soc =".$this->socid; - if ($option == 'others') $sql.= " AND c.rowid != ".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " WHERE fk_soc =".$this->socid; + if ($option == 'others') $sql .= " AND c.rowid != ".$this->id; dol_syslog(get_class($this)."::getOtherContracts()", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - $contrat=new Contrat($this->db); + $contrat = new Contrat($this->db); $contrat->fetch($obj->rowid); - $tab[]=$contrat; + $tab[] = $contrat; $i++; } return $tab; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2156,47 +2156,47 @@ class Contrat extends CommonObject global $conf, $langs; $this->from = " FROM ".MAIN_DB_PREFIX."contrat as c"; - $this->from.= ", ".MAIN_DB_PREFIX."contratdet as cd"; - $this->from.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $this->from.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $this->from .= ", ".MAIN_DB_PREFIX."contratdet as cd"; + $this->from .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $this->from .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($mode == 'inactive') { $sql = "SELECT cd.rowid, cd.date_ouverture_prevue as datefin"; - $sql.= $this->from; - $sql.= " WHERE c.statut = 1"; - $sql.= " AND c.rowid = cd.fk_contrat"; - $sql.= " AND cd.statut = 0"; + $sql .= $this->from; + $sql .= " WHERE c.statut = 1"; + $sql .= " AND c.rowid = cd.fk_contrat"; + $sql .= " AND cd.statut = 0"; } elseif ($mode == 'expired') { $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; - $sql.= $this->from; - $sql.= " WHERE c.statut = 1"; - $sql.= " AND c.rowid = cd.fk_contrat"; - $sql.= " AND cd.statut = 4"; - $sql.= " AND cd.date_fin_validite < '".$this->db->idate(dol_now())."'"; + $sql .= $this->from; + $sql .= " WHERE c.statut = 1"; + $sql .= " AND c.rowid = cd.fk_contrat"; + $sql .= " AND cd.statut = 4"; + $sql .= " AND cd.date_fin_validite < '".$this->db->idate(dol_now())."'"; } elseif ($mode == 'active') { $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; - $sql.= $this->from; - $sql.= " WHERE c.statut = 1"; - $sql.= " AND c.rowid = cd.fk_contrat"; - $sql.= " AND cd.statut = 4"; + $sql .= $this->from; + $sql .= " WHERE c.statut = 1"; + $sql .= " AND c.rowid = cd.fk_contrat"; + $sql .= " AND cd.statut = 4"; //$datetouse = dol_now(); //$sql.= " AND cd.date_fin_validite < '".$this->db->idate($datetouse)."'"; } - $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - if ($user->socid) $sql.=" AND c.fk_soc = ".$user->socid; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if ($user->socid) $sql .= " AND c.fk_soc = ".$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $langs->load("contracts"); - $now=dol_now(); + $now = dol_now(); if ($mode == 'inactive') { $warning_delay = $conf->contrat->services->inactifs->warning_delay; @@ -2219,13 +2219,13 @@ class Contrat extends CommonObject } $response = new WorkboardResponse(); - $response->warning_delay = $warning_delay/60/60/24; + $response->warning_delay = $warning_delay / 60 / 60 / 24; $response->label = $label; $response->labelShort = $labelShort; $response->url = $url; $response->img = img_object('', "contract"); - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; @@ -2239,7 +2239,7 @@ class Contrat extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2255,26 +2255,26 @@ class Contrat extends CommonObject // phpcs:enable global $conf, $user; - $this->nb=array(); + $this->nb = array(); $clause = "WHERE"; $sql = "SELECT count(c.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; $clause = "AND"; } - $sql.= " ".$clause." c.entity = ".$conf->entity; + $sql .= " ".$clause." c.entity = ".$conf->entity; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["Contracts"]=$obj->nb; + $this->nb["Contracts"] = $obj->nb; } $this->db->free($resql); return 1; @@ -2282,7 +2282,7 @@ class Contrat extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2320,15 +2320,15 @@ class Contrat extends CommonObject */ public function initAsSpecimen() { - global $user,$langs,$conf; + global $user, $langs, $conf; // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; - $sql.= " AND tosell = 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; + $sql .= " AND tosell = 1"; $resql = $this->db->query($sql); if ($resql) { @@ -2343,35 +2343,35 @@ class Contrat extends CommonObject } // Initialise parametres - $this->id=0; - $this->specimen=1; + $this->id = 0; + $this->specimen = 1; $this->ref = 'SPECIMEN'; $this->ref_customer = 'SPECIMENCUST'; $this->ref_supplier = 'SPECIMENSUPP'; $this->socid = 1; - $this->statut= 0; + $this->statut = 0; $this->date_creation = (dol_now() - 3600 * 24 * 7); $this->date_contrat = dol_now(); $this->commercial_signature_id = 1; $this->commercial_suivi_id = 1; - $this->note_private='This is a comment (private)'; - $this->note_public='This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; + $this->note_public = 'This is a comment (public)'; $this->fk_projet = 0; // Lines $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { - $line=new ContratLigne($this->db); - $line->qty=1; - $line->subprice=100; - $line->price=100; - $line->tva_tx=19.6; - $line->remise_percent=10; - $line->total_ht=90; - $line->total_ttc=107.64; // 90 * 1.196 - $line->total_tva=17.64; + $line = new ContratLigne($this->db); + $line->qty = 1; + $line->subprice = 100; + $line->price = 100; + $line->tva_tx = 19.6; + $line->remise_percent = 10; + $line->total_ht = 90; + $line->total_ttc = 107.64; // 90 * 1.196 + $line->total_tva = 17.64; $line->date_start = dol_now() - 500000; $line->date_start_real = dol_now() - 200000; $line->date_end = dol_now() + 500000; @@ -2379,9 +2379,9 @@ class Contrat extends CommonObject if ($num_prods > 0) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + $line->fk_product = $prodids[$prodid]; } - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $xnbp++; } } @@ -2410,16 +2410,16 @@ class Contrat extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("contracts"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'strato'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->CONTRACT_ADDON_PDF)) { + } elseif (!empty($conf->global->CONTRACT_ADDON_PDF)) { $modele = $conf->global->CONTRACT_ADDON_PDF; } } @@ -2480,11 +2480,11 @@ class Contrat extends CommonObject if (is_array($clonedObj->array_options) && count($clonedObj->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach($clonedObj->array_options as $key => $option) + foreach ($clonedObj->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); //var_dump($shortkey); var_dump($extrafields->attributes[$this->element]['unique'][$shortkey]); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($clonedObj->array_options[$key]); @@ -2492,14 +2492,14 @@ class Contrat extends CommonObject } } - if (empty($conf->global->CONTRACT_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT . "/core/modules/contract/" . $conf->global->CONTRACT_ADDON . ".php")) { + if (empty($conf->global->CONTRACT_ADDON) || !is_readable(DOL_DOCUMENT_ROOT."/core/modules/contract/".$conf->global->CONTRACT_ADDON.".php")) { $this->error = 'ErrorSetupNotComplete'; dol_syslog($this->error); - return - 1; + return -1; } // Set ref - require_once DOL_DOCUMENT_ROOT . "/core/modules/contract/" . $conf->global->CONTRACT_ADDON . '.php'; + require_once DOL_DOCUMENT_ROOT."/core/modules/contract/".$conf->global->CONTRACT_ADDON.'.php'; $obj = $conf->global->CONTRACT_ADDON; $modContract = new $obj(); $clonedObj->ref = $modContract->getNextValue($objsoc, $clonedObj); @@ -2513,7 +2513,7 @@ class Contrat extends CommonObject $clonedObj->context['createfromclone'] = 'createfromclone'; $result = $clonedObj->create($user); if ($result < 0) { - $error ++; + $error++; $this->error = $clonedObj->error; $this->errors[] = $clonedObj->error; } else { @@ -2525,40 +2525,40 @@ class Contrat extends CommonObject } } - if (! $error) { + if (!$error) { foreach ($this->lines as $line) { $result = $clonedObj->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, $line->date_ouverture, $line->date_cloture, 'HT', 0, $line->info_bits, $line->fk_fournprice, $line->pa_ht, $line->array_options, $line->fk_unit); if ($result < 0) { - $error ++; + $error++; $this->error = $clonedObj->error; $this->errors[] = $clonedObj->error; } } } - if (! $error) { + if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters = array ( + $parameters = array( 'objFrom' => $this, 'clonedObj' => $clonedObj ); $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $clonedObj, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) - $error ++; + $error++; } } unset($clonedObj->context['createfromclone']); // End - if (! $error) { + if (!$error) { $this->db->commit(); return $clonedObj->id; } else { $this->db->rollback(); - return - 1; + return -1; } } } @@ -2572,12 +2572,12 @@ class ContratLigne extends CommonObjectLine /** * @var string ID to identify managed object */ - public $element='contratdet'; + public $element = 'contratdet'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='contratdet'; + public $table_element = 'contratdet'; /** * @var int ID @@ -2601,8 +2601,8 @@ class ContratLigne extends CommonObjectLine */ public $fk_product; - public $statut; // 0 inactive, 4 active, 5 closed - public $type; // 0 for product, 1 for service + public $statut; // 0 inactive, 4 active, 5 closed + public $type; // 0 for product, 1 for service /** * @var string @@ -2626,20 +2626,20 @@ class ContratLigne extends CommonObjectLine public $date_commande; - public $date_start; // date start planned - public $date_start_real; // date start real - public $date_end; // date end planned - public $date_end_real; // date end real + public $date_start; // date start planned + public $date_start_real; // date start real + public $date_end; // date end planned + public $date_end_real; // date end real // For backward compatibility - public $date_ouverture_prevue; // date start planned - public $date_ouverture; // date start real - public $date_fin_validite; // date end planned - public $date_cloture; // date end real + public $date_ouverture_prevue; // date start planned + public $date_ouverture; // date start real + public $date_fin_validite; // date end planned + public $date_cloture; // date end real public $tva_tx; public $localtax1_tx; public $localtax2_tx; - public $localtax1_type; // Local tax 1 type - public $localtax2_type; // Local tax 2 type + public $localtax1_type; // Local tax 1 type + public $localtax2_type; // Local tax 2 type public $qty; public $remise_percent; public $remise; @@ -2649,7 +2649,7 @@ class ContratLigne extends CommonObjectLine */ public $fk_remise_except; - public $subprice; // Unit price HT + public $subprice; // Unit price HT /** * @var float @@ -2717,7 +2717,7 @@ class ContratLigne extends CommonObjectLine */ public function getLibStatut($mode) { - return $this->LibStatut($this->statut, $mode, ((! empty($this->date_fin_validite))?($this->date_fin_validite < dol_now()?1:0):-1)); + return $this->LibStatut($this->statut, $mode, ((!empty($this->date_fin_validite)) ? ($this->date_fin_validite < dol_now() ? 1 : 0) : -1)); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2738,8 +2738,8 @@ class ContratLigne extends CommonObjectLine if ($status == self::STATUS_INITIAL) { $labelStatus = $langs->trans("ServiceStatusInitial"); $labelStatusShort = $langs->trans("ServiceStatusInitial"); } elseif ($status == self::STATUS_OPEN && $expired == -1) { $labelStatus = $langs->trans("ServiceStatusRunning"); $labelStatusShort = $langs->trans("ServiceStatusRunning"); } - elseif ($status == self::STATUS_OPEN && $expired == 0) { $labelStatus = $langs->trans("ServiceStatusNotLate"); $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); } - elseif ($status == self::STATUS_OPEN && $expired == 1) { $labelStatus = $langs->trans("ServiceStatusLate"); $labelStatusShort = $langs->trans("ServiceStatusLateShort"); } + elseif ($status == self::STATUS_OPEN && $expired == 0) { $labelStatus = $langs->trans("ServiceStatusNotLate"); $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); } + elseif ($status == self::STATUS_OPEN && $expired == 1) { $labelStatus = $langs->trans("ServiceStatusLate"); $labelStatusShort = $langs->trans("ServiceStatusLateShort"); } elseif ($status == self::STATUS_CLOSED) { $labelStatus = $langs->trans("ServiceStatusClosed"); $labelStatusShort = $langs->trans("ServiceStatusClosed"); } $statusType = 'status'.$status; @@ -2765,19 +2765,19 @@ class ContratLigne extends CommonObjectLine { global $langs; - $result=''; - $label=$langs->trans("ShowContractOfService").': '.$this->label; - if (empty($label)) $label=$this->description; + $result = ''; + $label = $langs->trans("ShowContractOfService").': '.$this->label; + if (empty($label)) $label = $this->description; $link = '<a href="'.DOL_URL_ROOT.'/contrat/card.php?id='.$this->fk_contrat.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; - $linkend='</a>'; + $linkend = '</a>'; - $picto='service'; - if ($this->type == 0) $picto='product'; + $picto = 'service'; + if ($this->type == 0) $picto = 'product'; - if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.($this->product_ref?$this->product_ref.' ':'').($this->label?$this->label:$this->description).$linkend; + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.($this->product_ref ? $this->product_ref.' ' : '').($this->label ? $this->label : $this->description).$linkend; return $result; } @@ -2795,54 +2795,54 @@ class ContratLigne extends CommonObjectLine if (empty($id) && empty($ref)) return -1; $sql = "SELECT"; - $sql.= " t.rowid,"; + $sql .= " t.rowid,"; - $sql.= " t.tms,"; - $sql.= " t.fk_contrat,"; - $sql.= " t.fk_product,"; - $sql.= " t.statut,"; - $sql.= " t.label,"; // This field is not used. Only label of product - $sql.= " p.ref as product_ref,"; - $sql.= " p.label as product_label,"; - $sql.= " p.description as product_desc,"; - $sql.= " p.fk_product_type as product_type,"; - $sql.= " t.description,"; - $sql.= " t.date_commande,"; - $sql.= " t.date_ouverture_prevue as date_ouverture_prevue,"; - $sql.= " t.date_ouverture as date_ouverture,"; - $sql.= " t.date_fin_validite as date_fin_validite,"; - $sql.= " t.date_cloture as date_cloture,"; - $sql.= " t.tva_tx,"; - $sql.= " t.vat_src_code,"; - $sql.= " t.localtax1_tx,"; - $sql.= " t.localtax2_tx,"; - $sql.= " t.localtax1_type,"; - $sql.= " t.localtax2_type,"; - $sql.= " t.qty,"; - $sql.= " t.remise_percent,"; - $sql.= " t.remise,"; - $sql.= " t.fk_remise_except,"; - $sql.= " t.subprice,"; - $sql.= " t.price_ht,"; - $sql.= " t.total_ht,"; - $sql.= " t.total_tva,"; - $sql.= " t.total_localtax1,"; - $sql.= " t.total_localtax2,"; - $sql.= " t.total_ttc,"; - $sql.= " t.fk_product_fournisseur_price as fk_fournprice,"; - $sql.= " t.buy_price_ht as pa_ht,"; - $sql.= " t.info_bits,"; - $sql.= " t.fk_user_author,"; - $sql.= " t.fk_user_ouverture,"; - $sql.= " t.fk_user_cloture,"; - $sql.= " t.commentaire,"; - $sql.= " t.fk_unit"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as t LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = t.fk_product"; - if ($id) $sql.= " WHERE t.rowid = ".$id; - if ($ref) $sql.= " WHERE t.rowid = '".$this->db->escape($ref)."'"; + $sql .= " t.tms,"; + $sql .= " t.fk_contrat,"; + $sql .= " t.fk_product,"; + $sql .= " t.statut,"; + $sql .= " t.label,"; // This field is not used. Only label of product + $sql .= " p.ref as product_ref,"; + $sql .= " p.label as product_label,"; + $sql .= " p.description as product_desc,"; + $sql .= " p.fk_product_type as product_type,"; + $sql .= " t.description,"; + $sql .= " t.date_commande,"; + $sql .= " t.date_ouverture_prevue as date_ouverture_prevue,"; + $sql .= " t.date_ouverture as date_ouverture,"; + $sql .= " t.date_fin_validite as date_fin_validite,"; + $sql .= " t.date_cloture as date_cloture,"; + $sql .= " t.tva_tx,"; + $sql .= " t.vat_src_code,"; + $sql .= " t.localtax1_tx,"; + $sql .= " t.localtax2_tx,"; + $sql .= " t.localtax1_type,"; + $sql .= " t.localtax2_type,"; + $sql .= " t.qty,"; + $sql .= " t.remise_percent,"; + $sql .= " t.remise,"; + $sql .= " t.fk_remise_except,"; + $sql .= " t.subprice,"; + $sql .= " t.price_ht,"; + $sql .= " t.total_ht,"; + $sql .= " t.total_tva,"; + $sql .= " t.total_localtax1,"; + $sql .= " t.total_localtax2,"; + $sql .= " t.total_ttc,"; + $sql .= " t.fk_product_fournisseur_price as fk_fournprice,"; + $sql .= " t.buy_price_ht as pa_ht,"; + $sql .= " t.info_bits,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.fk_user_ouverture,"; + $sql .= " t.fk_user_cloture,"; + $sql .= " t.commentaire,"; + $sql .= " t.fk_unit"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as t LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = t.fk_product"; + if ($id) $sql .= " WHERE t.rowid = ".$id; + if ($ref) $sql .= " WHERE t.rowid = '".$this->db->escape($ref)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -2860,7 +2860,7 @@ class ContratLigne extends CommonObjectLine $this->product_label = $obj->product_label; $this->product_description = $obj->product_description; $this->product_type = $obj->product_type; - $this->label = $obj->label; // deprecated. We do not use this field. Only ref and label of product, and description of contract line + $this->label = $obj->label; // deprecated. We do not use this field. Only ref and label of product, and description of contract line $this->description = $obj->description; $this->date_commande = $this->db->jdate($obj->date_commande); @@ -2899,7 +2899,7 @@ class ContratLigne extends CommonObjectLine $this->fk_fournprice = $obj->fk_fournprice; $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->fk_fournprice, $obj->pa_ht); $this->pa_ht = $marginInfos[0]; - $this->fk_unit = $obj->fk_unit; + $this->fk_unit = $obj->fk_unit; } $this->db->free($resql); @@ -2907,7 +2907,7 @@ class ContratLigne extends CommonObjectLine } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -2924,34 +2924,34 @@ class ContratLigne extends CommonObjectLine { global $conf, $langs, $mysoc; - $error=0; + $error = 0; // Clean parameters $this->fk_contrat = (int) $this->fk_contrat; $this->fk_product = (int) $this->fk_product; $this->statut = (int) $this->statut; - $this->label=trim($this->label); - $this->description=trim($this->description); - $this->vat_src_code=trim($this->vat_src_code); - $this->tva_tx=trim($this->tva_tx); - $this->localtax1_tx=trim($this->localtax1_tx); - $this->localtax2_tx=trim($this->localtax2_tx); - $this->qty=trim($this->qty); - $this->remise_percent=trim($this->remise_percent); - $this->remise=trim($this->remise); + $this->label = trim($this->label); + $this->description = trim($this->description); + $this->vat_src_code = trim($this->vat_src_code); + $this->tva_tx = trim($this->tva_tx); + $this->localtax1_tx = trim($this->localtax1_tx); + $this->localtax2_tx = trim($this->localtax2_tx); + $this->qty = trim($this->qty); + $this->remise_percent = trim($this->remise_percent); + $this->remise = trim($this->remise); $this->fk_remise_except = (int) $this->fk_remise_except; - $this->subprice=price2num($this->subprice); - $this->price_ht=price2num($this->price_ht); - $this->total_ht=trim($this->total_ht); - $this->total_tva=trim($this->total_tva); - $this->total_localtax1=trim($this->total_localtax1); - $this->total_localtax2=trim($this->total_localtax2); - $this->total_ttc=trim($this->total_ttc); - $this->info_bits=trim($this->info_bits); + $this->subprice = price2num($this->subprice); + $this->price_ht = price2num($this->price_ht); + $this->total_ht = trim($this->total_ht); + $this->total_tva = trim($this->total_tva); + $this->total_localtax1 = trim($this->total_localtax1); + $this->total_localtax2 = trim($this->total_localtax2); + $this->total_ttc = trim($this->total_ttc); + $this->info_bits = trim($this->info_bits); $this->fk_user_author = (int) $this->fk_user_author; $this->fk_user_ouverture = (int) $this->fk_user_ouverture; $this->fk_user_cloture = (int) $this->fk_user_cloture; - $this->commentaire=trim($this->commentaire); + $this->commentaire = trim($this->commentaire); //if (empty($this->subprice)) $this->subprice = 0; if (empty($this->price_ht)) $this->price_ht = 0; if (empty($this->total_ht)) $this->total_ht = 0; @@ -2961,10 +2961,10 @@ class ContratLigne extends CommonObjectLine if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; if (empty($this->remise_percent)) $this->remise_percent = 0; // For backward compatibility - if (empty($this->date_start)) $this->date_start=$this->date_ouverture_prevue; - if (empty($this->date_start_real)) $this->date_start=$this->date_ouverture; - if (empty($this->date_end)) $this->date_start=$this->date_fin_validite; - if (empty($this->date_end_real)) $this->date_start=$this->date_cloture; + if (empty($this->date_start)) $this->date_start = $this->date_ouverture_prevue; + if (empty($this->date_start_real)) $this->date_start = $this->date_ouverture; + if (empty($this->date_end)) $this->date_start = $this->date_fin_validite; + if (empty($this->date_end_real)) $this->date_start = $this->date_cloture; // Check parameters @@ -2976,14 +2976,14 @@ class ContratLigne extends CommonObjectLine // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. $localtaxes_type = getLocalTaxesFromRate($this->txtva, 0, $this->societe, $mysoc); - $tabprice=calcul_price_total($this->qty, $this->price_ht, $this->remise_percent, $this->tva_tx, $this->localtax1_tx, $this->localtax2_tx, 0, 'HT', 0, 1, $mysoc, $localtaxes_type); + $tabprice = calcul_price_total($this->qty, $this->price_ht, $this->remise_percent, $this->tva_tx, $this->localtax1_tx, $this->localtax2_tx, 0, 'HT', 0, 1, $mysoc, $localtaxes_type); $this->total_ht = $tabprice[0]; $this->total_tva = $tabprice[1]; $this->total_ttc = $tabprice[2]; - $this->total_localtax1= $tabprice[9]; - $this->total_localtax2= $tabprice[10]; + $this->total_localtax1 = $tabprice[9]; + $this->total_localtax2 = $tabprice[10]; - if (empty($this->pa_ht)) $this->pa_ht=0; + if (empty($this->pa_ht)) $this->pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) @@ -3006,52 +3006,52 @@ class ContratLigne extends CommonObjectLine // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; - $sql.= " fk_contrat=".$this->fk_contrat.","; - $sql.= " fk_product=".($this->fk_product?"'".$this->db->escape($this->fk_product)."'":'null').","; - $sql.= " statut=".$this->statut.","; - $sql.= " label='".$this->db->escape($this->label)."',"; - $sql.= " description='".$this->db->escape($this->description)."',"; - $sql.= " date_commande=".($this->date_commande!=''?"'".$this->db->idate($this->date_commande)."'":"null").","; - $sql.= " date_ouverture_prevue=".($this->date_ouverture_prevue!=''?"'".$this->db->idate($this->date_ouverture_prevue)."'":"null").","; - $sql.= " date_ouverture=".($this->date_ouverture!=''?"'".$this->db->idate($this->date_ouverture)."'":"null").","; - $sql.= " date_fin_validite=".($this->date_fin_validite!=''?"'".$this->db->idate($this->date_fin_validite)."'":"null").","; - $sql.= " date_cloture=".($this->date_cloture!=''?"'".$this->db->idate($this->date_cloture)."'":"null").","; - $sql.= " vat_src_code='".$this->db->escape($this->vat_src_code)."',"; - $sql.= " tva_tx=".price2num($this->tva_tx).","; - $sql.= " localtax1_tx=".price2num($this->localtax1_tx).","; - $sql.= " localtax2_tx=".price2num($this->localtax2_tx).","; - $sql.= " qty=".price2num($this->qty).","; - $sql.= " remise_percent=".price2num($this->remise_percent).","; - $sql.= " remise=".($this->remise?price2num($this->remise):"null").","; - $sql.= " fk_remise_except=".($this->fk_remise_except > 0?$this->fk_remise_except:"null").","; - $sql.= " subprice=".($this->subprice != '' ? $this->subprice : "null").","; - $sql.= " price_ht=".($this->price_ht != '' ? $this->price_ht : "null").","; - $sql.= " total_ht=".$this->total_ht.","; - $sql.= " total_tva=".$this->total_tva.","; - $sql.= " total_localtax1=".$this->total_localtax1.","; - $sql.= " total_localtax2=".$this->total_localtax2.","; - $sql.= " total_ttc=".$this->total_ttc.","; - $sql.= " fk_product_fournisseur_price=".(!empty($this->fk_fournprice)?$this->fk_fournprice:"NULL").","; - $sql.= " buy_price_ht='".price2num($this->pa_ht)."',"; - $sql.= " info_bits='".$this->db->escape($this->info_bits)."',"; - $sql.= " fk_user_author=".($this->fk_user_author >= 0?$this->fk_user_author:"NULL").","; - $sql.= " fk_user_ouverture=".($this->fk_user_ouverture > 0?$this->fk_user_ouverture:"NULL").","; - $sql.= " fk_user_cloture=".($this->fk_user_cloture > 0?$this->fk_user_cloture:"NULL").","; - $sql.= " commentaire='".$this->db->escape($this->commentaire)."',"; - $sql.= " fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= " WHERE rowid=".$this->id; + $sql .= " fk_contrat=".$this->fk_contrat.","; + $sql .= " fk_product=".($this->fk_product ? "'".$this->db->escape($this->fk_product)."'" : 'null').","; + $sql .= " statut=".$this->statut.","; + $sql .= " label='".$this->db->escape($this->label)."',"; + $sql .= " description='".$this->db->escape($this->description)."',"; + $sql .= " date_commande=".($this->date_commande != '' ? "'".$this->db->idate($this->date_commande)."'" : "null").","; + $sql .= " date_ouverture_prevue=".($this->date_ouverture_prevue != '' ? "'".$this->db->idate($this->date_ouverture_prevue)."'" : "null").","; + $sql .= " date_ouverture=".($this->date_ouverture != '' ? "'".$this->db->idate($this->date_ouverture)."'" : "null").","; + $sql .= " date_fin_validite=".($this->date_fin_validite != '' ? "'".$this->db->idate($this->date_fin_validite)."'" : "null").","; + $sql .= " date_cloture=".($this->date_cloture != '' ? "'".$this->db->idate($this->date_cloture)."'" : "null").","; + $sql .= " vat_src_code='".$this->db->escape($this->vat_src_code)."',"; + $sql .= " tva_tx=".price2num($this->tva_tx).","; + $sql .= " localtax1_tx=".price2num($this->localtax1_tx).","; + $sql .= " localtax2_tx=".price2num($this->localtax2_tx).","; + $sql .= " qty=".price2num($this->qty).","; + $sql .= " remise_percent=".price2num($this->remise_percent).","; + $sql .= " remise=".($this->remise ?price2num($this->remise) : "null").","; + $sql .= " fk_remise_except=".($this->fk_remise_except > 0 ? $this->fk_remise_except : "null").","; + $sql .= " subprice=".($this->subprice != '' ? $this->subprice : "null").","; + $sql .= " price_ht=".($this->price_ht != '' ? $this->price_ht : "null").","; + $sql .= " total_ht=".$this->total_ht.","; + $sql .= " total_tva=".$this->total_tva.","; + $sql .= " total_localtax1=".$this->total_localtax1.","; + $sql .= " total_localtax2=".$this->total_localtax2.","; + $sql .= " total_ttc=".$this->total_ttc.","; + $sql .= " fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? $this->fk_fournprice : "NULL").","; + $sql .= " buy_price_ht='".price2num($this->pa_ht)."',"; + $sql .= " info_bits='".$this->db->escape($this->info_bits)."',"; + $sql .= " fk_user_author=".($this->fk_user_author >= 0 ? $this->fk_user_author : "NULL").","; + $sql .= " fk_user_ouverture=".($this->fk_user_ouverture > 0 ? $this->fk_user_ouverture : "NULL").","; + $sql .= " fk_user_cloture=".($this->fk_user_cloture > 0 ? $this->fk_user_cloture : "NULL").","; + $sql .= " commentaire='".$this->db->escape($this->commentaire)."',"; + $sql .= " fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $error++; } - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -3059,39 +3059,39 @@ class ContratLigne extends CommonObjectLine } // If we change a planned date (start or end), sync dates for all services - if (! $error && ! empty($conf->global->CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES)) + if (!$error && !empty($conf->global->CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES)) { if ($this->date_ouverture_prevue != $this->oldcopy->date_ouverture_prevue) { - $sql ='UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; - $sql.= " date_ouverture_prevue = ".($this->date_ouverture_prevue!=''?"'".$this->db->idate($this->date_ouverture_prevue)."'":"null"); - $sql.= " WHERE fk_contrat = ".$this->fk_contrat; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; + $sql .= " date_ouverture_prevue = ".($this->date_ouverture_prevue != '' ? "'".$this->db->idate($this->date_ouverture_prevue)."'" : "null"); + $sql .= " WHERE fk_contrat = ".$this->fk_contrat; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); } } if ($this->date_fin_validite != $this->oldcopy->date_fin_validite) { - $sql ='UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; - $sql.= " date_fin_validite = ".($this->date_fin_validite!=''?"'".$this->db->idate($this->date_fin_validite)."'":"null"); - $sql.= " WHERE fk_contrat = ".$this->fk_contrat; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; + $sql .= " date_fin_validite = ".($this->date_fin_validite != '' ? "'".$this->db->idate($this->date_fin_validite)."'" : "null"); + $sql .= " WHERE fk_contrat = ".$this->fk_contrat; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); } } } - if (! $error && ! $notrigger) { + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINECONTRACT_UPDATE', $user); + $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); if ($result < 0) { $error++; $this->db->rollback(); @@ -3099,13 +3099,13 @@ class ContratLigne extends CommonObjectLine // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { $this->db->rollback(); - $this->errors[]=$this->error; + $this->errors[] = $this->error; return -1; } } @@ -3125,16 +3125,16 @@ class ContratLigne extends CommonObjectLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; - $sql.= " total_ht=".price2num($this->total_ht, 'MT').""; - $sql.= ",total_tva=".price2num($this->total_tva, 'MT').""; - $sql.= ",total_localtax1=".price2num($this->total_localtax1, 'MT').""; - $sql.= ",total_localtax2=".price2num($this->total_localtax2, 'MT').""; - $sql.= ",total_ttc=".price2num($this->total_ttc, 'MT').""; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " total_ht=".price2num($this->total_ht, 'MT').""; + $sql .= ",total_tva=".price2num($this->total_tva, 'MT').""; + $sql .= ",total_localtax1=".price2num($this->total_localtax1, 'MT').""; + $sql .= ",total_localtax2=".price2num($this->total_localtax2, 'MT').""; + $sql .= ",total_ttc=".price2num($this->total_ttc, 'MT').""; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_total", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); @@ -3142,7 +3142,7 @@ class ContratLigne extends CommonObjectLine } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -2; } @@ -3161,43 +3161,43 @@ class ContratLigne extends CommonObjectLine // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet"; - $sql.= " (fk_contrat, label, description, fk_product, qty, vat_src_code, tva_tx,"; - $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,"; - $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; - $sql.= " info_bits,"; - $sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; - if ($this->date_ouverture_prevue > 0) { $sql.= ",date_ouverture_prevue"; } - if ($this->date_fin_validite > 0) { $sql.= ",date_fin_validite"; } - $sql.= ") VALUES ($this->fk_contrat, '', '" . $this->db->escape($this->description) . "',"; - $sql.= ($this->fk_product>0 ? $this->fk_product : "null").","; - $sql.= " '".$this->db->escape($this->qty)."',"; - $sql.= " '".$this->db->escape($this->vat_src_code)."',"; - $sql.= " '".$this->db->escape($this->tva_tx)."',"; - $sql.= " '".$this->db->escape($this->localtax1_tx)."',"; - $sql.= " '".$this->db->escape($this->localtax2_tx)."',"; - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; - $sql.= " ".price2num($this->remise_percent).",".price2num($this->subprice).","; - $sql.= " ".price2num($this->total_ht).",".price2num($this->total_tva).",".price2num($this->total_localtax1).",".price2num($this->total_localtax2).",".price2num($this->total_ttc).","; - $sql.= " '".$this->db->escape($this->info_bits)."',"; - $sql.= " ".price2num($this->price_ht).",".price2num($this->remise).","; - if ($this->fk_fournprice > 0) $sql.= ' '.$this->fk_fournprice.','; - else $sql.= ' null,'; - if ($this->pa_ht > 0) $sql.= ' '.price2num($this->pa_ht); - else $sql.= ' null'; - if ($this->date_ouverture > 0) { $sql.= ",'".$this->db->idate($this->date_ouverture)."'"; } - if ($this->date_cloture > 0) { $sql.= ",'".$this->db->idate($this->date_cloture)."'"; } - $sql.= ")"; + $sql .= " (fk_contrat, label, description, fk_product, qty, vat_src_code, tva_tx,"; + $sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,"; + $sql .= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; + $sql .= " info_bits,"; + $sql .= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; + if ($this->date_ouverture_prevue > 0) { $sql .= ",date_ouverture_prevue"; } + if ($this->date_fin_validite > 0) { $sql .= ",date_fin_validite"; } + $sql .= ") VALUES ($this->fk_contrat, '', '".$this->db->escape($this->description)."',"; + $sql .= ($this->fk_product > 0 ? $this->fk_product : "null").","; + $sql .= " '".$this->db->escape($this->qty)."',"; + $sql .= " '".$this->db->escape($this->vat_src_code)."',"; + $sql .= " '".$this->db->escape($this->tva_tx)."',"; + $sql .= " '".$this->db->escape($this->localtax1_tx)."',"; + $sql .= " '".$this->db->escape($this->localtax2_tx)."',"; + $sql .= " '".$this->db->escape($this->localtax1_type)."',"; + $sql .= " '".$this->db->escape($this->localtax2_type)."',"; + $sql .= " ".price2num($this->remise_percent).",".price2num($this->subprice).","; + $sql .= " ".price2num($this->total_ht).",".price2num($this->total_tva).",".price2num($this->total_localtax1).",".price2num($this->total_localtax2).",".price2num($this->total_ttc).","; + $sql .= " '".$this->db->escape($this->info_bits)."',"; + $sql .= " ".price2num($this->price_ht).",".price2num($this->remise).","; + if ($this->fk_fournprice > 0) $sql .= ' '.$this->fk_fournprice.','; + else $sql .= ' null,'; + if ($this->pa_ht > 0) $sql .= ' '.price2num($this->pa_ht); + else $sql .= ' null'; + if ($this->date_ouverture > 0) { $sql .= ",'".$this->db->idate($this->date_ouverture)."'"; } + if ($this->date_cloture > 0) { $sql .= ",'".$this->db->idate($this->date_cloture)."'"; } + $sql .= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'contratdet'); // Insert of extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) // For avoid conflicts if trigger used { $result = $this->insertExtraFields(); if ($result < 0) @@ -3224,7 +3224,7 @@ class ContratLigne extends CommonObjectLine else { $this->db->rollback(); - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; return -1; } } @@ -3248,15 +3248,15 @@ class ContratLigne extends CommonObjectLine $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = ".ContratLigne::STATUS_OPEN.","; - $sql .= " date_ouverture = " . (dol_strlen($date) != 0 ? "'" . $this->db->idate($date) . "'" : "null") . ","; - if ($date_end >= 0) $sql .= " date_fin_validite = " . (dol_strlen($date_end) != 0 ? "'" . $this->db->idate($date_end) . "'" : "null") . ","; - $sql .= " fk_user_ouverture = " . $user->id . ","; + $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".ContratLigne::STATUS_OPEN.","; + $sql .= " date_ouverture = ".(dol_strlen($date) != 0 ? "'".$this->db->idate($date)."'" : "null").","; + if ($date_end >= 0) $sql .= " date_fin_validite = ".(dol_strlen($date_end) != 0 ? "'".$this->db->idate($date_end)."'" : "null").","; + $sql .= " fk_user_ouverture = ".$user->id.","; $sql .= " date_cloture = null,"; - $sql .= " commentaire = '" . $this->db->escape($comment) . "'"; - $sql .= " WHERE rowid = " . $this->id . " AND (statut = ".ContratLigne::STATUS_INITIAL." OR statut = ".ContratLigne::STATUS_CLOSED.")"; + $sql .= " commentaire = '".$this->db->escape($comment)."'"; + $sql .= " WHERE rowid = ".$this->id." AND (statut = ".ContratLigne::STATUS_INITIAL." OR statut = ".ContratLigne::STATUS_CLOSED.")"; - dol_syslog(get_class($this) . "::active_line", LOG_DEBUG); + dol_syslog(get_class($this)."::active_line", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // Call trigger @@ -3264,7 +3264,7 @@ class ContratLigne extends CommonObjectLine if ($result < 0) $error++; // End call triggers - if (! $error) + if (!$error) { $this->statut = ContratLigne::STATUS_OPEN; $this->date_ouverture = $date; @@ -3314,16 +3314,16 @@ class ContratLigne extends CommonObjectLine $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = ".ContratLigne::STATUS_CLOSED.","; - $sql .= " date_cloture = '" . $this->db->idate($date_end) . "',"; - $sql .= " fk_user_cloture = " . $user->id . ","; - $sql .= " commentaire = '" . $this->db->escape($comment) . "'"; - $sql .= " WHERE rowid = " . $this->id . " AND statut = ".ContratLigne::STATUS_OPEN; + $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".ContratLigne::STATUS_CLOSED.","; + $sql .= " date_cloture = '".$this->db->idate($date_end)."',"; + $sql .= " fk_user_cloture = ".$user->id.","; + $sql .= " commentaire = '".$this->db->escape($comment)."'"; + $sql .= " WHERE rowid = ".$this->id." AND statut = ".ContratLigne::STATUS_OPEN; $resql = $this->db->query($sql); if ($resql) { - if (! $notrigger) + if (!$notrigger) { // Call trigger $result = $this->call_trigger('LINECONTRACT_CLOSE', $user); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index f24105a93db..48deeba1565 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -39,39 +39,39 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // Load translation files required by the page $langs->loadLangs(array('contracts', 'products', 'companies', 'compta')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'contractlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contractlist'; // To manage different context of search -$search_name=GETPOST('search_name', 'alpha'); -$search_email=GETPOST('search_email', 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state", 'alpha')); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_contract=GETPOST('search_contract', 'alpha'); -$search_ref_customer=GETPOST('search_ref_customer', 'alpha'); -$search_ref_supplier=GETPOST('search_ref_supplier', 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_status=GETPOST('search_status', 'alpha'); -$socid=GETPOST('socid', 'int'); -$search_user=GETPOST('search_user', 'int'); -$search_sale=GETPOST('search_sale', 'int'); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_dfmonth=GETPOST('search_dfmonth', 'int'); -$search_dfyear=GETPOST('search_dfyear', 'int'); -$search_op2df=GETPOST('search_op2df', 'alpha'); -$day=GETPOST("day", "int"); -$year=GETPOST("year", "int"); -$month=GETPOST("month", "int"); +$search_name = GETPOST('search_name', 'alpha'); +$search_email = GETPOST('search_email', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state", 'alpha')); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_contract = GETPOST('search_contract', 'alpha'); +$search_ref_customer = GETPOST('search_ref_customer', 'alpha'); +$search_ref_supplier = GETPOST('search_ref_supplier', 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_status = GETPOST('search_status', 'alpha'); +$socid = GETPOST('socid', 'int'); +$search_user = GETPOST('search_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_product_category = GETPOST('search_product_category', 'int'); +$search_dfmonth = GETPOST('search_dfmonth', 'int'); +$search_dfyear = GETPOST('search_dfyear', 'int'); +$search_op2df = GETPOST('search_op2df', 'alpha'); +$day = GETPOST("day", "int"); +$year = GETPOST("year", "int"); +$month = GETPOST("month", "int"); $optioncss = GETPOST('optioncss', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -79,20 +79,20 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='c.ref'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'c.ref'; +if (!$sortorder) $sortorder = 'DESC'; // Security check -$id=GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; +$id = GETPOST('id', 'int'); +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'contrat', $id); -$diroutputmassaction=$conf->contrat->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id; -$staticcontrat=new Contrat($db); -$staticcontratligne=new ContratLigne($db); +$staticcontrat = new Contrat($db); +$staticcontratligne = new ContratLigne($db); -if ($search_status == '') $search_status=1; +if ($search_status == '') $search_status = 1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Contrat($db); @@ -102,7 +102,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('contrat'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'c.ref'=>'Ref', @@ -111,9 +111,9 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'c.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["c.note_private"] = "NotePrivate"; -$arrayfields=array( +$arrayfields = array( 'c.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'c.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1), 'c.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1), @@ -133,10 +133,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -147,11 +147,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Action */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -159,35 +159,35 @@ 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 test are required to be compatible with all browsers { - $day=''; - $month=''; - $year=''; - $search_dfmonth=''; - $search_dfyear=''; - $search_op2df=''; - $search_name=""; - $search_email=""; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_contract=""; - $search_ref_customer=""; - $search_ref_supplier=""; - $search_user=''; - $search_sale=''; - $search_product_category=''; - $sall=""; - $search_status=""; - $toselect=''; - $search_array_options=array(); + $day = ''; + $month = ''; + $year = ''; + $search_dfmonth = ''; + $search_dfyear = ''; + $search_op2df = ''; + $search_name = ""; + $search_email = ""; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_contract = ""; + $search_ref_customer = ""; + $search_ref_supplier = ""; + $search_user = ''; + $search_sale = ''; + $search_product_category = ''; + $sall = ""; + $search_status = ""; + $toselect = ''; + $search_array_options = array(); } if (empty($reshook)) { - $objectclass='Contrat'; - $objectlabel='Contracts'; + $objectclass = 'Contrat'; + $objectlabel = 'Contracts'; $permissiontoread = $user->rights->contrat->lire; $permissiontodelete = $user->rights->contrat->supprimer; $uploaddir = $conf->contrat->dir_output; @@ -199,7 +199,7 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); $form = new Form($db); $formfile = new FormFile($db); $formother = new FormOther($db); @@ -207,44 +207,44 @@ $socstatic = new Societe($db); $contracttmp = new Contrat($db); $sql = 'SELECT'; -$sql.= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; -$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") as lower_planned_end_date,"; -$sql.= ' SUM('.$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,'; -$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", 1, 0).') as nb_running,'; -$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", 1, 0).') as nb_expired,'; -$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", 1, 0).') as nb_late,'; -$sql.= ' SUM('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed'; +$sql .= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; +$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") as lower_planned_end_date,"; +$sql .= ' SUM('.$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,'; +$sql .= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", 1, 0).') as nb_running,'; +$sql .= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", 1, 0).') as nb_expired,'; +$sql .= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", 1, 0).') as nb_late,'; +$sql .= ' SUM('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed'; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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."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)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ", ".MAIN_DB_PREFIX."contrat as c"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (c.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; +$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."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)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= ", ".MAIN_DB_PREFIX."contrat as c"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (c.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= " WHERE c.fk_soc = s.rowid "; -$sql.= ' AND c.entity IN ('.getEntity('contract').')'; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; -if ($socid) $sql.= " AND s.rowid = ".$db->escape($socid); -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= dolSqlDateFilter('c.date_contrat', $day, $month, $year); +$sql .= " WHERE c.fk_soc = s.rowid "; +$sql .= ' AND c.entity IN ('.getEntity('contract').')'; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; +if ($socid) $sql .= " AND s.rowid = ".$db->escape($socid); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= dolSqlDateFilter('c.date_contrat', $day, $month, $year); if ($search_name) $sql .= natural_search('s.nom', $search_name); if ($search_email) $sql .= natural_search('s.email', $search_email); if ($search_contract) $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract); @@ -252,39 +252,39 @@ if (!empty($search_ref_customer)) $sql .= natural_search(array('c.ref_customer') if (!empty($search_ref_supplier)) $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier); if ($search_sale > 0) { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; } if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; +if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; -$sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; -$sql.= " typent.code,"; -$sql.= " state.code_departement, state.nom"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; +$sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= " typent.code,"; +$sql .= " state.code_departement, state.nom"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); } // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; if ($search_dfyear > 0 && $search_op2df) { - if ($search_op2df == '<=') $sql.= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."'"; - elseif ($search_op2df == '>=') $sql.= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; - else $sql.= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."' AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; + if ($search_op2df == '<=') $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."'"; + elseif ($search_op2df == '>=') $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; + else $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."' AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; } -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); //print $sql; -$totalnboflines=0; -$result=$db->query($sql); +$totalnboflines = 0; +$result = $db->query($sql); if ($result) { $totalnboflines = $db->num_rows($result); @@ -302,10 +302,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); -if (! $resql) +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); exit; @@ -314,7 +314,7 @@ if (! $resql) $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall && ! $page) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -330,7 +330,7 @@ llxHeader('', $langs->trans("Contracts")); $i = 0; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); if ($socid > 0) { @@ -339,40 +339,40 @@ if ($socid > 0) if (empty($search_name)) $search_name = $soc->name; } -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($sall != '') $param.='&sall='.urlencode($sall); -if ($search_contract != '') $param.='&search_contract='.urlencode($search_contract); -if ($search_name != '') $param.='&search_name='.urlencode($search_name); -if ($search_email != '') $param.='&search_email='.urlencode($search_email); -if ($search_ref_customer != '') $param.='&search_ref_customer='.urlencode($search_ref_customer); -if ($search_ref_supplier != '') $param.='&search_ref_supplier='.urlencode($search_ref_supplier); -if ($search_op2df != '') $param.='&search_op2df='.urlencode($search_op2df); -if ($search_dfyear != '') $param.='&search_dfyear='.urlencode($search_dfyear); -if ($search_dfmonth != '') $param.='&search_dfmonth='.urlencode($search_dfmonth); -if ($search_sale != '') $param.='&search_sale=' .urlencode($search_sale); -if ($search_user != '') $param.='&search_user=' .urlencode($search_user); -if ($search_product_category != '') $param.='&search_product_category=' .urlencode($search_product_category); -if ($show_files) $param.='&show_files=' .urlencode($show_files); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($sall != '') $param .= '&sall='.urlencode($sall); +if ($search_contract != '') $param .= '&search_contract='.urlencode($search_contract); +if ($search_name != '') $param .= '&search_name='.urlencode($search_name); +if ($search_email != '') $param .= '&search_email='.urlencode($search_email); +if ($search_ref_customer != '') $param .= '&search_ref_customer='.urlencode($search_ref_customer); +if ($search_ref_supplier != '') $param .= '&search_ref_supplier='.urlencode($search_ref_supplier); +if ($search_op2df != '') $param .= '&search_op2df='.urlencode($search_op2df); +if ($search_dfyear != '') $param .= '&search_dfyear='.urlencode($search_dfyear); +if ($search_dfmonth != '') $param .= '&search_dfmonth='.urlencode($search_dfmonth); +if ($search_sale != '') $param .= '&search_sale='.urlencode($search_sale); +if ($search_user != '') $param .= '&search_user='.urlencode($search_user); +if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category); +if ($show_files) $param .= '&show_files='.urlencode($show_files); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); -if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->contrat->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contrat/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contrat/card.php?action=create'); } print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; @@ -387,133 +387,133 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'commercial', 0, $newcardbutton, '', $limit); -$topicmail="SendContractRef"; -$modelmail="contract"; -$objecttmp=new Contrat($db); -$trackid='con'.$object->id; +$topicmail = "SendContractRef"; +$modelmail = "contract"; +$objecttmp = new Contrat($db); +$trackid = 'con'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } -$moreforfilter=''; +$moreforfilter = ''; // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view other users if ($user->rights->user->user->lire) { - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view categories of products if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='</div>'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '</div>'; } -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<tr class="liste_titre_filter">'; -if (! empty($arrayfields['c.ref']['checked'])) +if (!empty($arrayfields['c.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).'">'; print '</td>'; } -if (! empty($arrayfields['c.ref_customer']['checked'])) +if (!empty($arrayfields['c.ref_customer']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).'">'; print '</td>'; } -if (! empty($arrayfields['c.ref_supplier']['checked'])) +if (!empty($arrayfields['c.ref_supplier']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" size="6" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).'">'; print '</td>'; } -if (! empty($arrayfields['s.nom']['checked'])) +if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).'">'; print '</td>'; } -if (! empty($arrayfields['s.email']['checked'])) +if (!empty($arrayfields['s.email']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" size="6" name="search_email" value="'.dol_escape_htmltag($search_email).'">'; print '</td>'; } // Town -if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; +if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; // Zip -if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>'; +if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>'; // State -if (! empty($arrayfields['state.nom']['checked'])) +if (!empty($arrayfields['state.nom']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country -if (! empty($arrayfields['country.code_iso']['checked'])) +if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="liste_titre center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Company type -if (! empty($arrayfields['typent.code']['checked'])) +if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone center">'; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print '</td>'; } -if (! empty($arrayfields['sale_representative']['checked'])) +if (!empty($arrayfields['sale_representative']['checked'])) { print '<td class="liste_titre"></td>'; } -if (! empty($arrayfields['c.date_contrat']['checked'])) +if (!empty($arrayfields['c.date_contrat']['checked'])) { // Date contract print '<td class="liste_titre center nowraponall">'; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.$day.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.$day.'">'; print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month" value="'.$month.'">'; //print ' '.$langs->trans('Year').': '; $syear = $year; @@ -524,26 +524,26 @@ if (! empty($arrayfields['c.date_contrat']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (! empty($arrayfields['c.datec']['checked'])) +if (!empty($arrayfields['c.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification -if (! empty($arrayfields['c.tms']['checked'])) +if (!empty($arrayfields['c.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // First end date -if (! empty($arrayfields['lower_planned_end_date']['checked'])) +if (!empty($arrayfields['lower_planned_end_date']['checked'])) { print '<td class="liste_titre nowraponall center">'; - $arrayofoperators=array('0'=>'','='=>'=','<='=>'<=','>='=>'>='); + $arrayofoperators = array('0'=>'', '='=>'=', '<='=>'<=', '>='=>'>='); print $form->selectarray('search_op2df', $arrayofoperators, $search_op2df, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth50imp'); print '</br>'; print $formother->select_month($search_dfmonth, 'search_dfmonth', 1, 0); @@ -603,17 +603,17 @@ while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $contracttmp->ref=$obj->ref; - $contracttmp->id=$obj->rowid; - $contracttmp->ref_customer=$obj->ref_customer; - $contracttmp->ref_supplier=$obj->ref_supplier; + $contracttmp->ref = $obj->ref; + $contracttmp->id = $obj->rowid; + $contracttmp->ref_customer = $obj->ref_customer; + $contracttmp->ref_supplier = $obj->ref_supplier; if ($obj->socid > 0) { - $result=$socstatic->fetch($obj->socid); + $result = $socstatic->fetch($obj->socid); } print '<tr class="oddeven">'; - if (! empty($arrayfields['c.ref']['checked'])) + if (!empty($arrayfields['c.ref']['checked'])) { print '<td class="nowrap">'; print $contracttmp->getNomUrl(1); @@ -624,23 +624,23 @@ while ($i < min($num, $limit)) print '</span>'; } - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->contrat->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir); print '</td>'; print '</td>'; } - if (! empty($arrayfields['c.ref_customer']['checked'])) + if (!empty($arrayfields['c.ref_customer']['checked'])) { print '<td>'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).'</td>'; } - if (! empty($arrayfields['c.ref_supplier']['checked'])) + if (!empty($arrayfields['c.ref_supplier']['checked'])) { print '<td>'.$obj->ref_supplier.'</td>'; } - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td>'; //print '<a href="../comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a>'; @@ -650,59 +650,59 @@ while ($i < min($num, $limit)) } print '</td>'; } - if (! empty($arrayfields['s.email']['checked'])) + if (!empty($arrayfields['s.email']['checked'])) { print '<td>'.$obj->email.'</td>'; } // Town - if (! empty($arrayfields['s.town']['checked'])) + if (!empty($arrayfields['s.town']['checked'])) { print '<td class="nocellnopadd">'; print $obj->town; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['s.zip']['checked'])) + if (!empty($arrayfields['s.zip']['checked'])) { print '<td class="nocellnopadd">'; print $obj->zip; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "<td>".$obj->state_name."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="center">'; - $tmparray=getCountry($obj->fk_pays, 'all'); + $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="center">'; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['sale_representative']['checked'])) + if (!empty($arrayfields['sale_representative']['checked'])) { // Sales representatives print '<td>'; if ($obj->socid > 0) { - $listsalesrepresentatives=$socstatic->getSalesRepresentatives($user); + $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user); if ($listsalesrepresentatives < 0) dol_print_error($db); - $nbofsalesrepresentative=count($listsalesrepresentatives); + $nbofsalesrepresentative = count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) { // We print only number print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$socstatic->id.'">'; @@ -711,17 +711,17 @@ while ($i < min($num, $limit)) } elseif ($nbofsalesrepresentative > 0) { - $userstatic=new User($db); - $j=0; - foreach($listsalesrepresentatives as $val) + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { - $userstatic->id=$val['id']; - $userstatic->lastname=$val['lastname']; - $userstatic->firstname=$val['firstname']; - $userstatic->email=$val['email']; - $userstatic->statut=$val['statut']; - $userstatic->entity=$val['entity']; - $userstatic->photo=$val['photo']; + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; //print '<div class="float">': print $userstatic->getNomUrl(-2); @@ -739,66 +739,66 @@ while ($i < min($num, $limit)) print '</td>'; } // Date - if (! empty($arrayfields['c.date_contrat']['checked'])) + if (!empty($arrayfields['c.date_contrat']['checked'])) { print '<td class="center">'.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzuser').'</td>'; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['c.datec']['checked'])) + if (!empty($arrayfields['c.datec']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['c.tms']['checked'])) + if (!empty($arrayfields['c.tms']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date lower end date - if (! empty($arrayfields['lower_planned_end_date']['checked'])) + if (!empty($arrayfields['lower_planned_end_date']['checked'])) { print '<td class="center nowrapforall">'; print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['status']['checked'])) + if (!empty($arrayfields['status']['checked'])) { - print '<td class="center">'.($obj->nb_initial>0?$obj->nb_initial:'').'</td>'; - print '<td class="center">'.($obj->nb_running>0?$obj->nb_running:'').'</td>'; - print '<td class="center">'.($obj->nb_expired>0?$obj->nb_expired:'').'</td>'; - print '<td class="center">'.($obj->nb_closed>0 ?$obj->nb_closed:'').'</td>'; + print '<td class="center">'.($obj->nb_initial > 0 ? $obj->nb_initial : '').'</td>'; + print '<td class="center">'.($obj->nb_running > 0 ? $obj->nb_running : '').'</td>'; + print '<td class="center">'.($obj->nb_expired > 0 ? $obj->nb_expired : '').'</td>'; + print '<td class="center">'.($obj->nb_closed > 0 ? $obj->nb_closed : '').'</td>'; } // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "</tr>\n"; $i++; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'; @@ -806,16 +806,16 @@ print '</div>'; print '</form>'; -$hidegeneratedfilelistifempty=1; -if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; +$hidegeneratedfilelistifempty = 1; +if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents -$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; -$urlsource.=str_replace('&', '&', $param); +$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; +$urlsource .= str_replace('&', '&', $param); -$filedir=$diroutputmassaction; -$genallowed=$user->rights->contrat->lire; -$delallowed=$user->rights->contrat->lire; +$filedir = $diroutputmassaction; +$genallowed = $user->rights->contrat->lire; +$delallowed = $user->rights->contrat->lire; print $formfile->showdocuments('massfilesarea_contract', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index d40ed042350..6a26e9ef3a0 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -44,29 +44,29 @@ if (empty($objectclass) || empty($uploaddir)) } // For backward compatibility -if (! empty($permtoread) && empty($permissiontoread)) $permissiontoread = $permtoread; -if (! empty($permtocreate) && empty($permissiontoadd)) $permissiontoadd = $permtocreate; -if (! empty($permtodelete) && empty($permissiontodelete)) $permissiontoread = $permtodelete; +if (!empty($permtoread) && empty($permissiontoread)) $permissiontoread = $permtoread; +if (!empty($permtocreate) && empty($permissiontoadd)) $permissiontoadd = $permtocreate; +if (!empty($permtodelete) && empty($permissiontodelete)) $permissiontoread = $permtodelete; // Mass actions. Controls on number of lines checked. -$maxformassaction=(empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS)?1000:$conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS); -if (! empty($massaction) && is_array($toselect) && count($toselect) < 1) +$maxformassaction = (empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS) ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS); +if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) { $error++; setEventMessages($langs->trans("NoRecordSelected"), null, "warnings"); } -if (! $error && is_array($toselect) && count($toselect) > $maxformassaction) +if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) { setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors'); $error++; } -if (! $error && $massaction == 'confirm_presend' && ! GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form +if (!$error && $massaction == 'confirm_presend' && !GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form { - $massaction='presend'; + $massaction = 'presend'; } -if (! $error && $massaction == 'confirm_presend') +if (!$error && $massaction == 'confirm_presend') { $resaction = ''; $nbsent = 0; @@ -74,35 +74,35 @@ if (! $error && $massaction == 'confirm_presend') $langs->load("mails"); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $listofobjectid=array(); - $listofobjectthirdparties=array(); + $listofobjectid = array(); + $listofobjectthirdparties = array(); $listofobjectcontacts = array(); - $listofobjectref=array(); - $contactidtosend=array(); - $attachedfilesThirdpartyObj=array(); - $oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0); + $listofobjectref = array(); + $contactidtosend = array(); + $attachedfilesThirdpartyObj = array(); + $oneemailperrecipient = (GETPOST('oneemailperrecipient') == 'on' ? 1 : 0); - if (! $error) + if (!$error) { - $thirdparty=new Societe($db); + $thirdparty = new Societe($db); - $objecttmp=new $objectclass($db); - if ($objecttmp->element == 'expensereport') $thirdparty=new User($db); - if ($objecttmp->element == 'holiday') $thirdparty=new User($db); + $objecttmp = new $objectclass($db); + if ($objecttmp->element == 'expensereport') $thirdparty = new User($db); + if ($objecttmp->element == 'holiday') $thirdparty = new User($db); - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $objecttmp=new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use - $result=$objecttmp->fetch($toselectid); + $objecttmp = new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use + $result = $objecttmp->fetch($toselectid); if ($result > 0) { - $listofobjectid[$toselectid]=$toselectid; + $listofobjectid[$toselectid] = $toselectid; - $thirdpartyid=($objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid); - if ($objecttmp->element == 'societe') $thirdpartyid=$objecttmp->id; - if ($objecttmp->element == 'expensereport') $thirdpartyid=$objecttmp->fk_user_author; - if ($objecttmp->element == 'holiday') $thirdpartyid=$objecttmp->fk_user; - if (empty($thirdpartyid)) $thirdpartyid=0; + $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); + if ($objecttmp->element == 'societe') $thirdpartyid = $objecttmp->id; + if ($objecttmp->element == 'expensereport') $thirdpartyid = $objecttmp->fk_user_author; + if ($objecttmp->element == 'holiday') $thirdpartyid = $objecttmp->fk_user; + if (empty($thirdpartyid)) $thirdpartyid = 0; if ($objectclass == 'Facture') { $tmparraycontact = array(); @@ -114,8 +114,8 @@ if (! $error && $massaction == 'confirm_presend') } } - $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; - $listofobjectref[$thirdpartyid][$toselectid]=$objecttmp; + $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; + $listofobjectref[$thirdpartyid][$toselectid] = $objecttmp; } } } @@ -125,31 +125,31 @@ if (! $error && $massaction == 'confirm_presend') { $error++; setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); - $massaction='presend'; + $massaction = 'presend'; } - $receiver=$_POST['receiver']; - if (! is_array($receiver)) + $receiver = $_POST['receiver']; + if (!is_array($receiver)) { - if (empty($receiver) || $receiver == '-1') $receiver=array(); - else $receiver=array($receiver); + if (empty($receiver) || $receiver == '-1') $receiver = array(); + else $receiver = array($receiver); } - if (! trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory + if (!trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); - $massaction='presend'; + $massaction = 'presend'; } - if (! GETPOST('subject', 'none')) + if (!GETPOST('subject', 'none')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTopic")), null, 'warnings'); - $massaction='presend'; + $massaction = 'presend'; } // Loop on each recipient/thirdparty - if (! $error) + if (!$error) { foreach ($listofobjectthirdparties as $thirdpartyid) { @@ -160,21 +160,21 @@ if (! $error && $massaction == 'confirm_presend') exit; } - $sendto=''; - $sendtocc=''; - $sendtobcc=''; + $sendto = ''; + $sendtocc = ''; + $sendtobcc = ''; $sendtoid = array(); // Define $sendto - $tmparray=array(); + $tmparray = array(); if (trim($_POST['sendto'])) { // Recipients are provided into free text $tmparray[] = trim($_POST['sendto']); } - if (count($receiver)>0) + if (count($receiver) > 0) { - foreach($receiver as $key=>$val) + foreach ($receiver as $key=>$val) { // Recipient was provided from combo list if ($val == 'thirdparty') // Id of third party or user @@ -188,23 +188,23 @@ if (! $error && $massaction == 'confirm_presend') } } } - $sendto=implode(',', $tmparray); + $sendto = implode(',', $tmparray); // Define $sendtocc - $receivercc=$_POST['receivercc']; - if (! is_array($receivercc)) + $receivercc = $_POST['receivercc']; + if (!is_array($receivercc)) { - if ($receivercc == '-1') $receivercc=array(); - else $receivercc=array($receivercc); + if ($receivercc == '-1') $receivercc = array(); + else $receivercc = array($receivercc); } - $tmparray=array(); + $tmparray = array(); if (trim($_POST['sendtocc'])) { $tmparray[] = trim($_POST['sendtocc']); } if (count($receivercc) > 0) { - foreach($receivercc as $key=>$val) + foreach ($receivercc as $key=>$val) { // Recipient was provided from combo list if ($val == 'thirdparty') // Id of third party @@ -218,35 +218,35 @@ if (! $error && $massaction == 'confirm_presend') } } } - $sendtocc=implode(',', $tmparray); + $sendtocc = implode(',', $tmparray); //var_dump($listofobjectref);exit; - $listofqualifiedobj=array(); - $listofqualifiedref=array(); - $thirdpartywithoutemail=array(); + $listofqualifiedobj = array(); + $listofqualifiedref = array(); + $thirdpartywithoutemail = array(); - foreach($listofobjectref[$thirdpartyid] as $objectid => $objectobj) + foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) { //var_dump($thirdpartyid.' - '.$objectid.' - '.$objectobj->statut); if ($objectclass == 'Propal' && $objectobj->statut == Propal::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; - $resaction.='<div class="error">'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).'</div><br>'; + $resaction .= '<div class="error">'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).'</div><br>'; continue; // Payment done or started or canceled } if ($objectclass == 'Commande' && $objectobj->statut == Commande::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; - $resaction.='<div class="error">'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).'</div><br>'; + $resaction .= '<div class="error">'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).'</div><br>'; continue; } if ($objectclass == 'Facture' && $objectobj->statut == Facture::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; - $resaction.='<div class="error">'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).'</div><br>'; + $resaction .= '<div class="error">'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).'</div><br>'; continue; // Payment done or started or canceled } @@ -269,7 +269,7 @@ if (! $error && $massaction == 'confirm_presend') { $emails_to_sends = array(); $objectobj->fetch_thirdparty(); - $contactidtosend=array(); + $contactidtosend = array(); foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) { $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid, 'email'); if (!in_array($contactemailid, $contactidtosend)) { @@ -293,10 +293,10 @@ if (! $error && $massaction == 'confirm_presend') $nbignored++; if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) { - $resaction.='<div class="error">'.$langs->trans('NoRecipientEmail', $objectobj->thirdparty->name).'</div><br>'; + $resaction .= '<div class="error">'.$langs->trans('NoRecipientEmail', $objectobj->thirdparty->name).'</div><br>'; } dol_syslog('No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING); - $thirdpartywithoutemail[$objectobj->thirdparty->id]=1; + $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1; continue; } @@ -308,13 +308,13 @@ if (! $error && $massaction == 'confirm_presend') $subdir = ''; // TODO Set subdir to be compatible with multi levels dir trees // $subdir = get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element) - $filedir = $uploaddir . '/' . $subdir . dol_sanitizeFileName($objectobj->ref); - $file = $filedir . '/' . $filename; + $filedir = $uploaddir.'/'.$subdir.dol_sanitizeFileName($objectobj->ref); + $file = $filedir.'/'.$filename; // For supplier invoices, we use the file provided by supplier, not the one we generate if ($objectobj->element == 'invoice_supplier') { - $fileparams = dol_most_recent_file($uploaddir . '/' . get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($uploaddir.'/'.get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref, '/').'([^\-])+'); $file = $fileparams['fullname']; } @@ -323,7 +323,7 @@ if (! $error && $massaction == 'confirm_presend') if (dol_is_file($file)) { // Create form object - $attachedfilesThirdpartyObj[$thirdpartyid][$objectid]=array( + $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array( 'paths'=>array($file), 'names'=>array($filename), 'mimes'=>array($mime) @@ -333,15 +333,15 @@ if (! $error && $massaction == 'confirm_presend') { $nbignored++; $langs->load("errors"); - $resaction.='<div class="error">'.$langs->trans('ErrorCantReadFile', $file).'</div><br>'; + $resaction .= '<div class="error">'.$langs->trans('ErrorCantReadFile', $file).'</div><br>'; dol_syslog('Failed to read file: '.$file, LOG_WARNING); continue; } } // Object of thirdparty qualified, we add it - $listofqualifiedobj[$objectid]=$objectobj; - $listofqualifiedref[$objectid]=$objectobj->ref; + $listofqualifiedobj[$objectid] = $objectobj; + $listofqualifiedref[$objectid] = $objectobj->ref; //var_dump($listofqualifiedref); @@ -354,21 +354,21 @@ if (! $error && $massaction == 'confirm_presend') $fromtype = GETPOST('fromtype'); if ($fromtype === 'user') { - $from = $user->getFullName($langs) .' <'.$user->email.'>'; + $from = $user->getFullName($langs).' <'.$user->email.'>'; } elseif ($fromtype === 'company') { - $from = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { - $tmp=explode(',', $user->email_aliases); + $tmp = explode(',', $user->email_aliases); $from = trim($tmp[($reg[1] - 1)]); } elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { - $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); + $tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); $from = trim($tmp[($reg[1] - 1)]); } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { - $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; + $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; $resql = $db->query($sql); $obj = $db->fetch_object($resql); if ($obj) @@ -377,7 +377,7 @@ if (! $error && $massaction == 'confirm_presend') } } else { - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; + $from = $_POST['fromname'].' <'.$_POST['frommail'].'>'; } $replyto = $from; @@ -385,30 +385,30 @@ if (! $error && $massaction == 'confirm_presend') $message = GETPOST('message', 'none'); $sendtobcc = GETPOST('sendtoccc'); - if ($objectclass == 'Propal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); - if ($objectclass == 'Commande') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); - if ($objectclass == 'Facture') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); - if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); - if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); - if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); - if ($objectclass == 'Project') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO)); + if ($objectclass == 'Propal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); + if ($objectclass == 'Commande') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); + if ($objectclass == 'Facture') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); + if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); + if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); + if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); + if ($objectclass == 'Project') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO)); // $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet) // $looparray will be an array with number of email to send for the current thirdparty (so 1 or n if n object for same thirdparty) - $looparray=array(); - if (! $oneemailperrecipient) + $looparray = array(); + if (!$oneemailperrecipient) { $looparray = $listofqualifiedobj; foreach ($looparray as $key => $objecttmp) { - $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object + $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object } } else { - $objectforloop=new $objectclass($db); - $objectforloop->thirdparty = $thirdparty; // Force thirdparty on object (even if object was not loaded) - $looparray[0]=$objectforloop; + $objectforloop = new $objectclass($db); + $objectforloop->thirdparty = $thirdparty; // Force thirdparty on object (even if object was not loaded) + $looparray[0] = $objectforloop; } //var_dump($looparray);exit; dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient); @@ -416,39 +416,39 @@ if (! $error && $massaction == 'confirm_presend') foreach ($looparray as $objectid => $objecttmp) // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object { // Make substitution in email content - if (! empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) + if (!empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) { $objecttmp->fetch_projet(); } - $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp); + $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $objecttmp); $substitutionarray['__ID__'] = ($oneemailperrecipient ? join(', ', array_keys($listofqualifiedobj)) : $objecttmp->id); $substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ', $listofqualifiedref) : $objecttmp->ref); $substitutionarray['__EMAIL__'] = $thirdparty->email; $substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>'; - $parameters=array('mode'=>'formemail'); + $parameters = array('mode'=>'formemail'); - if (! empty($listofobjectthirdparties)) { + if (!empty($listofobjectthirdparties)) { $parameters['listofobjectthirdparties'] = $listofobjectthirdparties; } - if (! empty($listofobjectref)) { + if (!empty($listofobjectref)) { $parameters['listofobjectref'] = $listofobjectref; } complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); - $subjectreplaced=make_substitutions($subject, $substitutionarray); - $messagereplaced=make_substitutions($message, $substitutionarray); + $subjectreplaced = make_substitutions($subject, $substitutionarray); + $messagereplaced = make_substitutions($message, $substitutionarray); - $attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); + $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); if ($oneemailperrecipient) { // if "one email per recipient" is check we must collate $attachedfiles by thirdparty if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) { - foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles){ + foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) { // Create form object - $attachedfiles=array( + $attachedfiles = array( 'paths'=>array_merge($attachedfiles['paths'], $objAttachedFiles['paths']), 'names'=>array_merge($attachedfiles['names'], $objAttachedFiles['names']), 'mimes'=>array_merge($attachedfiles['mimes'], $objAttachedFiles['mimes']) @@ -456,10 +456,10 @@ if (! $error && $massaction == 'confirm_presend') } } } - elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])){ + elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) { // Create form object // if "one email per recipient" isn't check we must separate $attachedfiles by object - $attachedfiles=$attachedfilesThirdpartyObj[$thirdparty->id][$objectid]; + $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid]; } $filepath = $attachedfiles['paths']; @@ -469,22 +469,22 @@ if (! $error && $massaction == 'confirm_presend') // Define the trackid when emails sent from the mass action if ($oneemailperrecipient) { - $trackid='thi'.$thirdparty->id; - if ($objecttmp->element == 'expensereport') $trackid='use'.$thirdparty->id; - if ($objecttmp->element == 'holiday') $trackid='use'.$thirdparty->id; + $trackid = 'thi'.$thirdparty->id; + if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; + if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; } else { - $trackid=strtolower(get_class($objecttmp)); - if (get_class($objecttmp)=='Contrat') $trackid='con'; - if (get_class($objecttmp)=='Propal') $trackid='pro'; - if (get_class($objecttmp)=='Commande') $trackid='ord'; - if (get_class($objecttmp)=='Facture') $trackid='inv'; - if (get_class($objecttmp)=='Supplier_Proposal') $trackid='spr'; - if (get_class($objecttmp)=='CommandeFournisseur') $trackid='sor'; - if (get_class($objecttmp)=='FactureFournisseur') $trackid='sin'; + $trackid = strtolower(get_class($objecttmp)); + if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; + if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; + if (get_class($objecttmp) == 'Commande') $trackid = 'ord'; + if (get_class($objecttmp) == 'Facture') $trackid = 'inv'; + if (get_class($objecttmp) == 'Supplier_Proposal') $trackid = 'spr'; + if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor'; + if (get_class($objecttmp) == 'FactureFournisseur') $trackid = 'sin'; - $trackid.=$objecttmp->id; + $trackid .= $objecttmp->id; } //var_dump($filepath); //var_dump($trackid);exit; @@ -495,21 +495,21 @@ if (! $error && $massaction == 'confirm_presend') $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid); if ($mailfile->error) { - $resaction.='<div class="error">'.$mailfile->error.'</div>'; + $resaction .= '<div class="error">'.$mailfile->error.'</div>'; } else { - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $resaction.=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'<br>'; // Must not contain " + $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'<br>'; // Must not contain " - $error=0; + $error = 0; // Insert logs into agenda - foreach($listofqualifiedobj as $objid2 => $objectobj2) + foreach ($listofqualifiedobj as $objid2 => $objectobj2) { - if ((! $oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level + if ((!$oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2)); @@ -520,24 +520,24 @@ if (! $error && $massaction == 'confirm_presend') if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD'; if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/ - $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subjectreplaced); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subjectreplaced); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); $actionmsg = dol_concatdesc($actionmsg, $messagereplaced); } - $actionmsg2=''; + $actionmsg2 = ''; // Initialisation donnees - $objectobj2->sendtoid = (empty($contactidtosend)?0:$contactidtosend); - $objectobj2->actionmsg = $actionmsg; // Long text + $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend); + $objectobj2->actionmsg = $actionmsg; // Long text $objectobj2->actionmsg2 = $actionmsg2; // Short text $objectobj2->fk_element = $objid2; $objectobj2->elementtype = $objectobj2->element; - $triggername = strtoupper(get_class($objectobj2)) .'_SENTBYMAIL'; + $triggername = strtoupper(get_class($objectobj2)).'_SENTBYMAIL'; if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYMAIL'; if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYMAIL'; if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYMAIL'; @@ -547,13 +547,13 @@ if (! $error && $massaction == 'confirm_presend') if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYMAIL'; if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYMAIL'; - if (! empty($triggername)) + if (!empty($triggername)) { // Appel des triggers - include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"; - $interface=new Interfaces($db); - $result=$interface->run_triggers($triggername, $objectobj2, $user, $langs, $conf); - if ($result < 0) { $error++; $errors=$interface->errors; } + include_once DOL_DOCUMENT_ROOT."/core/class/interfaces.class.php"; + $interface = new Interfaces($db); + $result = $interface->run_triggers($triggername, $objectobj2, $user, $langs, $conf); + if ($result < 0) { $error++; $errors = $interface->errors; } // Fin appel triggers if ($error) @@ -563,7 +563,7 @@ if (! $error && $massaction == 'confirm_presend') } } - $nbsent++; // Nb of object sent + $nbsent++; // Nb of object sent } } else @@ -571,12 +571,12 @@ if (! $error && $massaction == 'confirm_presend') $langs->load("other"); if ($mailfile->error) { - $resaction.=$langs->trans('ErrorFailedToSendMail', $from, $sendto); - $resaction.='<br><div class="error">'.$mailfile->error.'</div>'; + $resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); + $resaction .= '<br><div class="error">'.$mailfile->error.'</div>'; } else { - $resaction.='<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>'; + $resaction .= '<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>'; } } } @@ -584,15 +584,15 @@ if (! $error && $massaction == 'confirm_presend') } } - $resaction.=($resaction?'<br>':$resaction); - $resaction.='<strong>'.$langs->trans("ResultOfMailSending").':</strong><br>'."\n"; - $resaction.=$langs->trans("NbSelected").': '.count($toselect)."\n<br>"; - $resaction.=$langs->trans("NbIgnored").': '.($nbignored?$nbignored:0)."\n<br>"; - $resaction.=$langs->trans("NbSent").': '.($nbsent?$nbsent:0)."\n<br>"; + $resaction .= ($resaction ? '<br>' : $resaction); + $resaction .= '<strong>'.$langs->trans("ResultOfMailSending").':</strong><br>'."\n"; + $resaction .= $langs->trans("NbSelected").': '.count($toselect)."\n<br>"; + $resaction .= $langs->trans("NbIgnored").': '.($nbignored ? $nbignored : 0)."\n<br>"; + $resaction .= $langs->trans("NbSent").': '.($nbsent ? $nbsent : 0)."\n<br>"; if ($nbsent) { - $action=''; // Do not show form post if there was at least one successfull sent + $action = ''; // Do not show form post if there was at least one successfull sent //setEventMessages($langs->trans("EMailSentToNRecipients", $nbsent.'/'.count($toselect)), null, 'mesgs'); setEventMessages($langs->trans("EMailSentForNElements", $nbsent.'/'.count($toselect)), null, 'mesgs'); setEventMessages($resaction, null, 'mesgs'); @@ -603,8 +603,8 @@ if (! $error && $massaction == 'confirm_presend') setEventMessages($resaction, null, 'warnings'); } - $action='list'; - $massaction=''; + $action = 'list'; + $massaction = ''; } } @@ -621,7 +621,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $db->begin(); - foreach($orders as $id_order) + foreach ($orders as $id_order) { $cmd = new Commande($db); if ($cmd->fetch($id_order) <= 0) continue; @@ -636,8 +636,8 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $objecttmp->type = Facture::TYPE_STANDARD; $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; - $objecttmp->fk_project = $cmd->fk_project; - $objecttmp->multicurrency_code = $cmd->multicurrency_code; + $objecttmp->fk_project = $cmd->fk_project; + $objecttmp->multicurrency_code = $cmd->multicurrency_code; if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); @@ -650,33 +650,33 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $objecttmp->origin = 'commande'; $objecttmp->origin_id = $id_order; - $objecttmp->array_options = $cmd->array_options; // Copy extrafields + $objecttmp->array_options = $cmd->array_options; // Copy extrafields $res = $objecttmp->create($user); - if($res > 0) $nb_bills_created++; + if ($res > 0) $nb_bills_created++; } if ($objecttmp->id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sql.= "fk_source"; - $sql.= ", sourcetype"; - $sql.= ", fk_target"; - $sql.= ", targettype"; - $sql.= ") VALUES ("; - $sql.= $id_order; - $sql.= ", '".$objecttmp->origin."'"; - $sql.= ", ".$objecttmp->id; - $sql.= ", '".$objecttmp->element."'"; - $sql.= ")"; + $sql .= "fk_source"; + $sql .= ", sourcetype"; + $sql .= ", fk_target"; + $sql .= ", targettype"; + $sql .= ") VALUES ("; + $sql .= $id_order; + $sql .= ", '".$objecttmp->origin."'"; + $sql .= ", ".$objecttmp->id; + $sql .= ", '".$objecttmp->element."'"; + $sql .= ")"; - if (! $db->query($sql)) + if (!$db->query($sql)) { $error++; } - if (! $error) + if (!$error) { $lines = $cmd->lines; if (empty($lines) && method_exists($cmd, 'fetch_lines')) @@ -685,33 +685,33 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $lines = $cmd->lines; } - $fk_parent_line=0; - $num=count($lines); + $fk_parent_line = 0; + $num = count($lines); - for ($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); // If we build one invoice for several order, we must put the invoice of order on the line - if (! empty($createbills_onebythird)) + if (!empty($createbills_onebythird)) { - $desc=dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day', $langs)); + $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day', $langs)); } if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); - $discount->fk_soc=$objecttmp->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); + $discount->fk_soc = $objecttmp->socid; + $discount->amount_ht = abs($lines[$i]->total_ht); + $discount->amount_tva = abs($lines[$i]->total_tva); + $discount->amount_ttc = abs($lines[$i]->total_ttc); + $discount->tva_tx = $lines[$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); if ($discountid > 0) { - $result=$objecttmp->insert_discount($discountid); + $result = $objecttmp->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else @@ -724,17 +724,17 @@ if ($massaction == 'confirm_createbills') // Create bills from orders else { // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_start = false; + if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + $date_end = false; + if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { @@ -776,11 +776,11 @@ if ($massaction == 'confirm_createbills') // Create bills from orders ); if ($result > 0) { - $lineid=$result; + $lineid = $result; } else { - $lineid=0; + $lineid = 0; $error++; break; } @@ -796,7 +796,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. - if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp; + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp; else $TFact[$objecttmp->id] = $objecttmp; } @@ -804,11 +804,11 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - if (! $error && $validate_invoices) + if (!$error && $validate_invoices) { $massaction = $action = 'builddoc'; - foreach($TAllFact as &$objecttmp) + foreach ($TAllFact as &$objecttmp) { $result = $objecttmp->validate($user); if ($result <= 0) @@ -836,36 +836,36 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $massaction = $action = 'confirm_createbills'; } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); // Make a redirect to avoid to bill twice if we make a refresh or back - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.='&sall='.urlencode($sall); - if ($socid > 0) $param.='&socid='.urlencode($socid); - if ($viewstatut != '') $param.='&viewstatut='.urlencode($viewstatut); - if ($search_orderday) $param.='&search_orderday='.urlencode($search_orderday); - if ($search_ordermonth) $param.='&search_ordermonth='.urlencode($search_ordermonth); - if ($search_orderyear) $param.='&search_orderyear='.urlencode($search_orderyear); - if ($search_deliveryday) $param.='&search_deliveryday='.urlencode($search_deliveryday); - if ($search_deliverymonth) $param.='&search_deliverymonth='.urlencode($search_deliverymonth); - if ($search_deliveryyear) $param.='&search_deliveryyear='.urlencode($search_deliveryyear); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_company) $param.='&search_company='.urlencode($search_company); - if ($search_ref_customer) $param.='&search_ref_customer='.urlencode($search_ref_customer); - if ($search_user > 0) $param.='&search_user='.urlencode($search_user); - if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); - if ($search_total_ht != '') $param.='&search_total_ht='.urlencode($search_total_ht); - if ($search_total_vat != '') $param.='&search_total_vat='.urlencode($search_total_vat); - if ($search_total_ttc != '') $param.='&search_total_ttc='.urlencode($search_total_ttc); - if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref); - if ($show_files) $param.='&show_files=' .urlencode($show_files); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($billed != '') $param.='&billed='.urlencode($billed); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= '&sall='.urlencode($sall); + if ($socid > 0) $param .= '&socid='.urlencode($socid); + if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut); + if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday); + if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth); + if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear); + if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday); + if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_company) $param .= '&search_company='.urlencode($search_company); + if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); + if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); + if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); + if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); + if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); + if ($show_files) $param .= '&show_files='.urlencode($show_files); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($billed != '') $param .= '&billed='.urlencode($billed); header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); exit; @@ -873,9 +873,9 @@ if ($massaction == 'confirm_createbills') // Create bills from orders else { $db->rollback(); - $action='create'; - $_GET["origin"]=$_POST["origin"]; - $_GET["originid"]=$_POST["originid"]; + $action = 'create'; + $_GET["origin"] = $_POST["origin"]; + $_GET["originid"] = $_POST["originid"]; setEventMessages("Error", null, 'errors'); $error++; } @@ -929,7 +929,7 @@ if (!$error && $massaction == 'cancelorders') } -if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('button_search')) +if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('button_search')) { if (empty($diroutputmassaction)) { @@ -941,34 +941,34 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $objecttmp=new $objectclass($db); - $listofobjectid=array(); - $listofobjectthirdparties=array(); - $listofobjectref=array(); - foreach($toselect as $toselectid) + $objecttmp = new $objectclass($db); + $listofobjectid = array(); + $listofobjectthirdparties = array(); + $listofobjectref = array(); + foreach ($toselect as $toselectid) { - $objecttmp=new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use - $result=$objecttmp->fetch($toselectid); + $objecttmp = new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use + $result = $objecttmp->fetch($toselectid); if ($result > 0) { - $listofobjectid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; - $listofobjectref[$toselectid]=$objecttmp->ref; + $listofobjectid[$toselectid] = $toselectid; + $thirdpartyid = $objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid; + $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; + $listofobjectref[$toselectid] = $objecttmp->ref; } } - $arrayofinclusion=array(); - foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; - foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files + $arrayofinclusion = array(); + foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; + foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files $listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true); // build list of files with full path $files = array(); - foreach($listofobjectref as $basename) + foreach ($listofobjectref as $basename) { $basename = dol_sanitizeFileName($basename); - foreach($listoffiles as $filefound) + foreach ($listoffiles as $filefound) { if (strstr($filefound["name"], $basename)) { @@ -980,10 +980,10 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but // Define output language (Here it is not used because we do only merging existing PDF) $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$objecttmp->thirdparty->default_lang; - if (! empty($newlang)) { + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $objecttmp->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -994,32 +994,32 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but dol_mkdir($diroutputmassaction); // Defined name of merged file - $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); - $filename=preg_replace('/\s/', '_', $filename); + $filename = strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); + $filename = preg_replace('/\s/', '_', $filename); // Save merged file if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) { - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); } - if ($year) $filename.='_'.$year; - if ($month) $filename.='_'.$month; + if ($year) $filename .= '_'.$year; + if ($month) $filename .= '_'.$month; - if (count($files)>0) + if (count($files) > 0) { - $now=dol_now(); - $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; + $now = dol_now(); + $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; $input_files = ''; - foreach($files as $f) { - $input_files.=' '.escapeshellarg($f); + foreach ($files as $f) { + $input_files .= ' '.escapeshellarg($f); } $cmd = 'pdftk '.escapeshellarg($input_files).' cat output '.escapeshellarg($file); exec($cmd); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $langs->load("exports"); @@ -1032,12 +1032,12 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but } else { // Create empty PDF - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $page_largeur = $formatarray['width']; $page_hauteur = $formatarray['height']; $format = array($page_largeur, $page_hauteur); - $pdf=pdf_getInstance($format); + $pdf = pdf_getInstance($format); if (class_exists('TCPDF')) { @@ -1046,10 +1046,10 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but } $pdf->SetFont(pdf_getPDFFont($outputlangs)); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); // Add all others - foreach($files as $file) + foreach ($files as $file) { // Charge un document PDF depuis un fichier. $pagecount = $pdf->setSourceFile($file); @@ -1066,23 +1066,23 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but dol_mkdir($diroutputmassaction); // Defined name of merged file - $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); - $filename=preg_replace('/\s/', '_', $filename); + $filename = strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); + $filename = preg_replace('/\s/', '_', $filename); // Save merged file if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) { - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); } - if ($year) $filename.='_'.$year; - if ($month) $filename.='_'.$month; + if ($year) $filename .= '_'.$year; + if ($month) $filename .= '_'.$month; if ($pagecount) { - $now=dol_now(); - $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; + $now = dol_now(); + $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; $pdf->Output($file, 'F'); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $langs->load("exports"); @@ -1102,38 +1102,38 @@ if ($action == 'remove_file') $langs->load("other"); $upload_dir = $diroutputmassaction; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file); + $file = $upload_dir.'/'.GETPOST('file'); + $ret = dol_delete_file($file); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); - $action=''; + $action = ''; } // Validate records -if (! $error && $massaction == 'validate' && $permissiontoadd) +if (!$error && $massaction == 'validate' && $permissiontoadd) { - $objecttmp=new $objectclass($db); + $objecttmp = new $objectclass($db); - if ($objecttmp->element == 'invoice' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if ($objecttmp->element == 'invoice' && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { $langs->load("errors"); setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); $error++; } - if ($objecttmp->element == 'invoice_supplier' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) + if ($objecttmp->element == 'invoice_supplier' && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { $langs->load("errors"); setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->begin(); $nbok = 0; - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $result=$objecttmp->fetch($toselectid); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { //if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); @@ -1162,7 +1162,7 @@ if (! $error && $massaction == 'validate' && $permissiontoadd) } } - if (! $error) + if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); @@ -1212,15 +1212,15 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio } } // Delete record from mass action (massaction = 'delete' for direct delete, action/confirm='delete'/'yes' with a confirmation step before) -if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) +if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) { $db->begin(); - $objecttmp=new $objectclass($db); + $objecttmp = new $objectclass($db); $nbok = 0; - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $result=$objecttmp->fetch($toselectid); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { // Refuse deletion for some objects/status @@ -1228,7 +1228,7 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == { $langs->load("errors"); $nbignored++; - $resaction.='<div class="error">'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'</div><br>'; + $resaction .= '<div class="error">'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'</div><br>'; continue; } @@ -1263,7 +1263,7 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == } } - if (! $error) + if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); @@ -1278,36 +1278,36 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == // Generate document foreach object according to model linked to object // @TODO : propose model selection -if (! $error && $massaction == 'generate_doc' && $permissiontoread) +if (!$error && $massaction == 'generate_doc' && $permissiontoread) { $db->begin(); - $objecttmp=new $objectclass($db); + $objecttmp = new $objectclass($db); $nbok = 0; - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $result=$objecttmp->fetch($toselectid); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { $outputlangs = $langs; - $newlang=''; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang=$objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang=$objecttmp->default_lang; // for thirdparty - if (! empty($newlang)) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // To be sure vars is defined - if (empty($hidedetails)) $hidedetails=0; - if (empty($hidedesc)) $hidedesc=0; - if (empty($hideref)) $hideref=0; - if (empty($moreparams)) $moreparams=null; + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; - $result= $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result = $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); if ($result <= 0) { @@ -1325,7 +1325,7 @@ if (! $error && $massaction == 'generate_doc' && $permissiontoread) } } - if (! $error) + if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); @@ -1337,10 +1337,10 @@ if (! $error && $massaction == 'generate_doc' && $permissiontoread) } } -$parameters['toselect']=$toselect; -$parameters['uploaddir']=$uploaddir; -$parameters['massaction']=$massaction; -$parameters['diroutputmassaction']=$diroutputmassaction; +$parameters['toselect'] = $toselect; +$parameters['uploaddir'] = $uploaddir; +$parameters['massaction'] = $massaction; +$parameters['diroutputmassaction'] = $diroutputmassaction; -$reshook=$hookmanager->executeHooks('doMassActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$reshook = $hookmanager->executeHooks('doMassActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 9140b9b9d43..91c6ab23910 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -34,9 +34,9 @@ include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; */ class box_contacts extends ModeleBoxes { - public $boxcode="lastcontacts"; - public $boximg="object_contact"; - public $boxlabel="BoxLastContacts"; + public $boxcode = "lastcontacts"; + public $boximg = "object_contact"; + public $boxlabel = "BoxLastContacts"; public $depends = array("societe"); /** @@ -62,7 +62,7 @@ class box_contacts extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->societe->lire && $user->rights->societe->contact->lire); + $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire); } /** @@ -76,46 +76,46 @@ class box_contacts extends ModeleBoxes global $user, $langs, $conf; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max)); if ($user->rights->societe->lire && $user->rights->societe->contact->lire) { $sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status"; - $sql.= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail"; - $sql.= ", s.nom as socname, s.name_alias, s.email as semail"; - $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; - $sql.= ", co.label as country, co.code as country_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON sp.fk_pays = co.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; - if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) $sql.= " AND sp.fk_soc = ".$user->socid; - $sql.= " ORDER BY sp.tms DESC"; - $sql.= $this->db->plimit($max, 0); + $sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail"; + $sql .= ", s.nom as socname, s.name_alias, s.email as semail"; + $sql .= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; + $sql .= ", co.label as country, co.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON sp.fk_pays = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sp.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND sp.fk_soc = ".$user->socid; + $sql .= " ORDER BY sp.tms DESC"; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $contactstatic=new Contact($this->db); - $societestatic=new Societe($this->db); + $contactstatic = new Contact($this->db); + $societestatic = new Societe($this->db); $line = 0; while ($line < $num) { $objp = $this->db->fetch_object($result); - $datec=$this->db->jdate($objp->datec); - $datem=$this->db->jdate($objp->tms); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); - $contactstatic->id=$objp->id; - $contactstatic->lastname=$objp->lastname; - $contactstatic->firstname=$objp->firstname; - $contactstatic->civility_id=$objp->civility_id; - $contactstatic->statut=$objp->status; + $contactstatic->id = $objp->id; + $contactstatic->lastname = $objp->lastname; + $contactstatic->firstname = $objp->firstname; + $contactstatic->civility_id = $objp->civility_id; + $contactstatic->statut = $objp->status; $contactstatic->phone_pro = $objp->phone; $contactstatic->phone_perso = $objp->phone_perso; $contactstatic->phone_mobile = $objp->phone_mobile; @@ -161,7 +161,7 @@ class box_contacts extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=> '<span class="opacitymedium">'.$langs->trans("NoRecordedContacts").'</span>', diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index 18c2ebfe340..f6bbbb76854 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -23,7 +23,7 @@ * \ingroup ticket * \brief This box shows latest modified tickets */ -require_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; +require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box @@ -86,23 +86,23 @@ class box_last_modified_ticket extends ModeleBoxes if ($user->rights->ticket->read) { $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; - $sql.= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; - $sql.= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; - $sql.= " FROM ".MAIN_DB_PREFIX."ticket as t"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; + $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - $sql.= " WHERE t.entity = ".$conf->entity; + $sql .= " WHERE t.entity = ".$conf->entity; // $sql.= " AND e.rowid = er.fk_event"; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->socid) { - $sql.= " AND t.fk_soc= ".$user->socid; + $sql .= " AND t.fk_soc= ".$user->socid; } - $sql.= " ORDER BY t.tms DESC, t.rowid DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " ORDER BY t.tms DESC, t.rowid DESC "; + $sql .= $this->db->plimit($max, 0); $resql = $this->db->query($sql); if ($resql) { @@ -112,9 +112,9 @@ class box_last_modified_ticket extends ModeleBoxes while ($i < $num) { $objp = $this->db->fetch_object($resql); - $datec=$this->db->jdate($objp->datec); - $dateterm=$this->db->jdate($objp->fin_validite); - $dateclose=$this->db->jdate($objp->date_cloture); + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); $late = ''; $ticket = new Ticket($this->db); @@ -136,7 +136,7 @@ class box_last_modified_ticket extends ModeleBoxes } - $r=0; + $r = 0; // Ticket $this->info_box_contents[$i][0] = array( @@ -149,7 +149,7 @@ class box_last_modified_ticket extends ModeleBoxes // Subject $this->info_box_contents[$i][$r] = array( 'td' => 'class="nowrap"', - 'text' => $objp->subject, // Some event have no ref + 'text' => $objp->subject, // Some event have no ref 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, ); $r++; @@ -180,8 +180,8 @@ class box_last_modified_ticket extends ModeleBoxes $i++; } - if ($num==0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"','text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); } } else { dol_print_error($this->db); diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 4a0842139d6..0ac4557431b 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -23,7 +23,7 @@ * \ingroup ticket * \brief This box shows latest created tickets */ -require_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; +require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box @@ -88,17 +88,17 @@ class box_last_ticket extends ModeleBoxes $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; - $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_type as type ON type.code=t.type_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_category as category ON category.code=t.category_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid=t.fk_soc"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - $sql .= " WHERE t.entity = " . $conf->entity; + $sql .= " WHERE t.entity = ".$conf->entity; // $sql.= " AND e.rowid = er.fk_event"; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->socid) { - $sql .= " AND t.fk_soc= " . $user->socid; + $sql .= " AND t.fk_soc= ".$user->socid; } //$sql.= " AND t.fk_statut > 9"; @@ -151,7 +151,7 @@ class box_last_ticket extends ModeleBoxes $this->info_box_contents[$i][$r] = array( 'td' => '', 'text' => $objp->subject, // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=" . $objp->track_id, + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, ); $r++; diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index 7a6c74e216c..6af4468c669 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -30,9 +30,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_lastlogin extends ModeleBoxes { - public $boxcode="lastlogin"; - public $boximg="object_user"; - public $boxlabel='BoxLoginInformation'; + public $boxcode = "lastlogin"; + public $boximg = "object_user"; + public $boxlabel = 'BoxLoginInformation'; public $depends = array("user"); /** @@ -57,7 +57,7 @@ class box_lastlogin extends ModeleBoxes { global $conf; - $this->db=$db; + $this->db = $db; } /** @@ -76,7 +76,7 @@ class box_lastlogin extends ModeleBoxes 'limit'=> dol_strlen($textHead), ); - $line=0; + $line = 0; $this->info_box_contents[$line][0] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $langs->trans("User"), @@ -87,13 +87,13 @@ class box_lastlogin extends ModeleBoxes 'asis' => 1 ); - $line=1; + $line = 1; $this->info_box_contents[$line][0] = array( 'td' => '', 'text' => $langs->trans("PreviousConnexion"), ); - if ($user->datepreviouslogin) $tmp= dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); - else $tmp= $langs->trans("Unknown"); + if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); + else $tmp = $langs->trans("Unknown"); $this->info_box_contents[$line][1] = array( 'td' => '', 'text' => $tmp, diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 582b5101aa1..e80c2a57214 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -30,10 +30,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_services_expired extends ModeleBoxes { - public $boxcode="expiredservices"; // id of box - public $boximg="object_contract"; - public $boxlabel="BoxOldestExpiredServices"; - public $depends = array("contrat"); // conf->propal->enabled + public $boxcode = "expiredservices"; // id of box + public $boximg = "object_contract"; + public $boxlabel = "BoxOldestExpiredServices"; + public $depends = array("contrat"); // conf->propal->enabled /** * @var DoliDB Database handler. @@ -58,7 +58,7 @@ class box_services_expired extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->contrat->lire); + $this->hidden = !($user->rights->contrat->lire); } /** @@ -71,11 +71,11 @@ class box_services_expired extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $now=dol_now(); + $now = dol_now(); $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max)); @@ -83,19 +83,19 @@ class box_services_expired extends ModeleBoxes { // Select contracts with at least one expired service $sql = "SELECT "; - $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; - $sql.= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql.= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; - if ($user->socid) $sql.=' AND c.fk_soc = '.$user->socid; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - $sql.= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; - $sql.= " ORDER BY date_line ASC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; + $sql .= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; + $sql .= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; + if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; + $sql .= " ORDER BY date_line ASC"; + $sql .= $this->db->plimit($max, 0); $resql = $this->db->query($sql); if ($resql) @@ -109,7 +109,7 @@ class box_services_expired extends ModeleBoxes while ($i < $num) { - $late=''; + $late = ''; $objp = $this->db->fetch_object($resql); @@ -129,8 +129,8 @@ class box_services_expired extends ModeleBoxes $contract->ref_customer = $objp->ref_customer; $contract->ref_supplier = $objp->ref_supplier; - $dateline=$this->db->jdate($objp->date_line); - if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late=img_warning($langs->trans("Late")); + $dateline = $this->db->jdate($objp->date_line); + if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', @@ -159,7 +159,7 @@ class box_services_expired extends ModeleBoxes $i++; } - if ($num==0) + if ($num == 0) { $langs->load("contracts"); $this->info_box_contents[$i][] = array( diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 4a55fa24bb3..eb4db331296 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -43,7 +43,7 @@ class FormFile public $error; public $numoffiles; - public $infofiles; // Used to return informations by function getDocumentsLink + public $infofiles; // Used to return informations by function getDocumentsLink /** @@ -54,7 +54,7 @@ class FormFile public function __construct($db) { $this->db = $db; - $this->numoffiles=0; + $this->numoffiles = 0; } @@ -83,17 +83,17 @@ class FormFile public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0) { // phpcs:enable - global $conf,$langs, $hookmanager; + global $conf, $langs, $hookmanager; $hookmanager->initHooks(array('formfile')); // Deprecation warning if ($useajax == 2) { - dol_syslog(__METHOD__ . ": using 2 for useajax is deprecated and should be not used", LOG_WARNING); + dol_syslog(__METHOD__.": using 2 for useajax is deprecated and should be not used", LOG_WARNING); } - if (! empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax=0; + if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax = 0; - if ((! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax==2)) + if ((!empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax == 2)) { // TODO: Check this works with 2 forms on same page // TODO: Check this works with GED module, otherwise, force useajax to 0 @@ -108,12 +108,12 @@ class FormFile return 1; } - $maxlength=$size; + $maxlength = $size; $out = "\n\n<!-- Start form attach new file -->\n"; - if (empty($title)) $title=$langs->trans("AttachANewFile"); - if ($title != 'none') $out.=load_fiche_titre($title, null, null); + if (empty($title)) $title = $langs->trans("AttachANewFile"); + if ($title != 'none') $out .= load_fiche_titre($title, null, null); if (empty($usewithoutform)) // Try to avoid this and set instead the form by the caller. { @@ -128,33 +128,33 @@ class FormFile $out .= '<table width="100%" class="nobordernopadding">'; $out .= '<tr>'; - if (! empty($options)) $out .= '<td>'.$options.'</td>'; + if (!empty($options)) $out .= '<td>'.$options.'</td>'; $out .= '<td class="valignmiddle nowrap">'; - $max=$conf->global->MAIN_UPLOAD_DOC; // In Kb - $maxphp=@ini_get('upload_max_filesize'); // In unknown - if (preg_match('/k$/i', $maxphp)) $maxphp=$maxphp*1; - if (preg_match('/m$/i', $maxphp)) $maxphp=$maxphp*1024; - if (preg_match('/g$/i', $maxphp)) $maxphp=$maxphp*1024*1024; - if (preg_match('/t$/i', $maxphp)) $maxphp=$maxphp*1024*1024*1024; - $maxphp2=@ini_get('post_max_size'); // In unknown - if (preg_match('/k$/i', $maxphp2)) $maxphp2=$maxphp2*1; - if (preg_match('/m$/i', $maxphp2)) $maxphp2=$maxphp2*1024; - if (preg_match('/g$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024; - if (preg_match('/t$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024*1024; + $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb + $maxphp = @ini_get('upload_max_filesize'); // In unknown + if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1; + if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024; + if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024; + if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024; + $maxphp2 = @ini_get('post_max_size'); // In unknown + if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1; + if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024; + if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024; + if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; // Now $max and $maxphp and $maxphp2 are in Kb $maxmin = $max; $maxphptoshow = $maxphptoshowparam = ''; if ($maxphp > 0) { - $maxmin=min($max, $maxphp); + $maxmin = min($max, $maxphp); $maxphptoshow = $maxphp; $maxphptoshowparam = 'upload_max_filesize'; } if ($maxphp2 > 0) { - $maxmin=min($max, $maxphp2); + $maxmin = min($max, $maxphp2); if ($maxphp2 < $maxphp) { $maxphptoshow = $maxphp2; @@ -165,17 +165,17 @@ class FormFile if ($maxmin > 0) { // MAX_FILE_SIZE doit précéder le champ input de type file - $out .= '<input type="hidden" name="max_file_size" value="'.($maxmin*1024).'">'; + $out .= '<input type="hidden" name="max_file_size" value="'.($maxmin * 1024).'">'; } $out .= '<input class="flat minwidth400" type="file"'; - $out .= ((! empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic')?' name="userfile"':' name="userfile[]" multiple'); - $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); - $out .= (!empty($accept)?' accept="'.$accept.'"':' accept=""'); + $out .= ((!empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic') ? ' name="userfile"' : ' name="userfile[]" multiple'); + $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); + $out .= (!empty($accept) ? ' accept="'.$accept.'"' : ' accept=""'); $out .= '>'; $out .= ' '; $out .= '<input type="submit" class="button reposition" name="sendit" value="'.$langs->trans("Upload").'"'; - $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); + $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); $out .= '>'; if ($addcancel) @@ -184,7 +184,7 @@ class FormFile $out .= '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; } - if (! empty($conf->global->MAIN_UPLOAD_DOC)) + if (!empty($conf->global->MAIN_UPLOAD_DOC)) { if ($perm) { @@ -202,10 +202,10 @@ class FormFile if ($savingdocmask) { //add a global variable for disable the auto renaming on upload - $rename=(empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT)?'checked':''); + $rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ? 'checked' : ''); $out .= '<tr>'; - if (! empty($options)) $out .= '<td>'.$options.'</td>'; + if (!empty($options)) $out .= '<td>'.$options.'</td>'; $out .= '<td valign="middle" class="nowrap">'; $out .= '<input type="checkbox" '.$rename.' class="savingdocmask" name="savingdocmask" value="'.dol_escape_js($savingdocmask).'"> '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); $out .= '</td>'; @@ -239,18 +239,18 @@ class FormFile $out .= '<div class="valignmiddle">'; $out .= '<div class="inline-block" style="padding-right: 10px;">'; - if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="link">'.$langs->trans("URLToLink") . ':</label> '; + if (!empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="link">'.$langs->trans("URLToLink").':</label> '; $out .= '<input type="text" name="link" class="flat minwidth400imp" id="link" placeholder="'.dol_escape_htmltag($langs->trans("URLToLink")).'">'; $out .= '</div>'; $out .= '<div class="inline-block" style="padding-right: 10px;">'; - if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="label">'.$langs->trans("Label") . ':</label> '; + if (!empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="label">'.$langs->trans("Label").':</label> '; $out .= '<input type="text" class="flat" name="label" id="label" placeholder="'.dol_escape_htmltag($langs->trans("Label")).'">'; - $out .= '<input type="hidden" name="objecttype" value="' . $object->element . '">'; - $out .= '<input type="hidden" name="objectid" value="' . $object->id . '">'; + $out .= '<input type="hidden" name="objecttype" value="'.$object->element.'">'; + $out .= '<input type="hidden" name="objectid" value="'.$object->id.'">'; $out .= '</div>'; $out .= '<div class="inline-block" style="padding-right: 10px;">'; $out .= '<input type="submit" class="button" name="linkit" value="'.$langs->trans("ToLink").'"'; - $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); + $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); $out .= '>'; $out .= '</div>'; $out .= '</div>'; @@ -263,11 +263,11 @@ class FormFile $out .= "\n<!-- End form link new url -->\n"; } - $parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''), 'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm); + $parameters = array('socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'url'=>$url, 'perm'=>$perm); $res = $hookmanager->executeHooks('formattachOptions', $parameters, $object); if (empty($res)) { - print '<div class="'.($usewithoutform?'inline-block valignmiddle':'attacharea attacharea'.$htmlname).'">'; + print '<div class="'.($usewithoutform ? 'inline-block valignmiddle' : 'attacharea attacharea'.$htmlname).'">'; print $out; print '</div>'; } @@ -303,7 +303,7 @@ class FormFile public function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '') { // phpcs:enable - $this->numoffiles=0; + $this->numoffiles = 0; print $this->showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang); return $this->numoffiles; } @@ -336,57 +336,57 @@ class FormFile public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0) { // Deprecation warning - if (! empty($iconPDF)) { - dol_syslog(__METHOD__ . ": passing iconPDF parameter is deprecated", LOG_WARNING); + if (!empty($iconPDF)) { + dol_syslog(__METHOD__.": passing iconPDF parameter is deprecated", LOG_WARNING); } global $langs, $conf, $user, $hookmanager; global $form; - if (! is_object($form)) $form=new Form($this->db); + if (!is_object($form)) $form = new Form($this->db); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // For backward compatibility - if (! empty($iconPDF)) { + if (!empty($iconPDF)) { return $this->getDocumentsLink($modulepart, $modulesubdir, $filedir); } // Add entity in $param if not already exists if (!preg_match('/entity\=[0-9]+/', $param)) { - $param.= 'entity='.(!empty($object->entity)?$object->entity:$conf->entity); + $param .= 'entity='.(!empty($object->entity) ? $object->entity : $conf->entity); } - $printer=0; + $printer = 0; if (in_array($modulepart, array('facture', 'supplier_proposal', 'propal', 'proposal', 'order', 'commande', 'expedition', 'commande_fournisseur', 'expensereport', 'livraison', 'ticket'))) // The direct print feature is implemented only for such elements { - $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false; + $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled)) ?true:false; } $hookmanager->initHooks(array('formfile')); // Get list of files - $file_list=null; - if (! empty($filedir)) + $file_list = null; + if (!empty($filedir)) { - $file_list=dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC); + $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC); } if ($hideifempty && empty($file_list)) return ''; - $out=''; - $forname='builddoc'; - $headershown=0; - $showempty=0; - $i=0; + $out = ''; + $forname = 'builddoc'; + $headershown = 0; + $showempty = 0; + $i = 0; - $out.= "\n".'<!-- Start show_document -->'."\n"; + $out .= "\n".'<!-- Start show_document -->'."\n"; //print 'filedir='.$filedir; if (preg_match('/massfilesarea_/', $modulepart)) { - $out.='<div id="show_files"><br></div>'."\n"; - $title=$langs->trans("MassFilesArea").' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans("Hide").')</a>'; - $title.='<script> + $out .= '<div id="show_files"><br></div>'."\n"; + $title = $langs->trans("MassFilesArea").' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans("Hide").')</a>'; + $title .= '<script> jQuery(document).ready(function() { jQuery(\'#togglemassfilesarea\').click(function() { if (jQuery(\'#togglemassfilesarea\').attr(\'ref\') == "shown") @@ -407,63 +407,63 @@ class FormFile </script>'; } - $titletoshow=$langs->trans("Documents"); - if (! empty($title)) $titletoshow=$title; + $titletoshow = $langs->trans("Documents"); + if (!empty($title)) $titletoshow = $title; // Show table if ($genallowed) { - $modellist=array(); + $modellist = array(); if ($modulepart == 'company') { - $showempty=1; - if (is_array($genallowed)) $modellist=$genallowed; + $showempty = 1; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/societe/modules_societe.class.php'; - $modellist=ModeleThirdPartyDoc::liste_modeles($this->db); + $modellist = ModeleThirdPartyDoc::liste_modeles($this->db); } } elseif ($modulepart == 'propal') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; - $modellist=ModelePDFPropales::liste_modeles($this->db); + $modellist = ModelePDFPropales::liste_modeles($this->db); } } elseif ($modulepart == 'supplier_proposal') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php'; - $modellist=ModelePDFSupplierProposal::liste_modeles($this->db); + $modellist = ModelePDFSupplierProposal::liste_modeles($this->db); } } elseif ($modulepart == 'commande') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; - $modellist=ModelePDFCommandes::liste_modeles($this->db); + $modellist = ModelePDFCommandes::liste_modeles($this->db); } } elseif ($modulepart == 'expedition') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; - $modellist=ModelePDFExpedition::liste_modeles($this->db); + $modellist = ModelePDFExpedition::liste_modeles($this->db); } } elseif ($modulepart == 'reception') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; @@ -472,195 +472,195 @@ class FormFile } elseif ($modulepart == 'livraison') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php'; - $modellist=ModelePDFDeliveryOrder::liste_modeles($this->db); + $modellist = ModelePDFDeliveryOrder::liste_modeles($this->db); } } elseif ($modulepart == 'ficheinter') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php'; - $modellist=ModelePDFFicheinter::liste_modeles($this->db); + $modellist = ModelePDFFicheinter::liste_modeles($this->db); } } elseif ($modulepart == 'facture') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $modellist=ModelePDFFactures::liste_modeles($this->db); + $modellist = ModelePDFFactures::liste_modeles($this->db); } } elseif ($modulepart == 'contract') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; - $modellist=ModelePDFContract::liste_modeles($this->db); + $modellist = ModelePDFContract::liste_modeles($this->db); } } elseif ($modulepart == 'project') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; - $modellist=ModelePDFProjects::liste_modeles($this->db); + $modellist = ModelePDFProjects::liste_modeles($this->db); } } elseif ($modulepart == 'project_task') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; - $modellist=ModelePDFTask::liste_modeles($this->db); + $modellist = ModelePDFTask::liste_modeles($this->db); } } elseif ($modulepart == 'product') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.class.php'; - $modellist=ModelePDFProduct::liste_modeles($this->db); + $modellist = ModelePDFProduct::liste_modeles($this->db); } } elseif ($modulepart == 'product_batch') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php'; - $modellist=ModelePDFProductBatch::liste_modeles($this->db); + $modellist = ModelePDFProductBatch::liste_modeles($this->db); } } elseif ($modulepart == 'stock') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.php'; - $modellist=ModelePDFStock::liste_modeles($this->db); + $modellist = ModelePDFStock::liste_modeles($this->db); } } elseif ($modulepart == 'movement') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_movement.php'; - $modellist=ModelePDFMovement::liste_modeles($this->db); + $modellist = ModelePDFMovement::liste_modeles($this->db); } } elseif ($modulepart == 'export') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; - $modellist=ModeleExports::liste_modeles($this->db); + $modellist = ModeleExports::liste_modeles($this->db); } } elseif ($modulepart == 'commande_fournisseur' || $modulepart == 'supplier_order') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php'; - $modellist=ModelePDFSuppliersOrders::liste_modeles($this->db); + $modellist = ModelePDFSuppliersOrders::liste_modeles($this->db); } } elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; - $modellist=ModelePDFSuppliersInvoices::liste_modeles($this->db); + $modellist = ModelePDFSuppliersInvoices::liste_modeles($this->db); } } elseif ($modulepart == 'supplier_payment') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php'; - $modellist=ModelePDFSuppliersPayments::liste_modeles($this->db); + $modellist = ModelePDFSuppliersPayments::liste_modeles($this->db); } } elseif ($modulepart == 'remisecheque') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/cheque/modules_chequereceipts.php'; - $modellist=ModeleChequeReceipts::liste_modeles($this->db); + $modellist = ModeleChequeReceipts::liste_modeles($this->db); } } elseif ($modulepart == 'donation') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php'; - $modellist=ModeleDon::liste_modeles($this->db); + $modellist = ModeleDon::liste_modeles($this->db); } } elseif ($modulepart == 'member') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php'; - $modellist=ModelePDFCards::liste_modeles($this->db); + $modellist = ModelePDFCards::liste_modeles($this->db); } } elseif ($modulepart == 'agenda' || $modulepart == 'actions') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/action/modules_action.php'; - $modellist=ModeleAction::liste_modeles($this->db); + $modellist = ModeleAction::liste_modeles($this->db); } } elseif ($modulepart == 'expensereport') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; - $modellist=ModeleExpenseReport::liste_modeles($this->db); + $modellist = ModeleExpenseReport::liste_modeles($this->db); } } elseif ($modulepart == 'unpaid') { - $modellist=''; + $modellist = ''; } elseif ($modulepart == 'user') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/user/modules_user.class.php'; - $modellist=ModelePDFUser::liste_modeles($this->db); + $modellist = ModelePDFUser::liste_modeles($this->db); } } elseif ($modulepart == 'usergroup') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/usergroup/modules_usergroup.class.php'; - $modellist=ModelePDFUserGroup::liste_modeles($this->db); + $modellist = ModelePDFUserGroup::liste_modeles($this->db); } } else @@ -668,29 +668,29 @@ class FormFile $submodulepart = $modulepart; // modulepart = 'nameofmodule' or 'nameofmodule:nameofsubmodule' - $tmp=explode(':', $modulepart); - if (! empty($tmp[1])) { - $modulepart=$tmp[0]; - $submodulepart=$tmp[1]; + $tmp = explode(':', $modulepart); + if (!empty($tmp[1])) { + $modulepart = $tmp[0]; + $submodulepart = $tmp[1]; } // For normalized standard modules - $file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$submodulepart.'.php', 0); + $file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$submodulepart.'.php', 0); if (file_exists($file)) { - $res=include_once $file; + $res = include_once $file; } // For normalized external modules. else { - $file=dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$submodulepart.'.php', 0); - $res=include_once $file; + $file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$submodulepart.'.php', 0); + $res = include_once $file; } - $class='ModelePDF'.ucfirst($submodulepart); + $class = 'ModelePDF'.ucfirst($submodulepart); if (class_exists($class)) { - $modellist=call_user_func($class.'::liste_modeles', $this->db); + $modellist = call_user_func($class.'::liste_modeles', $this->db); } else { @@ -700,80 +700,80 @@ class FormFile } // Set headershown to avoid to have table opened a second time later - $headershown=1; + $headershown = 1; - if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate'); + if (empty($buttonlabel)) $buttonlabel = $langs->trans('Generate'); - if ($conf->browser->layout == 'phone') $urlsource.='#'.$forname.'_form'; // So we switch to form after a generation - if (empty($noform)) $out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" id="'.$forname.'_form" method="post">'; - $out.= '<input type="hidden" name="action" value="builddoc">'; - $out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + if ($conf->browser->layout == 'phone') $urlsource .= '#'.$forname.'_form'; // So we switch to form after a generation + if (empty($noform)) $out .= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc').'" id="'.$forname.'_form" method="post">'; + $out .= '<input type="hidden" name="action" value="builddoc">'; + $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - $out.= load_fiche_titre($titletoshow, '', ''); - $out.= '<div class="div-table-responsive-no-min">'; - $out.= '<table class="liste formdoc noborder centpercent">'; + $out .= load_fiche_titre($titletoshow, '', ''); + $out .= '<div class="div-table-responsive-no-min">'; + $out .= '<table class="liste formdoc noborder centpercent">'; - $out.= '<tr class="liste_titre">'; + $out .= '<tr class="liste_titre">'; - $addcolumforpicto=($delallowed || $printer || $morepicto); - $colspan = (3+($addcolumforpicto?1:0)); $colspanmore = 0; + $addcolumforpicto = ($delallowed || $printer || $morepicto); + $colspan = (3 + ($addcolumforpicto ? 1 : 0)); $colspanmore = 0; - $out.= '<th colspan="'.$colspan.'" class="formdoc liste_titre maxwidthonsmartphone center">'; + $out .= '<th colspan="'.$colspan.'" class="formdoc liste_titre maxwidthonsmartphone center">'; // Model - if (! empty($modellist)) + if (!empty($modellist)) { asort($modellist); - $out.= '<span class="hideonsmartphone">'.$langs->trans('Model').' </span>'; + $out .= '<span class="hideonsmartphone">'.$langs->trans('Model').' </span>'; if (is_array($modellist) && count($modellist) == 1) // If there is only one element { - $arraykeys=array_keys($modellist); - $modelselected=$arraykeys[0]; + $arraykeys = array_keys($modellist); + $modelselected = $arraykeys[0]; } - $out.= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); if ($conf->use_javascript_ajax) { - $out.= ajax_combobox('model'); + $out .= ajax_combobox('model'); } } else { - $out.= '<div class="float">'.$langs->trans("Files").'</div>'; + $out .= '<div class="float">'.$langs->trans("Files").'</div>'; } // Language code (if multilang) - if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) && $conf->global->MAIN_MULTILANGS && ! $forcenomultilang && (! empty($modellist) || $showempty)) + if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) && $conf->global->MAIN_MULTILANGS && !$forcenomultilang && (!empty($modellist) || $showempty)) { include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin=new FormAdmin($this->db); - $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); - $morecss='maxwidth150'; - if ($conf->browser->layout == 'phone') $morecss='maxwidth100'; - $out.= $formadmin->select_language($defaultlang, 'lang_id', 0, 0, 0, 0, 0, $morecss); + $formadmin = new FormAdmin($this->db); + $defaultlang = $codelang ? $codelang : $langs->getDefaultLang(); + $morecss = 'maxwidth150'; + if ($conf->browser->layout == 'phone') $morecss = 'maxwidth100'; + $out .= $formadmin->select_language($defaultlang, 'lang_id', 0, 0, 0, 0, 0, $morecss); } else { - $out.= ' '; + $out .= ' '; } // Button $genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"'; - $genbutton.= ' type="submit" value="'.$buttonlabel.'"'; - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled'; - $genbutton.= '>'; - if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') + $genbutton .= ' type="submit" value="'.$buttonlabel.'"'; + if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) $genbutton .= ' disabled'; + $genbutton .= '>'; + if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') { $langs->load("errors"); - $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); + $genbutton .= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); } - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; - if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; - $out.= $genbutton; - $out.= '</th>'; + if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton = ''; + if (empty($modellist) && !$showempty && $modulepart != 'unpaid') $genbutton = ''; + $out .= $genbutton; + $out .= '</th>'; if (!empty($hookmanager->hooks['formfile'])) { - foreach($hookmanager->hooks['formfile'] as $module) + foreach ($hookmanager->hooks['formfile'] as $module) { if (method_exists($module, 'formBuilddocLineOptions')) { @@ -782,116 +782,116 @@ class FormFile } } } - $out.= '</tr>'; + $out .= '</tr>'; // Execute hooks - $parameters=array('colspan'=>($colspan+$colspanmore), 'socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''), 'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'modulepart'=>$modulepart); + $parameters = array('colspan'=>($colspan + $colspanmore), 'socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'modulepart'=>$modulepart); if (is_object($hookmanager)) { $reshook = $hookmanager->executeHooks('formBuilddocOptions', $parameters, $GLOBALS['object']); - $out.= $hookmanager->resPrint; + $out .= $hookmanager->resPrint; } } // Get list of files - if (! empty($filedir)) + if (!empty($filedir)) { $link_list = array(); if (is_object($object)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $link = new Link($this->db); $sortfield = $sortorder = null; $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); } - $out.= '<!-- html.formfile::showdocuments -->'."\n"; + $out .= '<!-- html.formfile::showdocuments -->'."\n"; // Show title of array if not already shown - if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) - && ! $headershown) + if ((!empty($file_list) || !empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) + && !$headershown) { - $headershown=1; - $out.= '<div class="titre">'.$titletoshow.'</div>'."\n"; - $out.= '<div class="div-table-responsive-no-min">'; - $out.= '<table class="noborder centpercent" id="'.$modulepart.'_table">'."\n"; + $headershown = 1; + $out .= '<div class="titre">'.$titletoshow.'</div>'."\n"; + $out .= '<div class="div-table-responsive-no-min">'; + $out .= '<table class="noborder centpercent" id="'.$modulepart.'_table">'."\n"; } // Loop on each file found if (is_array($file_list)) { - foreach($file_list as $file) + foreach ($file_list as $file) { // Define relative path for download link (depends on module) - $relativepath=$file["name"]; // Cas general - if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture... - if ($modulepart == 'export') $relativepath = $file["name"]; // Other case + $relativepath = $file["name"]; // Cas general + if ($modulesubdir) $relativepath = $modulesubdir."/".$file["name"]; // Cas propal, facture... + if ($modulepart == 'export') $relativepath = $file["name"]; // Other case - $out.= '<tr class="oddeven">'; + $out .= '<tr class="oddeven">'; $documenturl = DOL_URL_ROOT.'/document.php'; - if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper + if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper // Show file name with link to download - $out.= '<td class="minwidth200">'; - $out.= '<a class="documentdownload paddingright" href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param?'&'.$param:'').'"'; + $out .= '<td class="minwidth200">'; + $out .= '<a class="documentdownload paddingright" href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param ? '&'.$param : '').'"'; - $mime=dol_mimetype($relativepath, '', 0); - if (preg_match('/text/', $mime)) $out.= ' target="_blank"'; - $out.= '>'; - $out.= img_mime($file["name"], $langs->trans("File").': '.$file["name"]); - $out.= dol_trunc($file["name"], 150); - $out.= '</a>'."\n"; - $out.= $this->showPreview($file, $modulepart, $relativepath, 0, $param); - $out.= '</td>'; + $mime = dol_mimetype($relativepath, '', 0); + if (preg_match('/text/', $mime)) $out .= ' target="_blank"'; + $out .= '>'; + $out .= img_mime($file["name"], $langs->trans("File").': '.$file["name"]); + $out .= dol_trunc($file["name"], 150); + $out .= '</a>'."\n"; + $out .= $this->showPreview($file, $modulepart, $relativepath, 0, $param); + $out .= '</td>'; // Show file size - $size=(! empty($file['size'])?$file['size']:dol_filesize($filedir."/".$file["name"])); - $out.= '<td class="nowrap right">'.dol_print_size($size, 1, 1).'</td>'; + $size = (!empty($file['size']) ? $file['size'] : dol_filesize($filedir."/".$file["name"])); + $out .= '<td class="nowrap right">'.dol_print_size($size, 1, 1).'</td>'; // Show file date - $date=(! empty($file['date'])?$file['date']:dol_filemtime($filedir."/".$file["name"])); - $out.= '<td class="nowrap right">'.dol_print_date($date, 'dayhour', 'tzuser').'</td>'; + $date = (!empty($file['date']) ? $file['date'] : dol_filemtime($filedir."/".$file["name"])); + $out .= '<td class="nowrap right">'.dol_print_date($date, 'dayhour', 'tzuser').'</td>'; if ($delallowed || $printer || $morepicto) { - $out.= '<td class="right nowraponall">'; + $out .= '<td class="right nowraponall">'; if ($delallowed) { $tmpurlsource = preg_replace('/#[a-zA-Z0-9_]*$/', '', $urlsource); - $out.= '<a href="'.$tmpurlsource.(strpos($tmpurlsource, '?')?'&':'?').'action=remove_file&file='.urlencode($relativepath); - $out.= ($param?'&'.$param:''); + $out .= '<a href="'.$tmpurlsource.(strpos($tmpurlsource, '?') ? '&' : '?').'action=remove_file&file='.urlencode($relativepath); + $out .= ($param ? '&'.$param : ''); //$out.= '&modulepart='.$modulepart; // TODO obsolete ? //$out.= '&urlsource='.urlencode($urlsource); // TODO obsolete ? - $out.= '">'.img_picto($langs->trans("Delete"), 'delete').'</a>'; + $out .= '">'.img_picto($langs->trans("Delete"), 'delete').'</a>'; } if ($printer) { //$out.= '<td class="right">'; - $out.= '<a class="paddingleft" href="'.$urlsource.(strpos($urlsource, '?')?'&':'?').'action=print_file&printer='.$modulepart.'&file='.urlencode($relativepath); - $out.= ($param?'&'.$param:''); - $out.= '">'.img_picto($langs->trans("PrintFile", $relativepath), 'printer.png').'</a>'; + $out .= '<a class="paddingleft" href="'.$urlsource.(strpos($urlsource, '?') ? '&' : '?').'action=print_file&printer='.$modulepart.'&file='.urlencode($relativepath); + $out .= ($param ? '&'.$param : ''); + $out .= '">'.img_picto($langs->trans("PrintFile", $relativepath), 'printer.png').'</a>'; } if ($morepicto) { - $morepicto=preg_replace('/__FILENAMEURLENCODED__/', urlencode($relativepath), $morepicto); - $out.=$morepicto; + $morepicto = preg_replace('/__FILENAMEURLENCODED__/', urlencode($relativepath), $morepicto); + $out .= $morepicto; } - $out.='</td>'; + $out .= '</td>'; } if (is_object($hookmanager)) { - $parameters=array('colspan'=>($colspan+$colspanmore), 'socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''),'modulepart'=>$modulepart,'relativepath'=>$relativepath); + $parameters = array('colspan'=>($colspan + $colspanmore), 'socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'modulepart'=>$modulepart, 'relativepath'=>$relativepath); $res = $hookmanager->executeHooks('formBuilddocLineOptions', $parameters, $file); if (empty($res)) { - $out.= $hookmanager->resPrint; // Complete line - $out.= '</tr>'; + $out .= $hookmanager->resPrint; // Complete line + $out .= '</tr>'; } else { - $out = $hookmanager->resPrint; // Replace all $out + $out = $hookmanager->resPrint; // Replace all $out } } } @@ -901,42 +901,42 @@ class FormFile // Loop on each link found if (is_array($link_list)) { - $colspan=2; + $colspan = 2; - foreach($link_list as $file) + foreach ($link_list as $file) { - $out.='<tr class="oddeven">'; - $out.='<td colspan="'.$colspan.'" class="maxwidhtonsmartphone">'; - $out.='<a data-ajax="false" href="' . $file->url . '" target="_blank">'; - $out.=$file->label; - $out.='</a>'; - $out.='</td>'; - $out.='<td class="right">'; - $out.=dol_print_date($file->datea, 'dayhour'); - $out.='</td>'; - if ($delallowed || $printer || $morepicto) $out.='<td></td>'; - $out.='</tr>'."\n"; + $out .= '<tr class="oddeven">'; + $out .= '<td colspan="'.$colspan.'" class="maxwidhtonsmartphone">'; + $out .= '<a data-ajax="false" href="'.$file->url.'" target="_blank">'; + $out .= $file->label; + $out .= '</a>'; + $out .= '</td>'; + $out .= '<td class="right">'; + $out .= dol_print_date($file->datea, 'dayhour'); + $out .= '</td>'; + if ($delallowed || $printer || $morepicto) $out .= '<td></td>'; + $out .= '</tr>'."\n"; } $this->numoffiles++; } if (count($file_list) == 0 && count($link_list) == 0 && $headershown) { - $out.='<tr><td colspan="'.(3+($addcolumforpicto?1:0)).'" class="opacitymedium">'.$langs->trans("None").'</td></tr>'."\n"; + $out .= '<tr><td colspan="'.(3 + ($addcolumforpicto ? 1 : 0)).'" class="opacitymedium">'.$langs->trans("None").'</td></tr>'."\n"; } } if ($headershown) { // Affiche pied du tableau - $out.= "</table>\n"; - $out.= "</div>\n"; + $out .= "</table>\n"; + $out .= "</div>\n"; if ($genallowed) { - if (empty($noform)) $out.= '</form>'."\n"; + if (empty($noform)) $out .= '</form>'."\n"; } } - $out.= '<!-- End show_document -->'."\n"; + $out .= '<!-- End show_document -->'."\n"; //return ($i?$i:$headershown); return $out; } @@ -958,21 +958,21 @@ class FormFile include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $out=''; - $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); + $out = ''; + $this->infofiles = array('nboffiles'=>0, 'extensions'=>array(), 'files'=>array()); $entity = 1; // Without multicompany // Get object entity - if (! empty($conf->multicompany->enabled)) + if (!empty($conf->multicompany->enabled)) { preg_match('/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir, '/').'$/', $filedir, $regs); - $entity = ((! empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1); // If entity id not found in $filedir this is entity 1 by default + $entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1); // If entity id not found in $filedir this is entity 1 by default } // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files and get only generated files) // @TODO Why not showing by default all files by just removing the '[^\-]+' at end of regex ? - if (! empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) + if (!empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) { $filterforfilesearch = preg_quote(basename($modulesubdir), '/'); } @@ -980,70 +980,70 @@ class FormFile { $filterforfilesearch = preg_quote(basename($modulesubdir), '/').'[^\-]+'; } - $file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // We also discard .meta and .png preview + $file_list = dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // We also discard .meta and .png preview //var_dump($file_list); // For ajax treatment - $out.= '<!-- html.formfile::getDocumentsLink -->'."\n"; - if (! empty($file_list)) + $out .= '<!-- html.formfile::getDocumentsLink -->'."\n"; + if (!empty($file_list)) { - $out='<dl class="dropdown inline-block"> + $out = '<dl class="dropdown inline-block"> <dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto('', 'listlight', '', 0, 0, 0, '', 'valignmiddle').'</a></dt> <dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields" style="display: none;">'; - $tmpout=''; + $tmpout = ''; // Loop on each file found - $found=0; - foreach($file_list as $file) + $found = 0; + foreach ($file_list as $file) { $i++; - if ($filter && ! preg_match('/'.$filter.'/i', $file["name"])) continue; // Discard this. It does not match provided filter. + if ($filter && !preg_match('/'.$filter.'/i', $file["name"])) continue; // Discard this. It does not match provided filter. $found++; // Define relative path for download link (depends on module) - $relativepath=$file["name"]; // Cas general - if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture... + $relativepath = $file["name"]; // Cas general + if ($modulesubdir) $relativepath = $modulesubdir."/".$file["name"]; // Cas propal, facture... // Autre cas - if ($modulepart == 'donation') { + if ($modulepart == 'donation') { $relativepath = get_exdir($modulesubdir, 2, 0, 0, null, 'donation').$file["name"]; } - if ($modulepart == 'export') { + if ($modulepart == 'export') { $relativepath = $file["name"]; } $this->infofiles['nboffiles']++; - $this->infofiles['files'][]=$file['fullname']; - $ext=pathinfo($file["name"], PATHINFO_EXTENSION); - if (empty($this->infofiles[$ext])) $this->infofiles['extensions'][$ext]=1; + $this->infofiles['files'][] = $file['fullname']; + $ext = pathinfo($file["name"], PATHINFO_EXTENSION); + if (empty($this->infofiles[$ext])) $this->infofiles['extensions'][$ext] = 1; else $this->infofiles['extensions'][$ext]++; // Preview - if (! empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone')) + if (!empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone')) { $tmparray = getAdvancedPreviewUrl($modulepart, $relativepath, 1, '&entity='.$entity); if ($tmparray && $tmparray['url']) { - $tmpout.= '<li><a href="'.$tmparray['url'].'"'.($tmparray['css']?' class="'.$tmparray['css'].'"':'').($tmparray['mime']?' mime="'.$tmparray['mime'].'"':'').($tmparray['target']?' target="'.$tmparray['target'].'"':'').'>'; + $tmpout .= '<li><a href="'.$tmparray['url'].'"'.($tmparray['css'] ? ' class="'.$tmparray['css'].'"' : '').($tmparray['mime'] ? ' mime="'.$tmparray['mime'].'"' : '').($tmparray['target'] ? ' target="'.$tmparray['target'].'"' : '').'>'; //$tmpout.= img_picto('','detail'); - $tmpout.= '<i class="fa fa-search-plus paddingright" style="color: gray"></i>'; - $tmpout.= $langs->trans("Preview").' '.$ext.'</a></li>'; + $tmpout .= '<i class="fa fa-search-plus paddingright" style="color: gray"></i>'; + $tmpout .= $langs->trans("Preview").' '.$ext.'</a></li>'; } } // Download - $tmpout.= '<li class="nowrap"><a class="pictopreview nowrap" href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($relativepath).'"'; - $mime=dol_mimetype($relativepath, '', 0); - if (preg_match('/text/', $mime)) $tmpout.= ' target="_blank"'; - $tmpout.= '>'; - $tmpout.= img_mime($relativepath, $file["name"]); - $tmpout.= $langs->trans("Download").' '.$ext; - $tmpout.= '</a></li>'."\n"; + $tmpout .= '<li class="nowrap"><a class="pictopreview nowrap" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($relativepath).'"'; + $mime = dol_mimetype($relativepath, '', 0); + if (preg_match('/text/', $mime)) $tmpout .= ' target="_blank"'; + $tmpout .= '>'; + $tmpout .= img_mime($relativepath, $file["name"]); + $tmpout .= $langs->trans("Download").' '.$ext; + $tmpout .= '</a></li>'."\n"; } - $out.=$tmpout; - $out.='</ul></div></dd> + $out .= $tmpout; + $out .= '</ul></div></dd> </dl>'; - if (! $found) $out=''; + if (!$found) $out = ''; } else { @@ -1098,21 +1098,21 @@ class FormFile if ($disablecrop == -1) { - $disablecrop=1; - if (in_array($modulepart, array('bank','bom','expensereport','holiday','member','project','product','produit','service','societe','tax','ticket','user'))) $disablecrop=0; + $disablecrop = 1; + if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'member', 'project', 'product', 'produit', 'service', 'societe', 'tax', 'ticket', 'user'))) $disablecrop = 0; } // Define relative path used to store the file if (empty($relativepath)) { - $relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/'; - if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$relativepath; // TODO Call using a defined value for $relativepath - if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.'; + $relativepath = (!empty($object->ref) ?dol_sanitizeFileName($object->ref) : '').'/'; + if ($object->element == 'invoice_supplier') $relativepath = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$relativepath; // TODO Call using a defined value for $relativepath + if ($object->element == 'project_task') $relativepath = 'Call_not_supported_._Call_function_using_a_defined_relative_path_.'; } // For backward compatiblity, we detect file stored into an old path - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos') + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos') { - $relativepath=preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/'; + $relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/'; } // Defined relative dir to DOL_DATA_ROOT $relativedir = ''; @@ -1123,13 +1123,13 @@ class FormFile } $hookmanager->initHooks(array('formfile')); - $parameters=array( + $parameters = array( 'filearray' => $filearray, 'modulepart'=> $modulepart, 'param' => $param, 'forcedownload' => $forcedownload, - 'relativepath' => $relativepath, // relative filename to module dir - 'relativedir' => $relativedir, // relative dirname to DOL_DATA_ROOT + 'relativepath' => $relativepath, // relative filename to module dir + 'relativedir' => $relativedir, // relative dirname to DOL_DATA_ROOT 'permtodelete' => $permonobject, 'useinecm' => $useinecm, 'textifempty' => $textifempty, @@ -1137,7 +1137,7 @@ class FormFile 'title' => $title, 'url' => $url ); - $reshook=$hookmanager->executeHooks('showFilesList', $parameters, $object); + $reshook = $hookmanager->executeHooks('showFilesList', $parameters, $object); if (isset($reshook) && $reshook != '') // null or '' for bypass { @@ -1145,34 +1145,34 @@ class FormFile } else { - if (! is_object($form)) + if (!is_object($form)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; // The compoent may be included into ajax page that does not include the Form class - $form=new Form($this->db); + include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; // The compoent may be included into ajax page that does not include the Form class + $form = new Form($this->db); } - if (! preg_match('/&id=/', $param) && isset($object->id)) $param.='&id='.$object->id; - $relativepathwihtoutslashend=preg_replace('/\/$/', '', $relativepath); - if ($relativepathwihtoutslashend) $param.= '&file='.urlencode($relativepathwihtoutslashend); + if (!preg_match('/&id=/', $param) && isset($object->id)) $param .= '&id='.$object->id; + $relativepathwihtoutslashend = preg_replace('/\/$/', '', $relativepath); + if ($relativepathwihtoutslashend) $param .= '&file='.urlencode($relativepathwihtoutslashend); if ($permtoeditline < 0) // Old behaviour for backward compatibility. New feature should call method with value 0 or 1 { - $permtoeditline=0; - if (in_array($modulepart, array('product','produit','service'))) + $permtoeditline = 0; + if (in_array($modulepart, array('product', 'produit', 'service'))) { - if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoeditline=1; - if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline=1; + if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoeditline = 1; + if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline = 1; } } if (empty($conf->global->MAIN_UPLOAD_DOC)) { - $permtoeditline=0; - $permonobject=0; + $permtoeditline = 0; + $permonobject = 0; } // Show list of existing files - if ((empty($useinecm) || $useinecm == 6) && $title != 'none') print load_fiche_titre($title?$title:$langs->trans("AttachedFiles")); - if (empty($url)) $url=$_SERVER["PHP_SELF"]; + if ((empty($useinecm) || $useinecm == 6) && $title != 'none') print load_fiche_titre($title ? $title : $langs->trans("AttachedFiles")); + if (empty($url)) $url = $_SERVER["PHP_SELF"]; print '<!-- html.formfile::list_of_documents -->'."\n"; if (GETPOST('action', 'aZ09') == 'editfile' && $permtoeditline) @@ -1187,7 +1187,7 @@ class FormFile print '<div class="div-table-responsive-no-min">'; print '<table width="100%" id="tablelines" class="liste noborder nobottom">'."\n"; - if (! empty($addfilterfields)) + if (!empty($addfilterfields)) { print '<tr class="liste_titre nodrag nodrop">'; print '<td><input type="search_doc_ref" value="'.dol_escape_htmltag(GETPOST('search_doc_ref', 'alpha')).'"></td>'; @@ -1196,7 +1196,7 @@ class FormFile if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) print '<td></td>'; print '<td></td>'; print '<td></td>'; - if (! $disablemove) print '<td></td>'; + if (!$disablemove) print '<td></td>'; print "</tr>\n"; } @@ -1205,10 +1205,10 @@ class FormFile print_liste_field_titre('Documents2', $url, "name", "", $param, '', $sortfield, $sortorder, 'left '); print_liste_field_titre('Size', $url, "size", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre('Date', $url, "date", "", $param, '', $sortfield, $sortorder, 'center '); - if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) print_liste_field_titre('', $url, "", "", $param, '', $sortfield, $sortorder, 'center '); // Preview + if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) print_liste_field_titre('', $url, "", "", $param, '', $sortfield, $sortorder, 'center '); // Preview print_liste_field_titre(''); print_liste_field_titre(''); - if (! $disablemove) print_liste_field_titre(''); + if (!$disablemove) print_liste_field_titre(''); print "</tr>\n"; // Get list of files stored into database for same relative directory @@ -1219,29 +1219,29 @@ class FormFile //var_dump($sortfield.' - '.$sortorder); if ($sortfield && $sortorder) // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name) { - $filearray=dol_sort_array($filearray, $sortfield, $sortorder); + $filearray = dol_sort_array($filearray, $sortfield, $sortorder); } } - $nboffiles=count($filearray); + $nboffiles = count($filearray); if ($nboffiles > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $i=0; $nboflines = 0; $lastrowid=0; - foreach($filearray as $key => $file) // filearray must be only files here + $i = 0; $nboflines = 0; $lastrowid = 0; + foreach ($filearray as $key => $file) // filearray must be only files here { if ($file['name'] != '.' && $file['name'] != '..' - && ! preg_match('/\.meta$/i', $file['name'])) + && !preg_match('/\.meta$/i', $file['name'])) { if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid']; - $filepath=$relativepath.$file['name']; + $filepath = $relativepath.$file['name']; - $editline=0; + $editline = 0; $nboflines++; print '<!-- Line list_of_documents '.$key.' relativepath = '.$relativepath.' -->'."\n"; // Do we have entry into database ? print '<!-- In database: position='.$filearray[$key]['position'].' -->'."\n"; - print '<tr class="oddeven" id="row-'.($filearray[$key]['rowid']>0?$filearray[$key]['rowid']:'AFTER'.$lastrowid.'POS'.($i+1)).'">'; + print '<tr class="oddeven" id="row-'.($filearray[$key]['rowid'] > 0 ? $filearray[$key]['rowid'] : 'AFTER'.$lastrowid.'POS'.($i + 1)).'">'; // File name print '<td class="minwith200">'; @@ -1250,7 +1250,7 @@ class FormFile //print "XX".$file['name']; //$file['name'] must be utf8 print '<a class="paddingright" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart; if ($forcedownload) print '&attachment=1'; - if (! empty($object->entity)) print '&entity='.$object->entity; + if (!empty($object->entity)) print '&entity='.$object->entity; print '&file='.urlencode($filepath); print '">'; print img_mime($file['name'], $file['name'].' ('.dol_print_size($file['size'], 0, 0).')', 'inline-block valignbottom paddingright'); @@ -1259,11 +1259,11 @@ class FormFile if (GETPOST('action', 'aZ09') == 'editfile' && $file['name'] == basename(GETPOST('urlfile', 'alpha'))) { print '</a>'; - $section_dir=dirname(GETPOST('urlfile', 'alpha')); + $section_dir = dirname(GETPOST('urlfile', 'alpha')); print '<input type="hidden" name="section_dir" value="'.$section_dir.'">'; print '<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file['name']).'">'; print '<input type="text" name="renamefileto" class="quatrevingtpercent" value="'.dol_escape_htmltag($file['name']).'">'; - $editline=1; + $editline = 1; } else { @@ -1271,7 +1271,7 @@ class FormFile print '</a>'; } // Preview link - if (! $editline) print $this->showPreview($file, $modulepart, $filepath, 0, '&entity='.(! empty($object->entity)?$object->entity:$conf->entity)); + if (!$editline) print $this->showPreview($file, $modulepart, $filepath, 0, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); print "</td>\n"; @@ -1287,10 +1287,10 @@ class FormFile print '</td>'; // Date - print '<td class="center" style="width: 140px">'.dol_print_date($file['date'], "dayhour", "tzuser").'</td>'; // 140px = width for date with PM format + print '<td class="center" style="width: 140px">'.dol_print_date($file['date'], "dayhour", "tzuser").'</td>'; // 140px = width for date with PM format // Preview - if (empty($useinecm) || $useinecm == 4 || $useinecm == 5|| $useinecm == 6) + if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) { $fileinfo = pathinfo($file['name']); print '<td class="center">'; @@ -1298,23 +1298,23 @@ class FormFile { if ($useinecm == 5 || $useinecm == 6) { - $smallfile=getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image + $smallfile = getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image } else { - $smallfile=getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original + $smallfile = getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original } - if (! dol_is_file($file['path'].'/'.$smallfile)) $smallfile=getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension + if (!dol_is_file($file['path'].'/'.$smallfile)) $smallfile = getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension //print $file['path'].'/'.$smallfile.'<br>'; - $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); + $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); if (empty($urlforhref)) { - $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); + $urlforhref = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); print '<a href="'.$urlforhref.'" class="aphoto" target="_blank">'; } else { print '<a href="'.$urlforhref['url'].'" class="'.$urlforhref['css'].'" target="'.$urlforhref['target'].'" mime="'.$urlforhref['mime'].'">'; } - print '<img class="photo" height="'.(($useinecm == 4 || $useinecm == 5 || $useinecm == 6)? '12' : $maxheightmini).'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$smallfile).'" title="">'; + print '<img class="photo" height="'.(($useinecm == 4 || $useinecm == 5 || $useinecm == 6) ? '12' : $maxheightmini).'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$smallfile).'" title="">'; print '</a>'; } else print ' '; @@ -1328,24 +1328,24 @@ class FormFile if ($editline) { print $langs->trans("FileSharedViaALink").' '; - print '<input class="inline-block" type="checkbox" name="shareenabled"'.($file['share']?' checked="checked"':'').' /> '; + print '<input class="inline-block" type="checkbox" name="shareenabled"'.($file['share'] ? ' checked="checked"' : '').' /> '; } else { if ($file['share']) { // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current //print '<span class="opacitymedium">'.$langs->trans("Hash").' : '.$file['share'].'</span>'; - $forcedownload=0; - $paramlink=''; - if (! empty($file['share'])) $paramlink.=($paramlink?'&':'').'hashp='.$file['share']; // Hash for public share - if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1'; + $forcedownload = 0; + $paramlink = ''; + if (!empty($file['share'])) $paramlink .= ($paramlink ? '&' : '').'hashp='.$file['share']; // Hash for public share + if ($forcedownload) $paramlink .= ($paramlink ? '&' : '').'attachment=1'; - $fulllink=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:''); + $fulllink = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : ''); print img_picto($langs->trans("FileSharedViaALink"), 'globe').' '; print '<input type="text" class="quatrevingtpercent minwidth200imp" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).'">'; @@ -1359,7 +1359,7 @@ class FormFile print '</td>'; // Actions buttons - if (! $editline) + if (!$editline) { // Delete or view link // ($param must start with &) @@ -1370,10 +1370,10 @@ class FormFile } if (empty($useinecm) || $useinecm == 2 || $useinecm == 6) { - $newmodulepart=$modulepart; - if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; + $newmodulepart = $modulepart; + if (in_array($modulepart, array('product', 'produit', 'service'))) $newmodulepart = 'produit|service'; - if (! $disablecrop && image_format_supported($file['name']) > 0) + if (!$disablecrop && image_format_supported($file['name']) > 0) { if ($permtoeditline) { @@ -1384,17 +1384,17 @@ class FormFile if ($permtoeditline) { - $paramsectiondir=(in_array($modulepart, array('medias','ecm'))?'§ion_dir='.urlencode($relativepath):''); - print '<a href="'.(($useinecm == 1 || $useinecm == 5)?'#':($url.'?action=editfile&urlfile='.urlencode($filepath).$paramsectiondir.$param)).'" class="editfilelink" rel="'.$filepath.'">'.img_edit('default', 0, 'class="paddingrightonly"').'</a>'; + $paramsectiondir = (in_array($modulepart, array('medias', 'ecm')) ? '§ion_dir='.urlencode($relativepath) : ''); + print '<a href="'.(($useinecm == 1 || $useinecm == 5) ? '#' : ($url.'?action=editfile&urlfile='.urlencode($filepath).$paramsectiondir.$param)).'" class="editfilelink" rel="'.$filepath.'">'.img_edit('default', 0, 'class="paddingrightonly"').'</a>'; } } if ($permonobject) { - $useajax=1; - if (! empty($conf->dol_use_jmobile)) $useajax=0; - if (empty($conf->use_javascript_ajax)) $useajax=0; - if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; - print '<a href="'.((($useinecm && $useinecm != 6) && $useajax)?'#':($url.'?action=delete&urlfile='.urlencode($filepath).$param)).'" class="reposition deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>'; + $useajax = 1; + if (!empty($conf->dol_use_jmobile)) $useajax = 0; + if (empty($conf->use_javascript_ajax)) $useajax = 0; + if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax = 0; + print '<a href="'.((($useinecm && $useinecm != 6) && $useajax) ? '#' : ($url.'?action=delete&urlfile='.urlencode($filepath).$param)).'" class="reposition deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>'; } print "</td>"; @@ -1405,13 +1405,13 @@ class FormFile if ($i > 0) { print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&rowid='.$line->id.'">'.img_up('default', 0, 'imgupforline').'</a>'; } - if ($i < $nboffiles-1) { + if ($i < $nboffiles - 1) { print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&rowid='.$line->id.'">'.img_down('default', 0, 'imgdownforline').'</a>'; } print '</td>'; } else { - print '<td'.(($conf->browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown center"':' class="linecolmove center"').'>'; + print '<td'.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>'; print '</td>'; } } @@ -1432,8 +1432,8 @@ class FormFile } if ($nboffiles == 0) { - $colspan='6'; - if (empty($disablemove)) $colspan++; // 6 columns or 7 + $colspan = '6'; + if (empty($disablemove)) $colspan++; // 6 columns or 7 print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">'; if (empty($textifempty)) print $langs->trans("NoFileFound"); else print $textifempty; @@ -1443,9 +1443,9 @@ class FormFile print '</div>'; if ($nboflines > 1 && is_object($object)) { - if (! empty($conf->use_javascript_ajax) && $permtoeditline) { + if (!empty($conf->use_javascript_ajax) && $permtoeditline) { $table_element_line = 'ecm_files'; - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } } @@ -1491,9 +1491,9 @@ class FormFile // Show list of documents if (empty($useinecm) || $useinecm == 6) print load_fiche_titre($langs->trans("AttachedFiles")); - if (empty($url)) $url=$_SERVER["PHP_SELF"]; + if (empty($url)) $url = $_SERVER["PHP_SELF"]; - if (! empty($addfilterfields)) + if (!empty($addfilterfields)) { print '<form action="'.$_SERVER['PHP_SELF'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; @@ -1503,7 +1503,7 @@ class FormFile print '<div class="div-table-responsive-no-min">'; print '<table width="100%" class="noborder">'."\n"; - if (! empty($addfilterfields)) + if (!empty($addfilterfields)) { print '<tr class="liste_titre nodrag nodrop">'; print '<td></td>'; @@ -1512,15 +1512,15 @@ class FormFile print '<td></td>'; // Action column print '<td class="liste_titre center">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; } print '<tr class="liste_titre">'; - $sortref="fullname"; - if ($modulepart == 'invoice_supplier') $sortref='level1name'; + $sortref = "fullname"; + if ($modulepart == 'invoice_supplier') $sortref = 'level1name'; print_liste_field_titre("Ref", $url, $sortref, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Documents2", $url, "name", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Size", $url, "size", "", $param, '', $sortfield, $sortorder, 'right '); @@ -1532,115 +1532,115 @@ class FormFile if ($modulepart == 'company') { include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $object_instance=new Societe($this->db); + $object_instance = new Societe($this->db); } elseif ($modulepart == 'invoice') { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $object_instance=new Facture($this->db); + $object_instance = new Facture($this->db); } elseif ($modulepart == 'invoice_supplier') { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $object_instance=new FactureFournisseur($this->db); + $object_instance = new FactureFournisseur($this->db); } elseif ($modulepart == 'propal') { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $object_instance=new Propal($this->db); + $object_instance = new Propal($this->db); } elseif ($modulepart == 'supplier_proposal') { include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; - $object_instance=new SupplierProposal($this->db); + $object_instance = new SupplierProposal($this->db); } elseif ($modulepart == 'order') { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $object_instance=new Commande($this->db); + $object_instance = new Commande($this->db); } elseif ($modulepart == 'order_supplier') { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $object_instance=new CommandeFournisseur($this->db); + $object_instance = new CommandeFournisseur($this->db); } elseif ($modulepart == 'contract') { include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $object_instance=new Contrat($this->db); + $object_instance = new Contrat($this->db); } elseif ($modulepart == 'product') { include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $object_instance=new Product($this->db); + $object_instance = new Product($this->db); } elseif ($modulepart == 'tax') { include_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; - $object_instance=new ChargeSociales($this->db); + $object_instance = new ChargeSociales($this->db); } elseif ($modulepart == 'project') { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $object_instance=new Project($this->db); + $object_instance = new Project($this->db); } elseif ($modulepart == 'fichinter') { include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; - $object_instance=new Fichinter($this->db); + $object_instance = new Fichinter($this->db); } elseif ($modulepart == 'user') { include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $object_instance=new User($this->db); + $object_instance = new User($this->db); } elseif ($modulepart == 'expensereport') { include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - $object_instance=new ExpenseReport($this->db); + $object_instance = new ExpenseReport($this->db); } elseif ($modulepart == 'holiday') { include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; - $object_instance=new Holiday($this->db); + $object_instance = new Holiday($this->db); } elseif ($modulepart == 'banque') { include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $object_instance=new Account($this->db); + $object_instance = new Account($this->db); } - foreach($filearray as $key => $file) + foreach ($filearray as $key => $file) { if (!is_dir($file['name']) && $file['name'] != '.' && $file['name'] != '..' && $file['name'] != 'CVS' - && ! preg_match('/\.meta$/i', $file['name'])) + && !preg_match('/\.meta$/i', $file['name'])) { // Define relative path used to store the file - $relativefile=preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']); + $relativefile = preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']); - $id=0; $ref=''; $label=''; + $id = 0; $ref = ''; $label = ''; // To show ref or specific information according to view to show (defined by $module) - if ($modulepart == 'company' || $modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } - elseif ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices - elseif ($modulepart == 'user' || $modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } + if ($modulepart == 'company' || $modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); } + elseif ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); if (is_numeric($ref)) { $id = $ref; $ref = ''; } } // $ref may be also id with old supplier invoices + elseif ($modulepart == 'user' || $modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); } elseif (in_array($modulepart, array('invoice', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'project', 'fichinter', 'expensereport', 'banque'))) { - preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); + preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } else { //print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n"; } - if (! $id && ! $ref) continue; - $found=0; - if (! empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) + if (!$id && !$ref) continue; + $found = 0; + if (!empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) { - $found=1; + $found = 1; } else { @@ -1659,24 +1659,24 @@ class FormFile } if ($result > 0) { // Save object loaded into a cache - $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; + $found = 1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; } - if ($result == 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]='notfound'; unset($filearray[$key]); } + if ($result == 0) { $found = 1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = 'notfound'; unset($filearray[$key]); } } - if (! $found > 0 || ! is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) continue; // We do not show orphelins files + if (!$found > 0 || !is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) continue; // We do not show orphelins files print '<!-- Line list_of_autoecmfiles '.$key.' -->'."\n"; print '<tr class="oddeven">'; print '<td>'; if ($found > 0 && is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) print $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]->getNomUrl(1, 'document'); - else print $langs->trans("ObjectDeleted", ($id?$id:$ref)); + else print $langs->trans("ObjectDeleted", ($id ? $id : $ref)); //$modulesubdir=dol_sanitizeFileName($ref); - $modulesubdir=dirname($relativefile); + $modulesubdir = dirname($relativefile); //$filedir=$conf->$modulepart->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $filedir=$file['path']; + $filedir = $file['path']; //$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; //print $formfile->getDocumentsLink($modulepart, $filename, $filedir); @@ -1719,7 +1719,7 @@ class FormFile print "</table>"; print '</div>'; - if (! empty($addfilterfields)) print '</form>'; + if (!empty($addfilterfields)) print '</form>'; // Fin de zone } @@ -1745,7 +1745,7 @@ class FormFile $mul_upload_max_filesize = ($mul_upload_max_filesize == 'M' ? 1048576 : ($mul_upload_max_filesize == 'K' ? 1024 : ($mul_upload_max_filesize == 'G' ? 1073741824 : 1))); $upload_max_filesize = $mul_upload_max_filesize * (int) $upload_max_filesize; // Max file size - $max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize); + $max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize); // Include main include DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_main.tpl.php'; @@ -1771,7 +1771,7 @@ class FormFile $langs->load("link"); - require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $link = new Link($this->db); $links = array(); if ($sortfield == "name") { @@ -1782,14 +1782,14 @@ class FormFile $sortfield = null; } $res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder); - $param .= (isset($object->id)?'&id=' . $object->id : ''); + $param .= (isset($object->id) ? '&id='.$object->id : ''); print '<!-- listOfLinks -->'."\n"; // Show list of associated links print load_fiche_titre($langs->trans("LinkedFiles")); - print '<form action="' . $_SERVER['PHP_SELF'] . ($param?'?'.$param:'') . '" method="POST">'; + print '<form action="'.$_SERVER['PHP_SELF'].($param ? '?'.$param : '').'" method="POST">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<table width="100%" class="liste noborder nobottom">'; @@ -1850,36 +1850,36 @@ class FormFile if ($action == 'update' && $selected === $link->id) { print '<td>'; - print '<input type="hidden" name="id" value="' . $object->id . '">'; - print '<input type="hidden" name="linkid" value="' . $link->id . '">'; + print '<input type="hidden" name="id" value="'.$object->id.'">'; + print '<input type="hidden" name="linkid" value="'.$link->id.'">'; print '<input type="hidden" name="action" value="confirm_updateline">'; - print $langs->trans('Link') . ': <input type="text" name="link" value="' . $link->url . '">'; + print $langs->trans('Link').': <input type="text" name="link" value="'.$link->url.'">'; print '</td>'; print '<td>'; - print $langs->trans('Label') . ': <input type="text" name="label" value="' . dol_escape_htmltag($link->label) . '">'; + print $langs->trans('Label').': <input type="text" name="label" value="'.dol_escape_htmltag($link->label).'">'; print '</td>'; - print '<td class="center">' . dol_print_date(dol_now(), "dayhour", "tzuser") . '</td>'; + print '<td class="center">'.dol_print_date(dol_now(), "dayhour", "tzuser").'</td>'; print '<td class="right"></td>'; print '<td class="right">'; - print '<input type="submit" name="save" class="button" value="' . dol_escape_htmltag($langs->trans('Save')) . '">'; - print '<input type="submit" name="cancel" class="button" value="' . dol_escape_htmltag($langs->trans('Cancel')) . '">'; + print '<input type="submit" name="save" class="button" value="'.dol_escape_htmltag($langs->trans('Save')).'">'; + print '<input type="submit" name="cancel" class="button" value="'.dol_escape_htmltag($langs->trans('Cancel')).'">'; print '</td>'; } else { print '<td>'; print img_picto('', 'globe').' '; - print '<a data-ajax="false" href="' . $link->url . '" target="_blank">'; + print '<a data-ajax="false" href="'.$link->url.'" target="_blank">'; print dol_escape_htmltag($link->label); print '</a>'; print '</td>'."\n"; print '<td class="right"></td>'; - print '<td class="center">' . dol_print_date($link->datea, "dayhour", "tzuser") . '</td>'; + print '<td class="center">'.dol_print_date($link->datea, "dayhour", "tzuser").'</td>'; print '<td class="center"></td>'; print '<td class="right">'; - print '<a href="' . $_SERVER['PHP_SELF'] . '?action=update&linkid=' . $link->id . $param . '" class="editfilelink reposition" >' . img_edit() . '</a>'; // id= is included into $param + print '<a href="'.$_SERVER['PHP_SELF'].'?action=update&linkid='.$link->id.$param.'" class="editfilelink reposition" >'.img_edit().'</a>'; // id= is included into $param if ($permissiontodelete) { - print '   <a href="'. $_SERVER['PHP_SELF'] .'?action=delete&linkid=' . $link->id . $param . '" class="deletefilelink">' . img_delete() . '</a>'; // id= is included into $param + print '   <a href="'.$_SERVER['PHP_SELF'].'?action=delete&linkid='.$link->id.$param.'" class="deletefilelink">'.img_delete().'</a>'; // id= is included into $param } else { print ' '; } @@ -1915,21 +1915,21 @@ class FormFile { global $langs, $conf; - $out=''; - if ($conf->browser->layout != 'phone' && ! empty($conf->use_javascript_ajax)) + $out = ''; + if ($conf->browser->layout != 'phone' && !empty($conf->use_javascript_ajax)) { - $urladvancedpreview=getAdvancedPreviewUrl($modulepart, $relativepath, 1, $param); // Return if a file is qualified for preview. + $urladvancedpreview = getAdvancedPreviewUrl($modulepart, $relativepath, 1, $param); // Return if a file is qualified for preview. if (count($urladvancedpreview)) { - $out.= '<a class="pictopreview '.$urladvancedpreview['css'].'" href="'.$urladvancedpreview['url'].'"'.(empty($urladvancedpreview['mime'])?'':' mime="'.$urladvancedpreview['mime'].'"').' '.(empty($urladvancedpreview['target'])?'':' target="'.$urladvancedpreview['target'].'"').'>'; + $out .= '<a class="pictopreview '.$urladvancedpreview['css'].'" href="'.$urladvancedpreview['url'].'"'.(empty($urladvancedpreview['mime']) ? '' : ' mime="'.$urladvancedpreview['mime'].'"').' '.(empty($urladvancedpreview['target']) ? '' : ' target="'.$urladvancedpreview['target'].'"').'>'; //$out.= '<a class="pictopreview">'; if (empty($ruleforpicto)) { //$out.= img_picto($langs->trans('Preview').' '.$file['name'], 'detail'); - $out.='<span class="fa fa-search-plus" style="color: gray"></span>'; + $out .= '<span class="fa fa-search-plus" style="color: gray"></span>'; } - else $out.= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']); - $out.= '</a>'; + else $out .= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']); + $out .= '</a>'; } } return $out; diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index bdcfe6bbf75..c5b499c78e1 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -36,7 +36,7 @@ class Interfaces */ public $db; - public $dir; // Directory with all core and external triggers files + public $dir; // Directory with all core and external triggers files /** * @var string[] Error codes (or messages) @@ -69,18 +69,18 @@ class Interfaces { // phpcs:enable // Check parameters - if (! is_object($object) || ! is_object($conf)) // Error + if (!is_object($object) || !is_object($conf)) // Error { - $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); + $this->error = 'function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); - $this->errors[]=$this->error; + $this->errors[] = $this->error; return -1; } - if (! is_object($langs)) // Warning + if (!is_object($langs)) // Warning { dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); } - if (! is_object($user)) // Warning + if (!is_object($user)) // Warning { dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); global $db; @@ -93,44 +93,44 @@ class Interfaces $files = array(); $modules = array(); $orders = array(); - $i=0; + $i = 0; - $dirtriggers=array_merge(array('/core/triggers'), $conf->modules_parts['triggers']); - foreach($dirtriggers as $reldir) + $dirtriggers = array_merge(array('/core/triggers'), $conf->modules_parts['triggers']); + foreach ($dirtriggers as $reldir) { - $dir=dol_buildpath($reldir, 0); - $newdir=dol_osencode($dir); + $dir = dol_buildpath($reldir, 0); + $newdir = dol_osencode($dir); //print "xx".$dir;exit; // Check if directory exists (we do not use dol_is_dir to avoir loading files.lib.php at each call) - if (! is_dir($newdir)) continue; + if (!is_dir($newdir)) continue; - $handle=opendir($newdir); + $handle = opendir($newdir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) { - $part1=$reg[1]; - $part2=$reg[2]; - $part3=$reg[3]; + $part1 = $reg[1]; + $part2 = $reg[2]; + $part3 = $reg[3]; $nbfile++; // Check if trigger file is disabled by name if (preg_match('/NORUN$/i', $file)) continue; // Check if trigger file is for a particular module - $qualified=true; + $qualified = true; if (strtolower($reg[2]) != 'all') { - $module=preg_replace('/^mod/i', '', $reg[2]); - $constparam='MAIN_MODULE_'.strtoupper($module); - if (empty($conf->global->$constparam)) $qualified=false; + $module = preg_replace('/^mod/i', '', $reg[2]); + $constparam = 'MAIN_MODULE_'.strtoupper($module); + if (empty($conf->global->$constparam)) $qualified = false; } - if (! $qualified) + if (!$qualified) { //dol_syslog(get_class($this)."::run_triggers action=".$action." Triggers for file '".$file."' need module to be enabled", LOG_DEBUG); continue; @@ -150,7 +150,7 @@ class Interfaces include_once $newdir.'/'.$file; //print 'Done for '.$modName."\n"; } - catch(Exception $e) + catch (Exception $e) { dol_syslog('ko for '.$modName." ".$e->getMessage()."\n", LOG_ERR); } @@ -158,7 +158,7 @@ class Interfaces $modules[$i] = $modName; $files[$i] = $file; $fullpathfiles[$modName] = $newdir.'/'.$file; - $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value + $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value $i++; } @@ -177,17 +177,17 @@ class Interfaces $objMod = new $modName($this->db); if ($objMod) { - $result=0; + $result = 0; if (method_exists($objMod, 'runTrigger')) // New method to implement { //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); - $result=$objMod->runTrigger($action, $object, $user, $langs, $conf); + $result = $objMod->runTrigger($action, $object, $user, $langs, $conf); } elseif (method_exists($objMod, 'run_trigger')) // Deprecated method { dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); - $result=$objMod->run_trigger($action, $object, $user, $langs, $conf); + $result = $objMod->run_trigger($action, $object, $user, $langs, $conf); } else { @@ -211,8 +211,8 @@ class Interfaces //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($objMod->errors), LOG_ERR); $nbtotal++; $nbko++; - if (! empty($objMod->errors)) $this->errors=array_merge($this->errors, $objMod->errors); - elseif (! empty($objMod->error)) $this->errors[]=$objMod->error; + if (!empty($objMod->errors)) $this->errors = array_merge($this->errors, $objMod->errors); + elseif (!empty($objMod->error)) $this->errors[] = $objMod->error; //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($this->errors), LOG_ERR); } } @@ -253,32 +253,32 @@ class Interfaces $orders = array(); $i = 0; - $dirtriggers=array_merge(array('/core/triggers/'), $conf->modules_parts['triggers']); + $dirtriggers = array_merge(array('/core/triggers/'), $conf->modules_parts['triggers']); if (is_array($forcedirtriggers)) { - $dirtriggers=$forcedirtriggers; + $dirtriggers = $forcedirtriggers; } - foreach($dirtriggers as $reldir) + foreach ($dirtriggers as $reldir) { - $dir=dol_buildpath($reldir, 0); - $newdir=dol_osencode($dir); + $dir = dol_buildpath($reldir, 0); + $newdir = dol_osencode($dir); // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) - if (! is_dir($newdir)) continue; + if (!is_dir($newdir)) continue; - $handle=opendir($newdir); + $handle = opendir($newdir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg)) { if (preg_match('/\.back$/', $file)) continue; - $part1=$reg[1]; - $part2=$reg[2]; - $part3=$reg[3]; + $part1 = $reg[1]; + $part2 = $reg[2]; + $part3 = $reg[3]; $modName = 'Interface'.ucfirst($reg[3]); //print "file=$file"; print "modName=$modName"; exit; @@ -295,9 +295,9 @@ class Interfaces $files[$i] = $file; $fullpath[$i] = $dir.'/'.$file; $relpath[$i] = preg_replace('/^\//', '', $reldir).'/'.$file; - $iscoreorexternal[$i] = ($reldir == '/core/triggers/'?'internal':'external'); + $iscoreorexternal[$i] = ($reldir == '/core/triggers/' ? 'internal' : 'external'); $modules[$i] = $modName; - $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value + $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value $i++; } @@ -317,7 +317,7 @@ class Interfaces $modName = $modules[$key]; if (empty($modName)) continue; - if (! class_exists($modName)) + if (!class_exists($modName)) { print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."<br>\n"; continue; @@ -326,24 +326,24 @@ class Interfaces $objMod = new $modName($db); // Define disabledbyname and disabledbymodule - $disabledbyname=0; - $disabledbymodule=1; - $module=''; + $disabledbyname = 0; + $disabledbymodule = 1; + $module = ''; // Check if trigger file is disabled by name - if (preg_match('/NORUN$/i', $files[$key])) $disabledbyname=1; + if (preg_match('/NORUN$/i', $files[$key])) $disabledbyname = 1; // Check if trigger file is for a particular module if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i', $files[$key], $reg)) { - $module=preg_replace('/^mod/i', '', $reg[2]); - $constparam='MAIN_MODULE_'.strtoupper($module); - if (strtolower($module) == 'all') $disabledbymodule=0; - elseif (empty($conf->global->$constparam)) $disabledbymodule=2; - $triggers[$j]['module']=strtolower($module); + $module = preg_replace('/^mod/i', '', $reg[2]); + $constparam = 'MAIN_MODULE_'.strtoupper($module); + if (strtolower($module) == 'all') $disabledbymodule = 0; + elseif (empty($conf->global->$constparam)) $disabledbymodule = 2; + $triggers[$j]['module'] = strtolower($module); } // We set info of modules - $triggers[$j]['picto'] = $objMod->picto?img_object('', $objMod->picto, 'class="valignmiddle pictomodule "'):img_object('', 'generic', 'class="valignmiddle pictomodule "'); + $triggers[$j]['picto'] = $objMod->picto ?img_object('', $objMod->picto, 'class="valignmiddle pictomodule "') : img_object('', 'generic', 'class="valignmiddle pictomodule "'); $triggers[$j]['file'] = $files[$key]; $triggers[$j]['fullpath'] = $fullpath[$key]; $triggers[$j]['relpath'] = $relpath[$key]; @@ -352,19 +352,19 @@ class Interfaces $triggers[$j]['status'] = img_picto($langs->trans("Active"), 'tick'); if ($disabledbyname > 0 || $disabledbymodule > 1) $triggers[$j]['status'] = ''; - $text ='<b>'.$langs->trans("Description").':</b><br>'; - $text.=$objMod->getDesc().'<br>'; - $text.='<br><b>'.$langs->trans("Status").':</b><br>'; + $text = '<b>'.$langs->trans("Description").':</b><br>'; + $text .= $objMod->getDesc().'<br>'; + $text .= '<br><b>'.$langs->trans("Status").':</b><br>'; if ($disabledbyname == 1) { - $text.=$langs->trans("TriggerDisabledByName").'<br>'; - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>'; + $text .= $langs->trans("TriggerDisabledByName").'<br>'; + if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>'; } else { - if ($disabledbymodule == 0) $text.=$langs->trans("TriggerAlwaysActive").'<br>'; - if ($disabledbymodule == 1) $text.=$langs->trans("TriggerActiveAsModuleActive", $module).'<br>'; - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>'; + if ($disabledbymodule == 0) $text .= $langs->trans("TriggerAlwaysActive").'<br>'; + if ($disabledbymodule == 1) $text .= $langs->trans("TriggerActiveAsModuleActive", $module).'<br>'; + if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>'; } $triggers[$j]['info'] = $text; diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index f395475faf7..e3289f2c8e0 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -32,19 +32,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","cron","bills","members")); +$langs->loadLangs(array("admin", "cron", "bills", "members")); if (!$user->rights->cron->read) accessforbidden(); -$action=GETPOST('action', 'alpha'); -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$confirm=GETPOST('confirm', 'alpha'); -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'cronjoblist'; // To manage different context of search +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$confirm = GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'cronjoblist'; // To manage different context of search -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -52,16 +52,16 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='t.status,t.priority'; -if (! $sortorder) $sortorder='DESC,ASC'; +if (!$sortfield) $sortfield = 't.status,t.priority'; +if (!$sortorder) $sortorder = 'DESC,ASC'; -$search_status=(GETPOSTISSET('search_status')?GETPOST('search_status', 'int'):GETPOST('status', 'int')); +$search_status = (GETPOSTISSET('search_status') ?GETPOST('search_status', 'int') : GETPOST('status', 'int')); //Search criteria -$search_label=GETPOST("search_label", 'alpha'); +$search_label = GETPOST("search_label", 'alpha'); $securitykey = GETPOST('securitykey', 'alpha'); -$diroutputmassaction=$conf->cronjob->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->cronjob->dir_output.'/temp/massgeneration/'.$user->id; $object = new Cronjob($db); @@ -72,7 +72,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -80,11 +80,11 @@ $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -95,21 +95,21 @@ if (empty($reshook)) // 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_label=''; - $search_status=-1; - $toselect=''; - $search_array_options=array(); + $search_label = ''; + $search_status = -1; + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } - $filter=array(); + $filter = array(); if (!empty($search_label)) { - $filter['t.label']=$search_label; + $filter['t.label'] = $search_label; } // Delete jobs @@ -117,7 +117,7 @@ if (empty($reshook)) { //Delete cron task $object = new Cronjob($db); - $object->id=$id; + $object->id = $id; $result = $object->delete($user); if ($result < 0) { @@ -128,19 +128,19 @@ if (empty($reshook)) // Execute jobs if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) { - if (! empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey) + if (!empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey) { setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors'); - $action=''; + $action = ''; } else { $object = new Cronjob($db); $job = $object->fetch($id); - $now = dol_now(); // Date we start + $now = dol_now(); // Date we start - $resrunjob = $object->run_jobs($user->login); // Return -1 if KO, 1 if OK + $resrunjob = $object->run_jobs($user->login); // Return -1 if KO, 1 if OK if ($resrunjob < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -154,39 +154,39 @@ if (empty($reshook)) if ($object->lastresult >= 0) setEventMessages($langs->trans("JobFinished"), null, 'mesgs'); else setEventMessages($langs->trans("JobFinished"), null, 'errors'); } - $action=''; + $action = ''; } else { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } - $param='&search_status='.urlencode($search_status); - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($search_label) $param.='&search_label='.urlencode($search_label); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = '&search_status='.urlencode($search_status); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - header("Location: ".DOL_URL_ROOT.'/cron/list.php?'.$param.($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'')); // Make a redirect to avoid to run twice the job when using back + header("Location: ".DOL_URL_ROOT.'/cron/list.php?'.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '')); // Make a redirect to avoid to run twice the job when using back exit; } } // Mass actions - $objectclass='CronJob'; - $objectlabel='CronJob'; + $objectclass = 'CronJob'; + $objectlabel = 'CronJob'; $permissiontoread = $user->rights->cron->read; - $permissiontoadd = $user->rights->cron->create?$user->rights->cron->create:$user->rights->cron->write; + $permissiontoadd = $user->rights->cron->create ? $user->rights->cron->create : $user->rights->cron->write; $permissiontodelete = $user->rights->cron->delete; $uploaddir = $conf->cron->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; if ($permissiontoadd) { $tmpcron = new Cronjob($db); - foreach($toselect as $id) + foreach ($toselect as $id) { $result = $tmpcron->fetch($id); if ($result) @@ -213,67 +213,67 @@ if (empty($reshook)) $form = new Form($db); $cronjob = new Cronjob($db); -$pagetitle=$langs->trans("CronList"); +$pagetitle = $langs->trans("CronList"); llxHeader('', $pagetitle); $sql = "SELECT"; -$sql.= " t.rowid,"; -$sql.= " t.tms,"; -$sql.= " t.datec,"; -$sql.= " t.jobtype,"; -$sql.= " t.label,"; -$sql.= " t.command,"; -$sql.= " t.classesname,"; -$sql.= " t.objectname,"; -$sql.= " t.methodename,"; -$sql.= " t.params,"; -$sql.= " t.md5params,"; -$sql.= " t.module_name,"; -$sql.= " t.priority,"; -$sql.= " t.processing,"; -$sql.= " t.datelastrun,"; -$sql.= " t.datenextrun,"; -$sql.= " t.dateend,"; -$sql.= " t.datestart,"; -$sql.= " t.lastresult,"; -$sql.= " t.datelastresult,"; -$sql.= " t.lastoutput,"; -$sql.= " t.unitfrequency,"; -$sql.= " t.frequency,"; -$sql.= " t.status,"; -$sql.= " t.fk_user_author,"; -$sql.= " t.fk_user_mod,"; -$sql.= " t.note,"; -$sql.= " t.maxrun,"; -$sql.= " t.nbrun,"; -$sql.= " t.libname,"; -$sql.= " t.test"; -$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; -$sql.= " WHERE entity IN (0,".$conf->entity.")"; -if ($search_status >= 0 && $search_status < 2 && $search_status != '') $sql.= " AND t.status = ".(empty($search_status)?'0':'1'); +$sql .= " t.rowid,"; +$sql .= " t.tms,"; +$sql .= " t.datec,"; +$sql .= " t.jobtype,"; +$sql .= " t.label,"; +$sql .= " t.command,"; +$sql .= " t.classesname,"; +$sql .= " t.objectname,"; +$sql .= " t.methodename,"; +$sql .= " t.params,"; +$sql .= " t.md5params,"; +$sql .= " t.module_name,"; +$sql .= " t.priority,"; +$sql .= " t.processing,"; +$sql .= " t.datelastrun,"; +$sql .= " t.datenextrun,"; +$sql .= " t.dateend,"; +$sql .= " t.datestart,"; +$sql .= " t.lastresult,"; +$sql .= " t.datelastresult,"; +$sql .= " t.lastoutput,"; +$sql .= " t.unitfrequency,"; +$sql .= " t.frequency,"; +$sql .= " t.status,"; +$sql .= " t.fk_user_author,"; +$sql .= " t.fk_user_mod,"; +$sql .= " t.note,"; +$sql .= " t.maxrun,"; +$sql .= " t.nbrun,"; +$sql .= " t.libname,"; +$sql .= " t.test"; +$sql .= " FROM ".MAIN_DB_PREFIX."cronjob as t"; +$sql .= " WHERE entity IN (0,".$conf->entity.")"; +if ($search_status >= 0 && $search_status < 2 && $search_status != '') $sql .= " AND t.status = ".(empty($search_status) ? '0' : '1'); //Manage filter -if (is_array($filter) && count($filter)>0) { - foreach($filter as $key => $value) { - $sql.= ' AND '.$key.' LIKE \'%'.$db->escape($value).'%\''; +if (is_array($filter) && count($filter) > 0) { + foreach ($filter as $key => $value) { + $sql .= ' AND '.$key.' LIKE \'%'.$db->escape($value).'%\''; } } $sqlwhere = array(); if (!empty($module_name)) { - $sqlwhere[]='(t.module_name='.$db->escape($module_name).')'; + $sqlwhere[] = '(t.module_name='.$db->escape($module_name).')'; } -if (count($sqlwhere)>0) { - $sql.= " WHERE ".implode(' AND ', $sqlwhere); +if (count($sqlwhere) > 0) { + $sql .= " WHERE ".implode(' AND ', $sqlwhere); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -288,21 +288,21 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$result=$db->query($sql); -if (! $result) dol_print_error($db); +$result = $db->query($sql); +if (!$result) dol_print_error($db); $num = $db->num_rows($result); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); $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_status) $param.='&search_status='.urlencode($search_status); -if ($search_label) $param.='&search_label='.urlencode($search_label); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($search_status) $param .= '&search_status='.urlencode($search_status); +if ($search_label) $param .= '&search_label='.urlencode($search_label); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -318,15 +318,15 @@ if ($action == 'execute') } // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), 'enable'=>$langs->trans("CronStatusActiveBtn"), 'disable'=>$langs->trans("CronStatusInactiveBtn"), ); -if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="search_form">'."\n"; @@ -348,15 +348,15 @@ print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $ print '<span class="opacitymedium">'.$langs->trans('CronInfo').'</span><br>'; -$text =$langs->trans("HoursOnThisPageAreOnServerTZ").' '.$stringcurrentdate.'<br>'; -if (! empty($conf->global->CRON_WARNING_DELAY_HOURS)) $text.=$langs->trans("WarningCronDelayed", $conf->global->CRON_WARNING_DELAY_HOURS); +$text = $langs->trans("HoursOnThisPageAreOnServerTZ").' '.$stringcurrentdate.'<br>'; +if (!empty($conf->global->CRON_WARNING_DELAY_HOURS)) $text .= $langs->trans("WarningCronDelayed", $conf->global->CRON_WARNING_DELAY_HOURS); print info_admin($text); print '<br>'; -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=''; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = ''; //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '<div class="div-table-responsive">'; print '<table class="noborder">'; @@ -381,7 +381,7 @@ print '<td class="liste_titre"> </td>'; print '<td class="liste_titre" align="center">'; print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Enabled")), $search_status, 1); print '</td><td class="liste_titre right">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'; @@ -410,14 +410,14 @@ if ($num > 0) { // Loop on each job $now = dol_now(); - $i=0; + $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($result); if (empty($obj)) break; - if (! verifCond($obj->test)) continue; // Discard line with test = false + if (!verifCond($obj->test)) continue; // Discard line with test = false $object->id = $obj->rowid; $object->ref = $obj->rowid; @@ -438,7 +438,7 @@ if ($num > 0) // Label print '<td>'; - if (! empty($obj->label)) + if (!empty($obj->label)) { $object->ref = $langs->trans($obj->label); print $object->getNomUrl(0, '', 1); @@ -456,52 +456,52 @@ if ($num > 0) print '</td>'; print '<td>'; - if ($obj->jobtype=='method') + if ($obj->jobtype == 'method') { - $text=$langs->trans("CronClass"); - $texttoshow=$langs->trans('CronModule').': '.$obj->module_name.'<br>'; - $texttoshow.=$langs->trans('CronClass').': '. $obj->classesname.'<br>'; - $texttoshow.=$langs->trans('CronObject').': '. $obj->objectname.'<br>'; - $texttoshow.=$langs->trans('CronMethod').': '. $obj->methodename; - $texttoshow.='<br>'.$langs->trans('CronArgs').': '. $obj->params; - $texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($obj->note); + $text = $langs->trans("CronClass"); + $texttoshow = $langs->trans('CronModule').': '.$obj->module_name.'<br>'; + $texttoshow .= $langs->trans('CronClass').': '.$obj->classesname.'<br>'; + $texttoshow .= $langs->trans('CronObject').': '.$obj->objectname.'<br>'; + $texttoshow .= $langs->trans('CronMethod').': '.$obj->methodename; + $texttoshow .= '<br>'.$langs->trans('CronArgs').': '.$obj->params; + $texttoshow .= '<br>'.$langs->trans('Comment').': '.$langs->trans($obj->note); } - elseif ($obj->jobtype=='command') + elseif ($obj->jobtype == 'command') { - $text=$langs->trans('CronCommand'); - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($obj->command); - $texttoshow.='<br>'.$langs->trans('CronArgs').': '. $obj->params; - $texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($obj->note); + $text = $langs->trans('CronCommand'); + $texttoshow = $langs->trans('CronCommand').': '.dol_trunc($obj->command); + $texttoshow .= '<br>'.$langs->trans('CronArgs').': '.$obj->params; + $texttoshow .= '<br>'.$langs->trans('Comment').': '.$langs->trans($obj->note); } print $form->textwithpicto($text, $texttoshow, 1); print '</td>'; print '<td>'; - if($obj->unitfrequency == "60") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Minutes'); - if($obj->unitfrequency == "3600") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Hours'); - if($obj->unitfrequency == "86400") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Days'); - if($obj->unitfrequency == "604800") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Weeks'); + if ($obj->unitfrequency == "60") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Minutes'); + if ($obj->unitfrequency == "3600") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Hours'); + if ($obj->unitfrequency == "86400") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Days'); + if ($obj->unitfrequency == "604800") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Weeks'); print '</td>'; print '<td class="center">'; - if(!empty($obj->datestart)) {print dol_print_date($db->jdate($obj->datestart), 'dayhour');} + if (!empty($obj->datestart)) {print dol_print_date($db->jdate($obj->datestart), 'dayhour'); } print '</td>'; print '<td class="center">'; - if(!empty($obj->dateend)) {print dol_print_date($db->jdate($obj->dateend), 'dayhour');} + if (!empty($obj->dateend)) {print dol_print_date($db->jdate($obj->dateend), 'dayhour'); } print '</td>'; print '<td class="right">'; - if (!empty($obj->maxrun)) {print $obj->maxrun;} + if (!empty($obj->maxrun)) {print $obj->maxrun; } print '</td>'; print '<td class="right">'; - if (!empty($obj->nbrun)) {print $obj->nbrun;} else {print '0';} + if (!empty($obj->nbrun)) {print $obj->nbrun; } else {print '0'; } print '</td>'; // Date start last run print '<td class="center">'; - if (!empty($datelastrun)) {print dol_print_date($datelastrun, 'dayhoursec');} + if (!empty($datelastrun)) {print dol_print_date($datelastrun, 'dayhoursec'); } print '</td>'; // Duration @@ -522,7 +522,7 @@ if ($num > 0) // Output of last run print '<td>'; - if(!empty($obj->lastoutput)) {print dol_trunc(nl2br($obj->lastoutput), 50);} + if (!empty($obj->lastoutput)) {print dol_trunc(nl2br($obj->lastoutput), 50); } print '</td>'; print '<td class="center">'; @@ -546,15 +546,15 @@ if ($num > 0) print '<td class="nowraponall right">'; - $backtourl = urlencode($_SERVER["PHP_SELF"].'?'.$param.($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'')); + $backtourl = urlencode($_SERVER["PHP_SELF"].'?'.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '')); if ($user->rights->cron->create) { - print "<a href=\"".DOL_URL_ROOT."/cron/card.php?id=".$obj->rowid."&action=edit".($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param; + print "<a href=\"".DOL_URL_ROOT."/cron/card.php?id=".$obj->rowid."&action=edit".($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').$param; print "&backtourl=".$backtourl."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'), 'edit')."</a>  "; } if ($user->rights->cron->delete) { - print "<a href=\"".$_SERVER["PHP_SELF"]."?id=".$obj->rowid."&action=delete".($page?'&page='.$page:'').($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param; + print "<a href=\"".$_SERVER["PHP_SELF"]."?id=".$obj->rowid."&action=delete".($page ? '&page='.$page : '').($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').$param; print "\" title=\"".dol_escape_htmltag($langs->trans('CronDelete'))."\">".img_picto($langs->trans('CronDelete'), 'delete')."</a>  "; } else { print "<a href=\"#\" title=\"".dol_escape_htmltag($langs->trans('NotEnoughPermissions'))."\">".img_picto($langs->trans('NotEnoughPermissions'), 'delete')."</a>   "; @@ -563,9 +563,9 @@ if ($num > 0) { if (!empty($obj->status)) { print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=execute'; - print (empty($conf->global->CRON_KEY)?'':'&securitykey='.$conf->global->CRON_KEY); - print ($sortfield?'&sortfield='.$sortfield:''); - print ($sortorder?'&sortorder='.$sortorder:''); + print (empty($conf->global->CRON_KEY) ? '' : '&securitykey='.$conf->global->CRON_KEY); + print ($sortfield ? '&sortfield='.$sortfield : ''); + print ($sortorder ? '&sortorder='.$sortorder : ''); print $param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'), "play").'</a>'; } else { print '<a href="#" class="cursordefault" title="'.dol_escape_htmltag($langs->trans('JobDisabled')).'">'.img_picto($langs->trans('JobDisabled'), "playdisabled").'</a>'; @@ -575,9 +575,9 @@ if ($num > 0) } if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '   <input id="cb'.$obj->rowid.'" class="flat checkforselect valignmiddle" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '   <input id="cb'.$obj->rowid.'" class="flat checkforselect valignmiddle" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index eeb05e8926c..390a38dc203 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -33,11 +33,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("sendings","deliveries",'companies','bills')); +$langs->loadLangs(array("sendings", "deliveries", 'companies', 'bills')); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'shipmentlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'shipmentlist'; // To manage different context of search -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); @@ -46,34 +46,34 @@ $toselect = GETPOST('toselect', 'array'); // Security check $expeditionid = GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'expedition', $expeditionid, ''); $search_ref_exp = GETPOST("search_ref_exp", 'alpha'); $search_ref_liv = GETPOST('search_ref_liv', 'alpha'); $search_ref_customer = GETPOST('search_ref_customer', 'alpha'); $search_company = GETPOST("search_company", 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_billed=GETPOST("search_billed", 'int'); -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_billed = GETPOST("search_billed", 'int'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $optioncss = GETPOST('optioncss', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if (! $sortfield) $sortfield="e.ref"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "e.ref"; +if (!$sortorder) $sortorder = "DESC"; if (empty($page) || $page == -1 || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$viewstatut=GETPOST('viewstatut'); +$viewstatut = GETPOST('viewstatut'); $diroutputmassaction = $conf->expedition->dir_output.'/sending/temp/massgeneration/'.$user->id; @@ -86,7 +86,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -94,10 +94,10 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'e.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["e.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["e.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), @@ -110,18 +110,18 @@ $arrayfields=array( 'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), - 'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)), - 'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)), + 'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled) ? 0 : 1)), + 'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled) ? 0 : 1)), 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) ); // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -133,11 +133,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ $error = 0; -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -145,20 +145,20 @@ 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_ref_exp=''; - $search_ref_liv=''; - $search_ref_customer=''; - $search_company=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_billed=''; - $viewstatut=''; + $search_ref_exp = ''; + $search_ref_liv = ''; + $search_ref_customer = ''; + $search_company = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_billed = ''; + $viewstatut = ''; $toselect = ''; - $search_array_options=array(); + $search_array_options = array(); } if (empty($reshook)) @@ -168,7 +168,7 @@ if (empty($reshook)) $permissiontoread = $user->rights->expedition->lire; $permissiontoadd = $user->rights->expedition->creer; $permissiontodelete = $user->rights->expedition->supprimer; - $uploaddir = $conf->expedition->dir_output . '/sending'; + $uploaddir = $conf->expedition->dir_output.'/sending'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -177,58 +177,58 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); $formfile = new FormFile($db); -$companystatic=new Societe($db); -$shipment=new Expedition($db); -$formcompany=new FormCompany($db); +$companystatic = new Societe($db); +$shipment = new Expedition($db); +$formcompany = new FormCompany($db); -$helpurl='EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones'; +$helpurl = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones'; llxHeader('', $langs->trans('ListOfSendings'), $helpurl); $sql = "SELECT e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed,"; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' e.date_creation as date_creation, e.tms as date_update'; +$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= ' e.date_creation as date_creation, e.tms as date_update'; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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."expedition as e"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; -$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)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target"; +$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."expedition as e"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; +$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)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target"; if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -$sql.= " WHERE e.entity IN (".getEntity('expedition').")"; +$sql .= " WHERE e.entity IN (".getEntity('expedition').")"; if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all { - $sql.= " AND e.fk_soc = sc.fk_soc"; - $sql.= " AND sc.fk_user = " .$user->id; + $sql .= " AND e.fk_soc = sc.fk_soc"; + $sql .= " AND sc.fk_user = ".$user->id; } if ($socid) { - $sql.= " AND e.fk_soc = ".$socid; + $sql .= " AND e.fk_soc = ".$socid; } if ($viewstatut <> '' && $viewstatut >= 0) { - $sql.= " AND e.fk_statut = ".$viewstatut; + $sql .= " AND e.fk_statut = ".$viewstatut; } -if ($search_ref_customer != '') $sql.=natural_search('e.ref_customer', $search_ref_customer); -if ($search_billed != '' && $search_billed >= 0) $sql.=' AND e.billed = '.$search_billed; -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_ref_customer != '') $sql .= natural_search('e.ref_customer', $search_ref_customer); +if ($search_billed != '' && $search_billed >= 0) $sql .= ' AND e.billed = '.$search_billed; +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp); @@ -240,11 +240,11 @@ if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -258,10 +258,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -270,32 +270,32 @@ if ($resql) $expedition = new Expedition($db); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.= "&sall=".urlencode($sall); - if ($search_ref_exp) $param.= "&search_ref_exp=".urlencode($search_ref_exp); - if ($search_ref_liv) $param.= "&search_ref_liv=".urlencode($search_ref_liv); - if ($search_ref_customer) $param.= "&search_ref_customer=".urlencode($search_ref_customer); - if ($search_company) $param.= "&search_company=".urlencode($search_company); - if ($search_town) $param.= '&search_town='.urlencode($search_town); - if ($search_zip) $param.= '&search_zip='.urlencode($search_zip); - if ($viewstatut != '') $param.= '&viewstatut='.urlencode($viewstatut); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= "&sall=".urlencode($sall); + if ($search_ref_exp) $param .= "&search_ref_exp=".urlencode($search_ref_exp); + if ($search_ref_liv) $param .= "&search_ref_liv=".urlencode($search_ref_liv); + if ($search_ref_customer) $param .= "&search_ref_customer=".urlencode($search_ref_customer); + if ($search_company) $param .= "&search_company=".urlencode($search_company); + if ($search_town) $param .= '&search_town='.urlencode($search_town); + if ($search_zip) $param .= '&search_zip='.urlencode($search_zip); + if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $arrayofmassactions = array( + $arrayofmassactions = array( 'builddoc' => $langs->trans("PDFMerge"), 'presend' => $langs->trans("SendByMail"), ); - if (in_array($massaction, array('presend'))) $arrayofmassactions=array(); + if (in_array($massaction, array('presend'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->expedition->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2'); } $i = 0; @@ -318,89 +318,89 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } - $moreforfilter=''; - if (! empty($moreforfilter)) + $moreforfilter = ''; + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; - $parameters=array('type'=>$type); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</div>'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);// This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search print '<tr class="liste_titre_filter">'; // Ref - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="6" type="text" name="search_ref_exp" value="'.$search_ref_exp.'">'; print '</td>'; } // Ref customer - if (! empty($arrayfields['e.ref_customer']['checked'])) + if (!empty($arrayfields['e.ref_customer']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="6" type="text" name="search_ref_customer" value="'.$search_ref_customer.'">'; print '</td>'; } // Thirdparty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">'; print '</td>'; } // Town - if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; + if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>'; + if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>'; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="liste_titre center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone center">'; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print '</td>'; } // Date delivery planned - if (! empty($arrayfields['e.date_delivery']['checked'])) + if (!empty($arrayfields['e.date_delivery']['checked'])) { print '<td class="liste_titre"> </td>'; } - if (! empty($arrayfields['l.ref']['checked'])) + if (!empty($arrayfields['l.ref']['checked'])) { // Delivery ref print '<td class="liste_titre">'; print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"'; print '</td>'; } - if (! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.date_delivery']['checked'])) { // Date received print '<td class="liste_titre"> </td>'; @@ -409,30 +409,30 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['e.datec']['checked'])) + if (!empty($arrayfields['e.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (! empty($arrayfields['e.tms']['checked'])) + if (!empty($arrayfields['e.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status - if (! empty($arrayfields['e.fk_statut']['checked'])) + if (!empty($arrayfields['e.fk_statut']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone right">'; - print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'),'1'=>$langs->trans('StatusSendingValidatedShort'),'2'=>$langs->trans('StatusSendingProcessedShort')), $viewstatut, 1); + print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $viewstatut, 1); print '</td>'; } // Status billed - if (! empty($arrayfields['e.billed']['checked'])) + if (!empty($arrayfields['e.billed']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone center">'; print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); @@ -440,121 +440,121 @@ if ($resql) } // Action column print '<td class="liste_titre middle">'; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; - if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['e.ref_customer']['checked'])) print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['e.ref_customer']['checked'])) print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; $typenArray = $formcompany->typent_array(1); - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $shipment->id=$obj->rowid; - $shipment->ref=$obj->ref; + $shipment->id = $obj->rowid; + $shipment->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->ref=$obj->name; - $companystatic->name=$obj->name; + $companystatic->id = $obj->socid; + $companystatic->ref = $obj->name; + $companystatic->name = $obj->name; print '<tr class="oddeven">'; // Ref - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print "<td>"; print $shipment->getNomUrl(1); print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref customer - if (! empty($arrayfields['e.ref_customer']['checked'])) + if (!empty($arrayfields['e.ref_customer']['checked'])) { print "<td>"; print $obj->ref_customer; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td>'; print $companystatic->getNomUrl(1); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['s.town']['checked'])) + if (!empty($arrayfields['s.town']['checked'])) { print '<td class="nocellnopadd">'; print $obj->town; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['s.zip']['checked'])) + if (!empty($arrayfields['s.zip']['checked'])) { print '<td class="nocellnopadd">'; print $obj->zip; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "<td>".$obj->state_name."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="center">'; - $tmparray=getCountry($obj->fk_pays, 'all'); + $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="center">'; if (isset($typenArray[$obj->typent_code])) print $typenArray[$obj->typent_code]; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date delivery planed - if (! empty($arrayfields['e.date_delivery']['checked'])) + if (!empty($arrayfields['e.date_delivery']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_livraison), "day"); @@ -565,13 +565,13 @@ if ($resql) print "</td>\n"; } - if (! empty($arrayfields['l.ref']['checked']) || ! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { $shipment->fetchObjectLinked($shipment->id, $shipment->element); - $receiving=''; - if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving=reset($shipment->linkedObjects['delivery']); + $receiving = ''; + if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving = reset($shipment->linkedObjects['delivery']); - if (! empty($arrayfields['l.ref']['checked'])) + if (!empty($arrayfields['l.ref']['checked'])) { // Ref print '<td>'; @@ -579,7 +579,7 @@ if ($resql) print '</td>'; } - if (! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.date_delivery']['checked'])) { // Date received print '<td class="center">'; @@ -591,48 +591,48 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['e.datec']['checked'])) + if (!empty($arrayfields['e.datec']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['e.tms']['checked'])) + if (!empty($arrayfields['e.tms']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['e.fk_statut']['checked'])) + if (!empty($arrayfields['e.fk_statut']['checked'])) { print '<td class="right nowrap">'.$shipment->LibStatut($obj->fk_statut, 5).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Billed - if (! empty($arrayfields['e.billed']['checked'])) + if (!empty($arrayfields['e.billed']['checked'])) { print '<td class="center">'.yn($obj->billed).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print '<td class="nowrap" align="center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "</tr>\n"; @@ -640,8 +640,8 @@ if ($resql) } $db->free($resql); - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "</table>"; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 91d0efec9cc..385277bb7d3 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -45,35 +45,35 @@ $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); -$contextpage = GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'expensereportlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'expensereportlist'; $childids = $user->getAllChildIds(1); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'expensereport', '', ''); $id = GETPOST('id', 'int'); // If we are on the view of a specific user if ($id > 0) { - $canread=0; - if ($id == $user->id) $canread=1; - if (! empty($user->rights->expensereport->readall)) $canread=1; - if (! empty($user->rights->expensereport->lire) && in_array($id, $childids)) $canread=1; - if (! $canread) + $canread = 0; + if ($id == $user->id) $canread = 1; + if (!empty($user->rights->expensereport->readall)) $canread = 1; + if (!empty($user->rights->expensereport->lire) && in_array($id, $childids)) $canread = 1; + if (!$canread) { accessforbidden(); } } -$diroutputmassaction=$conf->expensereport->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -81,17 +81,17 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder="DESC"; -if (!$sortfield) $sortfield="d.date_debut"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "d.date_debut"; -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST('search_ref', 'alpha'); $search_user = GETPOST('search_user', 'int'); $search_amount_ht = GETPOST('search_amount_ht', 'alpha'); $search_amount_vat = GETPOST('search_amount_vat', 'alpha'); $search_amount_ttc = GETPOST('search_amount_ttc', 'alpha'); -$search_status = (GETPOST('search_status', 'intcomma')!=''?GETPOST('search_status', 'intcomma'):GETPOST('statut', 'intcomma')); +$search_status = (GETPOST('search_status', 'intcomma') != '' ?GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma')); $month_start = GETPOST("month_start", "int"); $year_start = GETPOST("year_start", "int"); $day_start = GETPOST("day_start", "int"); @@ -100,8 +100,8 @@ $month_end = GETPOST("month_end", "int"); $year_end = GETPOST("year_end", "int"); $optioncss = GETPOST('optioncss', 'alpha'); -if ($search_status == '') $search_status=-1; -if ($search_user == '') $search_user=-1; +if ($search_status == '') $search_status = -1; +if ($search_user == '') $search_user = -1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new ExpenseReport($db); @@ -111,7 +111,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('expensereport'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" @@ -122,9 +122,9 @@ $fieldstosearchall = array( 'u.firstname'=>"Firstname", 'u.login'=>"Login", ); -if (empty($user->socid)) $fieldstosearchall["d.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["d.note_private"] = "NotePrivate"; -$arrayfields=array( +$arrayfields = array( 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'user'=>array('label'=>$langs->trans("User"), 'checked'=>1), 'd.date_debut'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1), @@ -141,14 +141,14 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } -$canedituser=(! empty($user->admin) || $user->rights->user->user->creer); +$canedituser = (!empty($user->admin) || $user->rights->user->user->creer); $objectuser = new User($db); @@ -157,11 +157,11 @@ $objectuser = new User($db); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) @@ -172,35 +172,35 @@ if (empty($reshook)) // 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_ref=""; - $search_user=""; - $search_amount_ht=""; - $search_amount_vat=""; - $search_amount_ttc=""; - $search_status=""; - $month_start=""; - $year_start=""; - $month_end=""; - $year_end=""; + $search_ref = ""; + $search_user = ""; + $search_amount_ht = ""; + $search_amount_vat = ""; + $search_amount_ttc = ""; + $search_status = ""; + $month_start = ""; + $year_start = ""; + $month_end = ""; + $year_end = ""; $day_end = ""; - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='ExpenseReport'; - $objectlabel='ExpenseReport'; + $objectclass = 'ExpenseReport'; + $objectlabel = 'ExpenseReport'; $permissiontoread = $user->rights->expensereport->lire; $permissiontodelete = $user->rights->expensereport->supprimer; $uploaddir = $conf->expensereport->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - if ($action == 'update' && ! $cancel) + if ($action == 'update' && !$cancel) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -277,49 +277,49 @@ if ($id > 0) } $sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,"; -$sql.= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve, d.note_private, d.note_public,"; -$sql.= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo"; +$sql .= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve, d.note_private, d.note_public,"; +$sql .= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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."expensereport as d"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; -$sql.= ", ".MAIN_DB_PREFIX."user as u"; -$sql.= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport').")"; +$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."expensereport as d"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; +$sql .= ", ".MAIN_DB_PREFIX."user as u"; +$sql .= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport').")"; // Search all -if (!empty($sall)) $sql.= natural_search(array_keys($fieldstosearchall), $sall); +if (!empty($sall)) $sql .= natural_search(array_keys($fieldstosearchall), $sall); // Ref -if (!empty($search_ref)) $sql.= natural_search('d.ref', $search_ref); +if (!empty($search_ref)) $sql .= natural_search('d.ref', $search_ref); // Date Start -$sql.= dolSqlDateFilter("d.date_debut", $day_start, $month_start, $year_start); +$sql .= dolSqlDateFilter("d.date_debut", $day_start, $month_start, $year_start); // Date End -$sql.= dolSqlDateFilter("d.date_fin", $day_end, $month_end, $year_end); +$sql .= dolSqlDateFilter("d.date_fin", $day_end, $month_end, $year_end); -if ($search_amount_ht != '') $sql.= natural_search('d.total_ht', $search_amount_ht, 1); -if ($search_amount_ttc != '') $sql.= natural_search('d.total_ttc', $search_amount_ttc, 1); +if ($search_amount_ht != '') $sql .= natural_search('d.total_ht', $search_amount_ht, 1); +if ($search_amount_ttc != '') $sql .= natural_search('d.total_ttc', $search_amount_ttc, 1); // User -if ($search_user != '' && $search_user >= 0) $sql.= " AND u.rowid = '".$db->escape($search_user)."'"; +if ($search_user != '' && $search_user >= 0) $sql .= " AND u.rowid = '".$db->escape($search_user)."'"; // Status -if ($search_status != '' && $search_status >= 0) $sql.=" AND d.fk_statut IN (".$db->escape($search_status).")"; +if ($search_status != '' && $search_status >= 0) $sql .= " AND d.fk_statut IN (".$db->escape($search_status).")"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) { - $sql.= " AND d.fk_user_author IN (".join(',', $childids).")\n"; + $sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n"; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -334,7 +334,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); @@ -342,37 +342,37 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($search_ref) $param.="&search_ref=".urlencode($search_ref); - if ($search_user) $param.="&search_user=".urlencode($search_user); - if ($search_amount_ht) $param.="&search_amount_ht=".urlencode($search_amount_ht); - if ($search_amount_ttc) $param.="&search_amount_ttc=".urlencode($search_amount_ttc); - if ($search_status >= 0) $param.="&search_status=".urlencode($search_status); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= "&sall=".urlencode($sall); + if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); + if ($search_user) $param .= "&search_user=".urlencode($search_user); + if ($search_amount_ht) $param .= "&search_amount_ht=".urlencode($search_amount_ht); + if ($search_amount_ttc) $param .= "&search_amount_ttc=".urlencode($search_amount_ttc); + if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->expensereport->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->expensereport->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // Lines of title fields print '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n"; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; - print '<input type="hidden" name="action" value="'.($action=='edit'?'update':'list').'">'; + print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'list').'">'; print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; @@ -449,7 +449,7 @@ if ($resql) $childids = $user->getAllChildIds(1); - $canedit=((in_array($user_id, $childids) && $user->rights->expensereport->creer) + $canedit = ((in_array($user_id, $childids) && $user->rights->expensereport->creer) || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance)); // Buttons for actions @@ -471,58 +471,58 @@ if ($resql) { $title = $langs->trans("ListTripsAndExpenses"); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->expensereport->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewTrip'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expensereport/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewTrip'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expensereport/card.php?action=create'); } print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); } - $topicmail="SendExpenseReport"; - $modelmail="expensereport"; - $objecttmp=new ExpenseReport($db); - $trackid='exp'.$object->id; + $topicmail = "SendExpenseReport"; + $modelmail = "expensereport"; + $objecttmp = new ExpenseReport($db); + $trackid = 'exp'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } - $moreforfilter=''; + $moreforfilter = ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } - $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) : ''); + $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) : ''); print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Filters print '<tr class="liste_titre_filter">'; - if (! empty($arrayfields['d.ref']['checked'])) + if (!empty($arrayfields['d.ref']['checked'])) { print '<td class="liste_titre" align="left">'; print '<input class="flat" size="15" type="text" name="search_ref" value="'.$search_ref.'">'; print '</td>'; } // User - if (! empty($arrayfields['user']['checked'])) + if (!empty($arrayfields['user']['checked'])) { if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) { @@ -534,10 +534,10 @@ if ($resql) } } // Date start - if (! empty($arrayfields['d.date_debut']['checked'])) + if (!empty($arrayfields['d.date_debut']['checked'])) { print '<td class="liste_titre" align="center">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print '<input class="flat width25" type="text" maxlength="2" name="day_start" value="'.dol_escape_htmltag($day_start).'">'; } @@ -546,10 +546,10 @@ if ($resql) print '</td>'; } // Date end - if (! empty($arrayfields['d.date_fin']['checked'])) + if (!empty($arrayfields['d.date_fin']['checked'])) { print '<td class="liste_titre" align="center">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print '<input class="flat width25" type="text" maxlength="2" name="day_end" value="'.dol_escape_htmltag($day_end).'">'; } print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">'; @@ -557,7 +557,7 @@ if ($resql) print '</td>'; } // Date valid - if (! empty($arrayfields['d.date_valid']['checked'])) + if (!empty($arrayfields['d.date_valid']['checked'])) { print '<td class="liste_titre" align="center">'; //print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">'; @@ -565,7 +565,7 @@ if ($resql) print '</td>'; } // Date approve - if (! empty($arrayfields['d.date_approve']['checked'])) + if (!empty($arrayfields['d.date_approve']['checked'])) { print '<td class="liste_titre" align="center">'; //print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">'; @@ -573,16 +573,16 @@ if ($resql) print '</td>'; } // Amount with no tax - if (! empty($arrayfields['d.total_ht']['checked'])) + if (!empty($arrayfields['d.total_ht']['checked'])) { print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ht" value="'.$search_amount_ht.'"></td>'; } - if (! empty($arrayfields['d.total_vat']['checked'])) + if (!empty($arrayfields['d.total_vat']['checked'])) { print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.'"></td>'; } // Amount with all taxes - if (! empty($arrayfields['d.total_ttc']['checked'])) + if (!empty($arrayfields['d.total_ttc']['checked'])) { print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.'"></td>'; } @@ -590,23 +590,23 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['d.date_create']['checked'])) + if (!empty($arrayfields['d.date_create']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (! empty($arrayfields['d.tms']['checked'])) + if (!empty($arrayfields['d.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status - if (! empty($arrayfields['d.fk_statut']['checked'])) + if (!empty($arrayfields['d.fk_statut']['checked'])) { print '<td class="liste_titre right">'; select_expensereport_statut($search_status, 'search_status', 1, 1); @@ -614,31 +614,31 @@ if ($resql) } // Action column print '<td class="liste_titre maxwidthsearch">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; - if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['user']['checked'])) print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['d.date_debut']['checked'])) print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['d.date_fin']['checked'])) print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['d.date_valid']['checked'])) print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['d.date_approve']['checked'])) print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['d.total_ht']['checked'])) print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['d.total_vat']['checked'])) print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['d.total_ttc']['checked'])) print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['user']['checked'])) print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['d.date_debut']['checked'])) print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['d.date_fin']['checked'])) print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['d.date_valid']['checked'])) print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['d.date_approve']['checked'])) print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['d.total_ht']['checked'])) print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['d.total_vat']['checked'])) print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['d.total_ttc']['checked'])) print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, 'align="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['d.date_create']['checked'])) print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['d.fk_statut']['checked'])) print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['d.date_create']['checked'])) print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['d.fk_statut']['checked'])) print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "</tr>\n"; @@ -646,33 +646,33 @@ if ($resql) $total_total_ttc = 0; $total_total_tva = 0; - $expensereportstatic=new ExpenseReport($db); + $expensereportstatic = new ExpenseReport($db); $usertmp = new User($db); if ($num > 0) { - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $expensereportstatic->id=$obj->rowid; - $expensereportstatic->ref=$obj->ref; - $expensereportstatic->status=$obj->status; - $expensereportstatic->date_debut=$db->jdate($obj->date_debut); - $expensereportstatic->date_fin=$db->jdate($obj->date_fin); - $expensereportstatic->date_create=$db->jdate($obj->date_create); - $expensereportstatic->date_modif=$db->jdate($obj->date_modif); - $expensereportstatic->date_valid=$db->jdate($obj->date_valid); - $expensereportstatic->date_approve=$db->jdate($obj->date_approve); - $expensereportstatic->note_private=$obj->note_private; - $expensereportstatic->note_public=$obj->note_public; + $expensereportstatic->id = $obj->rowid; + $expensereportstatic->ref = $obj->ref; + $expensereportstatic->status = $obj->status; + $expensereportstatic->date_debut = $db->jdate($obj->date_debut); + $expensereportstatic->date_fin = $db->jdate($obj->date_fin); + $expensereportstatic->date_create = $db->jdate($obj->date_create); + $expensereportstatic->date_modif = $db->jdate($obj->date_modif); + $expensereportstatic->date_valid = $db->jdate($obj->date_valid); + $expensereportstatic->date_approve = $db->jdate($obj->date_approve); + $expensereportstatic->note_private = $obj->note_private; + $expensereportstatic->note_public = $obj->note_public; print '<tr class="oddeven">'; // Ref - if (! empty($arrayfields['d.ref']['checked'])) { + if (!empty($arrayfields['d.ref']['checked'])) { print '<td>'; print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<td class="nobordernopadding nowrap">'; @@ -809,8 +809,8 @@ if ($resql) } else { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } @@ -819,8 +819,8 @@ if ($resql) $db->free($resql); - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -830,16 +830,16 @@ if ($resql) if (empty($id)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->expensereport->lire; - $delallowed=$user->rights->expensereport->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->expensereport->lire; + $delallowed = $user->rights->expensereport->creer; print $formfile->showdocuments('massfilesarea_expensereport', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index eeebd317977..9564481eab4 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -32,39 +32,39 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; -if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; +if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'bills', 'interventions')); if (!empty($conf->projet->enabled)) $langs->load("projects"); if (!empty($conf->contrat->enabled)) $langs->load("contracts"); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'interventionlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'interventionlist'; -$search_ref=GETPOST('search_ref')?GETPOST('search_ref', 'alpha'):GETPOST('search_inter', 'alpha'); -$search_company=GETPOST('search_company', 'alpha'); -$search_desc=GETPOST('search_desc', 'alpha'); -$search_projet_ref=GETPOST('search_projet_ref', 'alpha'); -$search_contrat_ref=GETPOST('search_contrat_ref', 'alpha'); -$search_status=GETPOST('search_status', 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST('search_ref') ?GETPOST('search_ref', 'alpha') : GETPOST('search_inter', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$search_projet_ref = GETPOST('search_projet_ref', 'alpha'); +$search_contrat_ref = GETPOST('search_contrat_ref', 'alpha'); +$search_status = GETPOST('search_status', 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $optioncss = GETPOST('optioncss', 'alpha'); -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); // Security check $id = GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); -$diroutputmassaction=$conf->ficheinter->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -72,12 +72,12 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { //if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sortfield="fd.date"; //else - $sortfield="f.ref"; + $sortfield = "f.ref"; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -89,7 +89,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('fichinter'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -98,30 +98,30 @@ $fieldstosearchall = array( 'f.description'=>'Description', 'f.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; -if (! empty($conf->global->FICHINTER_DISABLE_DETAILS)) unset($fieldstosearchall['f.description']); +if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate"; +if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) unset($fieldstosearchall['f.description']); // Definition of fields for list -$arrayfields=array( +$arrayfields = array( 'f.ref'=>array('label'=>'Ref', 'checked'=>1), 's.nom'=>array('label'=>'ThirdParty', 'checked'=>1), - 'pr.ref'=>array('label'=>'Project', 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled)?0:1)), - 'c.ref'=>array('label'=>'Contract', 'checked'=>1, 'enabled'=>(empty($conf->contrat->enabled)?0:1)), + 'pr.ref'=>array('label'=>'Project', 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 'c.ref'=>array('label'=>'Contract', 'checked'=>1, 'enabled'=>(empty($conf->contrat->enabled) ? 0 : 1)), 'f.description'=>array('label'=>'Description', 'checked'=>1), 'f.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>'DateModificationShort', 'checked'=>0, 'position'=>500), 'f.fk_statut'=>array('label'=>'Status', 'checked'=>1, 'position'=>1000), - 'fd.description'=>array('label'=>"DescriptionOfLine", 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0), - 'fd.date'=>array('label'=>'DateOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0), - 'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0), + 'fd.description'=>array('label'=>"DescriptionOfLine", 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), + 'fd.date'=>array('label'=>'DateOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), + 'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), ); // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -132,11 +132,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) @@ -147,19 +147,19 @@ if (empty($reshook)) // 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_ref=""; - $search_company=""; - $search_projet_ref=""; - $search_contrat_ref=""; - $search_desc=""; - $search_status=""; - $toselect=''; - $search_array_options=array(); + $search_ref = ""; + $search_company = ""; + $search_projet_ref = ""; + $search_contrat_ref = ""; + $search_desc = ""; + $search_status = ""; + $toselect = ''; + $search_array_options = array(); } // Mass actions - $objectclass='Fichinter'; - $objectlabel='Interventions'; + $objectclass = 'Fichinter'; + $objectlabel = 'Interventions'; $permissiontoread = $user->rights->ficheinter->lire; $permissiontodelete = $user->rights->ficheinter->supprimer; $uploaddir = $conf->ficheinter->dir_output; @@ -172,29 +172,29 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); $form = new Form($db); $formfile = new FormFile($db); -$objectstatic=new Fichinter($db); -$companystatic=new Societe($db); +$objectstatic = new Fichinter($db); +$companystatic = new Societe($db); if (!empty($conf->projet->enabled)) { - $projetstatic=new Project($db); + $projetstatic = new Project($db); } if (!empty($conf->contrat->enabled)) { - $contratstatic=new Contrat($db); + $contratstatic = new Contrat($db); } -$title=$langs->trans("ListOfInterventions"); +$title = $langs->trans("ListOfInterventions"); llxHeader('', $title); -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$atleastonefieldinlines=0; -foreach($arrayfields as $tmpkey => $tmpval) +$atleastonefieldinlines = 0; +foreach ($arrayfields as $tmpkey => $tmpval) { - if (preg_match('/^fd\./', $tmpkey) && ! empty($arrayfields[$tmpkey]['checked'])) + if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked'])) { $atleastonefieldinlines++; break; @@ -202,9 +202,9 @@ foreach($arrayfields as $tmpkey => $tmpval) } $sql = "SELECT"; -$sql.= " f.ref, f.rowid, f.fk_statut, f.description, f.datec as date_creation, f.tms as date_update, f.note_private,"; -if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql.= "fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,"; -$sql.= " s.nom as name, s.rowid as socid, s.client"; +$sql .= " f.ref, f.rowid, f.fk_statut, f.description, f.datec as date_creation, f.tms as date_update, f.note_private,"; +if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= "fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,"; +$sql .= " s.nom as name, s.rowid as socid, s.client"; if (!empty($conf->projet->enabled)) { $sql .= ", pr.rowid as projet_id, pr.ref as projet_ref, pr.title as projet_title"; } @@ -212,26 +212,26 @@ if (!empty($conf->contrat->enabled)) { $sql .= ", c.rowid as contrat_id, c.ref as contrat_ref, c.ref_customer as contrat_ref_supplier, c.ref_supplier as contrat_ref_supplier"; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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."fichinter as f"; +$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."fichinter as f"; if (!empty($conf->projet->enabled)) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr on f.fk_projet = pr.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr on f.fk_projet = pr.rowid"; } if (!empty($conf->contrat->enabled)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid"; } -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)"; -if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid"; -if (! $user->rights->societe->client->voir && empty($socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ", ".MAIN_DB_PREFIX."societe as s"; -$sql.= " WHERE f.entity IN (".getEntity('intervention').")"; -$sql.= " AND f.fk_soc = s.rowid"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)"; +if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid"; +if (!$user->rights->societe->client->voir && empty($socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= ", ".MAIN_DB_PREFIX."societe as s"; +$sql .= " WHERE f.entity IN (".getEntity('intervention').")"; +$sql .= " AND f.fk_soc = s.rowid"; if ($search_ref) { $sql .= natural_search('f.ref', $search_ref); } @@ -251,20 +251,20 @@ if ($search_desc) { if ($search_status != '' && $search_status >= 0) { $sql .= ' AND f.fk_statut = '.$search_status; } -if (! $user->rights->societe->client->voir && empty($socid)) - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +if (!$user->rights->societe->client->voir && empty($socid)) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) - $sql.= " AND s.rowid = " . $socid; + $sql .= " AND s.rowid = ".$socid; if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -279,15 +279,15 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); if ($socid > 0) { @@ -296,32 +296,32 @@ if ($resql) if (empty($search_company)) $search_company = $soc->name; } - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($socid) $param.="&socid=".urlencode($socid); - if ($search_ref) $param.="&search_ref=".urlencode($search_ref); - if ($search_company) $param.="&search_company=".urlencode($search_company); - if ($search_desc) $param.="&search_desc=".urlencode($search_desc); - if ($search_status != '' && $search_status > -1) $param.="&search_status=".urlencode($search_status); - if ($show_files) $param.='&show_files='.urlencode($show_files); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= "&sall=".urlencode($sall); + if ($socid) $param .= "&socid=".urlencode($socid); + if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); + if ($search_company) $param .= "&search_company=".urlencode($search_company); + if ($search_desc) $param .= "&search_desc=".urlencode($search_desc); + if ($search_status != '' && $search_status > -1) $param .= "&search_status=".urlencode($search_status); + if ($show_files) $param .= '&show_files='.urlencode($show_files); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->ficheinter->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->ficheinter->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; - $morehtmlcenter.= dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fichinter/card.php?action=create', '', $user->rights->ficheinter->creer); + $newcardbutton = ''; + $morehtmlcenter .= dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fichinter/card.php?action=create', '', $user->rights->ficheinter->creer); // Lines of title fields print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; @@ -336,63 +336,63 @@ if ($resql) print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'commercial', 0, $newcardbutton, '', $limit); - $topicmail="Information"; - $modelmail="intervention"; - $objecttmp=new Fichinter($db); - $trackid='int'.$object->id; + $topicmail = "Information"; + $modelmail = "intervention"; + $objecttmp = new Fichinter($db); + $trackid = 'int'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } - $moreforfilter=''; + $moreforfilter = ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<tr class="liste_titre_filter">'; - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">'; print '</td>'; } - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">'; print '</td>'; } - if (! empty($arrayfields['pr.ref']['checked'])) + if (!empty($arrayfields['pr.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_projet_ref" value="'.$search_projet_ref.'" size="8">'; print '</td>'; } - if (! empty($arrayfields['c.ref']['checked'])) + if (!empty($arrayfields['c.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_contrat_ref" value="'.$search_contrat_ref.'" size="8">'; print '</td>'; } - if (! empty($arrayfields['f.description']['checked'])) + if (!empty($arrayfields['f.description']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">'; @@ -402,86 +402,86 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { // Date creation print '<td class="liste_titre">'; print '</td>'; } - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { // Date modification print '<td class="liste_titre">'; print '</td>'; } // Status - if (! empty($arrayfields['f.fk_statut']['checked'])) + if (!empty($arrayfields['f.fk_statut']['checked'])) { print '<td class="liste_titre right">'; - $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short - $liststatus=$objectstatic->statuts_short; - if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 + $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short + $liststatus = $objectstatic->statuts_short; + if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1); print '</td>'; } // Fields of detail line - if (! empty($arrayfields['fd.description']['checked'])) + if (!empty($arrayfields['fd.description']['checked'])) { print '<td class="liste_titre"> </td>'; } - if (! empty($arrayfields['fd.date']['checked'])) + if (!empty($arrayfields['fd.date']['checked'])) { print '<td class="liste_titre"> </td>'; } - if (! empty($arrayfields['fd.duree']['checked'])) + if (!empty($arrayfields['fd.duree']['checked'])) { print '<td class="liste_titre"> </td>'; } print '<td class="liste_titre maxwidthsearch">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; - if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.description']['checked'])) print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.description']['checked'])) print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['fd.description']['checked'])) print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], ''); - if (! empty($arrayfields['fd.date']['checked'])) print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['fd.duree']['checked'])) print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['fd.description']['checked'])) print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], ''); + if (!empty($arrayfields['fd.date']['checked'])) print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['fd.duree']['checked'])) print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; $total = 0; $i = 0; - $totalarray=array(); + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $objectstatic->id=$obj->rowid; - $objectstatic->ref=$obj->ref; - $objectstatic->statut=$obj->fk_statut; + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; + $objectstatic->statut = $obj->fk_statut; print '<tr class="oddeven">'; - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print "<td>"; @@ -491,14 +491,14 @@ if ($resql) print $objectstatic->getNomUrl(1); print '</td>'; // Warning - $warnornote=''; + $warnornote = ''; //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); - if (! empty($obj->note_private)) + if (!empty($obj->note_private)) { - $warnornote.=($warnornote?' ':''); - $warnornote.= '<span class="note">'; - $warnornote.= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>'; - $warnornote.= '</span>'; + $warnornote .= ($warnornote ? ' ' : ''); + $warnornote .= '<span class="note">'; + $warnornote .= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>'; + $warnornote .= '</span>'; } if ($warnornote) { @@ -627,8 +627,8 @@ if ($resql) $db->free($resql); - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -636,16 +636,16 @@ if ($resql) print "</form>\n"; - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->ficheinter->lire; - $delallowed=$user->rights->ficheinter->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->ficheinter->lire; + $delallowed = $user->rights->ficheinter->creer; print $formfile->showdocuments('massfilesarea_interventions', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 4c6e98eda78..9701f43d993 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -41,30 +41,30 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -if (! empty($conf->supplier_proposal->enabled)) - require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; +if (!empty($conf->supplier_proposal->enabled)) + require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; if (!empty($conf->product->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } -$langs->loadLangs(array('admin','orders','sendings','companies','bills','propal','supplier_proposal','deliveries','products','stocks','productbatch')); +$langs->loadLangs(array('admin', 'orders', 'sendings', 'companies', 'bills', 'propal', 'supplier_proposal', 'deliveries', 'products', 'stocks', 'productbatch')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$comclientid = GETPOST('comid', 'int'); -$socid = GETPOST('socid', 'int'); -$projectid = GETPOST('projectid', 'int'); +$comclientid = GETPOST('comid', 'int'); +$socid = GETPOST('socid', 'int'); +$projectid = GETPOST('projectid', 'int'); $cancel = GETPOST('cancel', 'alpha'); $lineid = GETPOST('lineid', 'int'); @@ -73,19 +73,19 @@ $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility //PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); -$datelivraison=dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), GETPOST('liv_sec', 'int'), GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); +$datelivraison = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), GETPOST('liv_sec', 'int'), GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('ordersuppliercard','globalcard')); +$hookmanager->initHooks(array('ordersuppliercard', 'globalcard')); $object = new CommandeFournisseur($db); $extrafields = new ExtraFields($db); @@ -94,58 +94,58 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); if ($ret < 0) dol_print_error($db, $object->error); $ret = $object->fetch_thirdparty(); if ($ret < 0) dol_print_error($db, $object->error); } -elseif (! empty($socid) && $socid > 0) +elseif (!empty($socid) && $socid > 0) { $fourn = new Fournisseur($db); - $ret=$fourn->fetch($socid); + $ret = $fourn->fetch($socid); if ($ret < 0) dol_print_error($db, $object->error); $object->socid = $fourn->id; $ret = $object->fetch_thirdparty(); if ($ret < 0) dol_print_error($db, $object->error); } -$permissionnote=$user->rights->fournisseur->commande->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->fournisseur->commande->creer; // Used by the include of actions_dellink.inc.php -$permissiontoedit=$user->rights->fournisseur->commande->creer; // Used by the include of actions_lineupdown.inc.php -$permissiontoadd=$user->rights->fournisseur->commande->creer; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->rights->fournisseur->commande->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->fournisseur->commande->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->fournisseur->commande->creer; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd = $user->rights->fournisseur->commande->creer; // Used by the include of actions_addupdatedelete.inc.php /* * Actions */ -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; } - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) { - $result=$object->setValueFrom('ref_supplier', GETPOST('ref_supplier', 'alpha'), '', null, 'text', '', $user, 'ORDER_SUPPLIER_MODIFY'); + $result = $object->setValueFrom('ref_supplier', GETPOST('ref_supplier', 'alpha'), '', null, 'text', '', $user, 'ORDER_SUPPLIER_MODIFY'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -159,7 +159,7 @@ if (empty($reshook)) // payment conditions if ($action == 'setconditions' && $user->rights->fournisseur->commande->creer) { - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -183,55 +183,55 @@ if (empty($reshook)) // bank account if ($action == 'setbankaccount' && $user->rights->fournisseur->commande->creer) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // date of delivery if ($action == 'setdate_livraison' && $user->rights->fournisseur->commande->creer) { - $result=$object->set_date_livraison($user, $datelivraison); + $result = $object->set_date_livraison($user, $datelivraison); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Set project - if ($action == 'classin' && $user->rights->fournisseur->commande->creer) + if ($action == 'classin' && $user->rights->fournisseur->commande->creer) { - $result=$object->setProject($projectid); + $result = $object->setProject($projectid); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Edit Thirdparty - if (! empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $action == 'set_thirdparty' && $user->rights->fournisseur->commande->creer && $object->statut == CommandeFournisseur::STATUS_DRAFT) + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $action == 'set_thirdparty' && $user->rights->fournisseur->commande->creer && $object->statut == CommandeFournisseur::STATUS_DRAFT) { $new_socid = GETPOST('new_socid', 'int'); - if(! empty($new_socid) && $new_socid != $object->thirdparty->id) { + if (!empty($new_socid) && $new_socid != $object->thirdparty->id) { $db->begin(); // Update supplier $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; $sql .= ' SET fk_soc='.$new_socid; - $sql.= ' WHERE fk_soc='.$object->thirdparty->id; - $sql.= ' AND rowid='.$object->id; + $sql .= ' WHERE fk_soc='.$object->thirdparty->id; + $sql .= ' AND rowid='.$object->id; $res = $db->query($sql); - if(! $res) $db->rollback(); + if (!$res) $db->rollback(); else { $db->commit(); // Replace prices for each lines by new supplier prices - foreach($object->lines as $l) { + foreach ($object->lines as $l) { $sql = 'SELECT price, unitprice, tva_tx, ref_fourn'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; - $sql.= ' WHERE fk_product='.$l->fk_product; - $sql.= ' AND fk_soc='.$new_socid; - $sql.= ' ORDER BY unitprice ASC'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; + $sql .= ' WHERE fk_product='.$l->fk_product; + $sql .= ' AND fk_soc='.$new_socid; + $sql .= ' ORDER BY unitprice ASC'; $resql = $db->query($sql); - if($resql) { + if ($resql) { $num_row = $db->num_rows($resql); - if(empty($num_row)) { + if (empty($num_row)) { // No product price for this supplier ! $l->subprice = 0; $l->total_ht = 0; @@ -246,7 +246,7 @@ if (empty($reshook)) $l->subprice = $obj->unitprice; $l->total_ht = $obj->price; $l->tva_tx = $obj->tva_tx; - $l->total_tva = $l->total_ht * ($obj->tva_tx/100); + $l->total_tva = $l->total_ht * ($obj->tva_tx / 100); $l->total_ttc = $l->total_ht + $l->total_tva; $l->ref_supplier = $obj->ref_fourn; $l->update(); @@ -274,21 +274,21 @@ if (empty($reshook)) { if (in_array($object->statut, array(1, 2, 3, 4, 5, 6, 7, 9))) { - if ($object->statut == 1) $newstatus=0; // Validated->Draft - elseif ($object->statut == 2) $newstatus=0; // Approved->Draft - elseif ($object->statut == 3) $newstatus=2; // Ordered->Approved - elseif ($object->statut == 4) $newstatus=3; + if ($object->statut == 1) $newstatus = 0; // Validated->Draft + elseif ($object->statut == 2) $newstatus = 0; // Approved->Draft + elseif ($object->statut == 3) $newstatus = 2; // Ordered->Approved + elseif ($object->statut == 4) $newstatus = 3; elseif ($object->statut == 5) { //$newstatus=2; // Ordered // TODO Can we set it to submited ? //$newstatus=3; // Submited // TODO If there is at least one reception, we can set to Received->Received partially - $newstatus=4; // Received partially + $newstatus = 4; // Received partially } - elseif ($object->statut == 6) $newstatus=2; // Canceled->Approved - elseif ($object->statut == 7) $newstatus=3; // Canceled->Process running - elseif ($object->statut == 9) $newstatus=1; // Refused->Validated + elseif ($object->statut == 6) $newstatus = 2; // Canceled->Approved + elseif ($object->statut == 7) $newstatus = 3; // Canceled->Process running + elseif ($object->statut == 9) $newstatus = 1; // Refused->Validated else $newstatus = 2; //print "old status = ".$object->statut.' new status = '.$newstatus; @@ -299,18 +299,18 @@ if (empty($reshook)) { // Currently the "Re-open" also remove the billed flag because there is no button "Set unpaid" yet. $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; - $sql.= ' SET billed = 0'; - $sql.= ' WHERE rowid = '.$object->id; + $sql .= ' SET billed = 0'; + $sql .= ' WHERE rowid = '.$object->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($newstatus == 0) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; - $sql.= ' SET fk_user_approve = null, fk_user_approve2 = null, date_approve = null, date_approve2 = null'; - $sql.= ' WHERE rowid = '.$object->id; + $sql .= ' SET fk_user_approve = null, fk_user_approve2 = null, date_approve = null, date_approve2 = null'; + $sql .= ' WHERE rowid = '.$object->id; - $resql=$db->query($sql); + $resql = $db->query($sql); } $db->commit(); @@ -332,7 +332,7 @@ if (empty($reshook)) */ if ($action == 'classifybilled' && $user->rights->fournisseur->commande->creer) { - $ret=$object->classifyBilled($user); + $ret = $object->classifyBilled($user); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -347,26 +347,26 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $predef = ''; + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $price_ht = ''; $tva_tx = ''; } $qty = GETPOST('qty'.$predef); - $remise_percent=GETPOST('remise_percent'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); $price_ht_devise = GETPOST('multicurrency_price_ht'); // Extrafields @@ -376,31 +376,31 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } - if ($prod_entry_mode =='free' && GETPOST('price_ht') < 0 && $qty < 0) + if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) { setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && ! GETPOST('idprodfournprice') && GETPOST('type') < 0) + if ($prod_entry_mode == 'free' && !GETPOST('idprodfournprice') && GETPOST('type') < 0) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='' && $price_ht_devise === '') // Unit price can be 0 but not '' + if ($prod_entry_mode == 'free' && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') // Unit price can be 0 but not '' { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && ! GETPOST('dp_desc')) + if ($prod_entry_mode == 'free' && !GETPOST('dp_desc')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } - if (! GETPOST('qty')) + if (!GETPOST('qty')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; @@ -415,7 +415,7 @@ if (empty($reshook)) $idprod = $res->fk_product_child; } else { setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors'); - $error ++; + $error++; } } } @@ -427,18 +427,18 @@ if (empty($reshook)) { $productsupplier = new ProductFournisseur($db); - $idprod=0; - if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + $idprod = 0; + if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { - $idprod=$reg[1]; - $res=$productsupplier->fetch($idprod); // Load product from its id + $idprod = $reg[1]; + $res = $productsupplier->fetch($idprod); // Load product from its id // Call to init some price properties of $productsupplier // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price - if (! empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) + if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) { $fksoctosearch = 0; - $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist + $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist if ($productsupplier->fourn_socid != $socid) // The price we found is for another supplier, so we clear supplier price { $productsupplier->ref_supplier = ''; @@ -447,15 +447,15 @@ if (empty($reshook)) else { $fksoctosearch = $object->thirdparty->id; - $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist + $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist } } elseif (GETPOST('idprodfournprice', 'alpha') > 0) { - $qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat. + $qtytosearch = $qty; // Just to see if a price exists for the quantity. Not used to found vat. //$qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist - $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); - $res=$productsupplier->fetch($idprod); + $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); + $res = $productsupplier->fetch($idprod); } if ($idprod > 0) @@ -463,27 +463,27 @@ if (empty($reshook)) $label = $productsupplier->label; // if we use supplier description of the products - if(!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { + if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { $desc = $productsupplier->desc_supplier; } else $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $type = $productsupplier->type; - $price_base_type = ($productsupplier->fourn_price_base_type?$productsupplier->fourn_price_base_type:'HT'); + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); $ref_supplier = $productsupplier->ref_supplier; - $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + $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; - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); + if (empty($tva_tx)) $tva_npr = 0; + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); $pu = $productsupplier->fourn_pu; - if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value + if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value - $result=$object->addline( + $result = $object->addline( $desc, $pu, $qty, @@ -491,7 +491,7 @@ if (empty($reshook)) $localtax1_tx, $localtax2_tx, $idprod, - 0, // We already have the $idprod always defined + 0, // We already have the $idprod always defined $ref_supplier, $remise_percent, $price_base_type, @@ -530,13 +530,13 @@ if (empty($reshook)) $type = GETPOST('type'); $ref_supplier = GETPOST('fourn_ref', 'alpha'); - $fk_unit= GETPOST('units', 'alpha'); + $fk_unit = GETPOST('units', 'alpha'); - $tva_tx = price2num($tva_tx); // When vat is text input field + $tva_tx = price2num($tva_tx); // When vat is text input field // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); if ($price_ht !== '') { @@ -554,11 +554,11 @@ if (empty($reshook)) } //print "xx".$tva_tx; exit; - if (! $error && $result > 0) + if (!$error && $result > 0) { $db->commit(); - $ret=$object->fetch($object->id); // Reload to get new records + $ret = $object->fetch($object->id); // Reload to get new records // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -567,14 +567,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } @@ -622,9 +622,9 @@ if (empty($reshook)) /* * Updating a line in the order */ - if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && ! GETPOST('cancel', 'alpha')) + if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && !GETPOST('cancel', 'alpha')) { - $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + $vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0); if ($lineid) { @@ -634,16 +634,16 @@ if (empty($reshook)) } $productsupplier = new ProductFournisseur($db); - if (! empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) + if (!empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) { - if ($line->fk_product > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid', 'int')) < 0 ) + if ($line->fk_product > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid', 'int')) < 0) { setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); } } - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); // Define info_bits $info_bits = 0; @@ -683,11 +683,11 @@ if (empty($reshook)) // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } - $result = $object->updateline( + $result = $object->updateline( $lineid, $_POST['product_desc'], $ht, @@ -698,7 +698,7 @@ if (empty($reshook)) $localtax2_rate, $price_base_type, 0, - isset($_POST["type"])?$_POST["type"]:$line->product_type, + isset($_POST["type"]) ? $_POST["type"] : $line->product_type, false, $date_start, $date_end, @@ -735,7 +735,7 @@ if (empty($reshook)) unset($_POST['date_endmonth']); unset($_POST['date_endyear']); - if ($result >= 0) + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -744,14 +744,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } } @@ -775,7 +775,7 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -791,19 +791,19 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); /* Fix bug 1485 : Reset action to avoid asking again confirmation on failure */ - $action=''; + $action = ''; } } // Validate if ($action == 'confirm_valid' && $confirm == 'yes' && - ((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))) + ((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))) ) { - $object->date_commande=dol_now(); + $object->date_commande = dol_now(); $result = $object->valid($user); - if ($result >= 0) + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -812,14 +812,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } } @@ -829,40 +829,40 @@ if (empty($reshook)) } // If we have permission, and if we don't need to provide the idwarehouse, we go directly on approved step - if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $user->rights->fournisseur->commande->approuver && ! (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))) + if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $user->rights->fournisseur->commande->approuver && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))) { - $action='confirm_approve'; // can make standard or first level approval also if permission is set + $action = 'confirm_approve'; // can make standard or first level approval also if permission is set } } if (($action == 'confirm_approve' || $action == 'confirm_approve2') && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) { - $idwarehouse=GETPOST('idwarehouse', 'int'); + $idwarehouse = GETPOST('idwarehouse', 'int'); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) // warning name of option should be STOCK_CALCULATE_ON_SUPPLIER_APPROVE_ORDER + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) // warning name of option should be STOCK_CALCULATE_ON_SUPPLIER_APPROVE_ORDER { - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } - if (! $error) + if (!$error) { - $result = $object->approve($user, $idwarehouse, ($action=='confirm_approve2'?1:0)); + $result = $object->approve($user, $idwarehouse, ($action == 'confirm_approve2' ? 1 : 0)); if ($result > 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -870,7 +870,7 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -886,7 +886,7 @@ if (empty($reshook)) } } - if ($action == 'confirm_refuse' && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) + if ($action == 'confirm_refuse' && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) { $result = $object->refuse($user); if ($result > 0) @@ -910,7 +910,7 @@ if (empty($reshook)) } } - if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) + if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) { $result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']); if ($result > 0) @@ -921,7 +921,7 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -940,7 +940,7 @@ if (empty($reshook)) if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->commande->supprimer) { - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { header("Location: ".DOL_URL_ROOT.'/fourn/commande/list.php?restore_lastsearch_values=1'); @@ -955,7 +955,7 @@ if (empty($reshook)) // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer) { - if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } @@ -965,7 +965,7 @@ if (empty($reshook)) { $orig = clone $object; - $result=$object->createFromClone($user, $socid); + $result = $object->createFromClone($user, $socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -975,7 +975,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $object = $orig; - $action=''; + $action = ''; } } } @@ -988,14 +988,14 @@ if (empty($reshook)) { $date_liv = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); - $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); // GETPOST("type") is 'tot', 'par', 'nev', 'can' if ($result > 0) { $langs->load("deliveries"); setEventMessages($langs->trans("DeliveryStateSaved"), null); $action = ''; } - elseif($result == -3) + elseif ($result == -3) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -1010,9 +1010,9 @@ if (empty($reshook)) } } - if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) + if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) { - $result = $object->cancel($user); + $result = $object->cancel($user); if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); @@ -1028,9 +1028,9 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='ORDER_SUPPLIER_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO'; - $trackid='sor'.$object->id; + $trigger_name = 'ORDER_SUPPLIER_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO'; + $trackid = 'sor'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc @@ -1047,12 +1047,12 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); + $result = $object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); if ($result < 0) { $error++; @@ -1070,16 +1070,16 @@ if (empty($reshook)) */ if ($action == 'add' && $user->rights->fournisseur->commande->creer) { - $error=0; + $error = 0; - if ($socid <1) + if ($socid < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } - if (! $error) + if (!$error) { $db->begin(); @@ -1099,16 +1099,16 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid'); // Fill array 'array_options' with data from add form - if (! $error) + if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; } - if (! $error) + if (!$error) { // If creation from another object of another module (Example: origin=propal, originid=1) - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { if ($origin == 'propal' || $origin == 'proposal') { @@ -1133,18 +1133,18 @@ if (empty($reshook)) // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; $other_linked_objects = GETPOST('other_linked_objects', 'array'); - if (! empty($other_linked_objects)) { + if (!empty($other_linked_objects)) { $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); } $id = $object->create($user); if ($id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); if ($result > 0) { @@ -1161,14 +1161,14 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); - for($i = 0; $i < $num; $i ++) + for ($i = 0; $i < $num; $i++) { if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0) continue; - $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); - $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->product_desc); - $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); + $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->product_desc); + $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { @@ -1202,11 +1202,11 @@ if (empty($reshook)) $tva_tx = $lines[$i]->tva_tx; - if ($origin=="commande") + if ($origin == "commande") { - $soc=new societe($db); + $soc = new societe($db); $soc->fetch($socid); - $tva_tx=get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $product_fourn_price_id); + $tva_tx = get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $product_fourn_price_id); } $result = $object->addline( @@ -1253,14 +1253,14 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been if ($reshook < 0) - $error ++; + $error++; } else { setEventMessages($srcobject->error, $srcobject->errors, 'errors'); - $error ++; + $error++; } } else { setEventMessages($object->error, $object->errors, 'errors'); - $error ++; + $error++; } } else @@ -1278,8 +1278,8 @@ if (empty($reshook)) { $langs->load("errors"); $db->rollback(); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; } else { @@ -1290,7 +1290,7 @@ if (empty($reshook)) } } - if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && ! GETPOST('cancel', 'alpha')) + if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && !GETPOST('cancel', 'alpha')) { $ws_url = $object->thirdparty->webservices_url; $ws_key = $object->thirdparty->webservices_key; @@ -1300,8 +1300,8 @@ if (empty($reshook)) $ws_thirdparty = GETPOST('ws_thirdparty', 'int'); // NS and Authentication parameters - $ws_ns='http://www.dolibarr.org/ns/'; - $ws_authentication=array( + $ws_ns = 'http://www.dolibarr.org/ns/'; + $ws_authentication = array( 'dolibarrkey'=>$ws_key, 'sourceapplication'=>'DolibarrWebServiceClient', 'login'=>$ws_user, @@ -1319,12 +1319,12 @@ if (empty($reshook)) } else { //Create SOAP client and connect it to order $soapclient_order = new nusoap_client($ws_url."/webservices/server_order.php"); - $soapclient_order->soap_defencoding='UTF-8'; + $soapclient_order->soap_defencoding = 'UTF-8'; $soapclient_order->decodeUTF8(false); //Create SOAP client and connect it to product/service $soapclient_product = new nusoap_client($ws_url."/webservices/server_productorservice.php"); - $soapclient_product->soap_defencoding='UTF-8'; + $soapclient_product->soap_defencoding = 'UTF-8'; $soapclient_product->decodeUTF8(false); //Prepare the order lines from order @@ -1381,7 +1381,7 @@ if (empty($reshook)) } } - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->commande->creer) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->commande->creer) { if ($action == 'addcontact') { @@ -1413,7 +1413,7 @@ if (empty($reshook)) // bascule du statut d'un contact elseif ($action == 'swapstatut' && $object->id > 0) { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } // Efface un contact @@ -1438,18 +1438,18 @@ if (empty($reshook)) * View */ -$form = new Form($db); +$form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $productstatic = new Product($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } -$help_url='EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; +$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; llxHeader('', $langs->trans("Order"), $help_url); -$now=dol_now(); -if ($action=='create') +$now = dol_now(); +if ($action == 'create') { print load_fiche_titre($langs->trans('NewOrderSupplier')); @@ -1457,18 +1457,18 @@ if ($action=='create') $currency_code = $conf->currency; - $societe=''; - if ($socid>0) + $societe = ''; + if ($socid > 0) { - $societe=new Societe($db); + $societe = new Societe($db); $societe->fetch($socid); } - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; - $regs=array(); + $regs = array(); if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { $element = $regs[1]; $subelement = $regs[2]; @@ -1491,7 +1491,7 @@ if ($action=='create') $subelement = 'supplier_proposal'; } - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $objectsrc = new $classname($db); $objectsrc->fetch($originid); @@ -1503,21 +1503,21 @@ if ($action=='create') $objectsrc->fetch_optionals($originid); $object->array_options = $objectsrc->array_options; - $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); - $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); + $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); + $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); $soc = $objectsrc->client; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); - $shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0)); - $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0)); + $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0)); + $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0)); + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; - $datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); + $datedelivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); if (!empty($conf->multicurrency->enabled)) { @@ -1525,11 +1525,11 @@ if ($action=='create') if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; } - $note_private = $object->getDefaultCreateValueFor('note_private', (! empty($objectsrc->note_private) ? $objectsrc->note_private : null)); - $note_public = $object->getDefaultCreateValueFor('note_public', (! empty($objectsrc->note_public) ? $objectsrc->note_public : null)); + $note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null)); + $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null)); // Object source contacts list - $srccontactslist = $objectsrc->liste_contact(- 1, 'external', 1); + $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); } else { @@ -1543,17 +1543,17 @@ if ($action=='create') } // If not defined, set default value from constant - if (empty($cond_reglement_id) && ! empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID)) $cond_reglement_id=$conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID; - if (empty($mode_reglement_id) && ! empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID)) $mode_reglement_id=$conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID; + if (empty($cond_reglement_id) && !empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID)) $cond_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID; + if (empty($mode_reglement_id) && !empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID)) $mode_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID; print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="add">'; - print '<input type="hidden" name="socid" value="' . $soc->id . '">' . "\n"; - print '<input type="hidden" name="remise_percent" value="' . $soc->remise_supplier_percent . '">'; - print '<input type="hidden" name="origin" value="' . $origin . '">'; - print '<input type="hidden" name="originid" value="' . $originid . '">'; - if (!empty($currency_tx)) print '<input type="hidden" name="originmulticurrency_tx" value="' . $currency_tx . '">'; + print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n"; + print '<input type="hidden" name="remise_percent" value="'.$soc->remise_supplier_percent.'">'; + print '<input type="hidden" name="origin" value="'.$origin.'">'; + print '<input type="hidden" name="originid" value="'.$originid.'">'; + if (!empty($currency_tx)) print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">'; dol_fiche_head(''); @@ -1573,7 +1573,7 @@ if ($action=='create') } else { - print $form->select_company((empty($socid)?'':$socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + print $form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { @@ -1594,13 +1594,13 @@ if ($action=='create') if ($societe->id > 0) { // Discounts for third party - print '<tr><td>' . $langs->trans('Discounts') . '</td><td>'; + print '<tr><td>'.$langs->trans('Discounts').'</td><td>'; $absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1); $thirdparty = $societe; $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '</td></tr>'; @@ -1614,12 +1614,12 @@ if ($action=='create') // Payment term print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; - $form->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id, 'cond_reglement_id'); + $form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); print '</td></tr>'; // Payment mode print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">'; - $form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id, 'mode_reglement_id'); + $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); print '</td></tr>'; // Planned delivery date @@ -1627,29 +1627,29 @@ if ($action=='create') print $langs->trans('DateDeliveryPlanned'); print '</td>'; print '<td>'; - $usehourmin=0; - if (! empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin=1; - print $form->selectDate($datelivraison?$datelivraison:-1, 'liv_', $usehourmin, $usehourmin, '', "set"); + $usehourmin = 0; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 1; + print $form->selectDate($datelivraison ? $datelivraison : -1, 'liv_', $usehourmin, $usehourmin, '', "set"); print '</td></tr>'; // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && ! empty($conf->banque->enabled)) + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) { $langs->load("bank"); - print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">'; + print '<tr><td>'.$langs->trans('BankAccount').'</td><td colspan="2">'; $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print '</td></tr>'; } // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); $langs->load('projects'); - print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">'; - $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); - print '   <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$societe->id).'"><span class="valignmiddle text-plus-circle">' . $langs->trans("AddProject") . '</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; + print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">'; + $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1); + print '   <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$societe->id).'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; print '</td></tr>'; } @@ -1660,12 +1660,12 @@ if ($action=='create') print '<tr>'; print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $object->label_incoterms, 1).'</label></td>'; print '<td colspan="3" class="maxwidthonsmartphone">'; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:'')); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print '</td></tr>'; } // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print '<tr>'; print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>'; @@ -1690,42 +1690,42 @@ if ($action=='create') //print '<td><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea></td>'; print '</tr>'; - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { - print "\n<!-- " . $classname . " info -->"; + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { + print "\n<!-- ".$classname." info -->"; print "\n"; - print '<input type="hidden" name="amount" value="' . $objectsrc->total_ht . '">' . "\n"; - print '<input type="hidden" name="total" value="' . $objectsrc->total_ttc . '">' . "\n"; - print '<input type="hidden" name="tva" value="' . $objectsrc->total_tva . '">' . "\n"; - print '<input type="hidden" name="origin" value="' . $objectsrc->element . '">'; - print '<input type="hidden" name="originid" value="' . $objectsrc->id . '">'; + print '<input type="hidden" name="amount" value="'.$objectsrc->total_ht.'">'."\n"; + print '<input type="hidden" name="total" value="'.$objectsrc->total_ttc.'">'."\n"; + print '<input type="hidden" name="tva" value="'.$objectsrc->total_tva.'">'."\n"; + print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">'; + print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">'; $newclassname = $classname; - print '<tr><td>' . $langs->trans($newclassname) . '</td><td colspan="2">' . $objectsrc->getNomUrl(1) . '</td></tr>'; - print '<tr><td>' . $langs->trans('AmountHT') . '</td><td colspan="2">' . price($objectsrc->total_ht) . '</td></tr>'; - print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td colspan="2">' . price($objectsrc->total_tva) . "</td></tr>"; + print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>'; + print '<tr><td>'.$langs->trans('AmountHT').'</td><td colspan="2">'.price($objectsrc->total_ht).'</td></tr>'; + print '<tr><td>'.$langs->trans('AmountVAT').'</td><td colspan="2">'.price($objectsrc->total_tva)."</td></tr>"; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE { - print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax1) . "</td></tr>"; + print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td><td colspan="2">'.price($objectsrc->total_localtax1)."</td></tr>"; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF { - print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax2) . "</td></tr>"; + print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td><td colspan="2">'.price($objectsrc->total_localtax2)."</td></tr>"; } - print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc) . "</td></tr>"; + print '<tr><td>'.$langs->trans('AmountTTC').'</td><td colspan="2">'.price($objectsrc->total_ttc)."</td></tr>"; if (!empty($conf->multicurrency->enabled)) { - print '<tr><td>' . $langs->trans('MulticurrencyAmountHT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ht) . '</td></tr>'; - print '<tr><td>' . $langs->trans('MulticurrencyAmountVAT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_tva) . '</td></tr>'; - print '<tr><td>' . $langs->trans('MulticurrencyAmountTTC') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ttc) . '</td></tr>'; + print '<tr><td>'.$langs->trans('MulticurrencyAmountHT').'</td><td colspan="2">'.price($objectsrc->multicurrency_total_ht).'</td></tr>'; + print '<tr><td>'.$langs->trans('MulticurrencyAmountVAT').'</td><td colspan="2">'.price($objectsrc->multicurrency_total_tva).'</td></tr>'; + print '<tr><td>'.$langs->trans('MulticurrencyAmountTTC').'</td><td colspan="2">'.price($objectsrc->multicurrency_total_ttc).'</td></tr>'; } } // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) @@ -1741,13 +1741,13 @@ if ($action=='create') print '<div class="center">'; print '<input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'">'; print '     '; - print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; + print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; print '</div>'; print "</form>\n"; // Show origin lines - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); @@ -1759,30 +1759,30 @@ if ($action=='create') print '</table>'; } } -elseif (! empty($object->id)) +elseif (!empty($object->id)) { $result = $object->fetch($id, $ref); $societe = new Fournisseur($db); - $result=$societe->fetch($object->socid); + $result = $societe->fetch($object->socid); if ($result < 0) dol_print_error($db); - $author = new User($db); + $author = new User($db); $author->fetch($object->user_author_id); - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); $head = ordersupplier_prepare_head($object); - $title=$langs->trans("SupplierOrder"); + $title = $langs->trans("SupplierOrder"); dol_fiche_head($head, 'card', $title, -1, 'order'); - $formconfirm=''; + $formconfirm = ''; // Confirmation de la suppression de la commande - if ($action == 'delete') + if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 2); } @@ -1791,17 +1791,17 @@ elseif (! empty($object->id)) if ($action == 'clone') { // Create an array for form - $formquestion=array( - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.fournisseur=1)')) + $formquestion = array( + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.fournisseur=1)')) ); // Paiement incomplet. On demande si motif = escompte ou autre $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Confirmation de la validation - if ($action == 'valid') + if ($action == 'valid') { - $object->date_commande=dol_now(); + $object->date_commande = dol_now(); // We check if number is temporary number if (preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) // empty should not happened, but when it occurs, the test save life @@ -1813,17 +1813,17 @@ elseif (! empty($object->id)) if ($newref < 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } else { - $text=$langs->trans('ConfirmValidateOrder', $newref); - if (! empty($conf->notification->enabled)) + $text = $langs->trans('ConfirmValidateOrder', $newref); + if (!empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; - $notify=new Notify($db); - $text.='<br>'; - $text.=$notify->confirmMessage('ORDER_SUPPLIER_VALIDATE', $object->socid, $object); + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '<br>'; + $text .= $notify->confirmMessage('ORDER_SUPPLIER_VALIDATE', $object->socid, $object); } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_valid', '', 0, 1); @@ -1831,59 +1831,59 @@ elseif (! empty($object->id)) } // Confirm approval - if ($action == 'approve' || $action == 'approve2') + if ($action == 'approve' || $action == 'approve2') { - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } - $formquestion=array(); - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) + $formquestion = array(); + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct=new FormProduct($db); - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $formquestion=array( + $formproduct = new FormProduct($db); + $forcecombo = 0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( //'text' => $langs->trans("ConfirmClone"), //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse', 'int'), 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse', 'int'), 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) ); } - $text=$langs->trans("ConfirmApproveThisOrder", $object->ref); - if (! empty($conf->notification->enabled)) + $text = $langs->trans("ConfirmApproveThisOrder", $object->ref); + if (!empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; - $notify=new Notify($db); - $text.='<br>'; - $text.=$notify->confirmMessage('ORDER_SUPPLIER_APPROVE', $object->socid, $object); + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '<br>'; + $text .= $notify->confirmMessage('ORDER_SUPPLIER_APPROVE', $object->socid, $object); } $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ApproveThisOrder"), $text, "confirm_".$action, $formquestion, 1, 1, 240); } // Confirmation de la desapprobation - if ($action == 'refuse') + if ($action == 'refuse') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DenyingThisOrder"), $langs->trans("ConfirmDenyingThisOrder", $object->ref), "confirm_refuse", '', 0, 1); } // Confirmation de l'annulation - if ($action == 'cancel') + if ($action == 'cancel') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("Cancel"), $langs->trans("ConfirmCancelThisOrder", $object->ref), "confirm_cancel", '', 0, 1); } // Confirmation de l'envoi de la commande - if ($action == 'commande') + if ($action == 'commande') { $date_com = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]), $langs->trans("MakeOrder"), $langs->trans("ConfirmMakeOrder", dol_print_date($date_com, 'day')), "confirm_commande", '', 0, 2); @@ -1897,10 +1897,10 @@ elseif (! empty($object->id)) if (!$formconfirm) { - $parameters=array('lineid'=>$lineid); + $parameters = array('lineid'=>$lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; } // Print form confirm @@ -1909,56 +1909,56 @@ elseif (! empty($object->id)) // Supplier order card - $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; + $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; - $morehtmlref='<div class="refidno">'; + $morehtmlref = '<div class="refidno">'; // Ref supplier - $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='<br>'.$langs->trans('ThirdParty'); - if(! empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && ! empty($user->rights->fournisseur->commande->creer) && $action == 'edit_thirdparty') { + $morehtmlref .= '<br>'.$langs->trans('ThirdParty'); + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && !empty($user->rights->fournisseur->commande->creer) && $action == 'edit_thirdparty') { $morehtmlref .= ' : '; - $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">'; + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref .= '<input type="hidden" name="action" value="set_thirdparty">'; - $morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $morehtmlref .= $form->select_company($object->thirdparty->id, 'new_socid', 's.fournisseur=1', '', 0, 0, array(), 0, 'minwidth300'); - $morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">'; + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= '</form>'; } - if(empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) || $action != 'edit_thirdparty') { - if(! empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $object->statut == CommandeFournisseur::STATUS_DRAFT) { - $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=edit_thirdparty&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetThirdParty')) . '</a>'; + if (empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) || $action != 'edit_thirdparty') { + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $object->statut == CommandeFournisseur::STATUS_DRAFT) { + $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=edit_thirdparty&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetThirdParty')).'</a>'; } $morehtmlref .= ' : '.$object->thirdparty->getNomUrl(1); - if(empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="' . DOL_URL_ROOT . '/fourn/commande/list.php?socid=' . $object->thirdparty->id . '&search_company=' . urlencode($object->thirdparty->name) . '">' . $langs->trans("OtherOrders") . '</a>)'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)'; } // Project - if(!empty($conf->projet->enabled)) { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref .= '<br>' . $langs->trans('Project') . ' '; - if($user->rights->fournisseur->commande->creer) { - if($action != 'classify') - $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; - if($action == 'classify') { + $morehtmlref .= '<br>'.$langs->trans('Project').' '; + if ($user->rights->fournisseur->commande->creer) { + if ($action != 'classify') + $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; + if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">'; + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref .= '<input type="hidden" name="action" value="classin">'; - $morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">'; + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= '</form>'; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if(!empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; + $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; $morehtmlref .= $proj->ref; $morehtmlref .= '</a>'; } @@ -1967,7 +1967,7 @@ elseif (! empty($object->id)) } } } - $morehtmlref.='</div>'; + $morehtmlref .= '</div>'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -2001,7 +2001,7 @@ elseif (! empty($object->id)) print '</tr>'; // Relative and absolute discounts - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -2014,11 +2014,11 @@ elseif (! empty($object->id)) $absolute_discount = price2num($absolute_discount, 'MT'); $absolute_creditnote = price2num($absolute_creditnote, 'MT'); - print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>'; + print '<tr><td class="titlefield">'.$langs->trans('Discounts').'</td><td>'; $thirdparty = $societe; $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '</td></tr>'; @@ -2063,7 +2063,7 @@ elseif (! empty($object->id)) print '</td></tr>'; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print '<tr>'; @@ -2072,13 +2072,13 @@ elseif (! empty($object->id)) print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print '</td>'; if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencycode&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencycode&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; print '</tr></table>'; print '</td><td>'; if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); } print '</td></tr>'; @@ -2092,16 +2092,16 @@ elseif (! empty($object->id)) print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print '</td>'; if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencyrate&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; print '</tr></table>'; print '</td><td>'; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - if($action == 'actualizemulticurrencyrate') { + if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '<div class="inline-block">         '; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>'; @@ -2113,7 +2113,7 @@ elseif (! empty($object->id)) } // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && ! empty($conf->banque->enabled)) + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) { print '<tr><td class="nowrap">'; print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">'; @@ -2145,18 +2145,18 @@ elseif (! empty($object->id)) print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="setdate_livraison">'; - $usehourmin=0; - if (! empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin=1; - print $form->selectDate($object->date_livraison?$object->date_livraison:-1, 'liv_', $usehourmin, $usehourmin, '', "setdate_livraison"); + $usehourmin = 0; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 1; + print $form->selectDate($object->date_livraison ? $object->date_livraison : -1, 'liv_', $usehourmin, $usehourmin, '', "setdate_livraison"); print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '</form>'; } else { - $usehourmin='day'; - if (! empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour'; + $usehourmin = 'day'; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 'dayhour'; print $object->date_livraison ? dol_print_date($object->date_livraison, $usehourmin) : ' '; - if ($object->hasDelay() && ! empty($object->date_livraison)) { + if ($object->hasDelay() && !empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } @@ -2186,13 +2186,13 @@ elseif (! empty($object->id)) } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print '</td></tr>'; } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '</table>'; @@ -2206,25 +2206,25 @@ elseif (! empty($object->id)) if (!empty($conf->multicurrency->enabled)) { // Multicurrency Amount HT - print '<tr><td class="titlefieldmiddle">' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . '</td>'; - print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>'; + print '<td class="nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount VAT - print '<tr><td>' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . '</td>'; - print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>'; + print '<td class="nowrap">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount TTC - print '<tr><td>' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . '</td>'; - print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>'; + print '<td class="nowrap">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; } // Total $alert = ''; - if (! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->supplier_order_min_amount) { - $alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->supplier_order_min_amount)); + if (!empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->supplier_order_min_amount) { + $alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->supplier_order_min_amount)); } print '<tr><td class="titlefieldmiddle">'.$langs->trans("AmountHT").'</td>'; print '<td>'.price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency).$alert.'</td>'; @@ -2235,13 +2235,13 @@ elseif (! empty($object->id)) print '</tr>'; // Amount Local Taxes - if ($mysoc->localtax1_assuj=="1" || $object->total_localtax1 != 0) //Localtax1 + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) //Localtax1 { print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>'; print '<td>'.price($object->total_localtax1, '', $langs, 1, -1, -1, $conf->currency).'</td>'; print '</tr>'; } - if ($mysoc->localtax2_assuj=="1" || $object->total_localtax2 != 0) //Localtax2 + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) //Localtax2 { print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>'; print '<td>'.price($object->total_localtax2, '', $langs, 1, -1, -1, $conf->currency).'</td>'; @@ -2266,14 +2266,14 @@ elseif (! empty($object->id)) print '<div class="clearboth"></div><br>'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); @@ -2286,16 +2286,16 @@ elseif (! empty($object->id)) //$result = $object->getLinesArray(); - print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline')?'#addline':'#line_'.GETPOST('lineid')).'" method="POST"> + print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid')).'" method="POST"> <input type="hidden" name="token" value="'.$_SESSION['newtoken'].'"> - <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '"> + <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'"> <input type="hidden" name="mode" value=""> <input type="hidden" name="id" value="'.$object->id.'"> <input type="hidden" name="socid" value="'.$societe->id.'"> '; - if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '<div class="div-table-responsive-no-min">'; @@ -2303,13 +2303,13 @@ elseif (! empty($object->id)) // Add free products/services form global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; - $forceall=1; $dateSelector=0; $inputalsopricewithtax=1; - $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. + $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1; + $senderissupplier = 2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. //if (! empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) $senderissupplier=2; - if (! empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; + if (!empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier = 1; // Show object lines - if (! empty($object->lines)) + if (!empty($object->lines)) $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); $num = count($object->lines); @@ -2345,15 +2345,15 @@ elseif (! empty($object->id)) // modified by hook if (empty($reshook)) { - $object->fetchObjectLinked(); // Links are used to show or not button, so we load them now. + $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'); + $tmpbuttonlabel = $langs->trans('Validate'); if ($user->rights->fournisseur->commande->approuver && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid">'; @@ -2381,7 +2381,7 @@ elseif (! empty($object->id)) { 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)) + 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 '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("FirstApprovalAlreadyDone")).'">'.$langs->trans("ApproveOrder").'</a>'; } @@ -2397,13 +2397,13 @@ elseif (! empty($object->id)) } // 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 (!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 == CommandeFournisseur::STATUS_VALIDATED) { if ($user->rights->fournisseur->commande->approve2) { - if (! empty($object->user_approve_id2)) + if (!empty($object->user_approve_id2)) { print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("SecondApprovalAlreadyDone")).'">'.$langs->trans("Approve2Order").'</a>'; } @@ -2444,20 +2444,20 @@ elseif (! empty($object->id)) // Reopen if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED))) { - $buttonshown=0; - if (! $buttonshown && $user->rights->fournisseur->commande->approuver) + $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)) + || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id)) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Disapprove").'</a>'; $buttonshown++; } } - if (! $buttonshown && $user->rights->fournisseur->commande->approve2 && ! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) + 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)) + || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Disapprove").'</a>'; } @@ -2473,13 +2473,13 @@ elseif (! empty($object->id)) // 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 (!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 (in_array($object->statut, array(3, 4, 5))) { if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->receptionner) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/fourn/commande/dispatch.php?id=' . $object->id . '">' . $langs->trans('ReceiveProducts') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id.'">'.$langs->trans('ReceiveProducts').'</a></div>'; } else { - print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('ReceiveProducts') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('ReceiveProducts').'</a></div>'; } } } @@ -2508,7 +2508,7 @@ elseif (! empty($object->id)) // 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 (!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) { @@ -2541,7 +2541,7 @@ elseif (! empty($object->id)) } // Create a remote order using WebService only if module is activated - if (! empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted + if (!empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=webservice&mode=init">'.$langs->trans('CreateRemoteOrder').'</a>'; } @@ -2562,7 +2562,7 @@ elseif (! empty($object->id)) } // Delete - if (! empty($user->rights->fournisseur->commande->supprimer) || ($object->statut == CommandeFournisseur::STATUS_DRAFT && ! empty($user->rights->fournisseur->commande->creer))) + if (!empty($user->rights->fournisseur->commande->supprimer) || ($object->statut == CommandeFournisseur::STATUS_DRAFT && !empty($user->rights->fournisseur->commande->creer))) { print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>'; } @@ -2585,7 +2585,7 @@ elseif (! empty($object->id)) //print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ToOrder").'</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans("OrderDate").'</td><td>'; $date_com = dol_mktime(GETPOST('rehour', 'int'), GETPOST('remin', 'int'), GETPOST('resec', 'int'), GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($date_com)) $date_com=dol_now(); + if (empty($date_com)) $date_com = dol_now(); print $form->selectDate($date_com, '', 1, 1, '', "commande", 1, 1); print '</td></tr>'; @@ -2612,25 +2612,25 @@ elseif (! empty($object->id)) // Generated documents $comfournref = dol_sanitizeFileName($object->ref); - $file = $conf->fournisseur->dir_output . '/commande/' . $comfournref . '/' . $comfournref . '.pdf'; - $relativepath = $comfournref.'/'.$comfournref.'.pdf'; - $filedir = $conf->fournisseur->dir_output . '/commande/' . $comfournref; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$user->rights->fournisseur->commande->lire; - $delallowed=$user->rights->fournisseur->commande->creer; + $file = $conf->fournisseur->dir_output.'/commande/'.$comfournref.'/'.$comfournref.'.pdf'; + $relativepath = $comfournref.'/'.$comfournref.'.pdf'; + $filedir = $conf->fournisseur->dir_output.'/commande/'.$comfournref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->fournisseur->commande->lire; + $delallowed = $user->rights->fournisseur->commande->creer; print $formfile->showdocuments('commande_fournisseur', $comfournref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 0, 0, '', '', '', $object->thirdparty->default_lang); - $somethingshown=$formfile->numoffiles; + $somethingshown = $formfile->numoffiles; // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('supplier_order','order_supplier')); + $linktoelem = $form->showLinkToObjectBlock($object, null, array('supplier_order', 'order_supplier')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); print '</div><div class="fichehalfright"><div class="ficheaddleft">'; if ($action == 'classifyreception') { - if ($user->rights->fournisseur->commande->receptionner && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) + if ($user->rights->fournisseur->commande->receptionner && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) { // Set status to received (action=livraison) print '<!-- form to record purchase order received -->'."\n"; @@ -2667,8 +2667,8 @@ elseif (! empty($object->id)) // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - $somethingshown = $formactions->showactions($object, 'order_supplier', $socid, 1, 'listaction'.($genallowed?'largetitle':'')); + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'order_supplier', $socid, 1, 'listaction'.($genallowed ? 'largetitle' : '')); print '</div></div></div>'; } @@ -2676,7 +2676,7 @@ elseif (! empty($object->id)) /* * Action webservice */ - if ($action == 'webservice' && GETPOST('mode', 'alpha') != "send" && ! GETPOST('cancel', 'alpha')) + if ($action == 'webservice' && GETPOST('mode', 'alpha') != "send" && !GETPOST('cancel', 'alpha')) { $mode = GETPOST('mode', 'alpha'); $ws_url = $object->thirdparty->webservices_url; @@ -2750,7 +2750,7 @@ elseif (! empty($object->id)) //Create SOAP client and connect it to user $soapclient_user = new nusoap_client($ws_url."/webservices/server_user.php"); - $soapclient_user->soap_defencoding='UTF-8'; + $soapclient_user->soap_defencoding = 'UTF-8'; $soapclient_user->decodeUTF8(false); //Get the thirdparty associated to user @@ -2773,7 +2773,7 @@ elseif (! empty($object->id)) { //Create SOAP client and connect it to product/service $soapclient_product = new nusoap_client($ws_url."/webservices/server_productorservice.php"); - $soapclient_product->soap_defencoding='UTF-8'; + $soapclient_product->soap_defencoding = 'UTF-8'; $soapclient_product->decodeUTF8(false); // Iterate each line and get the reference that uses the supplier of that product/service @@ -2821,9 +2821,9 @@ elseif (! empty($object->id)) $product_fourn = new ProductFournisseur($db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($line->fk_product); - if (count($product_fourn_list)>0) + if (count($product_fourn_list) > 0) { - foreach($product_fourn_list as $product_fourn_line) + foreach ($product_fourn_list as $product_fourn_line) { //Only accept the line where the supplier is the same at this order and has the same ref if ($product_fourn_line->fourn_id == $object->socid && $product_fourn_line->fourn_ref == $ref_supplier) { @@ -2888,10 +2888,10 @@ elseif (! empty($object->id)) } // Presend form - $modelmail='order_supplier_send'; - $defaulttopic='SendOrderRef'; + $modelmail = 'order_supplier_send'; + $defaulttopic = 'SendOrderRef'; $diroutput = $conf->fournisseur->commande->dir_output; - $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO'; $trackid = 'sor'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 197d4562114..4582f76c8a6 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -42,61 +42,61 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -$langs->loadLangs(array("orders","sendings",'deliveries','companies','compta','bills','projects','suppliers')); +$langs->loadLangs(array("orders", "sendings", 'deliveries', 'companies', 'compta', 'bills', 'projects', 'suppliers')); -$action=GETPOST('action', 'aZ09'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'supplierorderlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierorderlist'; -$search_orderyear=GETPOST("search_orderyear", "int"); -$search_ordermonth=GETPOST("search_ordermonth", "int"); -$search_orderday=GETPOST("search_orderday", "int"); -$search_deliveryyear=GETPOST("search_deliveryyear", "int"); -$search_deliverymonth=GETPOST("search_deliverymonth", "int"); -$search_deliveryday=GETPOST("search_deliveryday", "int"); +$search_orderyear = GETPOST("search_orderyear", "int"); +$search_ordermonth = GETPOST("search_ordermonth", "int"); +$search_orderday = GETPOST("search_orderday", "int"); +$search_deliveryyear = GETPOST("search_deliveryyear", "int"); +$search_deliverymonth = GETPOST("search_deliverymonth", "int"); +$search_deliveryday = GETPOST("search_deliveryday", "int"); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_ref=GETPOST('search_ref', 'alpha'); -$search_refsupp=GETPOST('search_refsupp', 'alpha'); -$search_company=GETPOST('search_company', 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state", 'alpha')); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_user=GETPOST('search_user', 'int'); -$search_request_author=GETPOST('search_request_author', 'alpha'); -$search_ht=GETPOST('search_ht', 'alpha'); -$search_ttc=GETPOST('search_ttc', 'alpha'); -$search_status=(GETPOST('search_status', 'alpha')!=''?GETPOST('search_status', 'alpha'):GETPOST('statut', 'alpha')); // alpha and not intbecause it can be '6,7' +$search_product_category = GETPOST('search_product_category', 'int'); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_refsupp = GETPOST('search_refsupp', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state", 'alpha')); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_user = GETPOST('search_user', 'int'); +$search_request_author = GETPOST('search_request_author', 'alpha'); +$search_ht = GETPOST('search_ht', 'alpha'); +$search_ttc = GETPOST('search_ttc', 'alpha'); +$search_status = (GETPOST('search_status', 'alpha') != '' ?GETPOST('search_status', 'alpha') : GETPOST('statut', 'alpha')); // alpha and not intbecause it can be '6,7' $optioncss = GETPOST('optioncss', 'alpha'); $socid = GETPOST('socid', 'int'); -$search_sale=GETPOST('search_sale', 'int'); -$search_total_ht=GETPOST('search_total_ht', 'alpha'); -$search_total_vat=GETPOST('search_total_vat', 'alpha'); -$search_total_ttc=GETPOST('search_total_ttc', 'alpha'); +$search_sale = GETPOST('search_sale', 'int'); +$search_total_ht = GETPOST('search_total_ht', 'alpha'); +$search_total_vat = GETPOST('search_total_vat', 'alpha'); +$search_total_ttc = GETPOST('search_total_ttc', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $search_billed = GETPOST('search_billed', 'int'); -$search_project_ref=GETPOST('search_project_ref', 'alpha'); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); -$status=GETPOST('statut', 'alpha'); -$viewstatut=GETPOST('viewstatut'); +$status = GETPOST('statut', 'alpha'); +$viewstatut = GETPOST('viewstatut'); // Security check $orderid = GETPOST('orderid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); -$diroutputmassaction=$conf->fournisseur->commande->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -104,10 +104,10 @@ if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='cf.ref'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'cf.ref'; +if (!$sortorder) $sortorder = 'DESC'; -if ($search_status == '') $search_status=-1; +if ($search_status == '') $search_status = -1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new CommandeFournisseur($db); @@ -117,7 +117,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('commande_fournisseur'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -127,10 +127,10 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'cf.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["cf.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["cf.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'cf.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'cf.ref_supplier'=>array('label'=>$langs->trans("RefOrderSupplierShort"), 'checked'=>1, 'enabled'=>1), 'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>1), @@ -154,10 +154,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -169,11 +169,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) @@ -184,45 +184,45 @@ if (empty($reshook)) // 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_categ=''; - $search_user=''; - $search_sale=''; - $search_product_category=''; - $search_ref=''; - $search_refsupp=''; - $search_company=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_request_author=''; - $search_total_ht=''; - $search_total_vat=''; - $search_total_ttc=''; - $search_project_ref=''; - $search_status=-1; - $search_orderyear=''; - $search_ordermonth=''; - $search_orderday=''; - $search_deliveryday=''; - $search_deliverymonth=''; - $search_deliveryyear=''; - $billed=''; - $search_billed=''; - $toselect=''; - $search_array_options=array(); + $search_categ = ''; + $search_user = ''; + $search_sale = ''; + $search_product_category = ''; + $search_ref = ''; + $search_refsupp = ''; + $search_company = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_request_author = ''; + $search_total_ht = ''; + $search_total_vat = ''; + $search_total_ttc = ''; + $search_project_ref = ''; + $search_status = -1; + $search_orderyear = ''; + $search_ordermonth = ''; + $search_orderday = ''; + $search_deliveryday = ''; + $search_deliverymonth = ''; + $search_deliveryyear = ''; + $billed = ''; + $search_billed = ''; + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='CommandeFournisseur'; - $objectlabel='SupplierOrders'; + $objectclass = 'CommandeFournisseur'; + $objectlabel = 'SupplierOrders'; $permissiontoread = $user->rights->fournisseur->commande->lire; $permissiontodelete = $user->rights->fournisseur->commande->supprimer; $uploaddir = $conf->fournisseur->commande->dir_output; @@ -242,18 +242,18 @@ if (empty($reshook)) $db->begin(); - foreach($orders as $id_order) { + foreach ($orders as $id_order) { $cmd = new Commande($db); - if($cmd->fetch($id_order) <= 0) continue; + if ($cmd->fetch($id_order) <= 0) continue; $object = new Facture($db); - if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. + if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. else { $object->socid = $cmd->socid; $object->type = Facture::TYPE_STANDARD; $object->cond_reglement_id = $cmd->cond_reglement_id; $object->mode_reglement_id = $cmd->mode_reglement_id; - $object->fk_project = $cmd->fk_project; + $object->fk_project = $cmd->fk_project; $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datefacture)) @@ -267,29 +267,29 @@ if (empty($reshook)) $res = $object->create($user); - if($res > 0) $nb_bills_created++; + if ($res > 0) $nb_bills_created++; } if ($object->id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sql.= "fk_source"; - $sql.= ", sourcetype"; - $sql.= ", fk_target"; - $sql.= ", targettype"; - $sql.= ") VALUES ("; - $sql.= $id_order; - $sql.= ", '".$object->origin."'"; - $sql.= ", ".$object->id; - $sql.= ", '".$object->element."'"; - $sql.= ")"; + $sql .= "fk_source"; + $sql .= ", sourcetype"; + $sql .= ", fk_target"; + $sql .= ", targettype"; + $sql .= ") VALUES ("; + $sql .= $id_order; + $sql .= ", '".$object->origin."'"; + $sql .= ", ".$object->id; + $sql .= ", '".$object->element."'"; + $sql .= ")"; - if (! $db->query($sql)) + if (!$db->query($sql)) { $erorr++; } - if (! $error) + if (!$error) { $lines = $cmd->lines; if (empty($lines) && method_exists($cmd, 'fetch_lines')) @@ -298,27 +298,27 @@ if (empty($reshook)) $lines = $cmd->lines; } - $fk_parent_line=0; - $num=count($lines); + $fk_parent_line = 0; + $num = count($lines); - for ($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); - $discount->fk_soc=$object->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); + $discount->fk_soc = $object->socid; + $discount->amount_ht = abs($lines[$i]->total_ht); + $discount->amount_tva = abs($lines[$i]->total_tva); + $discount->amount_ttc = abs($lines[$i]->total_ttc); + $discount->tva_tx = $lines[$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); if ($discountid > 0) { - $result=$object->insert_discount($discountid); + $result = $object->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else @@ -331,17 +331,17 @@ if (empty($reshook)) else { // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_start = false; + if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + $date_end = false; + if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { @@ -375,11 +375,11 @@ if (empty($reshook)) ); if ($result > 0) { - $lineid=$result; + $lineid = $result; } else { - $lineid=0; + $lineid = 0; $error++; break; } @@ -393,9 +393,9 @@ if (empty($reshook)) } } - $cmd->classifyBilled($user); // TODO Move this in workflow like done for customer orders + $cmd->classifyBilled($user); // TODO Move this in workflow like done for customer orders - if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; else $TFact[$object->id] = $object; } @@ -403,10 +403,10 @@ if (empty($reshook)) $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - if (! $error && $validate_invoices) { + if (!$error && $validate_invoices) { $massaction = $action = 'builddoc'; - foreach($TAllFact as &$object) + foreach ($TAllFact as &$object) { $object->validate($user); if ($result <= 0) @@ -436,9 +436,9 @@ if (empty($reshook)) else { $db->rollback(); - $action='create'; - $_GET["origin"]=$_POST["origin"]; - $_GET["originid"]=$_POST["originid"]; + $action = 'create'; + $_GET["origin"] = $_POST["origin"]; + $_GET["originid"] = $_POST["originid"]; setEventMessages($object->error, $object->errors, 'errors'); $error++; } @@ -450,15 +450,15 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); -$form=new Form($db); +$form = new Form($db); $thirdpartytmp = new Fournisseur($db); -$commandestatic=new CommandeFournisseur($db); +$commandestatic = new CommandeFournisseur($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $formother = new FormOther($db); -$formcompany=new FormCompany($db); +$formcompany = new FormCompany($db); $title = $langs->trans("SuppliersOrders"); if ($socid > 0) @@ -469,88 +469,88 @@ if ($socid > 0) } if ($status) { - if ($status == '1,2,3') $title.=' - '.$langs->trans("StatusOrderToProcessShort"); - if ($status == '6,7') $title.=' - '.$langs->trans("StatusOrderCanceled"); - else $title.=' - '.$commandestatic->LibStatut($status); + if ($status == '1,2,3') $title .= ' - '.$langs->trans("StatusOrderToProcessShort"); + if ($status == '6,7') $title .= ' - '.$langs->trans("StatusOrderCanceled"); + else $title .= ' - '.$commandestatic->LibStatut($status); } -if ($search_billed > 0) $title.=' - '.$langs->trans("Billed"); +if ($search_billed > 0) $title .= ' - '.$langs->trans("Billed"); //$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; -$help_url=''; +$help_url = ''; // llxHeader('',$title,$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,'; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,"; -$sql.= ' cf.date_creation as date_creation, cf.tms as date_update,'; -$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; -$sql.= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email"; +$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,"; +$sql .= ' cf.date_creation as date_creation, cf.tms as date_update,'; +$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; +$sql .= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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."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)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cf.rowid = ef.fk_object)"; -if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande'; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet"; +$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."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)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cf.rowid = ef.fk_object)"; +if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (!$user->rights->societe->client->voir && ! $socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE cf.fk_soc = s.rowid'; -$sql.= ' AND cf.entity IN ('.getEntity('supplier_order').')'; -if ($socid > 0) $sql.= " AND s.rowid = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql .= ' WHERE cf.fk_soc = s.rowid'; +$sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')'; +if ($socid > 0) $sql .= " AND s.rowid = ".$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($search_ref) $sql .= natural_search('cf.ref', $search_ref); -if ($search_refsupp) $sql.= natural_search("cf.ref_supplier", $search_refsupp); +if ($search_refsupp) $sql .= natural_search("cf.ref_supplier", $search_refsupp); if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_request_author) $sql.=natural_search(array('u.lastname','u.firstname','u.login'), $search_request_author) ; +if ($search_request_author) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_request_author); if ($search_billed != '' && $search_billed >= 0) $sql .= " AND cf.billed = ".$db->escape($search_billed); -if ($search_product_category > 0) $sql.= " AND cp.fk_categorie = ".$search_product_category; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; //Required triple check because statut=0 means draft filter if (GETPOST('statut', 'intcomma') !== '') $sql .= " AND cf.fk_statut IN (".$db->escape($db->escape(GETPOST('statut', 'intcomma'))).")"; if ($search_status != '' && $search_status >= 0) - $sql.=" AND cf.fk_statut IN (".$db->escape($search_status).")"; -$sql.= dolSqlDateFilter("cf.date_commande", $search_orderday, $search_ordermonth, $search_orderyear); -$sql.= dolSqlDateFilter("cf.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); + $sql .= " AND cf.fk_statut IN (".$db->escape($search_status).")"; +$sql .= dolSqlDateFilter("cf.date_commande", $search_orderday, $search_ordermonth, $search_orderyear); +$sql .= dolSqlDateFilter("cf.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale); -if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user); -if ($search_total_ht != '') $sql.= natural_search('cf.total_ht', $search_total_ht, 1); -if ($search_total_vat != '') $sql.= natural_search('cf.tva', $search_total_vat, 1); -if ($search_total_ttc != '') $sql.= natural_search('cf.total_ttc', $search_total_ttc, 1); -if ($search_project_ref != '') $sql.= natural_search("p.ref", $search_project_ref); +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale); +if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user); +if ($search_total_ht != '') $sql .= natural_search('cf.total_ht', $search_total_ht, 1); +if ($search_total_vat != '') $sql .= natural_search('cf.tva', $search_total_vat, 1); +if ($search_total_ttc != '') $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1); +if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -564,7 +564,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -573,7 +573,7 @@ if ($resql) { $soc = new Societe($db); $soc->fetch($socid); - $title = $langs->trans('ListOfSupplierOrders') . ' - '.$soc->name; + $title = $langs->trans('ListOfSupplierOrders').' - '.$soc->name; } else { @@ -582,9 +582,9 @@ if ($resql) $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -594,48 +594,48 @@ if ($resql) llxHeader('', $title, $help_url); - $param=''; - if ($socid > 0) $param.='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($sall) $param.="&search_all=".$sall; - if ($search_orderday) $param.='&search_orderday='.$search_orderday; - if ($search_ordermonth) $param.='&search_ordermonth='.$search_ordermonth; - if ($search_orderyear) $param.='&search_orderyear='.$search_orderyear; - if ($search_deliveryday) $param.='&search_deliveryday='.$search_deliveryday; - if ($search_deliverymonth) $param.='&search_deliverymonth='.$search_deliverymonth; - if ($search_deliveryyear) $param.='&search_deliveryyear='.$search_deliveryyear; - if ($search_ref) $param.='&search_ref='.$search_ref; - if ($search_company) $param.='&search_company='.$search_company; - if ($search_user > 0) $param.='&search_user='.$search_user; - if ($search_request_author) $param.='&search_request_author='.$search_request_author; - if ($search_sale > 0) $param.='&search_sale='.$search_sale; - if ($search_total_ht != '') $param.='&search_total_ht='.$search_total_ht; - if ($search_total_ttc != '') $param.="&search_total_ttc=".$search_total_ttc; - if ($search_refsupp) $param.="&search_refsupp=".$search_refsupp; - if ($search_status >= 0) $param.="&search_status=".$search_status; - if ($search_project_ref >= 0) $param.="&search_project_ref=".$search_project_ref; - if ($search_billed != '') $param.="&search_billed=".$search_billed; - if ($show_files) $param.='&show_files=' .$show_files; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = ''; + if ($socid > 0) $param .= '&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($sall) $param .= "&search_all=".$sall; + if ($search_orderday) $param .= '&search_orderday='.$search_orderday; + if ($search_ordermonth) $param .= '&search_ordermonth='.$search_ordermonth; + if ($search_orderyear) $param .= '&search_orderyear='.$search_orderyear; + if ($search_deliveryday) $param .= '&search_deliveryday='.$search_deliveryday; + if ($search_deliverymonth) $param .= '&search_deliverymonth='.$search_deliverymonth; + if ($search_deliveryyear) $param .= '&search_deliveryyear='.$search_deliveryyear; + if ($search_ref) $param .= '&search_ref='.$search_ref; + if ($search_company) $param .= '&search_company='.$search_company; + if ($search_user > 0) $param .= '&search_user='.$search_user; + if ($search_request_author) $param .= '&search_request_author='.$search_request_author; + if ($search_sale > 0) $param .= '&search_sale='.$search_sale; + if ($search_total_ht != '') $param .= '&search_total_ht='.$search_total_ht; + if ($search_total_ttc != '') $param .= "&search_total_ttc=".$search_total_ttc; + if ($search_refsupp) $param .= "&search_refsupp=".$search_refsupp; + if ($search_status >= 0) $param .= "&search_status=".$search_status; + if ($search_project_ref >= 0) $param .= "&search_project_ref=".$search_project_ref; + if ($search_billed != '') $param .= "&search_billed=".$search_billed; + if ($show_files) $param .= '&show_files='.$show_files; + if ($optioncss != '') $param .= '&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); - if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; - if($user->rights->fournisseur->commande->creer) + $newcardbutton = ''; + if ($user->rights->fournisseur->commande->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fourn/commande/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fourn/commande/card.php?action=create'); } // Fields title search @@ -651,10 +651,10 @@ if ($resql) print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'commercial', 0, $newcardbutton, '', $limit); - $topicmail="SendOrderRef"; - $modelmail="order_supplier_send"; - $objecttmp=new CommandeFournisseur($db); - $trackid='sord'.$object->id; + $topicmail = "SendOrderRef"; + $modelmail = "order_supplier_send"; + $objecttmp = new CommandeFournisseur($db); + $trackid = 'sord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($massaction == 'createbills') @@ -699,144 +699,144 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } - $moreforfilter=''; + $moreforfilter = ''; // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view other users if ($user->rights->user->user->lire) { - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view prospects other than his' if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='</div>'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '</div>'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<tr class="liste_titre_filter">'; // Ref - if (! empty($arrayfields['cf.ref']['checked'])) + if (!empty($arrayfields['cf.ref']['checked'])) { print '<td class="liste_titre"><input size="8" type="text" class="flat" name="search_ref" value="'.$search_ref.'"></td>'; } // Ref customer - if (! empty($arrayfields['cf.ref_supplier']['checked'])) + if (!empty($arrayfields['cf.ref_supplier']['checked'])) { print '<td class="liste_titre"><input type="text" class="flat" size="8" name="search_refsupp" value="'.$search_refsupp.'"></td>'; } // Project ref - if (! empty($arrayfields['p.project_ref']['checked'])) + if (!empty($arrayfields['p.project_ref']['checked'])) { print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.$search_project_ref.'"></td>'; } // Request author - if (! empty($arrayfields['u.login']['checked'])) + if (!empty($arrayfields['u.login']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" size="6" name="search_request_author" value="'.$search_request_author.'">'; print '</td>'; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre"><input type="text" size="6" class="flat" name="search_company" value="'.$search_company.'"></td>'; } // Town - if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>'; + if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>'; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>'; + if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>'; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="liste_titre center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone center">'; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print '</td>'; } // Date order - if (! empty($arrayfields['cf.date_commande']['checked'])) + if (!empty($arrayfields['cf.date_commande']['checked'])) { print '<td class="liste_titre nowraponall center">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_orderday" value="'.$search_orderday.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_orderday" value="'.$search_orderday.'">'; print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_ordermonth" value="'.$search_ordermonth.'">'; - $formother->select_year($search_orderyear?$search_orderyear:-1, 'search_orderyear', 1, 20, 5); + $formother->select_year($search_orderyear ? $search_orderyear : -1, 'search_orderyear', 1, 20, 5); print '</td>'; } // Date delivery - if (! empty($arrayfields['cf.date_delivery']['checked'])) + if (!empty($arrayfields['cf.date_delivery']['checked'])) { print '<td class="liste_titre nowraponall center">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliveryday" value="'.$search_deliveryday.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliveryday" value="'.$search_deliveryday.'">'; print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_deliverymonth" value="'.$search_deliverymonth.'">'; - $formother->select_year($search_deliveryyear?$search_deliveryyear:-1, 'search_deliveryyear', 1, 20, 5); + $formother->select_year($search_deliveryyear ? $search_deliveryyear : -1, 'search_deliveryyear', 1, 20, 5); print '</td>'; } - if (! empty($arrayfields['cf.total_ht']['checked'])) + if (!empty($arrayfields['cf.total_ht']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_total_ht" value="'.$search_total_ht.'">'; print '</td>'; } - if (! empty($arrayfields['cf.total_vat']['checked'])) + if (!empty($arrayfields['cf.total_vat']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_total_vat" value="'.$search_total_vat.'">'; print '</td>'; } - if (! empty($arrayfields['cf.total_ttc']['checked'])) + if (!empty($arrayfields['cf.total_ttc']['checked'])) { // Amount print '<td class="liste_titre right">'; @@ -847,30 +847,30 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['cf.datec']['checked'])) + if (!empty($arrayfields['cf.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (! empty($arrayfields['cf.tms']['checked'])) + if (!empty($arrayfields['cf.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status - if (! empty($arrayfields['cf.fk_statut']['checked'])) + if (!empty($arrayfields['cf.fk_statut']['checked'])) { print '<td class="liste_titre right">'; - $formorder->selectSupplierOrderStatus((strstr($search_status, ',')?-1:$search_status), 1, 'search_status'); + $formorder->selectSupplierOrderStatus((strstr($search_status, ',') ?-1 : $search_status), 1, 'search_status'); print '</td>'; } // Status billed - if (! empty($arrayfields['cf.billed']['checked'])) + if (!empty($arrayfields['cf.billed']['checked'])) { print '<td class="liste_titre center">'; print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); @@ -878,59 +878,59 @@ if ($resql) } // Action column print '<td class="liste_titre middle">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; - if (! empty($arrayfields['cf.ref']['checked'])) print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['cf.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.project_ref']['checked'])) print_liste_field_titre($arrayfields['p.project_ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cf.fk_author']['checked'])) print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['cf.date_commande']['checked'])) print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cf.date_delivery']['checked'])) print_liste_field_titre($arrayfields['cf.date_delivery']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cf.total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['cf.total_vat']['checked'])) print_liste_field_titre($arrayfields['cf.total_vat']['label'], $_SERVER["PHP_SELF"], "cf.tva", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['cf.total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.ref']['checked'])) print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cf.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.project_ref']['checked'])) print_liste_field_titre($arrayfields['p.project_ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.fk_author']['checked'])) print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cf.date_commande']['checked'])) print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.date_delivery']['checked'])) print_liste_field_titre($arrayfields['cf.date_delivery']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.total_vat']['checked'])) print_liste_field_titre($arrayfields['cf.total_vat']['label'], $_SERVER["PHP_SELF"], "cf.tva", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['cf.datec']['checked'])) print_liste_field_titre($arrayfields['cf.datec']['label'], $_SERVER["PHP_SELF"], "cf.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['cf.tms']['checked'])) print_liste_field_titre($arrayfields['cf.tms']['label'], $_SERVER["PHP_SELF"], "cf.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['cf.fk_statut']['checked'])) print_liste_field_titre($arrayfields['cf.fk_statut']['label'], $_SERVER["PHP_SELF"], "cf.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['cf.billed']['checked'])) print_liste_field_titre($arrayfields['cf.billed']['label'], $_SERVER["PHP_SELF"], 'cf.billed', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.datec']['checked'])) print_liste_field_titre($arrayfields['cf.datec']['label'], $_SERVER["PHP_SELF"], "cf.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['cf.tms']['checked'])) print_liste_field_titre($arrayfields['cf.tms']['label'], $_SERVER["PHP_SELF"], "cf.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['cf.fk_statut']['checked'])) print_liste_field_titre($arrayfields['cf.fk_statut']['label'], $_SERVER["PHP_SELF"], "cf.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.billed']['checked'])) print_liste_field_titre($arrayfields['cf.billed']['label'], $_SERVER["PHP_SELF"], 'cf.billed', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; - $total=0; - $subtotal=0; - $productstat_cache=array(); + $total = 0; + $subtotal = 0; + $productstat_cache = array(); $userstatic = new User($db); - $objectstatic=new CommandeFournisseur($db); - $projectstatic=new Project($db); + $objectstatic = new CommandeFournisseur($db); + $projectstatic = new Project($db); - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $objectstatic->id=$obj->rowid; - $objectstatic->ref=$obj->ref; + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; $objectstatic->ref_supplier = $obj->ref_supplier; $objectstatic->total_ht = $obj->total_ht; $objectstatic->total_tva = $obj->total_tva; @@ -941,36 +941,36 @@ if ($resql) print '<tr class="oddeven">'; // Ref - if (! empty($arrayfields['cf.ref']['checked'])) + if (!empty($arrayfields['cf.ref']['checked'])) { print '<td class="nowrap">'; // Picto + Ref print $objectstatic->getNomUrl(1); // Other picto tool - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->fournisseur->commande->dir_output.'/' . dol_sanitizeFileName($obj->ref); + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print '</td>'."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref Supplier - if (! empty($arrayfields['cf.ref_supplier']['checked'])) + if (!empty($arrayfields['cf.ref_supplier']['checked'])) { print '<td>'.$obj->ref_supplier.'</td>'."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project - if (! empty($arrayfields['p.project_ref']['checked'])) + if (!empty($arrayfields['p.project_ref']['checked'])) { - $projectstatic->id=$obj->project_id; - $projectstatic->ref=$obj->project_ref; - $projectstatic->title=$obj->project_title; + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_title; print '<td>'; if ($obj->project_id > 0) print $projectstatic->getNomUrl(1); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Author $userstatic->id = $obj->fk_user_author; @@ -979,15 +979,15 @@ if ($resql) $userstatic->login = $obj->login; $userstatic->photo = $obj->photo; $userstatic->email = $obj->user_email; - if (! empty($arrayfields['u.login']['checked'])) + if (!empty($arrayfields['u.login']['checked'])) { print '<td class="tdoverflowmax150">'; if ($userstatic->id) print $userstatic->getNomUrl(1); print "</td>"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Thirdparty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="tdoverflowmax150">'; $thirdpartytmp->id = $obj->socid; @@ -1137,8 +1137,8 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "</table>\n"; @@ -1147,16 +1147,16 @@ if ($resql) $db->free($resql); - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->fournisseur->commande->lire; - $delallowed=$user->rights->fournisseur->commande->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->fournisseur->commande->lire; + $delallowed = $user->rights->fournisseur->commande->creer; print $formfile->showdocuments('massfilesarea_supplier_order', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index ce212069238..05965067b55 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -49,59 +49,59 @@ if (!$user->rights->fournisseur->facture->lire) accessforbidden(); // Load translation files required by the page $langs->loadLangs(array('products', 'bills', 'companies', 'projects')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss', 'alpha'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'supplierinvoicelist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierinvoicelist'; $socid = GETPOST('socid', 'int'); // Security check if ($user->socid > 0) { - $action=''; + $action = ''; $_GET["action"] = ''; $socid = $user->socid; } -$mode=GETPOST("mode"); +$mode = GETPOST("mode"); -$search_all = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_label = GETPOST("search_label", "alpha"); $search_amount_no_tax = GETPOST("search_amount_no_tax", "alpha"); $search_amount_all_tax = GETPOST("search_amount_all_tax", "alpha"); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref', 'alpha'):GETPOST('search_ref', 'alpha'); -$search_refsupplier=GETPOST('search_refsupplier', 'alpha'); -$search_type=GETPOST('search_type', 'int'); -$search_project=GETPOST('search_project', 'alpha'); -$search_company=GETPOST('search_company', 'alpha'); -$search_montant_ht=GETPOST('search_montant_ht', 'alpha'); -$search_montant_vat=GETPOST('search_montant_vat', 'alpha'); -$search_montant_localtax1=GETPOST('search_montant_localtax1', 'alpha'); -$search_montant_localtax2=GETPOST('search_montant_localtax2', 'alpha'); -$search_montant_ttc=GETPOST('search_montant_ttc', 'alpha'); -$search_status=GETPOST('search_status', 'int'); -$search_paymentmode=GETPOST('search_paymentmode', 'int'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); +$search_product_category = GETPOST('search_product_category', 'int'); +$search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); +$search_refsupplier = GETPOST('search_refsupplier', 'alpha'); +$search_type = GETPOST('search_type', 'int'); +$search_project = GETPOST('search_project', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_montant_ht = GETPOST('search_montant_ht', 'alpha'); +$search_montant_vat = GETPOST('search_montant_vat', 'alpha'); +$search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha'); +$search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha'); +$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); +$search_status = GETPOST('search_status', 'int'); +$search_paymentmode = GETPOST('search_paymentmode', 'int'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); -$day = GETPOST('day', 'int'); -$month = GETPOST('month', 'int'); -$year = GETPOST('year', 'int'); -$day_lim = GETPOST('day_lim', 'int'); +$day = GETPOST('day', 'int'); +$month = GETPOST('month', 'int'); +$year = GETPOST('year', 'int'); +$day_lim = GETPOST('day_lim', 'int'); $month_lim = GETPOST('month_lim', 'int'); $year_lim = GETPOST('year_lim', 'int'); $toselect = GETPOST('toselect', 'array'); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $option = GETPOST('option'); if ($option == 'late') { @@ -109,20 +109,20 @@ if ($option == 'late') { } $filter = GETPOST('filtre', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page=GETPOST("page", 'int'); -if ($page == -1 || $page == null || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0 ; } -$offset = $limit * $page ; +$page = GETPOST("page", 'int'); +if ($page == -1 || $page == null || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="f.datef,f.rowid"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "f.datef,f.rowid"; -$diroutputmassaction=$conf->fournisseur->facture->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id; -$now=dol_now(); +$now = dol_now(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new FactureFournisseur($db); @@ -132,7 +132,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -142,10 +142,10 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'f.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'f.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'f.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1), 'f.type'=>array('label'=>$langs->trans("Type"), 'checked'=>0), @@ -162,8 +162,8 @@ $arrayfields=array( 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), 'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), 'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), - 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax1_assuj=="1"), - 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax2_assuj=="1"), + 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax1_assuj == "1"), + 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax2_assuj == "1"), 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), 'dynamount_payed'=>array('label'=>$langs->trans("Payed"), 'checked'=>0), 'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0), @@ -174,10 +174,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -188,11 +188,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) @@ -254,58 +254,58 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$formother=new FormOther($db); +$form = new Form($db); +$formother = new FormOther($db); $formfile = new FormFile($db); -$bankaccountstatic=new Account($db); -$facturestatic=new FactureFournisseur($db); -$formcompany=new FormCompany($db); -$thirdparty=new Societe($db); +$bankaccountstatic = new Account($db); +$facturestatic = new FactureFournisseur($db); +$formcompany = new FormCompany($db); +$thirdparty = new Societe($db); // llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); $sql = "SELECT"; if ($search_all || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement,"; -$sql.= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,"; -$sql.= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,"; -$sql.= " s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= " country.code as country_code,"; -$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; +$sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement,"; +$sql .= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,"; +$sql .= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,"; +$sql .= " s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " country.code as country_code,"; +$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. -if (! $search_all) $sql.= ', SUM(pf.amount) as dynamount_payed'; +if (!$search_all) $sql .= ', SUM(pf.amount) as dynamount_payed'; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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."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)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql.= ', '.MAIN_DB_PREFIX.'facture_fourn as f'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)"; -if (! $search_all) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; -if ($search_all || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; +$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."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)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql .= ', '.MAIN_DB_PREFIX.'facture_fourn as f'; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)"; +if (!$search_all) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; +if ($search_all || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE f.fk_soc = s.rowid'; -$sql.= ' AND f.entity IN ('.getEntity('facture_fourn').')'; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; +$sql .= ' WHERE f.fk_soc = s.rowid'; +$sql .= ' AND f.entity IN ('.getEntity('facture_fourn').')'; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; if ($search_ref) { @@ -316,34 +316,34 @@ if ($search_ref) $sql .= natural_search('f.ref', $search_ref); if ($search_refsupplier) $sql .= natural_search('f.ref_supplier', $search_refsupplier); if ($search_type != '' && $search_type >= 0) { - if ($search_type == '0') $sql.=" AND f.type = 0"; // standard - if ($search_type == '1') $sql.=" AND f.type = 1"; // replacement - if ($search_type == '2') $sql.=" AND f.type = 2"; // credit note - if ($search_type == '3') $sql.=" AND f.type = 3"; // deposit + if ($search_type == '0') $sql .= " AND f.type = 0"; // standard + if ($search_type == '1') $sql .= " AND f.type = 1"; // replacement + if ($search_type == '2') $sql .= " AND f.type = 2"; // credit note + if ($search_type == '3') $sql .= " AND f.type = 3"; // deposit //if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma //if ($search_type == '5') $sql.=" AND f.type = 5"; // situation } if ($search_project) $sql .= natural_search('p.ref', $search_project); if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; -if ($search_montant_ht != '') $sql.= natural_search('f.total_ht', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql.= natural_search('f.total_tva', $search_montant_vat, 1); -if ($search_montant_localtax1 != '') $sql.= natural_search('f.localtax1', $search_montant_localtax1, 1); -if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $search_montant_localtax2, 1); -if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); -if ($search_status != '' && $search_status >= 0) $sql.= " AND f.fk_statut = ".$db->escape($search_status); +if ($search_montant_ht != '') $sql .= natural_search('f.total_ht', $search_montant_ht, 1); +if ($search_montant_vat != '') $sql .= natural_search('f.total_tva', $search_montant_vat, 1); +if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); +if ($search_montant_localtax2 != '') $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1); +if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); +if ($search_status != '' && $search_status >= 0) $sql .= " AND f.fk_statut = ".$db->escape($search_status); if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode.""; -$sql.= dolSqlDateFilter("f.datef", $day, $month, $year); -$sql.= dolSqlDateFilter("f.date_lim_reglement", $day_lim, $month_lim, $year_lim); -if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; +$sql .= dolSqlDateFilter("f.datef", $day, $month, $year); +$sql .= dolSqlDateFilter("f.date_lim_reglement", $day_lim, $month_lim, $year_lim); +if ($option == 'late') $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; if ($search_label) $sql .= natural_search('f.libelle', $search_label); if ($search_status != '' && $search_status >= 0) { - $sql.= " AND f.fk_statut = ".$search_status; + $sql .= " AND f.fk_statut = ".$search_status; } if ($filter && $filter != -1) { @@ -351,44 +351,44 @@ if ($filter && $filter != -1) foreach ($aFilter as $fil) { $filt = explode(':', $fil); - $sql .= ' AND ' . $db->escape(trim($filt[0])) . ' = ' . $db->escape(trim($filt[1])); + $sql .= ' AND '.$db->escape(trim($filt[0])).' = '.$db->escape(trim($filt[1])); } } -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale); +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale); if ($search_user > 0) { - $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; + $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -if (! $search_all) +if (!$search_all) { - $sql.= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement, f.fk_mode_reglement,"; - $sql.= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; - $sql.= " f.localtax1, f.localtax2,"; - $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; - $sql.= " typent.code,"; - $sql.= " state.code_departement, state.nom,"; - $sql.= ' country.code,'; - $sql.= " p.rowid, p.ref, p.title"; - if (! empty($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement, f.fk_mode_reglement,"; + $sql .= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; + $sql .= " f.localtax1, f.localtax2,"; + $sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; + $sql .= " typent.code,"; + $sql .= " state.code_departement, state.nom,"; + $sql .= ' country.code,'; + $sql .= " p.rowid, p.ref, p.title"; + if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { //prevent error with sql_mode=only_full_group_by - $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : ''); } } } else { - $sql.= natural_search(array_keys($fieldstosearchall), $search_all); + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -402,7 +402,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); @@ -410,9 +410,9 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->facid; @@ -430,51 +430,51 @@ if ($resql) if (empty($search_company)) $search_company = $soc->name; } - $param='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_all) $param.='&search_all='.urlencode($search_all); - if ($day) $param.='&day='.urlencode($day); - if ($month) $param.='&month='.urlencode($month); - if ($year) $param.='&year=' .urlencode($year); - if ($day_lim) $param.='&day_lim='.urlencode($day_lim); - if ($month_lim) $param.='&month_lim='.urlencode($month_lim); - if ($year_lim) $param.='&year_lim=' .urlencode($year_lim); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_refsupplier) $param.='&search_refsupplier='.urlencode($search_refsupplier); - if ($search_type != '') $param.='&search_type='.urlencode($search_type); - if ($search_label) $param.='&search_label='.urlencode($search_label); - if ($search_company) $param.='&search_company='.urlencode($search_company); - if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht); - if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); - if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1); - if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2); - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); - if ($search_amount_no_tax) $param.='&search_amount_no_tax='.urlencode($search_amount_no_tax); - if ($search_amount_all_tax) $param.='&search_amount_all_tax='.urlencode($search_amount_all_tax); - if ($search_status >= 0) $param.="&search_status=".urlencode($search_status); - if ($show_files) $param.='&show_files=' .$show_files; - if ($option) $param.="&option=".$option; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = '&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($search_all) $param .= '&search_all='.urlencode($search_all); + if ($day) $param .= '&day='.urlencode($day); + if ($month) $param .= '&month='.urlencode($month); + if ($year) $param .= '&year='.urlencode($year); + if ($day_lim) $param .= '&day_lim='.urlencode($day_lim); + if ($month_lim) $param .= '&month_lim='.urlencode($month_lim); + if ($year_lim) $param .= '&year_lim='.urlencode($year_lim); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_refsupplier) $param .= '&search_refsupplier='.urlencode($search_refsupplier); + if ($search_type != '') $param .= '&search_type='.urlencode($search_type); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_company) $param .= '&search_company='.urlencode($search_company); + if ($search_montant_ht != '') $param .= '&search_montant_ht='.urlencode($search_montant_ht); + if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); + if ($search_montant_localtax1 != '') $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1); + if ($search_montant_localtax2 != '') $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2); + if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); + if ($search_amount_no_tax) $param .= '&search_amount_no_tax='.urlencode($search_amount_no_tax); + if ($search_amount_all_tax) $param .= '&search_amount_all_tax='.urlencode($search_amount_all_tax); + if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status); + if ($show_files) $param .= '&show_files='.$show_files; + if ($option) $param .= "&option=".$option; + if ($optioncss != '') $param .= '&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'validate'=>$langs->trans("Validate"), 'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); - if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->fournisseur->facture->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fourn/facture/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fourn/facture/card.php?action=create'); } $i = 0; @@ -489,12 +489,12 @@ if ($resql) print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; print '<input type="hidden" name="socid" value="'.$socid.'">'; - print_barre_liste($langs->trans("BillsSuppliers").($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'invoicing', 0, $newcardbutton, '', $limit); + print_barre_liste($langs->trans("BillsSuppliers").($socid ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'invoicing', 0, $newcardbutton, '', $limit); - $topicmail="SendBillRef"; - $modelmail="invoice_supplier_send"; - $objecttmp=new FactureFournisseur($db); - $trackid='sinv'.$object->id; + $topicmail = "SendBillRef"; + $modelmail = "invoice_supplier_send"; + $objecttmp = new FactureFournisseur($db); + $trackid = 'sinv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($massaction == 'createbills') @@ -539,40 +539,40 @@ if ($resql) if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } // If the user can view prospects other than his' - $moreforfilter=''; + $moreforfilter = ''; if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '</div>'; } // If the user can view prospects other than his' if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='</div>'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '</div>'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; @@ -583,34 +583,34 @@ if ($resql) print '</div>'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Line for filters print '<tr class="liste_titre_filter">'; // Ref - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.$search_ref.'">'; print '</td>'; } // Ref supplier - if (! empty($arrayfields['f.ref_supplier']['checked'])) + if (!empty($arrayfields['f.ref_supplier']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth50" type="text" name="search_refsupplier" value="'.$search_refsupplier.'">'; print '</td>'; } // Type - if (! empty($arrayfields['f.type']['checked'])) + if (!empty($arrayfields['f.type']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone">'; - $listtype=array( + $listtype = array( FactureFournisseur::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), FactureFournisseur::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), @@ -627,114 +627,114 @@ if ($resql) print '</td>'; } // Label - if (! empty($arrayfields['f.label']['checked'])) + if (!empty($arrayfields['f.label']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat maxwidth75" type="text" name="search_label" value="'.$search_label.'">'; print '</td>'; } // Date invoice - if (! empty($arrayfields['f.datef']['checked'])) + if (!empty($arrayfields['f.datef']['checked'])) { print '<td class="liste_titre nowraponall center">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">'; print '<input class="flat width25 valignmiddle" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; - $formother->select_year($year?$year:-1, 'year', 1, 20, 5); + $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); print '</td>'; } // Date due - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print '<td class="liste_titre nowraponall center">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day_lim" value="'.dol_escape_htmltag($day_lim).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day_lim" value="'.dol_escape_htmltag($day_lim).'">'; print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month_lim" value="'.$month_lim.'">'; - $formother->select_year($year_lim?$year_lim:-1, 'year_lim', 1, 20, 5); - print '<br><input type="checkbox" name="option" value="late"'.($option == 'late'?' checked':'').'> '.$langs->trans("Late"); + $formother->select_year($year_lim ? $year_lim : -1, 'year_lim', 1, 20, 5); + print '<br><input type="checkbox" name="option" value="late"'.($option == 'late' ? ' checked' : '').'> '.$langs->trans("Late"); print '</td>'; } // Project - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_project" value="'.$search_project.'"></td>'; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company" value="'.$search_company.'"></td>'; } // Town - if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>'; + if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>'; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre center"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>'; + if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre center"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>'; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="liste_titre center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone center">'; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print '</td>'; } // Payment mode - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print '<td class="liste_titre left">'; $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10); print '</td>'; } - if (! empty($arrayfields['f.total_ht']['checked'])) + if (!empty($arrayfields['f.total_ht']['checked'])) { // Amount without tax print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">'; print '</td>'; } - if (! empty($arrayfields['f.total_vat']['checked'])) + if (!empty($arrayfields['f.total_vat']['checked'])) { // Amount vat print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">'; print '</td>'; } - if (! empty($arrayfields['f.total_localtax1']['checked'])) + if (!empty($arrayfields['f.total_localtax1']['checked'])) { // Amount tax 1 print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.$search_montant_localtax1.'">'; print '</td>'; } - if (! empty($arrayfields['f.total_localtax2']['checked'])) + if (!empty($arrayfields['f.total_localtax2']['checked'])) { // Amount tax 2 print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.$search_montant_localtax2.'">'; print '</td>'; } - if (! empty($arrayfields['f.total_ttc']['checked'])) + if (!empty($arrayfields['f.total_ttc']['checked'])) { // Amount inc tac print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; print '</td>'; } - if (! empty($arrayfields['dynamount_payed']['checked'])) + if (!empty($arrayfields['dynamount_payed']['checked'])) { print '<td class="liste_titre right">'; print '</td>'; } - if (! empty($arrayfields['rtp']['checked'])) + if (!empty($arrayfields['rtp']['checked'])) { print '<td class="liste_titre">'; print '</td>'; @@ -743,102 +743,102 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status - if (! empty($arrayfields['f.fk_statut']['checked'])) + if (!empty($arrayfields['f.fk_statut']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone right">'; - $liststatus=array('0'=>$langs->trans("Draft"),'1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); + $liststatus = array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); print $form->selectarray('search_status', $liststatus, $search_status, 1); print '</td>'; } // Action column print '<td class="liste_titre middle">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; - if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref,f.rowid', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['f.ref_supplier']['label'], $_SERVER["PHP_SELF"], 'f.ref_supplier', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.label']['checked'])) print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER['PHP_SELF'], "f.libelle,f.rowid", '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef,f.rowid', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref,f.rowid', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['f.ref_supplier']['label'], $_SERVER["PHP_SELF"], 'f.ref_supplier', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.label']['checked'])) print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER['PHP_SELF'], "f.libelle,f.rowid", '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef,f.rowid', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "fk_statut,paye,type", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "fk_statut,paye,type", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; - $facturestatic=new FactureFournisseur($db); - $supplierstatic=new Fournisseur($db); - $projectstatic=new Project($db); + $facturestatic = new FactureFournisseur($db); + $supplierstatic = new Fournisseur($db); + $projectstatic = new Project($db); if ($num > 0) { - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $datelimit=$db->jdate($obj->datelimite); - $facturestatic->id=$obj->facid; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; - $facturestatic->ref_supplier=$obj->ref_supplier; + $datelimit = $db->jdate($obj->datelimite); + $facturestatic->id = $obj->facid; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; + $facturestatic->ref_supplier = $obj->ref_supplier; $facturestatic->date_echeance = $db->jdate($obj->datelimite); $facturestatic->statut = $obj->fk_statut; - $thirdparty->id=$obj->socid; - $thirdparty->name=$obj->name; - $thirdparty->client=$obj->client; - $thirdparty->fournisseur=$obj->fournisseur; - $thirdparty->code_client=$obj->code_client; - $thirdparty->code_compta_client=$obj->code_compta_client; - $thirdparty->code_fournisseur=$obj->code_fournisseur; - $thirdparty->code_compta_fournisseur=$obj->code_compta_fournisseur; - $thirdparty->email=$obj->email; - $thirdparty->country_code=$obj->country_code; + $thirdparty->id = $obj->socid; + $thirdparty->name = $obj->name; + $thirdparty->client = $obj->client; + $thirdparty->fournisseur = $obj->fournisseur; + $thirdparty->code_client = $obj->code_client; + $thirdparty->code_compta_client = $obj->code_compta_client; + $thirdparty->code_fournisseur = $obj->code_fournisseur; + $thirdparty->code_compta_fournisseur = $obj->code_compta_fournisseur; + $thirdparty->email = $obj->email; + $thirdparty->country_code = $obj->country_code; $paiement = $facturestatic->getSommePaiement(); $totalcreditnotes = $facturestatic->getSumCreditNotesUsed(); @@ -847,14 +847,14 @@ if ($resql) $remaintopay = $obj->total_ttc - $totalpay; //If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice - if($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) { - if($facturestatic->isCreditNoteUsed()){ - $remaintopay=-$facturestatic->getSumFromThisCreditNotesNotUsed(); + if ($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) { + if ($facturestatic->isCreditNoteUsed()) { + $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed(); } } print '<tr class="oddeven">'; - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print '<td class="nowrap">'; @@ -868,54 +868,54 @@ if ($resql) //print '</td>'; // Other picto tool print '<td width="16" class="right nobordernopadding hideonsmartphone">'; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); print '</td></tr></table>'; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Supplier ref - if (! empty($arrayfields['f.ref_supplier']['checked'])) + if (!empty($arrayfields['f.ref_supplier']['checked'])) { print '<td class="nowrap">'; print $obj->ref_supplier; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type - if (! empty($arrayfields['f.type']['checked'])) + if (!empty($arrayfields['f.type']['checked'])) { print '<td class="nowrap">'; print $facturestatic->getLibType(); print "</td>"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Label - if (! empty($arrayfields['f.label']['checked'])) + if (!empty($arrayfields['f.label']['checked'])) { print '<td class="nowrap">'; print $obj->label; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date - if (! empty($arrayfields['f.datef']['checked'])) + if (!empty($arrayfields['f.datef']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->datef), 'day'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date limit - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print '<td class="center nowrap">'.dol_print_date($datelimit, 'day'); if ($facturestatic->hasDelay()) @@ -1060,45 +1060,45 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['f.fk_statut']['checked'])) + if (!empty($arrayfields['f.fk_statut']['checked'])) { print '<td class="right nowrap">'; // TODO $paiement is not yet defined print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type); print "</td>"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->facid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->facid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "</tr>\n"; @@ -1111,8 +1111,8 @@ if ($resql) $db->free($resql); - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "</table>\n"; @@ -1120,16 +1120,16 @@ if ($resql) print "</form>\n"; - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->facture->lire; + $delallowed = $user->rights->facture->creer; $title = ''; print $formfile->showdocuments('massfilesarea_supplier_invoice', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 4262280233c..da83eee70c9 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -42,23 +42,23 @@ $langs->loadLangs(array('users', 'holiday', 'hrm')); // Protection if external user if ($user->socid > 0) accessforbidden(); -$action = GETPOST('action', 'aZ09'); // 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'):'holidaylist'; // To manage different context of search +$action = GETPOST('action', 'aZ09'); // 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') : 'holidaylist'; // 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') +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id', 'int'); $childids = $user->getAllChildIds(1); // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -68,21 +68,21 @@ $result = restrictedArea($user, 'holiday', '', ''); // If we are on the view of a specific user if ($id > 0) { - $canread=0; - if ($id == $user->id) $canread=1; - if (! empty($user->rights->holiday->read_all)) $canread=1; - if (! empty($user->rights->holiday->read) && in_array($id, $childids)) $canread=1; - if (! $canread) + $canread = 0; + if ($id == $user->id) $canread = 1; + if (!empty($user->rights->holiday->read_all)) $canread = 1; + if (!empty($user->rights->holiday->read) && in_array($id, $childids)) $canread = 1; + if (!$canread) { accessforbidden(); } } -$diroutputmassaction=$conf->holiday->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->holiday->dir_output.'/temp/massgeneration/'.$user->id; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -90,10 +90,10 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder="DESC"; -if (!$sortfield) $sortfield="cp.rowid"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "cp.rowid"; -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST('search_ref', 'alphanohtml'); $search_day_create = GETPOST('search_day_create', 'int'); $search_month_create = GETPOST('search_month_create', 'int'); @@ -110,14 +110,14 @@ $search_statut = GETPOST('search_statut', 'int'); $search_type = GETPOST('search_type', 'int'); // Initialize technical objects -$object=new Holiday($db); +$object = new Holiday($db); $extrafields = new ExtraFields($db); -$hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -128,7 +128,7 @@ $fieldstosearchall = array( 'uu.login'=>'Login' ); -$arrayfields=array( +$arrayfields = array( 'cp.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'cp.fk_user'=>array('label'=>$langs->trans("Employee"), 'checked'=>1, 'position'=>20), 'cp.fk_validator'=>array('label'=>$langs->trans("ValidatorCP"), 'checked'=>1, 'position'=>30), @@ -145,10 +145,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } @@ -158,11 +158,11 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) @@ -171,31 +171,31 @@ if (empty($reshook)) 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 + 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_ref=""; - $search_month_create=""; - $search_year_create=""; - $search_month_start=""; - $search_year_start=""; - $search_month_end=""; - $search_year_end=""; - $search_employee=""; - $search_valideur=""; - $search_statut=""; - $search_type=''; - $toselect=''; - $search_array_options=array(); + $search_ref = ""; + $search_month_create = ""; + $search_year_create = ""; + $search_month_start = ""; + $search_year_start = ""; + $search_month_end = ""; + $search_year_end = ""; + $search_employee = ""; + $search_valideur = ""; + $search_statut = ""; + $search_type = ''; + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Holiday'; - $objectlabel='Holiday'; + $objectclass = 'Holiday'; + $objectlabel = 'Holiday'; $permissiontoread = $user->rights->holiday->read; $permissiontodelete = $user->rights->holiday->delete; $uploaddir = $conf->holiday->dir_output; @@ -214,7 +214,7 @@ $formother = new FormOther($db); $formfile = new FormFile($db); $fuser = new User($db); -$holidaystatic=new Holiday($db); +$holidaystatic = new Holiday($db); // Update sold $result = $object->updateBalance(); @@ -343,7 +343,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; @@ -352,45 +352,45 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_day_create) $param.='&search_day_create='.urlencode($search_day_create); - if ($search_month_create) $param.='&search_month_create='.urlencode($search_month_create); - if ($search_year_create) $param.='&search_year_create='.urlencode($search_year_create); - if ($search_day_start) $param.='&search_day_start='.urlencode($search_day_start); - if ($search_month_start) $param.='&search_month_start='.urlencode($search_month_start); - if ($search_year_start) $param.='&search_year_start='.urlencode($search_year_start); - if ($search_day_end) $param.='&search_day_end='.urlencode($search_day_end); - if ($search_month_end) $param.='&search_month_end='.urlencode($search_month_end); - if ($search_year_end) $param.='&search_year_end='.urlencode($search_year_end); - if ($search_employee > 0) $param.='&search_employee='.urlencode($search_employee); - if ($search_valideur > 0) $param.='&search_valideur='.urlencode($search_valideur); - if ($search_type > 0) $param.='&search_type='.urlencode($search_type); - if ($search_statut > 0) $param.='&search_statut='.urlencode($search_statut); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_day_create) $param .= '&search_day_create='.urlencode($search_day_create); + if ($search_month_create) $param .= '&search_month_create='.urlencode($search_month_create); + if ($search_year_create) $param .= '&search_year_create='.urlencode($search_year_create); + if ($search_day_start) $param .= '&search_day_start='.urlencode($search_day_start); + if ($search_month_start) $param .= '&search_month_start='.urlencode($search_month_start); + if ($search_year_start) $param .= '&search_year_start='.urlencode($search_year_start); + if ($search_day_end) $param .= '&search_day_end='.urlencode($search_day_end); + if ($search_month_end) $param .= '&search_month_end='.urlencode($search_month_end); + if ($search_year_end) $param .= '&search_year_end='.urlencode($search_year_end); + if ($search_employee > 0) $param .= '&search_employee='.urlencode($search_employee); + if ($search_valideur > 0) $param .= '&search_valideur='.urlencode($search_valideur); + if ($search_type > 0) $param .= '&search_type='.urlencode($search_type); + if ($search_statut > 0) $param .= '&search_statut='.urlencode($search_statut); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( //'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->holiday->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->holiday->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // Lines of title fields print '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n"; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; - print '<input type="hidden" name="action" value="'.($action=='edit'?'update':'list').'">'; + print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'list').'">'; print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; @@ -422,7 +422,7 @@ if ($resql) print '<div class="tabsAction">'; - $canedit=(($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && $user->rights->holiday->write_all)); + $canedit = (($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && $user->rights->holiday->write_all)); if ($canedit) { @@ -435,75 +435,75 @@ if ($resql) { $title = $langs->trans("ListeCP"); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->holiday->write) { - $newcardbutton.= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=request'); + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=request'); } print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm.png', 0, $newcardbutton, '', $limit); } - $topicmail="Information"; - $modelmail="leaverequest"; - $objecttmp=new Holiday($db); - $trackid='leav'.$object->id; + $topicmail = "Information"; + $modelmail = "leaverequest"; + $objecttmp = new Holiday($db); + $trackid = 'leav'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } - $moreforfilter=''; + $moreforfilter = ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } - $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) : ''); + $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) : ''); $include = ''; - if (! empty($user->rights->holiday->read_all)) $include = 'hierarchyme'; // Can see all + if (!empty($user->rights->holiday->read_all)) $include = 'hierarchyme'; // Can see all print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Filters print '<tr class="liste_titre_filter">'; - if (! empty($arrayfields['cp.ref']['checked'])) + if (!empty($arrayfields['cp.ref']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="4" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } - if (! empty($arrayfields['cp.fk_user']['checked'])) + if (!empty($arrayfields['cp.fk_user']['checked'])) { $morefilter = 'AND employee = 1'; - if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; + if (!empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; // User - $disabled=0; + $disabled = 0; // If into the tab holiday of a user ($id is set in such a case) - if ($id && ! GETPOSTISSET('search_employee')) + if ($id && !GETPOSTISSET('search_employee')) { - $search_employee=$id; - $disabled=1; + $search_employee = $id; + $disabled = 1; } print '<td class="liste_titre maxwidthonsmartphone left">'; @@ -512,16 +512,16 @@ if ($resql) } // Approver - if (! empty($arrayfields['cp.fk_validator']['checked'])) + if (!empty($arrayfields['cp.fk_validator']['checked'])) { if ($user->rights->holiday->read_all) { print '<td class="liste_titre maxwidthonsmartphone left">'; $validator = new UserGroup($db); - $excludefilter=$user->admin?'':'u.rowid <> '.$user->id; + $excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id; $valideurobjects = $validator->listUsersForGroup($excludefilter); $valideurarray = array(); - foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id; + foreach ($valideurobjects as $val) $valideurarray[$val->id] = $val->id; print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); print '</td>'; } @@ -532,19 +532,19 @@ if ($resql) } // Type - if (! empty($arrayfields['cp.fk_type']['checked'])) + if (!empty($arrayfields['cp.fk_type']['checked'])) { print '<td class="liste_titre">'; if (empty($mysoc->country_id)) { - setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"),$langs->trans("CompanyFoundation")), 'errors'); + setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"), $langs->trans("CompanyFoundation")), 'errors'); } else { - $typeleaves=$holidaystatic->getTypes(1, -1); - $arraytypeleaves=array(); - foreach($typeleaves as $key => $val) + $typeleaves = $holidaystatic->getTypes(1, -1); + $arraytypeleaves = array(); + foreach ($typeleaves as $key => $val) { - $labeltoshow = ($langs->trans($val['code'])!=$val['code'] ? $langs->trans($val['code']) : $val['label']); + $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']); //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); - $arraytypeleaves[$val['rowid']]=$labeltoshow; + $arraytypeleaves[$val['rowid']] = $labeltoshow; } print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1); } @@ -552,13 +552,13 @@ if ($resql) } // Duration - if (! empty($arrayfields['duration']['checked'])) + if (!empty($arrayfields['duration']['checked'])) { print '<td class="liste_titre"> </td>'; } // Start date - if (! empty($arrayfields['cp.date_debut']['checked'])) + if (!empty($arrayfields['cp.date_debut']['checked'])) { print '<td class="liste_titre center nowraponall">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_start" value="'.dol_escape_htmltag($search_month_start).'">'; @@ -567,7 +567,7 @@ if ($resql) } // End date - if (! empty($arrayfields['cp.date_fin']['checked'])) + if (!empty($arrayfields['cp.date_fin']['checked'])) { print '<td class="liste_titre center nowraponall">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_end" value="'.dol_escape_htmltag($search_month_end).'">'; @@ -578,12 +578,12 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Create date - if (! empty($arrayfields['cp.date_create']['checked'])) + if (!empty($arrayfields['cp.date_create']['checked'])) { print '<td class="liste_titre center nowraponall">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_create" value="'.dol_escape_htmltag($search_month_create).'">'; @@ -592,7 +592,7 @@ if ($resql) } // Create date - if (! empty($arrayfields['cp.tms']['checked'])) + if (!empty($arrayfields['cp.tms']['checked'])) { print '<td class="liste_titre center nowraponall">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_update" value="'.dol_escape_htmltag($search_month_update).'">'; @@ -601,7 +601,7 @@ if ($resql) } // Status - if (! empty($arrayfields['cp.statut']['checked'])) + if (!empty($arrayfields['cp.statut']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone maxwidth200 right">'; $object->selectStatutCP($search_statut, 'search_statut'); @@ -610,37 +610,37 @@ if ($resql) // Action column print '<td class="liste_titre maxwidthsearch">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; - if (! empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['cp.fk_validator']['checked'])) print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['cp.fk_type']['checked'])) print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['duration']['checked'])) print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cp.fk_validator']['checked'])) print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cp.fk_type']['checked'])) print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['duration']['checked'])) print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['cp.date_create']['checked'])) print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cp.tms']['checked'])) print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cp.statut']['checked'])) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cp.date_create']['checked'])) print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cp.tms']['checked'])) print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cp.statut']['checked'])) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "</tr>\n"; - $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); + $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); // If we ask a dedicated card and not allow to see it, we force on user. - if ($id && empty($user->rights->holiday->read_all) && ! in_array($id, $childids)) { + if ($id && empty($user->rights->holiday->read_all) && !in_array($id, $childids)) { $langs->load("errors"); print '<tr class="oddeven opacitymediuem"><td colspan="10">'.$langs->trans("NotEnoughPermissions").'</td></tr>'; $result = 0; @@ -785,8 +785,8 @@ if ($resql) // Si il n'y a pas d'enregistrement suite à une recherche if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } @@ -819,16 +819,16 @@ function showMyBalance($holiday, $user_id) { global $conf, $langs; - $alltypeleaves=$holiday->getTypes(1, -1); // To have labels + $alltypeleaves = $holiday->getTypes(1, -1); // To have labels - $out=''; - $nb_holiday=0; - $typeleaves=$holiday->getTypes(1, 1); - foreach($typeleaves as $key => $val) + $out = ''; + $nb_holiday = 0; + $typeleaves = $holiday->getTypes(1, 1); + foreach ($typeleaves as $key => $val) { $nb_type = $holiday->getCPforUser($user_id, $val['rowid']); $nb_holiday += $nb_type; - $out .= ' - '.$val['label'].': <strong>'.($nb_type?price2num($nb_type):0).'</strong><br>'; + $out .= ' - '.$val['label'].': <strong>'.($nb_type ?price2num($nb_type) : 0).'</strong><br>'; } print $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'<br>'; print $out; diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index f75e7d352f1..4a077e35b5b 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -23,19 +23,19 @@ */ // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -45,27 +45,27 @@ dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); // Load translation files required by the page -$langs->loadLangs(array("mymodule@mymodule","other")); +$langs->loadLangs(array("mymodule@mymodule", "other")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('actioncode', 'array')) { - $actioncode=GETPOST('actioncode', 'array', 3); - if (! count($actioncode)) $actioncode='0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } $search_agenda_label = GETPOST('search_agenda_label'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -73,41 +73,41 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='a.datep,a.id'; -if (! $sortorder) $sortorder='DESC,DESC'; +if (!$sortfield) $sortfield = 'a.datep,a.id'; +if (!$sortorder) $sortorder = 'DESC,DESC'; // Initialize technical objects $object = new MyObject($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectagenda','globalcard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectagenda', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id; +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || !empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; // Security check - Protection if external user //if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $object->id); -$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php /* * Actions */ -$parameters=array('id'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id); +$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)) { // Cancel - if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -116,8 +116,8 @@ if (empty($reshook)) // 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 { - $actioncode=''; - $search_agenda_label=''; + $actioncode = ''; + $search_agenda_label = ''; } } @@ -131,12 +131,12 @@ $form = new Form($db); if ($object->id > 0) { - $title=$langs->trans("Agenda"); + $title = $langs->trans("Agenda"); //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url = ''; llxHeader('', $title, $help_url); - if (! empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = myobjectPrepareHead($object); @@ -144,9 +144,9 @@ if ($object->id > 0) // Object card // ------------------------------------------------------------ - $linkback = '<a href="' .dol_buildpath('/mymodule/myobject_list.php', 1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; + $linkback = '<a href="'.dol_buildpath('/mymodule/myobject_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; - $morehtmlref='<div class="refidno">'; + $morehtmlref = '<div class="refidno">'; /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); @@ -186,7 +186,7 @@ if ($object->id > 0) } } }*/ - $morehtmlref.='</div>'; + $morehtmlref .= '</div>'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -205,16 +205,16 @@ if ($object->id > 0) // Actions buttons - $objthirdparty=$object; - $objcon=new stdClass(); + $objthirdparty = $object; + $objcon = new stdClass(); - $out='&origin='.$object->element.'&originid='.$object->id; - $permok=$user->rights->agenda->myactions->create; - if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok) + $out = '&origin='.$object->element.'&originid='.$object->id; + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'; - if (get_class($objthirdparty) == 'Societe') $out.='&socid='.$objthirdparty->id; - $out.=(! empty($objcon->id)?'&contactid='.$objcon->id:'').'&backtopage=1&percentage=-1'; + if (get_class($objthirdparty) == 'Societe') $out .= '&socid='.$objthirdparty->id; + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&percentage=-1'; //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.="</a>"; @@ -223,9 +223,9 @@ if ($object->id > 0) print '<div class="tabsAction">'; - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { - if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>'; } @@ -237,18 +237,18 @@ if ($object->id > 0) print '</div>'; - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $param='&id='.$object->id.'&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + $param = '&id='.$object->id.'&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); //print load_fiche_titre($langs->trans("ActionsOnMyObject"), '', ''); // List of all actions - $filters=array(); - $filters['search_agenda_label']=$search_agenda_label; + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; // TODO Replace this with same code than into list.php //show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 9d0954d277e..5a58a068a64 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -23,19 +23,19 @@ */ // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -45,12 +45,12 @@ dol_include_once('/mymodule/class/myobject.class.php'); dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); // Load translation files required by the page -$langs->loadLangs(array("mymodule@mymodule","companies","other","mails")); +$langs->loadLangs(array("mymodule@mymodule", "companies", "other", "mails")); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm'); -$id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); +$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); // Get parameters @@ -61,30 +61,30 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; //if (! $sortfield) $sortfield="position_name"; // Initialize technical objects -$object=new MyObject($db); +$object = new MyObject($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectdocument','globalcard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectdocument', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals //if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity?$object->entity:$conf->entity] . "/myobject/" . dol_sanitizeFileName($object->id); -if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity?$object->entity:$conf->entity] . "/myobject/" . dol_sanitizeFileName($object->ref); +if ($id > 0 || !empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity ? $object->entity : $conf->entity]."/myobject/".dol_sanitizeFileName($object->ref); // Security check - Protection if external user //if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $object->id); -$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php @@ -92,7 +92,7 @@ $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the in * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -101,8 +101,8 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title=$langs->trans("MyObject").' - '.$langs->trans("Files"); -$help_url=''; +$title = $langs->trans("MyObject").' - '.$langs->trans("Files"); +$help_url = ''; //$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); @@ -117,16 +117,16 @@ if ($object->id) // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } // Object card // ------------------------------------------------------------ - $linkback = '<a href="' .dol_buildpath('/mymodule/myobject_list.php', 1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; + $linkback = '<a href="'.dol_buildpath('/mymodule/myobject_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -152,12 +152,12 @@ if ($object->id) $permission = 1; //$permtoedit = $user->rights->mymodule->myobject->write; $permtoedit = 1; - $param = '&id=' . $object->id; + $param = '&id='.$object->id; //$relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->id).'/'; - $relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->ref).'/'; + $relativepathwithnofile = 'myobject/'.dol_sanitizeFileName($object->ref).'/'; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 0cfade3c8f8..923fc6e5744 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -42,47 +42,47 @@ //if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // load mymodule libraries -require_once __DIR__ . '/class/myobject.class.php'; +require_once __DIR__.'/class/myobject.class.php'; // for other modules //dol_include_once('/othermodule/class/otherobject.class.php'); // Load translation files required by the page -$langs->loadLangs(array("mymodule@mymodule","other")); +$langs->loadLangs(array("mymodule@mymodule", "other")); -$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') +$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') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -94,8 +94,8 @@ $pagenext = $page + 1; // Initialize technical objects $object = new MyObject($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -104,12 +104,12 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check if (empty($conf->mymodule->enabled)) accessforbidden('Module not enabled'); -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -166,11 +166,11 @@ $permissiontodelete = $user->rights->mymodule->myobject->delete; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -179,24 +179,24 @@ if (empty($reshook)) 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 + 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='MyObject'; - $objectlabel='MyObject'; + $objectclass = 'MyObject'; + $objectlabel = 'MyObject'; $uploaddir = $conf->mymodule->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -207,49 +207,49 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("MyObjects")); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=preg_replace('/^,/', '', $hookmanager->resPrint); -$sql =preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -267,7 +267,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/,\s*$/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -288,10 +288,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -301,7 +301,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && ! $page) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -330,30 +330,30 @@ jQuery(document).ready(function() { }); </script>'; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); - else $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'validate'=>$langs->trans("Validate"), //'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); -if ($permissiontodelete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -370,16 +370,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle' print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendMyObjectRef"; -$modelmail="myobject"; -$objecttmp=new MyObject($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendMyObjectRef"; +$modelmail = "myobject"; +$objecttmp = new MyObject($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; @@ -387,39 +387,39 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'">'; + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; print '</td>'; @@ -429,12 +429,12 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$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 '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -443,23 +443,23 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -467,56 +467,56 @@ print '</tr>'."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print '<tr class="oddeven">'; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print '</td>'; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -524,19 +524,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'."\n"; @@ -549,16 +549,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -568,19 +568,19 @@ print '</form>'."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$permissiontoread; - $delallowed=$permissiontoadd; + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index 89a8ed5513b..f7440c71cf8 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -23,38 +23,38 @@ */ // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); dol_include_once('/mymodule/class/myobject.class.php'); dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); // Load translation files required by the page -$langs->loadLangs(array("mymodule@mymodule","companies")); +$langs->loadLangs(array("mymodule@mymodule", "companies")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new MyObject($db); +$object = new MyObject($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectnote','globalcard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectnote', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -64,11 +64,11 @@ $extrafields->fetch_name_optionals_label($object->table_element); //$result = restrictedArea($user, 'mymodule', $id); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id; +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || !empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; -$permissionnote=$user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php -$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php @@ -76,7 +76,7 @@ $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the in * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once /* @@ -86,10 +86,10 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, $form = new Form($db); //$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; -$help_url=''; +$help_url = ''; llxHeader('', $langs->trans('MyObject'), $help_url); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); @@ -99,9 +99,9 @@ if ($id > 0 || ! empty($ref)) // Object card // ------------------------------------------------------------ - $linkback = '<a href="' .dol_buildpath('/mymodule/myobject_list.php', 1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; + $linkback = '<a href="'.dol_buildpath('/mymodule/myobject_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; - $morehtmlref='<div class="refidno">'; + $morehtmlref = '<div class="refidno">'; /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); @@ -141,7 +141,7 @@ if ($id > 0 || ! empty($ref)) } } }*/ - $morehtmlref.='</div>'; + $morehtmlref .= '</div>'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -151,7 +151,7 @@ if ($id > 0 || ! empty($ref)) print '<div class="underbanner clearboth"></div>'; - $cssclass="titlefield"; + $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; print '</div>'; diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 6124101cffa..4d3bb9cd313 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -48,28 +48,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // load mrp libraries -require_once __DIR__ . '/class/mo.class.php'; +require_once __DIR__.'/class/mo.class.php'; // for other modules //dol_include_once('/othermodule/class/otherobject.class.php'); // Load translation files required by the page -$langs->loadLangs(array("mrp","other")); +$langs->loadLangs(array("mrp", "other")); -$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'):'molist'; // 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') +$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') : 'molist'; // 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') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -83,8 +83,8 @@ $pagenext = $page + 1; // Initialize technical objects $object = new Mo($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('molist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('molist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -92,12 +92,12 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check if (empty($conf->mrp->enabled)) accessforbidden('Module not enabled'); -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -107,34 +107,34 @@ if ($user->socid > 0) // Protection if external user // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -146,11 +146,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -159,24 +159,24 @@ if (empty($reshook)) 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 + 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Mo'; - $objectlabel='Mo'; + $objectclass = 'Mo'; + $objectlabel = 'Mo'; $permissiontoread = $user->rights->mrp->read; $permissiontodelete = $user->rights->mrp->delete; $uploaddir = $conf->mrp->dir_output; @@ -189,47 +189,47 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_Mo|FR:Module_Mo_FR|ES:Módulo_Mo"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOfManufacturingOrders'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -247,7 +247,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -268,10 +268,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -281,7 +281,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -310,30 +310,30 @@ jQuery(document).ready(function() { }); </script>'; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); - else $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'validate'=>$langs->trans("Validate"), //'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); -if ($user->rights->mrp->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->mrp->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -350,16 +350,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle' print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cubes', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendMoRef"; -$modelmail="mo"; -$objecttmp=new Mo($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendMoRef"; +$modelmail = "mo"; +$objecttmp = new Mo($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; @@ -367,39 +367,39 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'">'; + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; print '</td>'; @@ -409,12 +409,12 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$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 '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -423,23 +423,23 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -447,56 +447,56 @@ print '</tr>'."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print '<tr class="oddeven">'; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print '</td>'; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -504,19 +504,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'; @@ -530,16 +530,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -549,19 +549,19 @@ print '</form>'."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mrp->read; - $delallowed=$user->rights->mrp->write; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->mrp->read; + $delallowed = $user->rights->mrp->write; print $formfile->showdocuments('massfilesarea_mrp', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index b772cef3705..6f5fd824b06 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -30,23 +30,23 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; // Load translation files required by the page $langs->load("opensurvey"); -$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') +$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') -$id=GETPOST('id', 'alpha'); +$id = GETPOST('id', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha'); $search_title = GETPOST('search_title', 'alpha'); $search_status = GETPOST('search_status', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -107,11 +107,11 @@ $permissiontodelete = $user->rights->opensurvey->delete; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -146,33 +146,33 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); $now = dol_now(); //$help_url="EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject"; -$help_url=''; +$help_url = ''; $title = $langs->trans('OpenSurveyArea'); $sql = "SELECT p.id_sondage as rowid, p.fk_user_creat, p.format, p.date_fin, p.status, p.titre, p.nom_admin,"; -$sql.= " u.login, u.firstname, u.lastname"; -$sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; -$sql.= " WHERE p.entity IN (".getEntity('survey').")"; -if ($search_status != '-1' && $search_status != '') $sql.=natural_search("p.status", $search_status, 2); -if ($search_expired == 'expired') $sql.=" AND p.date_fin < '".$db->idate($now)."'"; -if ($search_expired == 'opened') $sql.=" AND p.date_fin >= '".$db->idate($now)."'"; -if ($search_ref) $sql.=natural_search("p.id_sondage", $search_ref); -if ($search_title) $sql.=natural_search("p.titre", $search_title); +$sql .= " u.login, u.firstname, u.lastname"; +$sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; +$sql .= " WHERE p.entity IN (".getEntity('survey').")"; +if ($search_status != '-1' && $search_status != '') $sql .= natural_search("p.status", $search_status, 2); +if ($search_expired == 'expired') $sql .= " AND p.date_fin < '".$db->idate($now)."'"; +if ($search_expired == 'opened') $sql .= " AND p.date_fin >= '".$db->idate($now)."'"; +if ($search_ref) $sql .= natural_search("p.id_sondage", $search_ref); +if ($search_title) $sql .= natural_search("p.titre", $search_title); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -193,10 +193,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -206,7 +206,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -275,25 +275,25 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields=''; -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$selectedfields = ''; +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '<div class="div-table-responsive">'; -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- @@ -334,8 +334,8 @@ print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.status", $param, "", // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; @@ -345,27 +345,27 @@ print '</tr>'."\n"; // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen - $sql2='select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->id_sondage)."'"; - $resql2=$db->query($sql2); + $sql2 = 'select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->id_sondage)."'"; + $resql2 = $db->query($sql2); if ($resql2) { - $obj2=$db->fetch_object($resql2); - $nbuser=$obj2->nb; + $obj2 = $db->fetch_object($resql2); + $nbuser = $obj2->nb; } else dol_print_error($db); - $opensurvey_static->id=$obj->rowid; - $opensurvey_static->ref=$obj->rowid; - $opensurvey_static->title=$obj->titre; - $opensurvey_static->status=$obj->status; - $opensurvey_static->date_fin=$db->jdate($obj->date_fin); + $opensurvey_static->id = $obj->rowid; + $opensurvey_static->ref = $obj->rowid; + $opensurvey_static->title = $obj->titre; + $opensurvey_static->status = $obj->status; + $opensurvey_static->date_fin = $db->jdate($obj->date_fin); // Show here line of result print '<tr class="oddeven">'; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index ac2ac589200..843a7b6cb0a 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -29,22 +29,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; // Load translation files required by the page -$langs->loadLangs(array("stocks","other")); +$langs->loadLangs(array("stocks", "other")); -$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'):'inventorylist'; // 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') +$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') : 'inventorylist'; // 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') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -54,20 +54,20 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object=new Inventory($db); +$object = new Inventory($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('inventorylist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->inventory->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('inventorylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -83,34 +83,34 @@ else } // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -122,11 +122,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -135,24 +135,24 @@ if (empty($reshook)) 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 + 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Inventory'; - $objectlabel='Inventory'; + $objectclass = 'Inventory'; + $objectlabel = 'Inventory'; $permissiontoread = $user->rights->stock->lire; $permissiontodelete = $user->rights->stock->supprimer; $uploaddir = $conf->stock->dir_output; @@ -165,48 +165,48 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_Inventory|FR:Module_Inventory_FR|ES:Módulo_Inventory"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOfInventories'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -225,7 +225,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -246,10 +246,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -259,7 +259,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -273,28 +273,28 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader('', $title, $help_url); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); - else $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->stock->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -311,16 +311,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle' print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="Information"; -$modelmail="inventory"; -$objecttmp=new Inventory($db); -$trackid='inve'.$object->id; +$topicmail = "Information"; +$modelmail = "inventory"; +$objecttmp = new Inventory($db); +$trackid = 'inve'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; @@ -328,39 +328,39 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'">'; + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; print '</td>'; @@ -370,12 +370,12 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$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 '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -384,23 +384,23 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -408,55 +408,55 @@ print '</tr>'."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print '<tr class="oddeven">'; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print '</td>'; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -464,19 +464,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'."\n"; @@ -490,16 +490,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -509,19 +509,19 @@ print '</form>'."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->mymodule->read; + $delallowed = $user->rights->mymodule->create; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index d9369fcb148..33ad0b4806c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -37,26 +37,26 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (! empty($conf->categorie->enabled)) +if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'suppliers', 'companies')); -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref=GETPOST("search_ref", 'alpha'); -$search_barcode=GETPOST("search_barcode", 'alpha'); -$search_label=GETPOST("search_label", 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST("search_ref", 'alpha'); +$search_barcode = GETPOST("search_barcode", 'alpha'); +$search_label = GETPOST("search_label", 'alpha'); $search_type = GETPOST("search_type", 'int'); $search_sale = GETPOST("search_sale", 'int'); -$search_vatrate=GETPOST("search_vatrate", 'alpha'); +$search_vatrate = GETPOST("search_vatrate", 'alpha'); $searchCategoryProductOperator = (GETPOST('search_category_product_operator', 'int') ? GETPOST('search_category_product_operator', 'int') : 0); $searchCategoryProductList = GETPOST('search_category_product_list', 'array'); $search_tosell = GETPOST("search_tosell", 'int'); @@ -69,49 +69,49 @@ $search_accountancy_code_sell_intra = GETPOST("search_accountancy_code_sell_intr $search_accountancy_code_sell_export = GETPOST("search_accountancy_code_sell_export", 'alpha'); $search_accountancy_code_buy = GETPOST("search_accountancy_code_buy", 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); -$type=GETPOST("type", "int"); +$type = GETPOST("type", "int"); //Show/hide child products -if (!empty($conf->variants->enabled) && ! empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { +if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { $show_childproducts = GETPOST('search_show_childproducts'); } else { $show_childproducts = ''; } -$diroutputmassaction=$conf->product->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = (GETPOST("page", 'int')?GETPOST("page", 'int'):0); +$page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "ASC"; // Initialize context for list -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'productservicelist'; -if ((string) $type == '1') { $contextpage='servicelist'; if ($search_type=='') $search_type='1'; } -if ((string) $type == '0') { $contextpage='productlist'; if ($search_type=='') $search_type='0'; } +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'productservicelist'; +if ((string) $type == '1') { $contextpage = 'servicelist'; if ($search_type == '') $search_type = '1'; } +if ((string) $type == '0') { $contextpage = 'productlist'; if ($search_type == '') $search_type = '0'; } // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks -$object=new Product($db); +$object = new Product($db); $hookmanager->initHooks(array('productservicelist')); $extrafields = new ExtraFields($db); -$form=new Form($db); +$form = new Form($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('product'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -if (empty($action)) $action='list'; +if (empty($action)) $action = 'list'; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -$canvas=GETPOST("canvas"); -$objcanvas=null; -if (! empty($canvas)) +$canvas = GETPOST("canvas"); +$objcanvas = null; +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); @@ -119,15 +119,15 @@ if (! empty($canvas)) } // Security check -if ($search_type=='0') $result=restrictedArea($user, 'produit', '', '', '', '', '', $objcanvas); -elseif ($search_type=='1') $result=restrictedArea($user, 'service', '', '', '', '', '', $objcanvas); -else $result=restrictedArea($user, 'produit|service', '', '', '', '', '', $objcanvas); +if ($search_type == '0') $result = restrictedArea($user, 'produit', '', '', '', '', '', $objcanvas); +elseif ($search_type == '1') $result = restrictedArea($user, 'service', '', '', '', '', '', $objcanvas); +else $result = restrictedArea($user, 'produit|service', '', '', '', '', '', $objcanvas); // Define virtualdiffersfromphysical -$virtualdiffersfromphysical=0; -if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) ) +$virtualdiffersfromphysical = 0; +if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { - $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } // List of fields to search into when doing a "search in all" @@ -140,52 +140,52 @@ $fieldstosearchall = array( ); // multilang -if (! empty($conf->global->MAIN_MULTILANGS)) +if (!empty($conf->global->MAIN_MULTILANGS)) { - $fieldstosearchall['pl.label']='ProductLabelTranslated'; - $fieldstosearchall['pl.description']='ProductDescriptionTranslated'; - $fieldstosearchall['pl.note']='ProductNoteTranslated'; + $fieldstosearchall['pl.label'] = 'ProductLabelTranslated'; + $fieldstosearchall['pl.description'] = 'ProductDescriptionTranslated'; + $fieldstosearchall['pl.note'] = 'ProductNoteTranslated'; } -if (! empty($conf->barcode->enabled)) { - $fieldstosearchall['p.barcode']='Gencod'; - $fieldstosearchall['pfp.barcode']='GencodBuyPrice'; +if (!empty($conf->barcode->enabled)) { + $fieldstosearchall['p.barcode'] = 'Gencod'; + $fieldstosearchall['pfp.barcode'] = 'GencodBuyPrice'; } // Personalized search criterias. Example: $conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS = 'p.ref=ProductRef;p.label=ProductLabel' -if (! empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall=dolExplodeIntoArray($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS); +if (!empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall = dolExplodeIntoArray($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS); if (empty($conf->global->PRODUIT_MULTIPRICES)) { - $titlesellprice=$langs->trans("SellingPrice"); - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + $titlesellprice = $langs->trans("SellingPrice"); + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - $titlesellprice=$form->textwithpicto($langs->trans("SellingPrice"), $langs->trans("DefaultPriceRealPriceMayDependOnCustomer")); + $titlesellprice = $form->textwithpicto($langs->trans("SellingPrice"), $langs->trans("DefaultPriceRealPriceMayDependOnCustomer")); } } -$isInEEC=isInEEC($mysoc); +$isInEEC = isInEEC($mysoc); // Definition of fields for lists -$arrayfields=array( +$arrayfields = array( 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), //'pfp.ref_fourn'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), 'p.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 'p.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(! empty($conf->product->enabled) && ! empty($conf->service->enabled))), - 'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), - 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled) && (string) $type == '1')), - 'p.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0, 'enabled'=>(! empty($conf->product->enabled))), - 'p.length'=>array('label'=>$langs->trans("Length"), 'checked'=>0, 'enabled'=>(! empty($conf->product->enabled) && ! empty($conf->global->PRODUCT_DISABLE_SIZE))), - 'p.surface'=>array('label'=>$langs->trans("Surface"), 'checked'=>0, 'enabled'=>(! empty($conf->product->enabled) && ! empty($conf->global->PRODUCT_DISABLE_SURFACE))), - 'p.volume'=>array('label'=>$langs->trans("Volume"), 'checked'=>0, 'enabled'=>(! empty($conf->product->enabled) && ! empty($conf->global->PRODUCT_DISABLE_VOLUME))), + 'p.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && !empty($conf->service->enabled))), + 'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>1, 'enabled'=>(!empty($conf->barcode->enabled))), + 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(!empty($conf->service->enabled) && (string) $type == '1')), + 'p.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled))), + 'p.length'=>array('label'=>$langs->trans("Length"), 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && !empty($conf->global->PRODUCT_DISABLE_SIZE))), + 'p.surface'=>array('label'=>$langs->trans("Surface"), 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && !empty($conf->global->PRODUCT_DISABLE_SURFACE))), + 'p.volume'=>array('label'=>$langs->trans("Volume"), 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && !empty($conf->global->PRODUCT_DISABLE_VOLUME))), 'p.sellprice'=>array('label'=>$langs->trans("SellingPrice"), 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)), - 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))), - 'p.numbuyprice'=>array('label'=>$langs->trans("BuyingPriceNumShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), - 'p.tva_tx'=>array('label'=>$langs->trans("VATRate"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), - 'p.pmp'=>array('label'=>$langs->trans("PMPValueShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), - 'p.seuil_stock_alerte'=>array('label'=>$langs->trans("StockLimit"), 'checked'=>0, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), - 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), - 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), - 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical)), - 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), + 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(!empty($user->rights->fournisseur->lire))), + 'p.numbuyprice'=>array('label'=>$langs->trans("BuyingPriceNumShort"), 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire))), + 'p.tva_tx'=>array('label'=>$langs->trans("VATRate"), 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire))), + 'p.pmp'=>array('label'=>$langs->trans("PMPValueShort"), 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire))), + 'p.seuil_stock_alerte'=>array('label'=>$langs->trans("StockLimit"), 'checked'=>0, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical)), + 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled))), 'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0, 'position'=>400), 'p.accountancy_code_sell_intra'=>array('label'=>$langs->trans("ProductAccountancySellIntraCode"), 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401), 'p.accountancy_code_sell_export'=>array('label'=>$langs->trans("ProductAccountancySellExportCode"), 'checked'=>0, 'position'=>402), @@ -198,10 +198,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -213,11 +213,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -228,30 +228,30 @@ if (empty($reshook)) // 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 { - $sall=""; - $search_ref=""; - $search_label=""; - $search_barcode=""; + $sall = ""; + $search_ref = ""; + $search_label = ""; + $search_barcode = ""; $searchCategoryProductOperator = 0; $searchCategoryProductList = array(); - $search_tosell=""; - $search_tobuy=""; - $search_vatrate=""; - $search_tobatch=''; + $search_tosell = ""; + $search_tobuy = ""; + $search_vatrate = ""; + $search_tobatch = ''; //$search_type=''; // There is 2 types of list: a list of product and a list of services. No list with both. So when we clear search criteria, we must keep the filter on type. $show_childproducts = ''; - $search_accountancy_code_sell=''; - $search_accountancy_code_sell_intra=''; - $search_accountancy_code_sell_export=''; - $search_accountancy_code_buy=''; - $search_array_options=array(); + $search_accountancy_code_sell = ''; + $search_accountancy_code_sell_intra = ''; + $search_accountancy_code_sell_export = ''; + $search_accountancy_code_buy = ''; + $search_array_options = array(); } // Mass actions - $objectclass='Product'; - if ((string) $search_type == '1') { $objectlabel='Services'; } - if ((string) $search_type == '0') { $objectlabel='Products'; } + $objectclass = 'Product'; + if ((string) $search_type == '1') { $objectlabel = 'Services'; } + if ((string) $search_type == '0') { $objectlabel = 'Products'; } $permissiontoread = $user->rights->produit->lire; $permissiontodelete = $user->rights->produit->supprimer; @@ -264,9 +264,9 @@ if (empty($reshook)) * View */ -$htmlother=new FormOther($db); +$htmlother = new FormOther($db); -$title=$langs->trans("ProductsAndServices"); +$title = $langs->trans("ProductsAndServices"); if ($search_type != '' && $search_type != '-1') { @@ -285,111 +285,111 @@ else } $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type, p.entity,'; -$sql.= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; -$sql.= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,'; -$sql.= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock,'; -$sql.= ' p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.width, p.width_units, p.height, p.height_units,'; -$sql.= ' MIN(pfp.unitprice) as minsellprice'; -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && ! $show_childproducts )) { +$sql .= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; +$sql .= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,'; +$sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock,'; +$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.width, p.width_units, p.height, p.height_units,'; +$sql .= ' MIN(pfp.unitprice) as minsellprice'; +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= ', pac.rowid prod_comb_id'; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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.'product as p'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; -if (!empty($searchCategoryProductList) || !empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; +$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.'product as p'; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; +if (!empty($searchCategoryProductList) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; // multilang -if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$langs->getDefaultLang() ."'"; +if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$langs->getDefaultLang()."'"; -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && ! $show_childproducts )) { +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } -$sql.= ' WHERE p.entity IN ('.getEntity('product').')'; +$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($search_type) && $search_type != '-1') { - if ($search_type == 1) $sql.= " AND p.fk_product_type = 1"; - else $sql.= " AND p.fk_product_type <> 1"; + if ($search_type == 1) $sql .= " AND p.fk_product_type = 1"; + else $sql .= " AND p.fk_product_type <> 1"; } -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && ! $show_childproducts )) { +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= " AND pac.rowid IS NULL"; } if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_label) $sql .= natural_search('p.label', $search_label); if ($search_barcode) $sql .= natural_search('p.barcode', $search_barcode); -if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell!=-1) $sql.= " AND p.tosell = ".$db->escape($search_tosell); -if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy!=-1) $sql.= " AND p.tobuy = ".$db->escape($search_tobuy); +if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell != -1) $sql .= " AND p.tosell = ".$db->escape($search_tosell); +if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy != -1) $sql .= " AND p.tobuy = ".$db->escape($search_tobuy); if ($search_vatrate) $sql .= natural_search('p.tva_tx', $search_vatrate); -if (dol_strlen($canvas) > 0) $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; -if ($catid > 0) $sql.= " AND cp.fk_categorie = ".$catid; -if ($catid == -2) $sql.= " AND cp.fk_categorie IS NULL"; +if (dol_strlen($canvas) > 0) $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; +if ($catid > 0) $sql .= " AND cp.fk_categorie = ".$catid; +if ($catid == -2) $sql .= " AND cp.fk_categorie IS NULL"; $searchCategoryProductSqlList = array(); if ($searchCategoryProductOperator == 1) { foreach ($searchCategoryProductList as $searchCategoryProduct) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL"; } elseif (intval($searchCategoryProduct) > 0) { - $searchCategoryProductSqlList[] = "cp.fk_categorie = " . $db->escape($searchCategoryProduct); + $searchCategoryProductSqlList[] = "cp.fk_categorie = ".$db->escape($searchCategoryProduct); } } if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (" . implode(' OR ', $searchCategoryProductSqlList) . ")"; + $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; } } else { foreach ($searchCategoryProductList as $searchCategoryProduct) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL"; } elseif (intval($searchCategoryProduct) > 0) { - $searchCategoryProductSqlList[] = "p.rowid IN (SELECT fk_product FROM " . MAIN_DB_PREFIX . "categorie_product WHERE fk_categorie = " . $searchCategoryProduct . ")"; + $searchCategoryProductSqlList[] = "p.rowid IN (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_categorie = ".$searchCategoryProduct.")"; } } if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (" . implode(' AND ', $searchCategoryProductSqlList) . ")"; + $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; } } -if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id; -if ($search_tobatch != '' && $search_tobatch >= 0) $sql.= " AND p.tobatch = ".$db->escape($search_tobatch); -if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); -if ($search_accountancy_code_sell_intra) $sql.= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); -if ($search_accountancy_code_sell_export) $sql.= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); -if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); +if ($fourn_id > 0) $sql .= " AND pfp.fk_soc = ".$fourn_id; +if ($search_tobatch != '' && $search_tobatch >= 0) $sql .= " AND p.tobatch = ".$db->escape($search_tobatch); +if ($search_accountancy_code_sell) $sql .= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); +if ($search_accountancy_code_sell_intra) $sql .= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); +if ($search_accountancy_code_sell_export) $sql .= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); +if ($search_accountancy_code_buy) $sql .= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type,"; -$sql.= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; -$sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.pmp, p.stock,'; -$sql.= ' p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.width, p.width_units, p.height, p.height_units'; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type,"; +$sql .= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; +$sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.pmp, p.stock,'; +$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.width, p.width_units, p.height, p.height_units'; -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && ! $show_childproducts )) { +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= ', pac.rowid'; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; //if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -403,7 +403,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); @@ -411,9 +411,9 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -421,81 +421,81 @@ if ($resql) exit; } - $helpurl=''; + $helpurl = ''; if ($search_type != '') { if ($search_type == 0) { - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } elseif ($search_type == 1) { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } } llxHeader('', $title, $helpurl, ''); // Displays product removal confirmation - if (GETPOST('delprod')) { + if (GETPOST('delprod')) { setEventMessages($langs->trans("ProductDeleted", GETPOST('delprod')), null, 'mesgs'); } - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($searchCategoryProductOperator == 1) $param .= "&search_category_product_operator=" . urlencode($searchCategoryProductOperator); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= "&sall=".urlencode($sall); + if ($searchCategoryProductOperator == 1) $param .= "&search_category_product_operator=".urlencode($searchCategoryProductOperator); foreach ($searchCategoryProductList as $searchCategoryProduct) { - $param .= "&search_category_product_list[]=" . urlencode($searchCategoryProduct); + $param .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); } - if ($search_ref) $param="&search_ref=".urlencode($search_ref); - if ($search_ref_supplier) $param="&search_ref_supplier=".urlencode($search_ref_supplier); - if ($search_barcode) $param.=($search_barcode?"&search_barcode=".urlencode($search_barcode):""); - if ($search_label) $param.="&search_label=".urlencode($search_label); - if ($search_tosell != '') $param.="&search_tosell=".urlencode($search_tosell); - if ($search_tobuy != '') $param.="&search_tobuy=".urlencode($search_tobuy); + if ($search_ref) $param = "&search_ref=".urlencode($search_ref); + if ($search_ref_supplier) $param = "&search_ref_supplier=".urlencode($search_ref_supplier); + if ($search_barcode) $param .= ($search_barcode ? "&search_barcode=".urlencode($search_barcode) : ""); + if ($search_label) $param .= "&search_label=".urlencode($search_label); + if ($search_tosell != '') $param .= "&search_tosell=".urlencode($search_tosell); + if ($search_tobuy != '') $param .= "&search_tobuy=".urlencode($search_tobuy); if ($search_vatrate) $sql .= natural_search('p.tva_tx', $search_vatrate); - if ($fourn_id > 0) $param.=($fourn_id?"&fourn_id=".$fourn_id:""); + if ($fourn_id > 0) $param .= ($fourn_id ? "&fourn_id=".$fourn_id : ""); //if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):""); - if ($show_childproducts) $param.=($show_childproducts?"&search_show_childproducts=".urlencode($show_childproducts):""); - if ($type != '') $param.='&type='.urlencode($type); - if ($search_type != '') $param.='&search_type='.urlencode($search_type); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier); - if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); - if ($search_accountancy_code_sell_intra) $param="&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra); - if ($search_accountancy_code_sell_export) $param="&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export); - if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); + if ($show_childproducts) $param .= ($show_childproducts ? "&search_show_childproducts=".urlencode($show_childproducts) : ""); + if ($type != '') $param .= '&type='.urlencode($type); + if ($search_type != '') $param .= '&search_type='.urlencode($search_type); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($search_tobatch) $param = "&search_ref_supplier=".urlencode($search_ref_supplier); + if ($search_accountancy_code_sell) $param = "&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); + if ($search_accountancy_code_sell_intra) $param = "&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra); + if ($search_accountancy_code_sell_export) $param = "&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export); + if ($search_accountancy_code_buy) $param = "&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->produit->supprimer) $arrayofmassactions['predelete']="<span class='fa fa-trash paddingrightonly'></span>".$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->produit->supprimer) $arrayofmassactions['predelete'] = "<span class='fa fa-trash paddingrightonly'></span>".$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; - $rightskey='produit'; - if($type == Product::TYPE_SERVICE) $rightskey='service'; - if($user->rights->{$rightskey}->creer) + $newcardbutton = ''; + $rightskey = 'produit'; + if ($type == Product::TYPE_SERVICE) $rightskey = 'service'; + if ($user->rights->{$rightskey}->creer) { - $oldtype=$type; + $oldtype = $type; if ($type === "") { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0'); $type = Product::TYPE_SERVICE; } - $label='NewProduct'; - if($type == Product::TYPE_SERVICE) $label='NewService'; - $newcardbutton.= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type='.$type); + $label = 'NewProduct'; + if ($type == Product::TYPE_SERVICE) $label = 'NewService'; + $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type='.$type); - $type=$oldtype; + $type = $oldtype; } print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">'; @@ -511,13 +511,13 @@ if ($resql) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit); - $topicmail="Information"; - $modelmail="product"; - $objecttmp=new Product($db); - $trackid='prod'.$object->id; + $topicmail = "Information"; + $modelmail = "product"; + $objecttmp = new Product($db); + $trackid = 'prod'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if (! empty($catid)) + if (!empty($catid)) { print "<div id='ways'>"; $c = new Categorie($db); @@ -528,35 +528,35 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) + $moreforfilter = ''; + if (!empty($conf->categorie->enabled)) { - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('Categories').': '; $categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1); - $categoriesProductArr[-2] = '- ' . $langs->trans('NotCategorized') . ' -'; - $moreforfilter.=Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300'); - $moreforfilter.=' <input type="checkbox" class="valignmiddle" name="search_category_product_operator" value="1"' . ($searchCategoryProductOperator==1 ? ' checked="checked"' : '') . '/> ' . $langs->trans('UseOrOperatorForCategories'); - $moreforfilter.='</div>'; + $categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -'; + $moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300'); + $moreforfilter .= ' <input type="checkbox" class="valignmiddle" name="search_category_product_operator" value="1"'.($searchCategoryProductOperator == 1 ? ' checked="checked"' : '').'/> '.$langs->trans('UseOrOperatorForCategories'); + $moreforfilter .= '</div>'; } //Show/hide child products. Hidden by default if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.= '<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts"'.($show_childproducts ? 'checked="checked"':'').'>'; - $moreforfilter.= ' <label for="search_show_childproducts">'.$langs->trans('ShowChildProducts').'</label>'; - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= '<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts"'.($show_childproducts ? 'checked="checked"' : '').'>'; + $moreforfilter .= ' <label for="search_show_childproducts">'.$langs->trans('ShowChildProducts').'</label>'; + $moreforfilter .= '</div>'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint; - else $moreforfilter=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; if ($moreforfilter) { @@ -565,258 +565,258 @@ if ($resql) print '</div>'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Lines with input filters print '<tr class="liste_titre_filter">'; - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) + if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat" type="text" name="search_ref_supplier" size="8" value="'.dol_escape_htmltag($search_ref_supplier).'">'; print '</td>'; } - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).'">'; print '</td>'; } // Type - if (! empty($arrayfields['p.fk_product_type']['checked'])) + if (!empty($arrayfields['p.fk_product_type']['checked'])) { print '<td class="liste_titre left">'; - $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); + $array = array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); print $form->selectarray('search_type', $array, $search_type); print '</td>'; } // Barcode - if (! empty($arrayfields['p.barcode']['checked'])) + if (!empty($arrayfields['p.barcode']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" type="text" name="search_barcode" size="6" value="'.dol_escape_htmltag($search_barcode).'">'; print '</td>'; } // Duration - if (! empty($arrayfields['p.duration']['checked'])) + if (!empty($arrayfields['p.duration']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Weight - if (! empty($arrayfields['p.weight']['checked'])) + if (!empty($arrayfields['p.weight']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Length - if (! empty($arrayfields['p.length']['checked'])) + if (!empty($arrayfields['p.length']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Surface - if (! empty($arrayfields['p.surface']['checked'])) + if (!empty($arrayfields['p.surface']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Volume - if (! empty($arrayfields['p.volume']['checked'])) + if (!empty($arrayfields['p.volume']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Sell price - if (! empty($arrayfields['p.sellprice']['checked'])) + if (!empty($arrayfields['p.sellprice']['checked'])) { print '<td class="liste_titre right">'; print '</td>'; } // Minimum buying Price - if (! empty($arrayfields['p.minbuyprice']['checked'])) + if (!empty($arrayfields['p.minbuyprice']['checked'])) { print '<td class="liste_titre">'; print ' '; print '</td>'; } // Number buying Price - if (! empty($arrayfields['p.numbuyprice']['checked'])) + if (!empty($arrayfields['p.numbuyprice']['checked'])) { print '<td class="liste_titre">'; print ' '; print '</td>'; } // Sell price - if (! empty($arrayfields['p.tva_tx']['checked'])) + if (!empty($arrayfields['p.tva_tx']['checked'])) { print '<td class="liste_titre right">'; print '<input class="right flat maxwidth50" placeholder="%" type="text" name="search_vatrate" size="1" value="'.dol_escape_htmltag($search_vatrate).'">'; print '</td>'; } // WAP - if (! empty($arrayfields['p.pmp']['checked'])) + if (!empty($arrayfields['p.pmp']['checked'])) { print '<td class="liste_titre">'; print ' '; print '</td>'; } // Limit for alert - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) + if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { print '<td class="liste_titre">'; print ' '; print '</td>'; } // Desired stock - if (! empty($arrayfields['p.desiredstock']['checked'])) + if (!empty($arrayfields['p.desiredstock']['checked'])) { print '<td class="liste_titre">'; print ' '; print '</td>'; } // Stock - if (! empty($arrayfields['p.stock']['checked'])) print '<td class="liste_titre"> </td>'; + if (!empty($arrayfields['p.stock']['checked'])) print '<td class="liste_titre"> </td>'; // Stock - if (! empty($arrayfields['stock_virtual']['checked'])) print '<td class="liste_titre"> </td>'; + if (!empty($arrayfields['stock_virtual']['checked'])) print '<td class="liste_titre"> </td>'; // To batch - if (! empty($arrayfields['p.tobatch']['checked'])) print '<td class="liste_titre center">'.$form->selectyesno($search_tobatch, '', '', '', 1).'</td>'; + if (!empty($arrayfields['p.tobatch']['checked'])) print '<td class="liste_titre center">'.$form->selectyesno($search_tobatch, '', '', '', 1).'</td>'; // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell" value="'.dol_escape_htmltag($search_accountancy_code_sell).'"></td>'; - if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_intra" value="'.dol_escape_htmltag($search_accountancy_code_sell_intra).'"></td>'; - if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_export" value="'.dol_escape_htmltag($search_accountancy_code_sell_export).'"></td>'; + if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell" value="'.dol_escape_htmltag($search_accountancy_code_sell).'"></td>'; + if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_intra" value="'.dol_escape_htmltag($search_accountancy_code_sell_intra).'"></td>'; + if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_export" value="'.dol_escape_htmltag($search_accountancy_code_sell_export).'"></td>'; // Accountancy code buy - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" name="search_accountancy_code_buy" size="6" value="'.dol_escape_htmltag($search_accountancy_code_buy).'"></td>'; + if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" name="search_accountancy_code_buy" size="6" value="'.dol_escape_htmltag($search_accountancy_code_buy).'"></td>'; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } - if (! empty($arrayfields['p.tosell']['checked'])) + if (!empty($arrayfields['p.tosell']['checked'])) { print '<td class="liste_titre right">'; - print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')), $search_tosell, 1); + print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'), '1'=>$langs->trans('ProductStatusOnSellShort')), $search_tosell, 1); print '</td >'; } - if (! empty($arrayfields['p.tobuy']['checked'])) + if (!empty($arrayfields['p.tobuy']['checked'])) { print '<td class="liste_titre right">'; - print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')), $search_tobuy, 1); + print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'), '1'=>$langs->trans('ProductStatusOnBuyShort')), $search_tobuy, 1); print '</td>'; } print '<td class="liste_titre center maxwidthsearch">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'; print '<tr class="liste_titre">'; - if (! empty($arrayfields['p.ref']['checked'])) { + if (!empty($arrayfields['p.ref']['checked'])) { print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) { + if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"], "pfp.ref_fourn", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['p.label']['checked'])) { + if (!empty($arrayfields['p.label']['checked'])) { print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], "p.label", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['p.fk_product_type']['checked'])) { + if (!empty($arrayfields['p.fk_product_type']['checked'])) { print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"], "p.fk_product_type", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['p.barcode']['checked'])) { + if (!empty($arrayfields['p.barcode']['checked'])) { print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"], "p.barcode", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['p.duration']['checked'])) { + if (!empty($arrayfields['p.duration']['checked'])) { print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"], "p.duration", "", $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['p.weight']['checked'])) print_liste_field_titre($arrayfields['p.weight']['label'], $_SERVER["PHP_SELF"], "p.weight", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.length']['checked'])) print_liste_field_titre($arrayfields['p.length']['label'], $_SERVER["PHP_SELF"], "p.length", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.surface']['checked'])) print_liste_field_titre($arrayfields['p.surface']['label'], $_SERVER["PHP_SELF"], "p.surface", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.volume']['checked'])) print_liste_field_titre($arrayfields['p.volume']['label'], $_SERVER["PHP_SELF"], "p.volume", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.sellprice']['checked'])) { + if (!empty($arrayfields['p.weight']['checked'])) print_liste_field_titre($arrayfields['p.weight']['label'], $_SERVER["PHP_SELF"], "p.weight", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['p.length']['checked'])) print_liste_field_titre($arrayfields['p.length']['label'], $_SERVER["PHP_SELF"], "p.length", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['p.surface']['checked'])) print_liste_field_titre($arrayfields['p.surface']['label'], $_SERVER["PHP_SELF"], "p.surface", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['p.volume']['checked'])) print_liste_field_titre($arrayfields['p.volume']['label'], $_SERVER["PHP_SELF"], "p.volume", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['p.sellprice']['checked'])) { print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.minbuyprice']['checked'])) { + if (!empty($arrayfields['p.minbuyprice']['checked'])) { print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.numbuyprice']['checked'])) { + if (!empty($arrayfields['p.numbuyprice']['checked'])) { print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.tva_tx']['checked'])) { + if (!empty($arrayfields['p.tva_tx']['checked'])) { print_liste_field_titre($arrayfields['p.tva_tx']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.pmp']['checked'])) { + if (!empty($arrayfields['p.pmp']['checked'])) { print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) { + if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"], "p.seuil_stock_alerte", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.desiredstock']['checked'])) { + if (!empty($arrayfields['p.desiredstock']['checked'])) { print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"], "p.desiredstock", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.stock']['checked'])) { + if (!empty($arrayfields['p.stock']['checked'])) { print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"], "p.stock", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['stock_virtual']['checked'])) { + if (!empty($arrayfields['stock_virtual']['checked'])) { print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.tobatch']['checked'])) { + if (!empty($arrayfields['p.tobatch']['checked'])) { print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"], "p.tobatch", "", $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) { + if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell", "", $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { + if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_sell_intra']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_intra", "", $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { + if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_sell_export']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_export", "", $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) { + if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy", "", $param, '', $sortfield, $sortorder); } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['p.datec']['checked'])) { + if (!empty($arrayfields['p.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } - if (! empty($arrayfields['p.tms']['checked'])) { + if (!empty($arrayfields['p.tms']['checked'])) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } - if (! empty($arrayfields['p.tosell']['checked'])) { + if (!empty($arrayfields['p.tosell']['checked'])) { print_liste_field_titre($arrayfields['p.tosell']['label'], $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.tobuy']['checked'])) { + if (!empty($arrayfields['p.tobuy']['checked'])) { print_liste_field_titre($arrayfields['p.tobuy']['label'], $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'right '); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -827,25 +827,25 @@ if ($resql) $product_fourn = new ProductFournisseur($db); $i = 0; - $totalarray=array(); + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$obj->rowid; - $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; - $sql.= " LIMIT 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$obj->rowid; + $sql .= " AND lang='".$db->escape($langs->getDefaultLang())."'"; + $sql .= " LIMIT 1"; $result = $db->query($sql); if ($result) { $objtp = $db->fetch_object($result); - if (! empty($objtp->label)) $obj->label = $objtp->label; + if (!empty($objtp->label)) $obj->label = $objtp->label; } } @@ -876,11 +876,11 @@ if ($resql) $product_static->surface = $obj->surface; $product_static->surface_units = $obj->surface_units; - if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock + if ((!empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock { - if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service + if ($obj->fk_product_type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service { - $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() + $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() } } @@ -888,107 +888,107 @@ if ($resql) print '<tr class="oddeven">'; // Ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="tdoverflowmax200">'; print $product_static->getNomUrl(1); print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref supplier - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) + if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { print '<td class="tdoverflowmax200">'; print $product_static->getNomUrl(1); print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Label - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { print '<td class="tdoverflowmax200">'.dol_trunc($obj->label, 80).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type - if (! empty($arrayfields['p.fk_product_type']['checked'])) + if (!empty($arrayfields['p.fk_product_type']['checked'])) { print '<td>'.$obj->fk_product_type.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Barcode - if (! empty($arrayfields['p.barcode']['checked'])) + if (!empty($arrayfields['p.barcode']['checked'])) { print '<td>'.$obj->barcode.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Duration - if (! empty($arrayfields['p.duration']['checked'])) + if (!empty($arrayfields['p.duration']['checked'])) { print '<td class="center nowraponall">'; if (preg_match('/([^a-z]+)[a-z]$/i', $obj->duration)) { - $duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1); - $duration_unit = substr($obj->duration, -1); + $duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); + $duration_unit = substr($obj->duration, -1); if ((float) $duration_value > 1) { - $dur=array("i"=>$langs->trans("Minutes"),"h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); + $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); } elseif ((float) $duration_value > 0) { - $dur=array("i"=>$langs->trans("Minute"),"h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } print $duration_value; - print ((! empty($duration_unit) && isset($dur[$duration_unit]) && $duration_value != '') ? ' '.$langs->trans($dur[$duration_unit]) : ''); + print ((!empty($duration_unit) && isset($dur[$duration_unit]) && $duration_value != '') ? ' '.$langs->trans($dur[$duration_unit]) : ''); } - elseif (! preg_match('/^[a-z]$/i', $obj->duration)) // If duration is a simple char (like 's' of 'm'), we do not show value + elseif (!preg_match('/^[a-z]$/i', $obj->duration)) // If duration is a simple char (like 's' of 'm'), we do not show value { print $obj->duration; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Weight - if (! empty($arrayfields['p.weight']['checked'])) + if (!empty($arrayfields['p.weight']['checked'])) { print '<td align="center">'; print $obj->weight; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Length - if (! empty($arrayfields['p.length']['checked'])) + if (!empty($arrayfields['p.length']['checked'])) { print '<td align="center">'; print $obj->length; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Surface - if (! empty($arrayfields['p.surface']['checked'])) + if (!empty($arrayfields['p.surface']['checked'])) { print '<td align="center">'; print $obj->surface; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Volume - if (! empty($arrayfields['p.volume']['checked'])) + if (!empty($arrayfields['p.volume']['checked'])) { print '<td align="center">'; print $obj->volume; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Sell price - if (! empty($arrayfields['p.sellprice']['checked'])) + if (!empty($arrayfields['p.sellprice']['checked'])) { print '<td class="right nowraponall">'; if ($obj->tosell) @@ -997,11 +997,11 @@ if ($resql) else print price($obj->price).' '.$langs->trans("HT"); } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Better buy price - if (! empty($arrayfields['p.minbuyprice']['checked'])) + if (!empty($arrayfields['p.minbuyprice']['checked'])) { print '<td class="right nowraponall">'; if ($obj->tobuy && $obj->minsellprice != '') @@ -1011,28 +1011,28 @@ if ($resql) { if ($product_fourn->product_fourn_price_id > 0) { - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { - $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext); + $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1); + print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext); } else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); } } } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Number of buy prices - if (! empty($arrayfields['p.numbuyprice']['checked'])) + if (!empty($arrayfields['p.numbuyprice']['checked'])) { print '<td class="right">'; if ($obj->tobuy) { if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) { - $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); + $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); print $form->textwithpicto(count($productFournList), $htmltext); } } @@ -1040,16 +1040,16 @@ if ($resql) } // Sell Tax Rate - if (! empty($arrayfields['p.tva_tx']['checked'])) + if (!empty($arrayfields['p.tva_tx']['checked'])) { print '<td class="right">'; print vatrate($obj->tva_tx, true); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // WAP - if (! empty($arrayfields['p.pmp']['checked'])) + if (!empty($arrayfields['p.pmp']['checked'])) { print '<td class="nowrap right">'; print price($product_static->pmp, 1, $langs); @@ -1057,7 +1057,7 @@ if ($resql) } // Limit alert - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) + if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { print '<td class="right">'; if ($obj->fk_product_type != 1) @@ -1065,10 +1065,10 @@ if ($resql) print $obj->seuil_stock_alerte; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Desired stock - if (! empty($arrayfields['p.desiredstock']['checked'])) + if (!empty($arrayfields['p.desiredstock']['checked'])) { print '<td class="right">'; if ($obj->fk_product_type != 1) @@ -1076,10 +1076,10 @@ if ($resql) print $obj->desiredstock; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Stock real - if (! empty($arrayfields['p.stock']['checked'])) + if (!empty($arrayfields['p.stock']['checked'])) { print '<td class="right">'; if ($obj->fk_product_type != 1) @@ -1088,10 +1088,10 @@ if ($resql) print $product_static->stock_reel; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Stock virtual - if (! empty($arrayfields['stock_virtual']['checked'])) + if (!empty($arrayfields['stock_virtual']['checked'])) { print '<td class="right">'; if ($obj->fk_product_type != 1) @@ -1100,95 +1100,95 @@ if ($resql) print $product_static->stock_theorique; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Lot/Serial - if (! empty($arrayfields['p.tobatch']['checked'])) + if (!empty($arrayfields['p.tobatch']['checked'])) { print '<td class="center">'; print yn($obj->tobatch); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) + if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) { print '<td>'.$obj->accountancy_code_sell.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) + if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { print '<td>'.$obj->accountancy_code_sell_intra.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) + if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { print '<td>'.$obj->accountancy_code_sell_export.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Accountancy code buy - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) + if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { print '<td>'.$obj->accountancy_code_buy.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print '<td class="center nowraponall">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print '<td class="center nowraponall">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status (to sell) - if (! empty($arrayfields['p.tosell']['checked'])) + if (!empty($arrayfields['p.tosell']['checked'])) { print '<td class="right nowrap">'; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { print $product_static->LibStatut($obj->tosell, 5, 0); } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status (to buy) - if (! empty($arrayfields['p.tobuy']['checked'])) + if (!empty($arrayfields['p.tobuy']['checked'])) { print '<td class="right nowrap">'; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { print $product_static->LibStatut($obj->tobuy, 5, 1); } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "</tr>\n"; $i++; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index a87f1a28621..23efeb0cf6d 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -28,25 +28,25 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; // Load translation files required by the page -$langs->loadLangs(array("stocks","other")); +$langs->loadLangs(array("stocks", "other")); -$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'):'stocklist'; // 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') +$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') : 'stocklist'; // 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_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref=GETPOST("sref", "alpha")?GETPOST("sref", "alpha"):GETPOST("search_ref", "alpha"); -$search_label=GETPOST("snom", "alpha")?GETPOST("snom", "alpha"):GETPOST("search_label", "alpha"); -$search_status=GETPOST("search_status", "int"); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("search_ref", "alpha"); +$search_label = GETPOST("snom", "alpha") ?GETPOST("snom", "alpha") : GETPOST("search_label", "alpha"); +$search_status = GETPOST("search_status", "int"); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -54,11 +54,11 @@ if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST( $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="e.ref"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "e.ref"; +if (!$sortorder) $sortorder = "ASC"; // Security check -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); $year = strftime("%Y", time()); @@ -66,13 +66,13 @@ $year = strftime("%Y", time()); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Entrepot($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->inventory->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('stocklist')); // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" @@ -86,23 +86,23 @@ $fieldstosearchall = array( ); // Definition of fields for list -$arrayfields=array( +$arrayfields = array( 'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'position'=>70), 'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>-2, 'position'=>71), 'sellvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'visible'=>-2, 'position'=>72), ); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -113,11 +113,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -126,24 +126,24 @@ if (empty($reshook)) 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 + 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_ref=""; - $sall=""; - $search_label=""; - $search_status=""; - $toselect=''; - $search_array_options=array(); + $search_ref = ""; + $sall = ""; + $search_label = ""; + $search_status = ""; + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Entrepot'; - $objectlabel='Warehouse'; + $objectclass = 'Entrepot'; + $objectlabel = 'Warehouse'; $permissiontoread = $user->rights->stock->lire; $permissiontodelete = $user->rights->stock->supprimer; $uploaddir = $conf->stock->dir_output; @@ -155,48 +155,48 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$warehouse=new Entrepot($db); +$form = new Form($db); +$warehouse = new Entrepot($db); -$now=dol_now(); +$now = dol_now(); -$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; +$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; $title = $langs->trans("ListOfWarehouses"); // Build and execute select // -------------------------------------------------------------------- $sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,"; -$sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; +$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; -$sql.= " WHERE e.entity IN (".getEntity('stock').")"; -if ($search_ref) $sql.= natural_search("e.ref", $search_ref); // ref -if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label -if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; +$sql .= " WHERE e.entity IN (".getEntity('stock').")"; +if ($search_ref) $sql .= natural_search("e.ref", $search_ref); // ref +if ($search_label) $sql .= natural_search("e.lieu", $search_label); // label +if ($search_status != '' && $search_status >= 0) $sql .= " AND e.statut = ".$search_status; if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent"; -$totalnboflines=0; -$result=$db->query($sql); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent"; +$totalnboflines = 0; +$result = $db->query($sql); if ($result) { $totalnboflines = $db->num_rows($result); @@ -211,7 +211,7 @@ if ($result) $line++; } } -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -232,10 +232,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -245,7 +245,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -259,27 +259,27 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader('', $title, $help_url); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$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_ref) $param.="&search_ref=".urlencode($search_ref); -if ($search_label) $param.="&search_label=".urlencode($search_label); -if ($search_status) $param.="&search_status=".urlencode($search_status); -if ($search_all) $param.="&search_all=".urlencode($search_all); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +$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_ref) $param .= "&search_ref=".urlencode($search_ref); +if ($search_label) $param .= "&search_label=".urlencode($search_label); +if ($search_status) $param .= "&search_status=".urlencode($search_status); +if ($search_all) $param .= "&search_all=".urlencode($search_all); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form action="'.$_SERVER["PHP_SELF"].'" id="searchFormList" method="POST" name="formulaire">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -296,17 +296,17 @@ $newcardbutton = dolGetButtonTitle($langs->trans('MenuNewWarehouse'), '', 'fa fa print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="Information"; -$modelmail="warehouse"; -$objecttmp=new Entrepot($db); -$trackid='ware'.$object->id; +$topicmail = "Information"; +$modelmail = "warehouse"; +$objecttmp = new Entrepot($db); +$trackid = 'ware'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; @@ -314,24 +314,24 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- @@ -352,8 +352,8 @@ print '<td class="liste_titre"></td>'; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Status @@ -363,7 +363,7 @@ print '</td>'; // Action column print '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -379,8 +379,8 @@ print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right '); // Action column @@ -389,17 +389,17 @@ print '</tr>'."\n"; // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); if ($num) { - $warehouse=new Entrepot($db); + $warehouse = new Entrepot($db); - $totalarray=array(); + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen $warehouse->id = $obj->rowid; $warehouse->ref = $obj->ref; @@ -410,55 +410,55 @@ if ($num) // Show here line of result print '<tr class="oddeven">'; - print '<td>' . $warehouse->getNomUrl(1) . '</td>'; - if (! $i) $totalarray['nbfield']++; + print '<td>'.$warehouse->getNomUrl(1).'</td>'; + if (!$i) $totalarray['nbfield']++; // Location print '<td>'.$obj->lieu.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Stock qty print '<td class="right">'.price2num($obj->stockqty, 5).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // PMP value print '<td class="right">'; if (price2num($obj->estimatedvalue, 'MT')) print price(price2num($obj->estimatedvalue, 'MT'), 1); else print ''; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Selling value print '<td class="right">'; if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($obj->sellvalue, 'MT'), 1); else { - $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); + $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); print $form->textwithtooltip($langs->trans("Variable"), $htmltext); } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Status print '<td class="right">'.$warehouse->LibStatut($obj->statut, 5).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'."\n"; @@ -466,7 +466,7 @@ if ($num) $i++; } - if ($totalnboflines-$offset <= $limit) + if ($totalnboflines - $offset <= $limit) { print '<tr class="liste_total">'; print '<td colspan="2" class="right">'.$langs->trans("Total").'</td>'; @@ -476,7 +476,7 @@ if ($num) if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency); else { - $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); + $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); print $form->textwithtooltip($langs->trans("Variable"), $htmltext); } print '</td>'; @@ -488,8 +488,8 @@ if ($num) $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -499,19 +499,19 @@ print '</form>'."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->mymodule->read; + $delallowed = $user->rights->mymodule->create; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index cef869d6a21..9d10e08be9a 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -37,25 +37,25 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! empty($conf->projet->enabled)) { +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'orders')); -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); // Security check -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$msid=GETPOST('msid', 'int'); -$product_id=GETPOST("product_id", 'int'); -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'movementlist'; +$msid = GETPOST('msid', 'int'); +$product_id = GETPOST("product_id", 'int'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; $idproduct = GETPOST('idproduct', 'int'); $year = GETPOST("year", 'int'); @@ -69,18 +69,18 @@ $search_inventorycode = trim(GETPOST("search_inventorycode", 'alpha')); $search_user = trim(GETPOST("search_user", 'alpha')); $search_batch = trim(GETPOST("search_batch", 'alpha')); $search_qty = trim(GETPOST("search_qty", 'alpha')); -$search_type_mouvement=GETPOST('search_type_mouvement', 'int'); +$search_type_mouvement = GETPOST('search_type_mouvement', 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (! $sortfield) $sortfield="m.datem"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "m.datem"; +if (!$sortorder) $sortorder = "DESC"; -$pdluoid=GETPOST('pdluoid', 'int'); +$pdluoid = GETPOST('pdluoid', 'int'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new MouvementStock($db); @@ -91,17 +91,17 @@ $formfile = new FormFile($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -$arrayfields=array( +$arrayfields = array( 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1), 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'), 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1), - 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(! $id > 0)), // If we are on specific warehouse, we hide it + 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(!$id > 0)), // If we are on specific warehouse, we hide it 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1), @@ -123,8 +123,8 @@ $usercanread = (($user->rights->stock->mouvement->lire)); $usercancreate = (($user->rights->stock->mouvement->creer)); $usercandelete = (($user->rights->stock->mouvement->supprimer)); -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 @@ -135,45 +135,45 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $year=''; - $month=''; - $search_ref=''; - $search_movement=""; - $search_type_mouvement=""; - $search_inventorycode=""; - $search_product_ref=""; - $search_product=""; - $search_warehouse=""; - $search_user=""; - $search_batch=""; - $search_qty=''; - $sall=""; - $toselect=''; - $search_array_options=array(); + $year = ''; + $month = ''; + $search_ref = ''; + $search_movement = ""; + $search_type_mouvement = ""; + $search_inventorycode = ""; + $search_product_ref = ""; + $search_product = ""; + $search_warehouse = ""; + $search_user = ""; + $search_batch = ""; + $search_qty = ''; + $sall = ""; + $toselect = ''; + $search_array_options = array(); } // Correct stock if ($action == "correct_stock") { $product = new Product($db); - if (! empty($product_id)) $result=$product->fetch($product_id); + if (!empty($product_id)) $result = $product->fetch($product_id); - $error=0; + $error = 0; if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); - $action='correction'; + $action = 'correction'; } - if (! is_numeric($_POST["nbpiece"])) + if (!is_numeric($_POST["nbpiece"])) { $error++; setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); - $action='correction'; + $action = 'correction'; } - if (! $error) + if (!$error) { $origin_element = ''; $origin_id = null; @@ -186,14 +186,14 @@ if ($action == "correct_stock") if ($product->hasbatch()) { - $batch=GETPOST('batch_number', 'alpha'); + $batch = GETPOST('batch_number', 'alpha'); //$eatby=GETPOST('eatby'); //$sellby=GETPOST('sellby'); - $eatby=dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); - $sellby=dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); + $eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); + $sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); - $result=$product->correct_stock_batch( + $result = $product->correct_stock_batch( $user, $id, GETPOST("nbpiece", 'int'), @@ -206,11 +206,11 @@ if ($action == "correct_stock") GETPOST('inventorycode', 'alpha'), $origin_element, $origin_id - ); // We do not change value of stock for a correction + ); // We do not change value of stock for a correction } else { - $result=$product->correct_stock( + $result = $product->correct_stock( $user, $id, GETPOST("nbpiece", 'int'), @@ -220,7 +220,7 @@ if ($action == "correct_stock") GETPOST('inventorycode', 'alpha'), $origin_element, $origin_id - ); // We do not change value of stock for a correction + ); // We do not change value of stock for a correction } if ($result > 0) @@ -232,72 +232,72 @@ if ($action == "correct_stock") { $error++; setEventMessages($product->error, $product->errors, 'errors'); - $action='correction'; + $action = 'correction'; } } - if (! $error) $action=''; + if (!$error) $action = ''; } // Transfer stock from a warehouse to another warehouse -if ($action == "transfert_stock" && ! $cancel) +if ($action == "transfert_stock" && !$cancel) { $product = new Product($db); - if (! empty($product_id)) $result=$product->fetch($product_id); + if (!empty($product_id)) $result = $product->fetch($product_id); - if (! (GETPOST("id_entrepot_destination", 'int') > 0)) + if (!(GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); - $action='transfert'; + $action = 'transfert'; } - if (! GETPOST("nbpiece", 'int')) + if (!GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } if ($id == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } - if (! empty($conf->productbatch->enabled)) + if (!empty($conf->productbatch->enabled)) { $product = new Product($db); - $result=$product->fetch($product_id); + $result = $product->fetch($product_id); - if ($product->hasbatch() && ! GETPOST("batch_number", 'alpha')) + if ($product->hasbatch() && !GETPOST("batch_number", 'alpha')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } } - if (! $error) + if (!$error) { if ($id) { $object = new Entrepot($db); - $result=$object->fetch($id); + $result = $object->fetch($id); $db->begin(); - $product->load_stock('novirtual'); // Load array product->stock_warehouse + $product->load_stock('novirtual'); // Load array product->stock_warehouse // Define value of products moved - $pricesrc=0; - if (isset($product->pmp)) $pricesrc=$product->pmp; - $pricedest=$pricesrc; + $pricesrc = 0; + if (isset($product->pmp)) $pricesrc = $product->pmp; + $pricedest = $pricesrc; if ($product->hasbatch()) { @@ -305,13 +305,13 @@ if ($action == "transfert_stock" && ! $cancel) if ($pdluoid > 0) { - $result=$pdluo->fetch($pdluoid); + $result = $pdluo->fetch($pdluoid); if ($result) { - $srcwarehouseid=$pdluo->warehouseid; - $batch=$pdluo->batch; - $eatby=$pdluo->eatby; - $sellby=$pdluo->sellby; + $srcwarehouseid = $pdluo->warehouseid; + $batch = $pdluo->batch; + $eatby = $pdluo->eatby; + $sellby = $pdluo->sellby; } else { @@ -321,16 +321,16 @@ if ($action == "transfert_stock" && ! $cancel) } else { - $srcwarehouseid=$id; - $batch=GETPOST('batch_number', 'alpha'); - $eatby=$d_eatby; - $sellby=$d_sellby; + $srcwarehouseid = $id; + $batch = GETPOST('batch_number', 'alpha'); + $eatby = $d_eatby; + $sellby = $d_sellby; } - if (! $error) + if (!$error) { // Remove stock - $result1=$product->correct_stock_batch( + $result1 = $product->correct_stock_batch( $user, $srcwarehouseid, GETPOST("nbpiece", 'int'), @@ -343,7 +343,7 @@ if ($action == "transfert_stock" && ! $cancel) GETPOST('inventorycode', 'alpha') ); // Add stock - $result2=$product->correct_stock_batch( + $result2 = $product->correct_stock_batch( $user, GETPOST("id_entrepot_destination", 'int'), GETPOST("nbpiece", 'int'), @@ -360,7 +360,7 @@ if ($action == "transfert_stock" && ! $cancel) else { // Remove stock - $result1=$product->correct_stock( + $result1 = $product->correct_stock( $user, $id, GETPOST("nbpiece", 'int'), @@ -371,7 +371,7 @@ if ($action == "transfert_stock" && ! $cancel) ); // Add stock - $result2=$product->correct_stock( + $result2 = $product->correct_stock( $user, GETPOST("id_entrepot_destination"), GETPOST("nbpiece", 'int'), @@ -381,7 +381,7 @@ if ($action == "transfert_stock" && ! $cancel) GETPOST('inventorycode', 'alpha') ); } - if (! $error && $result1 >= 0 && $result2 >= 0) + if (!$error && $result1 >= 0 && $result2 >= 0) { $db->commit(); @@ -400,7 +400,7 @@ if ($action == "transfert_stock" && ! $cancel) { setEventMessages($product->error, $product->errors, 'errors'); $db->rollback(); - $action='transfert'; + $action = 'transfert'; } } } @@ -433,62 +433,62 @@ if (empty($reshook) && $action != 'remove_file') * View */ -$productlot=new ProductLot($db); -$productstatic=new Product($db); -$warehousestatic=new Entrepot($db); -$movement=new MouvementStock($db); -$userstatic=new User($db); -$form=new Form($db); -$formother=new FormOther($db); -$formproduct=new FormProduct($db); -if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db); +$productlot = new ProductLot($db); +$productstatic = new Product($db); +$warehousestatic = new Entrepot($db); +$movement = new MouvementStock($db); +$userstatic = new User($db); +$form = new Form($db); +$formother = new FormOther($db); +$formproduct = new FormProduct($db); +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,"; -$sql.= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,"; -$sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; -$sql.= " m.batch, m.price,"; -$sql.= " m.type_mouvement,"; -$sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; -$sql.= " u.login, u.photo, u.lastname, u.firstname"; +$sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,"; +$sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; +$sql .= " m.batch, m.price,"; +$sql .= " m.type_mouvement,"; +$sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,"; +$sql .= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks $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."entrepot as e,"; -$sql.= " ".MAIN_DB_PREFIX."product as p,"; -$sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; -$sql.= " WHERE m.fk_product = p.rowid"; +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; +$sql .= " ".MAIN_DB_PREFIX."product as p,"; +$sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; +$sql .= " WHERE m.fk_product = p.rowid"; if ($msid > 0) $sql .= " AND m.rowid = ".$msid; -$sql.= " AND m.fk_entrepot = e.rowid"; -$sql.= " AND e.entity IN (".getEntity('stock').")"; -if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0"; -if ($id > 0) $sql.= " AND e.rowid ='".$id."'"; -$sql.= dolSqlDateFilter('m.datem', 0, $month, $year); -if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'"; -if (! empty($search_ref)) $sql.= natural_search('m.rowid', $search_ref, 1); -if (! empty($search_movement)) $sql.= natural_search('m.label', $search_movement); -if (! empty($search_inventorycode)) $sql.= natural_search('m.inventorycode', $search_inventorycode); -if (! empty($search_product_ref)) $sql.= natural_search('p.ref', $search_product_ref); -if (! empty($search_product)) $sql.= natural_search('p.label', $search_product); -if ($search_warehouse != '' && $search_warehouse != '-1') $sql.= natural_search('e.rowid', $search_warehouse, 2); -if (! empty($search_user)) $sql.= natural_search('u.login', $search_user); -if (! empty($search_batch)) $sql.= natural_search('m.batch', $search_batch); -if ($search_qty != '') $sql.= natural_search('m.value', $search_qty, 1); -if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql.= natural_search('m.type_mouvement', $search_type_mouvement, 2); +$sql .= " AND m.fk_entrepot = e.rowid"; +$sql .= " AND e.entity IN (".getEntity('stock').")"; +if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; +if ($id > 0) $sql .= " AND e.rowid ='".$id."'"; +$sql .= dolSqlDateFilter('m.datem', 0, $month, $year); +if ($idproduct > 0) $sql .= " AND p.rowid = '".$idproduct."'"; +if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1); +if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); +if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); +if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); +if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); +if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); +if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); +if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); +if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -502,9 +502,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -if(empty($search_inventorycode)) +if (empty($search_inventorycode)) { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } else { @@ -515,7 +515,7 @@ else $resql = $db->query($sql); -if(!empty($search_inventorycode)) $limit = $db->num_rows($resql); +if (!empty($search_inventorycode)) $limit = $db->num_rows($resql); if ($resql) { @@ -537,16 +537,16 @@ if ($resql) $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); $i = 0; - $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; if ($msid) $texte = $langs->trans('StockMovementForId', $msid); else { $texte = $langs->trans("ListOfStockMovements"); - if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')'; + if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; } llxHeader("", $texte, $help_url); @@ -562,12 +562,12 @@ if ($resql) $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/list.php">'.$langs->trans("BackToList").'</a>'; - $morehtmlref='<div class="refidno">'; - $morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu; - $morehtmlref.='</div>'; + $morehtmlref = '<div class="refidno">'; + $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu; + $morehtmlref .= '</div>'; $shownav = 1; - if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); @@ -583,18 +583,18 @@ if ($resql) // Description print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'.dol_htmlentitiesbr($object->description).'</td></tr>'; - $calcproductsunique=$object->nb_different_products(); - $calcproducts=$object->nb_products(); + $calcproductsunique = $object->nb_different_products(); + $calcproducts = $object->nb_products(); // Total nb of different products print '<tr><td>'.$langs->trans("NumberOfDifferentProducts").'</td><td>'; - print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']; + print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']; print "</td></tr>"; // Nb of products print '<tr><td>'.$langs->trans("NumberOfProducts").'</td><td>'; - $valtoshow=price2num($calcproducts['nb'], 'MS'); - print empty($valtoshow)?'0':$valtoshow; + $valtoshow = price2num($calcproducts['nb'], 'MS'); + print empty($valtoshow) ? '0' : $valtoshow; print "</td></tr>"; print '</table>'; @@ -608,7 +608,7 @@ if ($resql) // Value print '<tr><td class="titlefield">'.$langs->trans("EstimatedStockValueShort").'</td><td>'; - print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); + print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); print "</td></tr>"; // Last movement @@ -619,7 +619,7 @@ if ($resql) if ($resqlbis) { $obj = $db->fetch_object($resqlbis); - $lastmovementdate=$db->jdate($obj->datem); + $lastmovementdate = $db->jdate($obj->datem); } else { @@ -691,32 +691,32 @@ if ($resql) print '</div><br>'; } - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($id > 0) $param.='&id='.urlencode($id); - if ($search_movement) $param.='&search_movement='.urlencode($search_movement); - if ($search_inventorycode) $param.='&search_inventorycode='.urlencode($search_inventorycode); - if ($search_type_mouvement) $param.='&search_type_mouvement='.urlencode($search_type_mouvement); - if ($search_product_ref) $param.='&search_product_ref='.urlencode($search_product_ref); - if ($search_product) $param.='&search_product='.urlencode($search_product); - if ($search_batch) $param.='&search_batch='.urlencode($search_batch); - if ($search_warehouse > 0) $param.='&search_warehouse='.urlencode($search_warehouse); - if (!empty($sref)) $param.='&sref='.urlencode($sref); // FIXME $sref is not defined - if (!empty($snom)) $param.='&snom='.urlencode($snom); // FIXME $snom is not defined - if ($search_user) $param.='&search_user='.urlencode($search_user); - if ($idproduct > 0) $param.='&idproduct='.urlencode($idproduct); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($id > 0) $param .= '&id='.urlencode($id); + if ($search_movement) $param .= '&search_movement='.urlencode($search_movement); + if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); + if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); + if ($search_product_ref) $param .= '&search_product_ref='.urlencode($search_product_ref); + if ($search_product) $param .= '&search_product='.urlencode($search_product); + if ($search_batch) $param .= '&search_batch='.urlencode($search_batch); + if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse); + if (!empty($sref)) $param .= '&sref='.urlencode($sref); // FIXME $sref is not defined + if (!empty($snom)) $param .= '&snom='.urlencode($snom); // FIXME $snom is not defined + if ($search_user) $param .= '&search_user='.urlencode($search_user); + if ($idproduct > 0) $param .= '&idproduct='.urlencode($idproduct); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( // 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -735,140 +735,140 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } - $moreforfilter=''; + $moreforfilter = ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search print '<tr class="liste_titre_filter">'; - if (! empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) { // Ref print '<td class="liste_titre left">'; print '<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } - if (! empty($arrayfields['m.datem']['checked'])) + if (!empty($arrayfields['m.datem']['checked'])) { print '<td class="liste_titre nowraponall">'; print '<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans("Month")).'" name="month" value="'.$month.'">'; if (empty($conf->productbatch->enabled)) print ' '; //else print '<br>'; - $syear = $year?$year:-1; + $syear = $year ? $year : -1; print '<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" name="year" value="'.($syear > 0 ? $syear : '').'">'; //print $formother->selectyear($syear,'year',1, 20, 5); print '</td>'; } - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { // Product Ref print '<td class="liste_titre left">'; - print '<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct?$product->ref:$search_product_ref).'">'; + print '<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).'">'; print '</td>'; } - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { // Product label print '<td class="liste_titre left">'; - print '<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct?$product->label:$search_product).'">'; + print '<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).'">'; print '</td>'; } // Batch - if (! empty($arrayfields['m.batch']['checked'])) + if (!empty($arrayfields['m.batch']['checked'])) { print '<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).'"></td>'; } - if (! empty($arrayfields['pl.eatby']['checked'])) + if (!empty($arrayfields['pl.eatby']['checked'])) { print '<td class="liste_titre left">'; print '</td>'; } - if (! empty($arrayfields['pl.sellby']['checked'])) + if (!empty($arrayfields['pl.sellby']['checked'])) { print '<td class="liste_titre left">'; print '</td>'; } // Warehouse - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone left">'; //print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">'; print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print '</td>'; } - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) { // Author print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">'; print '</td>'; } - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).'">'; print '</td>'; } - if (! empty($arrayfields['m.label']['checked'])) + if (!empty($arrayfields['m.label']['checked'])) { // Label of movement print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).'">'; print '</td>'; } - if (! empty($arrayfields['m.type_mouvement']['checked'])) + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement print '<td class="liste_titre center">'; //print '<input class="flat" type="text" size="3" name="search_type_mouvement" value="'.dol_escape_htmltag($search_type_mouvement).'">'; print '<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">'; - print '<option value="" '.(($search_type_mouvement=="")?'selected="selected"':'').'></option>'; - print '<option value="0" '.(($search_type_mouvement=="0")?'selected="selected"':'').'>'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</option>'; - print '<option value="1" '.(($search_type_mouvement=="1")?'selected="selected"':'').'>'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</option>'; - print '<option value="2" '.(($search_type_mouvement=="2")?'selected="selected"':'').'>'.$langs->trans('StockDecrease').'</option>'; - print '<option value="3" '.(($search_type_mouvement=="3")?'selected="selected"':'').'>'.$langs->trans('StockIncrease').'</option>'; + print '<option value="" '.(($search_type_mouvement == "") ? 'selected="selected"' : '').'></option>'; + print '<option value="0" '.(($search_type_mouvement == "0") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</option>'; + print '<option value="1" '.(($search_type_mouvement == "1") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</option>'; + print '<option value="2" '.(($search_type_mouvement == "2") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecrease').'</option>'; + print '<option value="3" '.(($search_type_mouvement == "3") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncrease').'</option>'; print '</select>'; print ajax_combobox('search_type_mouvement'); // TODO: add new function $formentrepot->selectTypeOfMovement(...) like // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print '</td>'; } - if (! empty($arrayfields['origin']['checked'])) + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print '<td class="liste_titre left">'; print '  '; print '</td>'; } - if (! empty($arrayfields['m.value']['checked'])) + if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).'">'; print '</td>'; } - if (! empty($arrayfields['m.price']['checked'])) + if (!empty($arrayfields['m.price']['checked'])) { // Price print '<td class="liste_titre left">'; @@ -881,108 +881,108 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['m.datec']['checked'])) + if (!empty($arrayfields['m.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (! empty($arrayfields['m.tms']['checked'])) + if (!empty($arrayfields['m.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Actions print '<td class="liste_titre maxwidthsearch">'; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; - if (! empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['m.datem']['checked'])) + if (!empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['m.batch']['checked'])) + if (!empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['pl.eatby']['checked'])) + if (!empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['pl.sellby']['checked'])) + if (!empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['e.ref']['checked'])) { + if (!empty($arrayfields['e.ref']['checked'])) { // We are on a specific warehouse card, no filter on other should be possible print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (!empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.label']['checked'])) + if (!empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.type_mouvement']['checked'])) + if (!empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['origin']['checked'])) + if (!empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.value']['checked'])) + if (!empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['m.price']['checked'])) + if (!empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['m.datec']['checked'])) { + if (!empty($arrayfields['m.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } - if (! empty($arrayfields['m.tms']['checked'])) { + if (!empty($arrayfields['m.tms']['checked'])) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; - $arrayofuniqueproduct=array(); + $arrayofuniqueproduct = array(); while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); - $userstatic->id=$objp->fk_user_author; - $userstatic->login=$objp->login; - $userstatic->lastname=$objp->lastname; - $userstatic->firstname=$objp->firstname; - $userstatic->photo=$objp->photo; + $userstatic->id = $objp->fk_user_author; + $userstatic->login = $objp->login; + $userstatic->lastname = $objp->lastname; + $userstatic->firstname = $objp->firstname; + $userstatic->photo = $objp->photo; - $productstatic->id=$objp->rowid; - $productstatic->ref=$objp->product_ref; - $productstatic->label=$objp->produit; - $productstatic->type=$objp->type; - $productstatic->entity=$objp->entity; - $productstatic->status_batch=$objp->tobatch; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->product_ref; + $productstatic->label = $objp->produit; + $productstatic->type = $objp->type; + $productstatic->entity = $objp->entity; + $productstatic->status_batch = $objp->tobatch; $productlot->id = $objp->lotid; - $productlot->batch= $objp->batch; - $productlot->eatby= $objp->eatby; - $productlot->sellby= $objp->sellby; + $productlot->batch = $objp->batch; + $productlot->eatby = $objp->eatby; + $productlot->sellby = $objp->sellby; - $warehousestatic->id=$objp->entrepot_id; - $warehousestatic->libelle=$objp->warehouse_ref; // deprecated - $warehousestatic->label=$objp->warehouse_ref; - $warehousestatic->lieu=$objp->lieu; + $warehousestatic->id = $objp->entrepot_id; + $warehousestatic->libelle = $objp->warehouse_ref; // deprecated + $warehousestatic->label = $objp->warehouse_ref; + $warehousestatic->lieu = $objp->lieu; - $arrayofuniqueproduct[$objp->rowid]=$objp->produit; + $arrayofuniqueproduct[$objp->rowid] = $objp->produit; if (!empty($objp->fk_origin)) { $origin = $movement->get_origin($objp->fk_origin, $objp->origintype); } else { @@ -991,24 +991,24 @@ if ($resql) print '<tr class="oddeven">'; // Id movement - if (! empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) { // This is primary not movement id print '<td>'.$objp->mid.'</td>'; } - if (! empty($arrayfields['m.datem']['checked'])) + if (!empty($arrayfields['m.datem']['checked'])) { // Date print '<td>'.dol_print_date($db->jdate($objp->datem), 'dayhour').'</td>'; } - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { // Product ref print '<td class="nowraponall">'; print $productstatic->getNomUrl(1, 'stock', 16); print "</td>\n"; } - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { // Product label print '<td>'; @@ -1019,36 +1019,36 @@ if ($resql) print $productstatic->label; print "</td>\n"; } - if (! empty($arrayfields['m.batch']['checked'])) + if (!empty($arrayfields['m.batch']['checked'])) { print '<td class="center nowraponall">'; if ($productlot->id > 0) print $productlot->getNomUrl(1); - else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. print '</td>'; } - if (! empty($arrayfields['pl.eatby']['checked'])) + if (!empty($arrayfields['pl.eatby']['checked'])) { - print '<td class="center">'. dol_print_date($objp->eatby, 'day') .'</td>'; + print '<td class="center">'.dol_print_date($objp->eatby, 'day').'</td>'; } - if (! empty($arrayfields['pl.sellby']['checked'])) + if (!empty($arrayfields['pl.sellby']['checked'])) { - print '<td class="center">'. dol_print_date($objp->sellby, 'day') .'</td>'; + print '<td class="center">'.dol_print_date($objp->sellby, 'day').'</td>'; } // Warehouse - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print '<td>'; print $warehousestatic->getNomUrl(1); print "</td>\n"; } // Author - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) { print '<td class="tdoverflowmax100">'; print $userstatic->getNomUrl(-1); print "</td>\n"; } - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print '<td><a href="' @@ -1061,15 +1061,15 @@ if ($resql) .'</a>' .'</td>'; } - if (! empty($arrayfields['m.label']['checked'])) + if (!empty($arrayfields['m.label']['checked'])) { // Label of movement print '<td class="tdoverflowmax100aaa">'.$objp->label.'</td>'; } - if (! empty($arrayfields['m.type_mouvement']['checked'])) + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement - switch($objp->type_mouvement) { + switch ($objp->type_mouvement) { case "0": print '<td class="center">'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</td>'; break; @@ -1084,12 +1084,12 @@ if ($resql) break; } } - if (! empty($arrayfields['origin']['checked'])) + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print '<td class="nowraponall">'.$origin.'</td>'; } - if (! empty($arrayfields['m.value']['checked'])) + if (!empty($arrayfields['m.value']['checked'])) { // Qty print '<td class="right">'; @@ -1097,7 +1097,7 @@ if ($resql) print $objp->qty; print '</td>'; } - if (! empty($arrayfields['m.price']['checked'])) + if (!empty($arrayfields['m.price']['checked'])) { // Price print '<td class="right">'; @@ -1108,12 +1108,12 @@ if ($resql) print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "</tr>\n"; $i++; @@ -1129,15 +1129,15 @@ if ($resql) { print "<br>"; - $productidselected=0; + $productidselected = 0; foreach ($arrayofuniqueproduct as $key => $val) { - $productidselected=$key; - $productlabelselected=$val; + $productidselected = $key; + $productlabelselected = $val; } - $datebefore=dol_get_first_day($year?$year:strftime("%Y", time()), $month?$month:1, true); - $dateafter=dol_get_last_day($year?$year:strftime("%Y", time()), $month?$month:12, true); - $balancebefore=$movement->calculateBalanceForProductBefore($productidselected, $datebefore); - $balanceafter=$movement->calculateBalanceForProductBefore($productidselected, $dateafter); + $datebefore = dol_get_first_day($year ? $year : strftime("%Y", time()), $month ? $month : 1, true); + $dateafter = dol_get_last_day($year ? $year : strftime("%Y", time()), $month ? $month : 12, true); + $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore); + $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter); //print '<tr class="total"><td class="liste_total">'; print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt')); @@ -1166,9 +1166,9 @@ else * Documents generes */ //Area for doc and last events of warehouse are stored on the main card of warehouse -$modulepart='movement'; +$modulepart = 'movement'; -if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) +if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id > 0) { print '<br/>'; print '<div class="fichecenter"><div class="fichehalfleft">'; @@ -1177,33 +1177,33 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) // Documents $objectref = dol_sanitizeFileName($object->ref); // Add inventorycode & type_mouvement to filename of the pdf - if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode; - if($search_type_mouvement) $objectref.="_".$search_type_mouvement; - $relativepath = $comref . '/' . $objectref . '.pdf'; - $filedir = $conf->stock->dir_output . '/movement/' . $objectref; + if (!empty($search_inventorycode)) $objectref .= "_".$id."_".$search_inventorycode; + if ($search_type_mouvement) $objectref .= "_".$search_type_mouvement; + $relativepath = $comref.'/'.$objectref.'.pdf'; + $filedir = $conf->stock->dir_output.'/movement/'.$objectref; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id."&search_inventorycode=".$search_inventorycode."&search_type_mouvement=$search_type_mouvement"; - $genallowed=$usercanread; - $delallowed=$usercancreate; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id."&search_inventorycode=".$search_inventorycode."&search_type_mouvement=$search_type_mouvement"; + $genallowed = $usercanread; + $delallowed = $usercancreate; - $genallowed=$user->rights->stock->lire; - $delallowed=$user->rights->stock->creer; + $genallowed = $user->rights->stock->lire; + $delallowed = $user->rights->stock->creer; print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); - $somethingshown=$formfile->numoffiles; + $somethingshown = $formfile->numoffiles; print '</div><div class="fichehalfright"><div class="ficheaddleft">'; $MAXEVENT = 10; $morehtmlright = '<a href="'.DOL_URL_ROOT.'/product/agenda.php?id='.$object->id.'">'; - $morehtmlright.= $langs->trans("SeeAll"); - $morehtmlright.= '</a>'; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= '</a>'; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'mouvement', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product + $somethingshown = $formactions->showactions($object, 'mouvement', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product print '</div></div></div>'; } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 4c306dc1702..d832a0406ee 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -42,19 +42,19 @@ $myparam = GETPOST('myparam', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$search_entity=GETPOST('search_entity', 'int'); -$search_product=GETPOST('search_product', 'alpha'); -$search_batch=GETPOST('search_batch', 'alpha'); -$search_fk_user_creat=GETPOST('search_fk_user_creat', 'int'); -$search_fk_user_modif=GETPOST('search_fk_user_modif', 'int'); -$search_import_key=GETPOST('search_import_key', 'int'); +$search_entity = GETPOST('search_entity', 'int'); +$search_product = GETPOST('search_product', 'alpha'); +$search_batch = GETPOST('search_batch', 'alpha'); +$search_fk_user_creat = GETPOST('search_fk_user_creat', 'int'); +$search_fk_user_modif = GETPOST('search_fk_user_modif', 'int'); +$search_import_key = GETPOST('search_import_key', 'int'); -$search_myfield=GETPOST('search_myfield'); +$search_myfield = GETPOST('search_myfield'); $optioncss = GETPOST('optioncss', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -62,11 +62,11 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="t.batch"; // Set here default search field -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.batch"; // Set here default search field +if (!$sortorder) $sortorder = "ASC"; // Protection if external user -$socid=0; +$socid = 0; if ($user->socid > 0) { $socid = $user->socid; @@ -81,7 +81,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -90,7 +90,7 @@ $fieldstosearchall = array( ); // Definition of fields for list -$arrayfields=array( +$arrayfields = array( //'t.entity'=>array('label'=>$langs->trans("Fieldentity"), 'checked'=>1), 't.batch'=>array('label'=>$langs->trans("Batch"), 'checked'=>1), 't.fk_product'=>array('label'=>$langs->trans("Product"), 'checked'=>1), @@ -107,19 +107,19 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); // Load object if id or ref is provided as parameter -if (($id > 0 || ! empty($ref)) && $action != 'add') +if (($id > 0 || !empty($ref)) && $action != 'add') { - $result=$object->fetch($id, $ref); + $result = $object->fetch($id, $ref); if ($result < 0) dol_print_error($db); } @@ -129,35 +129,35 @@ if (($id > 0 || ! empty($ref)) && $action != 'add') * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $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 +$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'); 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 +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_entity=''; - $search_product=''; - $search_batch=''; - $search_fk_user_creat=''; - $search_fk_user_modif=''; - $search_import_key=''; - $search_date_creation=''; - $search_date_update=''; - $toselect=array(); - $search_array_options=array(); + $search_entity = ''; + $search_product = ''; + $search_batch = ''; + $search_fk_user_creat = ''; + $search_fk_user_modif = ''; + $search_import_key = ''; + $search_date_creation = ''; + $search_date_update = ''; + $toselect = array(); + $search_array_options = array(); } if (empty($reshook)) { - $objectclass='ProductLot'; - $objectlabel='LotSerial'; + $objectclass = 'ProductLot'; + $objectlabel = 'LotSerial'; $permissiontoread = $user->rights->stock->read; $permissiontodelete = $user->rights->stock->delete; $uploaddir = $conf->stock->dir_output; @@ -171,13 +171,13 @@ if (empty($reshook)) * VIEW */ -$now=dol_now(); +$now = dol_now(); -$form=new Form($db); -$productstatic=new Product($db); +$form = new Form($db); +$productstatic = new Product($db); //$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; -$help_url=''; +$help_url = ''; $title = $langs->trans('LotSerialList'); llxHeader('', $title, $help_url); @@ -259,37 +259,37 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); dol_syslog($script_file, LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_entity != '') $param.= '&search_entity='.urlencode($search_entity); - if ($search_product != '') $param.= '&search_product='.urlencode($search_product); - if ($search_batch != '') $param.= '&search_batch='.urlencode($search_batch); - if ($search_fk_user_creat != '') $param.= '&search_fk_user_creat='.urlencode($search_fk_user_creat); - if ($search_fk_user_modif != '') $param.= '&search_fk_user_modif='.urlencode($search_fk_user_modif); - if ($search_import_key != '') $param.= '&search_import_key='.urlencode($search_import_key); - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($search_entity != '') $param .= '&search_entity='.urlencode($search_entity); + if ($search_product != '') $param .= '&search_product='.urlencode($search_product); + if ($search_batch != '') $param .= '&search_batch='.urlencode($search_batch); + if ($search_fk_user_creat != '') $param .= '&search_fk_user_creat='.urlencode($search_fk_user_creat); + if ($search_fk_user_modif != '') $param .= '&search_fk_user_modif='.urlencode($search_fk_user_modif); + if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key); + if ($optioncss != '') $param .= '&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $arrayofmassactions = array( + $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -302,16 +302,16 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'products', 0, '', '', $limit); - $topicmail="Information"; - $modelmail="productlot"; - $objecttmp=new Productlot($db); - $trackid='lot'.$object->id; + $topicmail = "Information"; + $modelmail = "productlot"; + $objecttmp = new Productlot($db); + $trackid = 'lot'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } /*$moreforfilter = ''; @@ -319,48 +319,48 @@ if ($resql) $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search print '<tr class="liste_titre_filter">'; - if (! empty($arrayfields['t.entity']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_entity" value="'.$search_entity.'" size="8"></td>'; - if (! empty($arrayfields['t.batch']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_batch" value="'.$search_batch.'" size="8"></td>'; - if (! empty($arrayfields['t.fk_product']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_product" value="'.$search_product.'" size="8"></td>'; - if (! empty($arrayfields['t.sellby']['checked'])) print '<td class="liste_titre"></td>'; - if (! empty($arrayfields['t.eatby']['checked'])) print '<td class="liste_titre"></td>'; - if (! empty($arrayfields['t.fk_user_creat']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_fk_user_creat" value="'.$search_fk_user_creat.'" size="10"></td>'; - if (! empty($arrayfields['t.fk_user_modif']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_fk_user_modif" value="'.$search_fk_user_modif.'" size="10"></td>'; - if (! empty($arrayfields['t.import_key']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_import_key" value="'.$search_import_key.'" size="10"></td>'; + if (!empty($arrayfields['t.entity']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_entity" value="'.$search_entity.'" size="8"></td>'; + if (!empty($arrayfields['t.batch']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_batch" value="'.$search_batch.'" size="8"></td>'; + if (!empty($arrayfields['t.fk_product']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_product" value="'.$search_product.'" size="8"></td>'; + if (!empty($arrayfields['t.sellby']['checked'])) print '<td class="liste_titre"></td>'; + if (!empty($arrayfields['t.eatby']['checked'])) print '<td class="liste_titre"></td>'; + if (!empty($arrayfields['t.fk_user_creat']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_fk_user_creat" value="'.$search_fk_user_creat.'" size="10"></td>'; + if (!empty($arrayfields['t.fk_user_modif']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_fk_user_modif" value="'.$search_fk_user_modif.'" size="10"></td>'; + if (!empty($arrayfields['t.import_key']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_import_key" value="'.$search_import_key.'" size="10"></td>'; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['t.datec']['checked'])) + if (!empty($arrayfields['t.datec']['checked'])) { // Date creation print '<td class="liste_titre">'; print '</td>'; } - if (! empty($arrayfields['t.tms']['checked'])) + if (!empty($arrayfields['t.tms']['checked'])) { // Date modification print '<td class="liste_titre">'; @@ -375,31 +375,31 @@ if ($resql) }*/ // Action column print '<td class="liste_titre maxwidthsearch">'; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print '</td>'; print '</tr>'."\n"; // Fields title print '<tr class="liste_titre">'; - if (! empty($arrayfields['t.entity']['checked'])) print_liste_field_titre($arrayfields['t.entity']['label'], $_SERVER['PHP_SELF'], 't.entity', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.batch']['checked'])) print_liste_field_titre($arrayfields['t.batch']['label'], $_SERVER['PHP_SELF'], 't.batch', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.fk_product']['checked'])) print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.sellby']['checked'])) print_liste_field_titre($arrayfields['t.sellby']['label'], $_SERVER['PHP_SELF'], 't.sellby', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.eatby']['checked'])) print_liste_field_titre($arrayfields['t.eatby']['label'], $_SERVER['PHP_SELF'], 't.eatby', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.fk_user_creat']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_creat']['label'], $_SERVER['PHP_SELF'], 't.fk_user_creat', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.fk_user_modif']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_modif']['label'], $_SERVER['PHP_SELF'], 't.fk_user_modif', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.import_key']['checked'])) print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER['PHP_SELF'], 't.import_key', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.entity']['checked'])) print_liste_field_titre($arrayfields['t.entity']['label'], $_SERVER['PHP_SELF'], 't.entity', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.batch']['checked'])) print_liste_field_titre($arrayfields['t.batch']['label'], $_SERVER['PHP_SELF'], 't.batch', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.fk_product']['checked'])) print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.sellby']['checked'])) print_liste_field_titre($arrayfields['t.sellby']['label'], $_SERVER['PHP_SELF'], 't.sellby', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.eatby']['checked'])) print_liste_field_titre($arrayfields['t.eatby']['label'], $_SERVER['PHP_SELF'], 't.eatby', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.fk_user_creat']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_creat']['label'], $_SERVER['PHP_SELF'], 't.fk_user_creat', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.fk_user_modif']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_modif']['label'], $_SERVER['PHP_SELF'], 't.fk_user_modif', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.import_key']['checked'])) print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER['PHP_SELF'], 't.import_key', '', $param, '', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['t.datec']['checked'])) { + if (!empty($arrayfields['t.datec']['checked'])) { print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } - if (! empty($arrayfields['t.tms']['checked'])) { + if (!empty($arrayfields['t.tms']['checked'])) { print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } //if (! empty($arrayfields['t.status']['checked'])) { @@ -410,8 +410,8 @@ if ($resql) $productlot = new Productlot($db); - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -422,72 +422,72 @@ if ($resql) // You can use here results print '<tr class="oddeven">'; - if (! empty($arrayfields['t.entity']['checked'])) + if (!empty($arrayfields['t.entity']['checked'])) { print '<td>'.$obj->entity.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.batch']['checked'])) + if (!empty($arrayfields['t.batch']['checked'])) { print '<td>'.$productlot->getNomUrl(1).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.fk_product']['checked'])) + if (!empty($arrayfields['t.fk_product']['checked'])) { - $productstatic->id=$obj->fk_product; - $productstatic->type=$obj->product_type; - $productstatic->ref=$obj->product_ref; - $productstatic->label=$obj->product_label; + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->product_type; + $productstatic->ref = $obj->product_ref; + $productstatic->label = $obj->product_label; $productstatic->status_batch = $obj->tobatch; print '<td>'.$productstatic->getNomUrl(1).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.sellby']['checked'])) + if (!empty($arrayfields['t.sellby']['checked'])) { print '<td>'.dol_print_date($db->jdate($obj->sellby), 'day').'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.eatby']['checked'])) + if (!empty($arrayfields['t.eatby']['checked'])) { print '<td>'.dol_print_date($db->jdate($obj->eatby), 'day').'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.fk_user_creat']['checked'])) + if (!empty($arrayfields['t.fk_user_creat']['checked'])) { print '<td>'.$obj->fk_user_creat.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.fk_user_modif']['checked'])) + if (!empty($arrayfields['t.fk_user_modif']['checked'])) { print '<td>'.$obj->fk_user_modif.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.import_key']['checked'])) + if (!empty($arrayfields['t.import_key']['checked'])) { print '<td>'.$obj->import_key.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['t.datec']['checked'])) + if (!empty($arrayfields['t.datec']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['t.tms']['checked'])) + if (!empty($arrayfields['t.tms']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status /* @@ -501,12 +501,12 @@ if ($resql) print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'; } @@ -518,8 +518,8 @@ if ($resql) $db->free($resql); - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 61a96af9f58..d5c37b81fa6 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -37,17 +37,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; // Load translation files required by the page $langs->loadLangs(array('projects', 'companies', 'commercial')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'projectlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist'; $title = $langs->trans("Projects"); // Security check -$socid = (is_numeric($_GET["socid"]) ? $_GET["socid"] : 0 ); +$socid = (is_numeric($_GET["socid"]) ? $_GET["socid"] : 0); //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if ($socid > 0) { @@ -57,40 +57,40 @@ if ($socid > 0) } if (!$user->rights->projet->lire) accessforbidden(); -$diroutputmassaction=$conf->projet->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->projet->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); $sortorder = GETPOST("sortorder"); $page = GETPOST("page"); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="ASC"; -$offset = $limit * $page ; +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "ASC"; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$search_all=GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); -$search_categ=GETPOST("search_categ", 'alpha'); -$search_ref=GETPOST("search_ref", 'alpha'); -$search_label=GETPOST("search_label", 'alpha'); -$search_societe=GETPOST("search_societe", 'alpha'); -$search_status=GETPOST("search_status", 'int'); -$search_opp_status=GETPOST("search_opp_status", 'alpha'); -$search_opp_percent=GETPOST("search_opp_percent", 'alpha'); -$search_opp_amount=GETPOST("search_opp_amount", 'alpha'); -$search_budget_amount=GETPOST("search_budget_amount", 'alpha'); -$search_public=GETPOST("search_public", 'int'); -$search_project_user=GETPOST('search_project_user', 'int'); -$search_sale=GETPOST('search_sale', 'int'); -$search_usage_opportunity=GETPOST('search_usage_opportunity', 'int'); -$search_usage_task=GETPOST('search_usage_task', 'int'); -$search_usage_bill_time=GETPOST('search_usage_bill_time', 'int'); +$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search_categ = GETPOST("search_categ", 'alpha'); +$search_ref = GETPOST("search_ref", 'alpha'); +$search_label = GETPOST("search_label", 'alpha'); +$search_societe = GETPOST("search_societe", 'alpha'); +$search_status = GETPOST("search_status", 'int'); +$search_opp_status = GETPOST("search_opp_status", 'alpha'); +$search_opp_percent = GETPOST("search_opp_percent", 'alpha'); +$search_opp_amount = GETPOST("search_opp_amount", 'alpha'); +$search_budget_amount = GETPOST("search_budget_amount", 'alpha'); +$search_public = GETPOST("search_public", 'int'); +$search_project_user = GETPOST('search_project_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_usage_opportunity = GETPOST('search_usage_opportunity', 'int'); +$search_usage_task = GETPOST('search_usage_task', 'int'); +$search_usage_bill_time = GETPOST('search_usage_bill_time', 'int'); $optioncss = GETPOST('optioncss', 'alpha'); -$mine = $_REQUEST['mode']=='mine' ? 1 : 0; -if ($mine) { $search_project_user = $user->id; $mine=0; } +$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; +if ($mine) { $search_project_user = $user->id; $mine = 0; } $search_sday = GETPOST('search_sday', 'int'); $search_smonth = GETPOST('search_smonth', 'int'); @@ -99,7 +99,7 @@ $search_eday = GETPOST('search_eday', 'int'); $search_emonth = GETPOST('search_emonth', 'int'); $search_eyear = GETPOST('search_eyear', 'int'); -if ($search_status == '') $search_status=-1; // -1 or 1 +if ($search_status == '') $search_status = -1; // -1 or 1 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Project($db); @@ -109,7 +109,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -118,23 +118,23 @@ $fieldstosearchall = array( 's.nom'=>"ThirdPartyName", "p.note_public"=>"NotePublic" ); -if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["p.note_private"] = "NotePrivate"; -$arrayfields=array( +$arrayfields = array( 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'p.title'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>(empty($conf->societe->enabled)?0:1)), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>(empty($conf->societe->enabled) ? 0 : 1)), 'commercial'=>array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0), 'p.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), 'p.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101), 'p.public'=>array('label'=>$langs->trans("Visibility"), 'checked'=>1, 'position'=>102), - 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), - 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>104), - 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>105), + 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>103), + 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>104), + 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>105), 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), - 'p.usage_opportunity'=>array('label'=>$langs->trans("UsageOpportunity"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>115), - 'p.usage_task'=>array('label'=>$langs->trans("UsageTasks"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS?0:1), 'position'=>116), - 'p.usage_bill_time'=>array('label'=>$langs->trans("UsageBillTimeShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS?0:1), 'position'=>117), + 'p.usage_opportunity'=>array('label'=>$langs->trans("UsageOpportunity"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>115), + 'p.usage_task'=>array('label'=>$langs->trans("UsageTasks"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS ? 0 : 1), 'position'=>116), + 'p.usage_bill_time'=>array('label'=>$langs->trans("UsageBillTimeShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS ? 0 : 1), 'position'=>117), 'p.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), @@ -142,10 +142,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -157,11 +157,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) @@ -172,51 +172,51 @@ if (empty($reshook)) // 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_all=''; - $search_categ=''; - $search_ref=""; - $search_label=""; - $search_societe=""; - $search_status=-1; - $search_opp_status=-1; - $search_opp_amount=''; - $search_opp_percent=''; - $search_budget_amount=''; - $search_public=""; - $search_sale=""; - $search_project_user=''; - $search_sday=""; - $search_smonth=""; - $search_syear=""; - $search_eday=""; - $search_emonth=""; - $search_eyear=""; - $search_usage_opportunity=''; - $search_usage_task=''; - $search_usage_bill_time=''; - $toselect=''; - $search_array_options=array(); + $search_all = ''; + $search_categ = ''; + $search_ref = ""; + $search_label = ""; + $search_societe = ""; + $search_status = -1; + $search_opp_status = -1; + $search_opp_amount = ''; + $search_opp_percent = ''; + $search_budget_amount = ''; + $search_public = ""; + $search_sale = ""; + $search_project_user = ''; + $search_sday = ""; + $search_smonth = ""; + $search_syear = ""; + $search_eday = ""; + $search_emonth = ""; + $search_eyear = ""; + $search_usage_opportunity = ''; + $search_usage_task = ''; + $search_usage_bill_time = ''; + $toselect = ''; + $search_array_options = array(); } // Mass actions - $objectclass='Project'; - $objectlabel='Project'; + $objectclass = 'Project'; + $objectlabel = 'Project'; $permissiontoread = $user->rights->projet->lire; $permissiontodelete = $user->rights->projet->supprimer; $uploaddir = $conf->projet->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // Close records - if (! $error && $massaction == 'close' && $user->rights->projet->creer) + if (!$error && $massaction == 'close' && $user->rights->projet->creer) { $db->begin(); - $objecttmp=new $objectclass($db); + $objecttmp = new $objectclass($db); $nbok = 0; - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $result=$objecttmp->fetch($toselectid); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { $userWrite = $object->restrictedProjectArea($user, 'write'); @@ -227,7 +227,7 @@ if (empty($reshook)) $error++; break; } else $nbok++; - } elseif($userWrite <= 0) { + } elseif ($userWrite <= 0) { setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings'); } else { setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings'); @@ -241,7 +241,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); @@ -264,64 +264,64 @@ $form = new Form($db); $formother = new FormOther($db); $formproject = new FormProjets($db); -$title=$langs->trans("Projects"); +$title = $langs->trans("Projects"); // Get list of project id allowed to user (in a string list separated by coma) -$projectsListId=''; -if (! $user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid); +$projectsListId = ''; +if (!$user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid); // Get id of types of contacts for projects (This list never contains a lot of elements) -$listofprojectcontacttype=array(); +$listofprojectcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; -$sql.= " WHERE ctc.element = '" . $object->element . "'"; -$sql.= " AND ctc.source = 'internal'"; +$sql .= " WHERE ctc.element = '".$object->element."'"; +$sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listofprojectcontacttype[$obj->rowid]=$obj->code; + $listofprojectcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); -if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found +if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found -$distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. +$distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat"; -$sql.= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount, p.usage_opportunity, p.usage_task, p.usage_bill_time"; -$sql.= ", s.rowid as socid, s.nom as name, s.email"; -$sql.= ", cls.code as opp_status_code"; +$sql .= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount, p.usage_opportunity, p.usage_task, p.usage_bill_time"; +$sql .= ", s.rowid as socid, s.nom as name, s.email"; +$sql .= ", cls.code as opp_status_code"; // We'll need these fields in order to filter by categ if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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."projet as p"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; +$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."projet as p"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; // We'll need this table joined to the select in order to filter by categ -if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ +if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ // We'll need this table joined to the select in order to filter by sale // No check is done on company permission because readability is managed by public status of project and assignement. //if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; if ($search_sale > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; if ($search_project_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp"; } -$sql.= " WHERE p.entity IN (".getEntity('project').')'; -if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users +$sql .= " WHERE p.entity IN (".getEntity('project').')'; +if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users // No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser -if ($socid > 0) $sql.= " AND (p.fk_soc = ".$socid.")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users) -if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; +if ($socid > 0) $sql .= " AND (p.fk_soc = ".$socid.")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users) +if ($search_categ > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ); +if ($search_categ == -2) $sql .= " AND cs.fk_categorie IS NULL"; if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_label) $sql .= natural_search('p.title', $search_label); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); @@ -343,13 +343,13 @@ if ($search_opp_status) if ($search_opp_status == 'notopenedopp') $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1 OR p.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON')))"; if ($search_opp_status == 'none') $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)"; } -if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); +if ($search_public != '') $sql .= " AND p.public = ".$db->escape($search_public); // For external user, no check is done on company permission because readability is managed by public status of project and assignement. //if ($socid > 0) $sql.= " AND s.rowid = ".$socid; -if ($search_sale > 0) $sql.= " AND sc.fk_user = " .$search_sale; +if ($search_sale > 0) $sql .= " AND sc.fk_user = ".$search_sale; // No check is done on company permission because readability is managed by public status of project and assignement. //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; -if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; +if ($search_project_user > 0) $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; if ($search_opp_amount != '') $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); if ($search_budget_amount != '') $sql .= natural_search('p.budget_amount', $search_budget_amount, 1); if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) $sql .= natural_search('p.usage_opportunity', $search_usage_opportunity, 2); @@ -358,10 +358,10 @@ if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) $sql .= n // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -375,12 +375,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); dol_syslog("list allowed project", LOG_DEBUG); $resql = $db->query($sql); -if (! $resql) +if (!$resql) { dol_print_error($db); exit; @@ -388,61 +388,61 @@ if (! $resql) $num = $db->num_rows($resql); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id); exit; } -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($search_all != '') $param.='&search_all='.$search_all; -if ($search_sday) $param.='&search_sday='.$search_sday; -if ($search_smonth) $param.='&search_smonth='.$search_smonth; -if ($search_syear) $param.='&search_syear=' .$search_syear; -if ($search_eday) $param.='&search_eday='.$search_eday; -if ($search_emonth) $param.='&search_emonth='.$search_emonth; -if ($search_eyear) $param.='&search_eyear=' .$search_eyear; -if ($socid) $param.='&socid='.$socid; -if ($search_ref != '') $param.='&search_ref='.$search_ref; -if ($search_label != '') $param.='&search_label='.$search_label; -if ($search_societe != '') $param.='&search_societe='.$search_societe; -if ($search_status >= 0) $param.='&search_status='.$search_status; -if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','openedopp','notopenedopp','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); -if ($search_opp_percent != '') $param.='&search_opp_percent='.urlencode($search_opp_percent); -if ($search_public != '') $param.='&search_public='.$search_public; -if ($search_project_user != '') $param.='&search_project_user='.$search_project_user; -if ($search_sale > 0) $param.='&search_sale='.$search_sale; -if ($search_opp_amount != '') $param.='&search_opp_amount='.$search_opp_amount; -if ($search_budget_amount != '') $param.='&search_budget_amount='.$search_budget_amount; -if ($optioncss != '') $param.='&optioncss='.$optioncss; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($search_all != '') $param .= '&search_all='.$search_all; +if ($search_sday) $param .= '&search_sday='.$search_sday; +if ($search_smonth) $param .= '&search_smonth='.$search_smonth; +if ($search_syear) $param .= '&search_syear='.$search_syear; +if ($search_eday) $param .= '&search_eday='.$search_eday; +if ($search_emonth) $param .= '&search_emonth='.$search_emonth; +if ($search_eyear) $param .= '&search_eyear='.$search_eyear; +if ($socid) $param .= '&socid='.$socid; +if ($search_ref != '') $param .= '&search_ref='.$search_ref; +if ($search_label != '') $param .= '&search_label='.$search_label; +if ($search_societe != '') $param .= '&search_societe='.$search_societe; +if ($search_status >= 0) $param .= '&search_status='.$search_status; +if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status); +if ($search_opp_percent != '') $param .= '&search_opp_percent='.urlencode($search_opp_percent); +if ($search_public != '') $param .= '&search_public='.$search_public; +if ($search_project_user != '') $param .= '&search_project_user='.$search_project_user; +if ($search_sale > 0) $param .= '&search_sale='.$search_sale; +if ($search_opp_amount != '') $param .= '&search_opp_amount='.$search_opp_amount; +if ($search_budget_amount != '') $param .= '&search_budget_amount='.$search_budget_amount; +if ($optioncss != '') $param .= '&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->projet->creer) $arrayofmassactions['close']=$langs->trans("Close"); -if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +if ($user->rights->projet->creer) $arrayofmassactions['close'] = $langs->trans("Close"); +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->projet->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create'); } print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; @@ -457,173 +457,173 @@ print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; // Show description of content -$texthelp=''; -if ($search_project_user == $user->id) $texthelp.=$langs->trans("MyProjectsDesc"); +$texthelp = ''; +if ($search_project_user == $user->id) $texthelp .= $langs->trans("MyProjectsDesc"); else { - if ($user->rights->projet->all->lire && ! $socid) $texthelp.=$langs->trans("ProjectsDesc"); - else $texthelp.=$langs->trans("ProjectsPublicDesc"); + if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("ProjectsDesc"); + else $texthelp .= $langs->trans("ProjectsPublicDesc"); } print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit); -$topicmail="Information"; -$modelmail="project"; -$objecttmp=new Project($db); -$trackid='prj'.$object->id; +$topicmail = "Information"; +$modelmail = "project"; +$objecttmp = new Project($db); +$trackid = 'prj'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } -$moreforfilter=''; +$moreforfilter = ''; // Filter on categories -if (! empty($conf->categorie->enabled)) +if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('ProjectCategories'). ': '; - $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300'); - $moreforfilter.='</div>'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ProjectCategories').': '; + $moreforfilter .= $formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300'); + $moreforfilter .= '</div>'; } // If the user can view user other than himself -$moreforfilter.='<div class="divsearchfield">'; -$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; -$includeonly='hierarchyme'; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); -$moreforfilter.='</div>'; +$moreforfilter .= '<div class="divsearchfield">'; +$moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').': '; +$includeonly = 'hierarchyme'; +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= '</div>'; // If the user can view thirdparties other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '</div>'; } -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</div>'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; -print '<table class="tagtable nobottomiftotal liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<tr class="liste_titre_filter">'; // Project ref -if (! empty($arrayfields['p.ref']['checked'])) +if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_ref" value="'.dol_escape_htmltag($search_ref).'" size="6">'; print '</td>'; } // Project label -if (! empty($arrayfields['p.title']['checked'])) +if (!empty($arrayfields['p.title']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).'">'; print '</td>'; } // Third party -if (! empty($arrayfields['s.nom']['checked'])) +if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre">'; if ($socid > 0) { - $tmpthirdparty=new Societe($db); + $tmpthirdparty = new Societe($db); $tmpthirdparty->fetch($socid); - $search_societe=$tmpthirdparty->nom; + $search_societe = $tmpthirdparty->nom; } print '<input type="text" class="flat" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">'; print '</td>'; } // Sale representative -if (! empty($arrayfields['commercial']['checked'])) +if (!empty($arrayfields['commercial']['checked'])) { print '<td class="liste_titre"> </td>'; } // Start date -if (! empty($arrayfields['p.dateo']['checked'])) +if (!empty($arrayfields['p.dateo']['checked'])) { print '<td class="liste_titre center nowraponall">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">'; print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_smonth" value="'.dol_escape_htmltag($search_smonth).'">'; - $formother->select_year($search_syear?$search_syear:-1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print '</td>'; } // End date -if (! empty($arrayfields['p.datee']['checked'])) +if (!empty($arrayfields['p.datee']['checked'])) { print '<td class="liste_titre center nowraponall">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">'; print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_emonth" value="'.dol_escape_htmltag($search_emonth).'">'; - $formother->select_year($search_eyear?$search_eyear:-1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print '</td>'; } -if (! empty($arrayfields['p.public']['checked'])) +if (!empty($arrayfields['p.public']['checked'])) { print '<td class="liste_titre">'; - $array=array(''=>'',0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject")); + $array = array(''=>'', 0 => $langs->trans("PrivateProject"), 1 => $langs->trans("SharedProject")); print $form->selectarray('search_public', $array, $search_public); print '</td>'; } // Opp status -if (! empty($arrayfields['p.fk_opp_status']['checked'])) +if (!empty($arrayfields['p.fk_opp_status']['checked'])) { print '<td class="liste_titre nowrap center">'; print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100'); print '</td>'; } -if (! empty($arrayfields['p.opp_amount']['checked'])) +if (!empty($arrayfields['p.opp_amount']['checked'])) { print '<td class="liste_titre nowrap right">'; print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">'; print '</td>'; } -if (! empty($arrayfields['p.opp_percent']['checked'])) +if (!empty($arrayfields['p.opp_percent']['checked'])) { print '<td class="liste_titre nowrap right">'; print '<input type="text" class="flat" name="search_opp_percent" size="2" value="'.$search_opp_percent.'">'; print '</td>'; } -if (! empty($arrayfields['p.budget_amount']['checked'])) +if (!empty($arrayfields['p.budget_amount']['checked'])) { print '<td class="liste_titre nowrap right">'; print '<input type="text" class="flat" name="search_budget_amount" size="4" value="'.$search_budget_amount.'">'; print '</td>'; } -if (! empty($arrayfields['p.usage_opportunity']['checked'])) +if (!empty($arrayfields['p.usage_opportunity']['checked'])) { print '<td class="liste_titre nowrap right">'; print $form->selectyesno('search_usage_opportunity', $search_usage_opportunity, 1, false, 1); print ''; print '</td>'; } -if (! empty($arrayfields['p.usage_task']['checked'])) +if (!empty($arrayfields['p.usage_task']['checked'])) { print '<td class="liste_titre nowrap right">'; print $form->selectyesno('search_usage_task', $search_usage_task, 1, false, 1); print '</td>'; } -if (! empty($arrayfields['p.usage_bill_time']['checked'])) +if (!empty($arrayfields['p.usage_bill_time']['checked'])) { print '<td class="liste_titre nowrap right">'; print $form->selectyesno('search_usage_bill_time', $search_usage_bill_time, 1, false, 1); @@ -633,68 +633,68 @@ if (! empty($arrayfields['p.usage_bill_time']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['p.datec']['checked'])) +if (!empty($arrayfields['p.datec']['checked'])) { // Date creation print '<td class="liste_titre">'; print '</td>'; } -if (! empty($arrayfields['p.tms']['checked'])) +if (!empty($arrayfields['p.tms']['checked'])) { // Date modification print '<td class="liste_titre">'; print '</td>'; } -if (! empty($arrayfields['p.fk_statut']['checked'])) +if (!empty($arrayfields['p.fk_statut']['checked'])) { print '<td class="liste_titre nowrap right">'; $arrayofstatus = array(); - foreach($object->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val); - $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')'; + foreach ($object->statuts_short as $key => $val) $arrayofstatus[$key] = $langs->trans($val); + $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')'; print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 selectarrowonleft'); print ajax_combobox('search_status'); print '</td>'; } // Action column print '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; print '<tr class="liste_titre">'; -if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['p.usage_opportunity']['checked'])) print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['p.usage_task']['checked'])) print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.usage_opportunity']['checked'])) print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.usage_task']['checked'])) print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$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 +$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; -if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -708,34 +708,34 @@ while ($i < min($num, $limit)) $object->opp_status = $obj->fk_opp_status; $object->title = $obj->title; - $userAccess = $object->restrictedProjectArea($user); // why this ? + $userAccess = $object->restrictedProjectArea($user); // why this ? if ($userAccess >= 0) { - $socstatic->id=$obj->socid; - $socstatic->name=$obj->name; - $socstatic->email=$obj->email; + $socstatic->id = $obj->socid; + $socstatic->name = $obj->name; + $socstatic->email = $obj->email; print '<tr class="oddeven">'; // Project url - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="nowrap">'; print $object->getNomUrl(1); if ($object->hasDelay()) print img_warning($langs->trans('Late')); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Title - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print '<td class="tdoverflowmax200">'; print dol_trunc($obj->title, 80); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Company - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="tdoverflowmax100">'; if ($obj->socid) @@ -747,18 +747,18 @@ while ($i < min($num, $limit)) print ' '; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Sales Representatives - if (! empty($arrayfields['commercial']['checked'])) + if (!empty($arrayfields['commercial']['checked'])) { print '<td>'; if ($obj->socid) { - $socstatic->id=$obj->socid; - $socstatic->name=$obj->name; - $listsalesrepresentatives=$socstatic->getSalesRepresentatives($user); - $nbofsalesrepresentative=count($listsalesrepresentatives); + $socstatic->id = $obj->socid; + $socstatic->name = $obj->name; + $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user); + $nbofsalesrepresentative = count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$socstatic->id.'">'; @@ -767,17 +767,17 @@ while ($i < min($num, $limit)) } elseif ($nbofsalesrepresentative > 0) { - $userstatic=new User($db); - $j=0; - foreach($listsalesrepresentatives as $val) + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { - $userstatic->id=$val['id']; - $userstatic->lastname=$val['lastname']; - $userstatic->firstname=$val['firstname']; - $userstatic->email=$val['email']; - $userstatic->statut=$val['statut']; - $userstatic->entity=$val['entity']; - $userstatic->photo=$val['photo']; + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; //print $userstatic->getNomUrl(1, '', 0, 0, 12); print $userstatic->getNomUrl(-2); $j++; @@ -791,43 +791,43 @@ while ($i < min($num, $limit)) print ' '; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date start - if (! empty($arrayfields['p.dateo']['checked'])) + if (!empty($arrayfields['p.dateo']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_start), 'day'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date end - if (! empty($arrayfields['p.datee']['checked'])) + if (!empty($arrayfields['p.datee']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_end), 'day'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Visibility - if (! empty($arrayfields['p.public']['checked'])) + if (!empty($arrayfields['p.public']['checked'])) { print '<td class="left">'; if ($obj->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Opp Status - if (! empty($arrayfields['p.fk_opp_status']['checked'])) + if (!empty($arrayfields['p.fk_opp_status']['checked'])) { print '<td class="center">'; if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Opp Amount - if (! empty($arrayfields['p.opp_amount']['checked'])) + if (!empty($arrayfields['p.opp_amount']['checked'])) { print '<td class="right">'; //if ($obj->opp_status_code) @@ -870,10 +870,10 @@ while ($i < min($num, $limit)) print yn($obj->usage_opportunity); } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Usage task - if (! empty($arrayfields['p.usage_task']['checked'])) + if (!empty($arrayfields['p.usage_task']['checked'])) { print '<td class="right">'; if ($obj->usage_task) @@ -881,10 +881,10 @@ while ($i < min($num, $limit)) print yn($obj->usage_task); } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Bill time - if (! empty($arrayfields['p.usage_bill_time']['checked'])) + if (!empty($arrayfields['p.usage_bill_time']['checked'])) { print '<td class="right">'; if ($obj->usage_bill_time) @@ -892,46 +892,46 @@ while ($i < min($num, $limit)) print yn($obj->usage_bill_time); } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['p.fk_statut']['checked'])) + if (!empty($arrayfields['p.fk_statut']['checked'])) { print '<td class="right">'.$object->getLibStatut(5).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->id, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->id, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "</tr>\n"; } @@ -944,8 +944,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; $db->free($resql); -$parameters=array('sql' => $sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('sql' => $sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "</table>\n"; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index f16a9070325..9d9b8e69516 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -36,31 +36,31 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $langs->loadLangs(array('projects', 'users', 'companies')); $action = GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $taskref = GETPOST('taskref', 'alpha'); -$backtopage=GETPOST('backtopage', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); $search_user_id = GETPOST('search_user_id', 'int'); -$search_taskref=GETPOST('search_taskref'); -$search_tasklabel=GETPOST('search_tasklabel'); -$search_dtstartday=GETPOST('search_dtstartday'); -$search_dtstartmonth=GETPOST('search_dtstartmonth'); -$search_dtstartyear=GETPOST('search_dtstartyear'); -$search_dtendday=GETPOST('search_dtendday'); -$search_dtendmonth=GETPOST('search_dtendmonth'); -$search_dtendyear=GETPOST('search_dtendyear'); -$search_planedworkload=GETPOST('search_planedworkload'); -$search_timespend=GETPOST('search_timespend'); -$search_progresscalc=GETPOST('search_progresscalc'); -$search_progressdeclare=GETPOST('search_progressdeclare'); +$search_taskref = GETPOST('search_taskref'); +$search_tasklabel = GETPOST('search_tasklabel'); +$search_dtstartday = GETPOST('search_dtstartday'); +$search_dtstartmonth = GETPOST('search_dtstartmonth'); +$search_dtstartyear = GETPOST('search_dtstartyear'); +$search_dtendday = GETPOST('search_dtendday'); +$search_dtendmonth = GETPOST('search_dtendmonth'); +$search_dtendyear = GETPOST('search_dtendyear'); +$search_planedworkload = GETPOST('search_planedworkload'); +$search_timespend = GETPOST('search_timespend'); +$search_progresscalc = GETPOST('search_progresscalc'); +$search_progressdeclare = GETPOST('search_progressdeclare'); //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects @@ -68,10 +68,10 @@ $object = new Project($db); $taskstatic = new Task($db); $extrafields = new ExtraFields($db); -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -79,23 +79,23 @@ if ($id > 0 || ! empty($ref)) $extrafields->fetch_name_optionals_label($taskstatic->table_element); // Security check -$socid=0; +$socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $id, 'projet&project'); -$diroutputmassaction=$conf->projet->dir_output . '/tasks/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->projet->dir_output.'/tasks/temp/massgeneration/'.$user->id; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('projecttaskscard','globalcard')); +$hookmanager->initHooks(array('projecttaskscard', 'globalcard')); -$progress=GETPOST('progress', 'int'); -$label=GETPOST('label', 'alpha'); -$description=GETPOST('description'); -$planned_workloadhour=(GETPOST('planned_workloadhour', 'int')?GETPOST('planned_workloadhour', 'int'):0); -$planned_workloadmin=(GETPOST('planned_workloadmin', 'int')?GETPOST('planned_workloadmin', 'int'):0); -$planned_workload=$planned_workloadhour*3600+$planned_workloadmin*60; +$progress = GETPOST('progress', 'int'); +$label = GETPOST('label', 'alpha'); +$description = GETPOST('description'); +$planned_workloadhour = (GETPOST('planned_workloadhour', 'int') ?GETPOST('planned_workloadhour', 'int') : 0); +$planned_workloadmin = (GETPOST('planned_workloadmin', 'int') ?GETPOST('planned_workloadmin', 'int') : 0); +$planned_workload = $planned_workloadhour * 3600 + $planned_workloadmin * 60; -$arrayfields=array( +$arrayfields = array( 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>80), 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>80), 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), @@ -117,10 +117,10 @@ $arrayfields=array( // Extra fields project 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -131,8 +131,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -$parameters=array('id'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id); +$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)) @@ -143,40 +143,40 @@ if (empty($reshook)) // 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_user_id=""; - $search_taskref=''; - $search_tasklabel=''; - $search_dtstartday=''; - $search_dtstartmonth=''; - $search_dtstartyear=''; - $search_dtendday=''; - $search_dtendmonth=''; - $search_dtendyear=''; - $search_planedworkload=''; - $search_timespend=''; - $search_progresscalc=''; - $search_progressdeclare=''; - $toselect=''; - $search_array_options=array(); + $search_user_id = ""; + $search_taskref = ''; + $search_tasklabel = ''; + $search_dtstartday = ''; + $search_dtstartmonth = ''; + $search_dtstartyear = ''; + $search_dtendday = ''; + $search_dtendmonth = ''; + $search_dtendyear = ''; + $search_planedworkload = ''; + $search_timespend = ''; + $search_progresscalc = ''; + $search_progressdeclare = ''; + $toselect = ''; + $search_array_options = array(); } // Mass actions - $objectclass='Task'; - $objectlabel='Tasks'; + $objectclass = 'Task'; + $objectlabel = 'Tasks'; $permissiontoread = $user->rights->projet->lire; $permissiontodelete = $user->rights->projet->supprimer; $uploaddir = $conf->projet->dir_output.'/tasks'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -$morewherefilterarray=array(); +$morewherefilterarray = array(); if (!empty($search_taskref)) { - $morewherefilterarray[]= natural_search('t.ref', $search_taskref, 0, 1); + $morewherefilterarray[] = natural_search('t.ref', $search_taskref, 0, 1); } if (!empty($search_tasklabel)) { - $morewherefilterarray[]= natural_search('t.label', $search_tasklabel, 0, 1); + $morewherefilterarray[] = natural_search('t.label', $search_tasklabel, 0, 1); } $moresql = dolSqlDateFilter('t.dateo', $search_dtstartday, $search_dtstartmonth, $search_dtstartyear, 1); @@ -186,32 +186,32 @@ $moresql = dolSqlDateFilter('t.datee', $search_dtendday, $search_dtendmonth, $se if ($moresql) $morewherefilterarray[] = $moresql; if (!empty($search_planedworkload)) { - $morewherefilterarray[]= natural_search('t.planned_workload', $search_planedworkload, 1, 1); + $morewherefilterarray[] = natural_search('t.planned_workload', $search_planedworkload, 1, 1); } if (!empty($search_timespend)) { - $morewherefilterarray[]= natural_search('t.duration_effective', $search_timespend, 1, 1); + $morewherefilterarray[] = natural_search('t.duration_effective', $search_timespend, 1, 1); } if (!empty($search_progresscalc)) { - $filterprogresscalc='if '.natural_search('round(100 * $line->duration / $line->planned_workload,2)', $search_progresscalc, 1, 1). '{return 1;} else {return 0;}'; + $filterprogresscalc = 'if '.natural_search('round(100 * $line->duration / $line->planned_workload,2)', $search_progresscalc, 1, 1).'{return 1;} else {return 0;}'; } else { - $filterprogresscalc=''; + $filterprogresscalc = ''; } if (!empty($search_progressdeclare)) { - $morewherefilterarray[]= natural_search('t.progress', $search_progressdeclare, 1, 1); + $morewherefilterarray[] = natural_search('t.progress', $search_progressdeclare, 1, 1); } -$morewherefilter=''; -if (count($morewherefilterarray)>0) { - $morewherefilter= ' AND '. implode(' AND ', $morewherefilterarray); +$morewherefilter = ''; +if (count($morewherefilterarray) > 0) { + $morewherefilter = ' AND '.implode(' AND ', $morewherefilterarray); } if ($action == 'createtask' && $user->rights->projet->creer) { - $error=0; + $error = 0; // If we use user timezone, we must change also view/list to use user timezone everywhere //$date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear'],'user'); @@ -219,34 +219,34 @@ if ($action == 'createtask' && $user->rights->projet->creer) $date_start = dol_mktime($_POST['dateohour'], $_POST['dateomin'], 0, $_POST['dateomonth'], $_POST['dateoday'], $_POST['dateoyear']); $date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'], $_POST['dateeyear']); - if (! $cancel) + if (!$cancel) { if (empty($taskref)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } if (empty($label)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } elseif (empty($_POST['task_parent'])) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ChildOfProjectTask")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } - if (! $error) + if (!$error) { - $tmparray=explode('_', $_POST['task_parent']); - $projectid=$tmparray[0]; + $tmparray = explode('_', $_POST['task_parent']); + $projectid = $tmparray[0]; if (empty($projectid)) $projectid = $id; // If projectid is '' - $task_parent=$tmparray[1]; - if (empty($task_parent)) $task_parent = 0; // If task_parent is '' + $task_parent = $tmparray[1]; + if (empty($task_parent)) $task_parent = 0; // If task_parent is '' $task = new Task($db); @@ -287,16 +287,16 @@ if ($action == 'createtask' && $user->rights->projet->creer) } } - if (! $error) + if (!$error) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } elseif (empty($projectid)) { - header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode)?'':'?mode='.$mode)); + header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode)); exit; } $id = $projectid; @@ -304,7 +304,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) } else { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -312,7 +312,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) elseif (empty($id)) { // We go back on task list - header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode)?'':'?mode='.$mode)); + header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode)); exit; } } @@ -324,62 +324,62 @@ if ($action == 'createtask' && $user->rights->projet->creer) */ $now = dol_now(); -$form=new Form($db); -$formother=new FormOther($db); -$socstatic=new Societe($db); +$form = new Form($db); +$formother = new FormOther($db); +$socstatic = new Societe($db); $projectstatic = new Project($db); $taskstatic = new Task($db); -$userstatic=new User($db); +$userstatic = new User($db); -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$title=$langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name; -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Tasks"); -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$title = $langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Tasks"); +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); - $userWrite = $object->restrictedProjectArea($user, 'write'); + $userWrite = $object->restrictedProjectArea($user, 'write'); //$userDelete = $object->restrictedProjectArea($user,'delete'); //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; - $tab=GETPOST('tab')?GETPOST('tab'):'tasks'; + $tab = GETPOST('tab') ?GETPOST('tab') : 'tasks'; - $head=project_prepare_head($object); - dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); + $head = project_prepare_head($object); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); - $param=''; - if ($search_user_id > 0) $param.='&search_user_id='.dol_escape_htmltag($search_user_id); + $param = ''; + if ($search_user_id > 0) $param .= '&search_user_id='.dol_escape_htmltag($search_user_id); // Project card $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; - $morehtmlref='<div class="refidno">'; + $morehtmlref = '<div class="refidno">'; // Title - $morehtmlref.=$object->title; + $morehtmlref .= $object->title; // Thirdparty if ($object->thirdparty->id > 0) { - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } - $morehtmlref.='</div>'; + $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (! $user->rights->projet->all->lire) + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")"; + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -395,23 +395,23 @@ if ($id > 0 || ! empty($ref)) print $langs->trans("Usage"); print '</td>'; print '<td>'; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha')!=''?' checked="checked"':'') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; + print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '<br>'; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha')!=''?' checked="checked"':'') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; + print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '<br>'; } - if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha')!=''?' checked="checked"':'') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; + print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '<br>'; @@ -446,10 +446,10 @@ if ($id > 0 || ! empty($ref)) // Date start - end print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; $start = dol_print_date($object->date_start, 'dayhour'); - print ($start?$start:'?'); + print ($start ? $start : '?'); $end = dol_print_date($object->date_end, 'dayhour'); print ' - '; - print ($end?$end:'?'); + print ($end ? $end : '?'); if ($object->hasDelay()) print img_warning("Late"); print '</td></tr>'; @@ -460,7 +460,7 @@ if ($id > 0 || ! empty($ref)) // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '</table>'; @@ -477,7 +477,7 @@ if ($id > 0 || ! empty($ref)) print '</td></tr>'; // Bill time - if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '<tr><td>'.$langs->trans("BillTime").'</td><td>'; print yn($object->usage_bill_time); @@ -506,7 +506,7 @@ if ($id > 0 || ! empty($ref)) if ($action == 'create' && $user->rights->projet->creer && (empty($object->thirdparty->id) || $userWrite > 0)) { - if ($id > 0 || ! empty($ref)) print '<br>'; + if ($id > 0 || !empty($ref)) print '<br>'; print load_fiche_titre($langs->trans("NewTask"), '', 'project'); @@ -523,34 +523,34 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="createtask">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; - if (! empty($object->id)) print '<input type="hidden" name="id" value="'.$object->id.'">'; + if (!empty($object->id)) print '<input type="hidden" name="id" value="'.$object->id.'">'; dol_fiche_head(''); print '<table class="border centpercent">'; - $defaultref=''; - $obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON; - if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) + $defaultref = ''; + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) { - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; + require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; $modTask = new $obj; $defaultref = $modTask->getNextValue($object->thirdparty, null); } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; // Ref print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>'; if (empty($duplicate_code_error)) { - print (GETPOSTISSET("ref")?GETPOST("ref", 'alpha'):$defaultref); + print (GETPOSTISSET("ref") ?GETPOST("ref", 'alpha') : $defaultref); } else { print $defaultref; } - print '<input type="hidden" name="taskref" value="'.($_POST["ref"]?$_POST["ref"]:$defaultref).'">'; + print '<input type="hidden" name="taskref" value="'.($_POST["ref"] ? $_POST["ref"] : $defaultref).'">'; print '</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>'; @@ -559,11 +559,11 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // List of projects print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfProjectTask").'</td><td>'; - print $formother->selectProjectTasks(GETPOST('task_parent'), $projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1, 0, '0,1', 'maxwidth500'); + print $formother->selectProjectTasks(GETPOST('task_parent'), $projectid ? $projectid : $object->id, 'task_parent', 0, 0, 1, 1, 0, '0,1', 'maxwidth500'); print '</td></tr>'; print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>'; - $contactsofproject=(! empty($object->id)?$object->getListContactId('internal'):''); + $contactsofproject = (!empty($object->id) ? $object->getListContactId('internal') : ''); if (is_array($contactsofproject) && count($contactsofproject)) { print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300'); @@ -576,17 +576,17 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // Date start print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; - print $form->selectDate(($date_start?$date_start:''), 'dateo', 1, 1, 0, '', 1, 1); + print $form->selectDate(($date_start ? $date_start : ''), 'dateo', 1, 1, 0, '', 1, 1); print '</td></tr>'; // Date end print '<tr><td>'.$langs->trans("DateEnd").'</td><td>'; - print $form->selectDate(($date_end?$date_end:-1), 'datee', -1, 1, 0, '', 1, 1); + print $form->selectDate(($date_end ? $date_end : -1), 'datee', -1, 1, 0, '', 1, 1); print '</td></tr>'; // Planned workload print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>'; - print $form->select_duration('planned_workload', $planned_workload?$planned_workload : 0, 0, 'text'); + print $form->select_duration('planned_workload', $planned_workload ? $planned_workload : 0, 0, 'text'); print '</td></tr>'; // Progress @@ -601,13 +601,13 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print '</td></tr>'; // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields[$taskstatic->table_element]['label'])) + if (empty($reshook) && !empty($extrafields[$taskstatic->table_element]['label'])) { - print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic + print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic } print '</table>'; @@ -623,25 +623,25 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print '</form>'; } } -elseif ($id > 0 || ! empty($ref)) +elseif ($id > 0 || !empty($ref)) { /* * Projet card in view mode */ // Definition of fields for list - $arrayfields=array(); - $arrayfields['t.task_ref']=array('label'=>$langs->trans("RefTask"), 'checked'=>1); - $arrayfields['t.task_label']=array('label'=>$langs->trans("LabelTask"), 'checked'=>1); - $arrayfields['t.task_date_start']=array('label'=>$langs->trans("DateStart"), 'checked'=>1); - $arrayfields['t.task_date_end']=array('label'=>$langs->trans("DateEnd"), 'checked'=>1); + $arrayfields = array(); + $arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); + $arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); + $arrayfields['t.task_date_start'] = array('label'=>$langs->trans("DateStart"), 'checked'=>1); + $arrayfields['t.task_date_end'] = array('label'=>$langs->trans("DateEnd"), 'checked'=>1); // Extra fields if (is_array($extrafields->attributes[$taskstatic->table_element]['label']) && count($extrafields->attributes[$taskstatic->table_element]['label']) > 0) { - foreach($extrafields->attributes[$taskstatic->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$taskstatic->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$taskstatic->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$taskstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$taskstatic->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$taskstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$taskstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$taskstatic->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$taskstatic->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$taskstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$taskstatic->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$taskstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$taskstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$taskstatic->table_element]['perms'][$key])); } } $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -652,9 +652,9 @@ elseif ($id > 0 || ! empty($ref)) $linktocreatetaskParam = array(); $linktocreatetaskUserRight = false; if ($user->rights->projet->all->creer || $user->rights->projet->creer) { - if ($object->public || $userWrite > 0){ + if ($object->public || $userWrite > 0) { $linktocreatetaskUserRight = true; - }else{ + } else { $linktocreatetaskParam['attr']['title'] = $langs->trans("NotOwnerOfProject"); } } @@ -672,7 +672,7 @@ elseif ($id > 0 || ! empty($ref)) print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; - $title=$langs->trans("ListOfTasks"); + $title = $langs->trans("ListOfTasks"); $linktotasks = dolGetButtonTitle($langs->trans('GoToGanttView'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss'=>'reposition')); //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1); @@ -681,28 +681,28 @@ elseif ($id > 0 || ! empty($ref)) // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). $filteronthirdpartyid = $socid; - $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, array(), 1); + $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, array(), 1); // We load also tasks limited to a particular user - $tmpuser=new User($db); + $tmpuser = new User($db); if ($search_user_id > 0) $tmpuser->fetch($search_user_id); - $tasksrole=($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : ''); + $tasksrole = ($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : ''); //var_dump($tasksarray); //var_dump($tasksrole); - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } // Filter on categories - $moreforfilter=''; + $moreforfilter = ''; if (count($tasksarray) > 0) { - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans("TasksAssignedTo").': '; - $moreforfilter.=$form->select_dolusers($tmpuser->id > 0 ? $tmpuser->id : '', 'search_user_id', 1); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans("TasksAssignedTo").': '; + $moreforfilter .= $form->select_dolusers($tmpuser->id > 0 ? $tmpuser->id : '', 'search_user_id', 1); + $moreforfilter .= '</div>'; } if ($moreforfilter) { @@ -711,11 +711,11 @@ elseif ($id > 0 || ! empty($ref)) print '</div>'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '<div class="div-table-responsive">'; - print '<table id="tablelines" class="tagtable nobottomiftotal liste'.($moreforfilter?" listwithfilterbefore":"").'">'; + print '<table id="tablelines" class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'; // Fields title search print '<tr class="liste_titre_filter">'; @@ -731,13 +731,13 @@ elseif ($id > 0 || ! empty($ref)) print '<td class="liste_titre center">'; print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_dtstartday" value="'.$search_dtstartday.'">'; print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_dtstartmonth" value="'.$search_dtstartmonth.'">'; - $formother->select_year($search_dtstartyear?$search_dtstartyear:-1, 'search_dtstartyear', 1, 20, 5); + $formother->select_year($search_dtstartyear ? $search_dtstartyear : -1, 'search_dtstartyear', 1, 20, 5); print '</td>'; print '<td class="liste_titre center">'; print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_dtendday" value="'.$search_dtendday.'">'; print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_dtendmonth" value="'.$search_dtendmonth.'">'; - $formother->select_year($search_dtendyear?$search_dtendyear:-1, 'search_dtendyear', 1, 20, 5); + $formother->select_year($search_dtendyear ? $search_dtendyear : -1, 'search_dtendyear', 1, 20, 5); print '</td>'; print '<td class="liste_titre right">'; @@ -768,11 +768,11 @@ elseif ($id > 0 || ! empty($ref)) print '</td>'; } - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print '<td></td>'; + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print '<td></td>'; // Action column print '<td class="liste_titre maxwidthsearch">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; @@ -793,20 +793,20 @@ elseif ($id > 0 || ! empty($ref)) print_liste_field_titre("TimeToBill", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); print_liste_field_titre("TimeBilled", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); } - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', '', $sortfield, $sortorder); + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', '', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; if (count($tasksarray) > 0) { // Show all lines in taskarray (recursive function to go down on tree) - $j=0; $level=0; - $nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time?1:0)); + $j = 0; $level = 0; + $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0)); } else { - $colspan=10; - if ($object->usage_bill_time) $colspan+=2; + $colspan = 10; + if ($object->usage_bill_time) $colspan += 2; print '<tr class="oddeven nobottom"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoTasks").'</span></td></tr>'; } @@ -818,7 +818,7 @@ elseif ($id > 0 || ! empty($ref)) // Test if database is clean. If not we clean it. //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'<br>'; - if (! empty($user->rights->projet->all->lire)) // We make test to clean only if user has permission to see all (test may report false positive otherwise) + if (!empty($user->rights->projet->all->lire)) // We make test to clean only if user has permission to see all (test may report false positive otherwise) { if ($search_user_id == $user->id) { @@ -830,7 +830,7 @@ elseif ($id > 0 || ! empty($ref)) } else { - if ($nboftaskshown < count($tasksarray) && ! GETPOST('search_user_id', 'int')) + if ($nboftaskshown < count($tasksarray) && !GETPOST('search_user_id', 'int')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; cleanCorruptedTree($db, 'projet_task', 'fk_task_parent'); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 5215c82a062..a529c7d1a9d 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -34,32 +34,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('projects', 'users', 'companies')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); -$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_categ=GETPOST("search_categ", 'alpha'); -$search_project=GETPOST('search_project'); -if (! isset($_GET['search_projectstatus']) && ! isset($_POST['search_projectstatus'])) +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_categ = GETPOST("search_categ", 'alpha'); +$search_project = GETPOST('search_project'); +if (!isset($_GET['search_projectstatus']) && !isset($_POST['search_projectstatus'])) { - if ($search_all != '') $search_projectstatus=-1; - else $search_projectstatus=1; + if ($search_all != '') $search_projectstatus = -1; + else $search_projectstatus = 1; } -else $search_projectstatus=GETPOST('search_projectstatus'); -$search_project_ref=GETPOST('search_project_ref'); -$search_project_title=GETPOST('search_project_title'); -$search_task_ref=GETPOST('search_task_ref'); -$search_task_label=GETPOST('search_task_label'); -$search_task_description=GETPOST('search_task_description'); -$search_project_user=GETPOST('search_project_user'); -$search_task_user=GETPOST('search_task_user'); +else $search_projectstatus = GETPOST('search_projectstatus'); +$search_project_ref = GETPOST('search_project_ref'); +$search_project_title = GETPOST('search_project_title'); +$search_task_ref = GETPOST('search_task_ref'); +$search_task_label = GETPOST('search_task_label'); +$search_task_description = GETPOST('search_task_description'); +$search_project_user = GETPOST('search_project_user'); +$search_task_user = GETPOST('search_task_user'); -$mine = $_REQUEST['mode']=='mine' ? 1 : 0; +$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; if ($mine) { $search_task_user = $user->id; $mine = 0; } $search_sday = GETPOST('search_sday', 'int'); @@ -70,7 +70,7 @@ $search_emonth = GETPOST('search_emonth', 'int'); $search_eyear = GETPOST('search_eyear', 'int'); // Initialize context for list -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'tasklist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'tasklist'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Task($db); @@ -79,16 +79,16 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Security check -$socid=0; +$socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (!$user->rights->projet->lire) accessforbidden(); -$diroutputmassaction=$conf->projet->dir_output . '/tasks/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->projet->dir_output.'/tasks/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -96,8 +96,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='p.ref'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'p.ref'; +if (!$sortorder) $sortorder = 'DESC'; // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -106,9 +106,9 @@ $fieldstosearchall = array( 't.description'=>"Description", 't.note_public'=>"NotePublic", ); -if (empty($user->socid)) $fieldstosearchall['t.note_private']="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall['t.note_private'] = "NotePrivate"; -$arrayfields=array( +$arrayfields = array( 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>80), 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>80), 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), @@ -131,10 +131,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -145,11 +145,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) @@ -160,37 +160,37 @@ if (empty($reshook)) // 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_all=""; - $search_categ=""; - $search_project=""; - $search_projectstatus=-1; - $search_project_ref=""; - $search_project_title=""; - $search_task_ref=""; - $search_task_label=""; - $search_task_description=""; - $search_task_user=-1; - $search_project_user=-1; - $search_sday=''; - $search_smonth=''; - $search_syear=''; - $search_eday=''; - $search_emonth=''; - $search_eyear=''; - $toselect=''; - $search_array_options=array(); + $search_all = ""; + $search_categ = ""; + $search_project = ""; + $search_projectstatus = -1; + $search_project_ref = ""; + $search_project_title = ""; + $search_task_ref = ""; + $search_task_label = ""; + $search_task_description = ""; + $search_task_user = -1; + $search_project_user = -1; + $search_sday = ''; + $search_smonth = ''; + $search_syear = ''; + $search_eday = ''; + $search_emonth = ''; + $search_eyear = ''; + $toselect = ''; + $search_array_options = array(); } // Mass actions - $objectclass='Task'; - $objectlabel='Tasks'; + $objectclass = 'Task'; + $objectlabel = 'Tasks'; $permissiontoread = $user->rights->projet->lire; $permissiontodelete = $user->rights->projet->supprimer; $uploaddir = $conf->projet->dir_output.'/tasks'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus=1; +if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus = 1; @@ -200,21 +200,21 @@ if (empty($search_projectstatus) && $search_projectstatus == '') $search_project */ $now = dol_now(); -$form=new Form($db); -$formother=new FormOther($db); -$socstatic=new Societe($db); +$form = new Form($db); +$formother = new FormOther($db); +$socstatic = new Societe($db); $projectstatic = new Project($db); -$puser=new User($db); -$tuser=new User($db); +$puser = new User($db); +$tuser = new User($db); if ($search_project_user > 0) $puser->fetch($search_project_user); if ($search_task_user > 0) $tuser->fetch($search_task_user); -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$title=$langs->trans("Activities"); +$title = $langs->trans("Activities"); //if ($search_task_user == $user->id) $title=$langs->trans("MyActivities"); if ($id) @@ -224,115 +224,115 @@ if ($id) } // Get list of project id allowed to user (in a string list separated by coma) -if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); +if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); //var_dump($projectsListId); // Get id of types of contacts for projects (This list never contains a lot of elements) -$listofprojectcontacttype=array(); +$listofprojectcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; -$sql.= " WHERE ctc.element = '" . $projectstatic->element . "'"; -$sql.= " AND ctc.source = 'internal'"; +$sql .= " WHERE ctc.element = '".$projectstatic->element."'"; +$sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listofprojectcontacttype[$obj->rowid]=$obj->code; + $listofprojectcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); -if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found +if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found // Get id of types of contacts for tasks (This list never contains a lot of elements) -$listoftaskcontacttype=array(); +$listoftaskcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; -$sql.= " WHERE ctc.element = '" . $object->element . "'"; -$sql.= " AND ctc.source = 'internal'"; +$sql .= " WHERE ctc.element = '".$object->element."'"; +$sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listoftaskcontacttype[$obj->rowid]=$obj->code; + $listoftaskcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); -if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found +if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found -$distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is assigned only once. +$distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is assigned only once. $sql = "SELECT ".$distinct." p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.datee as projectdatee, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate, p.usage_bill_time,"; -$sql.= " s.nom as name, s.rowid as socid,"; -$sql.= " t.datec as date_creation, t.dateo as date_start, t.datee as date_end, t.tms as date_update,"; -$sql.= " t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; +$sql .= " s.nom as name, s.rowid as socid,"; +$sql .= " t.datec as date_creation, t.dateo as date_start, t.datee as date_end, t.tms as date_update,"; +$sql .= " t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; // We'll need these fields in order to filter by categ if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; // Add sum fields -if (! empty($arrayfields['t.tobill']['checked']) || ! empty($arrayfields['t.billed']['checked'])) +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { - $sql.=" , SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; + $sql .= " , SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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."projet as p"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; +$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."projet as p"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; // We'll need this table joined to the select in order to filter by categ -if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ -$sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; -if (! empty($arrayfields['t.tobill']['checked']) || ! empty($arrayfields['t.billed']['checked'])) +if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ +$sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($search_project_user > 0) $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; -if ($search_task_user > 0) $sql.=", ".MAIN_DB_PREFIX."element_contact as ect"; -$sql.= " WHERE t.fk_projet = p.rowid"; -$sql.= " AND p.entity IN (".getEntity('project').')'; -if (! $user->rights->projet->all->lire) $sql.=" AND p.rowid IN (".($projectsListId?$projectsListId:'0').")"; // public and assigned to projects, or restricted to company for external users -if (is_object($projectstatic) && $projectstatic->id > 0) $sql.=" AND p.rowid = ".$projectstatic->id; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($search_project_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp"; +if ($search_task_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect"; +$sql .= " WHERE t.fk_projet = p.rowid"; +$sql .= " AND p.entity IN (".getEntity('project').')'; +if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".($projectsListId ? $projectsListId : '0').")"; // public and assigned to projects, or restricted to company for external users +if (is_object($projectstatic) && $projectstatic->id > 0) $sql .= " AND p.rowid = ".$projectstatic->id; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser -if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; -if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; +if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +if ($search_categ > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ); +if ($search_categ == -2) $sql .= " AND cs.fk_categorie IS NULL"; if ($search_project_ref) $sql .= natural_search('p.ref', $search_project_ref); if ($search_project_title) $sql .= natural_search('p.title', $search_project_title); if ($search_task_ref) $sql .= natural_search('t.ref', $search_task_ref); if ($search_task_label) $sql .= natural_search('t.label', $search_task_label); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -$sql.= dolSqlDateFilter('t.dateo', $search_sday, $search_smonth, $search_syear); -$sql.= dolSqlDateFilter('t.datee', $search_eday, $search_emonth, $search_eyear); +$sql .= dolSqlDateFilter('t.dateo', $search_sday, $search_smonth, $search_syear); +$sql .= dolSqlDateFilter('t.datee', $search_eday, $search_emonth, $search_eyear); if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); if ($search_projectstatus >= 0) { if ($search_projectstatus == 99) $sql .= " AND p.fk_statut <> 2"; else $sql .= " AND p.fk_statut = ".$db->escape($search_projectstatus); } -if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); -if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; -if ($search_task_user > 0) $sql.= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; +if ($search_public != '') $sql .= " AND p.public = ".$db->escape($search_public); +if ($search_project_user > 0) $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; +if ($search_task_user > 0) $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -if (! empty($arrayfields['t.tobill']['checked']) || ! empty($arrayfields['t.billed']['checked'])) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { - $sql.=" GROUP BY p.rowid, p.ref, p.title, p.fk_statut, p.datee, p.fk_opp_status, p.public, p.fk_user_creat,"; - $sql.=" s.nom, s.rowid,"; - $sql.=" t.datec, t.dateo, t.datee, t.tms,"; - $sql.=" t.rowid, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; + $sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_statut, p.datee, p.fk_opp_status, p.public, p.fk_user_creat,"; + $sql .= " s.nom, s.rowid,"; + $sql .= " t.datec, t.dateo, t.datee, t.tms,"; + $sql .= " t.rowid, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; // Add fields from extrafields - if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); + if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); } } -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -346,12 +346,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); dol_syslog("list allowed project", LOG_DEBUG); $resql = $db->query($sql); -if (! $resql) +if (!$resql) { dol_print_error($db); exit; @@ -359,9 +359,9 @@ if (! $resql) $num = $db->num_rows($resql); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->id; @@ -369,48 +369,48 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && exit; } -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); -$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_sday) $param.='&search_sday='.urlencode($search_sday); -if ($search_smonth) $param.='&search_smonth='.urlencode($search_smonth); -if ($search_syear) $param.='&search_syear=' .urlencode($search_syear); -if ($search_eday) $param.='&search_eday='.urlencode($search_eday); -if ($search_emonth) $param.='&search_emonth='.urlencode($search_emonth); -if ($search_eyear) $param.='&search_eyear=' .urlencode($search_eyear); -if ($socid) $param.='&socid='.urlencode($socid); -if ($search_all != '') $param.='&search_all='.urlencode($search_all); -if ($search_project_ref != '') $param.='&search_project_ref='.urlencode($search_project_ref); -if ($search_project_title != '') $param.='&search_project_title='.urlencode($search_project_title); -if ($search_ref != '') $param.='&search_ref='.urlencode($search_ref); -if ($search_label != '') $param.='&search_label='.urlencode($search_label); -if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe); -if ($search_projectstatus != '') $param.='&search_projectstatus='.urlencode($search_projectstatus); -if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); -if ($search_public != '') $param.='&search_public='.urlencode($search_public); -if ($search_project_user != '') $param.='&search_project_user='.urlencode($search_project_user); -if ($search_task_user > 0) $param.='&search_task_user='.urlencode($search_task_user); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +$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_sday) $param .= '&search_sday='.urlencode($search_sday); +if ($search_smonth) $param .= '&search_smonth='.urlencode($search_smonth); +if ($search_syear) $param .= '&search_syear='.urlencode($search_syear); +if ($search_eday) $param .= '&search_eday='.urlencode($search_eday); +if ($search_emonth) $param .= '&search_emonth='.urlencode($search_emonth); +if ($search_eyear) $param .= '&search_eyear='.urlencode($search_eyear); +if ($socid) $param .= '&socid='.urlencode($socid); +if ($search_all != '') $param .= '&search_all='.urlencode($search_all); +if ($search_project_ref != '') $param .= '&search_project_ref='.urlencode($search_project_ref); +if ($search_project_title != '') $param .= '&search_project_title='.urlencode($search_project_title); +if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref); +if ($search_label != '') $param .= '&search_label='.urlencode($search_label); +if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); +if ($search_projectstatus != '') $param .= '&search_projectstatus='.urlencode($search_projectstatus); +if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status); +if ($search_public != '') $param .= '&search_public='.urlencode($search_public); +if ($search_project_user != '') $param .= '&search_project_user='.urlencode($search_project_user); +if ($search_task_user > 0) $param .= '&search_task_user='.urlencode($search_task_user); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( // 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->projet->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create'); } print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; @@ -425,149 +425,149 @@ print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; // Show description of content -$texthelp=''; -if ($search_task_user == $user->id) $texthelp.=$langs->trans("MyTasksDesc"); +$texthelp = ''; +if ($search_task_user == $user->id) $texthelp .= $langs->trans("MyTasksDesc"); else { - if ($user->rights->projet->all->lire && ! $socid) $texthelp.=$langs->trans("TasksOnProjectsDesc"); - else $texthelp.=$langs->trans("TasksOnProjectsPublicDesc"); + if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("TasksOnProjectsDesc"); + else $texthelp .= $langs->trans("TasksOnProjectsPublicDesc"); } print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit); -$topicmail="Information"; -$modelmail="task"; -$objecttmp=new Task($db); -$trackid='tas'.$object->id; +$topicmail = "Information"; +$modelmail = "task"; +$objecttmp = new Task($db); +$trackid = 'tas'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } $morehtmlfilter = ''; // Filter on categories -if (! empty($conf->categorie->enabled)) +if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('ProjectCategories'). ': '; - $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 'maxwidth300'); - $moreforfilter.='</div>'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ProjectCategories').': '; + $moreforfilter .= $formother->select_categories('project', $search_categ, 'search_categ', 1, 'maxwidth300'); + $moreforfilter .= '</div>'; } // If the user can view users -$moreforfilter.='<div class="divsearchfield">'; -$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ' '; -$includeonly=''; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); -$moreforfilter.='</div>'; +$moreforfilter .= '<div class="divsearchfield">'; +$moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').' '; +$includeonly = ''; +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= '</div>'; // If the user can view users -$moreforfilter.='<div class="divsearchfield">'; -$moreforfilter.=$langs->trans('TasksWithThisUserAsContact'). ': '; -$includeonly=''; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); -$moreforfilter.='</div>'; +$moreforfilter .= '<div class="divsearchfield">'; +$moreforfilter .= $langs->trans('TasksWithThisUserAsContact').': '; +$includeonly = ''; +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= '</div>'; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</div>'; } -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; -print '<table class="tagtable nobottomiftotal liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n"; +print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n"; print '<tr class="liste_titre_filter">'; -if (! empty($arrayfields['t.ref']['checked'])) +if (!empty($arrayfields['t.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'" size="4">'; print '</td>'; } -if (! empty($arrayfields['t.label']['checked'])) +if (!empty($arrayfields['t.label']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'" size="8">'; print '</td>'; } // Start date -if (! empty($arrayfields['t.dateo']['checked'])) +if (!empty($arrayfields['t.dateo']['checked'])) { print '<td class="liste_titre center minwidth150">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_sday" value="'.$search_sday.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_sday" value="'.$search_sday.'">'; print '<input class="flat" type="text" size="1" maxlength="2" name="search_smonth" value="'.$search_smonth.'">'; - $formother->select_year($search_syear?$search_syear:-1, 'search_syear', 1, 20, 5); + $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5); print '</td>'; } // End date -if (! empty($arrayfields['t.datee']['checked'])) +if (!empty($arrayfields['t.datee']['checked'])) { print '<td class="liste_titre center minwidth150">'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_eday" value="'.$search_eday.'">'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_eday" value="'.$search_eday.'">'; print '<input class="flat" type="text" size="1" maxlength="2" name="search_emonth" value="'.$search_emonth.'">'; - $formother->select_year($search_eyear?$search_eyear:-1, 'search_eyear', 1, 20, 5); + $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5); print '</td>'; } -if (! empty($arrayfields['p.ref']['checked'])) +if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_project_ref" value="'.$search_project_ref.'" size="4">'; print '</td>'; } -if (! empty($arrayfields['p.title']['checked'])) +if (!empty($arrayfields['p.title']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_project_title" value="'.$search_project_title.'" size="6">'; print '</td>'; } -if (! empty($arrayfields['s.nom']['checked'])) +if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre">'; print '<input type="text" class="flat" name="search_societe" value="'.dol_escape_htmltag($search_societe).'" size="4">'; print '</td>'; } -if (! empty($arrayfields['p.fk_statut']['checked'])) +if (!empty($arrayfields['p.fk_statut']['checked'])) { print '<td class="liste_titre center">'; $arrayofstatus = array(); - foreach($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val); - $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')'; + foreach ($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key] = $langs->trans($val); + $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')'; print $form->selectarray('search_projectstatus', $arrayofstatus, $search_projectstatus, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); print '</td>'; } -if (! empty($arrayfields['t.planned_workload']['checked'])) print '<td class="liste_titre"></td>'; -if (! empty($arrayfields['t.duration_effective']['checked'])) print '<td class="liste_titre"></td>'; -if (! empty($arrayfields['t.progress_calculated']['checked'])) print '<td class="liste_titre"></td>'; -if (! empty($arrayfields['t.progress']['checked'])) print '<td class="liste_titre"></td>'; -if (! empty($arrayfields['t.progress_summary']['checked'])) print '<td class="liste_titre"></td>'; -if (! empty($arrayfields['t.tobill']['checked'])) print '<td class="liste_titre"></td>'; -if (! empty($arrayfields['t.billed']['checked'])) print '<td class="liste_titre"></td>'; +if (!empty($arrayfields['t.planned_workload']['checked'])) print '<td class="liste_titre"></td>'; +if (!empty($arrayfields['t.duration_effective']['checked'])) print '<td class="liste_titre"></td>'; +if (!empty($arrayfields['t.progress_calculated']['checked'])) print '<td class="liste_titre"></td>'; +if (!empty($arrayfields['t.progress']['checked'])) print '<td class="liste_titre"></td>'; +if (!empty($arrayfields['t.progress_summary']['checked'])) print '<td class="liste_titre"></td>'; +if (!empty($arrayfields['t.tobill']['checked'])) print '<td class="liste_titre"></td>'; +if (!empty($arrayfields['t.billed']['checked'])) print '<td class="liste_titre"></td>'; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['t.datec']['checked'])) +if (!empty($arrayfields['t.datec']['checked'])) { // Date creation print '<td class="liste_titre">'; print '</td>'; } -if (! empty($arrayfields['t.tms']['checked'])) +if (!empty($arrayfields['t.tms']['checked'])) { // Date modification print '<td class="liste_titre">'; @@ -575,46 +575,46 @@ if (! empty($arrayfields['t.tms']['checked'])) } // Action column print '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; -if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "t.label", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $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, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); -if (! empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.progress_summary']['checked'])) print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.tobill']['checked'])) print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.billed']['checked'])) print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "t.label", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $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, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); +if (!empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.progress_summary']['checked'])) print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.tobill']['checked'])) print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.billed']['checked'])) print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$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 +$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; -if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; -$plannedworkloadoutputformat='allhourmin'; -$timespentoutputformat='allhourmin'; -if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; -if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; +$plannedworkloadoutputformat = 'allhourmin'; +$timespentoutputformat = 'allhourmin'; +if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; +if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -624,10 +624,10 @@ while ($i < min($num, $limit)) $object->label = $obj->label; $object->fk_statut = $obj->fk_statut; $object->progress = $obj->progress; - $object->datee = $db->jdate($obj->date_end); // deprecated + $object->datee = $db->jdate($obj->date_end); // deprecated $object->date_end = $db->jdate($obj->date_end); - $object->planned_workload= $obj->planned_workload; - $object->duration_effective= $obj->duration_effective; + $object->planned_workload = $obj->planned_workload; + $object->duration_effective = $obj->duration_effective; $projectstatic->id = $obj->projectid; @@ -637,69 +637,69 @@ while ($i < min($num, $limit)) $projectstatic->statut = $obj->projectstatus; $projectstatic->datee = $db->jdate($obj->projectdatee); - $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? + $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? if ($userAccess >= 0) { print '<tr data-rowid="'.$object->id.'" class="oddeven">'; // Ref - if (! empty($arrayfields['t.ref']['checked'])) + if (!empty($arrayfields['t.ref']['checked'])) { print '<td class="nowraponall">'; print $object->getNomUrl(1, 'withproject'); if ($object->hasDelay()) print img_warning("Late"); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Label - if (! empty($arrayfields['t.label']['checked'])) + if (!empty($arrayfields['t.label']['checked'])) { print '<td>'; print $object->label; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date start - if (! empty($arrayfields['t.dateo']['checked'])) + if (!empty($arrayfields['t.dateo']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_start), 'day'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date end - if (! empty($arrayfields['t.datee']['checked'])) + if (!empty($arrayfields['t.datee']['checked'])) { print '<td class="center">'; print dol_print_date($db->jdate($obj->date_end), 'day'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="nowrap">'; print $projectstatic->getNomUrl(1, 'task'); if ($projectstatic->hasDelay()) print img_warning("Late"); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project title - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print '<td>'; print dol_trunc($obj->projecttitle, 80); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td>'; if ($obj->socid) { - $socstatic->id=$obj->socid; - $socstatic->name=$obj->name; + $socstatic->id = $obj->socid; + $socstatic->name = $obj->name; print $socstatic->getNomUrl(1); } else @@ -707,23 +707,23 @@ while ($i < min($num, $limit)) print ' '; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project status - if (! empty($arrayfields['p.fk_statut']['checked'])) + if (!empty($arrayfields['p.fk_statut']['checked'])) { print '<td class="center">'; print $projectstatic->getLibStatut(1); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Planned workload - if (! empty($arrayfields['t.planned_workload']['checked'])) + if (!empty($arrayfields['t.planned_workload']['checked'])) { print '<td class="center">'; - $fullhour=convertSecondToTime($obj->planned_workload, $plannedworkloadoutputformat); - $workingdelay=convertSecondToTime($obj->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks + $fullhour = convertSecondToTime($obj->planned_workload, $plannedworkloadoutputformat); + $workingdelay = convertSecondToTime($obj->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks if ($obj->planned_workload != '') { print $fullhour; @@ -766,11 +766,11 @@ while ($i < min($num, $limit)) else print $form->textwithpicto('', $langs->trans('WorkloadNotDefined'), 1, 'help'); } print '</td>'; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalprogress_calculatedfield']=$totalarray['nbfield']; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['totalprogress_calculatedfield'] = $totalarray['nbfield']; } // Declared progress - if (! empty($arrayfields['t.progress']['checked'])) + if (!empty($arrayfields['t.progress']['checked'])) { print '<td class="center">'; if ($obj->progress != '') @@ -865,12 +865,12 @@ while ($i < min($num, $limit)) print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->id, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->id, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "</tr>\n"; @@ -885,7 +885,7 @@ if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['tota || isset($totalarray['totaltobill']) || isset($totalarray['totalbilled'])) { print '<tr class="liste_total">'; - $i=0; + $i = 0; while ($i < $totalarray['nbfield']) { $i++; @@ -907,8 +907,8 @@ if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['tota $db->free($resql); -$parameters=array('sql' => $sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('sql' => $sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "</table>"; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 5a93b888192..afd4c89aab5 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -41,12 +41,12 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; $langs->loadLangs(array("companies", "commercial", "customers", "suppliers", "bills", "compta", "categories", "cashdesk")); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'thirdpartylist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartylist'; if ($contextpage == 'poslist') { @@ -55,71 +55,71 @@ if ($contextpage == 'poslist') // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'societe', $socid, ''); -$search_all=trim(GETPOST('search_all', 'alphanohtml')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_cti=preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars +$search_all = trim(GETPOST('search_all', 'alphanohtml') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$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", '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')); -$search_country=GETPOST("search_country", 'intcomma'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_staff=GETPOST("search_staff", 'int'); -$search_status=GETPOST("search_status", 'int'); -$search_type=GETPOST('search_type', 'alpha'); -$search_level = GETPOST("search_level", "array"); -$search_stcomm=GETPOST('search_stcomm', 'int'); +$search_id = trim(GETPOST("search_id", "int")); +$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')); +$search_country = GETPOST("search_country", 'intcomma'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_staff = GETPOST("search_staff", 'int'); +$search_status = GETPOST("search_status", 'int'); +$search_type = GETPOST('search_type', 'alpha'); +$search_level = GETPOST("search_level", "array"); +$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_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $search_parent_name = GETPOST('search_parent_name', 'alpha'); -$type=GETPOST('type', 'alpha'); -$optioncss=GETPOST('optioncss', 'alpha'); -$mode=GETPOST("mode", 'alpha'); +$type = GETPOST('type', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST("mode", 'alpha'); -$diroutputmassaction=$conf->societe->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->societe->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$sortfield=GETPOST("sortfield", 'alpha'); -$sortorder=GETPOST("sortorder", 'alpha'); -$page=GETPOST("page", 'int'); -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="s.nom"; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "s.nom"; if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='customerlist'; if ($search_type=='') $search_type='1,3'; } -if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='prospectlist'; if ($search_type=='') $search_type='2,3'; } -if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='supplierlist'; if ($search_type=='') $search_type='4'; } +if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'customerlist'; if ($search_type == '') $search_type = '1,3'; } +if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'prospectlist'; if ($search_type == '') $search_type = '2,3'; } +if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'supplierlist'; if ($search_type == '') $search_type = '4'; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Societe($db); @@ -129,7 +129,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -148,40 +148,40 @@ $fieldstosearchall = array( 's.phone'=>"Phone", 's.fax'=>"Fax", ); -if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4']='ProfId4'; -if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5']='ProfId5'; -if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6']='ProfId6'; -if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode']='Gencod'; +if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4'] = 'ProfId4'; +if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5'] = 'ProfId5'; +if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6'] = 'ProfId6'; +if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode'] = 'Gencod'; // Personalized search criterias. Example: $conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS = 's.nom=ThirdPartyName;s.name_alias=AliasNameShort;s.code_client=CustomerCode' -if (! empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall=dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS); +if (!empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall = dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS); // Define list of fields to show into list -$checkedcustomercode=(in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? 1 : 0); -$checkedsuppliercode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); -$checkedcustomeraccountcode=(in_array($contextpage, array('customerlist')) ? 1 : 0); -$checkedsupplieraccountcode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); -$checkedtypetiers=1; -$checkedprofid1=0; -$checkedprofid2=0; -$checkedprofid3=0; -$checkedprofid4=0; -$checkedprofid5=0; -$checkedprofid6=0; +$checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? 1 : 0); +$checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); +$checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? 1 : 0); +$checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); +$checkedtypetiers = 1; +$checkedprofid1 = 0; +$checkedprofid2 = 0; +$checkedprofid3 = 0; +$checkedprofid4 = 0; +$checkedprofid5 = 0; +$checkedprofid6 = 0; //$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0); //$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0); //$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0); -$checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0); -$checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0); -$arrayfields=array( - 's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)), +$checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? 1 : 0); +$checkstcomm = (in_array($contextpage, array('prospectlist')) ? 1 : 0); +$arrayfields = array( + 's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0)), 's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1), - 's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), + 's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(!empty($conf->barcode->enabled))), 's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>$checkedcustomercode), - 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))), + 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(!empty($conf->fournisseur->enabled))), 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'checked'=>$checkedcustomeraccountcode), - 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))), + 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(!empty($conf->fournisseur->enabled))), 's.town'=>array('label'=>"Town", 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'checked'=>1), 'state.nom'=>array('label'=>"State", 'checked'=>0), @@ -212,10 +212,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -226,19 +226,19 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if ($action=="change") // Change customer for TakePOS +if ($action == "change") // Change customer for TakePOS { $idcustomer = GETPOST('idcustomer', 'int'); - $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant + $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant // @TODO Check if draft invoice already exists, if not create it or return a warning to ask to enter at least one line to have it created automatically - $sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); ?> <script> - parent.$("#poslines").load("invoice.php?place="+<?php print $place;?>, function() { + parent.$("#poslines").load("invoice.php?place="+<?php print $place; ?>, function() { //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight); - <?php if (! $resql) { ?> + <?php if (!$resql) { ?> alert('Error failed to update customer on draft invoice.'); <?php } ?> parent.$.colorbox.close(); /* Close the popup */ @@ -248,11 +248,11 @@ if ($action=="change") // Change customer for TakePOS exit; } -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -263,47 +263,47 @@ if (empty($reshook)) // Did we click on 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=''; - $search_nom=''; - $search_alias=''; - $search_categ_cus=0; - $search_categ_sup=0; - $search_sale=''; - $search_barcode=""; - $search_customer_code=''; - $search_supplier_code=''; - $search_account_customer_code=''; - $search_account_supplier_code=''; - $search_town=""; - $search_zip=""; - $search_state=""; - $search_country=''; - $search_email=''; - $search_phone=''; - $search_fax=''; - $search_url=''; - $search_idprof1=''; - $search_idprof2=''; - $search_idprof3=''; - $search_idprof4=''; - $search_idprof5=''; - $search_idprof6=''; - $search_vat=''; - $search_type=''; - $search_type_thirdparty=''; - $search_staff=''; - $search_status=-1; - $search_stcomm=''; - $search_level=''; - $search_parent_name=''; - $search_import_key=''; - $toselect=''; - $search_array_options=array(); + $search_id = ''; + $search_nom = ''; + $search_alias = ''; + $search_categ_cus = 0; + $search_categ_sup = 0; + $search_sale = ''; + $search_barcode = ""; + $search_customer_code = ''; + $search_supplier_code = ''; + $search_account_customer_code = ''; + $search_account_supplier_code = ''; + $search_town = ""; + $search_zip = ""; + $search_state = ""; + $search_country = ''; + $search_email = ''; + $search_phone = ''; + $search_fax = ''; + $search_url = ''; + $search_idprof1 = ''; + $search_idprof2 = ''; + $search_idprof3 = ''; + $search_idprof4 = ''; + $search_idprof5 = ''; + $search_idprof6 = ''; + $search_vat = ''; + $search_type = ''; + $search_type_thirdparty = ''; + $search_staff = ''; + $search_status = -1; + $search_stcomm = ''; + $search_level = ''; + $search_parent_name = ''; + $search_import_key = ''; + $toselect = ''; + $search_array_options = array(); } // Mass actions - $objectclass='Societe'; - $objectlabel='ThirdParty'; + $objectclass = 'Societe'; + $objectlabel = 'ThirdParty'; $permissiontoread = $user->rights->societe->lire; $permissiontodelete = $user->rights->societe->supprimer; $uploaddir = $conf->societe->dir_output; @@ -312,16 +312,16 @@ if (empty($reshook)) if ($action == 'setstcomm') { $object = new Client($db); - $result=$object->fetch(GETPOST('stcommsocid')); - $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); - $result=$object->update($object->id, $user); + $result = $object->fetch(GETPOST('stcommsocid')); + $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); + $result = $object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } -if ($search_status=='') $search_status=1; // always display active thirdparty first +if ($search_status == '') $search_status = 1; // always display active thirdparty first @@ -485,10 +485,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if (! $resql) +if (!$resql) { dol_print_error($db); exit; @@ -496,9 +496,9 @@ if (! $resql) $num = $db->num_rows($resql); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') { +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') { $obj = $db->fetch_object($resql); $id = $obj->rowid; if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) { @@ -516,49 +516,49 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && exit; } -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $langs->trans("ThirdParty"), $help_url); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +$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_all != '') $param = "&sall=".urlencode($search_all); -if ($sall != '') $param.= "&sall=".urlencode($sall); -if ($search_categ_cus > 0) $param.= '&search_categ_cus='.urlencode($search_categ_cus); -if ($search_categ_sup > 0) $param.= '&search_categ_sup='.urlencode($search_categ_sup); -if ($search_sale > 0) $param.= '&search_sale='.urlencode($search_sale); -if ($search_id > 0) $param.= "&search_id=".urlencode($search_id); -if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom); -if ($search_alias != '') $param.= "&search_alias=".urlencode($search_alias); -if ($search_town != '') $param.= "&search_town=".urlencode($search_town); -if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); -if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone); -if ($search_fax != '') $param.= "&search_fax=".urlencode($search_fax); -if ($search_email != '') $param.= "&search_email=".urlencode($search_email); -if ($search_url != '') $param.= "&search_url=".urlencode($search_url); -if ($search_state != '') $param.= "&search_state=".urlencode($search_state); -if ($search_country != '') $param.= "&search_country=".urlencode($search_country); -if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code); -if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code); -if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code); -if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code); -if ($search_barcode != '') $param.= "&search_barcode=".urlencode($search_barcode); -if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1); -if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2); -if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3); -if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4); -if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5); -if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6); -if ($search_vat != '') $param.= '&search_vat='.urlencode($search_vat); -if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty); -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_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); +if ($sall != '') $param .= "&sall=".urlencode($sall); +if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); +if ($search_categ_sup > 0) $param .= '&search_categ_sup='.urlencode($search_categ_sup); +if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); +if ($search_id > 0) $param .= "&search_id=".urlencode($search_id); +if ($search_nom != '') $param .= "&search_nom=".urlencode($search_nom); +if ($search_alias != '') $param .= "&search_alias=".urlencode($search_alias); +if ($search_town != '') $param .= "&search_town=".urlencode($search_town); +if ($search_zip != '') $param .= "&search_zip=".urlencode($search_zip); +if ($search_phone != '') $param .= "&search_phone=".urlencode($search_phone); +if ($search_fax != '') $param .= "&search_fax=".urlencode($search_fax); +if ($search_email != '') $param .= "&search_email=".urlencode($search_email); +if ($search_url != '') $param .= "&search_url=".urlencode($search_url); +if ($search_state != '') $param .= "&search_state=".urlencode($search_state); +if ($search_country != '') $param .= "&search_country=".urlencode($search_country); +if ($search_customer_code != '') $param .= "&search_customer_code=".urlencode($search_customer_code); +if ($search_supplier_code != '') $param .= "&search_supplier_code=".urlencode($search_supplier_code); +if ($search_account_customer_code != '') $param .= "&search_account_customer_code=".urlencode($search_account_customer_code); +if ($search_account_supplier_code != '') $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code); +if ($search_barcode != '') $param .= "&search_barcode=".urlencode($search_barcode); +if ($search_idprof1 != '') $param .= '&search_idprof1='.urlencode($search_idprof1); +if ($search_idprof2 != '') $param .= '&search_idprof2='.urlencode($search_idprof2); +if ($search_idprof3 != '') $param .= '&search_idprof3='.urlencode($search_idprof3); +if ($search_idprof4 != '') $param .= '&search_idprof4='.urlencode($search_idprof4); +if ($search_idprof5 != '') $param .= '&search_idprof5='.urlencode($search_idprof5); +if ($search_idprof6 != '') $param .= '&search_idprof6='.urlencode($search_idprof6); +if ($search_vat != '') $param .= '&search_vat='.urlencode($search_vat); +if ($search_type_thirdparty != '') $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); +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_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); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -569,30 +569,30 @@ if (GETPOST('delsoc')) } // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->societe->creer && $contextpage != 'poslist') { - $typefilter=''; - $label='MenuNewThirdParty'; + $typefilter = ''; + $label = 'MenuNewThirdParty'; - if(! empty($type)) + if (!empty($type)) { $typefilter = '&type='.$type; - if($type == 'p') $label='MenuNewProspect'; - if($type == 'c') $label='MenuNewCustomer'; - if($type == 'f') $label='NewSupplier'; + if ($type == 'p') $label = 'MenuNewProspect'; + if ($type == 'c') $label = 'MenuNewCustomer'; + if ($type == 'f') $label = 'NewSupplier'; } - $newcardbutton.= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter); + $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter); } print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">'; @@ -867,7 +867,7 @@ if (! empty($arrayfields['s.tva_intra']['checked'])) } // Type (customer/prospect/supplier) -if (! empty($arrayfields['customerorsupplier']['checked'])) +if (!empty($arrayfields['customerorsupplier']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone center">'; if ($type != '') print '<input type="hidden" name="type" value="'.$type.'">'; @@ -875,25 +875,25 @@ if (! empty($arrayfields['customerorsupplier']['checked'])) print '</select></td>'; } // Prospect level -if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) +if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { print '<td class="liste_titre center">'; print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2); print '</td>'; } // Prospect status -if (! empty($arrayfields['s.fk_stcomm']['checked'])) +if (!empty($arrayfields['s.fk_stcomm']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone center">'; - $arraystcomm=array(); - foreach($prospectstatic->cacheprospectstatus as $key => $val) + $arraystcomm = array(); + foreach ($prospectstatic->cacheprospectstatus as $key => $val) { - $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); + $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); } print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2); print '</td>'; } -if (! empty($arrayfields['s2.nom']['checked'])) +if (!empty($arrayfields['s2.nom']['checked'])) { print '<td class="liste_titre center">'; print '<input class="flat searchstring maxwidth75imp" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).'">'; @@ -903,29 +903,29 @@ if (! empty($arrayfields['s2.nom']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (! empty($arrayfields['s.datec']['checked'])) +if (!empty($arrayfields['s.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification -if (! empty($arrayfields['s.tms']['checked'])) +if (!empty($arrayfields['s.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status -if (! empty($arrayfields['s.status']['checked'])) +if (!empty($arrayfields['s.status']['checked'])) { print '<td class="liste_titre center minwidth75imp">'; - print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1); + print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 1); print '</td>'; } -if (! empty($arrayfields['s.import_key']['checked'])) +if (!empty($arrayfields['s.import_key']['checked'])) { print '<td class="liste_titre center">'; print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">'; @@ -933,101 +933,101 @@ if (! empty($arrayfields['s.import_key']['checked'])) } // Action column print '<td class="liste_titre right">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; -if (! empty($arrayfields['s.rowid']['checked'])) print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder); -if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['staff.code']['checked'])) print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['s.fax']['checked'])) print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['s.url']['checked'])) print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 0), $_SERVER["PHP_SELF"], "s.siren", "", $param, '', $sortfield, $sortorder, 'nowrap '); -if (! empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 0), $_SERVER["PHP_SELF"], "s.siret", "", $param, '', $sortfield, $sortorder, 'nowrap '); -if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 0), $_SERVER["PHP_SELF"], "s.ape", "", $param, '', $sortfield, $sortorder, 'nowrap '); -if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, '', $sortfield, $sortorder, 'nowrap '); -if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, '', $sortfield, $sortorder, 'nowrap '); -if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, '', $sortfield, $sortorder, 'nowrap '); -if (! empty($arrayfields['s.tva_intra']['checked'])) print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'nowrap '); -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, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['s2.nom']['checked'])) print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['s.rowid']['checked'])) print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder); +if (!empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['staff.code']['checked'])) print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.fax']['checked'])) print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.url']['checked'])) print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 0), $_SERVER["PHP_SELF"], "s.siren", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 0), $_SERVER["PHP_SELF"], "s.siret", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 0), $_SERVER["PHP_SELF"], "s.ape", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.tva_intra']['checked'])) print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'nowrap '); +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, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['s2.nom']['checked'])) print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$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 +$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; -if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['s.import_key']['checked'])) print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['s.import_key']['checked'])) print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "</tr>\n"; $i = 0; -$totalarray=array(); +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $companystatic->id=$obj->rowid; - $companystatic->name=$obj->name; - $companystatic->name_alias=$obj->name_alias; - $companystatic->logo=$obj->logo; - $companystatic->canvas=$obj->canvas; - $companystatic->client=$obj->client; - $companystatic->status=$obj->status; - $companystatic->email=$obj->email; - $companystatic->fournisseur=$obj->fournisseur; - $companystatic->code_client=$obj->code_client; - $companystatic->code_fournisseur=$obj->code_fournisseur; - $companystatic->tva_intra=$obj->tva_intra; - $companystatic->country_code=$obj->country_code; + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->name_alias = $obj->name_alias; + $companystatic->logo = $obj->logo; + $companystatic->canvas = $obj->canvas; + $companystatic->client = $obj->client; + $companystatic->status = $obj->status; + $companystatic->email = $obj->email; + $companystatic->fournisseur = $obj->fournisseur; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->tva_intra = $obj->tva_intra; + $companystatic->country_code = $obj->country_code; - $companystatic->code_compta_client=$obj->code_compta; - $companystatic->code_compta_fournisseur=$obj->code_compta_fournisseur; + $companystatic->code_compta_client = $obj->code_compta; + $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; - $companystatic->fk_prospectlevel=$obj->fk_prospectlevel; + $companystatic->fk_prospectlevel = $obj->fk_prospectlevel; $companystatic->fk_parent = $obj->fk_parent; print '<tr class="oddeven"'; if ($contextpage == 'poslist') { - $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant + $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant print ' onclick="location.href=\'list.php?action=change&contextpage=poslist&idcustomer='.$obj->rowid.'&place='.$place.'\'"'; } print '>'; - if (! empty($arrayfields['s.rowid']['checked'])) + if (!empty($arrayfields['s.rowid']['checked'])) { print '<td class="tdoverflowmax50">'; print $obj->rowid; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { $savalias = $obj->name_alias; - if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias=''; + if (!empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias = ''; print '<td class="tdoverflowmax200">'; if ($contextpage == 'poslist') { @@ -1039,213 +1039,213 @@ while ($i < min($num, $limit)) } print "</td>\n"; $companystatic->name_alias = $savalias; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.name_alias']['checked'])) + if (!empty($arrayfields['s.name_alias']['checked'])) { print '<td class="tdoverflowmax200">'; print $companystatic->name_alias; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Barcode - if (! empty($arrayfields['s.barcode']['checked'])) + if (!empty($arrayfields['s.barcode']['checked'])) { print '<td>'.$obj->barcode.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Customer code - if (! empty($arrayfields['s.code_client']['checked'])) + if (!empty($arrayfields['s.code_client']['checked'])) { print '<td class="nowraponall">'.$obj->code_client.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Supplier code - if (! empty($arrayfields['s.code_fournisseur']['checked'])) + if (!empty($arrayfields['s.code_fournisseur']['checked'])) { print '<td class="nowraponall">'.$obj->code_fournisseur.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account customer code - if (! empty($arrayfields['s.code_compta']['checked'])) + if (!empty($arrayfields['s.code_compta']['checked'])) { print '<td>'.$obj->code_compta.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account supplier code - if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) + if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { print '<td>'.$obj->code_compta_fournisseur.'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['s.town']['checked'])) + if (!empty($arrayfields['s.town']['checked'])) { print "<td>".$obj->town."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['s.zip']['checked'])) + if (!empty($arrayfields['s.zip']['checked'])) { print "<td>".$obj->zip."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "<td>".$obj->state_name."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Region - if (! empty($arrayfields['region.nom']['checked'])) + if (!empty($arrayfields['region.nom']['checked'])) { print "<td>".$obj->region_name."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="center">'; - $labelcountry=($obj->country_code && ($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code))?$langs->trans("Country".$obj->country_code):$obj->country_label; + $labelcountry = ($obj->country_code && ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code)) ? $langs->trans("Country".$obj->country_code) : $obj->country_label; print $labelcountry; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="center">'; - if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + if (!is_array($typenArray) || count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Staff - if (! empty($arrayfields['staff.code']['checked'])) + if (!empty($arrayfields['staff.code']['checked'])) { print '<td class="center">'; - if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1); + if (!is_array($staffArray) || count($staffArray) == 0) $staffArray = $formcompany->effectif_array(1); print $staffArray[$obj->staff_code]; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.email']['checked'])) + if (!empty($arrayfields['s.email']['checked'])) { print "<td>".$obj->email."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.phone']['checked'])) + if (!empty($arrayfields['s.phone']['checked'])) { print "<td>".dol_print_phone($obj->phone, $obj->country_code, 0, $obj->rowid)."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.fax']['checked'])) + if (!empty($arrayfields['s.fax']['checked'])) { print "<td>".dol_print_phone($obj->fax, $obj->country_code, 0, $obj->rowid)."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.url']['checked'])) + if (!empty($arrayfields['s.url']['checked'])) { print "<td>".$obj->url."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.siren']['checked'])) + if (!empty($arrayfields['s.siren']['checked'])) { print "<td>".$obj->idprof1."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.siret']['checked'])) + if (!empty($arrayfields['s.siret']['checked'])) { print "<td>".$obj->idprof2."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.ape']['checked'])) + if (!empty($arrayfields['s.ape']['checked'])) { print "<td>".$obj->idprof3."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.idprof4']['checked'])) + if (!empty($arrayfields['s.idprof4']['checked'])) { print "<td>".$obj->idprof4."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.idprof5']['checked'])) + if (!empty($arrayfields['s.idprof5']['checked'])) { print "<td>".$obj->idprof5."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.idprof6']['checked'])) + if (!empty($arrayfields['s.idprof6']['checked'])) { print "<td>".$obj->idprof6."</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.tva_intra']['checked'])) + if (!empty($arrayfields['s.tva_intra']['checked'])) { print "<td>"; print $obj->tva_intra; - if ($obj->tva_intra && ! isValidVATID($companystatic)) + if ($obj->tva_intra && !isValidVATID($companystatic)) { print img_warning("BadVATNumber", '', ''); } print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type - if (! empty($arrayfields['customerorsupplier']['checked'])) + if (!empty($arrayfields['customerorsupplier']['checked'])) { print '<td class="center">'; - $s=''; - if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + $s = ''; + if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $companystatic->name=$langs->trans("Customer"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0, 'customer', 0, 1); + $companystatic->name = $langs->trans("Customer"); + $companystatic->name_alias = ''; + $s .= $companystatic->getNomUrl(0, 'customer', 0, 1); } - if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) + if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - if ($s) $s.=" / "; - $companystatic->name=$langs->trans("Prospect"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0, 'prospect', 0, 1); + if ($s) $s .= " / "; + $companystatic->name = $langs->trans("Prospect"); + $companystatic->name_alias = ''; + $s .= $companystatic->getNomUrl(0, 'prospect', 0, 1); } - if ((! empty($conf->fournisseur->enabled) || ! empty($conf->supplier_proposal->enabled)) && $obj->fournisseur) + if ((!empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) && $obj->fournisseur) { - if ($s) $s.=" / "; - $companystatic->name=$langs->trans("Supplier"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0, 'supplier', 0, 1); + if ($s) $s .= " / "; + $companystatic->name = $langs->trans("Supplier"); + $companystatic->name_alias = ''; + $s .= $companystatic->getNomUrl(0, 'supplier', 0, 1); } print $s; print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) + if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { // Prospect level print '<td class="center">'; print $companystatic->getLibProspLevel(); print "</td>"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.fk_stcomm']['checked'])) + if (!empty($arrayfields['s.fk_stcomm']['checked'])) { // Prospect status print '<td class="center nowrap"><div class="nowrap">'; print '<div class="inline-block">'.$companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']); print '</div> - <div class="inline-block">'; - foreach($prospectstatic->cacheprospectstatus as $key => $val) + foreach ($prospectstatic->cacheprospectstatus as $key => $val) { - $titlealt='default'; - if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label']; - if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page?'&page='.urlencode($page):'').'">'.img_action($titlealt, $val['code']).'</a>'; + $titlealt = 'default'; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; + if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page ? '&page='.urlencode($page) : '').'">'.img_action($titlealt, $val['code']).'</a>'; } print '</div></div></td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Parent company - if (! empty($arrayfields['s2.nom']['checked'])) + if (!empty($arrayfields['s2.nom']['checked'])) { print '<td class="center">'; if ($companystatic->fk_parent > 0) @@ -1254,54 +1254,54 @@ while ($i < min($num, $limit)) print $companyparent->getNomUrl(1); } print "</td>"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['s.datec']['checked'])) + if (!empty($arrayfields['s.datec']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['s.tms']['checked'])) + if (!empty($arrayfields['s.tms']['checked'])) { print '<td class="center nowrap">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['s.status']['checked'])) + if (!empty($arrayfields['s.status']['checked'])) { print '<td class="center nowrap">'.$companystatic->getLibStatut(5).'</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.import_key']['checked'])) + if (!empty($arrayfields['s.import_key']['checked'])) { print '<td class="tdoverflowmax100">'; print $obj->import_key; print "</td>\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print '<td class="nowrap center">'; if (($massactionbutton || $massaction) && $contextpage != 'poslist') // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'."\n"; $i++; @@ -1309,8 +1309,8 @@ while ($i < min($num, $limit)) $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "</table>"; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 43387d9d8c2..1d12ea9d304 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -35,22 +35,22 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -$langs->loadLangs(array("companies","website")); +$langs->loadLangs(array("companies", "website")); -$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $show_files = GETPOST('show_files', 'int'); -$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') +$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_status=GETPOST('search_status'); +$search_status = GETPOST('search_status'); // Security check -$id = GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +$id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'societe', $socid, '&societe'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -58,53 +58,53 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='t.login'; -if (! $sortorder) $sortorder='ASC'; +if (!$sortfield) $sortfield = 't.login'; +if (!$sortorder) $sortorder = 'ASC'; // Initialize technical objects -$object=new Societe($db); -$objectwebsiteaccount=new SocieteAccount($db); +$object = new Societe($db); +$objectwebsiteaccount = new SocieteAccount($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('websitethirdpartylist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->website->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('websitethirdpartylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($objectwebsiteaccount->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($objectwebsiteaccount->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($objectwebsiteaccount->table_element, '', 'search_'); -unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty +unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($objectwebsiteaccount->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($objectwebsiteaccount->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($objectwebsiteaccount->fields as $key => $val) +foreach ($objectwebsiteaccount->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($objectwebsiteaccount->fields as $key => $val) +$arrayfields = array(); +foreach ($objectwebsiteaccount->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']); } // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -121,14 +121,14 @@ if ($id > 0) * Actions */ -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid); +$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)) { // Cancel - if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -138,24 +138,24 @@ if (empty($reshook)) 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 + 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 { - foreach($objectwebsiteaccount->fields as $key => $val) + foreach ($objectwebsiteaccount->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='WebsiteAccount'; - $objectlabel='WebsiteAccount'; + $objectclass = 'WebsiteAccount'; + $objectlabel = 'WebsiteAccount'; $permissiontoread = $user->rights->societe->lire; $permissiontodelete = $user->rights->societe->supprimer; $uploaddir = $conf->societe->dir_output; @@ -177,15 +177,15 @@ $langs->load("companies"); $title = $langs->trans("WebsiteAccounts"); llxHeader('', $title); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($id > 0) $param.='&id='.urlencode($id); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($id > 0) $param .= '&id='.urlencode($id); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -193,7 +193,7 @@ $head = societe_prepare_head($object); dol_fiche_head($head, 'website', $langs->trans("ThirdParty"), - 1, 'company'); -$linkback = '<a href="' . DOL_URL_ROOT . '/societe/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; +$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); @@ -204,26 +204,26 @@ print '<div class="underbanner clearboth"></div>'; print '<table class="border centpercent">'; // Prefix -if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field +if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { - print '<tr><td class="titlefield">' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>'; + print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; } if ($object->client) { print '<tr><td class="titlefield">'; - print $langs->trans('CustomerCode') . '</td><td colspan="3">'; + print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $object->code_client; if ($object->check_codeclient() != 0) - print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>'; + print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; print '</td></tr>'; } if ($object->fournisseur) { print '<tr><td class="titlefield">'; - print $langs->trans('SupplierCode') . '</td><td colspan="3">'; + print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $object->code_fournisseur; if ($object->check_codefournisseur() != 0) - print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>'; + print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; print '</td></tr>'; } @@ -234,11 +234,11 @@ print '</div>'; dol_fiche_end(); $newcardbutton = ''; -if (! empty($conf->website->enabled)) { - if (! empty($user->rights->societe->lire)) { - $newcardbutton.= dolGetButtonTitle($langs->trans("AddWebsiteAccount"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id)); +if (!empty($conf->website->enabled)) { + if (!empty($user->rights->societe->lire)) { + $newcardbutton .= dolGetButtonTitle($langs->trans("AddWebsiteAccount"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id)); } else { - $newcardbutton.= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', 0); + $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', 0); } } @@ -249,35 +249,35 @@ print '<br>'; // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($objectwebsiteaccount->fields as $key => $val) +foreach ($objectwebsiteaccount->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX."societe_account as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('societeaccount').")"; -else $sql.=" WHERE 1 = 1"; -$sql.=" AND fk_soc = ".$object->id; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX."societe_account as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('societeaccount').")"; +else $sql .= " WHERE 1 = 1"; +$sql .= " AND fk_soc = ".$object->id; +foreach ($search as $key => $val) { - $mode_search=(($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -294,7 +294,7 @@ $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // $sql.=$hookmanager->resPrint; */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -309,10 +309,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); -if (! $resql) +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); exit; @@ -320,16 +320,16 @@ if (! $resql) $num = $db->num_rows($resql); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -344,10 +344,10 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit); -$topicmail="Information"; -$modelmail="societeaccount"; -$objecttmp=new SocieteAccount($db); -$trackid='thi'.$object->id; +$topicmail = "Information"; +$modelmail = "societeaccount"; +$objecttmp = new SocieteAccount($db); +$trackid = 'thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; /*if ($sall) @@ -361,46 +361,46 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $objectwebsiteaccount may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($objectwebsiteaccount->fields as $key => $val) +foreach ($objectwebsiteaccount->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ' nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -409,60 +409,60 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($objectwebsiteaccount->fields as $key => $val) +foreach ($objectwebsiteaccount->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; + if (in_array($val['type'], array('timestamp'))) $align .= 'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; } // Extra fields // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ')."\n"; print '</tr>'."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $objectwebsiteaccount->id = $obj->rowid; - foreach($objectwebsiteaccount->fields as $key => $val) + foreach ($objectwebsiteaccount->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print '<tr class="oddeven">'; - foreach($objectwebsiteaccount->fields as $key => $val) + foreach ($objectwebsiteaccount->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; + if (in_array($val['type'], array('timestamp'))) $align .= 'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'; if ($align) print ' class="'.$align.'"'; @@ -470,10 +470,10 @@ while ($i < min($num, $limit)) if ($key == 'login') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1); else print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, ''); print '</td>'; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -481,19 +481,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'; @@ -507,16 +507,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -526,19 +526,19 @@ print '</form>'."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->mymodule->read; + $delallowed = $user->rights->mymodule->create; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 81999dc86f8..adb39743af7 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -33,23 +33,23 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmargin.class.php'; -require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_proposal/modules_supplier_proposal.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/supplier_proposal.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/supplier_proposal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page $langs->loadLangs(array('companies', 'supplier_proposal', 'compta', 'bills', 'propal', 'orders', 'products', 'deliveries', 'sendings')); -if (! empty($conf->margin->enabled)) +if (!empty($conf->margin->enabled)) $langs->load('margins'); $error = 0; @@ -66,19 +66,19 @@ $lineid = GETPOST('lineid', 'int'); $contactid = GETPOST('contactid', 'int'); // PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Nombre de ligne pour choix de produit/service predefinis $NBLINES = 4; // Security check -if (! empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'supplier_proposal', $id); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('supplier_proposalcard','globalcard')); +$hookmanager->initHooks(array('supplier_proposalcard', 'globalcard')); $object = new SupplierProposal($db); $extrafields = new ExtraFields($db); @@ -87,7 +87,7 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || ! empty($ref)) { +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); if ($ret > 0) $ret = $object->fetch_thirdparty(); @@ -96,8 +96,8 @@ if ($id > 0 || ! empty($ref)) { } $permissionnote = $user->rights->supplier_proposal->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->supplier_proposal->creer; // Used by the include of actions_dellink.inc.php -$permissiontoedit=$user->rights->supplier_proposal->creer; // Used by the include of actions_lineupdown.inc.php +$permissiondellink = $user->rights->supplier_proposal->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->supplier_proposal->creer; // Used by the include of actions_lineupdown.inc.php /* @@ -112,24 +112,24 @@ if (empty($reshook)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; } - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { - if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } @@ -138,7 +138,7 @@ if (empty($reshook)) if ($object->id > 0) { $result = $object->createFromClone($user, $socid); if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit(); } else @@ -155,7 +155,7 @@ if (empty($reshook)) { $result = $object->delete($user); if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/supplier_proposal/list.php'); + header('Location: '.DOL_URL_ROOT.'/supplier_proposal/list.php'); exit(); } else { $langs->load("errors"); @@ -174,7 +174,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -183,14 +183,14 @@ if (empty($reshook)) $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } // Validation elseif ($action == 'confirm_validate' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance))) ) { $result = $object->valid($user); @@ -205,11 +205,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -240,10 +240,10 @@ if (empty($reshook)) if ($socid < 1) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors'); $action = 'create'; - $error ++; + $error++; } - if (! $error) + if (!$error) { $db->begin(); @@ -295,12 +295,12 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error ++; + $error++; $action = 'create'; } } - if (! $error) + if (!$error) { if ($origin && $originid) { @@ -312,19 +312,19 @@ if (empty($reshook)) // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { + if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } $id = $object->create($user); if ($id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); if ($result > 0) @@ -336,12 +336,12 @@ if (empty($reshook)) $lines = $srcobject->lines; } - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) + $fk_parent_line = 0; + $num = count($lines); + for ($i = 0; $i < $num; $i++) { - $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); - $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); + $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle); // Positive line $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); @@ -384,7 +384,7 @@ if (empty($reshook)) $lineid = $result; } else { $lineid = 0; - $error ++; + $error++; break; } @@ -399,15 +399,15 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { - $error ++; + $error++; } } else { setEventMessages($srcobject->error, $srcobject->errors, 'errors'); - $error ++; + $error++; } } else { setEventMessages($object->error, $object->errors, 'errors'); - $error ++; + $error++; } } // Standard creation else @@ -417,7 +417,7 @@ if (empty($reshook)) if ($id > 0) { - if (! $error) + if (!$error) { $db->commit(); @@ -428,38 +428,38 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit(); } else { $db->rollback(); - $action='create'; + $action = 'create'; } } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); - $action='create'; + $action = 'create'; } } } } // Reopen proposal - elseif ($action == 'confirm_reopen' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel', 'alpha')) { + elseif ($action == 'confirm_reopen' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) { // prevent browser refresh from reopening proposal several times if ($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) { $object->reopen($user, SupplierProposal::STATUS_VALIDATED); @@ -467,7 +467,7 @@ if (empty($reshook)) } // Close proposal - elseif ($action == 'close' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel', 'alpha')) { + elseif ($action == 'close' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) { // prevent browser refresh from reopening proposal several times if ($object->statut == SupplierProposal::STATUS_SIGNED) { $object->setStatut(SupplierProposal::STATUS_CLOSE); @@ -475,8 +475,8 @@ if (empty($reshook)) } // Set accepted/refused - elseif ($action == 'setstatut' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel', 'alpha')) { - if (! GETPOST('statut')) { + elseif ($action == 'setstatut' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) { + if (!GETPOST('statut')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), null, 'errors'); $action = 'statut'; } else { @@ -491,9 +491,9 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='PROPOSAL_SUPPLIER_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO'; - $trackid='spr'.$object->id; + $trigger_name = 'PROPOSAL_SUPPLIER_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO'; + $trackid = 'spr'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc @@ -511,7 +511,7 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -539,27 +539,27 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $predef = ''; + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $ref_supplier = GETPOST('fourn_ref', 'alpha'); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $price_ht = ''; $tva_tx = ''; } - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); + $qty = GETPOST('qty'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); $price_ht_devise = GETPOST('multicurrency_price_ht'); // Extrafields @@ -569,25 +569,25 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error ++; + $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='' && $price_ht_devise === '') // Unit price can be 0 but not ''. Also price can be negative for proposal. + if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') // Unit price can be 0 but not ''. Also price can be negative for proposal. { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPrice")), null, 'errors'); - $error ++; + $error++; } if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); - $error ++; + $error++; } - if (! $error && ($qty >= 0)) { + if (!$error && ($qty >= 0)) { $pu_ht = 0; $pu_ttc = 0; $price_min = 0; @@ -602,19 +602,19 @@ if (empty($reshook)) { $productsupplier = new ProductFournisseur($db); - $idprod=0; - if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + $idprod = 0; + if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { - $idprod=$reg[1]; - $res=$productsupplier->fetch($idprod); // Load product from its ID + $idprod = $reg[1]; + $res = $productsupplier->fetch($idprod); // Load product from its ID // Call to init some price properties of $productsupplier // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price - if (! empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) + if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) { $fksoctosearch = 0; - $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist + $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist if ($productsupplier->fourn_socid != $socid) // The price we found is for another supplier, so we clear supplier price { $productsupplier->ref_supplier = ''; @@ -623,15 +623,15 @@ if (empty($reshook)) else { $fksoctosearch = $object->thirdparty->id; - $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist + $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist } } elseif (GETPOST('idprodfournprice', 'alpha') > 0) { //$qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat. - $qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist - $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); - $res=$productsupplier->fetch($idprod); + $qtytosearch = -1; // We force qty to -1 to be sure to find if a supplier price exist + $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); + $res = $productsupplier->fetch($idprod); } if ($idprod > 0) @@ -639,30 +639,30 @@ if (empty($reshook)) $label = $productsupplier->label; // if we use supplier description of the products - if(!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { + if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { $desc = $productsupplier->desc_supplier; } else $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $type = $productsupplier->type; - $price_base_type = ($productsupplier->fourn_price_base_type?$productsupplier->fourn_price_base_type:'HT'); + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); $ref_supplier = $productsupplier->ref_supplier; - $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + $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; - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); + if (empty($tva_tx)) $tva_npr = 0; + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); $pu_ht = $productsupplier->fourn_pu; - if (empty($pu_ht)) $pu_ht = 0; // If pu is '' or null, we force to have a numeric value + if (empty($pu_ht)) $pu_ht = 0; // If pu is '' or null, we force to have a numeric value $fournprice = 0; $buyingprice = 0; - $result=$object->addline( + $result = $object->addline( $desc, $pu_ht, $qty, @@ -713,7 +713,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); } } - elseif((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) // Free product. // $price_ht is already set + elseif ((GETPOST('price_ht') !== '' || GETPOST('price_ttc') !== '') && empty($error)) // Free product. // $price_ht is already set { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); @@ -723,13 +723,13 @@ if (empty($reshook)) $desc = $product_desc; $type = GETPOST('type'); - $fk_unit= GETPOST('units', 'alpha'); + $fk_unit = GETPOST('units', 'alpha'); - $tva_tx = price2num($tva_tx); // When vat is text input field + $tva_tx = price2num($tva_tx); // When vat is text input field // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); if ($price_ht !== '') { @@ -748,11 +748,11 @@ if (empty($reshook)) } - if (! $error && $result > 0) + if (!$error && $result > 0) { $db->commit(); - $ret=$object->fetch($object->id); // Reload to get new records + $ret = $object->fetch($object->id); // Reload to get new records // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -761,14 +761,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } @@ -820,7 +820,7 @@ if (empty($reshook)) // Mise a jour d'une ligne dans la demande de prix elseif ($action == 'updateline' && $user->rights->supplier_proposal->creer && GETPOST('save') == $langs->trans("Save")) { - $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + $vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0); // Define info_bits $info_bits = 0; @@ -858,7 +858,7 @@ if (empty($reshook)) // Add buying price $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = (GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value + $buyingprice = (GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value // Extrafields Lines $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -866,21 +866,21 @@ if (empty($reshook)) // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } // Define special_code for special lines - $special_code=GETPOST('special_code'); - if (! GETPOST('qty')) $special_code=3; + $special_code = GETPOST('special_code'); + if (!GETPOST('qty')) $special_code = 3; // Check minimum price $productid = GETPOST('productid', 'int'); - if (! empty($productid)) { + if (!empty($productid)) { $productsupplier = new ProductFournisseur($db); - if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) + if (!empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) { - if ($productid > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $productid, 'none', GETPOST('socid', 'int')) < 0 ) + if ($productid > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $productid, 'none', GETPOST('socid', 'int')) < 0) { setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); } @@ -892,7 +892,7 @@ if (empty($reshook)) $type = $product->type; $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) $price_min = $product->multiprices_min [$object->thirdparty->price_level]; $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); @@ -903,11 +903,11 @@ if (empty($reshook)) // Check parameters if (GETPOST('type') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error ++; + $error++; } } - if (! $error) { + if (!$error) { $db->begin(); $ref_supplier = GETPOST('fourn_ref', 'alpha'); @@ -943,7 +943,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -987,7 +987,7 @@ if (empty($reshook)) } elseif ($action == 'updateline' && $user->rights->supplier_proposal->creer && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } @@ -1036,7 +1036,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { $result = $object->insertExtraFields('SUPPLIER_PROPOSAL_MODIFY'); if ($result < 0) @@ -1062,7 +1062,7 @@ $formother = new FormOther($db); $formfile = new FormFile($db); $formmargin = new FormMargin($db); $companystatic = new Societe($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $now = dol_now(); @@ -1078,12 +1078,12 @@ if ($action == 'create') $res = $soc->fetch($socid); // Load objectsrc - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { $element = 'supplier_proposal'; $subelement = 'supplier_proposal'; - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($db); @@ -1094,13 +1094,13 @@ if ($action == 'create') } $objectsrc->fetch_thirdparty(); - $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); + $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); $soc = $objectsrc->thirdparty; - $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); // TODO maybe add default value option - $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); - $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); // TODO maybe add default value option + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); // Replicate extrafields $objectsrc->fetch_optionals($originid); @@ -1121,12 +1121,12 @@ if ($action == 'create') $object = new SupplierProposal($db); - print '<form name="addprop" action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; + print '<form name="addprop" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; + print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">'; print '<input type="hidden" name="action" value="add">'; if ($origin != 'project' && $originid) { - print '<input type="hidden" name="origin" value="' . $origin . '">'; - print '<input type="hidden" name="originid" value="' . $originid . '">'; + print '<input type="hidden" name="origin" value="'.$origin.'">'; + print '<input type="hidden" name="originid" value="'.$originid.'">'; } dol_fiche_head(); @@ -1134,15 +1134,15 @@ if ($action == 'create') print '<table class="border centpercent">'; // Reference - print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans("Draft") . '</td></tr>'; + print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans("Draft").'</td></tr>'; // Third party print '<tr>'; - print '<td class="fieldrequired">' . $langs->trans('Supplier') . '</td>'; + print '<td class="fieldrequired">'.$langs->trans('Supplier').'</td>'; if ($socid > 0) { print '<td colspan="2">'; print $soc->getNomUrl(1); - print '<input type="hidden" name="socid" value="' . $soc->id . '">'; + print '<input type="hidden" name="socid" value="'.$soc->id.'">'; print '</td>'; } else { print '<td colspan="2">'; @@ -1150,49 +1150,49 @@ if ($action == 'create') print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=0&fournisseur=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>'; print '</td>'; } - print '</tr>' . "\n"; + print '</tr>'."\n"; if ($soc->id > 0) { // Discounts for third party - print '<tr><td>' . $langs->trans('Discounts') . '</td><td>'; + print '<tr><td>'.$langs->trans('Discounts').'</td><td>'; $absolute_discount = $soc->getAvailableDiscounts('', '', 0, 1); $thirdparty = $soc; $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '</td></tr>'; } // Terms of payment - print '<tr><td class="nowrap">' . $langs->trans('PaymentConditionsShort') . '</td><td colspan="2">'; + print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; $form->select_conditions_paiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id', -1, 1); print '</td></tr>'; // Mode of payment - print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">'; + print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">'; $form->select_types_paiements(GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id'); print '</td></tr>'; // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) { - print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">'; - $form->select_comptes(GETPOST('fk_account')>0 ? GETPOST('fk_account', 'int') : $fk_account, 'fk_account', 0, '', 1); + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) { + print '<tr><td>'.$langs->trans('BankAccount').'</td><td colspan="2">'; + $form->select_comptes(GETPOST('fk_account') > 0 ? GETPOST('fk_account', 'int') : $fk_account, 'fk_account', 0, '', 1); print '</td></tr>'; } // Shipping Method - if (! empty($conf->expedition->enabled)) { - print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td colspan="2">'; + if (!empty($conf->expedition->enabled)) { + print '<tr><td>'.$langs->trans('SendingMethod').'</td><td colspan="2">'; print $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : $shipping_method_id, 'shipping_method_id', '', 1); print '</td></tr>'; } // Delivery date (or manufacturing) - print '<tr><td>' . $langs->trans("DeliveryDate") . '</td>'; + print '<tr><td>'.$langs->trans("DeliveryDate").'</td>'; print '<td colspan="2">'; $datedelivery = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { @@ -1209,14 +1209,14 @@ if ($action == 'create') // Model print '<tr>'; - print '<td>' . $langs->trans("DefaultModel") . '</td>'; + print '<td>'.$langs->trans("DefaultModel").'</td>'; print '<td colspan="2">'; $liste = ModelePDFSupplierProposal::liste_modeles($db); print $form->selectarray('model', $liste, ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)); print "</td></tr>"; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); @@ -1225,17 +1225,17 @@ if ($action == 'create') if ($origin == 'project') $projectid = ($originid ? $originid : 0); print '<tr>'; - print '<td>' . $langs->trans("Project") . '</td><td colspan="2">'; + print '<td>'.$langs->trans("Project").'</td><td colspan="2">'; $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1); - print '   <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="valignmiddle text-plus-circle">' . $langs->trans("AddProject") . '</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; + print '   <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; print '</td>'; print '</tr>'; } // Multicurrency - if (! empty($conf->multicurrency->enabled)) { + if (!empty($conf->multicurrency->enabled)) { print '<tr>'; print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>'; print '<td colspan="3" class="maxwidthonsmartphone">'; @@ -1253,7 +1253,7 @@ if ($action == 'create') // Lines from source - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { // TODO for compatibility if ($origin == 'contrat') { @@ -1263,33 +1263,33 @@ if ($action == 'create') $objectsrc->update_price(1, - 1, 1); } - print "\n<!-- " . $classname . " info -->"; + print "\n<!-- ".$classname." info -->"; print "\n"; - print '<input type="hidden" name="amount" value="' . $objectsrc->total_ht . '">' . "\n"; - print '<input type="hidden" name="total" value="' . $objectsrc->total_ttc . '">' . "\n"; - print '<input type="hidden" name="tva" value="' . $objectsrc->total_tva . '">' . "\n"; - print '<input type="hidden" name="origin" value="' . $objectsrc->element . '">'; - print '<input type="hidden" name="originid" value="' . $objectsrc->id . '">'; + print '<input type="hidden" name="amount" value="'.$objectsrc->total_ht.'">'."\n"; + print '<input type="hidden" name="total" value="'.$objectsrc->total_ttc.'">'."\n"; + print '<input type="hidden" name="tva" value="'.$objectsrc->total_tva.'">'."\n"; + print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">'; + print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">'; - print '<tr><td>' . $langs->trans('CommRequest') . '</td><td colspan="2">' . $objectsrc->getNomUrl(1) . '</td></tr>'; - print '<tr><td>' . $langs->trans('AmountHT') . '</td><td colspan="2">' . price($objectsrc->total_ht) . '</td></tr>'; - print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td colspan="2">' . price($objectsrc->total_tva) . "</td></tr>"; - if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0 ) // Localtax1 + print '<tr><td>'.$langs->trans('CommRequest').'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>'; + print '<tr><td>'.$langs->trans('AmountHT').'</td><td colspan="2">'.price($objectsrc->total_ht).'</td></tr>'; + print '<tr><td>'.$langs->trans('AmountVAT').'</td><td colspan="2">'.price($objectsrc->total_tva)."</td></tr>"; + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 { - print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax1) . "</td></tr>"; + print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td><td colspan="2">'.price($objectsrc->total_localtax1)."</td></tr>"; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 { - print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax2) . "</td></tr>"; + print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td><td colspan="2">'.price($objectsrc->total_localtax2)."</td></tr>"; } - print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc) . "</td></tr>"; + print '<tr><td>'.$langs->trans('AmountTTC').'</td><td colspan="2">'.price($objectsrc->total_ttc)."</td></tr>"; if (!empty($conf->multicurrency->enabled)) { - print '<tr><td>' . $langs->trans('MulticurrencyAmountHT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ht) . '</td></tr>'; - print '<tr><td>' . $langs->trans('MulticurrencyAmountVAT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_tva) . "</td></tr>"; - print '<tr><td>' . $langs->trans('MulticurrencyAmountTTC') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>"; + print '<tr><td>'.$langs->trans('MulticurrencyAmountHT').'</td><td colspan="2">'.price($objectsrc->multicurrency_total_ht).'</td></tr>'; + print '<tr><td>'.$langs->trans('MulticurrencyAmountVAT').'</td><td colspan="2">'.price($objectsrc->multicurrency_total_tva)."</td></tr>"; + print '<tr><td>'.$langs->trans('MulticurrencyAmountTTC').'</td><td colspan="2">'.price($objectsrc->multicurrency_total_ttc)."</td></tr>"; } } @@ -1302,23 +1302,23 @@ if ($action == 'create') if (empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) print '<input type="hidden" name="createmode" value="empty">'; - if (! empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) + if (!empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) { print '<br><table>'; // For backward compatibility print '<tr>'; print '<td><input type="radio" name="createmode" value="copy"></td>'; - print '<td>' . $langs->trans("CopyAskFrom") . ' </td>'; + print '<td>'.$langs->trans("CopyAskFrom").' </td>'; print '<td>'; $liste_ask = array(); $liste_ask [0] = ''; $sql = "SELECT p.rowid as id, p.ref, s.nom"; - $sql .= " FROM " . MAIN_DB_PREFIX . "supplier_proposal p"; - $sql .= ", " . MAIN_DB_PREFIX . "societe s"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal p"; + $sql .= ", ".MAIN_DB_PREFIX."societe s"; $sql .= " WHERE s.rowid = p.fk_soc"; - $sql .= " AND p.entity = " . $conf->entity; + $sql .= " AND p.entity = ".$conf->entity; $sql .= " AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT; $sql .= " ORDER BY Id"; @@ -1328,9 +1328,9 @@ if ($action == 'create') $i = 0; while ($i < $num) { $row = $db->fetch_row($resql); - $askPriceSupplierRefAndSocName = $row [1] . " - " . $row [2]; + $askPriceSupplierRefAndSocName = $row [1]." - ".$row [2]; $liste_ask [$row [0]] = $askPriceSupplierRefAndSocName; - $i ++; + $i++; } print $form->selectarray("copie_supplier_proposal", $liste_ask, 0); } else { @@ -1339,24 +1339,24 @@ if ($action == 'create') print '</td></tr>'; print '<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>'; - print '<td valign="top" colspan="2">' . $langs->trans("CreateEmptyAsk") . '</td></tr>'; + print '<td valign="top" colspan="2">'.$langs->trans("CreateEmptyAsk").'</td></tr>'; } - if (! empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) print '</table>'; + if (!empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) print '</table>'; dol_fiche_end(); print '<div class="center">'; - print '<input type="submit" class="button" value="' . $langs->trans("CreateDraft") . '">'; + print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">'; print '     '; - print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; + print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; print '</div>'; print "</form>"; // Show origin lines - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { print '<br>'; $title = $langs->trans('ProductsAndServices'); @@ -1389,24 +1389,24 @@ if ($action == 'create') // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => // 1), - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', 's.fournisseur=1'))); + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', 's.fournisseur=1'))); // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Confirm delete elseif ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteAsk'), $langs->trans('ConfirmDeleteAsk', $object->ref), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteAsk'), $langs->trans('ConfirmDeleteAsk', $object->ref), 'confirm_delete', '', 0, 1); } // Confirm reopen elseif ($action == 'reopen') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenAsk', $object->ref), 'confirm_reopen', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenAsk', $object->ref), 'confirm_reopen', '', 0, 1); } // Confirmation delete product/service line elseif ($action == 'ask_deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } // Confirm validate askprice @@ -1418,7 +1418,7 @@ if ($action == 'create') if ($ref == 'PROV') { $numref = $object->getNextNumRef($soc); if (empty($numref)) { - $error ++; + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } else { @@ -1426,72 +1426,72 @@ if ($action == 'create') } $text = $langs->trans('ConfirmValidateAsk', $numref); - if (! empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + if (!empty($conf->notification->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '<br>'; $text .= $notify->confirmMessage('SUPPLIER_PROPOSAL_VALIDATE', $object->socid, $object); } - if (! $error) - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateAsk'), $text, 'confirm_validate', '', 0, 1); + if (!$error) + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateAsk'), $text, 'confirm_validate', '', 0, 1); } // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; // Supplier proposal card - $linkback = '<a href="' . DOL_URL_ROOT . '/supplier_proposal/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; + $linkback = '<a href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; - $morehtmlref='<div class="refidno">'; + $morehtmlref = '<div class="refidno">'; // Ref supplier //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherProposals").'</a>)'; + $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherProposals").'</a>)'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; + $morehtmlref .= '<br>'.$langs->trans('Project').' '; if ($user->rights->supplier_proposal->creer) { if ($action != 'classify') { - $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; + $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; - $morehtmlref.='<input type="hidden" name="action" value="classin">'; - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; - $morehtmlref.='</form>'; + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; + $morehtmlref .= '</form>'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; - $morehtmlref.=$proj->ref; - $morehtmlref.='</a>'; + $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; + $morehtmlref .= $proj->ref; + $morehtmlref .= '</a>'; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='</div>'; + $morehtmlref .= '</div>'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -1504,7 +1504,7 @@ if ($action == 'create') print '<table class="border tableforfield" width="100%">'; // Relative and absolute discounts - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -1512,7 +1512,7 @@ if ($action == 'create') $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')"; } - print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>'; + print '<tr><td class="titlefield">'.$langs->trans('Discounts').'</td><td>'; $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount, 0, 1); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote, 0, 1); @@ -1521,7 +1521,7 @@ if ($action == 'create') $thirdparty = $soc; $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '</td></tr>'; @@ -1532,13 +1532,13 @@ if ($action == 'create') print $langs->trans('PaymentConditionsShort'); print '</td>'; if ($action != 'editconditions' && $object->statut == SupplierProposal::STATUS_DRAFT) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetConditions'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="3">'; if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none', 1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1); } print '</td>'; print '</tr>'; @@ -1550,15 +1550,15 @@ if ($action == 'create') print $langs->trans('DeliveryDate'); print '</td>'; if ($action != 'editdate_livraison' && $object->statut == SupplierProposal::STATUS_VALIDATED) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editdate_livraison&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'), 1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="3">'; if ($action == 'editdate_livraison') { - print '<form name="editdate_livraison" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post">'; - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; + print '<form name="editdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; + print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">'; print '<input type="hidden" name="action" value="setdate_livraison">'; print $form->selectDate($object->date_livraison, 'liv_', '', '', '', "editdate_livraison"); - print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">'; + print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '</form>'; } else { print dol_print_date($object->date_livraison, 'daytext'); @@ -1573,18 +1573,18 @@ if ($action == 'create') print $langs->trans('PaymentMode'); print '</td>'; if ($action != 'editmode' && $object->statut == $object::STATUS_VALIDATED) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editmode&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMode'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="3">'; if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id', 'DBIT', 1, 1); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'DBIT', 1, 1); } else { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); } print '</td></tr>'; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print '<tr>'; @@ -1593,13 +1593,13 @@ if ($action == 'create') print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print '</td>'; if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_VALIDATED) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencycode&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencycode&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="3">'; if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); } print '</td></tr>'; @@ -1612,16 +1612,16 @@ if ($action == 'create') print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print '</td>'; if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_VALIDATED && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) - print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; + print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencyrate&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="3">'; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '<div class="inline-block">         '; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>'; @@ -1646,7 +1646,7 @@ if ($action == 'create') print '</tr>'; }*/ - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) { // Bank Account print '<tr><td>'; @@ -1668,7 +1668,7 @@ if ($action == 'create') // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '</table>'; @@ -1682,48 +1682,48 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print '<tr><td class="titlefieldmiddle">' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . '</td>'; - print '<td>' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>'; + print '<td>'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount VAT - print '<tr><td>' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . '</td>'; - print '<td>' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>'; + print '<td>'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; // Multicurrency Amount TTC - print '<tr><td>' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . '</td>'; - print '<td>' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; + print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>'; + print '<td>'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '</tr>'; } // Amount HT - print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>'; - print '<td>' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; + print '<tr><td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>'; + print '<td>'.price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; // Amount VAT - print '<tr><td>' . $langs->trans('AmountVAT') . '</td>'; - print '<td>' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; + print '<tr><td>'.$langs->trans('AmountVAT').'</td>'; + print '<td>'.price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { - print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>'; - print '<td class="nowrap">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; + print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>'; + print '<td class="nowrap">'.price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 { - print '<tr><td height="10">' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>'; - print '<td class="nowrap">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; + print '<tr><td height="10">'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>'; + print '<td class="nowrap">'.price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; } // Amount TTC - print '<tr><td height="10">' . $langs->trans('AmountTTC') . '</td>'; - print '<td class="nowrap">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>'; + print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td>'; + print '<td class="nowrap">'.price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency).'</td>'; print '</tr>'; print '</table>'; @@ -1739,16 +1739,16 @@ if ($action == 'create') print '<div class="clearboth"></div><br>'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } /* @@ -1758,15 +1758,15 @@ if ($action == 'create') // Show object lines $result = $object->getLinesArray(); - print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#add' : '#line_' . GETPOST('lineid')) . '" method="POST"> - <input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '"> - <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '"> + print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#add' : '#line_'.GETPOST('lineid')).'" method="POST"> + <input type="hidden" name="token" value="' . $_SESSION ['newtoken'].'"> + <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'"> <input type="hidden" name="mode" value=""> - <input type="hidden" name="id" value="' . $object->id . '"> + <input type="hidden" name="id" value="' . $object->id.'"> '; - if (! empty($conf->use_javascript_ajax) && $object->statut == SupplierProposal::STATUS_DRAFT) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->statut == SupplierProposal::STATUS_DRAFT) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '<div class="div-table-responsive-no-min">'; @@ -1774,11 +1774,11 @@ if ($action == 'create') // Add free products/services form global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; - $forceall=1; $dateSelector=0; $inputalsopricewithtax=1; - $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty. - if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; + $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1; + $senderissupplier = 2; // $senderissupplier=2 is same than 1 but disable test on minimum qty. + if (!empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier = 1; - if (! empty($object->lines)) + if (!empty($object->lines)) $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector); // Form to add new line @@ -1843,61 +1843,61 @@ if ($action == 'create') { // Validate if ($object->statut == SupplierProposal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance))) ) { if (count($object->lines) > 0) - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=validate">' . $langs->trans('Validate') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=validate">'.$langs->trans('Validate').'</a></div>'; // else print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('Validate').'</a>'; } // Edit if ($object->statut == SupplierProposal::STATUS_VALIDATED && $user->rights->supplier_proposal->creer) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=modif">' . $langs->trans('Modify') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=modif">'.$langs->trans('Modify').'</a></div>'; } // ReOpen if (($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) && $user->rights->supplier_proposal->cloturer) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=reopen' . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#reopen') . '"'; - print '>' . $langs->trans('ReOpen') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#reopen').'"'; + print '>'.$langs->trans('ReOpen').'</a></div>'; } // Send if ($object->statut == SupplierProposal::STATUS_VALIDATED || $object->statut == SupplierProposal::STATUS_SIGNED) { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'; } else - print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans('SendMail') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>'; } // Create an order - if (! empty($conf->fournisseur->enabled) && $object->statut == SupplierProposal::STATUS_SIGNED) { + if (!empty($conf->fournisseur->enabled) && $object->statut == SupplierProposal::STATUS_SIGNED) { if ($user->rights->fournisseur->commande->creer) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/fourn/commande/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans("AddOrder") . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a></div>'; } } // Set accepted/refused if ($object->statut == SupplierProposal::STATUS_VALIDATED && $user->rights->supplier_proposal->cloturer) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=statut' . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#acceptedrefused') . '"'; - print '>' . $langs->trans('SetAcceptedRefused') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=statut'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#acceptedrefused').'"'; + print '>'.$langs->trans('SetAcceptedRefused').'</a></div>'; } // Close if ($object->statut == SupplierProposal::STATUS_SIGNED && $user->rights->supplier_proposal->cloturer) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=close' . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close') . '"'; - print '>' . $langs->trans('Close') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close').'"'; + print '>'.$langs->trans('Close').'</a></div>'; } // Clone if ($user->rights->supplier_proposal->creer) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&socid=' . $object->socid . '&action=clone&object=' . $object->element . '">' . $langs->trans("ToClone") . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object='.$object->element.'">'.$langs->trans("ToClone").'</a></div>'; } // Delete if (($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer) || $user->rights->supplier_proposal->supprimer) { - print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=delete"'; - print '>' . $langs->trans('Delete') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete"'; + print '>'.$langs->trans('Delete').'</a></div>'; } } } @@ -1913,8 +1913,8 @@ if ($action == 'create') * Documents generes */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->supplier_proposal->dir_output . "/" . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $filedir = $conf->supplier_proposal->dir_output."/".dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->rights->supplier_proposal->lire; $delallowed = $user->rights->supplier_proposal->creer; @@ -1929,7 +1929,7 @@ if ($action == 'create') print '</div><div class="fichehalfright"><div class="ficheaddleft">'; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'supplier_proposal', $socid, 1); @@ -1942,10 +1942,10 @@ if ($action == 'create') } // Presend form - $modelmail='supplier_proposal_send'; - $defaulttopic='SendAskRef'; + $modelmail = 'supplier_proposal_send'; + $defaulttopic = 'SendAskRef'; $diroutput = $conf->supplier_proposal->dir_output; - $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO'; $trackid = 'spr'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 2b8f4038bfc..178c88a14ad 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -40,50 +40,50 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'propal', 'supplier_proposal', 'compta', 'bills', 'orders', 'products')); -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'supplierproposallist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierproposallist'; -$search_user=GETPOST('search_user', 'int'); -$search_sale=GETPOST('search_sale', 'int'); -$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref', 'alpha'):GETPOST('search_ref', 'alpha'); -$search_societe=GETPOST('search_societe', 'alpha'); -$search_author=GETPOST('search_author', 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_montant_ht=GETPOST('search_montant_ht', 'alpha'); -$search_montant_vat=GETPOST('search_montant_vat', 'alpha'); -$search_montant_ttc=GETPOST('search_montant_ttc', 'alpha'); -$search_status=GETPOST('viewstatut', 'alpha')?GETPOST('viewstatut', 'alpha'):GETPOST('search_status', 'int'); -$object_statut=$db->escape(GETPOST('supplier_proposal_statut')); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); +$search_user = GETPOST('search_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); +$search_societe = GETPOST('search_societe', 'alpha'); +$search_author = GETPOST('search_author', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_montant_ht = GETPOST('search_montant_ht', 'alpha'); +$search_montant_vat = GETPOST('search_montant_vat', 'alpha'); +$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); +$search_status = GETPOST('viewstatut', 'alpha') ?GETPOST('viewstatut', 'alpha') : GETPOST('search_status', 'int'); +$object_statut = $db->escape(GETPOST('supplier_proposal_statut')); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); -$year=GETPOST("year"); -$month=GETPOST("month"); -$day=GETPOST("day"); -$yearvalid=GETPOST("yearvalid"); -$monthvalid=GETPOST("monthvalid"); -$dayvalid=GETPOST("dayvalid"); +$mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); +$year = GETPOST("year"); +$month = GETPOST("month"); +$day = GETPOST("day"); +$yearvalid = GETPOST("yearvalid"); +$monthvalid = GETPOST("monthvalid"); +$dayvalid = GETPOST("dayvalid"); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -91,28 +91,28 @@ if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='sp.date_livraison'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'sp.date_livraison'; +if (!$sortorder) $sortorder = 'DESC'; -if ($object_statut != '') $search_status=$object_statut; +if ($object_statut != '') $search_status = $object_statut; // Nombre de ligne pour choix de produit/service predefinis -$NBLINES=4; +$NBLINES = 4; // Security check -$module='supplier_proposal'; -$dbtable=''; -$objectid=''; -if (! empty($user->socid)) $socid=$user->socid; -if (! empty($socid)) +$module = 'supplier_proposal'; +$dbtable = ''; +$objectid = ''; +if (!empty($user->socid)) $socid = $user->socid; +if (!empty($socid)) { - $objectid=$socid; - $module='societe'; - $dbtable='&societe'; + $objectid = $socid; + $module = 'societe'; + $dbtable = '&societe'; } $result = restrictedArea($user, $module, $objectid, $dbtable); -$diroutputmassaction=$conf->supplier_proposal->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new SupplierProposal($db); @@ -122,7 +122,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" @@ -132,10 +132,10 @@ $fieldstosearchall = array( 'pd.description'=>'Description', 'sp.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["p.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'sp.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("Supplier"), 'checked'=>1), 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), @@ -156,10 +156,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -171,49 +171,49 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on 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 +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_categ=''; - $search_user=''; - $search_sale=''; - $search_ref=''; - $search_societe=''; - $search_montant_ht=''; - $search_montant_vat=''; - $search_montant_ttc=''; - $search_login=''; - $search_product_category=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_author=''; - $yearvalid=''; - $monthvalid=''; - $dayvalid=''; - $year=''; - $month=''; - $day=''; - $search_status=''; - $object_statut=''; + $search_categ = ''; + $search_user = ''; + $search_sale = ''; + $search_ref = ''; + $search_societe = ''; + $search_montant_ht = ''; + $search_montant_vat = ''; + $search_montant_ttc = ''; + $search_login = ''; + $search_product_category = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_author = ''; + $yearvalid = ''; + $monthvalid = ''; + $dayvalid = ''; + $year = ''; + $month = ''; + $day = ''; + $search_status = ''; + $object_statut = ''; } if (empty($reshook)) { - $objectclass='SupplierProposal'; - $objectlabel='SupplierProposals'; + $objectclass = 'SupplierProposal'; + $objectlabel = 'SupplierProposals'; $permissiontoread = $user->rights->supplier_proposal->lire; $permissiontodelete = $user->rights->supplier_proposal->supprimer; $uploaddir = $conf->supplier_proposal->dir_output; @@ -227,89 +227,89 @@ if (empty($reshook)) */ -$now=dol_now(); +$now = dol_now(); $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $formpropal = new FormPropal($db); -$companystatic=new Societe($db); -$formcompany=new FormCompany($db); +$companystatic = new Societe($db); +$formcompany = new FormCompany($db); -$help_url='EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; +$help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; //llxHeader('',$langs->trans('CommRequest'),$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' sp.rowid, sp.note_private, sp.total_ht, sp.tva as total_vat, sp.total as total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,'; -$sql.= ' sp.datec as date_creation, sp.tms as date_update,'; -$sql.= " p.rowid as project_id, p.ref as project_ref,"; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; -$sql.= " u.firstname, u.lastname, u.photo, u.login"; +$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= ' sp.rowid, sp.note_private, sp.total_ht, sp.tva as total_vat, sp.total as total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,'; +$sql .= ' sp.datec as date_creation, sp.tms as date_update,'; +$sql .= " p.rowid as project_id, p.ref as project_ref,"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; +$sql .= " u.firstname, u.lastname, u.photo, u.login"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$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."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)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql.= ', '.MAIN_DB_PREFIX.'supplier_proposal as sp'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (sp.rowid = ef.fk_object)"; -if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON sp.rowid=pd.fk_supplier_proposal'; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sp.fk_user_author = u.rowid'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = sp.fk_projet"; +$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."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)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql .= ', '.MAIN_DB_PREFIX.'supplier_proposal as sp'; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (sp.rowid = ef.fk_object)"; +if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON sp.rowid=pd.fk_supplier_proposal'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sp.fk_user_author = u.rowid'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = sp.fk_projet"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as c"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as c"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE sp.fk_soc = s.rowid'; -$sql.= ' AND sp.entity IN ('.getEntity('supplier_proposal').')'; -if (! $user->rights->societe->client->voir && ! $socid) //restriction +$sql .= ' WHERE sp.fk_soc = s.rowid'; +$sql .= ' AND sp.entity IN ('.getEntity('supplier_proposal').')'; +if (!$user->rights->societe->client->voir && !$socid) //restriction { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_ref) $sql .= natural_search('sp.ref', $search_ref); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_author) $sql .= natural_search('u.login', $search_author); -if ($search_montant_ht) $sql.= natural_search('sp.total_ht=', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql.= natural_search("sp.tva", $search_montant_vat, 1); -if ($search_montant_ttc != '') $sql.= natural_search("sp.total", $search_montant_ttc, 1); +if ($search_montant_ht) $sql .= natural_search('sp.total_ht=', $search_montant_ht, 1); +if ($search_montant_vat != '') $sql .= natural_search("sp.tva", $search_montant_vat, 1); +if ($search_montant_ttc != '') $sql .= natural_search("sp.total", $search_montant_ttc, 1); if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($socid) $sql.= ' AND s.rowid = '.$socid; -if ($search_status >= 0 && $search_status != '') $sql.= ' AND sp.fk_statut IN ('.$db->escape($search_status).')'; -$sql.= dolSqlDateFilter("sp.date_livraison", $day, $month, $year); -$sql.= dolSqlDateFilter("sp.date_valid", $dayvalid, $monthvalid, $yearvalid); -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; +if ($socid) $sql .= ' AND s.rowid = '.$socid; +if ($search_status >= 0 && $search_status != '') $sql .= ' AND sp.fk_statut IN ('.$db->escape($search_status).')'; +$sql .= dolSqlDateFilter("sp.date_livraison", $day, $month, $year); +$sql .= dolSqlDateFilter("sp.date_valid", $dayvalid, $monthvalid, $yearvalid); +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; if ($search_user > 0) { - $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = sp.rowid AND c.fk_socpeople = ".$search_user; + $sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = sp.rowid AND c.fk_socpeople = ".$search_user; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); -$sql.=', sp.ref DESC'; +$sql .= $db->order($sortfield, $sortorder); +$sql .= ', sp.ref DESC'; // Count total nb of records $nbtotalofrecords = ''; @@ -324,19 +324,19 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { - $objectstatic=new SupplierProposal($db); - $userstatic=new User($db); + $objectstatic = new SupplierProposal($db); + $userstatic = new User($db); if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); - $title = $langs->trans('ListOfSupplierProposals') . ' - '.$soc->name; + $title = $langs->trans('ListOfSupplierProposals').' - '.$soc->name; } else { @@ -345,9 +345,9 @@ if ($resql) $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); @@ -360,40 +360,40 @@ if ($resql) llxHeader('', $langs->trans('CommRequest'), $help_url); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($sall) $param.='&sall='.$sall; - if ($month) $param.='&month='.$month; - if ($year) $param.='&year='.$year; - if ($search_ref) $param.='&search_ref=' .$search_ref; - if ($search_societe) $param.='&search_societe=' .$search_societe; - if ($search_user > 0) $param.='&search_user='.$search_user; - if ($search_sale > 0) $param.='&search_sale='.$search_sale; - if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; - if ($search_author) $param.='&search_author='.$search_author; - if ($search_town) $param.='&search_town='.$search_town; - if ($search_zip) $param.='&search_zip='.$search_zip; - if ($socid > 0) $param.='&socid='.$socid; - if ($search_status != '') $param.='&search_status='.$search_status; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($sall) $param .= '&sall='.$sall; + if ($month) $param .= '&month='.$month; + if ($year) $param .= '&year='.$year; + if ($search_ref) $param .= '&search_ref='.$search_ref; + if ($search_societe) $param .= '&search_societe='.$search_societe; + if ($search_user > 0) $param .= '&search_user='.$search_user; + if ($search_sale > 0) $param .= '&search_sale='.$search_sale; + if ($search_montant_ht) $param .= '&search_montant_ht='.$search_montant_ht; + if ($search_author) $param .= '&search_author='.$search_author; + if ($search_town) $param .= '&search_town='.$search_town; + if ($search_zip) $param .= '&search_zip='.$search_zip; + if ($socid > 0) $param .= '&socid='.$socid; + if ($search_status != '') $param .= '&search_status='.$search_status; + if ($optioncss != '') $param .= '&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->supplier_proposal->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->supplier_proposal->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; - if($user->rights->supplier_proposal->creer) + $newcardbutton = ''; + if ($user->rights->supplier_proposal->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewAskPrice'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/supplier_proposal/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAskPrice'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/supplier_proposal/card.php?action=create'); } // Fields title search @@ -408,106 +408,106 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'commercial', 0, $newcardbutton, '', $limit); - $topicmail="SendSupplierProposalRef"; - $modelmail="supplier_proposal_send"; - $objecttmp=new SupplierProposal($db); - $trackid='spro'.$object->id; + $topicmail = "SendSupplierProposalRef"; + $modelmail = "supplier_proposal_send"; + $objecttmp = new SupplierProposal($db); + $trackid = 'spro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } $i = 0; - $moreforfilter=''; + $moreforfilter = ''; // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); + $moreforfilter .= '</div>'; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - $moreforfilter.='</div>'; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $moreforfilter .= '</div>'; } // If the user can view products if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='<div class="divsearchfield">'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '<div class="divsearchfield">'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='</div>'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '</div>'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<tr class="liste_titre_filter">'; - if (! empty($arrayfields['sp.ref']['checked'])) + if (!empty($arrayfields['sp.ref']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '<td class="liste_titre left">'; print '<input class="flat" type="text" size="12" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">'; print '</td>'; } - if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; - if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>'; + if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>'; + if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>'; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print '<td class="liste_titre">'; print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print '<td class="liste_titre center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone center">'; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print '</td>'; } // Date - if (! empty($arrayfields['sp.date_valid']['checked'])) + if (!empty($arrayfields['sp.date_valid']['checked'])) { print '<td class="liste_titre center" colspan="1">'; //print $langs->trans('Month').': '; @@ -518,7 +518,7 @@ if ($resql) print '</td>'; } // Date - if (! empty($arrayfields['sp.date_livraison']['checked'])) + if (!empty($arrayfields['sp.date_livraison']['checked'])) { print '<td class="liste_titre center" colspan="1">'; //print $langs->trans('Month').': '; @@ -529,28 +529,28 @@ if ($resql) print '</td>'; } - if (! empty($arrayfields['sp.total_ht']['checked'])) + if (!empty($arrayfields['sp.total_ht']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">'; print '</td>'; } - if (! empty($arrayfields['sp.total_vat']['checked'])) + if (!empty($arrayfields['sp.total_vat']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">'; print '</td>'; } - if (! empty($arrayfields['sp.total_ttc']['checked'])) + if (!empty($arrayfields['sp.total_ttc']['checked'])) { // Amount print '<td class="liste_titre right">'; print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; print '</td>'; } - if (! empty($arrayfields['u.login']['checked'])) + if (!empty($arrayfields['u.login']['checked'])) { // Author print '<td class="liste_titre center">'; @@ -560,23 +560,23 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['sp.datec']['checked'])) + if (!empty($arrayfields['sp.datec']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Date modification - if (! empty($arrayfields['sp.tms']['checked'])) + if (!empty($arrayfields['sp.tms']['checked'])) { print '<td class="liste_titre">'; print '</td>'; } // Status - if (! empty($arrayfields['sp.fk_statut']['checked'])) + if (!empty($arrayfields['sp.fk_statut']['checked'])) { print '<td class="liste_titre maxwidthonsmartphone right">'; $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'supplier', 'search_status'); @@ -584,7 +584,7 @@ if ($resql) } // Action column print '<td class="liste_titre middle">'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; @@ -592,46 +592,46 @@ if ($resql) // Fields title print '<tr class="liste_titre">'; - if (! empty($arrayfields['sp.ref']['checked'])) print_liste_field_titre($arrayfields['sp.ref']['label'], $_SERVER["PHP_SELF"], 'sp.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['sp.date_valid']['checked'])) print_liste_field_titre($arrayfields['sp.date_valid']['label'], $_SERVER["PHP_SELF"], 'sp.date_valid', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['sp.date_livraison']['checked'])) print_liste_field_titre($arrayfields['sp.date_livraison']['label'], $_SERVER["PHP_SELF"], 'sp.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['sp.total_ht']['checked'])) print_liste_field_titre($arrayfields['sp.total_ht']['label'], $_SERVER["PHP_SELF"], 'sp.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['sp.total_vat']['checked'])) print_liste_field_titre($arrayfields['sp.total_vat']['label'], $_SERVER["PHP_SELF"], 'sp.total_vat', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['sp.total_ttc']['checked'])) print_liste_field_titre($arrayfields['sp.total_ttc']['label'], $_SERVER["PHP_SELF"], 'sp.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['sp.ref']['checked'])) print_liste_field_titre($arrayfields['sp.ref']['label'], $_SERVER["PHP_SELF"], 'sp.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['sp.date_valid']['checked'])) print_liste_field_titre($arrayfields['sp.date_valid']['label'], $_SERVER["PHP_SELF"], 'sp.date_valid', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['sp.date_livraison']['checked'])) print_liste_field_titre($arrayfields['sp.date_livraison']['label'], $_SERVER["PHP_SELF"], 'sp.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['sp.total_ht']['checked'])) print_liste_field_titre($arrayfields['sp.total_ht']['label'], $_SERVER["PHP_SELF"], 'sp.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['sp.total_vat']['checked'])) print_liste_field_titre($arrayfields['sp.total_vat']['label'], $_SERVER["PHP_SELF"], 'sp.total_vat', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['sp.total_ttc']['checked'])) print_liste_field_titre($arrayfields['sp.total_ttc']['label'], $_SERVER["PHP_SELF"], 'sp.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $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 + $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; - if (! empty($arrayfields['sp.datec']['checked'])) print_liste_field_titre($arrayfields['sp.datec']['label'], $_SERVER["PHP_SELF"], "sp.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['sp.tms']['checked'])) print_liste_field_titre($arrayfields['sp.tms']['label'], $_SERVER["PHP_SELF"], "sp.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap'); - if (! empty($arrayfields['sp.fk_statut']['checked'])) print_liste_field_titre($arrayfields['sp.fk_statut']['label'], $_SERVER["PHP_SELF"], "sp.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['sp.datec']['checked'])) print_liste_field_titre($arrayfields['sp.datec']['label'], $_SERVER["PHP_SELF"], "sp.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['sp.tms']['checked'])) print_liste_field_titre($arrayfields['sp.tms']['label'], $_SERVER["PHP_SELF"], "sp.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap'); + if (!empty($arrayfields['sp.fk_statut']['checked'])) print_liste_field_titre($arrayfields['sp.fk_statut']['label'], $_SERVER["PHP_SELF"], "sp.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print '</tr>'."\n"; $now = dol_now(); - $i=0; - $total=0; - $subtotal=0; - $totalarray=array(); + $i = 0; + $total = 0; + $subtotal = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $objectstatic->id=$obj->rowid; - $objectstatic->ref=$obj->ref; + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; print '<tr class="oddeven">'; - if (! empty($arrayfields['sp.ref']['checked'])) + if (!empty($arrayfields['sp.ref']['checked'])) { print '<td class="nowrap">'; @@ -641,14 +641,14 @@ if ($resql) print $objectstatic->getNomUrl(1); print '</td>'; // Warning - $warnornote=''; - if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); - if (! empty($obj->note_private)) + $warnornote = ''; + if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late")); + if (!empty($obj->note_private)) { - $warnornote.=($warnornote?' ':''); - $warnornote.= '<span class="note">'; - $warnornote.= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>'; - $warnornote.= '</span>'; + $warnornote .= ($warnornote ? ' ' : ''); + $warnornote .= '<span class="note">'; + $warnornote .= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>'; + $warnornote .= '</span>'; } if ($warnornote) { @@ -835,8 +835,8 @@ if ($resql) $db->free($resql); - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -844,17 +844,17 @@ if ($resql) print '</form>'."\n"; - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; + $filedir = $diroutputmassaction; - $genallowed=$user->rights->supplier_proposal->lire; - $delallowed=$user->rights->supplier_proposal->creer; + $genallowed = $user->rights->supplier_proposal->lire; + $delallowed = $user->rights->supplier_proposal->creer; print $formfile->showdocuments('massfilesarea_supplier_proposal', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 1360dc6efcd..670ed740b5f 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -26,42 +26,42 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/ticket/class/actions_ticket.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticket.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; -include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; // Load translation files required by the page $langs->loadLangs(array("ticket", "companies", "other", "projects")); // Get parameters -$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'):'ticketlist'; // 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') +$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') : 'ticketlist'; // 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') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $msg_id = GETPOST('msg_id', 'int'); $socid = GETPOST('socid', 'int'); $projectid = GETPOST('projectid', 'int'); -$project_ref= GETPOST('project_ref', 'alpha'); +$project_ref = GETPOST('project_ref', 'alpha'); $search_societe = GETPOST('search_societe', 'alpha'); -$search_fk_project=GETPOST('search_fk_project', 'int')?GETPOST('search_fk_project', 'int'):GETPOST('projectid', 'int'); +$search_fk_project = GETPOST('search_fk_project', 'int') ?GETPOST('search_fk_project', 'int') : GETPOST('projectid', 'int'); $search_fk_status = GETPOST('search_fk_statut', 'array'); -$mode = GETPOST('mode', 'alpha'); +$mode = GETPOST('mode', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -71,51 +71,51 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object=new Ticket($db); +$object = new Ticket($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->ticket->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->ticket->dir_output.'/temp/massgeneration/'.$user->id; if ($socid > 0) $hookmanager->initHooks(array('thirdpartyticket')); elseif ($project > 0) $hookmanager->initHooks(array('projectticket')); else $hookmanager->initHooks(array('ticketlist')); // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.datec"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "t.datec"; +if (!$sortorder) $sortorder = "DESC"; -if (GETPOST('search_fk_status', 'alpha') == 'non_closed') $_GET['search_fk_statut'][]='openall'; // For backward compatibility +if (GETPOST('search_fk_status', 'alpha') == 'non_closed') $_GET['search_fk_statut'][] = 'openall'; // For backward compatibility // Initialize array of search criterias -$search_all=trim(GETPOSTISSET("search_all")?GETPOSTISSET("search_all", 'alpha'):GETPOST('sall')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOSTISSET("search_all") ?GETPOSTISSET("search_all", 'alpha') : GETPOST('sall')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -145,11 +145,11 @@ if ($project_ref) * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -158,24 +158,24 @@ if (empty($reshook)) 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 + 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Ticket'; - $objectlabel='Ticket'; + $objectclass = 'Ticket'; + $objectlabel = 'Ticket'; $permissiontoread = $user->rights->ticket->read; $permissiontodelete = $user->rights->ticket->delete; $uploaddir = $conf->ticket->dir_output; @@ -188,10 +188,10 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); $formTicket = new FormTicket($db); -$now=dol_now(); +$now = dol_now(); $user_assign = new User($db); $user_create = new User($db); @@ -204,63 +204,63 @@ $title = $langs->trans('TicketList'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)"; -$sql.= " WHERE t.entity IN (".getEntity($object->element).")"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)"; +$sql .= " WHERE t.entity IN (".getEntity($object->element).")"; if ($socid > 0) { - $sql.= " AND t.fk_soc = ".$socid; + $sql .= " AND t.fk_soc = ".$socid; } -foreach($search as $key => $val) +foreach ($search as $key => $val) { if ($key == 'fk_statut') { - $tmpstatus=''; - if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) $tmpstatus.=($tmpstatus?',':'')."'".Ticket::STATUS_NOT_READ."', '".Ticket::STATUS_READ."', '".Ticket::STATUS_ASSIGNED."', '".Ticket::STATUS_IN_PROGRESS."', '".Ticket::STATUS_NEED_MORE_INFO."', '".Ticket::STATUS_WAITING."'"; - if ($search['fk_statut'] == 'closeall' || in_array('closeall', $search['fk_statut'])) $tmpstatus.=($tmpstatus?',':'')."'".Ticket::STATUS_CLOSED."', '".Ticket::STATUS_CANCELED."'"; - if ($tmpstatus) $sql.=" AND fk_statut IN (".$tmpstatus.")"; - elseif (is_array($search[$key]) && count($search[$key])) $sql.=natural_search($key, join(',', $search[$key]), 2); + $tmpstatus = ''; + if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) $tmpstatus .= ($tmpstatus ? ',' : '')."'".Ticket::STATUS_NOT_READ."', '".Ticket::STATUS_READ."', '".Ticket::STATUS_ASSIGNED."', '".Ticket::STATUS_IN_PROGRESS."', '".Ticket::STATUS_NEED_MORE_INFO."', '".Ticket::STATUS_WAITING."'"; + if ($search['fk_statut'] == 'closeall' || in_array('closeall', $search['fk_statut'])) $tmpstatus .= ($tmpstatus ? ',' : '')."'".Ticket::STATUS_CLOSED."', '".Ticket::STATUS_CANCELED."'"; + if ($tmpstatus) $sql .= " AND fk_statut IN (".$tmpstatus.")"; + elseif (is_array($search[$key]) && count($search[$key])) $sql .= natural_search($key, join(',', $search[$key]), 2); continue; } if ($key == 'fk_user_assign') { - if ($search[$key] > 0) $sql.=natural_search($key, $search[$key], 2); + if ($search[$key] > 0) $sql .= natural_search($key, $search[$key], 2); continue; } - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], $mode_search); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], $mode_search); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_fk_project) $sql.= natural_search('fk_project', $search_fk_project, 2); -if (! $user->socid && ($mode == "mine" || (!$user->admin && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY))) { - $sql.= " AND (t.fk_user_assign = ".$user->id; - if (empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) $sql.=" OR t.fk_user_create = ".$user->id; - $sql.=")"; +if ($search_fk_project) $sql .= natural_search('fk_project', $search_fk_project, 2); +if (!$user->socid && ($mode == "mine" || (!$user->admin && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY))) { + $sql .= " AND (t.fk_user_assign = ".$user->id; + if (empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) $sql .= " OR t.fk_user_create = ".$user->id; + $sql .= ")"; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -281,10 +281,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -294,7 +294,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -309,12 +309,12 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader('', $title, $help_url); -if ($socid && ! $projectid && ! $project_ref && $user->rights->societe->lire) { +if ($socid && !$projectid && !$project_ref && $user->rights->societe->lire) { $socstat = new Societe($db); $res = $socstat->fetch($socid); if ($res > 0) { $tmpobject = $object; - $object = $socstat; // $object must be of type Societe when calling societe_prepare_head + $object = $socstat; // $object must be of type Societe when calling societe_prepare_head $head = societe_prepare_head($socstat); $object = $tmpobject; @@ -330,10 +330,10 @@ if ($socid && ! $projectid && ! $project_ref && $user->rights->societe->lire) { // Customer code if ($socstat->client && !empty($socstat->code_client)) { print '<tr><td class="titlefield">'; - print $langs->trans('CustomerCode') . '</td><td>'; + print $langs->trans('CustomerCode').'</td><td>'; print $socstat->code_client; if ($socstat->check_codeclient() != 0) { - print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>'; + print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; } print '</td>'; @@ -342,10 +342,10 @@ if ($socid && ! $projectid && ! $project_ref && $user->rights->societe->lire) { // Supplier code if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) { print '<tr><td class="titlefield">'; - print $langs->trans('SupplierCode') . '</td><td>'; + print $langs->trans('SupplierCode').'</td><td>'; print $socstat->code_fournisseur; if ($socstat->check_codefournisseur() != 0) { - print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>'; + print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; } print '</td>'; @@ -380,21 +380,21 @@ if ($projectid > 0 || $project_ref) { $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; - $morehtmlref='<div class="refidno">'; + $morehtmlref = '<div class="refidno">'; // Title - $morehtmlref.=$object->title; + $morehtmlref .= $object->title; // Thirdparty if ($object->thirdparty->id > 0) { - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } - $morehtmlref.='</div>'; + $morehtmlref .= '</div>'; // Define a complementary filter for search of next/prev ref. - if (! $user->rights->projet->all->lire) + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")"; + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -405,7 +405,7 @@ if ($projectid > 0 || $project_ref) { print '<table class="border tableforfield" width="100%">'; // Visibility - print '<tr><td class="titlefield">' . $langs->trans("Visibility") . '</td><td>'; + print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; if ($projectstat->public) { print $langs->trans('SharedProject'); } else { @@ -424,30 +424,30 @@ if ($projectid > 0 || $project_ref) { } } -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); - else $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -if ($socid) $param.='&socid='.urlencode($socid); -if ($projectid) $param.='&projectid='.urlencode($projectid); +if ($socid) $param .= '&socid='.urlencode($socid); +if ($projectid) $param .= '&projectid='.urlencode($projectid); // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->ticket->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->ticket->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -458,12 +458,12 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; -print '<input type="hidden" name="mode" value="' . $mode . '" >'; -if ($socid) print '<input type="hidden" name="socid" value="' . $socid . '" >'; -if ($projectid) print '<input type="hidden" name="projectid" value="' . $projectid . '" >'; +print '<input type="hidden" name="mode" value="'.$mode.'" >'; +if ($socid) print '<input type="hidden" name="socid" value="'.$socid.'" >'; +if ($projectid) print '<input type="hidden" name="projectid" value="'.$projectid.'" >'; -$newcardbutton=''; -$newcardbutton.= dolGetButtonTitle($langs->trans('NewTicket'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/ticket/card.php?action=create' . ($socid ? '&socid=' . $socid : '') . ($projectid ? '&origin=projet_project&originid=' . $projectid : ''), '', !empty($user->rights->ticket->write)); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('NewTicket'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/ticket/card.php?action=create'.($socid ? '&socid='.$socid : '').($projectid ? '&origin=projet_project&originid='.$projectid : ''), '', !empty($user->rights->ticket->write)); $picto = 'ticket'; if ($socid > 0) $picto = ''; @@ -471,19 +471,19 @@ if ($socid > 0) $picto = ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton, '', $limit); if ($mode == 'mine') { - print '<div class="opacitymedium">' . $langs->trans('TicketAssignedToMeInfos') . '</div><br>'; + print '<div class="opacitymedium">'.$langs->trans('TicketAssignedToMeInfos').'</div><br>'; } // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendTicketRef"; -$modelmail="ticket"; -$objecttmp=new Ticket($db); -$trackid='tick'.$object->id; +$topicmail = "SendTicketRef"; +$modelmail = "ticket"; +$objecttmp = new Ticket($db); +$trackid = 'tick'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; @@ -491,62 +491,62 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'fk_statut') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) { + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'fk_statut') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { if ($key == 'type_code') { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'">'; - $formTicket->selectTypesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; + $formTicket->selectTypesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); print '</td>'; } elseif ($key == 'category_code') { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'">'; - $formTicket->selectGroupTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; + $formTicket->selectGroupTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); print '</td>'; } elseif ($key == 'severity_code') { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'">'; - $formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; + $formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); print '</td>'; } elseif ($key == 'fk_user_assign') { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'">'; - print $form->select_dolusers($search[$key], 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css']?$val['css']:'maxwidth150')); + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; + print $form->select_dolusers($search[$key], 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth150')); print '</td>'; } elseif ($key == 'fk_statut') { $arrayofstatus = array(); - $arrayofstatus['openall']='-- '.$langs->trans('OpenAll').' --'; + $arrayofstatus['openall'] = '-- '.$langs->trans('OpenAll').' --'; foreach ($object->statuts_short as $key2 => $val2) { $arrayofstatus[$key2] = $val2; - if ($key2 == '6') $arrayofstatus['closeall']='-- '.$langs->trans('ClosedAll').' --'; + if ($key2 == '6') $arrayofstatus['closeall'] = '-- '.$langs->trans('ClosedAll').' --'; } - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'">'; + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; //var_dump($arrayofstatus);var_dump($search['fk_statut']);var_dump(array_values($search[$key])); $selectedarray = null; if ($search[$key]) $selectedarray = array_values($search[$key]); @@ -555,10 +555,10 @@ foreach($object->fields as $key => $val) } elseif ($key == "fk_soc") { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'"><input type="text" class="flat maxwidth75" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>'; + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>'; } else { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; } } } @@ -566,12 +566,12 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$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 '<td class="liste_titre maxwidthsearch">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -580,51 +580,51 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'fk_statut') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'fk_statut') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, '', $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, '', $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ')."\n"; print '</tr>'."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } @@ -632,14 +632,14 @@ while ($i < min($num, $limit)) // Show here line of result print '<tr class="oddeven">'; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - if ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowraponall'; - if ($key == 'fk_statut') $cssforfield.=($cssforfield?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall'; + if ($key == 'fk_statut') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'; if ($cssforfield || $val['css']) print ' class="'; @@ -653,13 +653,13 @@ while ($i < min($num, $limit)) elseif ($key == 'severity_code') print $langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label'); elseif ($key == 'type_code') print $langs->getLabelFromKey($db, $object->type_code, 'c_ticket_type', 'code', 'label'); elseif ($key == 'tms') print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print '</td>'; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -667,19 +667,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'; @@ -693,16 +693,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -714,19 +714,19 @@ print '</form>'."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->ticket->read; - $delallowed=$user->rights->ticket->write; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->ticket->read; + $delallowed = $user->rights->ticket->write; print $formfile->showdocuments('massfilesarea_ticket', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/zapier/hook_list.php b/htdocs/zapier/hook_list.php index 21e9c991d07..a49c0655b80 100644 --- a/htdocs/zapier/hook_list.php +++ b/htdocs/zapier/hook_list.php @@ -42,19 +42,19 @@ //if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL',1); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -62,24 +62,24 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once __DIR__.'/class/hook.class.php'; // Load translation files required by the page -$langs->loadLangs(array("mymodule@mymodule","other")); +$langs->loadLangs(array("mymodule@mymodule", "other")); // The action 'add', 'create', 'edit', 'update', 'view', ... -$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The bulk action (combo box choice into lists) $massaction = GETPOST('massaction', 'alpha'); -$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'):'hooklist'; // 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') +$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') : 'hooklist'; // 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') $id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -96,7 +96,7 @@ $pagenext = $page + 1; // Initialize technical objects $object = new Hook($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; // Note that conf->hooks_modules contains array $hookmanager->initHooks(array('hooklist')); @@ -106,16 +106,16 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) { +if (!$sortfield) { // Set here default search field. By default 1st field in definition. - $sortfield="t.".key($object->fields); + $sortfield = "t.".key($object->fields); } -if (! $sortorder) { - $sortorder="ASC"; +if (!$sortorder) { + $sortorder = "ASC"; } // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; @@ -124,29 +124,29 @@ if ($user->socid > 0) { //$result = restrictedArea($user, 'mymodule', $id, ''); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; +foreach ($object->fields as $key => $val) { + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) { +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields 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 => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -159,15 +159,15 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ if (GETPOST('cancel', 'alpha')) { - $action='list'; - $massaction=''; + $action = 'list'; + $massaction = ''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $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 +$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)) { @@ -175,22 +175,22 @@ if (empty($reshook)) { 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')) { + 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 - foreach($object->fields as $key => $val) { - $search[$key]=''; + foreach ($object->fields as $key => $val) { + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Hook'; - $objectlabel='Hook'; + $objectclass = 'Hook'; + $objectlabel = 'Hook'; $permissiontoread = $user->rights->mymodule->read; $permissiontodelete = $user->rights->mymodule->delete; $uploaddir = $conf->mymodule->dir_output; @@ -203,57 +203,57 @@ if (empty($reshook)) { * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_Hook|FR:Module_Hook_FR|ES:Módulo_Hook"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Hooks")); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) { - $sql.='t.'.$key.', '; +foreach ($object->fields as $key => $val) { + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); } } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; if ($object->ismultientitymanaged == 1) { - $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; } else { - $sql.=" WHERE 1 = 1"; + $sql .= " WHERE 1 = 1"; } -foreach($search as $key => $val) { +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) { continue; } - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if ($search[$key] != '') { - $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } } if ($search_all) { - $sql.= natural_search(array_keys($fieldstosearchall), $search_all); + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -271,7 +271,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -288,10 +288,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) { + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; } @@ -300,7 +300,7 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".dol_buildpath('/zapierfordolibarr/hook_card.php', 1).'?id='.$id); @@ -328,32 +328,32 @@ jQuery(document).ready(function() { }); </script>'; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) { +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { - foreach($search[$key] as $skey) { - $param.='&search_'.$key.'[]='.urlencode($skey); + foreach ($search[$key] as $skey) { + $param .= '&search_'.$key.'[]='.urlencode($skey); } } else { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param .= '&search_'.$key.'='.urlencode($search[$key]); } } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -365,12 +365,12 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; -$newcardbutton=''; +$newcardbutton = ''; //if ($user->rights->mymodule->creer) //{ - $newcardbutton='<a class="butActionNew" href="hook_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).'"><span class="valignmiddle text-plus-circle">'.$langs->trans('New').'</span>'; - $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; - $newcardbutton.= '</a>'; + $newcardbutton = '<a class="butActionNew" href="hook_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).'"><span class="valignmiddle text-plus-circle">'.$langs->trans('New').'</span>'; + $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>'; + $newcardbutton .= '</a>'; //} //else //{ @@ -382,15 +382,15 @@ $newcardbutton=''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendHookRef"; -$modelmail="hook"; -$objecttmp=new Hook($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendHookRef"; +$modelmail = "hook"; +$objecttmp = new Hook($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } $moreforfilter = ''; @@ -398,56 +398,56 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= '</div>';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) { +if (!empty($moreforfilter)) { print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; } -$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) : ''); +$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) : ''); -print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; +print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; // Fields title search // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) { - $cssforfield.=($cssforfield?' ':'').'center'; +foreach ($object->fields as $key => $val) { + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } if (in_array($val['type'], array('timestamp'))) { - $cssforfield.=($cssforfield?' ':'').'nowrap'; + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) { - $cssforfield.=($cssforfield?' ':'').'right'; + $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if ($key == 'status') { - $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - if (! empty($arrayfields['t.'.$key]['checked'])) { - print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; + if (!empty($arrayfields['t.'.$key]['checked'])) { + print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$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 '<td class="liste_titre right">'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '</td>'; print '</tr>'."\n"; @@ -456,16 +456,16 @@ print '</tr>'."\n"; // Fields title label // -------------------------------------------------------------------- print '<tr class="liste_titre">'; -foreach($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield.=($cssforfield?' ':'').'right'; +foreach ($object->fields as $key => $val) { + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; if ($key == 'status') { - $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - if (! empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + if (!empty($arrayfields['t.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields @@ -477,7 +477,7 @@ $parameters = array( 'sortfield' => $sortfield, 'sortorder' => $sortorder, ); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -485,7 +485,7 @@ print '</tr>'."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { @@ -498,36 +498,36 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); if (empty($obj)) { - break; // Should not happen + break; // Should not happen } // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) { + foreach ($object->fields as $key => $val) { if (isset($obj->$key)) $object->$key = $obj->$key; } // Show here line of result print '<tr class="oddeven">'; - foreach($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) { - $cssforfield.=($cssforfield?' ':'').'center'; + foreach ($object->fields as $key => $val) { + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif ($key == 'status') { - $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) { + if (!empty($arrayfields['t.'.$key]['checked'])) { print '<td'; if ($cssforfield || $val['css']) print ' class="'; print $cssforfield; @@ -536,13 +536,13 @@ while ($i < min($num, $limit)) { if ($cssforfield || $val['css']) print '"'; print '>'; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print '</td>'; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -550,19 +550,19 @@ while ($i < min($num, $limit)) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print '<td class="nowrap center">'; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; } print '</td>'; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print '</tr>'; @@ -575,9 +575,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { - if (! empty($val['checked'])) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { $colspan++; } } @@ -591,7 +591,7 @@ $parameters = array( 'arrayfields' => $arrayfields, 'sql' => $sql, ); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '</table>'."\n"; @@ -600,21 +600,21 @@ print '</div>'."\n"; print '</form>'."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; + $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 0; } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->mymodule->read; + $delallowed = $user->rights->mymodule->create; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } From df03041dbade0a4dc740238b89e1e5b9a18c7218 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 09:47:39 +0100 Subject: [PATCH 184/299] Fix phpcs --- htdocs/main.inc.php | 2 +- htdocs/mrp/class/mo.class.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 590f78437b4..4bbd4fe471a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -612,7 +612,7 @@ if (! defined('NOLOGIN')) if (! $login || (in_array('ldap', $authmode) && empty($passwordtotest))) // With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success. { // No data to test login, so we show the login page - dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." - action=".GETPOST('action','aZ09').", showing the login form and exit"); + dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." - action=".GETPOST('action', 'aZ09').", showing the login form and exit"); if (defined('NOREDIRECTBYMAINTOLOGIN')) return 'ERROR_NOT_LOGGED'; else dol_loginfunction($langs, $conf, (! empty($mysoc)?$mysoc:'')); exit; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index c4f0b6d4e83..725427e249f 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -809,7 +809,8 @@ class Mo extends CommonObject } else { - + // If origin BOM line is not a product, but another BOM + // TODO } $this->tpl['qty'] = $line->qty; From c02cd80b75a02df13fa2aa728c6676975e53025a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 10:11:30 +0100 Subject: [PATCH 185/299] Clean code --- htdocs/accountancy/bookkeeping/card.php | 4 ++-- .../class/accountancycategory.class.php | 6 ++++++ htdocs/comm/propal/class/propal.class.php | 4 ++-- htdocs/commande/class/commande.class.php | 8 ++++---- htdocs/compta/facture/class/facture.class.php | 5 +++-- .../class/expensereport.class.php | 5 ++--- htdocs/reception/card.php | 2 +- htdocs/societe/class/societe.class.php | 7 +++---- htdocs/takepos/invoice.php | 4 ++-- htdocs/ticket/class/ticket.class.php | 9 ++++++++- .../variants/class/ProductAttribute.class.php | 10 +++++----- .../class/ProductAttributeValue.class.php | 10 +++++----- .../class/ProductCombination.class.php | 14 ++++++------- .../ProductCombination2ValuePair.class.php | 10 +++++----- htdocs/webservices/server_invoice.php | 20 +++++++++---------- 15 files changed, 65 insertions(+), 53 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 80c9ffb7792..7a8a6612d4b 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -536,11 +536,11 @@ if ($action == 'create') print '<td class="titlefield">' . $langs->trans("Status") . '</td>'; print '<td>'; if (empty($object->validated)) { - print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=enable">'; + print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=enable">'; print img_picto($langs->trans("Disabled"), 'switch_off'); print '</a>'; } else { - print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=disable">'; + print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=disable">'; print img_picto($langs->trans("Activated"), 'switch_on'); print '</a>'; } diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index d68c9fa54a7..5e99f3fc4a6 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -57,6 +57,12 @@ class AccountancyCategory // extends CommonObject */ public $table_element='c_accounting_category'; + /** + * @var int ID + * @deprecated + */ + public $rowid; + /** * @var int ID */ diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3c0765830d6..27d876320c2 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -631,7 +631,7 @@ class Propal extends CommonObject if ($result > 0) { $this->db->commit(); - return $this->line->rowid; + return $this->line->id; } else { @@ -772,7 +772,7 @@ class Propal extends CommonObject $this->line->rang = $rangmax + 1; } - $this->line->rowid = $rowid; + $this->line->id = $rowid; $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = $qty; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6e01ba2f5e2..54ad29d32f4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1565,7 +1565,7 @@ class Commande extends CommonOrder if ($result > 0) { $this->db->commit(); - return $this->line->rowid; + return $this->line->id; } else { @@ -3104,7 +3104,7 @@ class Commande extends CommonOrder $this->line->rang = $rangmax + 1; } - $this->line->rowid=$rowid; + $this->line->id=$rowid; $this->line->label=$label; $this->line->desc=$desc; $this->line->qty=$qty; @@ -4267,11 +4267,11 @@ class OrderLine extends CommonOrderLine $resql=$this->db->query($sql); if ($resql) { - $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet'); + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet'); + $this->rowid = $this->id; if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $this->id=$this->rowid; $result=$this->insertExtraFields(); if ($result < 0) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index df41f2e5595..2ac89f1dace 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1175,7 +1175,7 @@ class Facture extends CommonInvoice $this->availability_id = $object->availability_id; $this->demand_reason_id = $object->demand_reason_id; $this->date_livraison = $object->date_livraison; - $this->fk_delivery_address = $object->fk_delivery_address; + $this->fk_delivery_address = $object->fk_delivery_address; // deprecated $this->contact_id = $object->contactid; $this->ref_client = $object->ref_client; @@ -2016,7 +2016,7 @@ class Facture extends CommonInvoice $list_rowid_det = array(); foreach ($this->lines as $key => $invoiceline) { - $list_rowid_det[] = $invoiceline->rowid; + $list_rowid_det[] = $invoiceline->id; } // Consumned discounts are freed @@ -3133,6 +3133,7 @@ class Facture extends CommonInvoice $this->line->rang = $rangmax + 1; } + $this->line->id = $rowid; $this->line->rowid = $rowid; $this->line->label = $label; $this->line->desc = $desc; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 91c69b0f3b3..ad21603efce 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1800,7 +1800,7 @@ class ExpenseReport extends CommonObject if ($result > 0) { $this->db->commit(); - return $this->line->rowid; + return $this->line->id; } else { @@ -2049,7 +2049,6 @@ class ExpenseReport extends CommonObject $this->line->fk_ecm_files = $fk_ecm_files; - $this->line->rowid = $rowid; $this->line->id = $rowid; // Select des infos sur le type fees @@ -2660,7 +2659,7 @@ class ExpenseReportLine $resql=$this->db->query($sql); if ($resql) { - $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'expensereport_det'); + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'expensereport_det'); if (! $fromaddline) { diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index cc4fad1cb60..d76ee06ab5a 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1031,7 +1031,7 @@ if ($action == 'create') //var_dump($product->stock_warehouse[1]); print '<td>'; - print '<a name="'.$line->rowid.'"></a>'; // ancre pour retourner sur la ligne + print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne // Show product and description $product_static->type = $line->fk_product_type; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e73a060af40..027527d20d7 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4176,10 +4176,9 @@ class Societe extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_commerciaux '; $sql .= ' WHERE fk_soc = '.(int) $origin_id.') '; - $query = $db->query($sql); - - while ($result = $db->fetch_object($query)) { - $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.$result->rowid); + $resql = $db->query($sql); + while ($obj = $db->fetch_object($resql)) { + $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.$obj->rowid); } /** diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 3e26bec7ce4..60664b99b19 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -399,7 +399,7 @@ if ($action == "order" and $placeid != 0) $result = array_intersect($catsprinter1, $existing); $count = count($result); if ($count > 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=$line->rowid"; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=".$line->id; $db->query($sql); $order_receipt_printer1 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty; if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer1 .= "<br>(".$line->array_options['options_order_notes'].")"; @@ -416,7 +416,7 @@ if ($action == "order" and $placeid != 0) $result = array_intersect($catsprinter2, $existing); $count = count($result); if ($count > 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=$line->rowid"; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=".$line->id; $db->query($sql); $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty; if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer2 .= "<br>(".$line->array_options['options_order_notes'].")"; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index d606fc1716c..5784fc22a3e 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -662,6 +662,7 @@ class Ticket extends CommonObject $line = new TicketsLine(); + $line->id = $obj->rowid; $line->rowid = $obj->rowid; $line->ref = $obj->ref; $line->track_id = $obj->track_id; @@ -2783,7 +2784,13 @@ class Ticket extends CommonObject */ class TicketsLine { - /** + /** + * @var int ID + * @deprecated + */ + public $rowid; + + /** * @var int ID */ public $id; diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index 139c919bb18..1172d08f74d 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -86,12 +86,12 @@ class ProductAttribute return -1; } - $result = $this->db->fetch_object($query); + $obj = $this->db->fetch_object($query); - $this->id = $result->rowid; - $this->ref = $result->ref; - $this->label = $result->label; - $this->rang = $result->rang; + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->label = $obj->label; + $this->rang = $obj->rang; return 1; } diff --git a/htdocs/variants/class/ProductAttributeValue.class.php b/htdocs/variants/class/ProductAttributeValue.class.php index e2a99de90d2..0a26b3eace2 100644 --- a/htdocs/variants/class/ProductAttributeValue.class.php +++ b/htdocs/variants/class/ProductAttributeValue.class.php @@ -85,12 +85,12 @@ class ProductAttributeValue return -1; } - $result = $this->db->fetch_object($query); + $obj = $this->db->fetch_object($query); - $this->id = $result->rowid; - $this->fk_product_attribute = $result->fk_product_attribute; - $this->ref = $result->ref; - $this->value = $result->value; + $this->id = $obj->rowid; + $this->fk_product_attribute = $obj->fk_product_attribute; + $this->ref = $obj->ref; + $this->value = $obj->value; return 1; } diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 4849c44c898..4dfd40a8f53 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -104,14 +104,14 @@ class ProductCombination return -1; } - $result = $this->db->fetch_object($query); + $obj = $this->db->fetch_object($query); - $this->id = $result->rowid; - $this->fk_product_parent = $result->fk_product_parent; - $this->fk_product_child = $result->fk_product_child; - $this->variation_price = $result->variation_price; - $this->variation_price_percentage = $result->variation_price_percentage; - $this->variation_weight = $result->variation_weight; + $this->id = $obj->rowid; + $this->fk_product_parent = $obj->fk_product_parent; + $this->fk_product_child = $obj->fk_product_child; + $this->variation_price = $obj->variation_price; + $this->variation_price_percentage = $obj->variation_price_percentage; + $this->variation_weight = $obj->variation_weight; return 1; } diff --git a/htdocs/variants/class/ProductCombination2ValuePair.class.php b/htdocs/variants/class/ProductCombination2ValuePair.class.php index 4931efe54d5..e8ebbf57afd 100644 --- a/htdocs/variants/class/ProductCombination2ValuePair.class.php +++ b/htdocs/variants/class/ProductCombination2ValuePair.class.php @@ -128,12 +128,12 @@ class ProductCombination2ValuePair $return = array(); - while ($result = $this->db->fetch_object($query)) { + while ($obj = $this->db->fetch_object($query)) { $tmp = new ProductCombination2ValuePair($this->db); - $tmp->fk_prod_attr_val = $result->fk_prod_attr_val; - $tmp->fk_prod_attr = $result->fk_prod_attr; - $tmp->fk_prod_combination = $result->fk_prod_combination; - $tmp->id = $result->rowid; + $tmp->fk_prod_attr_val = $obj->fk_prod_attr_val; + $tmp->fk_prod_attr = $obj->fk_prod_attr; + $tmp->fk_prod_combination = $obj->fk_prod_combination; + $tmp->id = $obj->rowid; $return[] = $tmp; } diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 5e5163a71b6..f4d0762e3e1 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -322,7 +322,7 @@ function getInvoice($authentication, $id = '', $ref = '', $ref_ext = '') { //var_dump($line); exit; $linesresp[]=array( - 'id'=>$line->rowid, + 'id'=>$line->id, 'type'=>$line->product_type, 'desc'=>dol_htmlcleanlastbr($line->desc), 'total_net'=>$line->total_ht, @@ -458,17 +458,17 @@ function getInvoicesForThirdParty($authentication, $idthirdparty) foreach($invoice->lines as $line) { $linesresp[]=array( - 'id'=>$line->rowid, - 'type'=>$line->product_type, - 'total_net'=>$line->total_ht, - 'total_vat'=>$line->total_tva, - 'total'=>$line->total_ttc, + 'id'=>$line->id, + 'type'=>$line->product_type, + 'total_net'=>$line->total_ht, + 'total_vat'=>$line->total_tva, + 'total'=>$line->total_ttc, 'vat_rate'=>$line->tva_tx, 'qty'=>$line->qty, - 'unitprice'=> $line->subprice, - 'date_start'=> $line->date_start?dol_print_date($line->date_start, 'dayrfc'):'', - 'date_end'=> $line->date_end?dol_print_date($line->date_end, 'dayrfc'):'', - 'product_id'=>$line->fk_product, + 'unitprice'=> $line->subprice, + 'date_start'=> $line->date_start?dol_print_date($line->date_start, 'dayrfc'):'', + 'date_end'=> $line->date_end?dol_print_date($line->date_end, 'dayrfc'):'', + 'product_id'=>$line->fk_product, 'product_ref'=>$line->product_ref, 'product_label'=>$line->product_label, 'product_desc'=>$line->product_desc, From 3430a88c72a9381998be62108d2df642890da342 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 10:13:22 +0100 Subject: [PATCH 186/299] Fix $conf not defined --- htdocs/comm/propal/class/propal.class.php | 6 +++--- htdocs/compta/facture/class/facture.class.php | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 27d876320c2..ac5b35eef44 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1301,9 +1301,9 @@ class Propal extends CommonObject if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $object->ref_client = ''; if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) { - $object->note_private = ''; - $object->note_public = ''; - } + $object->note_private = ''; + $object->note_public = ''; + } // Create clone $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2ac89f1dace..0ce2930840f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1006,7 +1006,7 @@ class Facture extends CommonInvoice */ public function createFromClone(User $user, $fromid = 0) { - global $hookmanager; + global $conf, $hookmanager; $error = 0; @@ -1048,11 +1048,10 @@ class Facture extends CommonInvoice $object->close_code = ''; $object->close_note = ''; $object->products = $object->lines; // For backward compatibility - if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) - { - $object->note_private = ''; - $object->note_public = ''; - } + if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) { + $object->note_private = ''; + $object->note_public = ''; + } // Loop on each line of new invoice foreach ($object->lines as $i => $line) From f65ce1d5d0a2b60c907ee9abce12b49437d6ac27 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 10:17:46 +0100 Subject: [PATCH 187/299] Fix var not declared --- htdocs/admin/sms.php | 3 --- htdocs/core/class/html.formsms.class.php | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index 5536424e939..ce4161ea147 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -309,13 +309,10 @@ else $formsms->withfromreadonly=0; $formsms->withsubstit=0; $formsms->withfrom=1; - $formsms->witherrorsto=1; $formsms->withto=(isset($_POST['sendto'])?$_POST['sendto']:$user->user_mobile?$user->user_mobile:1); - $formsms->withfile=2; $formsms->withbody=(isset($_POST['message'])?(empty($_POST['message'])?1:$_POST['message']):$langs->trans("ThisIsATestMessage")); $formsms->withbodyreadonly=0; $formsms->withcancel=1; - $formsms->withfckeditor=0; // Tableau des substitutions $formsms->substit=$substitutionarrayfortest; // Tableau des parametres complementaires du post diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index 78ecefb87e0..3b949814691 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -38,8 +38,10 @@ class FormSms */ public $db; + public $fromid; public $fromname; public $fromsms; + public $fromtype; public $replytoname; public $replytomail; public $toname; From 528823140daae4fb0a18dab4f72a2106f65de560 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 12:05:06 +0100 Subject: [PATCH 188/299] Fix phpcs --- htdocs/core/class/interfaces.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 0d1ab36ce14..304a7a248a3 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -164,7 +164,7 @@ class Interfaces } } - closedir($handle); + closedir($handle); } } From c4a6108acf2322d45df3e73c2068258f6a4acd7c Mon Sep 17 00:00:00 2001 From: Daniel Seichter <daniel.seichter@erpware.de> Date: Tue, 12 Nov 2019 12:49:38 +0100 Subject: [PATCH 189/299] #12408 using MAIN_DURATION_OF_WORKDAY during creation of invoices --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index fa7efdfa2a5..54736ebc40f 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -390,7 +390,7 @@ if ($action == 'confirm_generateinvoice') // Define qty per hour $qtyhour = round($value['timespent'] / 3600, 2); - $qtyhourtext = convertSecondToTime($value['timespent']); + $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); // If no unit price known if (empty($pu_ht)) From 4f3d4950e1ba0439fc73a6e59f000753d82ca56d Mon Sep 17 00:00:00 2001 From: andreubisquerra <jove@bisquerra.com> Date: Tue, 12 Nov 2019 13:01:16 +0100 Subject: [PATCH 190/299] Check if draft exists in TakePOS customer list Check if draft invoice already exists, if not create it --- htdocs/societe/list.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index afd4c89aab5..bbe9f6a9424 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -231,7 +231,25 @@ if ($action == "change") // Change customer for TakePOS $idcustomer = GETPOST('idcustomer', 'int'); $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant - // @TODO Check if draft invoice already exists, if not create it or return a warning to ask to enter at least one line to have it created automatically + // Check if draft invoice already exists, if not create it + $sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'facture + where ref=\'(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')\' + AND entity IN ('.getEntity('invoice').')'; + $result = $db->query($sql); + $num_lines = $db->num_rows($result); + if ($num_lines==0) + { + require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + $invoice = new Facture($db); + $invoice->socid = $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}; + $invoice->date = dol_now(); + $invoice->module_source = 'takepos'; + $invoice->pos_source = $_SESSION["takeposterminal"]; + $placeid =$invoice->create($user); + $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; + $db->query($sql); + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); ?> From 2c718af26cf2676e8c5fd3982529dfd81589c0e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 13:55:46 +0100 Subject: [PATCH 191/299] Missing container type 'menu' Fix: Add security if container is not a page --- htdocs/core/website.inc.php | 10 +++++++++- htdocs/install/mysql/data/llx_c_type_container.sql | 1 + htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 2 ++ htdocs/langs/en_US/website.lang | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index f7908844afc..34c011c34ca 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2017-2018 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2017-2019 Laurent Destailleur <eldy@users.sourceforge.net> * * 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 @@ -51,6 +51,14 @@ if (! is_object($websitepage)) if ($pageid > 0) { $websitepage->fetch($pageid); + + if (! defined('USEDOLIBARREDITOR') && in_array($websitepage->type_container, array('menu', 'other'))) + { + $weblangs->load("website"); + http_response_code(404); + print '<center><br><br>'.$weblangs->trans("YouTryToAccessToAFileThatIsNotAWebsitePage").'</center>'; + exit; + } } // A lang was forced, so we change weblangs init diff --git a/htdocs/install/mysql/data/llx_c_type_container.sql b/htdocs/install/mysql/data/llx_c_type_container.sql index 949f0bad687..703d8f2ac34 100644 --- a/htdocs/install/mysql/data/llx_c_type_container.sql +++ b/htdocs/install/mysql/data/llx_c_type_container.sql @@ -33,5 +33,6 @@ insert into llx_c_type_container (code,label,module,active) values ('page', 'Page', 'system', 1); insert into llx_c_type_container (code,label,module,active) values ('banner', 'Banner', 'system', 1); insert into llx_c_type_container (code,label,module,active) values ('blogpost', 'BlogPost', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('menu', 'Menu', 'system', 1); insert into llx_c_type_container (code,label,module,active) values ('other', 'Other', 'system', 1); diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index e5712cc262f..9c52044291d 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -51,6 +51,8 @@ ALTER TABLE llx_adherent_type ADD UNIQUE INDEX uk_adherent_type_libelle (libelle -- For v11 +insert into llx_c_type_container (code,label,module,active) values ('menu', 'Menu', 'system', 1); + INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('HELP', '15', 'Request for functionnal help', 1, 0, NULL); ALTER TABLE llx_don ADD COLUMN fk_user_modif integer; diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 62ce5a23531..116b500fb7d 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -118,4 +118,5 @@ EditInLineOnOff=Mode 'Edit inline' is %s ShowSubContainersOnOff=Mode to execute 'dynamic content' is %s GlobalCSSorJS=Global CSS/JS/Header file of web site BackToHomePage=Back to home page... -TranslationLinks=Translation links \ No newline at end of file +TranslationLinks=Translation links +YouTryToAccessToAFileThatIsNotAWebsitePage=You try to access to a page that is not a website page \ No newline at end of file From 2c826d73bdda9bd939d2a173462fcbdc184158a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 14:07:56 +0100 Subject: [PATCH 192/299] Fix translation --- htdocs/website/index.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 3d80906003d..26199b90d0b 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3262,9 +3262,9 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print $langs->trans("SearchReplaceInto"); print '</div>'; print '<div class="tagtd">'; - print '<input type="checkbox" name="optioncontent" value="content"'.((!GETPOSTISSET('buttonreplacesitesearch') || GETPOST('optioncontent', 'aZ09')) ? ' checked' : '').'> '.$langs->trans("Content"); - print '<input type="checkbox" class="marginleftonly" name="optionmeta" value="meta"'.(GETPOST('optionmeta', 'aZ09') ? ' checked' : '').'> '.$langs->trans("Title").' | '.$langs->trans("Description").' | '.$langs->trans("Keywords"); - print '<input type="checkbox" class="marginleftonly" name="optionsitefiles" value="sitefiles"'.(GETPOST('optionsitefiles', 'aZ09') ? ' checked' : '').'> '.$langs->trans("GlobalCSSorJS"); + print '<input type="checkbox" class="marginleftonly" name="optioncontent" value="content"'.((!GETPOSTISSET('buttonreplacesitesearch') || GETPOST('optioncontent', 'aZ09')) ? ' checked' : '').'> '.$langs->trans("Content").'<br>'; + print '<input type="checkbox" class="marginleftonly" name="optionmeta" value="meta"'.(GETPOST('optionmeta', 'aZ09') ? ' checked' : '').'> '.$langs->trans("Title").' | '.$langs->trans("Description").' | '.$langs->trans("Keywords").'<br>'; + print '<input type="checkbox" class="marginleftonly" name="optionsitefiles" value="sitefiles"'.(GETPOST('optionsitefiles', 'aZ09') ? ' checked' : '').'> '.$langs->trans("GlobalCSSorJS").'<br>'; print '</div>'; print '</div>'; @@ -3327,7 +3327,9 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') if (get_class($answerrecord) == 'WebsitePage') { print '<tr>'; - print '<td>'.$langs->trans("Container").'</td>'; + print '<td>'.$langs->trans("Container").' - '; + print $langs->trans($answerrecord->type_container); // TODO Use label of container + print '</td>'; print '<td>'; print $answerrecord->getNomUrl(1); print ' <span class="opacitymedium">('.($answerrecord->title ? $answerrecord->title : $langs->trans("NoTitle")).')</span>'; @@ -3339,7 +3341,23 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') else { print '<tr>'; - print '<td>'.$answerrecord['type'].'</td>'; + print '<td>'; + + $translateofrecordtype = array( + 'website_csscontent'=>'WEBSITE_CSS_INLINE', + 'website_jscontent'=>'WEBSITE_JS_INLINE', + 'website_robotcontent'=>'WEBSITE_ROBOT', + 'website_htmlheadercontent'=>'WEBSITE_HTML_HEADER', + 'website_htaccess'=>'WEBSITE_HTACCESS', + 'website_readme'=>'WEBSITE_README', + 'website_manifestjson'=>'WEBSITE_MANIFEST_JSON' + ); + if (! empty($translateofrecordtype[$answerrecord['type']])) { + print $langs->trans($translateofrecordtype[$answerrecord['type']]); + } else { + print $answerrecord['type']; + } + print '</td>'; print '<td>'; $backtopageurl = $_SERVER["PHP_SELF"].'?action=replacesiteconfirm&searchstring='.urlencode($searchkey).'&optioncontent='.GETPOST('optioncontent', 'aZ09').'&optionmeta='.GETPOST('optionmeta', 'aZ09').'&optionsitefiles='.GETPOST('optionsitefiles', 'aZ09'); print '<a href="'.$_SERVER["PHP_SELF"].'?action=editcss&website='.$website->ref.'&backtopage='.urlencode($backtopageurl).'">'.$langs->trans("EditCss").'</a>'; From 34b832507959882da8c70467aea8d6fd551e95e5 Mon Sep 17 00:00:00 2001 From: andreubisquerra <jove@bisquerra.com> Date: Tue, 12 Nov 2019 14:21:49 +0100 Subject: [PATCH 193/299] Update list.php --- 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 bbe9f6a9424..a62dde1d79d 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -249,7 +249,7 @@ if ($action == "change") // Change customer for TakePOS $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; $db->query($sql); } - + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); ?> From bda512630a76c7d1a4f5e18cbddb16bb0d2c7299 Mon Sep 17 00:00:00 2001 From: Daniel Seichter <daniel.seichter@erpware.de> Date: Tue, 12 Nov 2019 15:55:40 +0100 Subject: [PATCH 194/299] extend .gitignore to not do versioning composer installed libraries --- .gitignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 6aa74f44ed0..fd10310671a 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,18 @@ htdocs/includes/bin/ htdocs/includes/composer/ /.pydevproject /dolibarr_genesis.mp4 +composer.phar +htdocs/includes/ckeditor/ +htdocs/includes/mike42/ +htdocs/includes/doctrine/ +htdocs/includes/jakub-onderka/ +htdocs/includes/phpoffice +htdocs/includes/sebastian/ +htdocs/includes/squizlabs/ +htdocs/includes/symfony/ +htdocs/includes/phpdocumentor/ +htdocs/includes/phpspec/ +htdocs/includes/phpunit/ +htdocs/includes/restler/ +htdocs/includes/tecnickcom/ +htdocs/includes/webmozart/ From 1153b81e6f6883a45719d5de149373b73cecfc91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 16:08:03 +0100 Subject: [PATCH 195/299] Update templates --- .../websites/website_template-corporate.zip | Bin 1721234 -> 1721252 bytes .../websites/website_template-stellar.zip | Bin 191327 -> 194363 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/htdocs/install/doctemplates/websites/website_template-corporate.zip b/htdocs/install/doctemplates/websites/website_template-corporate.zip index e86e11df2885d4590449673680bfd555722e92d4..01d984562cc35dfe45a4fbcee307779136c93baf 100644 GIT binary patch delta 18228 zcmZ_01z1~6w>FHsYY6V{?heHrio0u(;si>u;u@s5dy7kHi(7Fk?p~bY^3yzhu5;e^ ze1EP?_Py8Kv(}n5*~!c#YbQn67e&~kt1H36p+Nn4#HTwYqEo^CIdCyR4#wPn4xf`V zq5mA~Ibg0~{(xjA_&$i>0^S-@6KaUqY={W0cl<{RZu|{Bgz*B@IP^?)D+r;W<_QyX z$eJs!pt}hF5SraEV03XHXpjPC2@!(I7+`D(A+5N8Sduu<P*BP+V08sdGH?we5Up8W z0)_-)D#At*=B2>C6u6fH|56Z|Z6py(-$QI;^&t-Z0TIi6h%W`{r69i)l$V0qyxfOo zcmSaZe?}LAnDzOLj_(9P38WZG6cDr`iV=c>{ig%oJ8S3fNuZ!WFNG~JpBRkA3`7L` zu>dif^Iu`akw8d08y?!R3Q$n>FNNg~X^j<#+H7Nuk*5Grhg^#Rj|oB8Uol!lAn3;( zMhr3p8Ny*ca6ym(Kjt1b1j#C3Cc#3`f-)us-5(Tj=#JTZ=#Eue3z272VK<jTklqmX z1<M}<R=LK0f{0Xau-pDIh>C=h?+KCB2H<qO`GX={k8zq^k8xobA#zVbyw{MpHje@D z*oyzin!e%%L#%^CJMkdFY*z2WyN8T?glaEdvuZE?@d%`~crwB5KU85b0qq|V*b+>@ z@dretfeD(^z=Vl;5GIoV00Rg8MXtuyio=h_4+W(FmQ@5WAn+jt7hxoTJrn_|h>tBJ z4WhIA-~mMdpT!OxvB@~IXxT{?nzYo|ij|N}`C=y>YSs5}cDifyF?U!cfvg{y>O-hv z9XL7ru3X~dp;%9uLMawLM&Pq|$nWRdxVva-PTz^q%v({bk)yTDllxh~B$luhVXNjD zVqEjhgH4qH1fXs@4=G}%m6K<m(}T;?UwNP#1nId12FFvv=Wm*0wVLJ=*BDO+O~PXh zS6bEe!wW|y{_V}nYzW>tS3-DM!jJK#jv9k0#JY4tw_*0iT-~#Q&)c`u4{lF(wX4tL zCsXVQ;_P2N`q}D9x-nFqgs3|2ZZn;pZx{MJu8i5xi$LeCA(z%^$V8Qd2T2$5*u5?G z@OR&LuqaQvTC7TfxO9d=KLW36S-}1asip0wVE6~2aWs~$(2WPP3X};_5W^RR_=!UF zm`~0%&C7=>1ds3f#`#eXD>L%tjV3LRqMpCJjyN~CX|i@t3!3n>d!|*JvHnp#A+Yz^ zg%~Ap6am!shVxuzFCB<o-XGi@(ubRuc<ie2Q@4u`Bz9B2x~hot`*Hltcl>UiR0C90 zcTsIh!7pv(UfTf8t1^z3-KXhWXVm56rrkT*8-YC<gz@+tsLI=mnJFG6T+I|ORo=wM z*{B+^o-8^kbkx?+I^9F3X9>tlvXrtSgYChab^>u>g&?w+Ns#uwN0$hPGNywG5_UrR z2-*wq%!m^~k3kbfwUCWxC@FVip#G2<Z|-iG+jZT9i7!U%5x%sC_+wo!sB*^d^LBfi z)?yN?og#Y1f!JI?)r0m~K1~Z2Tx=o?1ub12<4_U2W`W#m8W!e4$987|Q5Yqw)jaNe zLQ2pl2egw8fRDfI4irB3y9v{gRQ8}kd-lHNNwW85LpqO$)p|)eMUIp=#Ofqv$pOw| z1Z}NBPj)b&hYu5d7n5aWmg+wB;MYR;8sT|<CeM8&DYU?Fu>l35M`{t>-YHSF+z*sY z6yyb^s8d(rA{>49O&w(Lj{aqhV{<DcAHRacOuI{C>U#5xvFh{MI1LkA^*j8&Ub&xq zOvz?`fTGb?h?NNPSO(PEI+oo3A`Vz!=y{fB1h?mG!>M=dP(^j>IV0Zg22{VU91_`V z!aju-`(jh_*4Z)5Qo0Nwqz^u8Z)L!pXK|`&k&$%$pu}E~S{tW`x~Fj`-b>5qcls>o zO|6FUXH`Q{pTdx@Pk=JwN7rVd<ru!h&$E2$Lrp}8*w<f5Xp5^S=YMWWYxg>`7Bn`M zCcH+K3Xa|#;RqGU`<5s`@_RM%Qo!mOCMV;BsBYX#hlx@8iqz_j{TZ`g_r^Ead6I?i z878Ni6(g<@1e2UKHOfCN1sgwLTRer)kxO|rp)K#kmHV?kyT1=}m7usp3s&i(LL0Z| z2=7-V1Y@WHbU@bJiDkso21A~2X^TE;C$TZ%(NP1KhFP&SyjXoD9RfL0K}3&(6(o`9 z=Vldtj7+QN58o%~>na(XA4<)&HVmA?t^$y`ygYjVpRK~9G%sq3f-Yvt8Lyq4@olK| z&3V*7PW$y?zRn{y{dcyMTkT9}Iv<KYe2?nFFR~NRA_k#gr~H_9hc6KuIMy!k9>$Xs zfTn#-Zw<Oaox;sfIJC{BDGEp~mXr;uE(T)?wFHbiw*}-yjl;r=LbGK#q}2-MWngQd zE&`#Le12A<&S+N{8>dUw+X=2QT&92MWyzIfK`47rk(m!ow!FIA3KZJ`tj)m{z0)UX z?H%n)z!!ReWu&st>&`oamVv3Yh@@wO-ofI+mPWw0W@us!y=P@naM%x4GlKiMukWhu z|M6Om)$Xgz<nnPNIXFulKmlsckepSp;mVz98*(t-Hm|B&I^a_L0r%d=8qw<(ZUz%w z#wAA91wpBRRDLnk)U|wXC%qMjf;mLhSf+7vGujr+Ib{BNj}Ntv>e8$KQsa}7v-unK zNUCCy*{N*qjJvM!E3AE~Ql}ywR0l+6DAA3)BFg>F2S&R@WK=jMn^LMx3b)6V+1Z&H z9p+igu2B6Y6BBOAC&$m%U9fzlq3#DwL|`Kg01q@1I8g&YK*XDAp;xvgw8B^&3!FX^ zAgFP9-HF#A<9H4Jt^uGVOU2XRtEm|HEFsZG%_L0A>!daAuZm_GSK1y~+Pn*X)&K~D zTnKOr@u*`zNDVZIBs>ub_S96Fp-IJQrSAsY<?LZJV3m4Ne1ETk1Egm7{3QyzM4Om$ z&WlR$J@Y5c;Hgoh>wp2$o*5_^iam6^2(jH1aJiacH4%U;D86suwa;i5!&i@Ch9LM> zy@YnQClvQuifgKbb~1fJH)&4Ght`l$5JRsyd2mKG6y<@{AQOCwcB*0&{y?$Ie32}Q zA_AU*AoP&*2_Pi3`;+r~b72*;^nBP4@G5tC=DNJJOy+3?N=4sI>1zkB#iOBd*>qVw zC5F!ga+LY#6MpU=RjDdhoAsgCOc#CSr!RR*A-}^UQ?b%YK}IdlE5J{ulP^7I6lIcg z<bm53OeI?k!;ZwNoqtpQ`iOvhv~OwCy|A3&2Qn;0P&(2=pi`rRJChim{fb-Y@0z#z zsBY$n>s>BjFD(E&bRf7`3m^l{20qXNun^WO-1jrUC&J~ML(xEMBDo6D!^|If<$zhW z0c6m1U}bFp1#}A7SsOqCD$sMUh@vW7`{5kFExy@W6l;^pj5_4(fLFkZ?~iBJZ~2~7 z4cLjnGJ!<KH(6F9!#kPa8PzF!?)OU{+{S6$AKVf<{Z^i7$jHvzKa4=v&OD63L35S3 zAus%94i4|Qn@e`Se9Fh%Vkx!_{!}vl*gv@>^_$g4Gzy}F?}R{a5L+v&Q4O*$r=kg5 z)puAV#Ess_q#vGBmu789%9|PWTqI{}tOGZJ8CHSR+1Ee5X3gk)gT_0Rr<CKfJ-Loo zLj^CJzS^+X3#4m9{S@;m6Pdg-;%mMzSjd>HKAemUDV}Xv%w?0+o{@ar3v3c4%e6m^ zy|X7F5O8itU12_q1;X`vKAsxJ%a+J<?+-p}H<9Jkv|2@A|Ms|TZF_GR{q4c$>T17v zHkCC7yeg%%#NjhY4+}ifwq?X~!?FxSQ~TMp9kU0dg?ptMO*|PFT97t0+*^0cjer|R zV71nvD>Dr$dOg=omBXA`rvwZe+7m6=1vP1=SUyYWa5VJlfLxt2=)802hYEI)BA)5Q zT1}Fv-OzMOi)PuI@YqvAr-flE)Ue9LoME&h?n)!jH7m>2ku^i;uq6W8pJ5-*Zc4G- z8%v#5zpc^TQ}zrdxml!FO#Xn^@Ya)e*TwRJ*Km9pj7SvswMv75Hpc*i!J>NpNsAd2 ztVRP>rD$1X5dOhcZ=bOLD(nTUg;~Uz;;8ofU%~^{^b_mil2~$F7I`t=ds5`=t+b9d z2bFbHxND?>c$=P*wF)|R_~V+6o;3!vZ{DO@8R+ImiCIezb8>@`w^7U$5KdXk%kN5B z9gs`fh8P7jeKY;(<W~wGdrBk0IlNs;+SA?P$}{iFK;g<VX#n0{S6A+J52~Wl4wrTq z$|$psR!SH3kHPas*RZqJ3|#71ugMm6v6a8!r47cQrf9x9ZZOD;=?LEc5xeV7Bnf-Y zL_dEZk!ZC?Qp+T#K+TWd{nP9{6M|<mhjkjol=5;rLtdo=v`GAROEylRaDQ<uG1WU5 zg5aC6*C05Qwo6avZY^r0P<#n3>+O<b&1H2oHdxwtYUMiI8Ou_Fxft)d%z@lJzUjv| zWLX2MNdy%X-Ii+Ulx2utoZKs1!V;ET!t?SvW!vpD3G=mtTqg0<%(=<u`XlgsH}yDN zBR&@zALPJaSX9^5YU<0(=D9Nq^`)Cq*%U5R{suw$^+oRv!l)V0VjuD7?H5F*^_N8t zh)f&L$Sm(pP*s=tC1vwfBI}nJkO&3cJ|abS5%qR3^nWMCs$tyu3bNRY80TV3cNQdM zwx38C?z8B^j}F9)_hzF$Rc&G-XEg#L5Ec9P2@t5?)Fr8+@1<oIln2I#pWC-e)j2(R zeFWvy=?^DmO?WyuGW#d$FLpCmcR{Or4>?06o|xG{d$5S2$@I<A0Q0r`jA7R|+C~jl zn)E)aHrI){lS`V``SMBoRI1dlknoQW?WqrNIf<d|BrNzmhpw~ph?qaVo1Z^lmQUu+ zL#MNQGXN9>dS3Uqek#y2kkhVZIW$xUrGX5ZlBGLIVWo>-2c-!xGP_VH19|-vodgK$ z083n2(nNlx5AShi^6%bjKImiA>Yux?h4_%S7de$)5!_n~()Wu=e_L{(*FJJvEu-ez zF1as=`O<2<hN0+X<SVVQI{zx8u7z<w|K5rSJ%r^ru7$!mBOv{Ci9OiBNvYUdYZx>N zMai<KI{Zq5l<+*v8I=ch)&KMMtc|V<j31pa1z@~>IqqA-p`+;m#xdgHr&oras5Mnk za-z;_@~At8VHl|~g&S$ajQb5_O5C&>W4v9c(Ru-8!~qmNvW1!QiH+tJ=ZT3v0722F z=zC{=M^(|A+n9TfSa8>-YpyMEi6;12AK<P<c7Nn1@B{swZNRyRFiJu3;e(Al(`ikt zu{gD<{t=xpqx<!``AN~VdVxE$><<2sa{zn!`v(x6(N&JHIaB&CJQeNNo1|%~h~O3B z#g1%XJx4FN!vH`EQei2LS=Id5ar1U0`a!p4qvwY%diYF^H}v<NJupRRigbKeXQJvo zCqtd4M)b7uWZ|H@I8tmh4!saNh3e-4Z3}6i?`7Zn8X{8epn?gsnbziMkXl!`@+yiK zVll*j-f6#=Eb)~-6cQ9$SF@1|5o{W?FaJVk<AqM)tI*bRfLNDSIRD1X0&Hdo0Dx3^ zy2D#p?1_ktlX~9AQb(?j(?7Pi$1-=lDLkMqa({&-CuZNP|2gx_QZO|l$>xZGE@Pa9 za^$e#PQfx6-r~I<9}pYZJeZKR>NLhViZjjD?1-U;-bI0>svxBw6!0~2l(}3Ya!!$| zEB93<UZF$Db|HoI90IKHr6vsPAvZ{NmKuF083%#P0p~8e>wK`zm$byiO3=3gZ9@Ut zH9GMWG#5x5(>(}9e)s4t4-!eLGZFnJ{@|95ED-qZ`8XRbLm6@Q)%MR)g;&E~a`v{e zXV9BRq>}`+6bVeGp$EhM!u!!f7`3XeyC)m%Y3D{qJ~63@oFtEG?}SfNea`|dQa~+X z#lTC=Z5B?|zy3b_#?lZhk{yM>eLap5aK|y1grw_$K#7atvBWV@Qj~{eNk20fAT3jp zX1k7lRB5U8dD)yI!QV-h{!yY#l0sjY9Mv$#7~D=%ty?Mi+dWWMis%L{q-fn8e{`bu z<r5{8K{m1Q!$o&z4@&w&9K!?%`#ji6ijAl^AYW1SA@Ft%j*$l*IvR1<ZUN^^M{;X= zbl~%_gXI=b%fNeM;)~S?iiUo>iY}7FP#8b0JS)D9hJ#$KUa1nRp0(8kT86pdo4P$D zPX~Di$GGfiPhCd0Xq#^OfTB$n+UnepdkPw@1=nO)GO>I1@_H_OsgAFpBib+&aOF{p zO;$8_ft7beUV7OpmFzESyrsA6xp%tjnp?ky<k4SmNM>53@rz(f6OAqv^$3hKnSm$t zJzs5Kc&a@Gpy_P6><irEeOE?ytMA4d#-?OEF*dE+`)-4F$|3kN1?yqpM#0NYQ0EJI z7n2b$yN#quLelWAI^DDb6jZLcb?*jqv;O{mD}TG*ll1NwsYOf!Pn2qt?9S?pO|zt; z@EGiB>VP<LzP-Dbmj9%naeDNG$v@GKnsd%HTy?pJn{A-)Bfx%vhieVOOkFIX?>lfj zn{T2C`CK1Dd)>QrGq2>#S4_3d|1PJ&p1N$xjv9#$fEhqsmWeR~T9lAT^}&55`aIxF zjW4q6m1)~?HLAi!0(RRc(Ti8|6=|*>f>|FjIrs3V9R6Be<uXA>_G@a+VY7LU#Q~B1 z2+e7^#q9Qdd9w7GMGKZo&>5*-fst>nr{02RLZx%Mp$qGBGaaQ#z$^?laC2z;lKtXs zqZ4Hq`na~t)ZvsqNX?*JZu!#WE!$>h`~0Mge7sjqqc=0(mBZfWwu(SKy~fI;tqz<n z%q`IcD+{k~;pGn~sJcG3U=kJDQYn<8bZCbqCuu~2%Z2(&L20P!u1@js`g1s9Brfwc z=WcRAYVb#n*ZU8nSl?Z?)HH<{B-FC8i?Ke>kf&!I?iCv$f>OQo=}><iE7HB<`-TwG zz4i^E#k0U)i!UTmw$uqBEf?+gH1dXlOn@o-4Iz>dYYb_tT3s1~s(#(;9Ds`r*`_02 zXMOEJ+E)E1j<+&-tO^*QL$rYFTV@QZx#IgEJEvfyoHf~8iJ-6a@Awyg8K$(h;8Eu> z;jTI0_SQ-k;DczZTh1rm$xv97$I#KUoekjE*tn-ptYH*Z9;>dTv6x^W{=n-t{rZI! zlLc4I3Wy%>oFR}v>V;pzR$}9KXBRatiu2K#k(W940nAS!gp$a?$3wlbCui{LP5R-P zQX0Bugu#z+Lb^Kd1ByI<(TiCbm9QeFFU3iOyxr1>F;k#YGSlbVwUPDt2?Zr=M{>I4 zh{@qCrSSUh-FZ9BovQka#vd}ivCeg%glomMPh|Itw+qbXS-Xxe&j?Sgjew(*U%5`3 ztp*zkdXyg1uXRW(h+JJUdc2a6h1Cfx*!ZmF(GQWF@iux9zZuLEd>#MHyNo*E*`u2E zB=KwhEhlKeAZ+rxr-%B>L_R#t*bjpx`Qs>xgr)waL^DnK)J6hlK_&u&T(JwB5eFMV z@Q*0^CMu8UNzN#t?>d;nBGH)GEDaCC8jt#^QiEqy{;BF@u6ie0znEp^RdqKXQC@w< zqcqVp^s=lFx&M;czfE4;8Mus)ee@>5R!m!$zPAeGf4X{gHd(@npxZ1#(9Cps>HhnN z-f%gaCo-AT7iY1N<I!B`aMB|4BX!9I|G`?@JNQ%D`mh$WwgzaraOr)|o8hg|`@v{F zUVE&CP($1P%<S7hzHmQ|EK_%4qAA4rEzIrPG5^6Fc}DS{nV1*ac3Fr8Gjx{+@vMZ- zs}n4sSKg8<8(|#26D*sO{=I|4n^x<wW(C)%Uf-)P&UN43HH*u@d86F%y5|M4w_eGs zBF(x>#o=D%f6<PyeW0kLCCtcBb?(H+>_KHsQ+C$CDs1-wbUdWJKV8akbh|$yWkBXJ zArdURZuK-@g<8O59m9;&y#SPUPjv)ONk>qC9?gpO!zm|B7cf<Sf25fIR#{ikUr<2S zyeaQrB+4xPyy?=^oGR;)F1l6)X0tRIJQE9!(sHpzKUYeO{}D@Yeu9UDm4RCR=9rrH zt`y70u9K%OxE7(`+t*aQQ8^k6kBtmhMs&lgO>!C8$)690d59i^T&F896h?+87mzRy zV!KsAt|y?gpUjL$-n#CmsMxM@Eb-K)YU~0i(J_rD9>3%06|57UR<a2s=Q{MvjC#kw zet?~ZRU`TBxyLKsY)w*mikM|-m4LFMhtqi-v<a%4S9<%jce%FQdB}Zrx3?Kl|9jOn zSj2KPxI<LX50l*R<Qh}_a`nprc`nHpkm!Ts;e*EBCad<jr%D7P%s`RH)1KfxLWx|; zHvf*q;{AJm`MJ*t=r=S7;_~Ew_TK`Lg3ms&O-Z0Z%~HT|<TUM~F~y)P`!#F2Zsh0G z7BZjJiT>!&aaD{NWQnNu=4<9Bdj-z%g#t*@mBUsIhec#qdp2+=MQhqk!KA8zNF-1r zvADFTCZ9UTcjl~_4IHYOop~5ASWSHpf00=6NvY_}Bn5t;bG+ysvSlUNV*NBAmSpu^ z>FX=7i!gG6XGp@3-)F0D+xA~NdnDusODj4agbc<}YU#Ry(}XLOavJSF>Qlb@k@*_w zjoWrddo^2Vt~=TMx@z1FJND!tJ7_!p{h3?W_Cnhf(u_urFVylTJ?9V%&W6xr^0McE z1e{Od??D&t*Ls3-Wl7-}9cvzjg$@oJxEOuqLbCo^1aVPH%R%KLGgi){5~Tj^+`lYv z))7bw>UE76md{vP>r6Q_bt1HkXE?db&?J<rP^IV$0JWnmrkErbjm3lx5+KG6C6mT| zl-Rg8S5-Ku#e6?sjTP5iMnr9v02y#`@r=y)n7L-OWj?6@_3aqESl-e|XQ<!?{y=4o zN))2+yQaUy_nx}jBOR;<=FqU~rVKguz^CfOVG#Y2Lj_LKQ86&u)1EEJOH-l)>WSXK zMDGaAfC0P1Z1q3K*P4Eb;Db`@>ze5i5r;<r-d@S@R+cQMT_mdYP=z-zBVNHy`VNWG zHH6Iqk8ba<ps364%8+Rfdu-Cv3{VZ2Tv=cgFMjY)4Dz%&s7$WrT%9R_?gxFH2s$y1 zmrBA`o&BD!L66_gbp}7M$|>09!c~<o)(Nv*-oy+)al5nPFc0zB9D^Q}mg_XK>i2M+ z&3_lrh6~@dA}=!ruBe*sC4}et#@X8Rjj(<DF+kHg4j`w_>rE##R2q2XA#32jX(dVo znqXHbir(9(=?u}v34FwV6=Fd|$e*G)m_un(R*BphyJJDK!XZq$i@E;&v<f=cx4yA1 zJX%AQE-Tb<hb1Bb-48@<iZ!?7kJLL#t}`%Qi>;rXbCmm$^y3mtiy!JKt$~8p6;<V| zF9EY0bOnnY6?OVhkrZOHx0`t6=^!CO;a*Y7uWONj12Mz(Qv4u?oHN4rxnk4^1tcz+ zowY9Us^31a^aiL>iTdOTyk=4-d6l<Un_w|G769MT&m3CgCT$1;AMU*0K89jb%`;QM zuaYgRG9)vKW8FPyRa9<;^UMrSPEt@2o0b-ioY<}lcKqdjvbFZO-hbT;$L`!<lJk9d zQ3~9RB~g{<&#Rp6ncB=nL?(aMFO@Cv_~3qaWyXl!Y8kIq<>vmeue=70xwl++Y$)*n zrND;rU@nr#wP^_yCeCl-X^3KyQV10v{^q3m*AiX;z;H*Zu3de6IiarI?NLnpvP9Vh ztjq~x+7iTknmr-{`!$x>^5kHXl9Pr%?`v(>JOVOvWk7uAO^D^)o_xZm^UqyF{gJ7r z3RO#0H-aBjcc4_74~cDZtd<@Iq;aK3-ZXKSGS}CL@H_Z|Du@nRP`socrnUwat2X7r zJ`Sk@*LlCvA;xm7812T8?T!(7EgTh-@fchJK746O7Y<7r;sY7@u@z!lmn!9s)?p<o z(9}4w?nGTGc@|)GpLR8KA%)bwKWc~yyN*1vcv+h(9p8%BzE#ZW=t_=KccR~xrb0O^ zF|v{|U;JziN`mV6#PHmk-szI<%j%oPjO+Zay1@VPc3`{>te<RHg7g5M31U`^dIj6M zlOrXodH#M4iX}ca8ehOOry-M<NcQc>ew$jrPt-2-VeWwwnNTJ1HqkYc@2pVgOCMsK zWW6JVmTm3zP|tbYJ2|Fab+@!PtF_j{rUuR*MLK0&gG|UtMuzx3bZ4caiE_d{Y$|w7 zkluvZx*3+53#!>{aVL^|z{41|TG|+lKq5`?7aH;H)%NCeUs0TJI3s`S?X6$hKJxZ0 zIX`FM=PDHN9dvbV<N0<}Bi+fz=gwL$&${5JXB*u>?0OPR&`m4BwMg6BZm{T89HZkE z@WO@b6f~*}>&kmNlywh<Nah*oCA@hoy0hf-vjb;i<DCZ~t5&Vts>5X}&oy+Mm=@v_ zFT9>fM;hPN6HOn6KXoSB7fZD@6<(Vugc*m^Y6R1x2*VB#x$!4zc^4J7WoZ#F*%KRZ z!`tCmRYlmTVU~==d(_%`mOx3F`CU6JQSSC1F(3>wEnOspz3pVaibCRd4M@f=#)hmq zmjDww%WQ}HqK1YB?=JB$ANZo<4e>Z_Bb6F`RZSurk!R~xs*`Q@EBL)Zpq&QeZ!(H{ z{=rGdRj?<b7mWLtr!NxO-ruU!zGB|dtn4<DB%3;F7?a)>Prs~b!Zldqvrq@#wL5Qf zDuR_A05rHcZc*(rzVR`ommI_TW-m*(^Cobp1Aq#hx9&LA<f7^`Ti8M+Gq}zHAcfLA zD=RsBUKxu~0e*4-s6i)#RUH9rsQl9tKYr`mY<zGv1V=am<Z-nM-U`t=l-8Fm*dw9Q z6jAugWP{gVn9$2$EGGa1NVIKpX;@;)EREc$uClU{AQ!Nlb}FYb7S9`_E4OWPc$Yf= z>O*0-be%A@N(3+6)5fxi7B;$J3cm?r%uRc%DiMJ&nvQ(gm1NQ=bMxBnjmPr1-Kd<B zRisU#!!=o^$#hK)k&T75O6x>Hpd8(V(bL$+cC?*$Vk==8c?h9Ipunkicy_UMS}-Fw zYx0|hlbGZoY&4-dO@~cU`W+;$#Av#e8!S)E>X>?D*Uvo&!a{FbCIibN$UaFoq(_E7 zkB^dPt~5?#_ejv}+!b%z?NgAjJ7by`IOZRb`ZFn&o=i%a9rn(aW+gD61A?^tcm*xn zQW=sKVT3S^Jc0xrKwSQ1yER^0hoRJ0C!ojpIjwHFQnu%(xo4yDet0I$8nR}+gE#rF zFf~LC%F3if3`Hl|1?|MR=w0(#y>LgA3r*_Xh(FeO-=w;Wg)TDLwR^(=ReT6p)noYP zL=okWUK@1=_onEPwKd;ee|sWEFb#R?aci)Ws@3w7j^KlJ0R;zJB##563n|Hut1m5{ zE)>}bl7bLA(gi)ecOA}tMP`eCXxO+dOw}~XqbgQB!(2W#X6&sW_ZVj#R%EnsZ)I0J zlOL@aSo{v}4LdyUtZ9|EIo*SuT1dVS5@#YK^UG1EjhnLB*)!++s#R!$O{7)^`ASjv zZEnAHqw>C`9q65w4D@FaxvZA_Lut>q(3xpFd0KosO{i~*H+AC=!#|2CUR>`HsG{jN zKME5tG{Ky?O7P^m76h#%Hr3xa<mlggnJf(}%9YHeL$p5$ASDQtur_9?x!i}rXPhe) z_U0RWfOf3Qw6O7LWna)%<x~hniNKq~C%+M3?y+B^j03?$AP#lVwnYLD#lB?hX-qcD z#qq-7qZMZow54n*?v{|qHU5l$Sbe@b0oySr3n!omvd@N;!4$vNp@$CSyX>JcPE56M zx;yj8wgQJ-rpLX%eEMDs%sz(|;01#de+^#R;_pspkzQ4TZ+x`xv&p7&r~7Q!wueC3 zwLIrX+90GSn^$BlCX)+e@;*i{zxpy@u4MR}TtDBfuk~w1wi=)7TuZ!-raV0vkQY~V zIBoSoG!^n(Xg>PQ@OrWShsxWpS37H$zi)wJ84?9zarVF9(LM|<S{<p#wbtg=u5-=> zxevJ?ZLiz{3HDLM6K;RDaVM=W?Sn)_O&1yLht)w?qb6gsK)5OXn+A=@=lIEWD#lWS zW>tmt?SlCHI!0RAO||mf3iqQ&p1SjE8lfrub(E?E=p?wKozCg5qIxVMrFh;h>Lw>@ zqHto%PVLQ4{L*9L2-D=hYpWF37r-I|$xMs|g(4!iq?dcey|sJj!w)W0KgM@jY_B!R zo^L^K?bans9j$S$D9m?!u;d~$Fc;>8Oc&p^lK+_URBK~^*Oe@_*sqs5JIgCQ5@fe5 z&UD(d3U-a#mu32Vsh;Mo6rRfH85eW6?1ZH8se?{Gv^a-)EE=9gxAv=((hRCXEcL|P zl~aD!;knW8Tk1Rxoq4>sxeu+s-z>=o<|IOcG#QllX~biHtq}@6gcVQ@WeYhq*)vrT zBF}YdKe6KW9$W^-HBA8IcZ&pW^I@i%pltC?UGE)A=xTYc8rHnV-Dyw9q+Zb!y3{P! z`x)y(t!0sBK6ud#N;Y7INjx$lnzNZ#Al*D2#`n8kjbWran_g3Y^7V7;lenxH)(sQ^ zVZ;T|2tPiNOT=GlY1}jP<gtkdf!y4K4<@-NZQT7%PgTA>Kg>ai#%aWnd^KNG6H;EZ z%y#iI0WLPPiVVfIXlW5d=RDt?cJFr%5(z)Jz3n+KpDo`~sp9!M8G841Fy-TNPw4A5 z%niHbiM<so0rCqLJq)ZQr>tM^)Sy9Gpr;bgJY<juEMvL^00W@Bfx^Bgouq<LU)>p; z6$tkui>1<le_kN{=j7Ib4O}JPPt&W_KoJ4s+WcNR4>O_q4C*~P!)ONBO>gvP`KIji zu^Vx}<F#6s_6uc4aoOnRqqnsk%Zo0Aq3vUS%f@JQ)!zta-nn;wkQLl@IgGW)05iD* z7(r8(mv*pvPFaV}*FcWcJNVdqSAq~z?#oDPzber)C3f<(nRggEb(hfuw~^6@RJ``_ zUW@8`9%)83iTu=lXg>o*OY1J^{gPz@#e47tgzjS=6Ng5dgF=?jj2Nn0MD^$2>u0v@ z>*P+}c&sW_Gw7_S9noBC?S9Aaq1&qEDh2(_x4}*S?eiT5;pG>&F<2~y1D>kg??ykj zB1Yv2cP__yp$+VHB5Y`TdGJ-aZHaivySJLe!cLrxL_YN0|BAYJ%-$dM7rob|tHE!s zAzs2$YH1#z@_Zmf(D;S&b}e;_|2QeuUY%R7S~vO^jhRgNx4ry*H0{BKuirP3T;o<i zzgI~*o^GDjy7iy8_V!|eg?`L6m3=TQOEX}YHn>#1NN7yDwR3nX-)Ryb!qPs}(ON3e zGUs*f`6)1;T0d1Gcu@(?emhA2oQz&iux+m2g|+|Mw|echZ)^oEw9*E37Qs&_-kUD7 zh|*u({oW@(CkC@Zajy>OOG@(5=zsoN2Cd(BbN_ffTUx}G8k7;8&1-e|O#_)vQy|Ab zr>uZ5k|aH&YRvs?$!8^-?s@g;Nwe)e9S*@T8^xj&+P>ahfODd38rSSFJKHO^&R+Oo zBR6|!95MEx<OPK38uApKcDho#>}VVNJ(fHx$$Y!sJZ9dGmf45TE*~n%ri6}psX>bf z&cD}U5$^6bmtX#Q^yiNwXmtC3{x~w$M8tM2mfL(@tb_@#J?Z;J`q;m+POc=r?R^cU zbJ^qyRolU><r~?~L-(>tZWV3D5xRzEmEqUUANwcumK@UP=(o2BK+Vi)(M?SoB_p3w z>UCOmar6!i12@Ft!OD})FoIJ*gF&kJ`7P*X8#|3U%))PUz;<`Gbk_+6rYZe6aIJP2 zsi<P*#~%o(4Pp=dLuqp>zGykw8~T?np$h;D%$BoN0QcFY4IGnJGLI|>#4Oo*M;po? zFcK0N5~{j+HkDWk*xq)b=6A4!x0+XNz^M3U4taf?j#t(|u^;Z}l#e{NVFn4d!feib z{Gq7?PBUoAVrk4Pa#L><`&FFgV4%&`D3cOJAR4E2(%<U3-{QgA{OhgmFl*&@+KjuB z*MWci5>D*xjC(Y-7p}5lHMH_rCd-#CEp4<(yDbHEcIOse1Ea(?Y~EijN~o5JGI0bt z8%R2s{DLIv!nVKUoJ=_a^@2b!jE#lDxQlb^ezJ!_-q&Zm4|+FZa+eNux?h=6UB<=< zIOt$nS;84Ns*m1awFJ33qMq2w_pXyVHxz}{%zsM%+FeUALHs*|^dm|A9Q_Hivh2>g z^IBS~l?;^~93l3ozJxqR{auRk0tTDo)4ccT{j22SXm|THE-|;P2^<?BMI8x2wd1M& z2uTGV>%x~+DUG$ZlpyQb*Z8NMnWY|O@mZu@O-kM|xL+7H=G$7Ioijfi@nnARO$)IV zCcjdy%EX)D=2S@cp-TI5yvVoQLqnb_wsMxIMDBycmyty~v74SLdVF+TRbo?FKJVb5 zn|-&UJc4u@nsTSOV*_sv!uIv02J#5*sbITyYTs_StY|CS|Kx7!51*Odb1<n;{hZBh z^;?PbD85mvKysAybDSt|VAZiR%~G)RWsfAemGJPqneLv_Z>qpxrBHV}8hv$RH(N6b zn-vkoxxz&9-|rG72owhHJj3Mp-`2clXdDM~C-0)V9&pvE^CSWlK*Og7gh#~|CLEXO z37jABACUuPQ)in$a$Z*<@WTx=x21#b-{m=Pxd!D3>Eg=Y#+arFUpH*t*nlfD^|bv4 zg8bdxJ}t!zDg`*@3;|F*-C}GiCFF1ItUq+xnK~p6SqHpb9l@k;*$&6n4t)6O$~$Yb zceXvdaTV}g{w-L6474~U7PRjw9+mm=?c)mD@B6Q`uKKl0-)xt^v1|U4(s}gj7+Dp# zCKk@>&&|TN-xe0h^6m3(DOvsLd*eH#)DomRN{%)LJVo4R`WT?e9`1N7`raZkz(x1> zBuYTWz`>={^VYAmErRbehQaJlaG3at)Hwv#yPw%P+5zxob$KA<vBS0;4r##LDFFv@ zp7?q)JDOY~CGq@;@6B{zQ<oa^!?egIJCb;y9GZ;a5>Ke<GFf(z7fDnjzWNu@|Ffqc zueAARPXWw457|;Ei1PUV+ftY@J_Z=Gp@LfE+HP<DXGcNACIPaeU?==R84o2vsO?Qi z`*n*zDYqy3e!MIN_RcOix*1W)et^_Jz#=SplSkFd`Zc5KvafEOwjLHQs>V0DA3pWl zY!9tx1&f-e1tjox;1qvX>)n#I?w?$QNy}mHj>A)y!w#=+^ZBja+d)<zuy4A48-|=X z?GT+hF9H1Z?vG<BTcLjk;;WL=0L0ytbDf<PssgG$opV}j>)|l-GY63|=be${?Y|Aw z^2mGBH-bsY!}$cT74~T3I%H5UOe@XI$4F4;?-3ssxYZh9Ocn}i?M4k3_N?$~UN4_j zT2Aj$9%@3{cfO+}cLi0KC@i1NqJ?Sh8gY{J`Qn%mq+!IL|Fi-Hcm#0mX3WudT-9fN z^krSYW62%!#d|x;*fit&^Pgv3<p+C4&cM?M3+i4y?Vyy6w=NuM+5FZzh^mMB_hHQ3 zmhAdheuWlxBz9JeA4r85TwjG#L@bO0Tqe^PC@_;JROCT)NAk|C9#&8OSGa<PG&?lA z00qIrtuk2clh*<P+)WIl<DLi%whaZ6yuq{Zc#(4)Ww8i$w#z)Ck?4cabq6gvPVU-S z`M6M{{hpwCaafg5Id(p~5x9yqNyD1HC37w8f;r{}>GJ+Y>3H(A-10(~#f>4o6>)?# zXUic1tPl|Cm~2=#CI0>afhHdN=6E2E{f_jJq-()0_IbZ7Z}C0-^cAU%0X1`;BZC%I z>2b!SEFCLHries5{h%#oYpeyQUA)7!nWA;uT?$%Zdk)3@)h`|>&+d640>r#NzKP^? zg+P2A_2PLu*6~}Xn79!Rk46kd7wrLnNZ7l8bvzK+3|TSeZ}OlS#5}Az(Ra$6sV>rU zw~d|45_Fx)tWJA)KK=CloMdH$MU8|Dkw#93?}oWpc5&jJ?})2gZ;8rt5S6rzdt}w4 zD6d5<<Ttboj%eq2>f%G%AIOvpKgpW9F02d?z%I{T4K)2+k7$+;{DGk{{1M;CEG7xc zCzJ*x0<S8`5I5or-yrQOzz?|d{3>OwAkCk|JZ*X?w)-of+T<KcQG$T)P3w}>HB7oE zRHo}w+<l@_KSKIUFpz$Eva4*9koE1>Pc4A`4HfwH#Iw31r61c*cpo;j7KC&HySKP) z<i)omn|$sJ7$PZzFz~=QWO3unEwj{;ev3fRwf}sSr4fD}*~b>j7481?rBF)vydHoh z=FvAl($*!~!L17h9Bf>VV3#nq2cHECa+y{+^&n!YelD!4yfO+~jEpv^3>f$+9vpMA zMkln%W0dHwGyxHcTtX;gH?FYNiB*AD9<(wPaZqTqs|X~>FdLKgdFt2*49t>SSp+p8 z^7$#<5DNWP067)Yx3z=hU}qvvL|sKgBWXo!Ou;~0!(meK%W?g_S1!604<VOdmr&EF z@FEkiEj4Qg6i0+P2zGQi(IQv+$<_#w->3D}b0|r~1=<R(^WF<UWs`A%4hsAI2g@tm zwhJA<lZwH`%72xm+JL4&6=e?2@qFVBI#%js$H)FHf&nv>oZkkQSyP#0a)@zvJ#~b> z6Art0-k;P@hZ+@Xv=}Li4r{ErS%VQ1c``N{r#3J21dYJ)r5yFkH%XSS8E~(zZA({A zyuHb}L;ay!ZIH+7e-?Np)yQaQwQ;by0W^<{=JRp5j1F>W%~)=_Fh0jW3gbr=fl`Cd zyVvNxcp+uN(<|}B1Q2RBy(iX~J$>~G4z+y)=Mzmu<YkIXVNHTuhs{CN$m_4ri<Ax| zG8A%}I+Uj0xh~-{e4uQM*Ylj^7_SC+ooHx6%&~sz@;qBxZ$7U+f1n=wh&i+1m|^)@ zjc!1k&){*fc;;LGi0-qUw5$jDO&!RTm(wBb5zjt}SETjU)5s_4X{<4A&bjuuws!VV z_t0ym{A9u}8~6(|sQj2scZW%Cf5bUjM`U1zf!wwuii;{0pNJ;vn3<%Iw+_L^<*S)L ze>^g=i2XbCfEs^}&wf9@=VjugewUb}og6PsQtVf>-!&nWLRee`h+N*es_B9T%)-!g z2l5i`Rw!Tvm&ip}7*;#|Depy61rkN=V^#SM{eQi=_ugj<l4Pdk)PwHEWu1r-#aEj| zl%CFSK*sEYv7S7e*q{G_9h)I92B_R~5Oe`pX{oDw8nD(Rr`?9%$(~VsS&swi;vbSC zz!17RtD@0_OCxzYFRxje!`_1=)3*qNiB7jQo26sG3w<}6okUF-TM_J{bbC$0vzEEB zBYn0;j`8>Tq&Jz)>xwbxAxkVxtfZB9Nsc<F6lgH(DR{>bp;7o8x1@y2B$N>rQj$c) zW=Y*#>i6H-j~2int)Tkt^2tb@q>Ep5AMw1M&2x)axqq|Ex(%wGM+t%GePyGcy2mLI zjxHRBF$4Churbxw?_Hrm17tx*Ax`HKuz8NNG`^#lC_5!>52u%x62JXdWR;^XQe01~ zS^)(M@^d1*+tO)p7?D|KNc%V1X58`uUzVb(F3l5|j$L;hTjT@2UU^@g)6$6EanrES zF<;*#wZsnYM7pL^-^GIzZh3$OR4jvEN}zO)4&=CEt*$Q`h(=Q8rdy^50xR614avgt zSOjgyub~9M@`}*Q896M9A`~g``GpaEG~lfP?0~Mo+@BjKwD^Om>3%ArHirq!hN<Nu z=`i_N8P&Psn!6X`k!$p1J>Fd7mJaqr_-yaD)g(FbQ>LS<8{UBo`nD=Kvi+o{%1cK| zv>LqfMK5vFW_rppG#Dpol9^g@eGGi`?W7v(-7{M=)vM{Wd0*a;?-kLn5XDRHgun)c z++?MgX622+2st=FpIJC`I3KqYbJ!3EA#E7wBE=0dLor<6VKJTvs5hr*NNxy%!>WCT z(l;gQbY}y_$G@3J+%~$l;0Ly->q^`2Z_+pv#A>>}>rC)EW6tkA!~RER71%5U0LkQO zjtT)_Lvnw>*&hJ=knEVKXn@2&X;43s0I=|oG^lj}sstzmD5wGq@c1DSVe=&zfQtZO zqvQad;r<{nS|Q*!1i%#m4j`?L_>?j{5TT$<Ng%C2f^42{PHb*=ZZkyAu8S?V?IDkd zIZcjEEOiTw%x`}yP4Mm0N*nGbEiHqgVQ43Ch(AmxYLjfbJO^URDyC7-kJeF2O!X0v zi=DUzlqs(g=!d+6>JWcCdq8ayXa_u4%Tmemwo)GIzsFw}pzr1o5&VYMJpngC3rzYl zerO&GdcBsy!bn~Cl8}@cw%&iCR%$Ll1ZX=^hcQ!4TAvuxE2WQC+dWw|HZjRId2;vj z<&hf8$q$N|O1?ORH;WlRd6l%P$fUsFqdYz#Fz|U&CXO+_-)v|C?r|~wLe}nm291C| zHJzJOQYQhW8-^MIdC*h9-L}vdBbJ(ec}W%;5HcVZ#<mBL!#ajIIqMnA28$i0XjvXn zI0)4s^yqG36tgmlIHkOc#`$9^L%zipDvu?=zJe$txAWbr_rC9HWJAPoO;lmqdDC}f zEb(k#GZomHl!KqdzW_hl8{fz+E@lv-)*#P)H6iSgcHzC?X`Kqe7Pn7-O~z2xnw~x; z0%D}f*NIL#f4@XpSZt<TCA8O^QiVe46>TPqn>~W#u4K8P7i}pcID^M++6%zh>b+@g z9zi&Fp|zS!Tg2A!EeIQb`O;94(q^&GFJChr!k-};x*yQ&is~^KAee{>p8l>`K$!P* z(;BazXwJj)RnPUES))NLZUh$r7pa%m8&JEea{hQx@7?wxISXIm1A=uDi>*n5j$-D= zbBbpo83K<^MuG8-pxyhukNs83NELex667^C35=3k_q@#?wD)<bnW*75tmX{|1aya9 z`5e~y@KqbYMsbH2u$sdR9#ST2uq6gpRrbvP-c=iLh)vVnGBeFVUC}JFFnKk^8vsh; zNhvZDpzAI)yQ^KR9vt<R@bL1CiCdc+4`ZCjzeon^%HAB`WwT1u)^vO)Zcc%3S>IZ+ zCF_{5(@b48aaPfGkm!*K(ApPCN2rlQKa;oopoEc>XBV4U<%W`HL_<rF_+IMnbv-pS zdK4Y^n23N#q*%A2b7z7-U*?T2?idL9X;+Ol(eYBRVVr31T1Rq#+WP0SJx3#BTuKb3 zGY&R5VX6(KQl})?hG$rkx++Hp{jL&)r@;e3?q<9vFKC@H_<QCKSWE1w;>#`1rvS-! zxBM!5&ehyjb<t6rxboF?RnQ3xbu{1M2ZCWMf=Wg^;#4e4=ggo~mEx2G;#@(U9Z!lD z453W+wkC3Rnfv^Ey%%%6%S9?ioE%RJ>UY|=ieSEv&OaC_JmDIVi2HAl)A*~=DeV;n zZCJ4`{Z%Y6ogFQLaH>9!of@RHIgcf+VDCZA)C^%#Y(<^4?W=wveHT)vq{-~4ql9U` z^f?r8ul}}`X4!cv@C;KX0BQ$>VU71|`Nn#^U)k-|Ct8~iP9ImDqPOdW0-vAiS{83y zSKmf2=*UD=)uj0AFBu}Fcue6QXT1R}t9?||AUG<bech+8W8n6-h>=>w;r>1Ll#I6C zEZZ^s&imi_u#(yi=!lXLeTrUeQA)+K$7bBFUnE1>=b+jmgQQaT`M<6OfqE3@FG=B1 zGRSPcRUuq39y4Jpa7$|E{$5Xy`lyZQS}T~Uz@ui|&5MgQlAr1&bPU9h!1~st0*=xy zJ9)m+u(c-3hzKB^n9hIC)E^Uzn&ZdOr8^aW<jz6zg{uQ_4NqmqKPL_C@Z~3YVK$Gj zy9;^7NYyh_IZ1nQf^T%LH3*I^Y6K2ZOR2Gm8(Ud7BUt*k#TzeUZ_TWUn3W`gR`w{S z3|;(y=3ma1F;xCbjf1czDSpvq?|f!_ziH%m)Mpfm@Dp`$gekEqvvI&^r6XqdNY6N> zAS2N4{AjOBi|<FgoR5=_hczP%-udx!)@@OtU9&RL!|t2bxoQkk;YW~zRr3hc==xX6 zk)q893v46kxl6nfR4cIuVe4<Wb}){1_CB#`fTy|gNygjka)R{qUn?tod1|Xn+sFL% z)qU1pLUN?z(p-n2dQkJc|6?6{jWC1a>>~dao?szwSotB-vRmNc*^cdafXcV5uEqyS z5raaL@YLMom()b#`#ex+3Rm-&*mQCK3smH6p;?s2keWyy%g}?9I)C(|L^_nNKzqOI z5U3N*F>|Y00~|+<k&(R5-#?lX6W8fQ{JbLSDig|ct@haL=^DC5_16~i8t?5~`|YkZ z3uUVBGD_z8Tf${3&+2|TFtY!dl8mQBBybW*8^`fk_)Kl1w&M~Mq3CT1ZPbu`ce1{Z zJQSp%xMfr0TD26rqfyR4f52ENVl(~2=_{R^`5=6$8-E@4y_vVV|L&Vc*FI|i7wIZ$ z^W9sf=c*s;RbOcoQ_k)EIgs8DtS$MC7DeidvY~LsgsEVO{p@YV4L#`niR%{>1**@v zyE!iH&+!?twsGkP-OKl>xS@xpL}wZ2oqsN7*k_HK3!(&&(97`JMu!vt@0>}w0x^WF zy2vIv=5~$s&P;sB8&I<l60(o@3k?BU*N89|Ff9vZ&F1zi)MF!Aju&#v9dB2kJaR`- zd8DZpg1(7m0<hK<?AW4~s&G4l8eK~Xi^C5O#}mk?YyD~gK`|y@pYkvCYM!C~oem)V zNwjXxs{-i%ljHkP3wQ;M{326p%f>Wl0&C0x2*E6ZKoqdcXTW#J*E?q&U>EY$Ph1a3 z{wH1ca|0k49#YBE_IDOR(GEcRr;_;#pcny?ZCm{o+8Y`k3aSr0c1Q#O3kw60o1eM> zsF0@3XafMTe~`)ufCw_X0NYOiwjj3DrvYscbzt;afCj{r`RqS_fR*O{u?gn?3CKeF z<GWXo6Af7XkL#JDKveL<Pe2z$OXoZQ?jNTH764=a7|UD(fFaWzFwY)f8={$HAFu=A z!yf=Ft|7=_ohT9sQu%wI=pWYd!9Sq6_mBt=q6@rqN(7lhfd|frVj%7G&WXPKqn+UH zZyn4%(FsJ;<vr0qfn0eYD*H!y6g=<@(k>7InD>vT6iC2{e{#`hcN9oOU&5D!_Rl1Y zfC8xbk6lMvAS7)YoJR{3faqSN1xiBzB^~geaCy-IRUneye<eipKrM*Gl^&=E0fY2F zZ3v)X_}j{p0jL9!{9yP?reXwYLL}adK(&8bF#=yh01eY$jvo`y2qKwh0xCiP9W&4X z0z&@<Ys^4>h(v_tFGy$k>&7|DU$PqOUr9MDP!~dmVFMaMfEn9gNh{l5H&EIC0%LZd zIfT>6{?|GN$KSr2Z~)aIRi8QjYDVS!+hq&RzvNm@pz0q^8rMHZum;!P*7^T}Gp@fK zmFNEJPBHgimtlDRMoyOp$O|zQ#{-mrfC-+zdMJ5;3jdXU?#=sm1gm&~#6tEV04PgW z7f*A07i)J9c6B9a7(A#y_eFqQu4)>;3;mXmpr8m}Zf5|5+%4hXmn1MW9}tpE4`$^9 z62q2!0D!AM007MYtwJI99v$^%YR-)Ne^tc&tD@~i1<Xtmm{Sah3qDQ)ApajV|FbUm zZ#9cxGXB4wDDuCk!Oi(c4NDFHndQH|>A9$iZ+__m>C2rKsQ>K?<cMDguH^@EQvA89 z2Z{`}|78LGgN0s{CIF<P{6qSmHOGH@bXNobLl*;xG5^at_>I7ef5lb*_?IsL#D|Pl z>x&c?`V#<*_UZr823inE46O_%6$H{kK5<e$8dHN;B!L9bd|-1yAPvM9k<4B_qn9r6 z!$3j3+_d3;Jt*n{VCH%NDeHgvq83|~;HLC)jUS`^xBE>E0B~mmfEbJ_1Vn>)2o!qp zK@iL*1ca>Rz@{(fFtqL92~i*cShgKN^?%}QU5F2Mds)WGWBs>wjxYaoU*!t`8T|0C z1ytb|3qQg1!azpI2;5ueNF%>^hwy*A!yW*;2?HTF>HufGw1U+f0f3E10L1_2Et4Rh zNbv6{;{30WKtZ{HpM`;x<bOsn1F3!>`XzEhFOkFh50Va8Tm(oBA#IH=|Dt-Sq<Ja- zNx}h#ypSLR(=>Dw0vQ-sn^^$(%`AWbyeRTFfCnNk-BSl6hyrOL0c8_?ITrydiUO%2 z=Wc(_7r-$u^$>%s*(Emry3X|<UiE>;MS+qKQtM=~cjils68=w&N5C9ne=i9mu@}v` zV4s(BNF!9Nv9o_Qzg&_3>mdmKE(WB6kWSkV6aOXsXMZWd(BeR9$PhU@&jQ%4p`dha zkf4bEmmVl6lmoDgIFKIFGZ*m}`>x;*;(vRFC@;YDuj>D_e+M2F|7$;exZ>vjP1*os zO8h194(E`s!a+e*p#Jw;YzV9_@wfZ`-)bCyDdgb?$?0!CNJ?U)kZ<bwoiRYCCjzl3 ziWkmKzvm#O0uGD>ll(93zyeGM7!s&uV9azyN2oo%jzDipPtSCeQUeE0j;Yh!-9QuH z0WoUeu>YRE-Vqu&H$l37PXFpCr2-Bt87H7?AODe@{_c+?W_o^9cT@rvD)K0<?VH}< yB&7#7Vk6K9#-{0KoustE{NErWRXL=l8*oTr8i}ar(f#&wdc3ogE?b@|$jbmP?#s~t delta 18213 zcmZ_01y~$S(=Lnz3GOV5ySuxF0Kql5OK=aqxVtUx9s<GLA-EG<LeSt4Ea)No<T>AY z-|zqTqM3WEtE;Q;?&<02ncAYT4~bzPP?g`ozCwcf^V!8iPe7%B{d3@;gB<iZ{~T(P zGNAt)>)2p!VE%w42Dq;f!7n&-NKTM0LX$26wARTVDY)SZdIaqSD6wf7YF6MwK`r4Y z<d8Idx`yt>|D(|4hz6sH1wq4PFsld<R7MA5i4Q5o0mKl;f`)>UhXE_gqLYBT>47Ls zZ^dAUAXSA~h{L=j*q8L`CBeNU_$CW+gwkM0-56gHM*e`XwXX;-3GpSpeo06#3At(Q zD~j#`L`|>;RRB`0M-3{jEd<3AqrD@8pmkxi03^&m4fweG{UVqM3JUa+SQ7FH!48Z- zw5D_!v{WKU{_YPK^%z+wsJfTL^fw;?yw3zgZE`S21It3py{<-sLx&*DPPAqr2pYRX zi+&A3y06e5I3P%e7kwWSg5JoYC&EI|vOGE(%^wtY=#1WU=!{Wa4UuP4U^bOPkk$z1 zFQz{TtZ;+*1Q99TVz&NMAu=LXzAHpl?Ss|f^aq7GoM1IMoM6MyL*%abIPW36HcbL> zSc?D18ar|PA+>{pdT=0QHYxYw+(UXkOmP6GNpS%8WE@gjGzstbKdORYJnBCpuqhai z?GFe`1>-fPg7FjbAesz(05mMr7rB!5aVqsS4-^yt{6-Ey2hWA*Uxbznc98=pB3w21 z)eFxbgNNh*JjNDLsI2=bBy%@-eeqLuy7GfeZh}@d-AJ~#Ce9mYOuS!$XHDjVRSnL5 zrku%l4LpdUOWfKVC`WEO>3>D0!LT@-Kul`xMZSwK8j#Kr0XWu)UiQDDP|%m5%o1xN zI%!x08@&VIfh42&^HFh6Z$LsGZeAYlQ=&dW`8G1i+_zEBhUI%&<zM!_@j+JtYnD2D z<@0OC*%S7bHXlE!p`3`U9jn@&T#DvYy`fgKf1ggbhhO40jG}w<2;Pf3>-$~U;rA@r zrPKv@Xuq8xZX0t(5#;)P82;*T&!+Zq&xUYv>0=95JZNMOeg>>fV^(QU_HKgo4bD~x z?mld$WN<g~R$}_yusZWI`^{2Ut=`E8t(=oyL%g#?G0rcD=#jsI${D0SKIEU#v_+HH z83i-DbZi+ky}v{TN^US!R$GLUI1RHL%0KK42qZ7`HZdpFT}G8i-m`jEu$bD%eC=U5 zbjzFCvjyc5;!`RG$ChIzxDz<?O?kj@%{(d~t;jF#P9lh2-Dk=cbdm~)pf8KIQ69vp zyLVn8Z(D@FJ4xZmD|wxfKl`3RDfJxyJ+@-8<(92?X)>SmeP4OWt@tlmr&5g_6}oTp zG$r%L96q&gb(++`Jm8GQZEF-*b!YkTF;oAvzzmQAJjIzm97<VX+85{{jJ#2)Zig_` zfM4j@aV)b5r2z@~mg1HBm;+q6Xy#HXzu4vN57lnh&+~gNO()_BAN~0sMjV<}Sb2Q4 zK3eP6zE&tFS6kc5h)c<35J`T8ADG9k3RToE#q%b;UQBKdF)G;H+|{nMui&jw#1Ww@ z%_Rlsm1fLl2R^Jr^$<~>i8R~Yr<RKW2d?9RX07EQ4EdId=e#SqnIu={S0LC(ShvLL z<0T2+g-KEcBgbsfWe)=&t{V!H!!_1BOVJSw^~uAHw4hq4z9|HL`a)3fV1-BP-cL1l zDY$LPOIPFN^>~D@9vh7dg+_Mh4cEVyGlOP93wt)V$tsP2dRP-YbzTeP3+7K+lM4nX z*-5o7A*B9PjOCa^4poF(SGMD>xxPV4gdw-jbUV%qby-jq3wl)Sw-t7j&so*DHX7-c zt2{6w-C+x3b5(ZZ&bEl($flZ&u-6E+V=cUwHED|}_13tUEraC(U4xtFA8PC)Kk1i% z+}3Q=wJKLs(ATZ<szu=sq@M+k?O6-Q-L<`u>C9K6gTlQHW)o*Lf7%|MlUMv`;F;E0 zQIn}eCGQ^iWsxRMGPNN?6np0&<waEM4Lvz_gQC6P%8-&wevek$Tz`w(VSK(3V2ft= zU7pp0{@ZSoB=S#ymKM#bIe$YWrpZ$X8I6Ps59-=(Y`M4HvvY8WgBaN*ioZfH1<KS1 zw$MR)bTFC{Km$~qA~T0-&1^2vhNY^=Ad8QSl!S?rvXdHK)|%Q*)*zBL(iQz=rh(QE z@5!dofs^9k>Gypfdr2di=V|r}y%RH!q<815bO8aA==U6bQstgns$IVi=92Guc#%01 zD%mnhMR~54dfOW<>P#Q&FfR0QLmA$vzWFY-iKNPvRgMY@L6ozwZh=uFHT%dg-Sz>A zGRq&UGO1SdKICV_SkYsh5|(P`@Jt>>*Zj;Vg1(-}KDWNel+=DeU=9>mfqQg;Xlg9H zEW{2K3RmdpTZlEow<?ygJnecSM;tHt0h828GCWxICz^tzo?&)x-wP2^7nCy_7}Xx8 zs8tI~(;*~*rvRJ;t|{ZGTPTVEE%ttFFq8{odN_GdBnQq)YR@B2DpiAPH!Tay(PbrX zh46%TAs&|@#ZS9qcM@=>GJp)UGD3Dp#hE^7t#95?b-^~TVedvjZ2=?EUK`})6L=5? zPr>_@f;WhII=1k*r@Beq)n!Z%H3Y#tL1&K6$H!8?8?eL1<eCX*ih0*+dPlcd-1vo$ zPAWl_<nZT2y1cKkm3O#nz8a5e23$iBu0M&B@=W}t(GyPnP%vB|b=@q56GrpX$?opA zZyJL0=)FPOs|E&~<WDwrH@&bt#6ivnZUC^J3V;im1)QJ)z$4(vFwrX87FehM90Qy? z=fkVAf8T>sFXg=l?p6VilceLQ@KjX{)rg6;QZfiqbK9y-c`KqA#+G`Amp1K!pH%>Y zpvK4umB<9?H{@nIBr?y@L?&9AZ1CiR^kXh!TuQD8I^nYd7)HG`uVXNi-`g7p(|?m5 za?6%M+eE6w`CiZ2D@^K);KU7uiRcA8kUz=4V}3B}?hPLrwozEagO^js7J0hP5osuX zg1cQ6)fKqPIMji-UG;VzZdG{<0J6{H1j#uqA{bdPiiHbk*UCXtYZR-Rz&V%e@_a}L zOoV=;s_1_)B`9sQ!)A+Yyy%V%u-NxE5l<4aO4Cq?kV`Ax$D%)57-qb9oHXeUj?zFT zo^lq7rA-=tP1X3ZNsG2blg$*4(^_>S6I%^5g8qmQM^j5b5*(tgJdGruRH*hFM;Nz| z8yI+zHNvtIfEkWaz2sE>{uqyR;_K>`b748%*lSoazcj>UU)v@dX9f|R59^LWS5@xX z$d1N@o4tx)H#Gn&v?sV&4Il-L20l;&FyYS@Jenp4$^=faK_x=b2lHlQ2OJ%_=YpBl z0VL3MV0m=_8FVVxP8~o5GHKdY$9^N-lfFVS3i|3IOE}J;g_pcCM<=Dra81`8JBTQl z!xc#Uz5r9mwn#-G!n%n3Cst6@_SIq?i<{|4EVL70`Ejgza?4cjJQ8!|R4)?qTu~>l zl{o5o^=rD-F!RV-wbJw6{$_kP<nKZHt)~hZnoo&N9R6lyu!dHvpqA}M#}=CH0Xk32 zFEHq2MB(_9avZY?vq3*8*kUXvMjZQtn#i_p%oDF-T-Q18?KQO?;g!2dLjX%z9UGz| z%zEx1@(8g0Rr)?lHwVQB8lP9BccCYG2d<uDKrat6p;p)X=AfpcVxQmzVlQgE;UcxS zX@#(xXTuJ0WubPGAo=~rHYHXySD1hiV%V>zUbq7?3BH8w57%Ju+Ghvmr;DwnmC_9z ztwuHjKV)X7zVFnzC|31q*~QA;;?Y;^LdGkpoCP+?7-am+_A<0+kva^l_@ld%0C_&0 z_<);bOqJ&Z6Mgh3k1F*Mv=2B8rZ?=u&vn@aME3|4f%(i;Aos!456*j@1x)V5n`ayS zv<o)QuVV8LlIQLQN`8bm$9ugMyLt`ttyIDPK>7Ldi?}s6E`vD36ctRk!wo1;l;jyl zqUt*N_#S`NOf;BJ8%q&IO(Ua)>|o+RW&)|8ip*N!z#CRY9L+}qS^Hy*5@WjSwX{y9 z4s?O$=!XwAbfA2Rwa!Hk?^AChKQWXeHiO~x$ar6b7F$|@2U^5l8EKT{b2R<^E$Sw- zad}@2O*5Ew$}p2GmVNGWq|Y!q)-e+rpQu=>66Hr3xTZ^Ot@tf=Ir8<$nTDY{skt>a zxU`si)V28G-ZCh;Ol}W(*XQ2ioX^xrdqhNfEykB;V1T~GM+{*VmfRlO(fB9^U%ECe zl#9tw0BDzH9&AO8corW0uK<xKIImK}u03DPvWA#*Y{3*K=LvqsqcdeS5^&jS(UYF? zZy%9u6i}uj5E%RvsWLO9(8tCD$d80xW0p^+9^z8FVL{rj(1DsX<+pE>+L&<quoW7f z=MP8r#0kO+2qY2KUpbpY>@|X$QrB)NZ&T;R2^tj}-a<^WeS5W7HNd@fTuF05+luN2 z${M7pO)3gu7&=?Twm>|9X3fm1&?Tp8$|R?=a-6o$*nP8~9Gl5Cptd+Rcy&(xX8jg- zY{mG<3fyYh)BgU`(I<7h1n#oc$XNDWaQIT$wKYiCKj-|1XKi<qrmU3UxJD~o!4CTY z1qZsD7PrccXT1z#MUGkNxV1!TIbK+-p`R#Bfupn&>j=9eLa<F_%W3Z7EqQ%3vW4!% zfSeB3c5O|X<ABLV-&Xc0Vtdl(k+;YTx#H44bJ%0ya5^iC)L>i9ORcOo3iEw*s^Xb4 zLBycaQrr33Z40jK<<&6*v-#^YxlfKzbJ@;>V%vgg+TBF&&|wp5xFe+LQk)jVnwzWY zQk#x7DrY}e#;v}c0^8<{W2{>zF(MD5)^iBp)S_gf2k{s2tUnvwBBLt3?=o_4^tqYd zMzIQdtwU5R9SgrEd`?)opOT9CjdAo2Z!Q;9oO-;i>^Ru1OrM%dtvC`%h?pcDlY>P# z5yAxDG&ZLkx=t^eFXdJyl8*yQ?XyX3&wNL=KFC79Qr<D(r#&%TGdacDwES8_aFzEU zT)yRJCmp4OJ$`ePDzVnO^4v#W)e<IqIj?;YZD~oes5VL#8C@Dun$!==#ds^KKiB3! zwVYyz$gQ&+s_KIwKE^9B<GrVyi>@}DjJ(joNyHc^`%CtNhRatCtZoQ5L1yoZm|Nkr zG@%M}c+LvpevM0n$$eFE8jVSIU5P7BPb}L5ZiWmnip-&kVEiah87~}KX4CjRBqJ1^ zrQaBIZ^vt+D17@n`kpNY+`HwFYe`rFe$)oIfb_3dHXYLlUrpX_d%ELDy<7M_9;^Oc zpRmnOy0cb5!CiIxq_1yXwme^IM>BGaae3v|K=t+SXZhwM;g7xQY)kYRWnX@OeBXL@ zD!WCTD*A}w>@f1w9eaj-zhub<|7ZqlPTvmS3UszpVk(W^xH#&#%^8n+@M|_19P>jB z{RSfOf}Y#m2a|;-YsK~cOt9Z$x2jY1jG|JQDO__FMU08UQW9V#Q>+<MH<9${{@guU zpOAb9Rfc!T;J-|TsJ+3FS5eFmt0=a3ryeX`;wgD3z%RL}WFZ|8(K!5}qn*aW4VBDO zwzc`7Hnnic$;e$)P|>#t$Pr_`{J!k%Rv9Sfhvvda*eQOV8dqQFYvytw;bUTda13Sm z<`gY;dtJzAuT$XxWs$Rtk+jH%fq<Hfb5s5l+9V4*Mw;{~b@K7U`d4zMNpL2?BRoJ% zVAF6$=7#MS`vjINYm<$lGHNdwhN7&5wx7>XI2v=gSone>MQ^T522P=M$xb1e<TD5! zR`604hWU{1%{*nyei9ZuNd@*@Hq7PlvM2EudovNwipn3d^bS!8XP^ad!sxzXC{mi) z0B%*4JFW(+wh6l9Ksphg_67xkyjROAcGh3KJa4G`KOglR1ak}NWNOxKt`e19^s5Q| zlsC7RVGgWmF$amk_Pi$}6BZE=j-m!N5+OFa4bP@qv5}%5cbB5OFuNKRTVQY)6AYpT z*~%eB#=EFykMZ_vTTkPzPgx7_;I0tE!?X<Uy859P;k-&j{Z;d2C&IPmX4<}qP@Q$b zk~%qH5<`Z8QEQXvF@tG^D_k|1yn;`ZNWRj4_%!^Hh&)c1W;;=31f09=x()_`6fhXo z;?q3zqG>2G4ROt6j)e%@DtV-<*o)n0Nyei_D%F!4Y-%Kw)mYl;`K`;@qEzeVzpC0O z5F~I)axH3RF$r{KEh{d|+Xc<f`+e1st4PK%c;oUNTV%%RIzh9g8-$TqKID)TL@094 zTF%MVa8*I^PBy=H$2#-#QpqMLnr=y-l#Yf$RgLyQZTy2@S!t(6b3b3(g$it{hgeD4 z4ysbCawsP+spYS=i`K~49G{$t;aso$NT#^Rx|?Im*yFn`<XnCGB0VSH;R~2d_U@$3 z)n_J?g0WsD*Hv+X+t(aCf_S(je9(?lMGZeZue=rtOtl}cefgjl9eaI2&P^BEt!Ttf zuk>>1B1sa8(R^z?@afxTRc=O`SQ~<@m@iyhN0pz8=x*Jg!!qes;Nomk%r(7YBVzNI zgtEY%R1vj?XdLe=)<20nH8^6r;kG{#OB)^A8Vz5u@&{h4dcQ4~`R$ucOT4`BlV^D$ zfPN5m<6C)&<W&`#GWGf_NM%ygc|`_p(o=AE$=>pw<|d4CUB>0jugrexa^$umCXA{h zYSE@oHAka^2dcI|;zfMl@%Tl>rn;Y_O?1!4Ag3y&2_WLI+8}T4f~TEckEAR}ek_WB zZy5`1+0h*EwZZx!Y{86?&t9bmc;;YzH;Sja2*oVQ)q$Gr7M)@}2U4ik-s7lhv1Vqr zKdL>cn@}9U(?=E7<gGqE*mY}IYSWUq4QR*9l>cn+@kUq0xChDMG=8IOJN|6|4yRE} zrrmybpn-R)2oK^H4Zd3hFHI5|SaBMZcA;BJ%WY$9ct+wu0+`j9RY^Gz?7jzQ0gg%I z-7g21?4o4kyjqq~Gf+S_@$jo*o_R7yz{3Jmx}vMY2n}29{?u6aMN)o_0ES*v#Oa~$ zBTT@jkQz!}89dwp`aYad?7s0zeV-T#kL#F)L?1l7ud#^r)We$&*#V~_paJpiR##ti zJA`-y?Di(?p~)MmGmA{$C=Psl(^u-|FnV?cx7;%I1x2`8A|PNeq7+lgbYMSqPG0Yo zJQ^o(Rmb(4#?VUQ!04uby2<S*xM?TAyf=&~dlQ-o8=<z)zHx3~PF{(W8MF0mU>#+# zMe+F41-z6c8P?ZO3n`*C8Dx4i7h%8QTJZyq$fdI<$?Hg>SC>_m27zVe@#-N>>K6r? zZu{+ycNklTq9D?Cej!1D4~!<qeP$QR0x>?rj_$WYgbE{BZtk6_>2%dKc=rhWg|E<7 z%t3;N-qg0gd_KE%y362`PAoi4JPq^Ye4@^A#pR$4)A*L3abC46rpKH91=gH=*F?>I z?n~^HH2J#e*{2k{O=M!R*$#guaodmk=>0i%yMfV4bf_SCeCQo|N;|8iV%k=Y;h*tP zT&Zu+U4JGBFryJrR($X`Q9qFGhTAfM9?J5#W~j}fdyFnCe1G+2tnL=0M`ERm=o_gj zeKHYio!0A}bImKoflgJ|ZBFj>8h@O3m_Mi+H1P9A>Lx#V>OH9dR~PK2mPimhcO}i; zRL5Eop6y6Mr$#_iBR6C-r#1;CR;@{&hO7e#@OP))mEGB+#s>nUMRDLf8g5Ys_`$2h z5Xz84HypX-U6O$bU$RJWm;6b4Zo8FQ5`4aJvzvS6Qs#!GX&FM@Z|bH5cHek~CuNd{ zcJPsBva`+S-)u@Djh<vWb`sT3i_X)@#N&ak_}k2&_0z<guN-JKT3PKvig@dYG+tfG z2&)3D4i=@Ldr2wB(mX>-(Ed%L4QM;qh?#bq&zN*Xu-Bs=okG_+A^qnZp5D1w`;^7- z93C9I7bt9c)Ik<;@;Ds6X=6PgQA{^Eq02M(UEC#V-s9B8gTEDb+-H8Fd1O9eSHu}~ z=?r@i0PC@MZCQQtb>d?i1EnVu!+{g6U;W$VI*v=x6LW7}0=lpz*a@$n_B$y=r?6>! zJDT%kT{ypoysXHd?E|0^uHt}(!m0%zB;!y#dCH(`YeygO$2GOldXF3Q1Tp`N07J<E z@i;&`9JR-L2P66T27wv+%RIIpL1XU24svOr1~%EGub%Q`U83+R%$E9`#f4bqxQ!Yd zDgm*suY>6)64vq!I1caQwVPJtaily|;=TksqTW5yR(ZdIMK{S<H`;t^L{y=U{eb*T z_?$FuQ2Xm`DZ(k5L2k{$TT;=i&(D6a+XOD~N5{j{-nWZ>U7*|i=Ut8G+wJein}#cU zpg0Lq)|A98YXNyoF`BhsZzq>{*|-asy4Vqx*J;}kTVq3PyJ^{P`R~}a1K3X_p`ydw z(&0^@zQB|FpVtdpDjQSo&$p#`VaHwh5bH;L+%rD;?4@QRZ^3Wdv9i4EL8kAu3vKi& zy(snz3qFZO>h!b`6SG`?1d_Ul6BIL<1ZYS;LgpSpGSd+J*{Zyusvb3uuij^q_=`*Y z5+b*T#=C3!jLLC*#$4|A@w{ae_cDpl)rS=NUfEP)GjI|NhXaX^sio)e*s#RZxfRzJ zhgRZ@?HP!$Iwxf;p7SM679nIcswU+9Jt;Tqsjc(ABc5iOg8VC8QZlq%$)Z?a`#`V3 zHiwFo>Tfakpk3o~`{|Hn!VhJX+-JyPF~6_P(F%?m>F)sY<$wa0fs=MI73Dqhe1Ose zoMQ!TJ{lIc`(kIIByMt8x7D?D<K09=-tQRM4O<dFoh^rV?jxrw1+oq*V$;RVp-fEl zF*v4sJ=`pQdwox<X6{gimBTc=uK+1%S-D2nS*E<FYv_^oVsR_>en-UnO)Nbv@B4JE zc0zdxMWEfxkc4EpX$>X8h;7Ecseu(BdXAsHQ#8N2IdlH4<=dQZXH1?o1?mQrEM=9> zu0uw&I#cm9XyUT6g<%UK8LRf)Y2)G8@3|JrIXd|q+|vg_;TO#I%FD7+I)p*|eDCeQ zHh;=wA|o^nxY>5hfCCKRTY12mjjBcwId?P<{0zemh60Fxd#gaF&D&T}Kc_RL>S>Cp zoMBl4En6~8Y?JtOT_0z7r>it!3X9;k|AUA5;biJp*Yn|XO0}G(Er*=IJ(ZEdTI!l{ z{-EXRMQ(yk!h4lQc9&DbgVY$%a@Lz%D`Xp99h2t5+{~%$nZ5Co5VQ}s>3bd)7OO{h zqtWt-j4|izFgnqmH7&ubN?YRILAjZj<(t&`6?1i`*XqT3Kf?R8190e4otz};Q;rBs zLR&L1R;^g1f1uXQIz3^ap-ckDS_=);`UdD;HivqcT~Z~7;IpGx!);DL!oencaSUb$ z3*nWDlh;ZUXo~jGdL3}LSf7jNf5mAW3Ps@-LTTV}B`CZzm(7n_5o{)vy4^+&QgKz4 zyY?m#xyt!`Hj5<6J$Z}VtCWigtAfTm{#~o-ZK>fKcoPxY1QH=-A|_lqG%DpwEt#5a z%g(^{trT&s=KRm2ZZ5sfppQ`aw8~#fkmf1W=NZvi22)+G^r%bpU<4HUWQU7rNDuOf z`}du-yScCPK02R0oo(Ig27-BjluF-s?D9vA5y>>CI)EjLts}bWC~<|irum9_ets<; z-d~bKS8E1oHTn1zx74*lQ+~`HTkgoX!Ku_?T-o$T^Xi`T<`S~Df|%i0M^yaZ_BG#V zy4xd(L^HdPFX_|m+siEJHv8q0da2Pgy(<9(u<CW;-cDHLKyQ4Fsrh(y9uG()RNm0q zv`q?5(dZmBdgx~Nbw!qW|NFi1j%oi$HI=5l<^$0iS{MJ4l`B+EB@TPP?fi(4UA~p{ z*%WQ99Kr^nZzyhhA)r?Brw`8CcJoe!5{l-uF=s%-q#$X4LzRnk+^@ap*6ayYbRe@A z${Pc{v1|!h^Gs1@VeoW#?QF4<rFQrb6_!>b-Y=;;Y5|pSV~<T;g5YkgUianxUhjT) z_E%Dy)HgmkoPyMo2AjiDbd8x8@R%W2suL^)Up_Cg$@)L3CxZk{#*9iQ+Eax_QzCeJ zG^d5{e9WxYMk|Mz)m}Y~TBG9>OBDs^xhUmR(EsLggi0O!I)FqZprkXN5ls=a>$*lO zas;;-x<jxnUeHrax<=y2`W+9-)BcTgV?mqb+In4m9Ncf<Z-cZCMaHWuE2XPT0VAD9 z?oy58-qq-_7CWF!eny-80TiV^e$H<|*5Kw|&gRdvU$SU9odaa5#E}pzISfv=C4<pM zh{3yAdKGN|{=Gu0rdxDDLBYzE6_XXgxXiT9_nIN^*1YBybXs=%b&~4FpT92%cxj1! z^yB>08Lk~0Ci<Wk<xQgBwmC}TJ($ex9plMM;9>bGpa}@_*ctcrhea3YZ_RePA#t%6 zIx=|e<kZs=)mW}o=)ip^mvImEHn$x1IU|tqqrp2uZxEJgSO=y8{CW-TSqZT2Ly$H1 zt!7a5b>HXpt~i#(1cW9U@CkWNYr)65cRGURHnhb7Kh0Cejvqr7v{O6D3XWX3YID-{ zEu^(#=ow$(!(J}P5`LRT71s%7X{!31%HU35Kx4WFe*6Fc3g|tVw@{p}v%16V4+E`K z=&w47>Uf7|Y&O8I2yQUW?N9Au*}7eooSo=*RO@>UL`jA=D*D8~i|1y+D%Jo_Y_MZQ zo0O+kbm=AA=sTm&nxCBOz+h_t1?q6kNs7U*${LoC<xjNWuhswwq|*5};`0}uVya5O zST+D9=xnfw4S)std3Jj2O55T`q(de+(+2PsTerZymD;+rt!()NA_`RznYYv$`07Oy zx&usQ3!nq(w`{GBip?6OlGZQ2Y~*JuMH}dP6qf7_0;L%Xo$K5lM{KDErZ>r#vJ*=B zfY_jO`|9%WQ05WBYFO!qHN8@lDB{oxO7(j(*}W9qGna=Jdn+!>LTV1FI++G<bOlyx ztw|Kln%a_8t7#F+BrBF@%L#pW7je?lUU}u9o@h|#&$U4O+_S{d<n+{GzU7Z!Wp@za ziM8n)&U3I`UZoGc!FKRLYz@==x)j``Z4yLGEU5QWWKI%&kz7Y!st;tfhpup{bAV_< zhUM}&<6Q5G84GR<W1DW6x{ei2DW3iKf&9y($*)<3A>7|6UGyCpS?p`_IKy_(*$7qq zT}0fVbm2Ld1%ZpJ9?bijuBXAna^pfZFzERZR5iB+gG;X!r^|TNtXvdUM#8MFPM-6b z<R_Sji!?oncWSjY!lFc_TDuulaY^t&jz71@4!3?y5ITmYJ&K1;I`c3msL-9M%Bb69 zgb{sB_wnBF88xU{3}nKm!;!y0-;pnw3C#-<6RVN6iq4;oN59eZVt@85#z&SF4Kf%b zYHf3A@Nn;cd3vmK{xB^^&!U{5T6`O3a9Wl8LwlcpKh?Y#hqGlBzxd_WNo(8gdth6D z`92Rl$CQ)xkMNOc^kcENtP~X24Ge4P@hdz6O5d9n$%+VmsPBgHmK#6qIcYPi-2pN{ z-*HsLnBt~s?Dy|5vi1E-iuw1GV_J?S^nNyf+iE2*jhlH8ZVkbfoIiYsg^T<w_CSa+ zzQ;T_xiaI9XE@G@oU3(LAAiZYKf6tKoL${lfL>M^HIO2rpGUEC=XyUulP+qcps6-y z%X0H3bA+CzTxm1@N9zw*Qp*rNRH1$q(DyU3mL@5D71OmaUTk5xyZND-(7eEW^;rpU zqTbKd<i0YV`-JBg?jEu1%$*Tb$zL9QV`${zd^(`Yn+(lKD`KowjaCr#t4ccJh$op% zh+ikY)hJZ+gDTy<;7Alsf2#bE<yF_`cZEe7XWca$beFWeI99CpyZTp(bZ0gasAmIZ z7<S>E&i!x1xR>X=usc11*r$(AhN46d9!Ts>a-9bxL-y>io``?%56Ys7;Gcef7p8dM z*g*nk<DI%>vS;Ifrf8U3y_xiy>R>DFt3h{OSv%fgJz%HPuQPN|?|ztmv;pkBXY;;@ z@j-0Y^l(BZ)TQ+K{L;s+u!vbw9K`1>tZRcIzwv!mn*2#rE-b1j%X&?KIs_ag5;{_n zj1wbTobzd<;bwMdWFu)`-ZF&oiv+w3R(&Rd8gkNvgc+0YJYw8pZHyVfJ{nFfrf(fZ zm=LH8n(L}%2(dA|AXBO+3Xi=w+x|FJ2*&Fw;AQ&N7QrT&xs|i_&hue!1(Y8G>-#xd zwi)>~=U@<<#F)=i=gTu}nz2WtoD%PuH}qeS1aRNw;zq_H2p^Am5-@%<lca_9agk?L zjVKPQZP(?fl+SlDn>)3T3=cf!9tJX95qTOg8P#}Qnd?><$XF9abT(QdujzsJDke#x zL&`@=zT9t5evaD`IrtTg5)YCvmZSas!3?2mYLgWQRpn&PxK2S$r9-9}t>nTXoldj# z)TKV=E1v-Ez%V*)S|c3ar(3TTElzIF;+j&p>Y!A{01%!81%aE(an85HS{SH}qp9s` zN?Ei5U%FQZO8kf}uhrgk-xz{~{OUmN-M06wqygizL7eafTKbI#TTURyOUk9=n`bDm zqTI;kx8(3{zt8W3l3>-rsju0SW`n{U?jHBL;P;)Powv_WSG;D-mq`w<D}K!^cG_*K zxc6sg)V{xbSO_CkL|2?x+zhLuOjT-7q;C2$b1R2_;2lNJztS7@z7_pP*?^U66JTQS z<-!dcOr;y8e@6e^Vb;M$79rz|mp4A}b?~Nt4^`D!pa|6m_B1<G_|+pyBm0_4Yr7gJ zwwmJMZ<?<@@hlo%Z}<xF=~w5!iQ;F={;-3%Y+{3HZuC&K`8?F9_C)afc2fW0+o5aj zhwM_T^TyewW7}hUx5%Cj%eD?;FpKlcBh<Rl{b~5BMUDl*6K*4hE6AHAFkKe=n4?Fv z6aB0mKJPV=1=NRUSar53S*oJuirOj{0wi+lww+_z32H|D*A`qD1VIJ7vU4|*dI5!X zlZ&L~M?Q!6L*v~cGm$GvDGF)D<(URo^f9709dnVYJCAer&Z2H;dg8VcPYf=gNMdWA z0PQ#gCL=Lo<0m1gfC9xnFSM}`1;2eCS7SwVeeApxO*bn|Re7~dE|=8*`*ujrK%rIp zWDeiPM*2znLY;&84;`n&)*gkLVDBg<i9wJt#z2)3f`P2x7Rgc?Jh#g?`=((<7-_TH zD3Xi`v6RYVWTDuz-F=Y$^Z4{(+$p+9)|FCh>;z(2pO0NqMRSC8d5pwog;OqcZN~Jt zlHFWu`};x^@dg9#0XqR)%~|Q_m?V9E!Ot0-U0zGa$vzjNOKdhOB&pOW39%^)NH3{O z2kQ%!NbQFJROKL66nBpi5g(tMSmNw<em>)BKND-<h-2XRI*7PaRH!f7+*gi4?I*Zp zQCqU{i7>^8GGwb|FM`1<U??Dc_>KvGGG=e>!^QLQDQodND+=S9BbZv|{&>IQ$pt)Z zGkVjGhaZ94SbBP2#^AtsWShSVgv#y2j_<^^8*H2-=Uc2&LnmP5@NgnEQM^=Vqin`W z4@;Vt&2<(!EI?)}d4(kH(_)68_F0qZXT`RaQKLlt`E{6sC7!;W^}S!3ovuIg{pDKY znudKHH0FmcRlrl+MW`Cfx>8zgPw(|q&RU5oF6FT`<Yoh}-K_{d1^s$|7pXfwvt5+6 z`r}k_z<GMtVzr(i)tQHJLGFjO?<b|zz4JubRs}LkAR%a~oC2o_T7I>?(b}B0>HtgO zd2E|R^)Tw<eIObBc)oKF?Kk~%6R9>QUxzQ-YAGKhneA*&liQ%*O5#*Dtp(O>_{t$u zDoD>wntbV*@%+XzQM3>BIs#@`K%TR+pW?uTwjE=6)Fh4YD+9|^a%s8VpzPxiPH}wW zDxpvCzI`JoF^Q4QV0@UV;nJ$y{L`>1vK$hE#$lg<b$Q8~9o2VI=~mNQd{=&1_o=ah z3(lj89~)L{b?mj7o777?c}JP2(+ruL_*8j&>c0WIFDr+8--)~#Ad8XCd37}ts#`dK zTTZCb7wcWmh9|pi^|H~SeC3$b2i@TE)u8_xZua92h&EnTu$8mMm$*u+{^Z7;#IO$( za%w77O=Gk3N%iM7iXF5mMf^(xDAt!r5CRTQ?d^X&9+mO67sjO4PjM6C&3?SarSd8i zsS8Rny}sM_4JjYeQ+{d)9$Tp!)|1$yo(5oXQ6CafY2XZu5tAfi{JOp03KJJy`xe9A z1&1XK(kn-z+Z*=1yJe$`D6w^Qaf~X8mZK}BUcZ^%XwS$@`#A{Q)MF^xP4{2xVXE|D zXndnqb1bdKKFM)ryVsW!p^;SJMMLu%Td6;B!FQ!3Gi|$YW>ApC^(QQP4~<J5)g6&q z-C&#G%BS)rYwO0042>7s)Hq=t$cj4?TeQVN@1+dZ!{HUsywv)2*)%$vGkI~<fY;H- zHOAcBtr_47HQPND?MKzO_oms&R`D)xE4QjLL^N-Bu<X0Zy?*4O*Jkh7vN2v3dnJf; z7mM?AB{G$<G;^|Ha5|6_A5IU&dG*MUMNyggwn`Kd3TiPW>+FxF5C00`btBNG%aDly z6`6Z{j=EN5X9e8B4*>=upMpCJ<PLQw(!4c;2m^O;^~bt=#iw{Kctw?nKSdP!d}STY z_Fi`KsT<W8XJimI>k@|SL2Oft@F<x_!wK+7*J<Px`qXm_7}c{j$n0>4w4LsTVXr#( zAy$a^9W?=MI4^IVZJfMCzEif1Qi0-*Kah4^HsweuD7N{XCg1sPBsW!Roov*dY~a(o z=U4c3tnWHx-N$5)Z%vMe*Iy9lj0<fE>diVF2|WnyQ0s}(?xBZTqTU9%;wp-i<M(mj zkVvpgiST~%`T*A{Z|3IJ2y%9JbVmMuz}$@w3JgOk##D;B|FwvprXLNXu1zu(yyvE` zltvzH<AI!pI+c4ij1ONp6d!YRBjj@+46e2S06+q<{mV#n>m>hcFQBm439=WEV%zKd zvK27h-}3*r6>z}vF`5Mor$@Qw<MTfo0VJF<e>MW%)f2y=L4uPZUTf}N^VZ9nC1?%3 z9HfXx{Pk;eU?m7t%(WdWEK<`u>;x=r<*39dwHIZ4TfrEf5mIJIY0<vqjQ_OiF>Och zp%M#I|8AtCsn$j9%-A*^dH6&^{G;T^dhgZ!!&D|mi$2EyqR-~t=kAX@zff*@?4vtA z`QChuU-iH1L@GtciYDbNndIT6))div{~J(q!5EQ}i7Ofh!kzL!n{sXIEa#u%+u9Ao z$N+$%>$3Uv)7@~&R7Tatl@Vmh2!G_7XFbqwC(9Cdt!~2g*$I4Wojp@OEVh?7rZLwI zz2td}k89GLEjsbA36&^!sRE#F3B6`Tei!!Evwo3ugD7{*bN6c4es4+P<$m7LH+6DP z2ubh|XXQW$baWu}@@KoGF;JhJCUPrTlkkI)K~&C3kQXpIky%>-TY6Rb*qf4G17`B> zP+{jn<Eq6OKqF4(rIL)7w6j9t{qPPaK5Tfugfi*6kY|mb<5~DVB8wTzCDA3iD9g=x z4!Yta6VZAkb0jBMHuMO=XDemYJU3{#AKWO`h0x0&ZC(X*6G><PN&$P^OrmcV`>*_e zv9B3kPm0avO-G^Xa0W1VOr?He|G20gynlsstbE{fJhc_JV|h@v(%5{FauXL|zLHjp zDrGe2qO$2I^QN^m1ZQBB&ox&n<F~T+6!WE!#8Y!wiR*Lla_6|bjTxLPs=3_uoUmH! zP!XIoC<$Tzoa*-xd6Nng{ISY0iF~=dR&JuP>jJjfMou=ozdfJs;18&|MH(+G&hqL4 zqzW#=V>p4_nCTh<i>i6?;TR->pi<>{)~w#b<-*JSr@rbtC>)8#xAF8PGj{s|T|CW% zLsV(yA*k6fr?=aDUtzBT>#rpU6Qb<&9koMuKzcuF6hMW-yrPufei=nnL^UHauy5zQ zJ(BT}`_!?WA$`s62<{r4!LyxS$ZX`T9T0135Uyo*zui1mA+3{~<FJIo2NY64t&_c0 z3Q)s{G<7k6KAs|+Kn)eiu2$BbnTpv)x>{(R<QFvj1QzngiVsoHV`-Y|fTAJx-_7jW z0{Lyv)IeKs=Y5rJs%Ja6eUnMde~lvz>>Q%jycC@?2+u)wht5HUt%5Fr%UBCOdHccd zS91(eBrN()h*&_VX|EEPhW~x>l6g(%eaBHhdliy0y5cH^LxrjQNl!eCvPpDJ*tKCt ztlmkY*@Y)gM0f<hSd#?4pO9T0dVwA#9jFU6-;@ARQ&~NpGfZATUp^r412BRuSBD4w z!^e;}#_xzo;wO>)S@_a>Pxl>&idwKJFy2CiCOW{zzJhl8sjXaw2%DTjcA<d05O?&U zO)S1rFB%;)#nACew!0Cv6_&A>xr)3vJS=OyciwprUD!31Jux$d0YuipdJ|ZT2nV7t z>rb0|xv~3&79G-}fdX4_Q-g5(1}4AwoM{Xz-gHA-(PLZ$O{_F*Ecb5z+`zelLGSlI z&@l{Md@I2rA>0FMNMaHxk5)e`>t6Nz-5V+4xFG)vvoe-|lEaFkh1Q^_M_2Elmd)<Q zhnnr0VTm7P3p^$&ePZCb=1;JcKkh+wbz5qUu^@kF6o&(tQwNNwrbMWpPe+&ckLwer z7LKfB3rx^nc)In9Gbwb|a`<22&?GCe83olPLf@^`y^4l2TqM7)0hLlD)MF|80ak;X z(8TM$n?-~soCc1hI#P}RNnS@78Efgmq)Oo?<Rn_n;m(vT$Y+0x+#&ozT<{en{>p?( z1NQ=sNm4030>Nk=7j4-h*(6S{Pg(*C03TrY=9i%+&(rf`HQ&Y9Z{^P&sr-2NW`Pf; zh2Oe}bsoJ}ZLi{Z)VXc~SnoBk3oVwE5@@vhk}{PBL%{pbdN!UN69-Rs)*bc@23py7 zB%c?`d!D|74^B+Xt4xyDR~z4h27>frE}Z5w=_pmT6T}nuJA2u6C~b^(caa-E{!07O zlSH%Fz1NC>{V5C;rGj4NH42qJ1*$JYxoc&z`-vO5*_Vcp9?9zGYqJm(%^{-@6r}P~ zRF3$*$DY2x3*vVC+DWwt?4_jneX}}0u<*$P%h~{|RWa2rgONu8bw*7o=!fi`QMf=d z&t}j2Jb8haHy<+j3)p`RA(-OoGyi$d0SPHm@za3Y49A9Y7ad73@2W~)g-J)B*!Lfw z$0Gvz9T5YnJ`?&d*&2x=COyEg!FK8$xQCyst^hzne0}o)4`;=Luh!fLy^iW?mTseM zj-5p7VGZk;^&)D><1+^uLB*yThR&anNP@-5vJ!hA9ocGNXu7rvGAXx}<>}}Oapaxf z!&{Ty7VF<%IE*+n3TXgq<eYQ#Q<HvFDIC>ZdY3#EBeMLK6;auvs<xU20R;N<eEsZx z2cTzj|A1!jd1n5OzSLJO9IrrP1?4)PK{feXyk}J%Oq!EJQsy_=1`4Nl%DF(z;l`I# zzu(U&E%6yj?1py2Mj<E8MY7#R3<C=$q==xX4m=+Fpx%T}zC77A=nO7;3knS$Fxw$9 z#A;$+B05KPk$PsQ&y|)`52j9E!0E2gUy~_GIP%NkDNMh}0D^%nN*XLiqlFmB)O#p* zBv5-7GW2<Zvq^6vKnTILWUiM}Y1@fJ{DDf%r`Wm=9Yqu^SZdYfgSN!Z=ASrH5Y)(U zDC(|$y*==GLco0J54u%^_mXF3F6<5Y@<2~l5}4>!ldh>enx=<aqNZdea8<wL8rjHF zALiFvn*reFWO$Qdrb_)0MhTe}S)r^^OOaCxyW(4L1<jRk21xnOh}=^*+*7r2{knAt z&D4N5)vYE0JDHIe0EK=cY)huB5GF_FuP(c4I%-MbuoSk7L57wC4Lw0-xisuygSde+ zLPgRt*U?F!sF&6bmF^>T?fQ{)1B+&OPy^7+&{}d#PWTA=k02=}NVF8>A2=WYKnMwN z$qfKtzDE2L;6gs4(g9|^BftkwMgsnclgW(&h#^3tU(lv+S|(mWL8X8<4_`Fyd4Nbw zs7ZjuR}drnU;sBf1d-(co*^<YMIqqoj|dDb0vteWK!;Zue?)+SdJD!Z2GD?b?%D$G z(X$%4dGNH48?;srzy)@R)M1SiiLUn?VtG_LCXxvZvIFdm_op|?MYjBj$9kG(@0S;U z^zA*ypr@Q4QZOoG<TVY7X8TI*mF{(%;!&xpC)w0yNxjF6b(ul$E3AuRBZ|hzE)*F? z?l@Wqhf^HR;@|+}wdKhIa<V`jqG)|8lT*GySWqsBm*^t;B&6f(xgEYPPEMXa=cDHX zJy61)fvxPZaT8S*{_J91l(L=4>WRu{X?a1$@utNQM5-j{J;_0sch&5Bg;R)}vW~S< z^5280I#4CP6OoLs``$S|oHMkijaP*th%-^W2E@Qv_G9EQPkPVHyE20Gy(o}UzN+3J z6p~oEJ)93U13Gf9zot(Rn530r$2m?yiD}=?sB>}%hrlHu{(7Y!0pm;7PK4n8iFYF6 zE8WBwbt$EGB`w;gt`1<<2mM>=mCOiy<f_*Tod$UQlJ?x^TrJ-MFhzCP>92@9^73{~ zOhnF$!h<zY<wmfby~B4wf$TL_`5Vf$bis3|fp7}0JhDTmF%gE$XqY?dYGXdQrZVxC zeWmL(ghOp1@v>_6@6>l9;3dM^bhuut)D(r31UAv*t6S2YQoMUji)BMjDD@Ub74}_3 zPQYDXsffj!P?e2agASy?0TXt4q7mgG*Qxn|<4%qci6r>LJyuXXXfgW2CRvsv*F#*B z{)6*K(1Rt0_8460cd@AZnA1W|k~$9ZvVvKdj<$BGl2-|*3#$yO#o*|&XpHbAa|iOi z_w<yT4WmDXo2^l)CSF<B2V+uIhsjH~NWs)LVwGx<u2X*E&Ulv)<m<`eA(<cPNlw3T zCOe~?7`T~si5__F0P3+x%AWP#J@}46++CfItX3eoNBgZh@@)JYp{~DyzIOnxEgiCB z-*C&MkXKMo8ADh0az@#le|W@g>r4wTnqCa>2exVCJG8_+s|Zc)O&qZn896bE*CCfR z7H?sISPC>bo{k<EzM(10!Tj{kzgwuBBmBfTvjaGCar=2yLqQ9oUZ$CoGQ$98Dom%> zuPZ+RbcW$vb7awe)Oe}7ZA~&vO|=nN9Z3!bnuL@>6<7)AEB-#KyC~V}zJPmuy}_5y z+YlMw%<}3h0}*${7kDv)AuJR&vu;=oQPVwz!LNLaykrg`(0r);9OwL<&<=OV5#)!T zh_XEh@;{Uq=39c44Dp%@X`BYSJ!}<zs_ii9FYj}+5Bg7G&5`M~d{z3=Zf}byt2V-J z<Db`I1N631!~T_I6yqBTE|^pB-n~o}>(Ods*a(WJ?X=0!J#R#WAK{VxT&cml7Und1 zZE_^Bw43PKrtooK1N)pLO*dKP%g1AI2q|X|dCzVdeXTp_$y#@8@0;;`_1?hoGN`SQ zaIT6%$IPvGb@;~wM;?*DxW4*aq#v&n!y9d`q*NmUON|dbDhVagm8vVW(P=yd%e9S8 ztZcNE$i#>Rsy6%g%s|F(EmSNicr8H+?VCW<PCZyF%DdMZB^$Sa_n3@36{mDBqmcdH zoI5SnNjCx{lM#@AS2@`$zg;9?DL7s(U*LJ5Q$^rmh4#7fn+w=+J>a(3u1&s3!uNR+ zJ3GbGjO4;xN-Yelf{2rc$>X4>Uk6pNakPi&tk>0a6*oL@N$&>EYG>dCU{}19=+ZW1 zYw>6(yR$eRGDi5oMCmAN3(o^kt!N+)Fp3{}m6Z?Ls~i2)nzS5kaT&@r<SVN_Twn2h z#oPgCinFv?<wkN=Fh?kb+y5!{rU7X@`)YB!MI6I|R?phlIRF#TDzr~UQX!o$&&J12 zyI$Pj!?#*EX(1#)1l0z`W%;!vG*fXoRfm!P{#uv%w7-mFq+Hs4Wo(703Li_p^3eoS z4|)M~iBp1XCi0+b-i2)i^UmsnN5n4RX`y_E;rHiqytFjijdiZPcN+{lCp>jAU(MYF zq?o6CISwb6y4H@e{g!YSoQ4Gi`(vFg>Py&g^{DZxsyWv$ah7dAT7F6~z7%OE>@x^W z$xXt^e5d!TEU1WMp|#=Gq2p&uumQ16$dectB$d%4emr9l1uIY#5$I@`aneECFF57` zSc(em*GYC5+z*A@eWkk+-?2E@IEo?tjl|a`TTAg}!=~#?Sg{&HHX-i`iUBRJIqF%; z&hC*o_-302O|Efet<BRX#A+(-;!@>>|H_Wjeh{j|@#?x3*amKM`KaC-SqWtPc~TA( zv08S;`^l-$Q=MTX!fR|MmVmo3qx$u#nsX1mUW6^x#uD+|s^|NjOnL%~cY`;ppGnGB zyCkd>M~Pzhkqe~gNt@0C#llf0KJUp#rhV%x!06*@M(P!8yS?wv^P;>C&&l0lomZoE z@blYeZ))w6KURP4Zhl>5T;c3ghpa9Fs>h-3=sBNZeHEk@T=p%&B(E$~WM1~c4K0@i z;W+Ee{mXjA%)FonZ9DREXbkMo<SyehYIM!Lq`&8luHD?q7p~LT(p}UBPnQ#eYKJFn zr9HR|GEBS9x1`Z1;b&A_O_KKW5k_6hO;dHMeH{%BGUy3f9ipOAlZH==cQ*6S1W^Aj z4iNuDP%B+c+t*UTLP43rgE7f~culjF0KR{MdC|TAWFWD&VC@>f9^{%XS^E!YVy*)u zK|`+YF_rO-@8F=IPQVysKtR(@J-`4CvaUFx=ji)qU18D+7>C3ktNntjYkFCT5Wj>= z^ME&(0Qg|7Hoz8S1tHuHD29hv{Ok_>5&FgA*FS3x09Zi~___(B4}c5@(IXiGi2Q>L z#{mS8)d$#n7O)M;G?@dm{^K&~JU|8FvdjEm-}M&&KOqv?ML_23KTUV@v!!YV8`c2u zz?H&4WH8zipci6hb_ww6pD5$yWx(V=wN-uxfDs_&rS}0l5Ww;iunW=0KLD8AK#<QS zK{z5L6XAg1AFb2BplRWd00&|Vd~!zck1NaP1ksRkA1(;m|FKSY_csscp5PQ>3I2fq z!hX})1HsGv=byDzCLHh_QZ5c2m<J6BLw76>@ydD$Ue}9-^dneE@@1)}j|eRJCx#uK z4Cwk#<-XKFNB}pumKw+hv35)il!O3I8sI;qh0y>NAd-cDC5*H{HHajD7N`XQE3`m$ z2;iXmTPl<er~#3z)BRQEq6ex%BoXvLrGHA%1K&dc55r%bXa=AjL~_Ugl!E|1MxYJ^ zr2Gpm7=hXli6YZqP{H)qjaSTnm5rJIO4^u#nh<3i7N9N!IJ5kfjI#W7gP8R%a9{-* zLv&_Y|JF{%_P6bhY(Qm5Rv+76%f#$|o9xQ|SGk8Bs0h));`j?pIsO)}`xn4+{%xr? z=U;!CIRE;L!}XUsD=r{6#7-U;Pz(aLxc=JV<Oa$@&WrzvM33P9+l8InKtgCW@G>_L zNd9L;t6UX&ts+7};lB(7;QuW9Uyx4#09^gD_y@D`08t<ni1NIYjR))U0BK17l$FiB zM@4>FrZZyyud?7g9v~$C9z6D^P#1Xr<vXO%CLcvS6g(7E0os2T8UVBL{w<`(3nYYn z%m#qjasY%(%I~0IaG?JDgu_1*Q2(#WxPK=F%Kz~Bxd7b53uGtz<K0k^uKK@PfdA0C zDFkEj0cjvw|Myno<p&V{v;Ese;Cvn+HrR#_hzs%jf9AdaR!suu^8NLEl<&p!(`o>i z<O_h1@xMK9%|_R0eDUSabcXjIJ_&$X`GM4sX)rlUpAvi~4#b0|0=w`7sUX~E@W0qa zs{??A>j1?6%kKZ3Qc?cfwW3skzn(D(ymSODSVjOy1F`7z=Q}nyMgaH*(meA*T(ILy z$GpY(ZyO}w^M8#H3jzsYzV`mZ%*#BB3nB5|JV)~N%lr%fzp8&8{6|%62=E%5Blve9 zeg0!bZ2X_BwHGT82jbr*;QiZSSpPwe9vD*yNDfg-N30u)dSPz_1_}!2Ka?cFDndX? z$e`YySUaM4$)tKo|EUBu4*;{y18~6=LO>J<+l?c)0spYA4*n+em+c3k7q&$f0ARZX z06zME^&(hI_=PzJu%0lG5@O=dRRIhw{L*1V;2dEfHG~u9>=KKATf^}mj@B=MV+DYC z;NQYP28g>YGsPb>Ug(SeU(B~H1HcE%FXy14$Y1L0MP8_j`Th@eIU;|lL&lgq|F^Q2 zlkxxg(1K?~fD{nw&e{$W{#E)<R?xxNqCiT>sNffUv48s$tSJhlg$Vp#1kn26EKwje z#0tV&K8Am-{AX4B;P0Y;t4bTKxc&cDngWxH{Z--~%^}@**(s<%{_g?T3^oz_J8EOa zUV38ki~#&}MnLet#{D&|LxkQ-YmHwL?*G$jD5y5@nHZ1?Laz~*!)4gZG{yAN=>I&$ z<t_-oo)-j!U}f>Y^csr4wDvXFTm1hFT0G>KI?de;H2575OQKlt_1E-+j?gfA4bt^| zI=d4z`RF+T9eweS<g~w%(z<A=$Ny2?Q3+Vs$fFop!zwj>HLH{YhBu!Yg&oZVCVDSm zq6d~!NT6W)eJ3exa76Js105keUDFv_&|Z7yDPs#vRg*9><@4!<&QiK;F{+@@003}< Bqf`I@ diff --git a/htdocs/install/doctemplates/websites/website_template-stellar.zip b/htdocs/install/doctemplates/websites/website_template-stellar.zip index b4d55a83e7314ffbc3a3deb243081f17395ff972..f3ed48c6729a93142095cc0aba87b64b2f882274 100644 GIT binary patch delta 22710 zcmY(pV~{3I6E-@wZSC0h?AW$#+qlQJZQI;2c5K_WJ!hZyJBZVNGUKYwimr;dQk^@? zuwB=%@CwqPU@$=cJ+bLF3GgJK{|RQw{|Q}||3pI)vgm)ZsZ7*V`hN;yf}+s>6yt@k z|1Gs$VFAPb`VVUR-~qn)KiZi-u<`5vFnJ9S1oHp1Gy^{nvi~XJejtp1e~5g~-8J_G z5)e?R2oMnRzprpNHFCCeG1Yf4G&gmocXqVd(s^^j?U?)7@Prv!(;7qHPV`Y=)zy;L zsxsoKO~Ip3tuzW?A&Pi%V9e;3IBr{me9!&Gkg5-wo+KQp)WMG1)jSUuD^|qd!r|4r zWk&d_Qy-=5w(32yZVXt?lllI<KD<dHdS&iFUl6fkieNNhHnep^k;n}X_H4K<k<;k% z{S1qGNi*lyZHRhN2bexdel&EZ_(e_q&QgEaeb<iGn&-4&l2h=^*OrmS&;N@VfjJ=| zjozBBlbMk>e6BX^H*XYi%ss51XN+zzaK+gzqTM&hB^#kqO#w)sH+o2yFB{04G-?^j zR}JQ(UepOCv1<s?gMjV#^(r+(KBu^}r?BVG)xEYa6^RP51RA19k~inq(bLJ1rI)L4 zotZO5jC<U<*k9sfCU~bsawe!(usn<Kq5WDZ(+|@75$$^Uv&C=pRW=xeIapMda$HvJ z&dNJ518aq`cL+E*(hH3b5aKjLB9tY+p-2*s69d?^t(B#VCxrL6G+6tw-XFmyeNSBc zZEJmaZ@8L(Sk179ix@|pGdwdh-#D?k|HYBd?*|ze$O8@g{q?ijEFq@boC+y=uwscP z%>X}7_K~%y6WyuknNb^}D-^Z#jg8izl=-WjeP6XXJRJbnP4qN;5&iYC;w?Sdx$W&V zsmEsffgifWp0i*b(Zgoc;aOKhs#;dafJ~q`2;#8s_Lc4lET1?<v{kuAY2W`V#IUFw z<P-U7fmMgjWI#d-`#W(FI!{(T7Ggk~@_EZCg|dzh;Z3R9z8i#AyZ{z&88WuhPX4L3 z^e&YBL<(@0NojjHJsEAgFOSa~`dOgcYC1EP3h&ln+5}f%znW}IJ|w1WHkP=S@G!oC z;qA(aML=*o_2t*aZ}1hg*T3iBATrhD;q<+L;oTxAa}HyhyzV${k%XF32|WHdl@R0- zAP*X_$1Nx7$~d`X0GIJ<KAuJ!Fiz`<Bi*PTbPlMu@QK(K7&aO+N$#_HgRw7mgnKW> z_OoyY3UWmS_RpLW;ZA$iZWcfjnr>(KmEpmh%|e%|2otiD$P*v96|S*IamL65sgWn{ z6v>3qg5Zt+5G-<?SK&Vt!VIlZxfV0joZch?9`IN!=L?+ybI1$NiORGL!6=~zavLx- zgbQfwL|UCq@`GtA@u}cerHS?}6SNC#C$?7lwOgb}^!L{^Mnk&ctd0O}$x47-n$0Hb zl2(Wu1n_RnuH)#oVN(%3VO%GWVhe+%f}!QoHgEEbdFW^?)dlUdv^M<XI=e65@4GJz z(s%^k749#`pc3$xX<}5nb-&)>+840}k4u0J?(XYFl#fQa!sQ<kks=OIp20H|8=%yO z=n)Gx8-M!psQiVorjiY(hEO1!z?cEjZXQv~0@q}?uC0xYjo6+PoXqXJ#YR}V1Z4u@ ztBhkNi|B?VD!7xA#35uK_5)jv1kKpk#PG1UbbonK|798;2&K?%$089sLE8~NCRM=s z!<XZPnVsnMCcGDs8*}jV0hH!8VYkn@+9!RZBBF=`{S!%!T74H`CPtqc9w7N$mU}C7 z*AAm>Kfb~Oec~-p?JHL=cJ1#h-j82cPNc~6AhGribIyvm<svk=tdH~4^%e5RYk<Q* zMc=Rcbu&)2Ov{wHlA?Vsv%F4qmMnlz_lTrnenE2q35xOjN1OU_3c0HkLdr%fpQ7~d z)Hk-q>uB3+x3#hms0=-*RPtFmm;G5u2cNA_o7t!y#(PznUNvN8mWNXshLD4pBnr)P z?FExKaL`A!(Ddy9MaI5WX?AJh!GJG{OUw<A+_q0Io!!(J<0rvO%oCCL3PnJ`DVS9c z;Oq4=>Q<?JEcZU7phf!*rd%tymXM#zP5CJL$~@e?bX?!{(gFugzUlAxQ=N}-&gC90 z(s4I;b6*&`GSP<JBVrXS;VPXv|LLuiAxixzsTcSk-wY98{Qz=KNzfxfSmsYZQxb_G z^#HtmA}U~Z0Dx}v&xk9c-3Z_$xT1b&Tun@-hP|P8oCVIpV3j<w*QDDRLS(wXMf&$a zL$&<sWZ?bg3hXF_&b>3VtD?Tv<^E*wDL|BRQW`f5opP+(wh?!@b?STUpF;qC9vg`u zGup@pis7dg#<apMGGA<|ACYaC>~F$Eo4~t7nc&R3*g!C2S2i+cJOG>~iemF~Gn*!e zzvT#0r_w-tQ&1lQe*m|VWWCs>D060MAqIGL8{Qarcqmx<jl9o<ePIp`ZYi_JKxgqZ zvQ1TFUU}k3&9`5vE3rU1(`N?a;;tnJ2Eo5&9A{7RJut#crq@8H!;htH-P5~^BdVqi zjPg5cL?1d$C$9do00Q(S)t+5rB)+CK0s36T<}dKw{9+v}lJWxgJWgYCgq0Xg8U4)n z2WjnC_sqx?fP>@=%lL4yBN^E9FY941iJtp81)0o<64AE7{uGf-g1#7RQZkru;to4e zp*nzeSBM9ghWR213b0BbDUtBPi9*rIWg`jr0&6J|S#783C<Dv~_B<>j#rcPHNJTz4 z!Otk8LqCb;$Au<ouh9yEX)?SzNi|zqKnrxzHyQ<-%0lEMBk`ZtcvtC>QDdxt>T60& zNWhax_ZS7B8p#+Ez&83A!1^5K;fNQoz%cc--ZcEf=Q+tb`>995CnKyZ9exQDU<!J` zNRvaif$eckivpTUAuf)T-p21Cx56K=Av*^MBq}5kHywsf$7(OB{vPiB01`COWr$ML z**z1EXwDPgwM0^B*|h@%K#qUJ0$~Zflw?WE<bFX?h{};}a81fVWko3__ntDg>2P@) zLBp+tD0=Lo783CKgW*_n#xpGmB<8PY+ZdJ7j<lM#0|N-rz2|`*lE*4`DV!e9Ribyi z-kTCrN*96x2EFK#RN17i$<W%yFr-x)G$yAk37_u&mgswDQNN-~v#QB_8+>Azv&J)@ zic-&!#i}aVq;Q5QjL*bAJ-%x_xKDEsl{q0^pMQGYc=#g4I@}{9K65H;0;J<UpiEz_ z_?sr_vH|Xz1E*t2W=M<Hu{UXOA|`n@ux|<<J8ui6k}L;Z>wAQE?Uvd7qEk>mV1pA; zEq_@Gx`!o^F3qQ|nBG)Zyvxkf>grxjEA|l-7ZjtOc6HY1u2uQ+F1pi<rD^sf!Q(wO z7Sj@%BjC^qMomx#u7)jp^aVemKfXWK)x@e_OaSmB4Ayjyh^0_&`(AY<2qdxSl7mlr zWkbUF4~%PdC}Yt+^Zh=kChU^^b=GufQ|<VgN;Nkpad2h=E8cEfXdu7)yG32ugZe*W zbC(NjLYosrZX4HTEDMipmfX0v<Wg;`B;dNQ26GE`xdmGXriMe1D;4e;q74Riy_cJq zm;m??Vw*39_+jK2{AQtCiH8oO+>j>GpyWuLcsl_izl1y^1Hk%rncNaUIc=MIULdu$ z$t;1cWM6GP)NP$St8y_?*W78e%`edfHYFUbx1mDRIRh4ejIb`!mKi?$$Rn7!#@+Vg z6JWLOH?kG9V@B8;N@^ijh#x&SCGC!zIRTO`YcawiC72$Uh~X7kreDNhx9t&~JtUH{ z5|Cv665BB2dIfy9Ilr~n(}}g0+%5)6@ECIZZLuNZHPyWAK6o{u@+|K}+mvA}cqI;m z*|8-CaC4`JSY<~~%^DS>#K%bLEJUq!pMLtEcjAw1(ajUs)F4jn!dDlDav;|Rpa7K> zOSM}D^*8GY5ga26DPI$ndtn9GZ{fUpnzdIa5~G}RE^QxHHKyq;K!Vuoww*fVAI@>I zC+$k(kKakxzf`uawPrP1xL(NYLsAR0%5jm^gL{)ND9c@bWbe1CKXQgvZ4cj>)_v-) zJw((nzA+HlqlPj+oW5SWxg%O0kpMKgRjiLQsy;19fQBASy!p+REfP2VtTvwdXVoBU zy~C%d($LHpFF{d0SY?KdcJZl^qWK%1b9RK>7s?gScIjH@g4F#DITt(f!4VM(<dWo? z$)<GWv|%4%kqzRh4)(ig-ZGjePCO;#(I))+>|V{#CaT$Kv8(t;?Z>}m$$%<@GO0!7 z;yjUEWKm%JAs1d8S>t6ou@n}vr>>#U!-}l~Z@-5W)H3(v+6-*Wg4jJqZ6{Ug=1dDp z%SX`p@|KGQQYCJOm9pXZcl4@>wN&v#9|ojX%_S*+o7O?I#)|T?QLGwuUlor8wr$O; zChH1$Y%3~z(+Pi@xwruJWWeViUG2pbsJV4L916>MDq&YiCS?c}qE>L%w43*>)OQv8 z;;i`_P2Tjs*jBao;O=98KZ@6SgzB;E<j3mvnhNgc2vQI2nxq?wNU(2syBH?*Dl2*< zJQ5*!tX8(H6m=L`&1`T}3TV+;vOO(nt&Er|otwuQE9WIth$@<|%>jwR_ebw4?Sh!M zLsErX=ENkW6~QSer`IIrG1$!^pk*r^g}`S)Q|s0uJ=Ks#Ne~YZ_{&RRZA|2z_PRmm zjoqMzQlwn<q!DUal8qtc6!Gpsx{6!RbVx_x;R8=W5>8fbsarbVzsD4t{4{MZ*zxt+ z=0kGI?e3~@FSuJ%i~t2))xRzaVZOGejEzQqFvuOZa#eJKKgV0zwQ17z88dZD1?V45 z6T=&mCl@lU!vP6WO2|<N-tr*F*VJbu^E%d@-a^g*Q@c`~8hi5%3KZ)B!M#Y4>g$@U zi+QZZVb_i|lir*$J9%U}@2HOp6Og}5*>Q1NUxJ8V&oLQ=n}92bqR5+FJD-YHCGdP% z?Eo^wkw?#}A0q{W_uAvxt%$RJK1%7QK(P?Q(DVEy9v{7YtDJ$4T`vzr9Z-TblG3m} zuhsKz53Swv%A1>@%Q-m`M$8GwgH`({h%oS2G5NN9jkah-VYml^OdS<qlkaz>eTA_| z2uk1l5;ey#8^Enf>OMRRuPN{I{Jx(Lus7;pwelwtP;7@ym@09WAwyGIqmGwA2?SWa zlIY%hp_3-C8Y>%8YklzbWZGwx&OFm!;|TuaT^m#LoGSBMS<a-bUJ4Z`Yw7C;-=nm* zTB`vepg^b48U<5`6#T<sj5je<!B)&=q^ja|o5I20Rsd&pdkN5Am2e0yy>w<Q58xtj zjeQ_;XTO?^C`M}6VGtY73t0L~<%E*YA?GixV+7<J>&<B$*^m>xscO`Xu({CQNaNR2 ze*>BHmktf;%^~2VNip4jZFoW9IRj7kDXoFg4Qz!GB7uY?kzh>9lYs}<!VRl(FCs?R zuNJ)`7X!K%c}p|Tc($PBA9e=PJZup@2UK76-N?VI3I`*lYf<vDl%aYt8>-7X+DdQP zeU4U>sefMg9uLo}vyaTu%+-?@pTT8J@+rt^zMZroz812Y@}|?rqKpmLf^?)uUZ}7E z&C<+%mNb05dnTV|%r-J3sEYU5o!;zZ4ado4i2!$JMNx%TKZqW(mETwdcy_PVjep)L z59wc`!gPqmLu^)h#siQ#U}Bx5+G~lXlD<`@tYVrt5&5GopZEOY8-W~rP^i1}XJoG7 z8;xL{IN={)LI_<2s~l^+j_RTykAISHT`-4<)SF@mx7j%|Rs8R4FUHI&Z5ERta7+WO zdjO_o18apU4ePw15*mb46B{!<tb5N09H7fSX;0BldGH@IVPWDIY#%{oS^V15k&o0b zn&!tKc#UMMQvH}kGo8#Ril#K4tr?HoQr!mG*{G#&n?7zr01gbmICj5D8(u7lj5th~ zKl|CZl?Cq~#rNn4EqpY!&1zMjf}`>7Xa2U7EVH&N<!j&Ezb?qXO#qowW`9*Ms*L_T zdUYQ-iCXlhTaMI4!{*5SJySgzBHemN{Qq@p(wd?`$l?EMqLjXuXaYe20r{jIM}cqy ziXA)Q<I_ka>+~@gEi7#wq!P3erEqAUdw1dsX*(o0o7=lLAZ%%q2KQK4W+vmuZ&e#; zi6nQQ#_Gy2Z?CVqrunZO%-V<JJoq!2f)bBbv*aks)ECa4iEp_c85u5p>o90nK~8jb zpV@tWvu4WeWas9{l!f89U5k%eXc#R6E_!-@XXxbS^!)DZ?EKyFzA~ojj_dahO_0W! zk-e>xIK=)5j00fk7^z6465^0^GNV0DpI{|d?hLyvV>uDhG!XhVaV<!hYPhVaEs<H4 zG;#29LV?M#P&F};)t*%>WlZu)3oSPEsB`9XyzaFHBP~8vI>K!0y%B~l<m$u(aHJ1a zKbUr~bOsI_8>SS(?f?dnCQQ{1IC$`;RKO+6@Xt_)GE|Cj59QK=I7_q)azjgT`^_1C zzE{#R+$Y$LFItg^QG&nv0rCrKM=W7jp54)#ur^tRo2a6t-9L_`#%w%uS&E+Jb1|#~ zMQDo;srSf3ozhkt_S(ZNtq9H@;28<}Q-Y}DG?9Uoo{Y@nc93JC3!iW;cUIkfb5iS3 z-|{lKLOVKJoQauAv!?Z|b_5mMp3iznhhImy&>#?zsac|pLmr7W*c__MOuLQEs7Q<b zsG~B;AnD}pj%hAPs^-=3g`|=GHQc|eDgE@_FGoh#{s|==^Pre4k_;CJAekyo%*NA_ z{N%*ytB?`RAoj4V+I@Y;(fK`Kpm1?39n+0zks6NHCS}QnQZ~W~(+iVK0PmaA=Tecc zN{A3KhRhiXZZy{zMzp=1oflxtVU=#3lBDWcYXTduu4h3{_cb!CVoa<N*=@)CN#}XA z$}Q(%*XesY4`{RN6ySjeY%}rYC5Ur~tFnu^l8`HIf=D08DT9-`#mzlG7t9RDSn!bz z0L@W-oie$HN=j(7y~ePRDS)t~Zw*Gm0s|dV(?~+G$Q4&i=2BJ4@#2bJ6OSrRg0q;} z!VNSDGi#v87S&%tPQesbEIbRFr{8JUUDe{mSX_opr(*hO_rEv+w6zBfVo+-de)0FP zv8H!c-?Hp+K`pAdyspW#`(L13xK3={1#jI)Pl`EB+F{X;5GoYY*GW*6sMMQtE{G&b zky4$9)$4~aR<zn?IP}}md<yWR8+)KP8Vik-o1f}&h-<p}DrAM6u(mb+c~+DQ>KD}3 zCjM4a4yXPIdOaWj?8!NyQ`A`&xev4oZljIE^k}RvU9P(*EXvdtwyfXmNVSz(`q}$v zr87ecFB)Srv`cmrrwXFRq>dClNig-4f(LS|BW%*-zYA{`BLS!Uf^9?#>~Kj5&4g)U z{Oi<z)`UH_Ce)ZRZuVdW5+CWSN7W@-bD9^iciA7Cihx!ExWg?gVK0eLr?#)88jJCV zn1`5^aS%%VOJnA#Ev@(w_lA|ph6wYUpiu$H7sGj{FH48EMzwKz_70nwZZDe=4wao? zKBM63M2R&(ma=h*Lzz*t>hO?AiS6*Mkf4ygNKLixG}%bj$B6u{F~T`9|DHMj0f9@9 zB4eUm#!yEBa4s*SkmWF(#vJjisaOYIkYfygx8q<-t8>7T&hK8BKnNXILkgs9Fs_UF zF2rne*kt_BaUv(1&K}2a?nqPXY|^^83Ulc|M{hk%5o}N{WWL)5x%1>^I1N!TuA`A{ z{F?;BAZ_zCR1|{iq}qFBZwqm)O$r92<3}XZGqlwb5G7xN<4w9Il(`st_tulC`|A^j zqIWke74n$|5$#3ZYnKWW4_TEj*Z=+FsbBg8)U0<M6xCkZbZ}?#-Axu}I;BzGd?$#z zWBfdo@2A_TBb2rx-<DQQr8IdmSG^`W?JLS^aWLCHlMdXckhHYVnLErBZ-dxo0DOh4 zKLMKq0I|`amwbha@`W~@T+S2<`xlv{iV04N4m&4Akw*;$tr(T5eOldBK&NOhv{Uj$ zc_QZM%<IUeRM#}RM@K^V3U87%>FoYu{_kvn6#WRpN0&DbtEO)ds=J2=b=J!5mF<xD z=;^%FGNQ^}?fQ=YWq$9+gI>_(AK&w}aGM`bKrTx*TBLno>&lL&<E%i{wDiot^S<XQ z7)>>G5A;UV_w>w<O+CJ<c$0a6_ghIkJ>w6#OxIUVHzquJo>H8UR+a2<(8C+JDGm(W zntGnRvz+V3jy((bwQsoVO82U2FSdP7b+-q!Oc@!ra;cA)sjuX)fHIqFn5m!_tGl=% zz=4NJf%~YqXJ<XRBqdPGwhIr<Ma<=CN`cCuFH(s|*JYwWsGuU$XTRfuRL1%Jw!1>V zElHak%#-E8{DqayS@^oFqg`rjg#LELrSl=s5L{f-lE~jjt`x~4IeSRjae{0irT{|M zu-HnpD|s0gdC=PlHe|UgG&1`hD?YXqz?t`uys#I$DHLL*7RhW+d*?c%4Ox3Qu0R5v zf7jhIq8~Z|Guxf*WsZ*$cnG&gOSk1$6W@{BttC?XJm)~2#h8(7Q{s5<2zSFOe6ZTq zn3pX~Q+@$uCGm(>OYVn?G1y=>k|3Z+wgRO&wsjRY^{1jaReE|k^7Un_6F{~C(Ctbq zI9!SG<!QNOuv-7y)4^{0=6$jLV-3>o?!>j=f^PwSlfZNH6QcSw<@SJEASL=BSFR}< zcip|d+CAoMk2PpL`qUe;`o|x+eC_>1Y+g)QB+!yNUh*Xe;en9)gI-!Yx%DLVnfU$& z`=cIE|FA0$^aK3=<OWb+|NY8I!%7A@Mffi{@V7$%iGTnCB1K9=NC6=Nl&JsMFL0v$ zWJrA?#+{02SI9ze7o*AsL0sg|ug<E)>dQrLuG&^}xz*>Sz`X9<tVy=I=yL6LGQ?cH z<nrHqNPkvNN{5qp@Oks_haukle*9joFWF1gZMt%igi9(m2x8^S&@Vl60Pz6_RZDi` zv4ECtG^3$kb%1*L=l8q--27Q3XT>M4xj@6VW2gB)cUEprj_d$mA5TxVu1{~bHNt^~ zvRlUCOOu{<fk<K>@TuSGI!!8L(SrQZFh;Zs#A%x0m5&s+TNTc=v`7Wm1=>iF3S!<o z(Ue?#9Uc#NUza`!dU`sv1AfU=QzZRqibW#fGcA*OhqiBa4UdZeX0}ud9xOSpa4R>z zeHpmAM7`_{A%7w#K6o{52V5wOUfQ-mvNEXxHAj^?FUNk`09uN5Mjm+TE}S3q=8cY) zqgCKP84wwXsggXc8;Rhv)ujQZ`ZkAl*_$vGrUHvnj&`{aT68IF_;U1AAIyO%C_=W+ zqxPH|$x<5#gQ3cREP1M~J#5^MVW{@QR8%H*?EZ8Q3<B^jBgRE`sfFuqZ*@;;7bq*( zs{}<e<|*lkl+T1_wj>$UDwnWRk%Ga9<y$!9P;q0D@$A07jFmspg;Qpz^P!|FUVNLq zU0l9r19=Ovr~Gj^%CPix#49#z@P#QWeWFtSigdG{BGhAmIWe}Yq&uu*W>j?3-M8vM z4t4ci6xfjiwM=t1H=6V@Y+?1q{fit%mXWR7%7`h;OVnJ`jzGCWc}7xD2f>9Qn8vFh zk2Vhg1ief~Xo?#6xjLGZ8<6K-$?^O?pjD2I27GKapK$m`q)rEj9GO7|0OtGY>~og6 z*4&VU{kjO?*27z|L~q7M2RDSIz2=c*i=X9#7~C78SVElRu4~4XE@-rl>%bJ3J?1)A zE|WsViym--ZBv{B@)w$eiNHF-`rWcF9by`~V7W_x!~NJpG;(<<_;48?ZT(_Q&O0FQ z+p*(FLin;9Ag|N(nx%F9Hy0lqE43rv-gvtIm-HUsvx3G={DpElkK%72pjHAHLX}pc zq(kr*@6BxT7&-wotrhs~yb8F1O;Kw(m_fOApS~uvpbnfw&~TWBMuXMV-G^Nnk+r11 zf}T^7V+TZ3P7(9yl;p3(e)t6#fGiZ8F)$_78;Yfs4)LG4Ap<J$zR6etr(gMv4uc7@ zsEitbG>;Km(GEPr)M^^RKCT()!Fg+iKf9wILB|FL4Xn;uh91=8s#xNt;%8FL^uM-~ zOO0E^)2$_CGB@vm2b#EDwK>$6sn@vqxr{}mJ>p<SkR^>SX>zg(r8c?ft$1I&YqLF- z*-Lv*M7_%5>v_f%vhb8EGX(!0IKKpwZ=omxY+}Yopt+CHwzh8Jat*&nq;np9*9)M$ z<X^*dB%hrNrNzAjCaZ~bcu7lLgL&G{k3fwwc<xQF3Z(7jtxsGSMp8T&DLtNx;!oY6 zyY`k<-Du+!H&E+4QM%oxcyx_cdJ#H}3`IxaQ9aa$OGz6`kW9uz;%TiwqA_`;pNq}` zjJfEkyCq61y%6O`+|j4a1+VZDIz~>lY*c>m3v?TX3J<A=911lZQ&mR@#d&|#SO_7W zQ#ag~?ujaYs9}<Knn74p?b!5BJm!>Ncmv|*<HT8mQO#bpdV=}Bbn<)@QwoNVi5<J| zz<oY<4GetAORU{!Xm1fSOL(5ZBsY)%d<^WPkebEy=?+R<+7M%JYXfz7uo${3B}+7R zr9?VidF=$-4j~KoW!aMTTtVXodb`leUO~FXzxLh~-%9MxuQw}E7RULOQdGg0Cy~>2 zY(Ld>(+OYLImaty!zC}t`q9)<9>oZDy+yk{y}BNJ_ivlg9DcBRIx()O15sW9h55@t z2G1d;=+Cb*d$)TwYnx31E^MI&oQ^uzvgO0roe@OURQQI0mHln@ZC=4wgEEZ0+hn#5 zefWH07Q*jdJY_-ot39nw1@XjKp?>6WR2-ZswsSxMgh3#2=RAytt3SzM4>Z<8eAmA2 z7@H5qp<nOo{)zY}(OTMj!QOp<0(|}5GhcB$<`cA7@@v;yv@J(bHIWDW^TClT=AJR8 z*;OcWVL0ay2H^*6B+0$PA;H0_h_m$(I(n-d1>rhsw=4SXK6!h5n!uS&%Ud<iD@Tg{ zE6&Q2e39hqW~t5mbBI&3@oiu8wvfT-x-6ap)>iXPqr}n-1CdU)<NLB-USb{PHkxYz z#`uD}e@~HjqsF(Z&U^pg==ERlY75H*Ap`s0>_A;E2s`lqMg~sv{_lXsNv-8w1quXY z2l-z>!vHXI(7QO;&^uT-#HbqDZ?GeM*%|!oRl>KxizKqZts-edC$8(l7d!5?Z=?Z( z(B;ySpj9NOs2HyTb`%qpyQV|28_9C7x4U_Iip)7w6$SAIxAs?#Kz-hCEpLT`v}y2u z@BLn5j*3j-lv;Rm$|*gd3da-EP_yIb=2Wu@>j1=a5)8JLlFIHd++bRA<G;3Z^o>== z$A#t*Vm>T=-Cw(P`{`5zw5!96Jw7n>UNk1tvd}%F_ZS#o&FSDuwM?M~Dd{s@El3I) z!=<q0_U!eigWURx1xH?p*bYV^DFTACr`2zM19W(8=AW!uB0?QY;YXBg4tm1Fb9p9z zumRrT-h0fm8;jg#n-;wINL9mwn{8NjwUA8%DJZ1MU8JM3yYM2Zc5<8%D_KGs`BD8j zi#+Acu1)RUZ0RYdSSH{s7`iBn^oRgxgyVq@>PMTrB%+1!0;hrvbu58iDUdLIoy!Gz zeF1K`a70SKnWVnc8n<UkCCXTRdZHDjbHMTBm!^TT<v}b6PQPw~gAWFF=+!<*Fp3-_ z_Ih-J0DY091B`H|b@Sd|&$h*&CKp?d*laz^HBC72ENn%tf~BeiPdc*ZZ}HrGX9sYQ ztD;e#aeD#x@>#~RDda<)B#(3^2T5?Tr1-H)1IGI<<GTHJ%gpc>`ULi_JFbQAD?kb% zS$|wU;Qj7oS{vpGETo?o+DM!%*rj3ih5B*W8ybR@J~6m2SuOB=3%mzfSff&A8Lt4` z5oeq4cVM0d)F7w}uGN-aAstdhhHmXNis|w@97p$QlBRc}ftm#;w_s`U6VM+Z?=8hu zt_Z}exR>3hI0&aAY3f$miaUMi7Qk)_^7tIXwNg-u33hDg-DTYCNYoqmzYc<4UwqGR z`mF-#kJ2?oo~E{}4LiM{!SWG77m?IUf{I@#Z+{JVb6XeQ^K8B_@ZlD}FDs6C(}%w# zK6YPvlJ%%Y4ZFfHBObx>7ypn`90oQorgSg4_(98|3Lth9N(wSt%iH><f&)^l!y^S( zFV<aDKFCEJCb%p&jg~7rk!yiUp$PCc=9JxUy7^#RQ~Wk$WVy~>$we%%u7Ji$T34ro z6-ZMsr@4H)TmAy+54i`e5f?EOZ@yGb?CvPFfE3+pJU6p+s(r%r%sgbv(a^ON44W`# zK!CwLzHxVL3@#Evutkzc5lFtgjpkwWn6LPm|1t8?%=!N4Xbc29-Tgg>IOZ=??jhAD z^TsB7dZYWI-cn`7abJLm)ZEztgtO2j{6qNvqkY;!KFG=cSl?X$lJq~;w<#Babo?Lw zBbI<D{?8E@mw>qcuk95kU{YrL&k-=Eos@tO15#8K|6{*jZNOJp75gH)K?MA}(qdv@ zvzt1oq|WN~GqXT`Nt0+WiE3i3HQdJypOll?-;G(|SjpTQ9zXXNd{q4vQ~2oqkF&Za z@7K>W=bJRX+8T#f|1gs&I%>T=q6zXQ(Ny@qMC^=xm2P4Ea}CGZn@|yh#Jn72n$L~^ zH=e0R$C(2?Awjc{;rt&{uAE7G^Ba4Ns3VuV4VO8>fhzUe8G?l|8#anK;!kLZ-s|9g znJT;j!iGrgFme>?ILef7tnd4?O>0OUoWo(@;$v`(ZWbcZY4Qg|{p-?~DjTM}y29TR zErR63nXZx|&GyFMM9<;g`|}GIliYTIO#{wr<f^l;p){=81wEZkslY?4EHGSD572~? zVQ31bZsC?F&90kabZ!LCu^7=bFrGH(9SCvfGaY;{uQ<tg>m!AZS$r$Fd>*oZLHpRZ zj}dvnb*#QvMW3X9oNsY^2BT65*b%FrQ#$_&`6%l1t%>0Qz7*XXFYXgh_~%XW#E6m| z0w-pVv(X&UyAh@b<7c1O(aK)*be2^1hx%7e1}X%ya20t9mRQueRa4Y<Su2DB)5^O2 z?G+35<g!q2MUtS}nH)s_6s-`axsDm`M%nE!weH*$6*@;WuOTpSx%T!vxJT}jK4!J4 z*R-LX14{*Eks6>UJgq}ZoFoEp##7V+&zHS=;DpmFbgp57Aw=JNH0b-|aDw-k)IeLV ziRMzn7jxM?tRtMPzu;GLw36CAK^Pg>vZKG#MR5EvmC6VMbrWBkJG;OcbXe<|I=PqM z?1f}+*P)J1aoaNbweImCeKCIeYr83x$*DI81@pdn={E`|I;qzLS!@6tRatJcfd|nI zMBK#EZiE$NC~vlmc(GYbAM&j|6yk$g=br_8n^Bq^Q3RiJW%H7tuo{HBlBoE=<t`1s zC}_bV%4EH3&i0T+QC?+F#Jkfr*I95~yk|%sr(T*0UX6oF*#5Ovy2IV)85qjDEGN6{ zQacC4sLo`#gyEd(KGFeqtfk_YJ70j-RS&!126~CKE9lb$zRbi=4<xN->cB@aOLZmW ztDnea71cvqjK4@T#7x$WaoDOsYU{6wB|VaQyg38YKS3Rpp<t(Xd`T!&fimThv}vO$ z{0lDM+w4X?&QH_uye?pZzY36N!}WMKcmBVc^Iy~kwn+=C06F?!&DpQnR4_~OZ<-G% z&8rgR7hr=u@yACw<tM<p&fP4#Ky1ddHfd_GOH!3xZf&g#(OsKfDp*WMxll;yL1O&p zV^4B_&O>3IbDM`J0~^|g6(>gQ020aK^KIhE2tOxROuzSY<Aq<0-}hyqpYUe3dEDv| zf$vW`Il2~^w9Di3RohOl-^cUoJ5iRnI3Qe!6)>Yl$;bWqH!E$Y=Y8*^uGj19eQILm z=k5M!&+)O0UzBlp!oK(C4ZV~z)-Ouxae|y?Zo`O87}<P>hgX+eHD+9|HS?+7By45Q zn`8@7G*QgL6?bo5T@;_pGa~Vkc-)a&3K31Oy}s?={>Ov>z}vx$y?(FP6U#9-jg(6! zz<fbjuZ`e)@)hzJ{SBuBA@XdaQf~acd~OURDtP>yP7Pab*!44R;babNDp5A1&@;7& zvWjGqXvZMqE)4I2qEkB`{Tr`<wW`Q8p^#FuWDY-a-pEx$+<h$alUjZ4oZQO~2ftn@ z7NJ+t3>FQbTz%d+T32Z5L`cDLI(%9U*x`>@&a%v%k}Etatvo>4BKJ%sXX73!WPfv% zqczvzubxv?Df)PKQBw`x{{mKfognNb8$t4Y8wRc&;;`QqVM!(Cmb&NFI%upkrkyp1 zv~=6Z!Z-t6L9$yjRoXVGswxNIPdS!)<kB{M?oo65w2Zj=CRJAsCY28W_F+;0Yj_-Y z=8!N^!})tCE5n&i`}$>~x|q_LjdJs7)<@Jhk1H=L>3_{3qr5W2dwt!I_5e$8G~{t* z773eXqMqog6NTlNdH4!aC4aWz)NNv<?!`@dC+58bJzny37kJGORA7t>d$4HUAXYN@ zIzq=Qmd7g73`L(4|4@ZjmXG@ZhHGYTWM@$(*CwK}3g_yn_ijPd^T_BF+?vXlnk^Og zA>t-Tr`VTNSqq*D5EIwBvKm*bmGpQm_eizh2tn^<8~ocHuR|POjdkb}o7=l0_xs;- zzi{C0>Y%@=>`TYyh7U<m_`kMyIp2j_budk1WcAR5a8&3|Md;K&a16Bpi%H?rPt7LX z(~31^7z==cjD*Z7>C2zT#o;~)Y#gdzzf5h4WulW=_)Kdk40LC<zZ$6~-|M7*Q8A&E zF3d{|`kFq~vnDPyi>R6==WU%zvg9+Ft!7}u2Rr?;v};CWCLK!^OIRC6y4+%2O7dg6 z?3a*84Gpa#b8`|i(lxsQMC0r&8ks_=+m@OoD$3YuY}gt#$MjnmTMW$dx(bFC$}Zs^ zm4$-9{#qH47=wpC#vWf7zchX*WL;;MFD+F)JcX!%GdwrR%yLVuzNlu5E+^NI9^xVZ zjTT`h$B792J`YJSIvnsI%E}-iS2cSM(QNFLg>#lcc5CcNh)z`om?X2$*s+_%{jI=A zi675$>qiPmkn-s@Y>;kdp0rQFl51OCyof0{abjV^DITE5jBj42z4Nzc*Ej1ll6je) zeIcKMDYD;Vr(AtqBtg5c0Y<r`!DSrgu=F_A@GsFdglz7+Eh(jH3upC7ghdi?U<q&s zayd03!7z4cX0$;D5LRw^S~HWCX|_zGMt_`ofLjC#gBO;y3(}LnkEUYT7@;-L`o%!o zDvfY}O(7-o<rbeFlX`Iz<m43?vZnJ6>XSb>dT|ZZ@2}mlnVFh~A9<uLeH?XEKabb3 zFep#NgPK>)u<-JfpNHXLHd6~2w+P4RV<Em*!;AvhL|5McxHhDLCJ0z(45>c7j85cW zd6~P|BYQ3PTO{cC|4ND2SaXlc_-dL+r!|T(^dT(aX&gvkt%iCsZe*fu61jQ6-dLI{ z*nUepm~GKP<CsVZ{oSTTPO^pS!};vt^3LgGBl>fzx_WciWYk(|WYdxqrMRnkWF6>R zx-U1R0aFElGL>;}iGs{nCB~Mmf8n%rxyEQWti8=2(O-o2LLchOHuQRwGyr|_M1ZPu z%8asfr&>0c1#?w?=3!q>gD>ls9O`e~j|r5S0o26ETalE>!MM>snV8HyeGikyBQmZT z9*Isy#ZEV^LrH4W2CSD4nrq(5BW~wXWpZnE%_;2w;C<43t(hk=PrEbPnWJfvf4Ok- z6nmatEcw~+<mB8$C6+w@XkavP`aN8#B3Z(aX=%&AcYHMMB;H~~p@|6rvyq)03Iil9 z+*NLdJ`Mvu#$WLRKZNy;swo_Op_83K=v<Gs-uLb%XjcEv<vyZ@_=iK;1}gJ#`XgSh zh#q0U8y(55xaN|j)7D*q@1i-q1pbX<0dbDKgV}{I-m!JXK#Jv949mj2s(Wc+&s}FK zca8Yu-VOP2eNcK)(~k6b07*%te+dG^1|OTIP0k>-5SChAvs?l#cq?LcP8}|2jk??T zA78ORTqRZ-sj-hyB#~<G(pLtlB49#^KeI%D4y|}Wd0?Js%xLz<&)fSE6(^WN@3;@7 zVxUx~;y*rE(^kB;AS1~ZHL@$W0O4k^hKWuJjB;(70k%zAb*vnO56%?@CZt<zJ8w$- zQd^jC`@|=7WH?Fz?`5?7Qen&cOy+>ZwNK#kXJdL1kQkf0y(H`IjQ4KmZH06!!>km5 zg3IR3Q`nSLn;O1zzY`PKyqLf`mP8hirTM@TR`=g+<N|fH_4~f~x^3KbY@xR>v2Ved z!X#t?tA!n`eEhy*)S%{_u3*U-pm}G(a{{YradV7CUZ4?3!_U531=~`8G)&&XP9#6f zAc;+vw#~ZvHgSw$wXCO9JY(DmH|{Ec$0puX1DT3wZpmDFm)$JzK#yE*YeJyq4+$VF zAIW4-mrC!?2Qov*P;xvpYdp9W(KZLxzNyFVEAp0McpI%6_*w7ix)F2a?f^G>N0^EO z+>1a4)3dty{FO?~^c-bU=jtSeck0sb{NzURm|@zYv^@DmoCCcTmorMMN@oB7oh+-< z-wT`5aAgG0GA6=j<EoL|ZF*l<s1i1p5Yj0wj%!s-8^jBipyEyN=30JbN|{_oy3W!x zXF{~H42xz&&RX{4!#O5>B_g`L8OLwtE$Z-EvC1Wi7oaRMcEH*sj~n*QWlGG@?Mi32 zH_)Vu^)$XOcd_$;=ja~JKjaP|3oto+X>qnBk4)z?E|tEtXz<PVf}j(fL+K6Ab=Ns3 zUUNuG;Gy^%?AWv_30|tLqyu-DYgJ$GuAZQKUSAJnk<xj8u$OeC_J~gY&Md9mU{_`G z5;aAko0@pVd{BCBDoxM)GI7@@7#+h%Kxv(X*^T@Lc}=pH5&5QLvcCb)!7_jvl^VyT zK7yb2GJoCasOuwEFp$tw+Lxem<h)B^0~vQZAt{MYQ4%X+6pamN6uM7Dp^%C=5KJeh z5Qrf5l#DQ!ia_;fN>EwGR!HT+q&m`}Bbz0iDQE<-y%(aoqn#yZ@JA8;XT^|$GSkiO z37vd2E&Ac6f3+DPMg?fB*y5R`hO89sfMcBiK2#E7USMV`Gg^b7z=Y&R6aSr&d2{~| zlXm42_~qWcFz!eL&iXwF)fWL=P3bRZQ81sC$@Mmn!N$8Q3?|2Z?k2`V@4%c;AApO` z*})3cAA+2XXOe9o3?m1@tW|#iE?$H(iL`UF+KS6$a=SY&$pgqsT@gW{M`&iT!n3I# zpcq3+6&Zp4t>}WG*0+~r3N|s|5G)VF#{wkka}>9CZ)&rbBxG&~PW4-pyq=c%{C2Fc zseS-6kJh}N)~KjK`@c7Be2((8$8TnJ|Lrk)kaPr+dQ>e8nA6ngkC#uC)<}KG|1LC# zFi2d9dZM!fR11eOd1wG9tK&o|cVEt$!V#!h9HopLYkUZHkBlM&(9@u@$%A&o{r(a- z1j%pI-AM%mn&suM{Ss=zk6)YavypGNao1>NP-%sw+`vz|LKu4v8Fhm+`4}+n>TB4V zTfH{0(buqXr)*^)ZG}bJ07cjUh1<Y|*#L#wz=hZVzz6byfLy?}u5(Nh`(NCnZodb& z`9b~>jdogaID=?k{IfwspECFy51U+!d+ZcG5APDt7+gpnhE`AyOWTWk?IbY=?-9`G zBCLm?*(u1Nkg9Nb6i<TY(|_bHq)$)9-Tx1=dz~Pb<^X~iM~UpiQvwraT#a!ZG@ut> zh7Se=%)5vfB3N<{Fs?R095ALSe@O(SyQ*JO5IsYO^N}DG1<<t)8cHqO8l(>xc%wm# z&A|t+fuDu;6G;jYr|X6)fI*~e!~3t9o`&`kNp|)#bdhe&Vv<TyzBW!EMRxbi^9VA8 z!R5sNgE)3g(~5Dg14*GnbltE66){hnI{^XoVH@Y69YmVkLiAm<_{f;2B0<1ug8_b= zf0lr4HRZ1XLfUz=%fAY1KJa&!zotDd{N(-rUB&@Iy{{m>Lh3HQL01rc{bwvs-!piZ zfF}1f&<5r$h$-|oa4XMa;KWTUsEz(EY;wte2LD~gKLc+dgL>SHc2FC8Bmi7;=><Z4 zcfh~nhu#2vP#S1>FTe2Bd-p~_;X0vYlv+6Yg}n<JZBTh?En?28=Bl{zYMXQ*)6EsH z#^`-K;}Y?C6aqKd9{dD``G%x|2)SY7Z11Cy@~M98kRm-sQ7oBtPM%Zzuol&{vXWKC zhnaNt!)Ro%(rzuX%3|nS0$hI!NH7sCM-%W?z%QU2n9;F6MG&lnl+h$!B@|)Am~q&B z92}laPdb=qHIlTp(>Fpmb2QOneDm7HEd)7=4c)yP-r&L25|>B^EYlYNfz8A4c?fNx z2cOslTqQy<7Ay~*1QLIRhkhWO%II;=6$uDEBl#3R(@70*W35DE0hsFTfxaqRlu|XE zTRXwyX;hnsqin3L3V^65sn9WXnL!)D?}4iLW+rcU1zh<|WZ8hZ_4sxp)aYdTD-V9> zL#lyB+rg_2Nw2Da7ayho=UFZ#<ijCFla;HvaHvVt{0Ww=5s=cOxy?|cu?$K_i7%5@ zA4EtJp<$ba7V$wB0?;nb2C#?Q7q!q2sZHxlT>o9()Zz(FVB2g5m=vi++ucDaN(KoE z?rSU|(w0s=(KC3{^-Tya2{Aw>fc3CeLin8#5ds;Ehg0XBy}mXS@fX+n@QJn#kVKqC zw`UE2<UGw%UwdR55SBQa332D7)t`wFk=>B&vP|6`Aq9k<1F{u$0<E$qB_6BesXwT) zxCe{>%-;&vEJv4Xw}cg>e7A*4$f1L^dE4unDIfvL-+_x|m*|@Rtf!V~rEsOx+~w&_ znx#GTv<+6p4xv!bmSh>&BjpONBu((NTN>nabPq2~n6T#wBO~TmLAfF0J7GmSbig4d zh@#tJ-aq0^0mRCyBwe2H@SD!Gpl?Zmlk5GebIB|oN!^D>mD%0fe|ts2{em=l3Qz<J zxNWi01eMlo{5@6}fICy2RM|;0z9<`#Dw&!^N+|jG6<a_W&{ru?gqD>_dz^leJvHI` zH&W)dIgM>rwY9KqH-t?Eip`!8m&%%RLwU}Bze8i-34lNzU9;!7USCh9p7U5Q($06L ziuPF~Hyg^GL-uwVPRSNo1Z?I?TNei$WoLw3!J0c;imJ#^N0NN9);UgXol<)`jDCm` zMLj~j1}5YQ%Q6nJRX3(0^8^hX^ay!2FGDL_(y3!5pEgi|@(vYyNi)HyoxjFoqn@jY zeZ4fC1OWI6xP!c%{vlEu2aP$0b#3rKU6kuZ7w^ma#xbu#+tMz4?9Yt&9d<($#QNC5 zJG;8IfFZr}2UgfPNdsOz%_gjyX%qHC=_fc4%Y8u#3QaMkDEf6VGxGemSxT|HgA!^F zRZ<wt2kug{3pE@(^CeLdOo^ZrS{ruC1gU+JJs^o$dNo8~3Uu9LHEMS+DrKnfKJZ0R zQS00TiZY<?T%nHpi{=}{*EOutD56mEaRsG7xXF;AKm9FkodEx@<C9Sd5vrZAMcZ}_ zVEIo%f^n3^jT33*vO^M8s-^O;ldP;~_|{d_MP^v#8}zU6`D?4zLo|PNi(A0)*Y~Bv z2H@C@H8)BhQo3G%iZ}VbR`PA6{ma}!@vtHtl>Hmasr^!}GS;(oTqHElmNa>@gTv}x zJoJO7cInDG3J7u$tqy#^lA#7@fv5lusYW34cZi$Ns5KXJpWVNKt4M+7DTb4c<hQvb z)(WOb3h1(>tErQhiBGRq2`OF<Ktsg|CV*l_Y-jfos;sUOGc2l8Pd_Jjdu!|ITCBV9 z4;TLPhi~FTyk{+D*ugikd-ml+rp)7n_M>XcNaG)JiGyKcY=4AbPMGT}!(UOtN=Zy_ zKeubAWb}?Xi&2!mj;}8h+pi{!mofK(c|HTZr)BA%nNQw>SU=g1-bv}aBP<8$C4e}& z_ty>VZ|wL*)I|GW<-3{aBO-p%zrjD<(PpF*oMxKSV1tCASTWhr5Zx2l3{lBkd&S8t zp8l}Wnze$H!>@+X%8)1RL+P+MO){w8X=r0n#2M3I@+6j%WFhA-$0$+ZDa@S6>u*o- zIy1SwoXu_#gQv-ssjTSVk6`Ddn*gmyS8vGDJ*7pcv*nG&=NOf?_U8*n#nCV*)E_}e zFM~IEJC`LgN%>6I1-sO~FWnbzfw$)?_U`olhrs@BdW!(at~(#JQUsYs)B}QykX_4( zI*Xm?jVr<Dj;k_R=Puh!)GT4#5D3}%sg}ndbrx$y|7UYXy`4M+66THLB!F#}A^`a* zUmYy<NI-cb^3te_IlV?ak2(XC{EPMi&6=cU@=vR4NF5a)Yn91o@djWQyQh0;@2sE^ z!js)`vuu$*u*4$Q#;K~;P>9+ULCc&oNv$hO6VT*8TT2Z`$0I%*SXfh7KQLg&QTSxV z?)i~iorcWLVh<Cb3dz9G3Rp*?UU)j%{#A93v>h?S4Sa_QiVkkf)1JN_lV^rqscCkS z*0dJFGa)gRsPozsy+oU~aE2sU1*()9ktqtnudOd&zyv56Bkvv=7oP6qHaZVYX1~sH zr=BJl6?x%buTpi3+hX%3c}q@k$u`M?iFR=f@ffbTj%}1^q7lEc07yU;`Il5JYhKzn zsZTiDYgc%=kdaxGblzb1f+(WXF=%gdPOxTEPnL-<x5m^UUnaP)YW>czySs$vAjwQJ z{?&O>iV;B;guc7cdYmoN^it3vywI3wrxxdo;r^PTO<f#>MO>X#bKN%!0UAf7iqyK5 z+$Phg8c$kem#EMa04PN3@Gnvg8oQ&VLtVvH3-?<dEOeOUoylJyUM61`*f&w_Q!N$3 zz}3zoV&~H8rJ9(ZZct%&!zk3bhAt1OJeBE<S{lBv%1t?k7R;!tM7qG2uq5b#hgm3n zzHWSqr5I4-+aKK#45~?JJm&#JrZ{<e1I3+mN={C+R?<zW0n{(5DD}DvYFQXD;iNuL zXRKW9M;!T@({N!T$nO_i;Ma&X!xO}>&-3&o1)7_*SFz?Ss0NZ3OJ@Bmy(TFpU?gmn zCM9!9{!+Q2AU4;)T>Fh$7rp`UJ;IJKxw1<;G07S#@@La}ACgI>9?ru=(kw>ICMH2# zOgwEq$?!ka08S@svP;S1lg<iFdAlS}E8VJ4aP~>3q*xES22P(IBgJ$`H~nej@Z-2u z^Q3K8NAo$1I84Hv>uF}slgNI*EB<jq+&URjDafrk!f>@ni35Jj(I8P)spUnAOhpBz z?r+vgUOUGhRr4mrsu~kW#H~(WvH^j187tQ+hg4G32Mm#e8o5EWQ)Js-<SW)Vs8<#K z9zfYHdelHWz7P=99o>k?-lDw4A(Z9|W?G+|GmOVb0*juvOO+dJ&Lp?UUN^nG+7ek_ zs-c&%lIaj8Uzh``EzQCL4vTBu2Pc$Sk4!n5Rbphg6;O7t+cBiTuXxOXm1xHs2q>yH zU_@gj0<eq}{&1<WlX8lz>|Pn?7+8W)&$UH&?!c-|PC!i-Fi4Psg&j$Ns|&&&!6qB{ z(=v=&BCCiIIjJ|&h0aHzv_e72OE>E<--h}3uwx=AW9*`X=3%ib$8B@jCb>b2YOCP{ zemt|14er0I+>{p?9Z&Iaxu&tnyII-UmTP-e0pg1?@iNH^n9C#fuNT{@@keFcS#w(7 zKPvD3P+HA0R%F>#J53BbE?oA{3eHLZW%exNJd?SU6Ze0em`OuGH^-LBhCI4gE0`%y zrIxGUzdN0RG@By#kTU^U%+9pzQX)lgPNN(=)8A)Tme8~F_L)CCZd<7)xA`*tg|yRr z24s?owmh`ZyK^!Fq5Tf$@!|1y4Yruhe5?^y(P$0X!{DX3N;Z_C7W&;w<P9?M9!E)l z8{BwG!i}N~cj@G*XB5(^$}cW<sw$gXO{4P!Q<KD8Q7|0NZoLriinE$(#R>6$)o~S2 zQEguzE@2VU4HDAbjNn7MJESF~Q&NeMmIjHTqy?pCK!#Fs2x+CeySw>D*8e@f=l}ce zy=Sf8I(MHPci&lSpSgQ)8+UmHT-Lr?P8JC7u9nfRX7W%Q$cp=k9l@JI3?Xo4OS3;t zWmJ(`jZw)u#?Ph!XX*UwcJJ4n`Ny0)psYHfO*KWiPJ;^9lp7rt@96h$0t?t<>QBd1 z^uJ{Fe^1v2Gv*iTgOn~@isioBJ(sKsdHHQVJZd&_UJJK!+RTQVXDaT2<NT}))VOwk z8Wni?%_~f!Nh5}el7dUmwAmEQJhwU;6!p}<nO?!syC*Z-Lwhg&Th6N&4?^l-&Vid% zF;ZLO%c(Wk3N^teE}B{K`X$-Ef#EHd9_owz(Cm+e@#H6P`{U7XxPH3X4ZFv60a?EO z8YPhk7i&}llbR$*F~W*Ih}}z+-X5GumkAre7QXXh<`}b_On+<?-i!*im(dYC-f}@n zgC<7#c2PE3n!Pj^lgvsH*M=azPu|PLSDxbfw)BP8m+zI+BMNj}LsaU$A>5aq&-c_2 z?pxR|gej-b8OkZe=ULQf4D$9@EBiGcNiEn2u8I3Qi17sl*3hQHKUNy3+w~1NqJ2c1 zPg-cs*mmQzWNoiJ<8$%^A04N;Q@(a$=C^$R@jl32@PS2R<1&w7flWBipq<0?EB6cc z-NE}`JjuY&xA$zHs3dY!#8}Ep_PnpW+{o#jQ1*&>f&rWQ^aK4aRE&v7g1ygvjkYc$ zZ~Wx6*pe%YHZPqcw-GJfo=dWMgL5n6OT$wQl<m=E{x1cfTFS^>MevZlGx}vx3Bw$` zZJdH6qdWqvTNiQg)z>h`KuhOc9pTA^_lMDQY7=@ay8C_(4qFcuAgi*0!y6mElHgG{ z{4LaEQs<Q5GPF+-=T#7qq!E$q$AxLjz_3ZP&WlSs?rm+-5o0=&AqJXVfAR?d^WmMn zQ9N|LLNYJE*6n!x2(Wwam!^5RNtMrcEMxB(33%~7)#;+sX{FY#0ao{1pu-%d?87(* z6D|*thT|hS%`dLTA6*OtbS>3!G3+r2$L)J~qFE2rxCh>S=+%DY4^erdgEesani)W_ z<j|Wo2z_RUB{PJRwwbrnTTxQ#fxp&Qvxt&2<TtT;(BTave*ot-av!lOS%BWfNM98` zN)%||D*I|!-C2*lY|m+DuFbj~f}4z0%!J!*={CpdPTUc%|Ci`%VgR<ughO=0SmV#* ziF!5t))yvh-x4P$+AAD`cS9js`<y3Raa^5#%bLxGDZM@RX3CenQl3r0^vC!}p+G^y z0%L5F0sM-F^8+~QwX&C34hpeZqjPT>eDZihLwF}f?8wdFWW7pur<Q{vsuy%$%)alG zCmW9cn!zRIli}`-jYm;)L2>xV<L?m+!LoLbVODoAXPptv^8MVTvRBgx7cF9Ujoe(X zLDhjC=vsXsZ^uGJjBsrK?rhQGFz@krOHBIn;b;!ReSL6>QnNvoGAw$w0m9srZA7gd z86%GFS<e#ZCP;S!C88G2$*<0Io2*xNst>2cdc)3``Q5|)N(+*_73L<_;kut$ziwW? zy$Y|uxj1)JM004yN#l&mkP#}}*hyR^5Jso>&1*B|PrxQl=wRAufi-e{UCp&2c^ZM* zVa^j2FAH|wCsoO4?6fjM&wF<WQC2U~w6!G)kW{!C6YdTlB-eKoZavstCV^5i!_o`h z2G<%XO{p$*Uc5f66nj$YmIZYODegNQ1~$C1+9;op;np<%*!47$=;7?KsYDM;pp-E% z6Cg0bG|s+bt$+9F17vX?)H=5*8udQ(hb;&?5De}g6(D%Hc(?wp=0RD~hSdbT@wf{% zIdJ;&WhgqezjtATU7ssP1b*OvcO8Jthc*zPXB1Oz9q;mRY!HG*25%7<l(er@H}{nJ z?PwgSE}yQFk*_T<K72~u*!0$1+30cmqmxSimv!(YE~w+hw5j8S_-vzI-kgO)`+DT} zN<A<Ljr9s<S;S_wCnlc$j7IM*rtdJ3O}`RVHYNekMt-QrJ(@L$GX7$XaS}PEkz*D) z=3lHe#Rh8IGIc-G6J=d};XaP<-rp_OH8uOqht?C6nvj%6r7SUV6<x2_Xh1C;eC#`7 zUUYxTaq<q`R(L>}Mnxf8!lds=ZZQ}{B7NdbgC=WH2b#SY+&sVg@x&1QvvsR94Dm6x zRs~ep>K>D-%{9dvY)HUj*P%MH^u432D_-u>4Nf|N9qloMZnbMf`}tF={J|4rrnM16 zS&~5kgHeq5Sk4xspQR9GOy<wI=IiNPyXW$1s&hDYD@Dv#spGvS4v95gO9|lEdC&#) ztD#n>Fd9jx*TYXYAhP&gzt55Kb~XC>8+o}D{G%B5wT?+HpXvBR50c3AI5@-Gzq-gI zHLKkecw1e^Og}lW7dD$>Sj`|q$Yf1eE=u1&t0LR@Y+6xtx|5D-*s!pi!ugH+w2G|k zZpIU<<DDju37>h1#7LKAcQ6ZhHtgiIx<ZClw|8{ofR;1E^rL63Ut4l<P~;IR9AV#n zGC+FASh|Afpnt=<%6vO|blV8+LHG~qHUxgk)VGku75L8MWJlVuC+rqpXcOmJchM`3 zO6WcB?a>Pbge6;-(K)rf=lw>DbFXAQR}qG`B1PFJhR0;C8Uz-p;#uegzjV5E9+@O5 zb2x1rKM7UX`*P|yr(XM9jFKK<ZfqK-0kExwN8`8BG0=sNC<dpi?(&?`y`P_?u)>$w zPeJFFdSi`x-LdL;mN$CF$hJq#XW4|;x%0g4L`FpKCrMqJ#4$y%lL64De1dv^;b_~# zeWVO}N?Hg#ns)g~?oYJ{mUK9Q$A|s2V93oj_{lQiHMtpt*}W_Qiv7}3<?1Az9kp;# zy4s;VP{B#`rD4cZM@#Dme8RgZ9QJNjQp6JP`G5-~eB3kKo6UA?<!gH_41YdJ?D>p3 z<a}HxrR!+WQyP6pd1Rpf8`OsjWOix5QR6l!B{>drG`4bBv5N%2?1uU82#ctU66l4o zT@;P%6sQiH;>QD6ULNmIi1c7++iP$4gdYX^xW?6otu?#jO>?5974N*IbqI|^sK4jQ zf4kCxGEwyj2WzNi<E?4jjG)%$ER^c8gEwP=t0_)_6=^wsM%4zf-@@Pwj=MTKlvr%C zPuQGG35S0-V{*$Gd@g#v+(R*$+qJqfzhc&7LMYRx+WE7fE3|Bb$UEy??EHsVa}Dx~ zI^hE$--j#rt#w>AnX|9h&fF9N;Pu|tcZGdjQ8K(tBrXZ`=;#krXf-q{oD#TMmk%dW zm1amoHCoePJdad!UWf6;OAWK=4O<edE<Nr!KUt&-FH{c80T)OA0JN*W31AzhGi}Jc zsCryI&}vuNN+|kuUJH@WXot;627Z)`>P_3r$$UkjB^xHy=%iwKCcHNVz@L1)Ci5mq z49GlxPC|Cn8MIo&k6?!&@+IiRn$Jz`?CZ}`2b`OS&O#>h*m_4hSYw;xoPUf+sYo$! z=$5c92F8=5gZD3ps<!eZ4o#&_-1z2SR^bcQ(RvSj8VKJScL;|?7%()9D2-HznDM5_ z>C4CO8~JGF+|gSKe>F|>f9ITREP>wO5&eV<ee&xv*VdA4A7Qvx@&ms3w3z5DgZK;# zjXt;4EE77y>wJSRmZD8F6u+>6)_t@TGlQQo05PGw<oZ|Q8~koB@b2zya$Ec`uq6Ad zY(qz=bPtYfh((2pf`ZJXK{0o7bThSaeEG_i%gx%xl>>R1a+ujWS#dZ!xw`$zeszzA z76LpEr7wIC96>|P=u!~11fcwutM>>Hc?<530z1C|{Bjh?LcPt^fekV4#UqPHLrEZo z<H-7uDN;M93E_QLU=y5tU-~6lQbJYT=v1pmETavDA+_}TX+IJ1tjFWaI{4b}VG9O_ z4LevYA{yyT<&CH-qU_i!Vl64Op%+W_LCgWT?U^dQb6qQ36J-#eoZz{cQ(J!1R1)@; zufk73HIWO~)bCghy^K?}%bu~1MXE}-UHDdmACM#V+T(vN2v1Ki*6PO6RnOY=-Mn%4 zadUaIKR3I-zka$u(+=^YnXdQ0;E9e=Ddl>YiwpLjpJB`PVvh(4q>&N%8B(N1DE}`1 z)O$CuTLgmnJYQH*H&#Ar->pvaUHU?9L`#`f`^w1P5(44ADjTLH`n{E*FzW8!*q#p~ z*g+CL{L(<h%psZgD>CiL*4@WXiZkSD@7URKAB$I~TZWoT6#0$j^kq=z=_vtMHU7O= z`p~#Q2V7T2QU=$2ej)lY-k-BVWvG2oENB|8Jp1^1q{hjO#R}Wct_1h78hG$JrwsU9 zL?78!tCh=UyeF`6i_josX&`IVvP>~_1ZQ!fn<QzZ5I1S$Sw2-blVA`n=R$iJ%pLI3 zUxn1NZNj;I1J)E|ppaO#lu`0xc)vBoVk4ROx}ZH)vy|Ym0=>l^$~`%Zv-=9AmF&+k zX?R5@UYHY^$rKXD(}&eGCj`K)b*c%<i_`g5)s+q%2{|BL+$HJ~pDnMHr`CszG{BO1 z9K$={t0_~foKs9!L;*cl;Rgx5<+<n%?#1HRVDUcCqV6*kCh7OuEO!*G87Pg7P#qNR z284WgJY<>ZBDO+_wtD(RF4<Zc|9GRG8ruOn+i56KB)4e_@)rNBV@3Mjfpzcfe3OtF zQ4{d_y$E^o3e1|tA_byAh<S6MR}A(_fd-viTAyZGXa4Y@3^Tky+ue&<ohK7=*<zlm znAo2^Z*-6^8;gn~sY;L*c6k*ZbhvtS;q4*$w6LTnnw-1SV!vm-UMzCmNU@csGXeC( z>wY{@@y{F`lvgP_?^-qe&lb8f<k;2es9qncEtsD2<-3yzPEVhA-aD6s;=6(qR`K44 z2Y)mHeF`nltb()8TNRWeCdSE!&k11OhwPLj(}Eaxu-_P<b?wQ2E~4ZXP}kK$<<`U| z)J}r>kS0c3Eeh*pzolV2i6lvkw|yoEYpywd*n%i;EXv5FPjdPIF4`k29Xc<??!wbC zSc=6l>KO5`LH^-g)!_~*7PAJ2rA<lsS;a@<Yirj-jUmO>{n9G_9{8bjnf^NWc%Mn+ z)7O!bZTgYP2seHUELBrydH*4^<u65cBK8(4#m>JX-`OopdoJ(^vXLsi79i+;A*(@Y z^lrCpNESAG&soWOR*0DfD%mZwY0naZk}Wc<WCSHlc|powj!w!MSkBW7c8Grv^|Wn> z6)#>PbQj|becI7Ucni>Cz#S;enNHWPC6B@Du_MA)`Dsk4A5DX;O+Z9Xd$ov?zg_7e zJ53|t+aa&LX;1D&`${||Kat+k!pe~DM&X`VmbhAF^=D>WyDbXP<d9)p;5N5-#Vgc$ z2~K@J`_y|?_`|R6rTX9Sg8hSf;}RvDG}~>R<D~UIhhGY2?VF*$F8NNJ^P+H=GpI!Y z8un<4pACZxB|CA5+)kU-$j7-xN|#3qVnrE0s-@Kvj?u*%^cSCK4`$Bn4KBTV5hmk; zfTduqbyH%i$&`G*q%p|pMRddtQI~1{s6^HQf#GMY*Qvw~r??vaoM4H*zF|!BDdzG{ z4QXA%S$*O<MDbO)0~Q-Qn}!CDe4*jOc4f4anT?2Pns^p$#v^8QesDG9TrTl$7keDp zSKUFK^n&Jzb!|wr`<Xt3+xBWy<V#J7xkrhS-TF!Z*OBDoe4~)8HeA0ky}y>%J_u3P zM|R__PPHu&7GblRX@glm3MyM<9YKd+#7VK#Rn?x{_GH`5#v^<rk&W$Df(Iwt#pVau zWZHMkQ*%_;prP1NC2vY$IQ98rrW8|o4!uAJ%~y1=a0f}yp>aVxcDT()o;;irwx`n( z7KkpE&qa7}4n|Vd8u{frdR0%;(aq!LTb<o}+~tt{5=$cqM8PDn4S2g<C?1%z?E5w$ z(1RccwQFm8UkPfaAC{uhUJF&&X=}0cZiZSS0zZvqb-ll>+5Q#u!4J}8GNpT79oOM> zCz&mHVPzE8V2>x9sCMKi1hEl%%`Gv%H#K{``fXq7Kp(skqr7GE%y)mISk$4J@PbNl z*$C8_dYGDVo(4ug+4X89QsA8HQ=s56!svm@uJ}&?Z;P7xsuQ<UukW_FU)uDh&H2@% znuSOULtTSEM9CU={va$G=B%G!aXM~%W1^<9C2^V&Zh=XO+vknj^-UF52X~fKkIh%f zrC5vj++z@oSC*ul&}?x}6)oKcNF|(Dh@v^Rb#c5Ly93UQb~{E;qfCzK&p-26l*tx4 zc5WE{5w{gELzZy4>p_sC?WWKcZIq`J{D$YiN2&X$b+I>Mdcu>m_@d%yDW9?X!_hUW z&T)E}O=RbnMKeJrucUFRRnZrC)Z^AMokcJiN`W+SLNCsR{x>)pAyyTHtJXwX{Bumn zx?Fs$1fRex(YR2IRxR|jcb@liIAYn}OJVd~k|=WHpq<v2@>L~2th18yT&geajH+LQ zCugZFPVJusVS8xMsOoG}fCB5>aeMTXN|-snesM##mXkcb#<YO@XIbWy=j-)ulv$CF ze<IZ$>)OpsV^^<qd9ywo3K52FeUa#03MkT{gL8uAhp)Zjls7xgE<TN^(p`DM!o<d+ z$6sA@>4(LC<-zh=*%v2^o8?){Ee=1-)f#cV<`Sy&3OqVIQ9HimL-po2zVHmy>dF^z z@?<<Lu^hXqo_HIhk$UvFUD6X<Gh%R3(0**j!17d1h{L?LFWWo+oVU=M!*L(K9a)_) z4Wi|fMK{%r80aa^@?@_(%JNoEf$@sbQN6WtO2gc}9+?qx47|ZqQ$z&_QU2*$3Tc}I zcyHsIi#b5}76{G*lDEKT9#FakUGsp-EudWZ&y3yQp!RQYZ}C63p8pLB76H}URcDKU zz%Afe0>p0vr{AqhA>bu|=h3gI4H>BYb3FJ5A^V%6bi_dVmjE)_UsV6}>mWlxA^(T! z7ubsdAe#{Y1>|fQz`Es#o5}Ox?>Lb7U$iXA5cOq%;g;%mk?)@z2~!}6%fM|zS4iVB zKmiP8LZ*-tw~8>$Wk;eS157F4&t+G+0Hh%Upuqk8sP7_^yzL=sD@Y!KA0ZAa00ZAI zV}6%o{mFwiANb#4>#vrs{JfCeWq{~b=Lb?(pZ>Ot=wFth7eb&b0R63sqNxa7L!^pA zNEIpnMYUZBKzgzPs{c}vb`_~&P%-4`DnNHDX|Z=|^H&VbfE<MX;vrrNdHXljC7B{j z4tZDkzo-&QA<amtTYdg1I=S<wxj1D2Wa}f+caPQptlL+GYYnML1q`CJ2GHIv{+$<( zih}h0|2ont00_7cAcuTHF1}Uzu=R9a7a5m7CqO~@x8rk$A%klG!>x#mUm`eWAf)R6 zt>!Ox{JC%VErV$GU+(ySb`gL2TXY>M0Ba7Sw+`I)^@V_cO{C31($@i|TcehEbr3d4 z4=MbYhoa^I2-X-t#qkGI)!%!LKOZ9ZA^<5H2PlZu6fuxR>nJFXktZwimwvH{WRLPc Dkm+W% delta 19892 zcmY&-V{mRuv~6tLwr$(CZQEaL+qP}nww;}1$2-{JJLlZ{Ue)VAb4>K=RbADi#_aC7 zg*{k@g;$aV1%m<lcet@4CBc(`{%csM{xkZl|C**0WbuD(ONF?(?0*0;Nm=ASV7e0V zU#jB<3mBI4-%!T~FYxvMpi4tw)3^U(idrBD6#t?OqW}={|3G8_2ovC+h$2-VRm&6{ z5RfN35D@Y|f8l9v;%e<?Zs=reY3|D4>TI{Cd+mbTf&N{`2cGR=V=1Fj$`D`2G)t9? zXKO>9FBQFmz2G#cpD5PbVFWzoQz{^7SbG56sOds2vqDkD-`o~6Gc?q7l#6&BP|$Y* zJ2bDjHFR&gUeLJY26*p?IRVI({95^=FzZq^#x|08nfkotOy<qtf<c8Wlh+dPlfyXA z*f1Z^ZE=yYA=vy<dO_2dVw^B1xUKnd_~9F?6C3Rli>gj=NwA_K`3qW{fGW#6i-MoR zl=rEmb3j%-^Hr<9i{lO7r4~e?6Su;&Rh&<IF_li;Cz_hS9iZgLfqLXtzl;@f%Q`EK zI%iIzmO$^0M-Ps8nUyVGJYXV7IMB!4<Fij6MIb8&HeRvvYI$IoXILP=pjh>sl`+H0 zw|tOtwI;}tA4-P;OVC8N#)5RF_0C%icnL4j{5qQX{*@SKfOj*%!{fJP6)+SYAsO-J zEj~w*wXerd3&3hti<}5Po_F)%&b$2``?Gr2@)~WKrL?#`%6S(n>OEujb`!yPr*{#- zsBg$TIOk_7u2v9<K*`Cu!;hKb`5Cx$3IY=5;ezq?VYt~kIniTPhd50^DM5{$IXU{< zvZ@Q~&f?kJ1OEm`xAu9WIWkRd>To*puGxIt3`L9r4L}+8UI6gIFkO$ZH1r?o*X_80 zg|oHqPSuR<M>qcKO*x;Ot-6#E6Igl#<>mTuPYz3xf3ZjQRXtW|G}VGOGOiu+hH$gO zp~q-GKdFNqkg^t)ICt9zC)OypWqAC-2mhWDI$`2|4R1mY+jD5_e(1GvSGCvX(3>`Q z&9+9b3b<OG-;LL=DB$ph`&(?7V9rRLeq)b1a}F+A;7oOmA!bSCYC?THc|E=p?&aR- z>E_hfzcpUdmEHesE!um<l+rG$Tk(?JvVSUHh8+k4cseFBJZzCN>eP^6gCy0vkvBpe zz#(YCV?cE+AsegdJ8!ge3EQVqC$V6eL2esH12~>K!+n=x2UvL$g}A!{2WQWPX-j?9 z>lnd6Tk@r5&4OmpWnws695(8>D5^B-7O8xmf>K}*;XcaEGmSTK7*R%Fn7It#0LRFh z5ipl*)s3=^Y3EBM!Ig3ph02S&7?aG04sR1d%*+T2BxicbDq}+AfU&Sa=~`2*2(!YN z0uCr>M3Fj7=5#@Ju_awt&h4s3@j@^_ET}_({dzD?EF`Yk9yp*t9KkiAdj>5gdi+@S z!J{nvn3YA#=DeQN_zSd&eamXAxoYj%muYw4o=>^p(k6}Zy&T-bQ`nO*wteAq?pN{? ze14C#JjluW*@5OcxhHwfup#R*CN2GP0GL>E=@%oIl+9bkDkQ8cVXlg=UY>3(-n4F- z0KqF)Fi#x{tLoU~ok{leczSw*`cty=`6HD+F!YMecLwjU&Y_#dHmzWTTufw-A^US& z_zNa+$HhOzQl4c-E{KJ$+j2r^gzr!3#Ow}k=R%sKmlF~$=rX&Kx;A_jQo2y00^a!I z6W<<wr>Sy2dK$#~kc7ZiWmv2q-a6ayfZ%$63SV(rv_}oykSLH6%eMHEW6J70H~e{o z?~(rfK!~teHF-wDZBnCK{`9_R79zGd%DI8*h`2S!dkkFxvOr~<bE2iqSR=v^qDIg3 zu{yB5m3m#5mnw#%kW)%#BG>Kb3$Qn|UM@^m`fJ~V>fX%IxBc^uUZ(l6Q>yum_161T z;~?#Ju4%v^e*6@IshR}0c7Q!g)Nffi|HvkM_U50;5bcfmS{52pbyI7{#fNiCi2u8x zio_5vPC{2R$<}rf5@zyw?c{tp=}KbYOQJ1u_S#Rs|17yqr+-<QrJfO$5TK1yUjxgD z8J35B<Z*V$AuZ3kuFYtapVkzMNvA2i)US(ue6aBS4>wq_U=hFtOd&~7xtQP)cu)$6 zt<QY*O@+;A$LOt>57wPR^YDn{pmh4F`?*-(2IiT9(uCfEnfE76!kgfkc*H^tfsUhA zYt*^0lAEs9C6jbRQ|;k50z65grNFpR^vUX?qz)&$IzYXcq-13hZhU9i-OuqRg39Us z<{gtz9?^nMDZ3z|ihOI5^^0@Rp+tesgLPZz)wPi(y`T16sQeXzwVzDne;wlsWh|1C zp$FO2pvz(^OuoQlhN>DkWlu7~eS@^-jz^%CDj{-tsM3rFkD8?t1-OVBsa0Z1*-&(+ zL2Ig88zIe-J*1adAwi4QH0ez^<CH51{*rhe;@U({3LLUEjY-#ypC&%g;HU4U$ob5_ z;-QAEow&TZR3S0vw)h-`FDvrIw{wXaVU8{w!ytCD9MMjsfoTadFou_S*Gb5rMc)bG z&ypfFkoh&E;gu%*1+bB-6gR%6m9mvrvs?a7ClOXJZhVuQzqcc@v2^cZ&<w@!X+y!} zZ})0F-HYGx2<&vak=ZVe){jG{BylBS+!(_4qaE@HBv@^Zm#^49sn%eyLu?Wp8j4VE zy#{`QU9YjBtO7GmUmj2NKmwzfM`pUYh3#lgC9CxihEzqa2mE$`-5*q}2C<F;uc~W% zNb&Z?Z=@A&zd27uGtu5?Z%c_3H4x)0EEry&=2v%4$kpPy>j|4&k|Lt+LretQ+!LZ( z)xV`q>WX6wlamQbhi5;Ma=f>5cog#b0g;7LMi-{cs19<1*>t0phZIa5C~*r9jkdcj zXPYvyThg4K1=Lg&?YI=-lsr!qs$tui4F-_KrOq-zhY(xZ%wjbboY5yVEuneTiB$oM z@HF1wh<fzQhe*3xy0;Wdso6mLO(sI^7;(|II!_Tx!?0SIzm85c!N?gadeOGaSb|`i z#@Xhq1rpfR)qfN=(}~3^y*s7yuF%>|<uTyJu=ly}1N3$vRBf{qaO?cR)Ou7uUV%G3 ze$EoFqC)JiqReq(7J4#&VTf8X3yV~#gPE5xJ*5rfqHJT7jZTkBuA%sj(Az})IHNBC z@3t)lx+VEcsrV*QG+aUq$xpdTHL=T$5y^5~EU2yIE*qJ-7wfO}Vk!&41lNdi2An;} z1<AP|0Gg`0ok6-!I|f9}LuL)iik#ErJiSj0$>IWZ;#4E_9_iMSBJ{eAu?>~jkMJGY z&_M@EZNUA-@{eWYyP+zBA8Ax}7sZ#}4&jH|H$dI1+e(J?@jGKcWE;9Eyn31|2Q&)X zKuer95wFy~rYsr|XvR4j4RZAXtJgsk(QWlCfc<tV0((_7&W-C%cz4PwHL2`|(e!wh ziX*L6eTTmp-5ZU3s6nSo>HANOTbkejn*IGYzuoH=oQZJAb!-Sb*w@vdh&#M-q`MtH z!hXvgNScTlIV6T_sFU?1fUE_U+uF-G@x?b6!)*`uzwRt24gLw}@a$IWv$!ap5&erp z2w0nY9EXT$?zkbg-`NvkVo&<bn`HL7N3unfa)OnM?70@VaY2+SiUPBth%!~Rrwxq% z%{;ag?J(y5N<nB4H>{p(<?t{-5WBO>!GJ^%9UmD}Y0-|D(1rh_8#=n?wJZfJGuSfR zMsubaZJ`M<TVycfs@#zrW=-z%mQvP*41gj3CdbZfID<-T5=vuyv+J@_hBox-ILeqC z%C^Cds%FuG-)Lh-i`ns5K_Bp+yj?(33_d&YXOT3?q@#%FTiQqZx{ce4d7lF=nY!B_ z`CRt5#S!NCLZk6!sbKUi(ey>Hz^n_s5mtC5B-ZX0ZDsgm(|Gk63CTdOVYu{#12jM; z9I_v0DYQ^N`7Gl0`zSwL1<gz_`F5s3(}{hW5lHqO?F)~UJg>mhwUe5*mrHboQfmHk zNlHLP(hTMarMIe5WiQ0yOKI~NM&QJ_uR^MZ+2}(@{-sr!fJ8G22Wd9mj9`t5Ck=+v z*?Bi}l_;Rm%87KV6LG(s2}lNO0PMMt$4!Lzj%i;U-7Kclf*+@?oOOP{RqSepDf6)H zD+7hN#MdqMK^0Y;sY`Y#BL-+wZCgS5HsRVk>(JtWEv*XwmKqxKa~OzLVb`nMj*6?f z4G1gtITmf~D?wuay@_V%B<>O((x((PkU*t0nLSNaL`5mQir{5Gc;_A12Pnp8sn-ul z{qWS{itmE5G=gWT5bylKf|EETo?n!rdHW<!jF8)j7`4n*{sdYwu&)2b8x6S<CG>Pa zlEKvk8IVTvDM*PrP;<FyD^*{KQ+?^pFLp1<Ji`Iek6e8H_UMftAMkYh=k2`~A*iLM z#a5(OGzba%vMOwLU=OTe003}(S;1~8<c8olI>S&ABq{xN!Yvi>DA4g6m-6qx;z{yB zk%8{~u>6pZ=08I%SGD74<~?{b6kP{-m^)`L(5djz_8+^c<vb!d8XJlJakwXAp>Zh@ z^d#yzedrhtz|aC7)%CK<sh{YlfdBjr?G_#FyiCVlAT&jQfjE|zhE4?hpdeH5h4}yV zU>R!(AQbTbwno7FHQ8WLKtPchP>CQsfL7^l_{0nn=>|gtCM#<@SJ@<<WEmX1+ku0` zV!A5n-PX>&9teB7l#wG=)`i)`={NNz8Y1b#xv9Gf%=_=XkA1^iCx^~4MK8fD){x{g zuFSc3#RiL(8_`2pEF*)>4`F((MskME!5jNG7b}*WK7M}QtT_Z<hrNZwrN&V^z~YaS zzl)!@$NTy7+S>Ef+JQp-`_BCg<9+Ao)WhW*xwPGgpzw*HOucitS@dE;N-lN`&pAun zRO&bJ=S-Gs5gk)elKCqU+6>dRJ4W*P*2CFS#8XO4&eq!5nf$JzN*Ob<Up^SAiBG+o zfUA9<LtI(KIjd<_d&tcQK@m?EfXjm+TytgL%lsduJatAUg53oSB1@RA8?^G|OQnQM zo)y@oG~=ui_d3q4192H`9pZuF-|5ZE6M1!%);2aN+?OX-m5fn_zx4q^3Uxq{G`7Iu z>`Pdmmg*tQLsZq)8K_87cRroHF2lh3$rl=iBC^MiG;rpnNoB7Kd+TKZ&`g1I^o}O| zF^AG~naRS+N=4@NILWK5377J$a9iJhmDS|i-1a@!#W1r{nS-54v!nN|Z~>FlQ^I*n zkLOId)G8L6t6iptpNPg9X${wBq1(r1R<6Z@(^H#uly>p-#IzJ9)9~r~Lek3onj1RQ zmVN#nQXr@A`~;(oi;+$Rh^4{>lgyPS=i=!|fAZlBRmq8G5qnwJ9R7O8(GwW9QoFvF zjqAg-(uhRskg;Y*sTk*i8GuR6kM++RbSo=VCq#&vLgoqwH(6?qAll!{EeJB@w9&Fk zOHuc(H-k;oG_Ycz{~AA&GbPrF4hdlS_I;dga?ifs{S&cR@#C-uu#57*=rx59AT>Pb zt#4+oMrDpV#?Zp?%%&k~@{MipK=fyD5WA*EhKN+Sq)h1IR1g{N9&^m24noNs`XpG_ zg90Mb)Rq>>bS9BEf6-HRKi(p9K@^TRVaR0OYigX4oP#kb)BRL+%ze-uc&o>Wv-(}J zpN{FLS@i6pt9t?j*oW3kxR%dsOv>28$qAnF$%JYc-gn^2j`!~OGh+cMQLTpK?xJd1 zMF-0gEcT%TTag}j@J^?Wg_Zs*sw+<-8Si}T7Ot<^vtmjq@h$TB%K?j_oKU%xfjEjX zHO6@0K`$j(hK!o#Bzd|t{TcIjI}84=ierq1U|+FN<5m4XfWm?jx(|WRxnb9AUEVqm zM}?4~4qe?KY7JE;RZT$~=L?})iQVG+*}T*3Ed$lO<#<Rt2EF57D56Ni?ZW$L(=h#d zThDfuJXAIm8$kwluMx|2*4YO+`55K1LrBuv<FF1Y3{_o=VkKn{R{Sb*4c0-01R0>O zFqJCEG1L@7fUuchI_hJFrm~`!5jwg?J(qVoiAd7qI(3d5P1L|uj7OO*dK>W{IXFv1 z4>vN}xC1WwHfs4^4R2L>X$LU2M2<j<VAN*5`YN?8ooIKLH>~V<NbrJqZK^bZgD%Hs z`StX5ny&dBRx_PpZeuLU*i6M4-2eu0)Xh+m9Y0%2K*>UVVsOrK-QnfD!>8nfTD?1G zQC4&bzRkedwpQo3rIYWG7^xr%fi4@Qs?oH*<U7nBC(HW7^KMH?xmZq>;bSX$7dVTq zja`_-?t|Y%Unmls`Ze6=%OUR}1KlQ-dX{Ui>n!Cc$nR*}gWgG^i`;ro{Qa*)L)&fC z$uCM2z?5sFyqq6R)+XsC8cLBz?82{SyNG4{b^kF$dc@zF1XQ;Le+E?<yz)>nA}9;L zo&E2Z{|0V3z6>^Xlr<my%)Wc9VKb&SD_S0e$aKzMrSt!E1#b$ct1WV1(9)>NSS-|N zjL&>avtJp{bKaza1k{q154!S{n&a&d+YN(n0LX`uusI=inher!L=nHxrc*1K!(k_o zNottkWazQ;Vw8C`P|!+Om^=41p1FQ68jJ3g_EevZKep;}=U8iEmo#85EAdLY&Y5+; zxBp>wGfSSioH@GPN08SzI2^@C%%46-=<kbrgTmG~ntD&7*=_saO~i-u1nk)+=5;Kv z18|dW1Q%SxQ$!y07hl4884+--)}nrCZyN9+<`{*kk9ivVGVlI<Zh&v!SUbAbJ~RlR zFO{7gfL*zDvb+-ynW|VVN#tp(@^S(hD3lWoBL28SwVJPT_~>ycAMC?zy1l~ex#GO2 zYiYq`47zM3Go4OdsH$zK#ImX`zvZHn0wkQ@Ho`hkLdaC)t|IE@G`FfK)!1i*1S3S& z_hZw5BWNkxRK(met5LD7B`)xJ=7m}-5cYGzUwgRBgc3Pge7ohBn>$Q?v0-XbZ*78q zPb<6{GSwbZ(ZYizGESm_#3iSAQ9E>*bu+IP(#ERQS!FEykea*+ITS7WY$zqE0ti5t zm(Va_^Idp$lXNSU=46%6<H-AOy{`w;^sr^ffZ6&x*578F@PWHaRPSm<MG|v~bIZzh z8qirbS~g-P*934B%uy*)lIz$M1mchSEUfT8)?ZRwt-#&!h2f*}htEbFhfTPaXSq<Q zs!wr<X}fw38oM~t)?KEwD<Xe30d*gqE_-dh%rXIcn;oh%-=*dLr#ZGO>44VyuLFue zU%?Dk`HdirdxEaDZ$&Nj13S)vrz$lzNB?Z~Kfm@n<o9&>U)z~`lYf8fkDi0e3C;D~ z5lG|0BSTwM2~q5M^2`EifA`SYD{lws@`O$fxZ(|e56y=NLVn`@rw{%S0zgpzUeac8 zWP<!c_*WntN*)c#fdc{kh0C}p0Kv@o{Qv?D$kViU+~Gj_)&u=O)HJTNCraNo0T0*G zNMu*QC6W&w-Rg%!qI$4HEs{zrJ;oXN{)qRHPTjuT#*wB=@|?K1&F?WiE^*NpK^r1` zLbSwmdVa9EzlLC?#oIsfNN0|TM(2`QNol!e!&elhGY%EMY%fu0G^5pni8^8S>tmAz ztgN&=d1os?8r+dP>1a$!j_l<8ojUuwML4ms!TEG8c(F0U-0K7WL4HnY86%sFH6mzq z?@A6=u5$)8!bFqlZY5Imn5c)XaAbHlALcPwDm>mn#C|dfsfae^;^Xr7`(@?RB+0<g zfMM7;)ixvvO?#CGdD+$UiPxRC50VZPkXN?Od?Imj8K^YJsNffQM1?(St0|QzS7$M_ z3>FYHxSWBiVB%8E?u{-vw?o9R$UM0*tL4^m=;6%sm;YD##(Wwo;(Y+dsSdZA!*M$~ z#A5#(NQ9x@sba1GR@H8@ozSZGgLOW*gyr^Dez_9f0N$XAY!xT(@hb>t8Ap8upb>eu z&JyoVJU-?93@8*ufr-0`n^d6}+7ME44rz^J`~JI&S8^@s7c?94Hu8y;E2#`+>w9_| zIt|;b^$IG_QmT^$TrY9x(KU3+S@zIm#0G)Hl0^%&H!X@y3(j5s-YtR8JM2E|*UmM^ zs!AoV7OviWu$8v&VHOHf4LNxNfVvKBtTM@;J8Lj&+I$SzhQH$IYYzTxIC!eGMWaTi zBh6|fGBtYKuLb3N{T(%4$6@}s`;ght_80nlDiwAhrTh%K$`1I0^TQ<`pZwC`@~_}e zT9`VYK%0{?<mn|ty)p>dDHlBWlDE5Glc-ElV#X1WOr?em8TE^0_PM_+0St8~W6r7? z!kWs;NH2rS-5sky&|juZ1d7+i?-V)(X%56GJOee%h{u(6d<}kA`qooHc+K>Djm6+V zVdv=3#F%0Q<2Q1uImmt(ZxI^t&5T)XiW|v8u<vY?Yg@1H18_zQln%d?bL<H~ll_zd zCNW)>UXn}+Vdl$}3u<pvfL9WO0r~i{H@zkhy1%N8(@?Sm12<EtQ}FiES4QBG%NpQF zNmJ}1aHF=6e@bYmvlKg<SFJNc$Tet%4-#m>b*Uj@V^lWvD$%)cP}9imhjdb)Uai=^ zHjxrh5OdQ=NV6a`q3+;YRy&}Xx<QqOWh(J@VO3b+=-7#qU^ShK00@<28fj*StY>k` z1#M;qFe<$jPDET+Bf*-Z;&WjLCzZds^`{sFYZ1zB#BadSHBegG6Kyymd#hF$D$-na z_|2a2vXt+m@M1~RN7=-DD8<wK<n&f8ZZA~08$`Flzia3oB_m3GkKsJ0m@gpc$@B9+ zc=;}0LriSl1*EB%0TrpY8kT>;quJ->SZZx!<?b6|4eQ#5?^yMHmMmvyVJS`pSoKLh z`&S}-XNwQ2eK-3>2|aR7{~(rgc4eTE{9us3lMdO3KH2B`7_Y(u*_6%JewHe*;yic? zAJEZlm8u8xs5jAPU6GN^C_zjWBNO#68Z^&TUp&xN9a!ib0KTva6|TL-D(XfRg;1iS zUCp%~Ofv~q^C8{Wqdvi^)10npd_gWhn%JioKtG6fCun>z)_&N*8E$z)x)?enYS-Ns zX@B^_bkz^Syr3wp#$@n^;{gFw{Wa4{Oa4R;A@}&Z2Hse!1=^RCJIOeo`;C7ZxP+JG z2Xr#Zj||Ys0r=>-%L3`bF3$ax2fZ-t`YvTpv<?k?e-u<V7RE*u4FR-P4G4-q$j;)> ztcARPQg}hyh;>B9R`f_zzw?-W*8UvNOsA#cdar>(UG)qBFW%T*e18%C-xlpZ239P2 zB)z!@1p@N_hm>*t;bl`t2RCDD2Xhx!#*Xg-5NNRfp1oj7K{$Z_d+ib}1NrqIK&}S4 z_%HWS4U+O-t|O@yr0ajG<m*9{|Ensh2k}Jxm*DqhlSN$qSw|D{zjZQ_{(#^D^3;_R zwz-f33`#!`RS&8HTgmkIWYv>v+r#XWJThQ5doof;P!UIUCKT{N#VbDUI2Ay`TzJ&Q zb?gvX3j`PZSaJ8#y`hbv?j{H+74QG9T+BQ2>S-(=!QP&bHz+-U_*(O1&n~wLf^`KG zV3h5=BE*v$p2*Prem(M4%`JZgq(nGpBk&5`qC>IRqV?TA`SE27$n77@Sv)=bPI#!@ ziP&g38sHx<nKF?f@PEUl3)qs1sanDo;e>)U;BF0C)fQ5`L^vY+$)!9Aq>a)0EsV{e z<Teii&5bWF$R`+IfN^QZqYt*n#EKzGo?-kE8TbN!jyO(m9IwY?k);t2(A~I3<Q=v7 zWP79z-zh~st5+)QG?=h6&*DVV*2#5)Ns(O5p|X3)s}!0bp6RMv9Q*C<Ea)|ZaK78+ za(HQPnvQ*=)DyImF<HnzHhZLr`Th|unHZ;w3=s;6W_X&Z-NIJS6P2oSxM8b>T{e3= z>`&{giF2(0;-S*XhtZh^z(%+lVV9!MJGD_V&qZ@a?KQq&B5TcSI{vdCQ*$Mk%k}oD z#|2%>LMuxd_dTDcAa2aYC0ea?c&4o%+Mrx=Houv2m_&^1WP23u1?dQ(m&P5Dujup4 z0O#4GPo$GExat0rtom`y3#dS&TpSqav+hk>WlYr78>6F(tldBWkmk|SP;E%aPV1ih zwP6a3nqQS5T2=m&kNCv>rV%o97^ohh;n2`Hja<bC?_~<zT>Z$o+inwA;sa)sj>~2J zMI4nHgsD<P2-8FMVEyn0WYB44Y%cFS`NS#0?qyx(@h9$j)uhTRyw3sa3w_^5nWBiU z`j*}8a$%y(*3CKxP*$zUxwCg%Z_VcMt0@tj(roHB35O);pg91b)v@){{LIdcl|F68 z$bO-K*53Ck<nBvV$GR}^j37SS3R=i`G(1;H3PthhcUjR8src+?`E$uOt%3SQd#UT0 zVAA={c7aCv=Q379aU9QWLuI@4=#I{Lxsc(QA?<AMKJ~yl0FUv|YzO6KRClcWB~m0` zjBP&v$%)+lOv~jCGxKCYXwjtAXsXu$fI{Y)OHP=?^~N22Ou`2<Ku!%q?eA6y^NvT^ zpKM@U2e<Gu*Hs*fWhGK@8D}O+u}U(B=5n*JIt<`g%XZM~a^@%Wfv;WPVpk$GlzRmL z|1SkV{I3cdYz8^|?~rz&Qnj0q0s(=N0Rv$J0cGGkgWv#e^siG++LM0#bklx<v?sE# zeM^^I4RYET+c~3Z@OI28Jqd5?+o@1+mSm$?q~~Ver++?x{f?L5*~o6T=i>-_Sc$rq ztk`h&1cL_)1orCNhsMP3w`v9g{<`1a9Q6CYL_oGvB`5b8I~p<!2ip&`^ZI|i$1o1~ ze!c%5YcT_0=Y9)BZn11NzWq5ZI2d?8&S~iX{Jn7C|N2#P_kFVFNohGm_=7dbZs7lL zCfI+(J|Fx8@A7iOFtv4UhuTzVEXdcT6(K(LXxtnXuGgG`IkX_s-O$X0uz4<USm)Tx z0=1GG_OL^Ac19Oaet#U-_kEnR@bmXo)9~ly+4BJ4_k=jlKJDU>L=h8H?kM{0I#(dI zv+VA|KZDT_!!kRwqCiQ@fHD)ap=aKk`ucFdAOM3w2jdA2n=U;aTnfb%;x=J^E?BB3 zI5ZM%|F!@elft59$qYLzkH^<YG|xe4evjlZO8A#zYZshQA8g@DLP1dgu>>90FW-Ke zPu39-;{L`3b+<Wld1mECVCNab7BwI8Tu%kb-GjJ7h9K)PEPnHgn>@o+sei9|r_e0n zOk54Eczj`@bJ)=TD~u`pa78iyLBa3)>s43{6|BNI8$x$q!+9M1eXoV9i;$uD&Ax<K zp!u3<K$fFp=$ClosaS}4r^0ea$Iuj~?*0bgZbaVMg#hidL3rrVY%1c-a{&#b#(BbA z$zms3_34^~cE(OW&2EJ2T&D|uyyWHtc3$*^MXsf%Hs#850pxo@6eWXJfw}9P%zY`E z+_Of7Ue}CUbD0S7#7uJ+;%O=3CWOhyHN&z;o{uWIpz}CXW7zB@KyRvpW}}Mkq>Bd7 z{9-$(UW19g<5ZFnwqrjn)5oU!IY?5%rhV?mb6r-`q|CxBQ!X(zOO=I7p5Zg4!KhWL z{pWl_-{J+3gDYO7+^BUbp`B`((_ve}74NEnCh;+qXMhGAg8a~B4TmHfS6s#{Fq=rG zjVn)qE855zqs92X)CgHZq=$>cu<i$##|bmf?`8HGm2HV5)@#zu6qjHvGq!&%V&;G- z$t!{uecHWY3Q@MJ-nSCuK+D8d<1Ha$C)1*!i-UEIr*GNC+F{en)JSUPZD$Up9uc?M z*6yTFnPn<g`7}XeXqiQ-Mq}8gV*8_6ABz$a&FCm?7LA1w#f@3)<VuKhj>QVN{ZT2& ztiznOvd`MRnZ;g^MNW&H&+$-ZbdsoYnh77P-x_BckhkL6v(t3&49|bs8^%fu?$Hxk zHt9IO&fxZox{UVj;|%ZjbWX;0jY$yJXt4bXrVY4WAA8^Mp|=IpV4V8c<0NF8%ct(S zK(-#&IBTcvvNGQr^Be|^;9COdhJ}#pR<AerDT1*=%tMW1ybMqFV=d}Vxv1N%Cr2`E z`asx}*HCnD+=#)IU|odhsS($sAMK|nEK-7|$1|o0Z3)&|f`tG*M!VkFcBL>!C`ykB zP<sjP&pMG5DyP5)Q?O^AV%5{|>!tFC=;qcq4ly)=)qrF<??KbTN>+fA6B@*42PZV5 zgSVEh_6Jcc;IN5_COFeQ4$L2FVrTwsl-iY`+F>Nuv*=PmeRlyfPrLbO|M<nDaXtWt zuEk0dE_tq8J)Q?YtqbOn*`5V_m}g0u!FbcnuywXX1jA*iWIxwuY!Gn+{1b@kwE4TI z5>U_>VV|DiJ|gdh-vam`GYPrkbc^J29{-wUnIq7tVf5NfFOOkz#L;>xr9vx<y?`g7 z=RvntSeg8t9r0z!&gwq>MD(#sWsefbzCervu`*Q&{RZGLN0ZwI_C=#mi&HTT?1lQZ zF8N;Q7b=&Ya5_cOG9eGsGKc6;{`AJ<Q^YU7&L`Ld@8Rw9-V1pDTWn@~+b1)wKKB+o z%@}&y#f$5}>AA2lZ<~TVPdf|gNpgqG{o9V9rRV7|Wb4mWvV8Evr|9>LA9svn`Ox#{ zNDC?3&gKc@B1^}>>%kQPy-hijTr}`P4A{M~R_-Glhd^7jSw!2y=DkBCc|-oi&|OMf z=C1L{U!J?8N(#VdWM6a&C}#O%Pn0f>B|k%aP5c-4ufg9bP1MtO7)O_80)mL|f)XP$ z+)Rz^n&3>{-~R10q#D8$3kx9wO@H#EI^~2Fd8#8Qt}^4V+Qi|-y-Ls;c=|_oZBhVM zWj8ow=$<vH8uj(6He5VA>B*cPk=%dBMsvL)x%)oLO7Q@+D%C|@Y)9rj4RYza7o|{G z39kzuYYIXRU!ZP}f0-98$}k_kLrI8YwNuZMUz1E{Fbre=9?&6-%ZDDu{vF;)b9$CR z(|rmak;)?&*T+a!wW@fv0~?D58Yf%gcu-e)^kV?2?9d^Y`pIi#$4YgGphw!(MZP<7 z=sU8WFdGF_QA7s?F1&4uo;mH+2My_W_Mry@!&@zML#(<~*0MxVETD6XH2cB2edv>v z4ib?H_<f5ImM`5`V^bMqIp?G;mke2PWzW_)fI#&GmDW=TZJ|-+0GqoO{%&?>AOAf> zN%DtAXoQ|(#GBPE+k*n>YqXFM5jjsTs5<l8LTC@btmp2ah7a#}Se+rXR?}YXU)7au zKytZ=rA4T70+}9R(g9T3=>XNPeeLOuG!=2%|4_50izC)F=Fmeq0X*J3L5-G>(@fqG zN+O%WmC0U@>lWD9kn-fb<itKOdVs0~^&lZ+-S2O>+An3}`lVCYM5ly#>_0Es8_I}h z*a8V4IIe4vr#NTy4a$rq@v_Z}-c6BlBDf7=dD=7#lX}PNmFcIYFmI31kW5E6RC3Wy zfta?KeXQx)HWj$;rp5=;_atx(aniI{qytUDvj5VIsJ($)k5CuTix4#H>W)=N+8(iK ztBP%-NX#Hoj$T=95Rt3y#;ceKdy#9d#wrAC<9ge$7MVXM&?>mBw@ZjCTzL*y@QOFS zRRyt&=LS<3pE`H{Mm=Hb&Mufr?~`<;)#bY$vC6bW-2OBuuXT?2j2IGS5Mg<^fTcah z0BhrSEw{b3>hf=731%9v9#afX;A7?!=IEt;8gfX9%<x5zQ4HQ;qk9XiOJ+;2=xhbx z0vn^3Kk_*a&j>?CYWg>LByD0%rtBL9EqtcyWq&jR*`e<I`YWTSN?TnK)vs{eIrf6? z(y=N39o`x{GaF%>S&N&5izyhmKiZns#g8}+6X4IE8x0U>MKYf;mtEZy!S_Xy68A+d z>w7r6PyTT|vvC4plPW@|S4hL4bkzjtsut4ordgSnx3c6dqj7_77cWL*T*$<<Fw3X7 z7K+2vSv{y&H|^t^*<Pbq%_xxTbgAePXP=_4Vk}WKq+u{dad^YG{`<XsDtZHM`$vd> ziqz+Bl6bnJB({>PR&uP;OxKEbk>*_By3k;p*UHb;Bot=wLJ+_!YBVI&0rYb(d?7PX zvjSukd)vDe49^1yBIfQK<PSyb;zUiEv(jG|^70LbXmS=|HbElxn&9#v(IUHk=WHd1 zB*<JxJkF@R>c>+cE0JOF@~Bu)W#e_(5O!km`6<#z1iVudYN(k;iP^(2D?m}(MKAz@ zMulBJ3esYgatDD-iQQ5JfV&q<p!*W@*6WRlplcx>@;pkNH%T_NMj_>@&ju^4VP<AB zYp^!yw9*`&epg9aT(00Yixe#?bxi9;k_Ll5gY^tW9o}gy$_#ZK+-Wb$0v){uN%PE* z>GVW1s;C01eX4q9`BFA_MVu&lyER@T*edxHSi0Cem45Lry2aI10Qn4Bdf7aezRIsr zq2((Z07M6)Wf23l8-^9nb+S3a49P_WgZ4jO@pbYUN_yEB$v8up0$k}}{YyjQ3x9dc zJcxX}ezV?4v!2f^W*&GpM~_)oka-u$9A+MtRArulU1%qB0<`J9kg9zJTcm2=LnaFZ zA{(@)ObGWnvh_Lu>r~0d0bWc3rwq+A*t$C;3k@r1sylBNPOvC-FC>B*Axk-@7nO~) zY=I#i<4eiAGgT}jyqpH7gL^OWeRX?mshl1MHn{o4DD--ID7L=jo4t(}Tv!F50s?Y5 z8UtJoi;~imuqF4-4~LN6=`hKcE3=(|`p=vW1hT?PTN%Jf#C7!eU{xjmrjbsvR@Vcl z+s++oz<ns;XZn2z=wV36QV3}fWP~Z?L@)w^FaiQ30>T7*JUA|1JPsZ#8y6TW7aj{2 z9y1q)krS7J6J6&aQtKg<(GYTDaEUOuq!3Iz1R7pAD&G*8BGVA6+&$R;gNs98oQhO{ zAygS4xCKW9awLuZ>&~|!Fq#_yuApgSKp{}-C?a)Z<S`_AV6##aNDP|VKZo%Ek-kyt z2of`}`RxcCL;Dj5R0)H|#3(5k27B<v*BF9>x>x9*kl^YdNerPK(6q=HJe^8n5a?#y zUt&lO$#Y2jz-2EJNDOPfA<)gH<Rt)Tj;en!V*Vj0O$FuKA+&(kzfK4M{SAm;=IlQ= zK=xkP{q`f^SCB|IqE{i)CLwR&>3s--lkjIEs1yo~Q{ary7<}RSml3EQgy1Sr@+czP zAo;@x9FcToA}|9eIx~>&D+nANi`Nl&B3XbFFhdlf4v@46III))BtQ%JSL<gXNX*Wo zC=8J{Ul52MhGH&|Td`T@;IUAFQt)dSN}`D$uauCfu$1qsQD{XUnneKA&=Js3(|wTX zFsP&`<jXh&f*3@6AS@m>I?)LnBnSnXoDri0Brugh<lw22Sm5{|d>$Sma;6s%$S-|V z#mGTal6zedFapFtFaQDKI2b_!7))TY7lE!5ofc4Pn4jIy(IC)f|3wq{L@<PqHeUig z7Y5fqdnwR<=;Q_DaB#O7YzhokNS8l>fd@+hWKK+|>jahv<YD@60G<M<?18`i&`JpS zx7OtZ2A?qa07#_~j{u04kh#c~N+TleOg;z-ui)fi^5in0oS6hMc=+Wg^m=A&j?&Ph zshNB_Rbh+Oj1a-gMs5%KuqfSjS^^0(@t?^`s|K}BaY>thhoIF0huiT(#)BJiO%WyD zEMmJrXe)QUSPWE^Z(*xsT336<=-y`-8(q1@Rb^Nj42_M}xoQQ#@PP(_$*2|_WwjZ% z)9~ujp*R8MI5_(!^}$!SF+Vg14qG!9V-8IU(-%Lc2J8D9Q`$p#>KMHBfpOXu44mxx z=p6$Zd)|ng-5{L9mzsDl8CCFajTSwRdISD-)S6_xB$7Atog<z22`Q#L8{xP&k0P7L z9I`yU6(Mjb^6oS8fJ=BUTrFSd`O*WrO1*f}G+Dsw?!M3lm^2o%S3>Mfb#H_^i31n9 z=1=4@#AfMii7`sn3xXVlWuJ#c5c+k*A*s8Ay80FLy3YfJ?omJRpBk%*#F~Jne&lLe z{n7gCTi@taAfDY-H9a>2TqKV@jLjQ!6Fmqp_YLK`YYL@?OM-i`Ym5eE&xwE+{>?ZV z%QAr5sCLsej8@Af+?(8We5wSfW_gm2dLEq6Wm=2L25qCo3hjN?I_+g6$k{euLDe{Z zc_-a|q(b3zN9uGP4&PPsn}^O*Rji9cs~sR##r8y~X5HEL)3nb9ev{vj7{;1;a@0QM zZ0BA5J4V!FgCr=UOoPxzn?`ylL!$<E;18gZ5Na?Lz0DW&B_|SpE~a{|#wzDEyoPC> zK#Xiy+$LrDri9&Xol&UeARB&u>57AEy3|$UHwCg*OBTr?>)icWj34}(_MHytGgs^= zenu)okFAG)cnwEhIH65nJ?&q2Uy++Xjyz(`)q#AsBlh|CM%VOZAEDLy8%f>r9Z7%+ zos1lv%|n0_zBuPhlIw6yJXqJ_MmcUXXCdk@pJs1JUwkb~566cgc`W*j#lBGu_C)<q z$gm=)oEaxI5jA5^VnV$pt7$*^;SE=><Vzi5FBB1ZEx}4l;=26z8~PVn_Z6q1Y&eik zWz60h%uX`{d)wGn@@v&Vh!-ylTnxaNX!^v9jvYQlm3Ej5_>FJSbT5M+M7<y+1o=)H z$Skw-yu(2WcoK0%-!sr2Mb1ZJj1(@F%#FohWA*c(vEmM}T|oy@y(@Fo77jthKrg?e z8YTZMHsOLwqg}u%?H|l!Nn@Nmm@<eEqgm~|sW&X3?lvM72fnKC`o5fZ4kLhdwp~oA zP>);BEQy0w$1qKojK`=Ffw4xDae{7Abd^9*qtrkKwSJ6wrCNq;-sN)HMR5SDqMd(~ z2A$8y&2&=QgLWSOPr>Ui1tP*ci(#3Z>p}Oz`W>j9ii2oUtNd>^DGp{|F^0h~c2qyT z1_CsAe>z6CPTy_NcZYJORt`X$RVU1rLO81zhK%9*D=V+1HB~UWW1W%+vO4#4w4t`D z1|PzeLVZiEo;rnJMua2mt)tq?vhBkn(Gda*otB)6$zP7TSvtcAYePT6bLmd%G|06> zXU5@-hVC-`tSm;XasR#PhseTG0!x0>N*tZ=YqGQDyw9*7jL*M8=v#nn@TWsYZd1zh z!Tnghqp_ul5m$W2cKCwaMfpx~d-FSvt5-9&kE}vZZk4)yrxEZBYfYBxoSg45-yXs? zO9|CG`)AUaueDgEc3{Vvp&x^IiKVIj5qoStTtP%xArb2SR1VdaW8T9P!Y1|faeIW# zzowH%`x+|;DHe<*O`m|@q(!ImYp16hNMxHQ0gAP^TDoA_f!)y?kw>j94!Ck5=x0F4 z@TD~siwaQKGfAMo3GQ!fkxK0IclVtoJ7!i^E}XR<sSMEc&|W<W1?yKZmuP0a9ll*O z85$M@a|7mQKn?n-4f1QJU3`6=AMWp&{4x<*K5tD}aN@wuq;CLS2KloRlyN7ufc<DO z!2wGEL%Ux3omlC^qZpkK<&gg{fxrxbVSZ%(>?nYeP{Hs4qr<oh<~V~AFn~QjKaq08 zhMzF1_?d835%fli15bIpGyb&XB!HCQZNXPLQ*lB1y+i&3pp#hu-%HJS{3*#6`DCOz zpF7|bCX=!V$p)M@o4>7vN|IizJls>*Y@^uE=TxIxJ_K@dRaT9MNW?Z+^t$<t>Ef{k zBiIysKXq6&TT3A6xATRShDfMX0uBzGkh@gIFX}u3c%ajzv-|mkD@LWAlx;QO(0?wu z*`#r7r`k=9MD(KVBthtN=1;DF?MYUzQv)t@A14w-$N=QMm=(|Sm_9(?DUkZ^(#t6b zoX;(x;|G6Vfs1+DcihI|;xXYo^pKzt5l;RpWa^kChhQO!V+^mP7i>0RzwU(G@4i^C z>>B5sZ_gFwiAYO#N0t2yOxNx}v<{57+?<SYA#Hi2*qKUvNi&5SAQL$iR@sZcc=WJH zan$D1i~>SS2PpKN<VVA#V~$`7)SruLo6kEC0Fy3Teb?9m0#{Bxl}3pfd;7A7;PQyU zV|LiLDys*pA~gOKM{pS^+k56;_<@ThFsNo1R<Kki_+jV}BuGvJ-SYbk<k$9#EKl{w zTJB7}o3<tDS@nz`1lsBm_X?jrC{O@qjS?dVNWcc{?i+1#lnjdgp4d`bo>_Hr=!Qdb zmW)e_mK;_nf)tr+nixU=o+g(;u_ZOpc>~;*-=_B8g$R8tX={6q-bWh*L2i{-!R;FL zrn~kJ4T(o;)tL_JR0KJ9cjew=fh}-~xgxwaMNz6)s73WVy7-Q*nhWpNI<*lPX=36v zQozK!cx-j`OY(DGoBT-CuwOXH4oADhYC@?g_o=A{(!#zoYOyxANAb=<<P6<)BZ%M5 zx<BR8jlb2<GjVWv&YmroCb@(g(WVTciISG5?p{zCJOZCoHIm&|Y6n6JymWF^0U5es zF_rdqc!@Y>$`c*EwW*^P@p}hB<S_RW8z873K{&z+GAacPSsx>oo&t(O@{ZG7`yEf# zJfy{H$DU8vyvW9lf?mVbEJSJI+9T`q3Nx6+P@PymX`Wu;a;MO1537K|_s$E&ZcPy{ z$8+(}YSjIeKDf1_{nua7zRWVZS@Mn2ZkpPrO|@k!FM0{9cr1B&Z(N2M0zTn=Pryqu z=kNnrz?rGo$0+Es7SD#~k`q~akI0I57>e74>+={rjgf#hrjWI!35EM)YzX2}$=pae zWj5mC!r6(lT$Y&eb~*KPl&VI$=mQElv?{c46MoB@&6G~W^~}rei=3dN82@9)I_l)q zn^l%2r*W9gD@|4WMs!N9_*{J>9bm7HGg`t<9S2l|K$pPVeIRMOG3lXECtz$q4WSc6 zxq$9rNpS4?b<v+r4n2Dd$9*Tl;4fcbfE6)|_}O%b#*z!MQjNJz?W5Tfgjo&04R+0# zP!hiubI(>D$)RYaPNi_yg>bk(Zbwcn-x)lA^IPp4mHty88)~lW5D#wPUjUH#n3SMS z&T#FtiDslZaC?|;##+A;EU3L){?76&1|m}8w4`*NxDQg+H^@C!fC*AR@pcU6r~i^c zZK7ksWbfcz^5km0V|t)!5<M4^qok8nFu9AIsE(%X_|0bv5Sogbs_^Ao@>(<7JnoWb zz_#HXdRvCIC?vinlsH!!3xHjM<Y<o;<B>~qe62M^soV&tKCzBs`6C`@CZq*6PA2}K z$V(sga%UFQOLg(oQy+r4w|cx(QiRRT3dCVxB^55_TBWZnAv(*mVSROOS-wf#RabOx zc_t_|?Rdx1`B>b%*pDX;2};Pqr||O6o}flThPFm<IJJIKtKhhOHh}-{FQdgjZA*hm zPF6%i_NV7k$za<MG4-PFH7b#tYOHP)7>5z`9tvYg$aH;Z1&^AL%8t76_F~HcX)K2) zd1cmR=`1_!5elA)gvvG5UMHEcwB2=6vdU<w>m4m|BT1lx>yYdSgq98UNPCo|q<>^n zvhB<}!6zVHr&%c2i2;CcB3}@&aqFB5h$17(8?kD1(4O6J4J~4beQl^BP6q2vdan)G zcKD~pP^Pf_R@_Mziuf|0>R>Pw>9f)oB`;+M^WVRGW)zJzaGc1q@OeVx9fn3Mo1Bb5 zZcb>_96EAb)UOZSnvt<Tx0LtOs#<2CFSaa4fcrvIdpUV?{sQjKS~KYAJo(JMC$KCE zT5T}Vskm#tYvr}uTsm(XK($hfDy8AYvmC1-#<62=Cb%UaLJ_rcZYSYAC95Do``pi- zfzeXC;`vi?(k*_!&3b9VXyz)>DlE)4E|DXB8A<u>dWYPeGOgCr1PG|8A^a|F^u!=Y z9BB`!RNV>fZvrSyGxWyfpzu`fHS5)yG-ZjRaX0;zrJim)eWH)rZ@UXI<o<P6w^tw7 z+NXGx7UV3-)rufAGwJ%#;*3J~mIiL0lTT96Y!1IUpKxaYx+$l`@fOb!IEQ8)a_0iN zIs1=0&lxy}XC4v&Q<x>Be7-flyI8EDvw2`Rvzgdm0r28VhcD&^fPAWG{<Lp{J}8Z~ z^&K~yIC(*;;?4l8<H29q#;h8oVesIDUU7xXzcT=huu|jA`p?a2$>bokJ>(L!E0L^Q zHnckxF+<XYbQeI*^&aH%UOC};$56Ifz*H9NaPS7gX>H<#+p^Djz`N_@wCF$e)2CLf zQwf;w0_H#{D(&&qJ^K4uWt#~z4eVN2ZeExBcF>@DQfqiGKz$kF--Ysx&r;`PRqi6> zHC$5*gO=y>Bf3Cy8#9Ri^vmWLJ#0wI1oE;bmw%tY72M(Os<?lk0S|<=t=flH9Nl1e z*3Tnc+rA6W-)b8)j)!a-Zd|7=ZM^7+tB^nH0&G^l)3BLf#`{t>DuTZob5OTI8xx(r zl4kbR;Rt;_Lwfs)+AAI0NeAiK2FKvLHia>F5QsE4N~wSHA$HP<t~(s@u%3wa$O4{& zdJ6YV>Z;f`KfkHYAlrs)8#Jrq%IEsMA2|78?f=$|pW7%q_CjFBrvKKubH)w$+DWXp z1!&4=Som+)joJ&QZbmO!b)ZhX4R&%5l4q_TtkNI{w&cGsGpS9?i6UDewb&ft!e4-s z#Au5nk9gU6oALKatRFDV-LgbLgjuiR^JdVfQ`$#ESYN4UPCgR}M82yF!=&zu$8^9V zX1Na5j)Wm-6oqfyTN0c8@db9pvNul82K-?c?<34lc@aN8fTsDDcL8k~2agRud8ZsT z#*G&{cHX+r<N%~-VzN=RO7q^7=G~It^d2!=e+&50kCxi&R+WtvS<hV(c3zZRoOkSv zl(%TFq?8i^2Z{F>X|0^{d;Z-<+n=2%dY8`zczz(Be<~GUmQ^gKe9!di{OS|S2gvB1 z(_nrZ=I+)Usj9%WbIZ0cg=^ZL@hKoe9J;6zf+*t~IP>5b6o7kcgp>2)%Skf#@UrG{ zMhO`h>ZL`Y!z1=X-zBwS3bLKz1w|*}u&_~RT1&JuifG;&%Ah?4(cP)V8U{hVs1|P* z&s4p2K)4;cGVS2jS?<C9nXj3Y1aK{EpQ`p9sC;15%)M;8NKMi{G{8M#IdV$)uLq5E z`QuwHu+!_Ku-0v7)DK8h=MO?sY9y?#pu(Gnz=u7)KC+>_;cGry9gSGBLwMIxI6a^- z<PVLxcD^l34$_c(IcKEV$mnZ}&k)yt4{?cU#}YtsX5I7keu!!zxDn)*0D{uGdFA#5 z&I-S{-U@$?b+d$6+49icc)wiry_>!5>aDY=9p}vnH8_QwKAgnos6*0n(e>Wk`siCj zJlW_I2M$x+kV&?GnMekUEOuurH2S3SbXq`3q6Tef+I*vTv9$v(V+@_m1w{=tIL<ne zyvnyb5%4i9s3<9U?!=IC0py$2y392R5myhx{q2PFNo|dQ;AbC?G2Y!TW}N-X?<qY( zd|A`yPTu}}#=}EqV|_#N38IBo=H?#V64)jEeaO>xeJHtE5_rlOe{oB<a>@sU%0IN} z%9;iR)4=1{Youh0mHB@qaL|)1E0tk^CvetST^g0wAd2I<ci}j%04}Wil{0gJB@CRT z@!h$2E~|MwROgjiy(@(!w=4O|lHz<~4u3qBlpRdiY)M|3v(cM$v2%=p?=0+i-G1ZZ z_^SW%F#Y*P)<p9I#;InoasPmiYre8$|8%q^tDo%TIn-Tr@>ja%t#?#oGpT8wP>=6c z;8Qp0`GQ-EAw)iN0Z3|#-ueh&^6&5FLf-s*V}$JWMAn4M9d^GdD@V1>GkQUn>bmAL zOlHJ-(36$QcH8p&iIxgZ=EG0n#D7?pQc`q_aK8snc96fhXm}xc=~6*a$?YKIoqkSc zw>*5ulmxr#2OF=AFa$SU7iS24kmvan2@wsJ-|=VSP*<X^1$d53+BB_sb-a#Fs$g9K zy6Mji|FmZ!Qm*)9CpttZ+kthHN<dJb@|r9rgw9nR_ftbSeWibx`1uk4jmN5hiqA2L zzZ>dhj1cZQ^c9bVmIGGIHH^{q73-pcxLf!?ZCnX7RP7rdmp;b6Q)A!B5-~!yz9h2b zixH_T3E7wM&oX>Mb`e)3##kz2kE!f?NF*U-mn>r&GgFrQ$Nc-M<NM!x?m55nzR&Y} z?(@F)ocBHF{+@T|g?ypMr{w`&Q7aUNa986Radzh|FNZ?%$2c_t`@_AAF=U@rfW2*g z)dv@wWc;8vV^{Cm2y6VL?vj8`6#kSoNFOfheDzdiUyRnKPzKv2mEyLniW7q4(C9Y! z{9?jLxbH-0LeNAgUC_ifcrxB<)+Vtd$+XvDV>Frt6GG~eDrM7NQRWmZj!ru3oxy{% z<+PV{k47b5zR0ZOeMh>RgoMgV<j@Q(Zgr?aFMZ3RS-17QMZJoDgWEKaoXEnAk}@K; zWzTLb=+u^+`&M~#aMdGkMK#a!3ZR`TK&28tT)RWK+88`D+@DZSO3WIfTM^1}u5Bza z!bpf7HLg~vx7WzHt%0JddYP{ETHSW+Wfi)=W5Xf9@7D5{0#p4BEOL7&u_oION1P}| z6VxU+zTFckN1x0|oY82{=GP<sN3f#oHbcZ?&5_BcrpOKB&pz6Ot8DoVi|UzEu%4tm zbSAP)JS*{4YZ7rK>%G-%aDqjy7Jro{FJi~fOsm|bMSm%>aBzce_e8Cuwc-v=;K5A> zi*k7uwA&7%!Snn?8`96cwqZ3n(s)SK&OpP~vEum+jPw-AF3er@8MW!>(|*l5bDin2 z)Te6-3PKvYHay<UY%x+JOwfc+EuO)I0G;ccy8VTcomNik9di+XgoYA}OtHo8UfyiM z#HF(9q5Q!+SkIh2l#OQus9O^l(%C)St4eBL{K#O|2H$Y?hQs>K?Fu+8B8QkltBzx9 zH_ekD)AphB0z-*2M;Er2mKA9F4kR9jgnihuA>bYzMT4h43CvT#(P<!_0-j6*YX<<E zIRoTUQ3Tj4@3E7(KOhh)R`C2BAcSnUH1ixg#U7d%zQ<D4Vuyp&3{LQS1;8})GGDld zNl2&ok>(*0>CRb}hUNy{E?y)14U@?!7%^;IebCF6go5ce>sb#yqqcU9>x-p(zTh_Z z=2b$r*Il-XXkYqw_b6<7S8$sk@*bpqSen`NuU6L*u13Yky6&G^<aDh_gCPs%HxxB_ z<PgOHpdeWMq3a&5p$M2U<WAjKsGV=`?d-uiVX*-{V>#*AS%>Xu+U>q$J#jrdFlWB^ zja}Vk36(yM&uj)x^%_psJ%9RalM@wh`h|yiVKk6^)X?m73Op~l{Y#AS=`wkbx7yd` z%GNBgs;Z>LQ#}c34-v~4CZtHa@76b3ca2(sp4S-5w+zdYosy!t*4M6k#V+<PIyc}8 zB;=mqMDAO(0AcN*<+Yyoq{<Y;d|S*TCo^~^IKa>y(4xM`)3vY@P}L}z9k>vp>5#Fb zmy*@p)7`i0AjffQk~;>R4DQ%@yk&B%F`T7aUBPBW&%SpwP_^9L0x8^R?Beho&Z00# zGSnLE*bZ-wklFPxdtKi>FI#71V9|XX<s{Ez+p)Z5u{p>@N3wNO949T^uZb|K8&MOx znY;g;^nhW}r}$Qx5dkJ~LpCkR{KB%4xN`l6n>#JW5V5)nYDu0yY}kedT<@keWJ0g5 z(HOswSnZSz3Jg3Shd_#}_y_H>U#Z;|ZN1puM7aK)nDnH?f)MGC@ZdHWl8CfQ&lOcR zl$W_AeFH9o)XsY6n6_M)%*j}f!q;ld6y|@#`0^NKBL@d?`Ddxn`%(tJ3xUz9a%DXD z6S6lNPAc=VOXm8XF{)0tI}rq(Y2EvvZy$T%0?gHr=5l)BF$j|Wt!uGNQln38W#y0v znCcDRcOpi)1Z6%QNGMY7K-OGwFSuSE<CEH-?nH8`5Kk?IRf+M3MLyEh6Oz`J=<Jk4 z2_t#jZS{{|c1=Y>GxYHooHabO6ZL#0`ACW2(;_{FFvCmA7gHhur2U9%1Y1F@UJFZ! zKzCWBuc>1Z8i`(;Ij4QaECTJuVt^txe-}37c-;WwKhn;^=GCvEo{9ZxrKTmJn;1F# zsYzF-?228;9jn?xv5Op+sluDgO)b#XQVUl6AvfP$8hNm;uo5I*EU|j*EUHqbkjOXB z&b#ifB#%;I?$Q=&Xt7Sh#$oQ3Gc8L!%kInz$V^s$=!<lq-AiW=;f@FyHhUCQF=T`o zdkv>v$>p|i$~BY^822yjmQ%~Z4!oINe=oJp*vYJ9S7kk4_C51^aYsJuF{YmJ9H*61 zQvD8oF>M6#H@xzr%(S<dRSe&miKl}_JcTK0240zSs&34CoOj!%5xMlq>AYE`Y)8g( z*%Qy206ob3GY|XK3VhC=L}b~Nz`y}Xp}FKw!{-JBxJvIvn_!;EG^d|w_6}BvT+oxO zi50YUkMw)wI3{Evt_D?-GBa^W;xvqkZSB2}F*g`_&*Hr4<|)UttBQCjJsch<9@1*= z_AbER+08{wua8d%^Vfa1sdlw+-;<p#B7aEh@_t1lxfmTpU~$2C)Q80uy-y=ic=$YY zmdmN+U62KIEbqc%U4?xKZx%;&3YYFE%^<I3WDKF%C&3)rlxF>RXTx+j0v9=yyx+X( zr^(r~zmNH#2F|&*w(XYD6B>)|9p`F(9*Ytk)qHIHsK$kLj+y-T!>q+AF-+b_e7q%4 z-d_)SgzH#GE|>jsz)}nK!(%u_JZEhC$)F|)8+7tu)lj)khHE0LdCO<vhHMOdT+E_N z$xxt2^3r*=g&lsg$VFl1YaeOrR<zFT-lgHCC1uEu*ejGYcWT1e7Ah0FRs%+?D=Z<8 z911q%nl2Akoe{S2LXKTxZmn%Gj!v@Zfw~7EIcR&~`Y$d_WpG$DkKpU1`J)`})h-uK zL7i0Y!h@rwxn@?%sgf#Q(!cdVf2*Ia(o|9@(CES>!t0~|Vp`_o%{!vh9_stuPj=Zs zJzit=>d`EZq#J)eIm$6{$!7kH@_7aYlA=X-WW~UIzNxbUub6(dd6Dt#x`vQHw~(C@ zKa#Jbj*lkz8gI~R2}yl{29?rL`1AFJ$MM-7*r5fCTwm%a5ylk8EQoKoF?HTh)#knc zqcm&O*q0bRL+z*aQfyDC&?PI!ZRs6ZiI9tQsziB954C)*zT5`GCKSCt-_5C4#U0f; z68~vZR>*VWbAo%SYfYChq>&4TXCb#=q$8UIU%)XTp|;#N&!I+j=R^qV^6h`>*;eUl z&oCwh#1cO%_IU|H`#w3&XDc=|UfUazbK-dLD(J1*S3aBR`)h$k!KrgFk07Sd?TB$u zMUJjfJZC&$noT7Bu|;XYldt>{_=UhLbuPi5zCyE1q@kp7>FJ`jxJgtaaPa~az)27J zd6E=Jj{}q_%ceFCI7I<>aKN7w(1ZhwD1c=ZFrfh3)gLWo|A6oR0OPeEU61|&%WHrs z#Y=M?P@#a^>wperJ^po=6xg~BC|Vt8=*jZ@pBKYV#7ahmalr4&eM$<H4E`tb|5<)b z7WE#8{C{12aiH-AASHA_&yu5<jU{*SQ$Zlyzf8!8;Q^So0f<qoepPB6<{~}-g*O3? zgW4@Fis|9nf?u3>G7n6pC@C9l0x%%&G3Y{Wptx1CDL?=J?=hAGR%`-d6gMF}0Hf~6 z1wi3v0JrSnj8A8_TiTHGPz4|mzF%?4s2l}`;Q<*6N67)lIWz#GFaQ@gg$EcZ&1>Xl z04M+%w*bl^VxS_qSb-W*0Du*x0N1}_9V%`3En0s8n7s8P&DsNwJ5K?yzY^dCaa#Z* zCD}ug>))L1pMggSfF#9gtL^KICAmW5GRNVm+35vs34j>g!355>Kwp7PTL3o@H3a4p z0AY$RQPMNUhRkb6ez<<)hd?}rK@}oEIpPewLL}$BHw*?6e}tS@LbSV(N6_$JBe*sK tHWC3D;e(LBwvC6shLlkNG@b)s+!rq#A@3_85K;1-0);@Z(_}`-e*tykY|8)u From 0e450b2acf3413c76c70e7aaa97360cd642089a2 Mon Sep 17 00:00:00 2001 From: Daniel Seichter <daniel.seichter@erpware.de> Date: Tue, 12 Nov 2019 16:17:23 +0100 Subject: [PATCH 196/299] remove duplicate entries --- build/.gitignore | 1 - htdocs/.gitignore | 3 --- 2 files changed, 4 deletions(-) diff --git a/build/.gitignore b/build/.gitignore index be85c819547..54c5d8be9c3 100644 --- a/build/.gitignore +++ b/build/.gitignore @@ -5,6 +5,5 @@ /dolibarr-*.tgz /dolibarr-*.rpm /dolibarr-*.zip -/dolibarr-*.tgz /*.exe /html diff --git a/htdocs/.gitignore b/htdocs/.gitignore index d51eaffd235..ef87c0455d6 100644 --- a/htdocs/.gitignore +++ b/htdocs/.gitignore @@ -16,9 +16,6 @@ /teclib* /test.php /ultimatepdf* -/lead -/dolimed* -/allscreens* /ecommerce/ /cabinetmed* /webmail* From c07f1f824688e059ea3e34e8c1abfb426817d2bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 16:26:42 +0100 Subject: [PATCH 197/299] Try exakat --- build/exakat/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 build/exakat/README.md diff --git a/build/exakat/README.md b/build/exakat/README.md new file mode 100644 index 00000000000..da04e781765 --- /dev/null +++ b/build/exakat/README.md @@ -0,0 +1,13 @@ + +mkdir exakat +cd exakat +curl -o exakat.phar http://dist.exakat.io/index.php?file=latest +curl -o apache-tinkerpop-gremlin-server-3.3.5-bin.zip http://dist.exakat.io/apache-tinkerpop-gremlin-server-3.3.5-bin.zip +unzip apache-tinkerpop-gremlin-server-3.3.5-bin.zip +mv apache-tinkerpop-gremlin-server-3.3.5 tinkergraph +rm -rf apache-tinkerpop-gremlin-server-3.3.5-bin.zip +cd tinkergraph ./bin/gremlin-server.sh -i org.apache.tinkerpop neo4j-gremlin 3.3.5 +cd .. + +php exakat.phar version +php exakat.phar doctor From e79ac7081a8493bd30beb0422ef085698aafef8f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 17:37:05 +0100 Subject: [PATCH 198/299] Look and feel v11 --- build/exakat/README.md | 16 ++++++++++++++++ htdocs/compta/prelevement/card.php | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/build/exakat/README.md b/build/exakat/README.md index da04e781765..3b9052e5281 100644 --- a/build/exakat/README.md +++ b/build/exakat/README.md @@ -1,4 +1,5 @@ +== Install exakat == mkdir exakat cd exakat curl -o exakat.phar http://dist.exakat.io/index.php?file=latest @@ -11,3 +12,18 @@ cd .. php exakat.phar version php exakat.phar doctor + +== Init project == +php + + +Edit config.ini file to exclude some dirs: +ignore_dirs[] = "/htdocs/includes"; +ignore_dirs[] = "/scripts"; +ignore_dirs[] = "/build"; +ignore_dirs[] = "/dev"; +ignore_dirs[] = "/documents"; + + +== Analyze project == +php diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index fb41142d970..72508c804a5 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -177,7 +177,7 @@ if ($id > 0 || $ref) print '<div class="fichecenter">'; print '<div class="underbanner clearboth"></div>'; - print '<table class="border centpercent">'; + print '<table class="border centpercent tableforfield">'; //print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>'; @@ -214,7 +214,7 @@ if ($id > 0 || $ref) print '<br>'; print '<div class="underbanner clearboth"></div>'; - print '<table class="border centpercent">'; + print '<table class="border centpercent tableforfield">'; $acc = new Account($db); $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); From 2a67dd0f6682647832b75d53ea3b4f8378927d92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 17:43:27 +0100 Subject: [PATCH 199/299] Look and feel v11 --- htdocs/compta/prelevement/factures.php | 4 ++-- htdocs/compta/prelevement/fiche-rejet.php | 4 ++-- htdocs/compta/prelevement/fiche-stat.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 01acea0479a..a9fd4f1fbbc 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -79,7 +79,7 @@ if ($prev_id > 0 || $ref) print '<div class="fichecenter">'; print '<div class="underbanner clearboth"></div>'; - print '<table class="border centpercent">'; + print '<table class="border centpercent tableforfield">'; //print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>'; @@ -111,7 +111,7 @@ if ($prev_id > 0 || $ref) print '<br>'; print '<div class="underbanner clearboth"></div>'; - print '<table class="border centpercent">'; + print '<table class="border centpercent tableforfield">'; $acc = new Account($db); $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index ebb7ab7fbb2..d44ffdea4a8 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -75,7 +75,7 @@ if ($prev_id > 0 || $ref) print '<div class="fichecenter">'; print '<div class="underbanner clearboth"></div>'; - print '<table class="border centpercent">'."\n"; + print '<table class="border centpercent tableforfield">'."\n"; //print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>'; @@ -112,7 +112,7 @@ if ($prev_id > 0 || $ref) print '<br>'; print '<div class="underbanner clearboth"></div>'; - print '<table class="border centpercent">'; + print '<table class="border centpercent tableforfield">'; $acc = new Account($db); $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index fa7b1758435..70441ff19c2 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -72,7 +72,7 @@ if ($prev_id > 0 || $ref) print '<div class="fichecenter">'; print '<div class="underbanner clearboth"></div>'; - print '<table class="border centpercent">'."\n"; + print '<table class="border centpercent tableforfield">'."\n"; //print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>'; @@ -109,7 +109,7 @@ if ($prev_id > 0 || $ref) print '<br>'; print '<div class="underbanner clearboth"></div>'; - print '<table class="border centpercent">'; + print '<table class="border centpercent tableforfield">'; $acc = new Account($db); $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); From 453ffad9e882415e2c070b7364abeb866edf07ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 18:01:16 +0100 Subject: [PATCH 200/299] Look and feel v11 --- .../class/bonprelevement.class.php | 58 ++++++------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index f1c3f70c53a..1e2050c5a47 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -74,6 +74,10 @@ class BonPrelevement extends CommonObject public $invoice_in_error=array(); public $thirdparty_in_error=array(); + const STATUS_DRAFT = 0; + const STATUS_TRANSFERED = 1; + const STATUS_CREDITED = 2; + /** * Constructor @@ -2001,49 +2005,23 @@ class BonPrelevement extends CommonObject */ public function LibStatut($status, $mode = 0) { - // phpcs:enable - if (empty($this->labelStatus)) + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; - $langs->load("withdrawals"); - $this->labelStatus[0]=$langs->trans("StatusWaiting"); - $this->labelStatus[1]=$langs->trans("StatusTrans"); - $this->labelStatus[2]=$langs->trans("StatusCredited"); + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('StatusWaiting'); + $this->labelStatus[self::STATUS_TRANSFERED] = $langs->trans('StatusTrans'); + $this->labelStatus[self::STATUS_CREDITED] = $langs->trans('StatusCredited'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('StatusWaiting'); + $this->labelStatusShort[self::STATUS_TRANSFERED] = $langs->trans('StatusTrans'); + $this->labelStatusShort[self::STATUS_CREDITED] = $langs->trans('StatusCredited'); } - if ($mode == 0 || $mode == 1) - { - return $this->labelStatus[$status]; - } - elseif ($mode == 2) - { - if ($status==0) return img_picto($this->labelStatus[$status], 'statut1').' '.$this->labelStatus[$status]; - elseif ($status==1) return img_picto($this->labelStatus[$status], 'statut3').' '.$this->labelStatus[$status]; - elseif ($status==2) return img_picto($this->labelStatus[$status], 'statut6').' '.$this->labelStatus[$status]; - } - elseif ($mode == 3) - { - if ($status==0) return img_picto($this->labelStatus[$status], 'statut1'); - elseif ($status==1) return img_picto($this->labelStatus[$status], 'statut3'); - elseif ($status==2) return img_picto($this->labelStatus[$status], 'statut6'); - } - elseif ($mode == 4) - { - if ($status==0) return img_picto($this->labelStatus[$status], 'statut1').' '.$this->labelStatus[$status]; - elseif ($status==1) return img_picto($this->labelStatus[$status], 'statut3').' '.$this->labelStatus[$status]; - elseif ($status==2) return img_picto($this->labelStatus[$status], 'statut6').' '.$this->labelStatus[$status]; - } - elseif ($mode == 5) - { - if ($status==0) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut1'); - elseif ($status==1) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut3'); - elseif ($status==2) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut6'); - } - elseif ($mode == 6) - { - if ($status==0) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut1'); - elseif ($status==1) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut3'); - elseif ($status==2) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut6'); - } + $statusType = 'status1'; + if ($status == self::STATUS_TRANSFERED) $statusType = 'status3'; + if ($status == self::STATUS_CREDITED) $statusType = 'status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } } From 480ac1a926286c29c4518f8a23502b150a077353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Tue, 12 Nov 2019 18:08:09 +0100 Subject: [PATCH 201/299] API New link/unlink products with categories Need it for V11 please :) --- .../categories/class/api_categories.class.php | 240 ++++++++++++++++++ 1 file changed, 240 insertions(+) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index d289874d1ee..f7a2addef3d 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -264,6 +264,246 @@ class Categories extends DolibarrApi ) ); } + + /** + * Link an object to a category by id + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param int $object_id ID of object + * + * @return array + * @throws RestException + * + * @url POST {id}/objects/{type}/{object_id} + */ + public function link_object_by_id($id, $type, $object_id) + { + if (empty($type) || empty($object_id)) { + 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'); + } + + # TODO Add all types + if ($type === "product") { + if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } + + if (!empty($object)) { + $result = $object->fetch($object_id); + if ($result > 0) { + $result=$this->category->add_type($object, $type); + if ($result < 0) { + if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { + throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); + } + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully linked to the category' + ) + ); + } + + throw new RestException(401); + } + + /** + * Link an object to a category by ref + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $object_ref Reference of object + * + * @return array + * @throws RestException + * + * @url POST {id}/objects/{type}/ref/{object_ref} + */ + public function link_object_by_ref($id, $type, $object_ref) + { + if (empty($type) || empty($object_ref)) { + 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'); + } + + # TODO Add all types + if ($type === "product") { + if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } + + if (!empty($object)) { + $result = $object->fetch('', $object_ref); + if ($result > 0) { + $result=$this->category->add_type($object, $type); + if ($result < 0) { + if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { + throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); + } + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully linked to the category' + ) + ); + } + + throw new RestException(401); + } + + /** + * Unlink an object from a category by id + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param int $object_id ID of the object + * + * @return array + * @throws RestException + * + * @url DELETE {id}/objects/{type}/{object_id} + */ + public function unlink_object_by_id($id, $type, $object_id) + { + if (empty($type) || empty($object_id)) { + 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'); + } + + # TODO Add all types + if ($type === "product") { + if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } + + if (!empty($object)) { + $result = $object->fetch((int) $object_id); + if ($result > 0) { + $result=$this->category->del_type($object, $type); + if ($result < 0) { + throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully unlinked from the category' + ) + ); + } + + throw new RestException(401); + } + + /** + * Unlink an object from a category by ref + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $object_ref Reference of the object + * + * @return array + * @throws RestException + * + * @url DELETE {id}/objects/{type}/ref/{object_ref} + */ + public function unlink_object_by_ref($id, $type, $object_ref) + { + if (empty($type) || empty($object_ref)) { + 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'); + } + + # TODO Add all types + if ($type === "product") { + if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + throw new RestException(401); + } + $object = new Product($this->db); + } else { + throw new RestException(401, "this type is not recognized yet."); + } + + if (!empty($object)) { + $result = $object->fetch('', (string) $object_ref); + if ($result > 0) { + $result=$this->category->del_type($object, $type); + if ($result < 0) { + throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); + } + } else { + throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Objects succefully unlinked from the category' + ) + ); + } + + throw new RestException(401); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore From fcb50841ccf35a298fb9c145f4be21445381e4e0 Mon Sep 17 00:00:00 2001 From: stickler-ci <support@stickler-ci.com> Date: Tue, 12 Nov 2019 17:10:20 +0000 Subject: [PATCH 202/299] Fixing style errors. --- .../categories/class/api_categories.class.php | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index f7a2addef3d..36b3e10174a 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -264,17 +264,17 @@ class Categories extends DolibarrApi ) ); } - + /** * Link an object to a category by id * * @param int $id ID of category * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') * @param int $object_id ID of object - * + * * @return array * @throws RestException - * + * * @url POST {id}/objects/{type}/{object_id} */ public function link_object_by_id($id, $type, $object_id) @@ -282,17 +282,17 @@ class Categories extends DolibarrApi if (empty($type) || empty($object_id)) { 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'); } - - # TODO Add all types + + // TODO Add all types if ($type === "product") { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -301,7 +301,7 @@ class Categories extends DolibarrApi } else { throw new RestException(401, "this type is not recognized yet."); } - + if (!empty($object)) { $result = $object->fetch($object_id); if ($result > 0) { @@ -314,7 +314,7 @@ class Categories extends DolibarrApi } else { throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); } - + return array( 'success' => array( 'code' => 200, @@ -322,10 +322,10 @@ class Categories extends DolibarrApi ) ); } - + throw new RestException(401); } - + /** * Link an object to a category by ref * @@ -343,17 +343,17 @@ class Categories extends DolibarrApi if (empty($type) || empty($object_ref)) { 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'); } - - # TODO Add all types + + // TODO Add all types if ($type === "product") { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -362,7 +362,7 @@ class Categories extends DolibarrApi } else { throw new RestException(401, "this type is not recognized yet."); } - + if (!empty($object)) { $result = $object->fetch('', $object_ref); if ($result > 0) { @@ -375,7 +375,7 @@ class Categories extends DolibarrApi } else { throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); } - + return array( 'success' => array( 'code' => 200, @@ -383,10 +383,10 @@ class Categories extends DolibarrApi ) ); } - + throw new RestException(401); } - + /** * Unlink an object from a category by id * @@ -404,17 +404,17 @@ class Categories extends DolibarrApi if (empty($type) || empty($object_id)) { 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'); } - - # TODO Add all types + + // TODO Add all types if ($type === "product") { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -423,7 +423,7 @@ class Categories extends DolibarrApi } else { throw new RestException(401, "this type is not recognized yet."); } - + if (!empty($object)) { $result = $object->fetch((int) $object_id); if ($result > 0) { @@ -434,7 +434,7 @@ class Categories extends DolibarrApi } else { throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); } - + return array( 'success' => array( 'code' => 200, @@ -442,10 +442,10 @@ class Categories extends DolibarrApi ) ); } - + throw new RestException(401); } - + /** * Unlink an object from a category by ref * @@ -463,17 +463,17 @@ class Categories extends DolibarrApi if (empty($type) || empty($object_ref)) { 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'); } - - # TODO Add all types + + // TODO Add all types if ($type === "product") { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -482,7 +482,7 @@ class Categories extends DolibarrApi } else { throw new RestException(401, "this type is not recognized yet."); } - + if (!empty($object)) { $result = $object->fetch('', (string) $object_ref); if ($result > 0) { @@ -493,7 +493,7 @@ class Categories extends DolibarrApi } else { throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors)); } - + return array( 'success' => array( 'code' => 200, @@ -501,7 +501,7 @@ class Categories extends DolibarrApi ) ); } - + throw new RestException(401); } From e33d969178ed5885548c7e590dafc3af4aad6654 Mon Sep 17 00:00:00 2001 From: ptibogxiv <support@ptibogxiv.net> Date: Tue, 12 Nov 2019 18:38:23 +0100 Subject: [PATCH 203/299] Fix php error on stripe account display convert non object in full array in order to avoid php error message. --- htdocs/societe/paymentmodes.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 5636f09b3a4..11a5955a3ff 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1317,11 +1317,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); if (! in_array($cpt->currency, $arrayzerounitcurrency)) { - $currencybalance[$cpt->currency]->available=$cpt->amount / 100; + $currencybalance[$cpt->currency]['available']=$cpt->amount / 100; } else { - $currencybalance[$cpt->currency]->available=$cpt->amount; + $currencybalance[$cpt->currency]['available']=$cpt->amount; } - $currencybalance[$cpt->currency]->currency=$cpt->currency; + $currencybalance[$cpt->currency]['currency']=$cpt->currency; } } @@ -1331,9 +1331,9 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); if (! in_array($cpt->currency, $arrayzerounitcurrency)) { - $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount / 100; + $currencybalance[$cpt->currency]['pending']=$currencybalance[$cpt->currency]['available']+$cpt->amount / 100; } else { - $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount; + $currencybalance[$cpt->currency]['pending']=$currencybalance[$cpt->currency]['available']+$cpt->amount; } } } @@ -1342,7 +1342,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($currencybalance as $cpt) { - print '<tr><td>'.$langs->trans("Currency".strtoupper($cpt->currency)).'</td><td>'.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'</td><td>'.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'</td><td>'.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'</td></tr>'; + print '<tr><td>'.$langs->trans("Currency".strtoupper($cpt['pending'])).'</td><td>'.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td><td>'.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td><td>'.price($cpt['available']+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td></tr>'; } } From 24bac213aaa7d0f141ef32036d939b610c7ad879 Mon Sep 17 00:00:00 2001 From: ptibogxiv <support@ptibogxiv.net> Date: Tue, 12 Nov 2019 18:39:39 +0100 Subject: [PATCH 204/299] Update paymentmodes.php --- htdocs/societe/paymentmodes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 11a5955a3ff..e44feb047ab 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1342,7 +1342,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($currencybalance as $cpt) { - print '<tr><td>'.$langs->trans("Currency".strtoupper($cpt['pending'])).'</td><td>'.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td><td>'.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td><td>'.price($cpt['available']+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td></tr>'; + print '<tr><td>'.$langs->trans("Currency".strtoupper($cpt['currency'])).'</td><td>'.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td><td>'.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td><td>'.price($cpt['available']+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td></tr>'; } } From 422d893eccac641b482188741ce90c050f5dd44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Tue, 12 Nov 2019 21:33:42 +0100 Subject: [PATCH 205/299] Update llx_c_action_trigger.sql --- htdocs/install/mysql/data/llx_c_action_trigger.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index b7cad86d6bb..85360478500 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -125,7 +125,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_REOPEN','BOM reopen','Executed when a BOM is re-open','bom',653); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',654); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO disabled','Executed when a MO is produced','bom',661); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663); -- actions not enabled by default : they are excluded when we enable the module Agenda (except TASK_...) From 4f90fe0fd23e02387882d04964ba549df2dc3e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Tue, 12 Nov 2019 21:34:45 +0100 Subject: [PATCH 206/299] Update 10.0.0-11.0.0.sql --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 9c52044291d..6a31fa3e745 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -493,7 +493,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',654); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO disabled','Executed when a MO is produced','bom',661); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663); From 7ce297c6cc54b463b210ddc285555552a41cf083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Tue, 12 Nov 2019 21:53:17 +0100 Subject: [PATCH 207/299] doxygen --- htdocs/core/lib/ticket.lib.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 41e783b7597..609dbd9926d 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -1,6 +1,7 @@ <?php /* Copyright (C) 2013-2018 Jean-François FERRY <hello@librethic.io> * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr> + * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr> * * 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 @@ -180,10 +181,10 @@ function showDirectPublicLink($object) } /** - * Generate a random id + * Generate a random id * - * @param string $car Char to generate key - * @return void + * @param int $car Length of string to generate key + * @return string */ function generate_random_id($car = 16) { From 89bf35a8bf736dd1d61b0085ecd6d5dac8b2d496 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 21:54:41 +0100 Subject: [PATCH 208/299] Fix default value show must match the theme selected --- htdocs/core/lib/usergroups.lib.php | 46 +++++++++++++++++++----------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 5e842612b24..eeaa4d4d6ce 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -420,6 +420,10 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print '</td></tr>'; + if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php')) { + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + } + // Show logo if ($foruserprofile) { @@ -563,8 +567,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default='5a6482'; - if ($conf->theme == 'md') $default='5a3278'; + $default=(empty($colorbackhmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackhmenu1))); print '<tr class="oddeven">'; print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>'; @@ -612,8 +615,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default='f0f0f0'; - if ($conf->theme == 'md') $default='ffffff'; + $default=(empty($colorbackvmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackvmenu1))); print '<tr class="oddeven">'; print '<td>'.$langs->trans("LeftMenuBackgroundColor").'</td>'; @@ -641,6 +643,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { + $default=(empty($colortexttitlenotab) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitlenotab))); + print '<tr class="oddeven">'; print '<td>'.$langs->trans("TextTitleColor").'</td>'; print '<td colspan="'.($colspan-1).'">'; @@ -652,7 +656,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLENOTAB, $langs->trans("Default")); } - print '   <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #643c14">643c14</span></strong>) '; + print '   <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #'.$default.'">'.$default.'</span></strong>) '; print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print '</span>'; print '</td>'; @@ -666,6 +670,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { + $default=(empty($colorbacktitle1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacktitle1))); + print '<tr class="oddeven">'; print '<td>'.$langs->trans("BackgroundTableTitleColor").'</td>'; print '<td colspan="'.($colspan-1).'">'; @@ -677,7 +683,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) { print $formother->showColor($conf->global->THEME_ELDY_BACKTITLE1, $langs->trans("Default")); } - print '   <span class="nowraponall">('.$langs->trans("Default").': <strong>f0f0f0</strong>) '; // $colorbacktitle1 in CSS + print '   <span class="nowraponall">('.$langs->trans("Default").': <strong>'.$default.'</strong>) '; // $colorbacktitle1 in CSS print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print '</span>'; print '</td>'; @@ -691,6 +697,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { + $default=(empty($colortexttitle) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitle))); + print '<tr class="oddeven">'; print '<td>'.$langs->trans("BackgroundTableTitleTextColor").'</td>'; print '<td colspan="'.($colspan-1).'">'; @@ -702,7 +710,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLE, $langs->trans("Default")); } - print '   <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #000000">000000</span></strong>) '; + print '   <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #'.$default.'">'.$default.'</span></strong>) '; print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print '</span>'; print '</td>'; @@ -716,8 +724,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default='ffffff'; - if ($conf->theme == 'md') $default='ffffff'; + $default=(empty($colorbacklineimpair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklineimpair1))); print '<tr class="oddeven">'; print '<td>'.$langs->trans("BackgroundTableLineOddColor").'</td>'; @@ -745,8 +752,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default='f8f8f8'; - if ($conf->theme == 'md') $default='f8f8f8'; + $default=(empty($colorbacklinepair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepair1))); print '<tr class="oddeven">'; print '<td>'.$langs->trans("BackgroundTableLineEvenColor").'</td>'; @@ -794,6 +800,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { + $default=(empty($colortextlink) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortextlink))); + print '<tr class="oddeven">'; print '<td>'.$langs->trans("LinkColor").'</td>'; print '<td colspan="'.($colspan-1).'">'; @@ -812,7 +820,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print $langs->trans("Default"); } } - print '   <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #000078">000078</span></strong>) '; + print '   <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #'.$default.'">'.$default.'</span></strong>) '; print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print '</span>'; print '</td>'; @@ -834,6 +842,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) */ } else { + $default=(empty($colorbacklinepairhover) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairhover))); + print '<tr class="oddeven">'; print '<td>'.$langs->trans("HighlightLinesColor").'</td>'; print '<td colspan="'.($colspan-1).'">'; @@ -841,22 +851,22 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) //print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; if ($edit) { - if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='e6edf0'; + if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color=colorArrayToHex(colorStringToArray($colorbacklinepairhover)); else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), ''); print $formother->selectColor($color, 'THEME_ELDY_USE_HOVER', 'formcolor', 1).' '; } else { - if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='e6edf0'; + if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color=colorArrayToHex(colorStringToArray($colorbacklinepairhover)); else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), ''); if ($color) { - if ($color != 'e6edf0') print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">'; + if ($color != colorArrayToHex(colorStringToArray($colorbacklinepairhover))) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">'; else print $langs->trans("Default"); } else print $langs->trans("Default"); } - print '   <span class="nowraponall">('.$langs->trans("Default").': <strong>e6edf0</strong>) '; + print '   <span class="nowraponall">('.$langs->trans("Default").': <strong>'.$default.'</strong>) '; print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print '</span>'; print '</td>'; @@ -878,6 +888,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { + $default=(empty($colorbacklinepairchecked) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairchecked))); + print '<tr class="oddeven">'; print '<td>'.$langs->trans("HighlightLinesChecked").'</td>'; print '<td colspan="'.($colspan-1).'">'; @@ -900,7 +912,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else print $langs->trans("Default"); } - print '   <span class="nowraponall">('.$langs->trans("Default").': <strong>e6edf0</strong>) '; + print '   <span class="nowraponall">('.$langs->trans("Default").': <strong>'.$default.'</strong>) '; print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print '</span>'; print '</td>'; From 9efcdc78f90d2892a3869da7b98197e9676a4270 Mon Sep 17 00:00:00 2001 From: Francis Appels <francis.appels@yahoo.com> Date: Tue, 12 Nov 2019 21:56:05 +0100 Subject: [PATCH 209/299] Cleanup interface_90_modSociete_ContactRoles --- .../interface_90_modSociete_ContactRoles.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index b806e70c71d..b50008dba2e 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -21,9 +21,9 @@ */ /** - * \file htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php + * \file htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php * \ingroup agenda - * \brief Trigger file for agenda module + * \brief Trigger file for company - contactroles */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; class InterfaceContactRoles extends DolibarrTriggers { public $family = 'agenda'; - public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup."; + public $description = "Triggers of this module auto link contact to company."; /** * Version of the trigger @@ -73,7 +73,6 @@ class InterfaceContactRoles extends DolibarrTriggers $socid=(property_exists($object, 'socid')?$object->socid:$object->fk_soc); if (! empty($socid) && $socid > 0) { - global $db, $langs; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contactdefault = new Contact($this->db); $contactdefault->socid=$socid; @@ -83,7 +82,7 @@ class InterfaceContactRoles extends DolibarrTriggers if ($object->id > 0) { $class = get_class($object); - $cloneFrom = new $class($db); + $cloneFrom = new $class($this->db); $r = $cloneFrom->fetch($object->id); if (!empty($cloneFrom->id)) $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal')); From e7d51d4ec753451c600d5bbb50cf1a613f3f3674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Tue, 12 Nov 2019 22:01:53 +0100 Subject: [PATCH 210/299] do not trim int --- htdocs/ticket/class/ticket.class.php | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 5784fc22a3e..2b673ad8899 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1,6 +1,7 @@ <?php /* Copyright (C) 2013-2018 Jean-François Ferry <hello@librethic.io> * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr> + * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr> * * 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 @@ -250,11 +251,11 @@ class Ticket extends CommonObject } if (isset($this->fk_soc)) { - $this->fk_soc = trim($this->fk_soc); + $this->fk_soc = (int) $this->fk_soc; } if (isset($this->fk_project)) { - $this->fk_project = trim($this->fk_project); + $this->fk_project = (int) $this->fk_project; } if (isset($this->origin_email)) { @@ -262,11 +263,11 @@ class Ticket extends CommonObject } if (isset($this->fk_user_create)) { - $this->fk_user_create = trim($this->fk_user_create); + $this->fk_user_create = (int) $this->fk_user_create; } if (isset($this->fk_user_assign)) { - $this->fk_user_assign = trim($this->fk_user_assign); + $this->fk_user_assign = (int) $this->fk_user_assign; } if (isset($this->subject)) { @@ -278,7 +279,7 @@ class Ticket extends CommonObject } if (isset($this->fk_statut)) { - $this->fk_statut = trim($this->fk_statut); + $this->fk_statut = (int) $this->fk_statut; } if (isset($this->resolution)) { @@ -746,11 +747,11 @@ class Ticket extends CommonObject } if (isset($this->fk_soc)) { - $this->fk_soc = trim($this->fk_soc); + $this->fk_soc = (int) $this->fk_soc; } if (isset($this->fk_project)) { - $this->fk_project = trim($this->fk_project); + $this->fk_project = (int) $this->fk_project; } if (isset($this->origin_email)) { @@ -758,11 +759,11 @@ class Ticket extends CommonObject } if (isset($this->fk_user_create)) { - $this->fk_user_create = trim($this->fk_user_create); + $this->fk_user_create = (int) $this->fk_user_create; } if (isset($this->fk_user_assign)) { - $this->fk_user_assign = trim($this->fk_user_assign); + $this->fk_user_assign = (int) $this->fk_user_assign; } if (isset($this->subject)) { @@ -774,7 +775,7 @@ class Ticket extends CommonObject } if (isset($this->fk_statut)) { - $this->fk_statut = trim($this->fk_statut); + $this->fk_statut = (int) $this->fk_statut; } if (isset($this->resolution)) { @@ -1002,12 +1003,12 @@ class Ticket extends CommonObject $this->ref = 'TI0501-001'; $this->track_id = 'XXXXaaaa'; $this->origin_email = 'email@email.com'; - $this->fk_project = '1'; - $this->fk_user_create = '1'; - $this->fk_user_assign = '1'; + $this->fk_project = 1; + $this->fk_user_create = 1; + $this->fk_user_assign = 1; $this->subject = 'Subject of ticket'; $this->message = 'Message of ticket'; - $this->fk_statut = '0'; + $this->fk_statut = 0; $this->resolution = '1'; $this->progress = '10'; $this->timing = '30'; From bb4fd0d5c02518f7464edc2ad34e25f4df213739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Tue, 12 Nov 2019 22:06:22 +0100 Subject: [PATCH 211/299] timing is varchar in db --- htdocs/ticket/class/ticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 2b673ad8899..1d6b1d591c4 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -121,7 +121,7 @@ class Ticket extends CommonObject public $progress; /** - * @var int Duration for ticket + * @var string Duration for ticket */ public $timing; From 56c2dc26148f1f7809c691361009b57bf7a26ce3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 12 Nov 2019 22:29:36 +0100 Subject: [PATCH 212/299] Reduce need of translations --- htdocs/core/class/html.formwebsite.class.php | 7 ++++--- htdocs/install/upgrade2.php | 8 ++++---- htdocs/langs/en_US/install.lang | 5 +---- htdocs/website/index.php | 5 +++-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 6bb4e1d25f5..7aab9bd6774 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -228,9 +228,10 @@ class FormWebsite * @param int $pageid Preselected container ID * @param int $showempty Show empty record * @param string $action Action on page that use this select list + * @param string $morecss More CSS * @return string HTML select component with list of type of containers */ - public function selectContainer($website, $htmlname = 'pageid', $pageid = 0, $showempty = 0, $action = '') + public function selectContainer($website, $htmlname = 'pageid', $pageid = 0, $showempty = 0, $action = '', $morecss = 'minwidth200') { global $langs; @@ -239,11 +240,11 @@ class FormWebsite $out=''; if ($atleastonepage && $action != 'editsource') { - $out.='<select name="'.$htmlname.'" id="'.$htmlname.'" class="minwidth200 maxwidth300">'; + $out.='<select name="'.$htmlname.'" id="'.$htmlname.'" class="maxwidth300'.($morecss ? ' '.$morecss : '').'">'; } else { - $out.='<select name="pageidbis" id="pageid" class="minwidth200 maxwidth300" disabled="disabled">'; + $out.='<select name="pageidbis" id="pageid" class="maxwidth300'.($morecss ? ' '.$morecss : '').'" disabled="disabled">'; } if ($showempty || ! $atleastonepage) $out.='<option value="-1"> </option>'; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index cdae711873b..0efb8dfde59 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -5030,7 +5030,7 @@ function migrate_users_socialnetworks() dol_print_error($db); $db->rollback(); } - print '<b>'.$langs->trans('MigrationUsersSocialNetworks')."</b><br>\n"; + print '<b>'.$langs->trans('MigrationFieldsSocialNetworks', 'Users')."</b><br>\n"; print '</td></tr>'; } @@ -5121,7 +5121,7 @@ function migrate_members_socialnetworks() dol_print_error($db); $db->rollback(); } - print '<b>'.$langs->trans('MigrationMembersSocialNetworks')."</b><br>\n"; + print '<b>'.$langs->trans('MigrationFieldsSocialNetworks', 'Members')."</b><br>\n"; print '</td></tr>'; } @@ -5216,7 +5216,7 @@ function migrate_contacts_socialnetworks() dol_print_error($db); $db->rollback(); } - print '<b>'.$langs->trans('MigrationContactsSocialNetworks')."</b><br>\n"; + print '<b>'.$langs->trans('MigrationFieldsSocialNetworks', 'Contacts')."</b><br>\n"; print '</td></tr>'; } @@ -5306,6 +5306,6 @@ function migrate_thirdparties_socialnetworks() dol_print_error($db); $db->rollback(); } - print '<b>'.$langs->trans('MigrationThirdpartiesSocialNetworks')."</b><br>\n"; + print '<b>'.$langs->trans('MigrationFieldsSocialNetworks', 'Thirdparties')."</b><br>\n"; print '</td></tr>'; } diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index cfd95d879b7..708b3bac479 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -205,10 +205,7 @@ MigrationRemiseExceptEntity=Update entity field value of llx_societe_remise_exce MigrationUserRightsEntity=Update entity field value of llx_user_rights MigrationUserGroupRightsEntity=Update entity field value of llx_usergroup_rights MigrationUserPhotoPath=Migration of photo paths for users -MigrationUsersSocialNetworks=Migration of users fields social networks -MigrationMembersSocialNetworks=Migration of members fields social networks -MigrationContactsSocialNetworks=Migration of contacts fields social networks -MigrationThirdpartiesSocialNetworks=Migration of thirdparties fields social networks +MigrationFieldsSocialNetworks=Migration of users fields social networks (%s) MigrationReloadModule=Reload module %s MigrationResetBlockedLog=Reset module BlockedLog for v7 algorithm ShowNotAvailableOptions=Show unavailable options diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 26199b90d0b..d35ca0130cb 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3059,9 +3059,10 @@ if ($action == 'editmeta' || $action == 'createcontainer') } elseif ($result > 0) { - $translationof = $sourcepage->id; + $translationof = 0; + //$translationof = $sourcepage->id; print '<span class="opacitymedium">'.$langs->trans('ThisPageIsTranslationOf').'</span> '; - print $formwebsite->selectContainer($website, 'pageidfortranslation', $sourcepage->id, 1, $action); + print $formwebsite->selectContainer($website, 'pageidfortranslation', $translationof, 1, $action, 'minwidth300'); } } print '</td></tr>'; From 4340f85e3c50aadeb62473ff2233842907fcf5e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Wed, 13 Nov 2019 01:22:13 +0100 Subject: [PATCH 213/299] Add warning --- htdocs/compta/paiement/cheque/card.php | 18 ++++++++++-------- htdocs/langs/en_US/errors.lang | 3 ++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 72de78e5d9f..9388fbcdd1f 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -678,19 +678,12 @@ else print_liste_field_titre("LineRecord", $_SERVER["PHP_SELF"], "b.rowid", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre(''); print "</tr>\n"; - $i = 1; + $i = 1; if ($num > 0) { while ($objp = $db->fetch_object($resql)) { - //$account_id = $objp->bid; FIXME not used - - // FIXME $accounts[$objp->bid] is a label - /*if (! isset($accounts[$objp->bid])) - $accounts[$objp->bid]=0; - $accounts[$objp->bid] += 1;*/ - print '<tr class="oddeven">'; print '<td align="center">'.$i.'</td>'; print '<td align="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>'; // Date operation @@ -751,6 +744,15 @@ else } print "</table>"; + + // Cheque denormalized data nbcheque is similar to real number of cheque + if ($num > 0 && $i < ($object->nbcheque + 1)) { + // Show warning that some records were removed. + $langs->load("errors"); + print info_admin($langs->trans("WarningSomeBankTransactionByChequeWereRemovedAfter"), 0, 0, 'warning'); + // TODO Fix data ->nbcheque and ->amount + } + print "</div>"; } else diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 2b23fc6d19e..53f9e57fceb 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -247,4 +247,5 @@ WarningYourLoginWasModifiedPleaseLogin=Your login was modified. For security pur WarningAnEntryAlreadyExistForTransKey=An entry already exists for the translation key for this language WarningNumberOfRecipientIsRestrictedInMassAction=Warning, number of different recipient is limited to <b>%s</b> when using the mass actions on lists WarningDateOfLineMustBeInExpenseReportRange=Warning, the date of line is not in the range of the expense report -WarningProjectClosed=Project is closed. You must re-open it first. \ No newline at end of file +WarningProjectClosed=Project is closed. You must re-open it first. +WarningSomeBankTransactionByChequeWereRemovedAfter=Some bank transaction were removed after that the receipt including them were generated. So nb of cheques and total of receipt may differ from number and total in list. \ No newline at end of file From ec0d5602f8f04952181bd1afe437b512a1c66fd1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Wed, 13 Nov 2019 02:05:11 +0100 Subject: [PATCH 214/299] Fix log --- htdocs/stripe/class/stripe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 7edccbfeeb7..5f8e264e9ab 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -178,7 +178,7 @@ class Stripe extends CommonObject global $stripearrayofkeysbyenv; \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); - dol_syslog(get_class($this)."::customerStripe found stripe customer key_account = ".$tiers." with publishable_key = ".$stripearrayofkeysbyenv[$status]['publishable_key']); + dol_syslog(get_class($this)."::customerStripe found stripe customer key_account = ".$tiers.". We will try to read it on Stripe with publishable_key = ".$stripearrayofkeysbyenv[$status]['publishable_key']); try { if (empty($key)) { // If the Stripe connect account not set, we use common API usage From 39229b7a99d872e54597bfe9e520788d2df0fd35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Wed, 13 Nov 2019 02:21:23 +0100 Subject: [PATCH 215/299] Fix css --- htdocs/theme/eldy/global.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 05e7919d764..2af18e3f3e0 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2120,9 +2120,9 @@ img.login, img.printer, img.entity { background-size: contain; } img.userphoto { /* size for user photo in lists */ - border-radius: 0.75em; - width: 1.5em; - height: 1.5em; + border-radius: 0.725em; + width: 1.45em; + height: 1.45em; background-size: contain; vertical-align: middle; } From 74239d48bff092a554afc26ba8eaba94db07cea4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Wed, 13 Nov 2019 11:11:08 +0100 Subject: [PATCH 216/299] Fix translation of extrafields when $extralabels not loaded --- htdocs/core/tpl/extrafields_list_search_title.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/extrafields_list_search_title.tpl.php b/htdocs/core/tpl/extrafields_list_search_title.tpl.php index 5772f3fc989..aea871b1109 100644 --- a/htdocs/core/tpl/extrafields_list_search_title.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_title.tpl.php @@ -24,7 +24,7 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $sortonfield = $extrafieldsobjectprefix.$key; if (! empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) $sortonfield=''; if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') print '<th class="liste_titre thseparator"></th>'; - else print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder)."\n"; + else print getTitleFieldOfList($langs->trans($extrafields->attributes[$extrafieldsobjectkey]['label'][$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder)."\n"; } } } From c4c463fb96eb9a207db5a3ac684cafc99b0f807d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Wed, 13 Nov 2019 11:36:42 +0100 Subject: [PATCH 217/299] camelCaps --- htdocs/categories/class/api_categories.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 36b3e10174a..0f2a425fe87 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -277,7 +277,7 @@ class Categories extends DolibarrApi * * @url POST {id}/objects/{type}/{object_id} */ - public function link_object_by_id($id, $type, $object_id) + public function linkObjectById($id, $type, $object_id) { if (empty($type) || empty($object_id)) { throw new RestException(401); @@ -338,7 +338,7 @@ class Categories extends DolibarrApi * * @url POST {id}/objects/{type}/ref/{object_ref} */ - public function link_object_by_ref($id, $type, $object_ref) + public function linkObjectByRef($id, $type, $object_ref) { if (empty($type) || empty($object_ref)) { throw new RestException(401); @@ -399,7 +399,7 @@ class Categories extends DolibarrApi * * @url DELETE {id}/objects/{type}/{object_id} */ - public function unlink_object_by_id($id, $type, $object_id) + public function unlinkObjectById($id, $type, $object_id) { if (empty($type) || empty($object_id)) { throw new RestException(401); @@ -458,7 +458,7 @@ class Categories extends DolibarrApi * * @url DELETE {id}/objects/{type}/ref/{object_ref} */ - public function unlink_object_by_ref($id, $type, $object_ref) + public function unlinkObjectByRef($id, $type, $object_ref) { if (empty($type) || empty($object_ref)) { throw new RestException(401); From 0497c399d7a6d6cdf2cde60cc2fe0859ada2de0a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO <aspangaro.dolibarr@gmail.com> Date: Wed, 13 Nov 2019 14:59:07 +0100 Subject: [PATCH 218/299] Missing language key --- htdocs/langs/en_US/holiday.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index c3cdda3cfd6..bfff50de4c8 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -127,4 +127,5 @@ HolidaysNumberingModules=Leave requests numbering models TemplatePDFHolidays=Template for leave requests PDF FreeLegalTextOnHolidays=Free text on PDF WatermarkOnDraftHolidayCards=Watermarks on draft leave requests -HolidaysToApprove=Holidays to approve \ No newline at end of file +HolidaysToApprove=Holidays to approve +NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays From 5d42ef323e6419d0135d12697f1c3fd6a4522b2b Mon Sep 17 00:00:00 2001 From: Francis Appels <francis.appels@yahoo.com> Date: Wed, 13 Nov 2019 15:13:56 +0100 Subject: [PATCH 219/299] Fix Printsheet product selector --- htdocs/barcode/printsheet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 1ed7c449868..7c055855ffc 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -380,7 +380,7 @@ if (! empty($user->rights->produit->lire) || ! empty($user->rights->service->lir print '<input id="fillfromproduct" type="radio" '.((GETPOST("selectorforbarcode")=='fillfromproduct')?'checked ':'').'name="selectorforbarcode" value="fillfromproduct" class="radiobarcodeselect"> '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; print '<br>'; print '<div class="showforproductselector">'; - $form->select_produits(GETPOST('productid'), 'productid', ''); + $form->select_produits(GETPOST('productid'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); print '   <input type="submit" id="submitproduct" name="submitproduct" class="button" value="'.(dol_escape_htmltag($langs->trans("GetBarCode"))).'">'; print '</div>'; } From 85e2546019b3a63de87ba885433b31c9bdc3e70c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO <aspangaro.dolibarr@gmail.com> Date: Wed, 13 Nov 2019 15:25:23 +0100 Subject: [PATCH 220/299] Missing language key --- htdocs/langs/en_US/admin.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index de1e5f52fcd..d70bfe959e9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -857,6 +857,7 @@ Permission20003=Delete leave requests Permission20004=Read all leave requests (even of user not subordinates) Permission20005=Create/modify leave requests for everybody (even of user not subordinates) Permission20006=Admin leave requests (setup and update balance) +Permission20007=Approve leave requests Permission23001=Read Scheduled job Permission23002=Create/update Scheduled job Permission23003=Delete Scheduled job From bdf02199411c9e6ef45c1b184d2219733c86a977 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Wed, 13 Nov 2019 18:18:45 +0100 Subject: [PATCH 221/299] Missing link to create contact Fix css --- htdocs/core/tpl/contacts.tpl.php | 16 +++++++++++----- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 821881314d3..2f4efae770a 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -127,7 +127,16 @@ if ($permission) { <?php $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0, '', 'minwidth300imp'); ?> </div> <div class="tagtd maxwidthonsmartphone noborderbottom"> - <?php $nbofcontacts=$form->select_contacts(($selectedCompany > 0 ? $selectedCompany : -1), '', 'contactid', 3, '', '', 1, 'minwidth100imp'); ?> + <?php + $nbofcontacts=$form->select_contacts(($selectedCompany > 0 ? $selectedCompany : -1), '', 'contactid', 3, '', '', 1, 'minwidth100imp'); + + $newcardbutton = ''; + if (! empty($object->socid) && $object->socid > 1 && $user->rights->societe->creer) + { + $newcardbutton .= '<a href="'.DOL_URL_ROOT.'/contact/card.php?socid='.$object->socid.'&action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'" title="'.$langs->trans('NewContact').'"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>'; + } + print $newcardbutton; + ?> </div> <div class="tagtd maxwidthonsmartphone noborderbottom"> <?php @@ -156,8 +165,6 @@ if ($permission) { </form> <?php -$var = false; - $arrayofsource=array('internal','external'); // Show both link to user and thirdparties contacts foreach($arrayofsource as $source) { $tmpobject=$object; @@ -168,10 +175,9 @@ foreach($arrayofsource as $source) { $i = 0; while ($i < $num) { - $var = ! $var; ?> - <form class="tagtr oddeven <?php echo ($var?'impair':'pair') ?>"> + <form class="tagtr oddeven"> <div class="tagtd left"> <?php if ($tab[$i]['source']=='internal') echo $langs->trans("User"); ?> <?php if ($tab[$i]['source']=='external') echo $langs->trans("ThirdPartyContact"); ?> diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index fff500fba1b..792d93dbcf6 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2738,7 +2738,7 @@ div.colorback border-left: 1px solid #ccc; } table.liste, table.noborder, table.formdoc, div.noborder { - width: 100%; + width: calc(100% - 1px); /* -1 to fix a bug. Without, a scroll appears dur to overflow-x: auto; of div-tableèresponsive border-collapse: separate !important; border-spacing: 0px; From 7118dbbd1d510c55eb58b2d2b02516bcfc75a4ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Wed, 13 Nov 2019 18:25:48 +0100 Subject: [PATCH 222/299] Fix var not defined --- htdocs/core/lib/usergroups.lib.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index eeaa4d4d6ce..44829cc9758 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -420,6 +420,18 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print '</td></tr>'; + // Set variables of theme + $colorbackhmenu1 = ''; + $colorbackvmenu1 = ''; + $colortexttitlenotab = ''; + $colorbacktitle1 = ''; + $colortexttitle = ''; + $colorbacklineimpair1 = ''; + $colorbacklinepair1 = ''; + $colortextlink = ''; + $colorbacklinepairhover = ''; + $colorbacklinepairhover = ''; + $colorbacklinepairchecked = ''; if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php')) { include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; } From c66bce7ec6a241b39a5369e7b0e17e879e5de3eb Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com> Date: Wed, 13 Nov 2019 17:31:18 +0000 Subject: [PATCH 223/299] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- .../sociales/class/chargesociales.class.php | 170 +++++++++--------- htdocs/core/modules/modBom.class.php | 54 +++--- 2 files changed, 112 insertions(+), 112 deletions(-) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 2bc82fc8b78..fecc5a96aa1 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -35,14 +35,14 @@ class ChargeSociales extends CommonObject /** * @var string ID to identify managed object */ - public $element='chargesociales'; + public $element = 'chargesociales'; - public $table='chargesociales'; + public $table = 'chargesociales'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='chargesociales'; + public $table_element = 'chargesociales'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -175,7 +175,7 @@ class ChargeSociales extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -187,10 +187,10 @@ class ChargeSociales extends CommonObject */ public function check() { - $newamount=price2num($this->amount, 'MT'); + $newamount = price2num($this->amount, 'MT'); // Validation parametres - if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode)) + if (!$newamount > 0 || empty($this->date_ech) || empty($this->periode)) { return false; } @@ -208,55 +208,55 @@ class ChargeSociales extends CommonObject public function create($user) { global $conf; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); // Nettoyage parametres - $newamount=price2num($this->amount, 'MT'); + $newamount = price2num($this->amount, 'MT'); if (!$this->check()) { - $this->error="ErrorBadParameter"; + $this->error = "ErrorBadParameter"; return -2; } $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, date_creation)"; - $sql.= " VALUES (".$this->type; - $sql.= ", ".($this->fk_account>0 ? $this->fk_account:'NULL'); - $sql.= ", ".($this->mode_reglement_id>0 ? $this->mode_reglement_id:"NULL"); - $sql.= ", '".$this->db->escape($this->label?$this->label:$this->lib)."'"; - $sql.= ", '".$this->db->idate($this->date_ech)."'"; - $sql.= ", '".$this->db->idate($this->periode)."'"; - $sql.= ", '".price2num($newamount)."'"; - $sql.= ", ".($this->fk_project>0?$this->fk_project:'NULL'); - $sql.= ", ".$conf->entity; - $sql.= ", ".$user->id; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ")"; + $sql .= " VALUES (".$this->type; + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "NULL"); + $sql .= ", '".$this->db->escape($this->label ? $this->label : $this->lib)."'"; + $sql .= ", '".$this->db->idate($this->date_ech)."'"; + $sql .= ", '".$this->db->idate($this->periode)."'"; + $sql .= ", '".price2num($newamount)."'"; + $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 'NULL'); + $sql .= ", ".$conf->entity; + $sql .= ", ".$user->id; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); //dol_syslog("ChargesSociales::create this->id=".$this->id); - $result=$this->call_trigger('SOCIALCONTRIBUTION_CREATE', $user); + $result = $this->call_trigger('SOCIALCONTRIBUTION_CREATE', $user); if ($result < 0) $error++; - if(empty($error)) { + if (empty($error)) { $this->db->commit(); return $this->id; } else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -271,23 +271,23 @@ class ChargeSociales extends CommonObject */ public function delete($user) { - $error=0; + $error = 0; $this->db->begin(); // Get bank transaction lines for this social contributions include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $account=new Account($this->db); - $lines_url=$account->get_url('', $this->id, 'sc'); + $account = new Account($this->db); + $lines_url = $account->get_url('', $this->id, 'sc'); // Delete bank urls foreach ($lines_url as $line_url) { - if (! $error) + if (!$error) { - $accountline=new AccountLine($this->db); + $accountline = new AccountLine($this->db); $accountline->fetch($line_url['fk_bank']); - $result=$accountline->delete_urls($user); + $result = $accountline->delete_urls($user); if ($result < 0) { $error++; @@ -296,31 +296,31 @@ class ChargeSociales extends CommonObject } // Delete payments - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -342,31 +342,31 @@ class ChargeSociales extends CommonObject */ public function update($user, $notrigger = 0) { - $error=0; + $error = 0; $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; - $sql.= " SET libelle='".$this->db->escape($this->label?$this->label:$this->lib)."'"; - $sql.= ", date_ech='".$this->db->idate($this->date_ech)."'"; - $sql.= ", periode='".$this->db->idate($this->periode)."'"; - $sql.= ", amount='".price2num($this->amount, 'MT')."'"; - $sql.= ", fk_projet=".($this->fk_project>0?$this->db->escape($this->fk_project):"NULL"); - $sql.= ", fk_user_modif=".$user->id; - $sql.= " WHERE rowid=".$this->id; + $sql .= " SET libelle='".$this->db->escape($this->label ? $this->label : $this->lib)."'"; + $sql .= ", date_ech='".$this->db->idate($this->date_ech)."'"; + $sql .= ", periode='".$this->db->idate($this->periode)."'"; + $sql .= ", amount='".price2num($this->amount, 'MT')."'"; + $sql .= ", fk_projet=".($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "NULL"); + $sql .= ", fk_user_modif=".$user->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('SOCIALCHARGES_MODIFY', $user); + $result = $this->call_trigger('SOCIALCHARGES_MODIFY', $user); if ($result < 0) $error++; // End call triggers } @@ -375,13 +375,13 @@ class ChargeSociales extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -401,9 +401,9 @@ class ChargeSociales extends CommonObject global $conf; $sql = "SELECT SUM(f.amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; - $sql.= " WHERE f.entity = ".$conf->entity; - $sql.= " AND paye = 0"; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; + $sql .= " WHERE f.entity = ".$conf->entity; + $sql .= " AND paye = 0"; if ($year) { $sql .= " AND f.datev >= '$y-01-01' AND f.datev <= '$y-12-31' "; @@ -441,8 +441,8 @@ class ChargeSociales extends CommonObject { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; - $sql.= " paye = 1"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " paye = 1"; + $sql .= " WHERE rowid = ".$this->id; $return = $this->db->query($sql); if ($return) return 1; else return -1; @@ -459,8 +459,8 @@ class ChargeSociales extends CommonObject { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; - $sql.= " paye = 0"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " paye = 0"; + $sql .= " WHERE rowid = ".$this->id; $return = $this->db->query($sql); if ($return) return 1; else return -1; @@ -549,9 +549,9 @@ class ChargeSociales extends CommonObject { global $langs, $conf, $user, $form; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result=''; + $result = ''; $url = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id; @@ -607,20 +607,20 @@ class ChargeSociales extends CommonObject */ public function getSommePaiement() { - $table='paiementcharge'; - $field='fk_charge'; + $table = 'paiementcharge'; + $field = 'fk_charge'; $sql = 'SELECT sum(amount) as amount'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; - $sql.= ' WHERE '.$field.' = '.$this->id; + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; + $sql .= ' WHERE '.$field.' = '.$this->id; dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $amount=0; + $amount = 0; $obj = $this->db->fetch_object($resql); - if ($obj) $amount=$obj->amount?$obj->amount:0; + if ($obj) $amount = $obj->amount ? $obj->amount : 0; $this->db->free($resql); return $amount; @@ -640,12 +640,12 @@ class ChargeSociales extends CommonObject public function info($id) { $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; - $sql.= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as e"; - $sql.= " WHERE e.rowid = ".$id; + $sql .= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as e"; + $sql .= " WHERE e.rowid = ".$id; dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -696,14 +696,14 @@ class ChargeSociales extends CommonObject public function initAsSpecimen() { // Initialize parameters - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->paye = 0; $this->date = dol_now(); - $this->date_ech=$this->date+3600*24*30; - $this->periode=$this->date+3600*24*30; - $this->amount=100; + $this->date_ech = $this->date + 3600 * 24 * 30; + $this->periode = $this->date + 3600 * 24 * 30; + $this->amount = 100; $this->label = 'Social contribution label'; $this->type = 1; $this->type_label = 'Type of social contribution'; diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 714e15f0ee9..362e0c445ee 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -25,7 +25,7 @@ * \ingroup bom * \brief Description and activation file for module Bom */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -75,7 +75,7 @@ class modBom extends DolibarrModules // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='bom'; + $this->picto = 'bom'; // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( @@ -103,15 +103,15 @@ class modBom extends DolibarrModules $this->config_page_url = array("bom.php"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) - $this->requiredby = array('modMrp'); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) - $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->hidden = false; // A condition to hide module + $this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->requiredby = array('modMrp'); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->langfiles = array("mrp"); //$this->phpmin = array(5,4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(9,0); // Minimum version of Dolibarr required by module - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->need_dolibarr_version = array(9, 0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) //$this->automatic_activation = array('FR'=>'BomWasAutomaticallyActivatedBecauseOfYourCountryChoice'); //$this->always_enabled = true; // If true, can't be disabled @@ -132,10 +132,10 @@ class modBom extends DolibarrModules 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' )*/ - if (! isset($conf->bom) || ! isset($conf->bom->enabled)) + if (!isset($conf->bom) || !isset($conf->bom->enabled)) { - $conf->bom=new stdClass(); - $conf->bom->enabled=0; + $conf->bom = new stdClass(); + $conf->bom->enabled = 0; } @@ -281,28 +281,28 @@ class modBom extends DolibarrModules // Exports - $r=1; + $r = 1; /* BEGIN MODULEBUILDER EXPORT BILLOFMATERIALS */ $langs->load("mrp"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='BomAndBomLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='bom'; - $keyforclass = 'BOM'; $keyforclassfile='/bom/class/bom.class.php'; $keyforelement='bom'; + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = 'BomAndBomLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r] = 'bom'; + $keyforclass = 'BOM'; $keyforclassfile = '/bom/class/bom.class.php'; $keyforelement = 'bom'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforclass = 'BOMLine'; $keyforclassfile='/bom/class/bom.class.php'; $keyforelement='bomline'; $keyforalias='tl'; + $keyforclass = 'BOMLine'; $keyforclassfile = '/bom/class/bom.class.php'; $keyforelement = 'bomline'; $keyforalias = 'tl'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; unset($this->export_fields_array[$r]['tl.fk_bom']); - $keyforselect ='bom_bom'; $keyforaliasextra='extra'; $keyforelement='bom'; + $keyforselect = 'bom_bom'; $keyforaliasextra = 'extra'; $keyforelement = 'bom'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect ='bom_bomline'; $keyforaliasextra='extraline'; $keyforelement='bomline'; + $keyforselect = 'bom_bomline'; $keyforaliasextra = 'extraline'; $keyforelement = 'bomline'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_dependencies_array[$r]=array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'bom_bom as t'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('bom').')'; + $this->export_dependencies_array[$r] = array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'bom_bom as t'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid'; + $this->export_sql_end[$r] .= ' WHERE 1 = 1'; + $this->export_sql_end[$r] .= ' AND t.entity IN ('.getEntity('bom').')'; $r++; /* END MODULEBUILDER EXPORT BILLOFMATERIALS */ } @@ -319,7 +319,7 @@ class modBom extends DolibarrModules { global $conf, $langs; - $result=$this->_load_tables('/bom/sql/'); + $result = $this->_load_tables('/bom/sql/'); if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') // Create extrafields From 87585c0f2a040c6cc26545d22619c033dda6b707 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com> Date: Wed, 13 Nov 2019 17:32:11 +0000 Subject: [PATCH 224/299] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/adherents/card.php | 630 ++++---- htdocs/core/actions_addupdatedelete.inc.php | 78 +- htdocs/core/class/CMailFile.class.php | 612 +++---- htdocs/expensereport/card.php | 706 ++++---- htdocs/install/check.php | 172 +- .../template/class/myobject.class.php | 144 +- htdocs/product/stock/productlot_card.php | 124 +- htdocs/projet/class/task.class.php | 1124 ++++++------- htdocs/reception/class/reception.class.php | 760 ++++----- htdocs/societe/card.php | 798 ++++----- htdocs/societe/class/societe.class.php | 1440 ++++++++--------- htdocs/societe/paymentmodes.php | 540 +++---- 12 files changed, 3564 insertions(+), 3564 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 417d4cd2c99..2a8177df6f2 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -43,19 +43,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","bills","members","users","other")); +$langs->loadLangs(array("companies", "bills", "members", "users", "other")); -$action=GETPOST('action', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); -$backtopage=GETPOST('backtopage', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); -$rowid=GETPOST('rowid', 'int'); -$id=GETPOST('id')?GETPOST('id', 'int'):$rowid; -$typeid=GETPOST('typeid', 'int'); -$userid=GETPOST('userid', 'int'); -$socid=GETPOST('socid', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$rowid = GETPOST('rowid', 'int'); +$id = GETPOST('id') ?GETPOST('id', 'int') : $rowid; +$typeid = GETPOST('typeid', 'int'); +$userid = GETPOST('userid', 'int'); +$socid = GETPOST('socid', 'int'); -if (! empty($conf->mailmanspip->enabled)) +if (!empty($conf->mailmanspip->enabled)) { include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; @@ -74,9 +74,9 @@ $socialnetworks = getArrayOfSocialNetworks(); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); -$canvas = $object->canvas?$object->canvas:GETPOST("canvas"); -$objcanvas=null; -if (! empty($canvas)) +$canvas = $object->canvas ? $object->canvas : GETPOST("canvas"); +$objcanvas = null; +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); @@ -84,7 +84,7 @@ if (! empty($canvas)) } // Security check -$result=restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objcanvas); +$result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objcanvas); if ($id > 0) { @@ -92,28 +92,28 @@ if ($id > 0) $result = $object->fetch($id); // Define variables to know what current user can do on users - $canadduser=($user->admin || $user->rights->user->user->creer); + $canadduser = ($user->admin || $user->rights->user->user->creer); // Define variables to know what current user can do on properties of user linked to edited member if ($object->user_id) { // $User is the user who edits, $object->user_id is the id of the related user in the edited member - $caneditfielduser=((($user->id == $object->user_id) && $user->rights->user->self->creer) + $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) || (($user->id != $object->user_id) && $user->rights->user->user->creer)); - $caneditpassworduser=((($user->id == $object->user_id) && $user->rights->user->self->password) + $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) || (($user->id != $object->user_id) && $user->rights->user->user->password)); } } // Define variables to determine what the current user can do on the members -$canaddmember=$user->rights->adherent->creer; +$canaddmember = $user->rights->adherent->creer; // Define variables to determine what the current user can do on the properties of a member if ($id) { - $caneditfieldmember=$user->rights->adherent->creer; + $caneditfieldmember = $user->rights->adherent->creer; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('membercard','globalcard')); +$hookmanager->initHooks(array('membercard', 'globalcard')); @@ -121,25 +121,25 @@ $hookmanager->initHooks(array('membercard','globalcard')); * Actions */ -$parameters=array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas, 'confirm'=>$confirm); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas, 'confirm'=>$confirm); +$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)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; } if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { - $error=0; + $error = 0; if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only { if ($userid != $user->id && $userid != $object->user_id) @@ -149,47 +149,47 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { if ($userid != $object->user_id) // If link differs from currently in database { - $result=$object->setUserId($userid); + $result = $object->setUserId($userid); if ($result < 0) dol_print_error($object->db, $object->error); - $action=''; + $action = ''; } } } if ($action == 'setsocid') { - $error=0; - if (! $error) + $error = 0; + if (!$error) { if ($socid != $object->socid) // If link differs from currently in database { - $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql.=" WHERE socid = '".$socid."'"; - $sql.=" AND entity = ".$conf->entity; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; + $sql .= " WHERE socid = '".$socid."'"; + $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj && $obj->rowid > 0) { - $othermember=new Adherent($db); + $othermember = new Adherent($db); $othermember->fetch($obj->rowid); - $thirdparty=new Societe($db); + $thirdparty = new Societe($db); $thirdparty->fetch($socid); $error++; setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors'); } } - if (! $error) + if (!$error) { - $result=$object->setThirdPartyId($socid); + $result = $object->setThirdPartyId($socid); if ($result < 0) dol_print_error($object->db, $object->error); - $action=''; + $action = ''; } } } @@ -202,7 +202,7 @@ if (empty($reshook)) { // Creation user $nuser = new User($db); - $result=$nuser->create_from_member($object, GETPOST('login')); + $result = $nuser->create_from_member($object, GETPOST('login')); if ($result < 0) { @@ -223,7 +223,7 @@ if (empty($reshook)) { // User creation $company = new Societe($db); - $result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha')); + $result = $company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha')); if ($result < 0) { @@ -238,29 +238,29 @@ if (empty($reshook)) } } - if ($action == 'update' && ! $cancel && $user->rights->adherent->creer) + if ($action == 'update' && !$cancel && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $birthdate=''; + $birthdate = ''; if (isset($_POST["birthday"]) && $_POST["birthday"] && isset($_POST["birthmonth"]) && $_POST["birthmonth"] && isset($_POST["birthyear"]) && $_POST["birthyear"]) { - $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); + $birthdate = dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); } - $lastname=$_POST["lastname"]; - $firstname=$_POST["firstname"]; + $lastname = $_POST["lastname"]; + $firstname = $_POST["firstname"]; $gender = $_POST["gender"]; - $societe=$_POST["societe"]; - $morphy=$_POST["morphy"]; - $login=$_POST["login"]; + $societe = $_POST["societe"]; + $morphy = $_POST["morphy"]; + $login = $_POST["login"]; if ($morphy != 'mor' && empty($lastname)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors'); } - if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { + if ($morphy != 'mor' && (!isset($firstname) || $firstname == '')) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors'); @@ -279,7 +279,7 @@ if (empty($reshook)) } } // Create new object - if ($result > 0 && ! $error) + if ($result > 0 && !$error) { $object->oldcopy = clone $object; @@ -291,7 +291,7 @@ if (empty($reshook)) $object->login = trim(GETPOST("login", 'alpha')); $object->pass = trim(GETPOST("pass", 'alpha')); - $object->societe = trim(GETPOST("societe", 'alpha')); // deprecated + $object->societe = trim(GETPOST("societe", 'alpha')); // deprecated $object->company = trim(GETPOST("societe", 'alpha')); $object->address = trim(GETPOST("address", 'alpha')); @@ -302,11 +302,11 @@ if (empty($reshook)) $object->phone = trim(GETPOST("phone", 'alpha')); $object->phone_perso = trim(GETPOST("phone_perso", 'alpha')); - $object->phone_mobile= trim(GETPOST("phone_mobile", 'alpha')); + $object->phone_mobile = trim(GETPOST("phone_mobile", 'alpha')); $object->email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); $object->socialnetworks = array(); foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { $object->socialnetworks[$key] = trim(GETPOST($key, 'alphanohtml')); } } @@ -320,8 +320,8 @@ if (empty($reshook)) //$object->note = trim(GETPOST("comment","alpha")); $object->morphy = GETPOST("morphy", 'alpha'); - if (GETPOST('deletephoto', 'alpha')) $object->photo=''; - elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); + if (GETPOST('deletephoto', 'alpha')) $object->photo = ''; + elseif (!empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); // Get status and public property $object->statut = GETPOST("statut", 'alpha'); @@ -332,36 +332,36 @@ if (empty($reshook)) if ($ret < 0) $error++; // Check if we need to also synchronize user information - $nosyncuser=0; + $nosyncuser = 0; if ($object->user_id) // If linked to a user { - if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser=1; // Disable synchronizing + if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser = 1; // Disable synchronizing } // Check if we need to also synchronize password information - $nosyncuserpass=0; + $nosyncuserpass = 0; if ($object->user_id) // If linked to a user { - if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass=1; // Disable synchronizing + if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass = 1; // Disable synchronizing } - $result=$object->update($user, 0, $nosyncuser, $nosyncuserpass); + $result = $object->update($user, 0, $nosyncuser, $nosyncuserpass); - if ($result >= 0 && ! count($object->errors)) + if ($result >= 0 && !count($object->errors)) { $categories = GETPOST('memcats', 'array'); $object->setCategories($categories); // Logo/Photo save - $dir= $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 1, $object, 'member').'/photos'; + $dir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos'; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) { if (GETPOST('deletephoto')) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileimg=$conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/'.$object->photo; - $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/thumbs'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $fileimg = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/'.$object->photo; + $dirthumbs = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } @@ -372,8 +372,8 @@ if (empty($reshook)) if (@is_dir($dir)) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } @@ -391,7 +391,7 @@ if (empty($reshook)) } else { - switch($_FILES['photo']['error']) + switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form @@ -403,11 +403,11 @@ if (empty($reshook)) } } - $rowid=$object->id; - $id=$object->id; - $action=''; + $rowid = $object->id; + $id = $object->id; + $action = ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -416,67 +416,67 @@ if (empty($reshook)) else { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } else { - $action='edit'; + $action = 'edit'; } } if ($action == 'add' && $user->rights->adherent->creer) { - if ($canvas) $object->canvas=$canvas; - $birthdate=''; + if ($canvas) $object->canvas = $canvas; + $birthdate = ''; if (isset($_POST["birthday"]) && $_POST["birthday"] && isset($_POST["birthmonth"]) && $_POST["birthmonth"] && isset($_POST["birthyear"]) && $_POST["birthyear"]) { - $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); + $birthdate = dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); } - $datesubscription=''; + $datesubscription = ''; if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) { - $datesubscription=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datesubscription = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); } - $typeid=GETPOST("typeid", 'int'); - $civility_id=GETPOST("civility_id", 'alpha'); - $lastname=GETPOST("lastname", 'alpha'); - $firstname=GETPOST("firstname", 'alpha'); - $gender=GETPOST("gender", 'alpha'); - $societe=GETPOST("societe", 'alpha'); - $address=GETPOST("address", 'alpha'); - $zip=GETPOST("zipcode", 'alpha'); - $town=GETPOST("town", 'alpha'); - $state_id=GETPOST("state_id", 'int'); - $country_id=GETPOST("country_id", 'int'); + $typeid = GETPOST("typeid", 'int'); + $civility_id = GETPOST("civility_id", 'alpha'); + $lastname = GETPOST("lastname", 'alpha'); + $firstname = GETPOST("firstname", 'alpha'); + $gender = GETPOST("gender", 'alpha'); + $societe = GETPOST("societe", 'alpha'); + $address = GETPOST("address", 'alpha'); + $zip = GETPOST("zipcode", 'alpha'); + $town = GETPOST("town", 'alpha'); + $state_id = GETPOST("state_id", 'int'); + $country_id = GETPOST("country_id", 'int'); - $phone=GETPOST("phone", 'alpha'); - $phone_perso=GETPOST("phone_perso", 'alpha'); - $phone_mobile=GETPOST("phone_mobile", 'alpha'); + $phone = GETPOST("phone", 'alpha'); + $phone_perso = GETPOST("phone_perso", 'alpha'); + $phone_mobile = GETPOST("phone_mobile", 'alpha'); // $skype=GETPOST("member_skype", 'alpha'); // $twitter=GETPOST("member_twitter", 'alpha'); // $facebook=GETPOST("member_facebook", 'alpha'); // $linkedin=GETPOST("member_linkedin", 'alpha'); - $email=preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); - $login=GETPOST("member_login", 'alpha'); - $pass=GETPOST("password", 'alpha'); - $photo=GETPOST("photo", 'alpha'); + $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); + $login = GETPOST("member_login", 'alpha'); + $pass = GETPOST("password", 'alpha'); + $photo = GETPOST("photo", 'alpha'); //$comment=GETPOST("comment",'none'); - $morphy=GETPOST("morphy", 'alpha'); - $subscription=GETPOST("subscription", 'alpha'); - $public=GETPOST("public", 'alpha'); + $morphy = GETPOST("morphy", 'alpha'); + $subscription = GETPOST("subscription", 'alpha'); + $public = GETPOST("public", 'alpha'); - $userid=GETPOST("userid", 'int'); - $socid=GETPOST("socid", 'int'); + $userid = GETPOST("userid", 'int'); + $socid = GETPOST("socid", 'int'); $object->civility_id = $civility_id; $object->firstname = $firstname; $object->lastname = $lastname; $object->gender = $gender; - $object->societe = $societe; // deprecated + $object->societe = $societe; // deprecated $object->company = $societe; $object->address = $address; $object->zip = $zip; @@ -485,11 +485,11 @@ if (empty($reshook)) $object->country_id = $country_id; $object->phone = $phone; $object->phone_perso = $phone_perso; - $object->phone_mobile= $phone_mobile; + $object->phone_mobile = $phone_mobile; $object->socialnetworks = array(); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { $object->socialnetworks[$key] = GETPOST("member_".$key, 'alphanohtml'); } } @@ -509,7 +509,7 @@ if (empty($reshook)) //$object->note = $comment; $object->morphy = $morphy; $object->user_id = $userid; - $object->socid = $socid; + $object->socid = $socid; $object->public = $public; // Fill array 'array_options' with data from add form @@ -555,29 +555,29 @@ if (empty($reshook)) $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors'); } - if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { + if ($morphy != 'mor' && (!isset($firstname) || $firstname == '')) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors'); } - if (! ($typeid > 0)) { // Keep () before ! + if (!($typeid > 0)) { // Keep () before ! $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); } - if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) { + if ($conf->global->ADHERENT_MAIL_REQUIRED && !isValidEMail($email)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors'); } - $public=0; - if (isset($public)) $public=1; + $public = 0; + if (isset($public)) $public = 1; - if (! $error) + if (!$error) { $db->begin(); // Email about right and login does not exist - $result=$object->create($user); + $result = $object->create($user); if ($result > 0) { // Foundation categories @@ -585,9 +585,9 @@ if (empty($reshook)) $object->setCategories($memcats); $db->commit(); - $rowid=$object->id; - $id=$object->id; - $action=''; + $rowid = $object->id; + $id = $object->id; + $action = ''; } else { @@ -609,10 +609,10 @@ if (empty($reshook)) if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { - $result=$object->delete($id, $user); + $result = $object->delete($id, $user); if ($result > 0) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -625,44 +625,44 @@ if (empty($reshook)) } else { - $errmesg=$object->error; + $errmesg = $object->error; } } if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') { - $error=0; + $error = 0; $db->begin(); $adht = new AdherentType($db); $adht->fetch($object->typeid); - $result=$object->validate($user); + $result = $object->validate($user); - if ($result >= 0 && ! count($object->errors)) + if ($result >= 0 && !count($object->errors)) { // Send confirmation email (according to parameters of member type. Otherwise generic) if ($object->email && GETPOST("send_mail")) { $subject = ''; - $msg= ''; + $msg = ''; // Send subscription email include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail=new FormMail($db); + $formmail = new FormMail($db); // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template - $arraydefaultmessage=null; + $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION; - if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; @@ -674,14 +674,14 @@ if (empty($reshook)) $error++; } else { - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); - $moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; + $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; - $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); if ($result < 0) { $error++; @@ -700,7 +700,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $db->commit(); } @@ -708,7 +708,7 @@ if (empty($reshook)) { $db->rollback(); } - $action=''; + $action = ''; } if ($user->rights->adherent->supprimer && $action == 'confirm_resign') @@ -720,30 +720,30 @@ if (empty($reshook)) $adht = new AdherentType($db); $adht->fetch($object->typeid); - $result=$object->resiliate($user); + $result = $object->resiliate($user); - if ($result >= 0 && ! count($object->errors)) + if ($result >= 0 && !count($object->errors)) { if ($object->email && GETPOST("send_mail")) { $subject = ''; - $msg= ''; + $msg = ''; // Send subscription email include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail=new FormMail($db); + $formmail = new FormMail($db); // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template - $arraydefaultmessage=null; + $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION; - if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; @@ -755,14 +755,14 @@ if (empty($reshook)) $error++; } else { - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs); - $moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; + $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; - $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); if ($result < 0) { $error++; @@ -780,10 +780,10 @@ if (empty($reshook)) } else { setEventMessages($object->error, $object->errors, 'errors'); } - $action=''; + $action = ''; } } - if (! empty($backtopage) && ! $error) + if (!empty($backtopage) && !$error) { header("Location: ".$backtopage); exit; @@ -793,7 +793,7 @@ if (empty($reshook)) // SPIP Management if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') { - if (! count($object->errors)) + if (!count($object->errors)) { if (!$mailmanspip->del_to_spip($object)) { @@ -804,7 +804,7 @@ if (empty($reshook)) if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') { - if (! count($object->errors)) + if (!count($object->errors)) { if (!$mailmanspip->add_to_spip($object)) { @@ -818,14 +818,14 @@ if (empty($reshook)) // Actions to build doc $upload_dir = $conf->adherent->dir_output; - $permissiontoadd=$user->rights->adherent->creer; + $permissiontoadd = $user->rights->adherent->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails - $trigger_name='MEMBER_SENTBYMAIL'; - $paramname='id'; - $mode='emailfrommember'; - $trackid='mem'.$object->id; + $trigger_name = 'MEMBER_SENTBYMAIL'; + $paramname = 'id'; + $mode = 'emailfrommember'; + $trackid = 'mem'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -838,11 +838,11 @@ $form = new Form($db); $formfile = new FormFile($db); $formcompany = new FormCompany($db); -$title=$langs->trans("Member") . " - " . $langs->trans("Card"); -$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +$title = $langs->trans("Member")." - ".$langs->trans("Card"); +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; llxHeader('', $title, $help_url); -$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { @@ -852,11 +852,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (empty($object->error) && $id) { $object = new Adherent($db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); } - $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + $objcanvas->display_canvas($action); // Show template } else { @@ -871,23 +871,23 @@ else /* Creation mode */ /* */ /* ************************************************************************** */ - $object->canvas=$canvas; + $object->canvas = $canvas; $object->state_id = GETPOST('state_id', 'int'); // We set country_id, country_code and country for the selected country - $object->country_id=GETPOST('country_id', 'int')?GETPOST('country_id', 'int'):$mysoc->country_id; + $object->country_id = GETPOST('country_id', 'int') ?GETPOST('country_id', 'int') : $mysoc->country_id; if ($object->country_id) { - $tmparray=getCountry($object->country_id, 'all'); - $object->country_code=$tmparray['code']; - $object->country=$tmparray['label']; + $tmparray = getCountry($object->country_id, 'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; } if (!empty($socid)) { $object = new Societe($db); if ($socid > 0) $object->fetch($socid); - if (! ($object->id > 0)) + if (!($object->id > 0)) { $langs->load("errors"); print($langs->trans('ErrorRecordNotFound')); @@ -944,14 +944,14 @@ else // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="member_login" class="minwidth300" maxlength="50" value="'.(isset($_POST["member_login"])?GETPOST("member_login", 'alpha', 2):$object->login).'" autofocus="autofocus"></td></tr>'; + print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="member_login" class="minwidth300" maxlength="50" value="'.(isset($_POST["member_login"]) ?GETPOST("member_login", 'alpha', 2) : $object->login).'" autofocus="autofocus"></td></tr>'; } // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generated_password=getRandomPassword(false); + $generated_password = getRandomPassword(false); print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>'; print '<input type="text" class="minwidth300" maxlength="50" name="password" value="'.$generated_password.'">'; print '</td></tr>'; @@ -959,10 +959,10 @@ else // Type print '<tr><td class="fieldrequired">'.$langs->trans("MemberType").'</td><td>'; - $listetype=$adht->liste_array(); + $listetype = $adht->liste_array(); if (count($listetype)) { - print $form->selectarray("typeid", $listetype, GETPOST('typeid', 'int')?GETPOST('typeid', 'int'):$typeid, count($listetype)>1?1:0); + print $form->selectarray("typeid", $listetype, GETPOST('typeid', 'int') ?GETPOST('typeid', 'int') : $typeid, count($listetype) > 1 ? 1 : 0); } else { print '<font class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</font>'; } @@ -972,51 +972,51 @@ else $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print '<tr><td class="fieldrequired">'.$langs->trans("MemberNature")."</td><td>\n"; - print $form->selectarray("morphy", $morphys, GETPOST('morphy', 'alpha')?GETPOST('morphy', 'alpha'):$object->morphy, 1); + print $form->selectarray("morphy", $morphys, GETPOST('morphy', 'alpha') ?GETPOST('morphy', 'alpha') : $object->morphy, 1); print "</td>\n"; // Company - print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(GETPOST('societe', 'alpha')?GETPOST('societe', 'alpha'):$object->company).'"></td></tr>'; + print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(GETPOST('societe', 'alpha') ?GETPOST('societe', 'alpha') : $object->company).'"></td></tr>'; // Civility print '<tr><td>'.$langs->trans("UserTitle").'</td><td>'; - print $formcompany->select_civility(GETPOST('civility_id', 'int')?GETPOST('civility_id', 'int'):$object->civility_id, 'civility_id').'</td>'; + print $formcompany->select_civility(GETPOST('civility_id', 'int') ?GETPOST('civility_id', 'int') : $object->civility_id, 'civility_id').'</td>'; print '</tr>'; // Lastname - print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="minwidth300" maxlength="50" value="'.(GETPOST('lastname', 'alpha')?GETPOST('lastname', 'alpha'):$object->lastname).'"></td>'; + print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="minwidth300" maxlength="50" value="'.(GETPOST('lastname', 'alpha') ?GETPOST('lastname', 'alpha') : $object->lastname).'"></td>'; print '</tr>'; // Firstname - print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="minwidth300" maxlength="50" value="'.(GETPOST('firstname', 'alpha')?GETPOST('firstname', 'alpha'):$object->firstname).'"></td>'; + print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="minwidth300" maxlength="50" value="'.(GETPOST('firstname', 'alpha') ?GETPOST('firstname', 'alpha') : $object->firstname).'"></td>'; print '</tr>'; // Gender print '<tr><td>'.$langs->trans("Gender").'</td>'; print '<td>'; - $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1); print '</td></tr>'; // EMail - print '<tr><td>'.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(GETPOST('member_email', 'alpha')?GETPOST('member_email', 'alpha'):$object->email).'"></td></tr>'; + print '<tr><td>'.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED ? '<span class="fieldrequired">' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '</span>' : '').'</td><td><input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(GETPOST('member_email', 'alpha') ?GETPOST('member_email', 'alpha') : $object->email).'"></td></tr>'; // Address print '<tr><td class="tdtop">'.$langs->trans("Address").'</td><td>'; - print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="2">'.(GETPOST('address', 'alphanohtml')?GETPOST('address', 'alphanohtml'):$object->address).'</textarea>'; + print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="2">'.(GETPOST('address', 'alphanohtml') ?GETPOST('address', 'alphanohtml') : $object->address).'</textarea>'; print '</td></tr>'; // Zip / Town print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>'; - print $formcompany->select_ziptown((GETPOST('zipcode', 'alphanohtml')?GETPOST('zipcode', 'alphanohtml'):$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6); + print $formcompany->select_ziptown((GETPOST('zipcode', 'alphanohtml') ?GETPOST('zipcode', 'alphanohtml') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print ' '; - print $formcompany->select_ziptown((GETPOST('town', 'alphanohtml')?GETPOST('town', 'alphanohtml'):$object->town), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((GETPOST('town', 'alphanohtml') ?GETPOST('town', 'alphanohtml') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '</td></tr>'; // Country - $object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; + $object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id; print '<tr><td width="25%">'.$langs->trans('Country').'</td><td>'; - print $form->select_country(GETPOST('country_id', 'alpha')?GETPOST('country_id', 'alpha'):$object->country_id, 'country_id'); + print $form->select_country(GETPOST('country_id', 'alpha') ?GETPOST('country_id', 'alpha') : $object->country_id, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '</td></tr>'; @@ -1026,7 +1026,7 @@ else print '<tr><td>'.$langs->trans('State').'</td><td>'; if ($object->country_id) { - print $formcompany->select_state(GETPOST('state_id', 'int')?GETPOST('state_id', 'int'):$object->state_id, $object->country_code); + print $formcompany->select_state(GETPOST('state_id', 'int') ?GETPOST('state_id', 'int') : $object->state_id, $object->country_code); } else { @@ -1036,18 +1036,18 @@ else } // Pro phone - print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(GETPOST('phone', 'alpha')?GETPOST('phone', 'alpha'):$object->phone).'"></td></tr>'; + print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(GETPOST('phone', 'alpha') ?GETPOST('phone', 'alpha') : $object->phone).'"></td></tr>'; // Personal phone - print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(GETPOST('phone_perso', 'alpha')?GETPOST('phone_perso', 'alpha'):$object->phone_perso).'"></td></tr>'; + print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(GETPOST('phone_perso', 'alpha') ?GETPOST('phone_perso', 'alpha') : $object->phone_perso).'"></td></tr>'; // Mobile phone - print '<tr><td>'.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(GETPOST('phone_mobile', 'alpha')?GETPOST('phone_mobile', 'alpha'):$object->phone_mobile).'"></td></tr>'; + print '<tr><td>'.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(GETPOST('phone_mobile', 'alpha') ?GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td></tr>'; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if (!$value['active']) break; - print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="member_'.$key.'" size="40" value="'.(GETPOST('member_'.$key, 'alpha')?GETPOST('member_'.$key, 'alpha'):$object->socialnetworks[$key]).'"></td></tr>'; + print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="member_'.$key.'" size="40" value="'.(GETPOST('member_'.$key, 'alpha') ?GETPOST('member_'.$key, 'alpha') : $object->socialnetworks[$key]).'"></td></tr>'; } } @@ -1062,9 +1062,9 @@ else print "</td></tr>\n"; // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print '<tr><td>' .$form->editfieldkey("Categories", 'memcats', '', $object, 0) . '</td><td>'; + print '<tr><td>'.$form->editfieldkey("Categories", 'memcats', '', $object, 0).'</td><td>'; $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, 'parent', null, null, 1); print $form->multiselectarray('memcats', $cate_arbo, GETPOST('memcats', 'array'), null, null, null, null, '100%'); print "</td></tr>"; @@ -1073,7 +1073,7 @@ else // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; //Hooks here - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1087,13 +1087,13 @@ else print '<div class="center">'; print '<input type="submit" name="button" class="button" value="'.$langs->trans("AddMember").'">'; print '  '; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">'; } else { - print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; + print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; } print '</div>'; @@ -1108,11 +1108,11 @@ else * ********************************************/ - $res=$object->fetch($id); + $res = $object->fetch($id); if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); if ($res < 0) { dol_print_error($db); exit; } @@ -1121,11 +1121,11 @@ else $adht->fetch($object->typeid); // We set country_id, and country_code, country of the chosen country - $country=GETPOST('country', 'int'); + $country = GETPOST('country', 'int'); if (!empty($country) || $object->country_id) { - $sql = "SELECT rowid, code, label from ".MAIN_DB_PREFIX."c_country where rowid = ".(!empty($country)?$country:$object->country_id); - $resql=$db->query($sql); + $sql = "SELECT rowid, code, label from ".MAIN_DB_PREFIX."c_country where rowid = ".(!empty($country) ? $country : $object->country_id); + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -1134,9 +1134,9 @@ else { dol_print_error($db); } - $object->country_id=$obj->rowid; - $object->country_code=$obj->code; - $object->country=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; + $object->country_id = $obj->rowid; + $object->country_code = $obj->code; + $object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; } $head = member_prepare_head($object); @@ -1190,26 +1190,26 @@ else // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="login" class="minwidth300" maxlength="50" value="'.(isset($_POST["login"])?GETPOST("login", 'alpha', 2):$object->login).'"></td></tr>'; + print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="login" class="minwidth300" maxlength="50" value="'.(isset($_POST["login"]) ?GETPOST("login", 'alpha', 2) : $object->login).'"></td></tr>'; } // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td><td><input type="password" name="pass" class="minwidth300" maxlength="50" value="'.(isset($_POST["pass"])?GETPOST("pass", '', 2):$object->pass).'"></td></tr>'; + print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td><td><input type="password" name="pass" class="minwidth300" maxlength="50" value="'.(isset($_POST["pass"]) ?GETPOST("pass", '', 2) : $object->pass).'"></td></tr>'; } // Morphy $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberNature").'</span></td><td>'; - print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy")?GETPOST("morphy", 'alpha'):$object->morphy)); + print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy") ?GETPOST("morphy", 'alpha') : $object->morphy)); print "</td></tr>"; // Type print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>'; if ($user->rights->adherent->creer) { - print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid")?GETPOST("typeid", 'int'):$object->typeid)); + print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ?GETPOST("typeid", 'int') : $object->typeid)); } else { @@ -1219,27 +1219,27 @@ else print "</td></tr>"; // Company - print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(isset($_POST["societe"])?GETPOST("societe", '', 2):$object->company).'"></td></tr>'; + print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(isset($_POST["societe"]) ?GETPOST("societe", '', 2) : $object->company).'"></td></tr>'; // Civility print '<tr><td>'.$langs->trans("UserTitle").'</td><td>'; - print $formcompany->select_civility(isset($_POST["civility_id"])?$_POST["civility_id"]:$object->civility_id)."\n"; + print $formcompany->select_civility(isset($_POST["civility_id"]) ? $_POST["civility_id"] : $object->civility_id)."\n"; print '</td>'; print '</tr>'; // Lastname - print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="minwidth300" maxlength="50" value="'.(isset($_POST["lastname"])?GETPOST("lastname", '', 2):$object->lastname).'"></td>'; + print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="minwidth300" maxlength="50" value="'.(isset($_POST["lastname"]) ?GETPOST("lastname", '', 2) : $object->lastname).'"></td>'; print '</tr>'; // Firstname - print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="minwidth300" maxlength="50" value="'.(isset($_POST["firstname"])?GETPOST("firstname", '', 3):$object->firstname).'"></td>'; + print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="minwidth300" maxlength="50" value="'.(isset($_POST["firstname"]) ?GETPOST("firstname", '', 3) : $object->firstname).'"></td>'; print '</tr>'; // Gender print '<tr><td>'.$langs->trans("Gender").'</td>'; print '<td>'; - $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); - print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1); + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); print '</td></tr>'; // Photo @@ -1258,24 +1258,24 @@ else print '</td></tr>'; // EMail - print '<tr><td>'.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(isset($_POST["member_email"])?GETPOST("member_email", '', 2):$object->email).'"></td></tr>'; + print '<tr><td>'.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED ? '<span class="fieldrequired">' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '</span>' : '').'</td><td><input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(isset($_POST["member_email"]) ?GETPOST("member_email", '', 2) : $object->email).'"></td></tr>'; // Address print '<tr><td>'.$langs->trans("Address").'</td><td>'; - print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.'">'.(isset($_POST["address"])?GETPOST("address", '', 2):$object->address).'</textarea>'; + print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.'">'.(isset($_POST["address"]) ?GETPOST("address", '', 2) : $object->address).'</textarea>'; print '</td></tr>'; // Zip / Town print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>'; - print $formcompany->select_ziptown((isset($_POST["zipcode"])?GETPOST("zipcode", '', 2):$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6); + print $formcompany->select_ziptown((isset($_POST["zipcode"]) ?GETPOST("zipcode", '', 2) : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print ' '; - print $formcompany->select_ziptown((isset($_POST["town"])?GETPOST("town", '', 2):$object->town), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((isset($_POST["town"]) ?GETPOST("town", '', 2) : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '</td></tr>'; // Country //$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined print '<tr><td>'.$langs->trans('Country').'</td><td>'; - print $form->select_country(isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id, 'country_id'); + print $form->select_country(isset($_POST["country_id"]) ? $_POST["country_id"] : $object->country_id, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '</td></tr>'; @@ -1283,23 +1283,23 @@ else if (empty($conf->global->MEMBER_DISABLE_STATE)) { print '<tr><td>'.$langs->trans('State').'</td><td>'; - print $formcompany->select_state($object->state_id, isset($_POST["country_id"])?GETPOST("country_id"):$object->country_id); + print $formcompany->select_state($object->state_id, isset($_POST["country_id"]) ?GETPOST("country_id") : $object->country_id); print '</td></tr>'; } // Pro phone - print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(isset($_POST["phone"])?GETPOST("phone"):$object->phone).'"></td></tr>'; + print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(isset($_POST["phone"]) ?GETPOST("phone") : $object->phone).'"></td></tr>'; // Personal phone - print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(isset($_POST["phone_perso"])?GETPOST("phone_perso"):$object->phone_perso).'"></td></tr>'; + print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(isset($_POST["phone_perso"]) ?GETPOST("phone_perso") : $object->phone_perso).'"></td></tr>'; // Mobile phone - print '<tr><td>'.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(isset($_POST["phone_mobile"])?GETPOST("phone_mobile"):$object->phone_mobile).'"></td></tr>'; + print '<tr><td>'.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(isset($_POST["phone_mobile"]) ?GETPOST("phone_mobile") : $object->phone_mobile).'"></td></tr>'; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if (!$value['active']) break; - print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="'.$key.'" class="minwidth100" value="'.(isset($_POST[$key])?GETPOST($key):$object->socialnetworks[$key]).'"></td></tr>'; + print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="'.$key.'" class="minwidth100" value="'.(isset($_POST[$key]) ?GETPOST($key) : $object->socialnetworks[$key]).'"></td></tr>'; } } @@ -1310,13 +1310,13 @@ else // Public profil print "<tr><td>".$langs->trans("Public")."</td><td>\n"; - print $form->selectyesno("public", (isset($_POST["public"])?GETPOST("public", '', 2):$object->public), 1); + print $form->selectyesno("public", (isset($_POST["public"]) ?GETPOST("public", '', 2) : $object->public), 1); print "</td></tr>\n"; // Categories - if (! empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print '<tr><td>' . $form->editfieldkey("Categories", 'memcats', '', $object, 0) . '</td>'; + print '<tr><td>'.$form->editfieldkey("Categories", 'memcats', '', $object, 0).'</td>'; print '<td>'; $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1); $c = new Categorie($db); @@ -1332,13 +1332,13 @@ else } // Third party Dolibarr - if (! empty($conf->societe->enabled)) + if (!empty($conf->societe->enabled)) { print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td colspan="2" class="valeur">'; if ($object->socid) { - $company=new Societe($db); - $result=$company->fetch($object->socid); + $company = new Societe($db); + $result = $company->fetch($object->socid); print $company->getNomUrl(1); } else @@ -1380,17 +1380,17 @@ else /* */ /* ************************************************************************** */ - $res=$object->fetch($id); + $res = $object->fetch($id); if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); if ($res < 0) { dol_print_error($db); exit; } $adht = new AdherentType($db); - $res=$adht->fetch($object->typeid); + $res = $adht->fetch($object->typeid); if ($res < 0) { dol_print_error($db); exit; } @@ -1406,24 +1406,24 @@ else // Confirm create user if ($action == 'create_user') { - $login=$object->login; + $login = $object->login; if (empty($login)) { // Full firstname and name separated with a dot : firstname.name include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $login=dol_buildlogin($object->lastname, $object->firstname); + $login = dol_buildlogin($object->lastname, $object->firstname); } - if (empty($login)) $login=strtolower(substr($object->firstname, 0, 4)) . strtolower(substr($object->lastname, 0, 4)); + if (empty($login)) $login = strtolower(substr($object->firstname, 0, 4)).strtolower(substr($object->lastname, 0, 4)); // Create a form array - $formquestion=array( + $formquestion = array( array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login) ); - $text=$langs->trans("ConfirmCreateLogin").'<br>'; - if (! empty($conf->societe->enabled)) + $text = $langs->trans("ConfirmCreateLogin").'<br>'; + if (!empty($conf->societe->enabled)) { - if ($object->socid > 0) $text.=$langs->trans("UserWillBeExternalUser"); - else $text.=$langs->trans("UserWillBeInternalUser"); + if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser"); + else $text .= $langs->trans("UserWillBeInternalUser"); } print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); } @@ -1431,22 +1431,22 @@ else // Confirm create third party if ($action == 'create_thirdparty') { - $companyalias=''; + $companyalias = ''; $fullname = $object->getFullName($langs); if ($object->morphy == 'mor') { - $companyname=$object->company; - if (! empty($fullname)) $companyalias=$fullname; + $companyname = $object->company; + if (!empty($fullname)) $companyalias = $fullname; } else { - $companyname=$fullname; - if (! empty($object->company)) $companyalias=$object->company; + $companyname = $fullname; + if (!empty($object->company)) $companyalias = $object->company; } // Create a form array - $formquestion=array( + $formquestion = array( array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'), array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"') ); @@ -1463,54 +1463,54 @@ else $adht->fetch($object->typeid); $subject = ''; - $msg= ''; + $msg = ''; // Send subscription email include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail=new FormMail($db); + $formmail = new FormMail($db); // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template - $arraydefaultmessage=null; + $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION; - if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; } - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); - $tmp=$langs->trans("SendingAnEMailToMember"); - $tmp.='<br>'.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, '; - $tmp.='<br>'.$langs->trans("MailRecipient").': <b>'.$object->email.'</b>'; - $helpcontent=''; - $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n"; - $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n"; - $helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n"; - $helpcontent.=$subjecttosend."\n"; - $helpcontent.="<br>"; - $helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>'; - $helpcontent.=dol_htmlentitiesbr($texttosend)."\n"; - $label=$form->textwithpicto($tmp, $helpcontent, 1, 'help'); + $tmp = $langs->trans("SendingAnEMailToMember"); + $tmp .= '<br>'.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, '; + $tmp .= '<br>'.$langs->trans("MailRecipient").': <b>'.$object->email.'</b>'; + $helpcontent = ''; + $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n"; + $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n"; + $helpcontent .= '<b>'.$langs->trans("Subject").'</b>:<br>'."\n"; + $helpcontent .= $subjecttosend."\n"; + $helpcontent .= "<br>"; + $helpcontent .= '<b>'.$langs->trans("Content").'</b>:<br>'; + $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; + $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help'); // Create form popup - $formquestion=array(); - if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false)); - if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_MAILMAN)) { - $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"),'value'=>''); + $formquestion = array(); + if ($object->email) $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL ?true:false)); + if (!empty($conf->mailman->enabled) && !empty($conf->global->ADHERENT_USE_MAILMAN)) { + $formquestion[] = array('type'=>'other', 'label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"), 'value'=>''); } - if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) { - $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>''); + if (!empty($conf->mailman->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) { + $formquestion[] = array('type'=>'other', 'label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"), 'value'=>''); } print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ValidateMember"), $langs->trans("ConfirmValidateMember"), "confirm_valid", $formquestion, 'yes', 1, 220); } @@ -1524,58 +1524,58 @@ else $adht->fetch($object->typeid); $subject = ''; - $msg= ''; + $msg = ''; // Send subscription email include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail=new FormMail($db); + $formmail = new FormMail($db); // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template - $arraydefaultmessage=null; + $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION; - if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; } - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs); - $tmp=$langs->trans("SendingAnEMailToMember"); - $tmp.='<br>('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, '; - $tmp.=$langs->trans("MailRecipient").': <b>'.$object->email.'</b>)'; - $helpcontent=''; - $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n"; - $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n"; - $helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n"; - $helpcontent.=$subjecttosend."\n"; - $helpcontent.="<br>"; - $helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>'; - $helpcontent.=dol_htmlentitiesbr($texttosend)."\n"; - $label=$form->textwithpicto($tmp, $helpcontent, 1, 'help'); + $tmp = $langs->trans("SendingAnEMailToMember"); + $tmp .= '<br>('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, '; + $tmp .= $langs->trans("MailRecipient").': <b>'.$object->email.'</b>)'; + $helpcontent = ''; + $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n"; + $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n"; + $helpcontent .= '<b>'.$langs->trans("Subject").'</b>:<br>'."\n"; + $helpcontent .= $subjecttosend."\n"; + $helpcontent .= "<br>"; + $helpcontent .= '<b>'.$langs->trans("Content").'</b>:<br>'; + $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; + $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help'); // Create an array - $formquestion=array(); - if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false')); - if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); + $formquestion = array(); + if ($object->email) $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? 'true' : 'false')); + if ($backtopage) $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ResiliateMember"), $langs->trans("ConfirmResiliateMember"), "confirm_resign", $formquestion, 'no', 1, 240); } // Confirm remove member if ($action == 'delete') { - $formquestion=array(); - if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); + $formquestion = array(); + if ($backtopage) $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteMember"), $langs->trans("ConfirmDeleteMember"), "confirm_delete", $formquestion, 'no', 1); } @@ -1590,9 +1590,9 @@ else print $form->formconfirm("card.php?rowid=$id", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip'); } - $rowspan=17; + $rowspan = 17; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; - if (! empty($conf->societe->enabled)) $rowspan++; + if (!empty($conf->societe->enabled)) $rowspan++; $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; @@ -1640,10 +1640,10 @@ else if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; else print $langs->trans("Hidden"); } - if ((! empty($object->pass) || ! empty($object->pass_crypted)) && empty($object->user_id)) + if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) { $langs->load("errors"); - $htmltext=$langs->trans("WarningPasswordSetWithNoAccount"); + $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); } print '</td></tr>'; @@ -1664,7 +1664,7 @@ else { print $langs->trans("SubscriptionNotNeeded"); } - elseif (! $adht->subscription) + elseif (!$adht->subscription) { print $langs->trans("SubscriptionNotRecorded"); if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated @@ -1678,7 +1678,7 @@ else print '</td></tr>'; // Third party Dolibarr - if (! empty($conf->societe->enabled)) + if (!empty($conf->societe->enabled)) { print '<tr><td>'; $editenable = $user->rights->adherent->creer; @@ -1686,7 +1686,7 @@ else print '</td><td colspan="2" class="valeur">'; if ($action == 'editthirdparty') { - $htmlname='socid'; + $htmlname = 'socid'; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">'; print '<input type="hidden" name="rowid" value="'.$object->id.'">'; print '<input type="hidden" name="action" value="set'.$htmlname.'">'; @@ -1702,8 +1702,8 @@ else { if ($object->socid) { - $company=new Societe($db); - $result=$company->fetch($object->socid); + $company = new Societe($db); + $result = $company->fetch($object->socid); print $company->getNomUrl(1); } else @@ -1749,16 +1749,16 @@ else print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>'; // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print '<tr><td>' . $langs->trans("Categories") . '</td>'; + print '<tr><td>'.$langs->trans("Categories").'</td>'; print '<td colspan="2">'; print $form->showCategories($object->id, 'member', 1); print '</td></tr>'; } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print "</table>\n"; @@ -1780,7 +1780,7 @@ else { // Send if ($object->statut == 1) { - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>'; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'; } // Send card by email @@ -1853,7 +1853,7 @@ else } // Create third party - if (! empty($conf->societe->enabled) && ! $object->socid) + if (!empty($conf->societe->enabled) && !$object->socid) { if ($user->rights->societe->creer) { @@ -1867,7 +1867,7 @@ else } // Create user - if (! $user->socid && ! $object->user_id) + if (!$user->socid && !$object->user_id) { if ($user->rights->user->user->creer) { @@ -1891,7 +1891,7 @@ else } // Action SPIP - if (! empty($conf->mailmanspip->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) + if (!empty($conf->mailmanspip->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) { $isinspip = $mailmanspip->is_in_spip($object); @@ -1928,8 +1928,8 @@ else $filename = dol_sanitizeFileName($object->ref); //$filename = 'tmp_cards.php'; //$filedir = $conf->adherent->dir_output . '/' . get_exdir($object->id, 2, 0, 0, $object, 'member') . dol_sanitizeFileName($object->ref); - $filedir = $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 0, $object, 'member'); - $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $object->id; + $filedir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'member'); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id; $genallowed = $user->rights->adherent->lire; $delallowed = $user->rights->adherent->creer; @@ -1946,7 +1946,7 @@ else */ // Shon online payment link - $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); if ($useonlinepayment) { @@ -1961,11 +1961,11 @@ else $MAX = 10; $morehtmlright = '<a href="'.DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id.'">'; - $morehtmlright.= $langs->trans("SeeAll"); - $morehtmlright.= '</a>'; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= '</a>'; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright); @@ -1973,8 +1973,8 @@ else } // Presend form - $modelmail='member'; - $defaulttopic='CardContent'; + $modelmail = 'member'; + $defaulttopic = 'CardContent'; $diroutput = $conf->adherent->dir_output; $trackid = 'mem'.$object->id; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index b8db7593ef8..45fe792c81a 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -78,54 +78,54 @@ if ($action == 'add' && ! empty($permissiontoadd)) } } - if (! $error) + if (!$error) { - $result=$object->create($user); + $result = $object->create($user); if ($result > 0) { // Creation OK $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation + $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation header("Location: ".$urltogo); exit; } else { // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); else setEventMessages($object->error, null, 'errors'); - $action='create'; + $action = 'create'; } } else { - $action='create'; + $action = 'create'; } } // Action to update record -if ($action == 'update' && ! empty($permissiontoadd)) +if ($action == 'update' && !empty($permissiontoadd)) { foreach ($object->fields as $key => $val) { - if (! GETPOSTISSET($key)) continue; // The field was not submited to be edited - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields + if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields // Set value to update if (in_array($object->fields[$key]['type'], array('text', 'html'))) { $value = GETPOST($key, 'none'); - } elseif ($object->fields[$key]['type']=='date') { + } elseif ($object->fields[$key]['type'] == 'date') { $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); - } elseif ($object->fields[$key]['type']=='datetime') { + } elseif ($object->fields[$key]['type'] == 'datetime') { $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); } elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) { $value = price2num(GETPOST($key)); } else { $value = GETPOST($key, 'alpha'); } - if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field - if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field + if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field + if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field - $object->$key=$value; + $object->$key = $value; if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) { $error++; @@ -133,28 +133,28 @@ if ($action == 'update' && ! empty($permissiontoadd)) } } - if (! $error) + if (!$error) { - $result=$object->update($user); + $result = $object->update($user); if ($result > 0) { - $action='view'; + $action = 'view'; } else { // Creation KO setEventMessages($object->error, $object->errors, 'errors'); - $action='edit'; + $action = 'edit'; } } else { - $action='edit'; + $action = 'edit'; } } // Action to update one extrafield -if ($action == "update_extras" && ! empty($permissiontoadd)) +if ($action == "update_extras" && !empty($permissiontoadd)) { $object->fetch(GETPOST('id', 'int')); @@ -162,7 +162,7 @@ if ($action == "update_extras" && ! empty($permissiontoadd)) $attributekeylong = 'options_'.$attributekey; $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, ' alpha'); - $result = $object->insertExtraFields(empty($triggermodname)?'':$triggermodname, $user); + $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); if ($result > 0) { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); @@ -176,15 +176,15 @@ if ($action == "update_extras" && ! empty($permissiontoadd)) } // Action to delete -if ($action == 'confirm_delete' && ! empty($permissiontodelete)) +if ($action == 'confirm_delete' && !empty($permissiontodelete)) { - if (! ($object->id > 0)) + if (!($object->id > 0)) { dol_print_error('', 'Error, object must be fetched before being deleted'); exit; } - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { // Delete OK @@ -194,13 +194,13 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete)) } else { - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); else setEventMessages($object->error, null, 'errors'); } } // Remove a line -if ($action == 'confirm_deleteline' && $confirm == 'yes' && ! empty($permissiontoadd)) +if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) { $result = $object->deleteline($user, $lineid); if ($result > 0) @@ -216,7 +216,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && ! empty($permissiont { $newlang = $object->thirdparty->default_lang; } - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -248,11 +248,11 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -277,11 +277,11 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -320,11 +320,11 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -337,30 +337,30 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) } // Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd)) +if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) { - if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); // ... - $result=$objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); + $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); if (is_object($result) || $result > 0) { $newid = 0; if (is_object($result)) $newid = $result->id; else $newid = $result; - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object exit; } else { setEventMessages($objectutil->error, $objectutil->errors, 'errors'); - $action=''; + $action = ''; } } } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 05cbcb0ca14..22ba7b66ec8 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -41,13 +41,13 @@ class CMailFile public $sendmode; public $sendsetup; - public $subject; // Topic: Subject of email - public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>'). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). + public $subject; // Topic: Subject of email + public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>'). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain. // Return-Path: Email where to send bounds. - public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) - public $errors_to; // Errors-To: Email where to send errors. + public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) + public $errors_to; // Errors-To: Email where to send errors. public $addr_to; public $addr_cc; public $addr_bcc; @@ -64,10 +64,10 @@ class CMailFile /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; - public $smtps; // Contains SMTPs object (if this method is used) - public $phpmailer; // Contains PHPMailer object (if this method is used) + public $smtps; // Contains SMTPs object (if this method is used) + public $phpmailer; // Contains PHPMailer object (if this method is used) /** * @var string CSS @@ -96,9 +96,9 @@ class CMailFile // Image public $html; public $image_boundary; - public $atleastoneimage=0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). - public $html_images=array(); - public $images_encoded=array(); + public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). + public $html_images = array(); + public $images_encoded = array(); public $image_types = array( 'gif' => 'image/gif', 'jpg' => 'image/jpeg', @@ -162,28 +162,28 @@ class CMailFile { $this->sendmode = $conf->global->MAIN_MAIL_SENDMODE_EMAILING; } - if (empty($this->sendmode)) $this->sendmode=$conf->global->MAIN_MAIL_SENDMODE; - if (empty($this->sendmode)) $this->sendmode='mail'; + if (empty($this->sendmode)) $this->sendmode = $conf->global->MAIN_MAIL_SENDMODE; + if (empty($this->sendmode)) $this->sendmode = 'mail'; // We define end of line (RFC 821). - $this->eol="\r\n"; + $this->eol = "\r\n"; // We define end of line for header fields (RFC 822bis section 2.3 says header must contains \r\n). - $this->eol2="\r\n"; - if (! empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) + $this->eol2 = "\r\n"; + if (!empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) { - $this->eol="\n"; - $this->eol2="\n"; + $this->eol = "\n"; + $this->eol2 = "\n"; $moreinheader = str_replace("\r\n", "\n", $moreinheader); } // On defini mixed_boundary - $this->mixed_boundary = "multipart_x." . time() . ".x_boundary"; + $this->mixed_boundary = "multipart_x.".time().".x_boundary"; // On defini related_boundary - $this->related_boundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); // Force md5 hash (does not contains special chars) + $this->related_boundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); // Force md5 hash (does not contains special chars) // On defini alternative_boundary - $this->alternative_boundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); // Force md5 hash (does not contains special chars) + $this->alternative_boundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); // Force md5 hash (does not contains special chars) dol_syslog("CMailFile::CMailfile: sendmode=".$this->sendmode." charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc, errors_to=$errors_to, trackid=$trackid sendcontext=$sendcontext", LOG_DEBUG); dol_syslog("CMailFile::CMailfile: subject=".$subject.", deliveryreceipt=".$deliveryreceipt.", msgishtml=".$msgishtml, LOG_DEBUG); @@ -191,13 +191,13 @@ class CMailFile if (empty($subject)) { dol_syslog("CMailFile::CMailfile: Try to send an email with empty subject"); - $this->error='ErrorSubjectIsRequired'; + $this->error = 'ErrorSubjectIsRequired'; return; } if (empty($msg)) { dol_syslog("CMailFile::CMailfile: Try to send an email with empty body"); - $msg='.'; // Avoid empty message (with empty message conten show a multipart structure) + $msg = '.'; // Avoid empty message (with empty message conten show a multipart structure) } // Detect if message is HTML (use fast method) @@ -214,21 +214,21 @@ class CMailFile global $dolibarr_main_url_root; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current // Replace relative /viewimage to absolute path $msg = preg_replace('/src="'.preg_quote(DOL_URL_ROOT, '/').'\/viewimage\.php/ims', 'src="'.$urlwithroot.'/viewimage.php', $msg, -1, $nbrep); - if (! empty($conf->global->MAIN_MAIL_FORCE_CONTENT_TYPE_TO_HTML)) $this->msgishtml=1; // To force to send everything with content type html. + if (!empty($conf->global->MAIN_MAIL_FORCE_CONTENT_TYPE_TO_HTML)) $this->msgishtml = 1; // To force to send everything with content type html. // Detect images if ($this->msgishtml) { $this->html = $msg; - if (! empty($conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS)) + if (!empty($conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS)) { $findimg = $this->findHtmlImages($dolibarr_main_data_root.'/medias'); } @@ -240,7 +240,7 @@ class CMailFile { if ($this->html_images[$i]) { - $this->atleastoneimage=1; + $this->atleastoneimage = 1; dol_syslog("CMailFile::CMailfile: html_images[$i]['name']=".$this->html_images[$i]['name'], LOG_DEBUG); } } @@ -254,14 +254,14 @@ class CMailFile { if ($filename_list[$i]) { - $this->atleastonefile=1; + $this->atleastonefile = 1; dol_syslog("CMailFile::CMailfile: filename_list[$i]=".$filename_list[$i].", mimetype_list[$i]=".$mimetype_list[$i]." mimefilename_list[$i]=".$mimefilename_list[$i], LOG_DEBUG); } } } // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc.=($addr_bcc?', ':'').$conf->global->MAIN_MAIL_AUTOCOPY_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; // Action according to choosed sending method if ($this->sendmode == 'mail') @@ -276,17 +276,17 @@ class CMailFile // Define smtp_headers $smtp_headers = $this->write_smtpheaders(); - if (! empty($moreinheader)) $smtp_headers.=$moreinheader; // $moreinheader contains the \r\n + if (!empty($moreinheader)) $smtp_headers .= $moreinheader; // $moreinheader contains the \r\n // Define mime_headers $mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list); - if (! empty($this->html)) + if (!empty($this->html)) { if (!empty($css)) { $this->css = $css; - $this->buildCSS(); // Build a css style (mode = all) into this->styleCSS and this->bodyCSS + $this->buildCSS(); // Build a css style (mode = all) into this->styleCSS and this->bodyCSS } $msg = $this->html; @@ -302,15 +302,15 @@ class CMailFile } // We now define $this->headers and $this->message - $this->headers = $smtp_headers . $mime_headers; + $this->headers = $smtp_headers.$mime_headers; // On nettoie le header pour qu'il ne se termine pas par un retour chariot. // This avoid also empty lines at end that can be interpreted as mail injection by email servers. $this->headers = preg_replace("/([\r\n]+)$/i", "", $this->headers); //$this->message = $this->eol.'This is a message with multiple parts in MIME format.'.$this->eol; $this->message = 'This is a message with multiple parts in MIME format.'.$this->eol; - $this->message.= $text_body . $files_encoded; - $this->message.= "--" . $this->mixed_boundary . "--" . $this->eol; + $this->message .= $text_body.$files_encoded; + $this->message .= "--".$this->mixed_boundary."--".$this->eol; } elseif ($this->sendmode == 'smtps') { @@ -327,9 +327,9 @@ class CMailFile $smtps->setTrackId($trackid); $smtps->setReplyTo($this->getValidAddress($replyto, 0, 1)); - if (! empty($moreinheader)) $smtps->setMoreInHeader($moreinheader); + if (!empty($moreinheader)) $smtps->setMoreInHeader($moreinheader); - if (! empty($this->html)) + if (!empty($this->html)) { if (!empty($css)) { @@ -355,7 +355,7 @@ class CMailFile { foreach ($filename_list as $i => $val) { - $content=file_get_contents($filename_list[$i]); + $content = file_get_contents($filename_list[$i]); $smtps->setAttachment($content, $mimefilename_list[$i], $mimetype_list[$i]); } } @@ -365,7 +365,7 @@ class CMailFile $smtps->setErrorsTo($errors_to); $smtps->setDeliveryReceipt($deliveryreceipt); - $this->smtps=$smtps; + $this->smtps = $smtps; } elseif ($this->sendmode == 'swiftmailer') { @@ -385,8 +385,8 @@ class CMailFile //$this->message = new Swift_SignedMessage(); // Adding a trackid header to a message $headers = $this->message->getHeaders(); - $headers->addTextHeader('X-Dolibarr-TRACKID', $trackid . '@' . $host); - $headerID = time() . '.swiftmailer-dolibarr-' . $trackid . '@' . $host; + $headers->addTextHeader('X-Dolibarr-TRACKID', $trackid.'@'.$host); + $headerID = time().'.swiftmailer-dolibarr-'.$trackid.'@'.$host; $msgid = $headers->get('Message-ID'); $msgid->setId($headerID); $headers->addIdHeader('References', $headerID); @@ -396,12 +396,12 @@ class CMailFile try { $result = $this->message->setSubject($subject); } catch (Exception $e) { - $this->errors[] = $e->getMessage(); + $this->errors[] = $e->getMessage(); } // Set the From address with an associative array //$this->message->setFrom(array('john@doe.com' => 'John Doe')); - if (! empty($from)) { + if (!empty($from)) { try { $result = $this->message->setFrom($this->getArrayAddress($from)); } catch (Exception $e) { @@ -410,7 +410,7 @@ class CMailFile } // Set the To addresses with an associative array - if (! empty($to)) { + if (!empty($to)) { try { $result = $this->message->setTo($this->getArrayAddress($to)); } catch (Exception $e) { @@ -418,7 +418,7 @@ class CMailFile } } - if (! empty($replyto)) { + if (!empty($replyto)) { try { $result = $this->message->SetReplyTo($this->getArrayAddress($replyto)); } catch (Exception $e) { @@ -429,10 +429,10 @@ class CMailFile try { $result = $this->message->setCharSet($conf->file->character_set_client); } catch (Exception $e) { - $this->errors[] = $e->getMessage(); + $this->errors[] = $e->getMessage(); } - if (! empty($this->html)) { + if (!empty($this->html)) { if (!empty($css)) { $this->css = $css; $this->buildCSS(); @@ -474,8 +474,8 @@ class CMailFile } } - if (! empty($addr_cc)) $this->message->setCc($this->getArrayAddress($addr_cc)); - if (! empty($addr_bcc)) $this->message->setBcc($this->getArrayAddress($addr_bcc)); + if (!empty($addr_cc)) $this->message->setCc($this->getArrayAddress($addr_cc)); + if (!empty($addr_bcc)) $this->message->setBcc($this->getArrayAddress($addr_bcc)); //if (! empty($errors_to)) $this->message->setErrorsTo($this->getArrayAddress($errors_to); if (isset($deliveryreceipt) && $deliveryreceipt == 1) $this->message->setReadReceiptTo($this->getArrayAddress($from)); } @@ -495,25 +495,25 @@ class CMailFile */ public function sendfile() { - global $conf,$db,$langs; + global $conf, $db, $langs; - $errorlevel=error_reporting(); + $errorlevel = error_reporting(); //error_reporting($errorlevel ^ E_WARNING); // Desactive warnings - $res=false; + $res = false; if (empty($conf->global->MAIN_DISABLE_ALL_MAILS) || !empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); $hookmanager->initHooks(array('mail')); - $parameters=array(); $action=''; + $parameters = array(); $action = ''; $reshook = $hookmanager->executeHooks('sendMail', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->error = "Error in hook maildao sendMail " . $reshook; - dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR); + $this->error = "Error in hook maildao sendMail ".$reshook; + dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); return $reshook; } @@ -523,23 +523,23 @@ class CMailFile } $sendingmode = $this->sendmode; - if ($this->context == 'emailing' && ! empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') + if ($this->context == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') { // List of sending methods - $listofmethods=array(); - $listofmethods['mail']='PHP mail function'; + $listofmethods = array(); + $listofmethods['mail'] = 'PHP mail function'; //$listofmethods['simplemail']='Simplemail class'; - $listofmethods['smtps']='SMTP/SMTPS socket library'; + $listofmethods['smtps'] = 'SMTP/SMTPS socket library'; // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent. // You ensure that every user is using its own SMTP server when using the mass emailing module. - $linktoadminemailbefore='<a href="'.DOL_URL_ROOT.'/admin/mails.php">'; - $linktoadminemailend='</a>'; + $linktoadminemailbefore = '<a href="'.DOL_URL_ROOT.'/admin/mails.php">'; + $linktoadminemailend = '</a>'; $this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); $this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]); $this->error .= '<br>'.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); $this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']); - if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) + if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) { $this->error .= '<br>'.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); $this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS); @@ -548,52 +548,52 @@ class CMailFile } // Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL - if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL=10; + if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL = 10; $tmparray1 = explode(',', $this->addr_to); if (count($tmparray1) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL) { $this->error = 'Too much recipients in to:'; - dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING); + dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_WARNING); return false; } - if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL=10; + if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL = 10; $tmparray2 = explode(',', $this->addr_cc); if (count($tmparray2) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL) { $this->error = 'Too much recipients in cc:'; - dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING); + dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_WARNING); return false; } - if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL=10; + if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL = 10; $tmparray3 = explode(',', $this->addr_bcc); if (count($tmparray3) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL) { $this->error = 'Too much recipients in bcc:'; - dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING); + dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_WARNING); return false; } - if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL=10; - if ((count($tmparray1)+count($tmparray2)+count($tmparray3)) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL) + if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL = 10; + if ((count($tmparray1) + count($tmparray2) + count($tmparray3)) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL) { $this->error = 'Too much recipients in to:, cc:, bcc:'; - dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING); + dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_WARNING); return false; } - $keyforsmtpserver='MAIN_MAIL_SMTP_SERVER'; - $keyforsmtpport ='MAIN_MAIL_SMTP_PORT'; - $keyforsmtpid ='MAIN_MAIL_SMTPS_ID'; - $keyforsmtppw ='MAIN_MAIL_SMTPS_PW'; - $keyfortls ='MAIN_MAIL_EMAIL_TLS'; - $keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS'; + $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER'; + $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT'; + $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID'; + $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW'; + $keyfortls = 'MAIN_MAIL_EMAIL_TLS'; + $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS'; if ($this->sendcontext == 'emailing' && !empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') { - $keyforsmtpserver='MAIN_MAIL_SMTP_SERVER_EMAILING'; - $keyforsmtpport ='MAIN_MAIL_SMTP_PORT_EMAILING'; - $keyforsmtpid ='MAIN_MAIL_SMTPS_ID_EMAILING'; - $keyforsmtppw ='MAIN_MAIL_SMTPS_PW_EMAILING'; - $keyfortls ='MAIN_MAIL_EMAIL_TLS_EMAILING'; - $keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS_EMAILING'; + $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_EMAILING'; + $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_EMAILING'; + $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_EMAILING'; + $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_EMAILING'; + $keyfortls = 'MAIN_MAIL_EMAIL_TLS_EMAILING'; + $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_EMAILING'; } if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) @@ -620,64 +620,64 @@ class CMailFile } // Force parameters - if (! empty($conf->global->$keyforsmtpserver)) ini_set('SMTP', $conf->global->$keyforsmtpserver); - if (! empty($conf->global->$keyforsmtpport)) ini_set('smtp_port', $conf->global->$keyforsmtpport); + if (!empty($conf->global->$keyforsmtpserver)) ini_set('SMTP', $conf->global->$keyforsmtpserver); + if (!empty($conf->global->$keyforsmtpport)) ini_set('smtp_port', $conf->global->$keyforsmtpport); - $res=true; - if ($res && ! $this->subject) + $res = true; + if ($res && !$this->subject) { - $this->error="Failed to send mail with php mail to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port')."<br>Subject is empty"; + $this->error = "Failed to send mail with php mail to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port')."<br>Subject is empty"; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - $res=false; + $res = false; } - $dest=$this->getValidAddress($this->addr_to, 2); - if ($res && ! $dest) + $dest = $this->getValidAddress($this->addr_to, 2); + if ($res && !$dest) { - $this->error="Failed to send mail with php mail to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port')."<br>Recipient address '$dest' invalid"; + $this->error = "Failed to send mail with php mail to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port')."<br>Recipient address '$dest' invalid"; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - $res=false; + $res = false; } if ($res) { - $additionnalparam = ''; // By default - if (! empty($conf->global->MAIN_MAIL_ALLOW_SENDMAIL_F)) + $additionnalparam = ''; // By default + if (!empty($conf->global->MAIN_MAIL_ALLOW_SENDMAIL_F)) { // le "Return-Path" (retour des messages bounced) dans les header ne fonctionne pas avec tous les MTA // Le forcage de la valeur grace à l'option -f de sendmail est donc possible si la constante MAIN_MAIL_ALLOW_SENDMAIL_F est definie. // Having this variable defined may create problems with some sendmail (option -f refused) // Having this variable not defined may create problems with some other sendmail (option -f required) - $additionnalparam .= ($additionnalparam?' ':'').(! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '-f' . $this->getValidAddress($conf->global->MAIN_MAIL_ERRORS_TO, 2) : ($this->addr_from != '' ? '-f' . $this->getValidAddress($this->addr_from, 2) : '') ); + $additionnalparam .= ($additionnalparam ? ' ' : '').(!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '-f'.$this->getValidAddress($conf->global->MAIN_MAIL_ERRORS_TO, 2) : ($this->addr_from != '' ? '-f'.$this->getValidAddress($this->addr_from, 2) : '')); } - if (! empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_BA)) // To force usage of -ba option. This option tells sendmail to read From: or Sender: to setup sender + if (!empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_BA)) // To force usage of -ba option. This option tells sendmail to read From: or Sender: to setup sender { - $additionnalparam .= ($additionnalparam?' ':'').'-ba'; + $additionnalparam .= ($additionnalparam ? ' ' : '').'-ba'; } - if (! empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_ADDPARAM)) $additionnalparam .= ($additionnalparam?' ':'').'-U '.$additionnalparam; // Use -U to add additionnal params + if (!empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_ADDPARAM)) $additionnalparam .= ($additionnalparam ? ' ' : '').'-U '.$additionnalparam; // Use -U to add additionnal params dol_syslog("CMailFile::sendfile: mail start HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port').", additionnal_parameters=".$additionnalparam, LOG_DEBUG); - $this->message=stripslashes($this->message); + $this->message = stripslashes($this->message); - if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail(); + if (!empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail(); - if (! empty($additionnalparam)) $res = mail($dest, $this->encodetorfc2822($this->subject), $this->message, $this->headers, $additionnalparam); + if (!empty($additionnalparam)) $res = mail($dest, $this->encodetorfc2822($this->subject), $this->message, $this->headers, $additionnalparam); else $res = mail($dest, $this->encodetorfc2822($this->subject), $this->message, $this->headers); - if (! $res) + if (!$res) { $langs->load("errors"); - $this->error="Failed to send mail with php mail"; - $linuxlike=1; - if (preg_match('/^win/i', PHP_OS)) $linuxlike=0; - if (preg_match('/^mac/i', PHP_OS)) $linuxlike=0; - if (! $linuxlike) + $this->error = "Failed to send mail with php mail"; + $linuxlike = 1; + if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; + if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; + if (!$linuxlike) { - $this->error.=" to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port'); // This values are value used only for non linuxlike systems + $this->error .= " to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port'); // This values are value used only for non linuxlike systems } - $this->error.=".<br>"; - $this->error.=$langs->trans("ErrorPhpMailDelivery"); + $this->error .= ".<br>"; + $this->error .= $langs->trans("ErrorPhpMailDelivery"); dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); } else @@ -692,86 +692,86 @@ class CMailFile } // Restore parameters - if (! empty($conf->global->$keyforsmtpserver)) ini_restore('SMTP'); - if (! empty($conf->global->$keyforsmtpport)) ini_restore('smtp_port'); + if (!empty($conf->global->$keyforsmtpserver)) ini_restore('SMTP'); + if (!empty($conf->global->$keyforsmtpport)) ini_restore('smtp_port'); } elseif ($this->sendmode == 'smtps') { - if (! is_object($this->smtps)) + if (!is_object($this->smtps)) { - $this->error="Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."<br>Constructor of object CMailFile was not initialized without errors."; + $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."<br>Constructor of object CMailFile was not initialized without errors."; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); return false; } // Use SMTPS library // ------------------------------------------ - $this->smtps->setTransportType(0); // Only this method is coded in SMTPs library + $this->smtps->setTransportType(0); // Only this method is coded in SMTPs library // Clean parameters - if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver=ini_get('SMTP'); - if (empty($conf->global->$keyforsmtpport)) $conf->global->$keyforsmtpport=ini_get('smtp_port'); + if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver = ini_get('SMTP'); + if (empty($conf->global->$keyforsmtpport)) $conf->global->$keyforsmtpport = ini_get('smtp_port'); // If we use SSL/TLS - $server=$conf->global->$keyforsmtpserver; - $secure=''; - if (! empty($conf->global->$keyfortls) && function_exists('openssl_open')) $secure='ssl'; - if (! empty($conf->global->$keyforstarttls) && function_exists('openssl_open')) $secure='tls'; - $server=($secure?$secure.'://':'').$server; + $server = $conf->global->$keyforsmtpserver; + $secure = ''; + if (!empty($conf->global->$keyfortls) && function_exists('openssl_open')) $secure = 'ssl'; + if (!empty($conf->global->$keyforstarttls) && function_exists('openssl_open')) $secure = 'tls'; + $server = ($secure ? $secure.'://' : '').$server; - $port=$conf->global->$keyforsmtpport; + $port = $conf->global->$keyforsmtpport; $this->smtps->setHost($server); $this->smtps->setPort($port); // 25, 465...; - $loginid=''; $loginpass=''; - if (! empty($conf->global->$keyforsmtpid)) + $loginid = ''; $loginpass = ''; + if (!empty($conf->global->$keyforsmtpid)) { $loginid = $conf->global->$keyforsmtpid; $this->smtps->setID($loginid); } - if (! empty($conf->global->$keyforsmtppw)) + if (!empty($conf->global->$keyforsmtppw)) { $loginpass = $conf->global->$keyforsmtppw; $this->smtps->setPW($loginpass); } - $res=true; - $from=$this->smtps->getFrom('org'); - if ($res && ! $from) + $res = true; + $from = $this->smtps->getFrom('org'); + if ($res && !$from) { - $this->error="Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."<br>Sender address '$from' invalid"; + $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."<br>Sender address '$from' invalid"; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - $res=false; + $res = false; } - $dest=$this->smtps->getTo(); - if ($res && ! $dest) + $dest = $this->smtps->getTo(); + if ($res && !$dest) { - $this->error="Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."<br>Recipient address '$dest' invalid"; + $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."<br>Recipient address '$dest' invalid"; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - $res=false; + $res = false; } if ($res) { - if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->smtps->setDebug(true); + if (!empty($conf->global->MAIN_MAIL_DEBUG)) $this->smtps->setDebug(true); - $result=$this->smtps->sendMsg(); + $result = $this->smtps->sendMsg(); //print $result; - if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail(); + if (!empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail(); - $result=$this->smtps->getErrors(); + $result = $this->smtps->getErrors(); if (empty($this->error) && empty($result)) { dol_syslog("CMailFile::sendfile: mail end success", LOG_DEBUG); - $res=true; + $res = true; } else { - if (empty($this->error)) $this->error=$result; + if (empty($this->error)) $this->error = $result; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - $res=false; + $res = false; } } } @@ -782,19 +782,19 @@ class CMailFile require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; // Clean parameters - if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver=ini_get('SMTP'); - if (empty($conf->global->$keyforsmtpport)) $conf->global->$keyforsmtpport=ini_get('smtp_port'); + if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver = ini_get('SMTP'); + if (empty($conf->global->$keyforsmtpport)) $conf->global->$keyforsmtpport = ini_get('smtp_port'); // If we use SSL/TLS $server = $conf->global->$keyforsmtpserver; $secure = ''; - if (! empty($conf->global->$keyfortls) && function_exists('openssl_open')) $secure='ssl'; - if (! empty($conf->global->$keyforstarttls) && function_exists('openssl_open')) $secure='tls'; + if (!empty($conf->global->$keyfortls) && function_exists('openssl_open')) $secure = 'ssl'; + if (!empty($conf->global->$keyforstarttls) && function_exists('openssl_open')) $secure = 'tls'; $this->transport = new Swift_SmtpTransport($server, $conf->global->$keyforsmtpport, $secure); - if (! empty($conf->global->$keyforsmtpid)) $this->transport->setUsername($conf->global->$keyforsmtpid); - if (! empty($conf->global->$keyforsmtppw)) $this->transport->setPassword($conf->global->$keyforsmtppw); + if (!empty($conf->global->$keyforsmtpid)) $this->transport->setUsername($conf->global->$keyforsmtpid); + if (!empty($conf->global->$keyforsmtppw)) $this->transport->setPassword($conf->global->$keyforsmtppw); //$smtps->_msgReplyTo = 'reply@web.com'; // Create the Mailer using your created Transport @@ -809,7 +809,7 @@ class CMailFile $this->message->attachSigner($signer->ignoreHeader('Return-Path')); } - if (! empty($conf->global->MAIN_MAIL_DEBUG)) { + if (!empty($conf->global->MAIN_MAIL_DEBUG)) { // To use the ArrayLogger $this->logger = new Swift_Plugins_Loggers_ArrayLogger(); // Or to use the Echo Logger @@ -820,14 +820,14 @@ class CMailFile try { $result = $this->mailer->send($this->message); } catch (Exception $e) { - $this->error = $e->getMessage(); + $this->error = $e->getMessage(); } - if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail(); + if (!empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail(); $res = true; - if (! empty($this->error) || ! $result) { + if (!empty($this->error) || !$result) { dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - $res=false; + $res = false; } else { @@ -842,23 +842,23 @@ class CMailFile return 'Bad value for sendmode'; } - $parameters=array(); $action=''; + $parameters = array(); $action = ''; $reshook = $hookmanager->executeHooks('sendMailAfter', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->error = "Error in hook maildao sendMailAfter " . $reshook; - dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR); + $this->error = "Error in hook maildao sendMailAfter ".$reshook; + dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); return $reshook; } } else { - $this->error='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + $this->error = 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; dol_syslog("CMailFile::sendfile: ".$this->error, LOG_WARNING); } - error_reporting($errorlevel); // Reactive niveau erreur origine + error_reporting($errorlevel); // Reactive niveau erreur origine return $res; } @@ -885,17 +885,17 @@ class CMailFile private function _encode_file($sourcefile) { // phpcs:enable - $newsourcefile=dol_osencode($sourcefile); + $newsourcefile = dol_osencode($sourcefile); if (is_readable($newsourcefile)) { - $contents = file_get_contents($newsourcefile); // Need PHP 4.3 - $encoded = chunk_split(base64_encode($contents), 76, $this->eol); // 76 max is defined into http://tools.ietf.org/html/rfc2047 + $contents = file_get_contents($newsourcefile); // Need PHP 4.3 + $encoded = chunk_split(base64_encode($contents), 76, $this->eol); // 76 max is defined into http://tools.ietf.org/html/rfc2047 return $encoded; } else { - $this->error="Error: Can't read file '".$sourcefile."' into _encode_file"; + $this->error = "Error: Can't read file '".$sourcefile."' into _encode_file"; dol_syslog("CMailFile::encode_file: ".$this->error, LOG_ERR); return -1; } @@ -913,30 +913,30 @@ class CMailFile public function dump_mail() { // phpcs:enable - global $conf,$dolibarr_main_data_root; + global $conf, $dolibarr_main_data_root; if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir { - $outputfile=$dolibarr_main_data_root."/dolibarr_mail.log"; + $outputfile = $dolibarr_main_data_root."/dolibarr_mail.log"; $fp = fopen($outputfile, "w"); if ($this->sendmode == 'mail') { fputs($fp, $this->headers); - fputs($fp, $this->eol); // This eol is added by the mail function, so we add it in log + fputs($fp, $this->eol); // This eol is added by the mail function, so we add it in log fputs($fp, $this->message); } elseif ($this->sendmode == 'smtps') { - fputs($fp, $this->smtps->log); // this->smtps->log is filled only if MAIN_MAIL_DEBUG was set to on + fputs($fp, $this->smtps->log); // this->smtps->log is filled only if MAIN_MAIL_DEBUG was set to on } elseif ($this->sendmode == 'swiftmailer') { - fputs($fp, $this->logger->dump()); // this->logger is filled only if MAIN_MAIL_DEBUG was set to on + fputs($fp, $this->logger->dump()); // this->logger is filled only if MAIN_MAIL_DEBUG was set to on } fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); } } @@ -953,12 +953,12 @@ class CMailFile if (!preg_match('/^[\s\t]*<html/i', $msg)) { $out = "<html><head><title>"; - if (!empty($this->styleCSS)) $out.= $this->styleCSS; - $out.= "bodyCSS)) $out.= $this->bodyCSS; - $out.= ">"; - $out.= $msg; - $out.= ""; + if (!empty($this->styleCSS)) $out .= $this->styleCSS; + $out .= "bodyCSS)) $out .= $this->bodyCSS; + $out .= ">"; + $out .= $msg; + $out .= ""; } else { @@ -975,24 +975,24 @@ class CMailFile */ public function buildCSS() { - if (! empty($this->css)) + if (!empty($this->css)) { // Style CSS $this->styleCSS = ''; + $this->styleCSS .= '}'; + $this->styleCSS .= ''; } } @@ -1013,48 +1013,48 @@ class CMailFile // Sender //$out.= "Sender: ".getValidAddress($this->addr_from,2)).$this->eol2; - $out.= "From: ".$this->getValidAddress($this->addr_from, 3, 1).$this->eol2; - if (! empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_BA)) + $out .= "From: ".$this->getValidAddress($this->addr_from, 3, 1).$this->eol2; + if (!empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_BA)) { - $out.= "To: ".$this->getValidAddress($this->addr_to, 0, 1).$this->eol2; + $out .= "To: ".$this->getValidAddress($this->addr_to, 0, 1).$this->eol2; } // Return-Path is important because it is used by SPF. Some MTA does not read Return-Path from header but from command line. See option MAIN_MAIL_ALLOW_SENDMAIL_F for that. - $out.= "Return-Path: ".$this->getValidAddress($this->addr_from, 0, 1).$this->eol2; - if (isset($this->reply_to) && $this->reply_to) $out.= "Reply-To: ".$this->getValidAddress($this->reply_to, 2).$this->eol2; - if (isset($this->errors_to) && $this->errors_to) $out.= "Errors-To: ".$this->getValidAddress($this->errors_to, 2).$this->eol2; + $out .= "Return-Path: ".$this->getValidAddress($this->addr_from, 0, 1).$this->eol2; + if (isset($this->reply_to) && $this->reply_to) $out .= "Reply-To: ".$this->getValidAddress($this->reply_to, 2).$this->eol2; + if (isset($this->errors_to) && $this->errors_to) $out .= "Errors-To: ".$this->getValidAddress($this->errors_to, 2).$this->eol2; // Receiver - if (isset($this->addr_cc) && $this->addr_cc) $out.= "Cc: ".$this->getValidAddress($this->addr_cc, 2).$this->eol2; - if (isset($this->addr_bcc) && $this->addr_bcc) $out.= "Bcc: ".$this->getValidAddress($this->addr_bcc, 2).$this->eol2; // TODO Question: bcc must not be into header, only into SMTP command "RCPT TO". Does php mail support this ? + if (isset($this->addr_cc) && $this->addr_cc) $out .= "Cc: ".$this->getValidAddress($this->addr_cc, 2).$this->eol2; + if (isset($this->addr_bcc) && $this->addr_bcc) $out .= "Bcc: ".$this->getValidAddress($this->addr_bcc, 2).$this->eol2; // TODO Question: bcc must not be into header, only into SMTP command "RCPT TO". Does php mail support this ? // Delivery receipt - if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $out.= "Disposition-Notification-To: ".$this->getValidAddress($this->addr_from, 2).$this->eol2; + if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $out .= "Disposition-Notification-To: ".$this->getValidAddress($this->addr_from, 2).$this->eol2; //$out.= "X-Priority: 3".$this->eol2; - $out.= 'Date: ' . date("r") . $this->eol2; + $out .= 'Date: '.date("r").$this->eol2; $trackid = $this->trackid; if ($trackid) { // References is kept in response and Message-ID is returned into In-Reply-To: - $out.= 'Message-ID: <' . time() . '.phpmail-dolibarr-'. $trackid . '@' . $host . ">" . $this->eol2; // Uppercase seems replaced by phpmail - $out.= 'References: <' . time() . '.phpmail-dolibarr-'. $trackid . '@' . $host . ">" . $this->eol2; - $out.= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host. $this->eol2; + $out .= 'Message-ID: <'.time().'.phpmail-dolibarr-'.$trackid.'@'.$host.">".$this->eol2; // Uppercase seems replaced by phpmail + $out .= 'References: <'.time().'.phpmail-dolibarr-'.$trackid.'@'.$host.">".$this->eol2; + $out .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host.$this->eol2; } else { - $out.= 'Message-ID: <' . time() . '.phpmail@' . $host . ">" . $this->eol2; + $out .= 'Message-ID: <'.time().'.phpmail@'.$host.">".$this->eol2; } - if (! empty($_SERVER['REMOTE_ADDR'])) $out.= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. $this->eol2; - $out.= "X-Mailer: Dolibarr version " . DOL_VERSION ." (using php mail)".$this->eol2; - $out.= "Mime-Version: 1.0".$this->eol2; + if (!empty($_SERVER['REMOTE_ADDR'])) $out .= "X-RemoteAddr: ".$_SERVER['REMOTE_ADDR'].$this->eol2; + $out .= "X-Mailer: Dolibarr version ".DOL_VERSION." (using php mail)".$this->eol2; + $out .= "Mime-Version: 1.0".$this->eol2; //$out.= "From: ".$this->getValidAddress($this->addr_from,3,1).$this->eol; - $out.= "Content-Type: multipart/mixed;".$this->eol2." boundary=\"".$this->mixed_boundary."\"".$this->eol2; - $out.= "Content-Transfer-Encoding: 8bit".$this->eol2; // TODO Seems to be ignored. Header is 7bit once received. + $out .= "Content-Type: multipart/mixed;".$this->eol2." boundary=\"".$this->mixed_boundary."\"".$this->eol2; + $out .= "Content-Transfer-Encoding: 8bit".$this->eol2; // TODO Seems to be ignored. Header is 7bit once received. dol_syslog("CMailFile::write_smtpheaders smtp_header=\n".$out); return $out; @@ -1072,18 +1072,18 @@ class CMailFile public function write_mimeheaders($filename_list, $mimefilename_list) { // phpcs:enable - $mimedone=0; + $mimedone = 0; $out = ""; if (is_array($filename_list)) { - $filename_list_size=count($filename_list); - for($i=0;$i < $filename_list_size;$i++) + $filename_list_size = count($filename_list); + for ($i = 0; $i < $filename_list_size; $i++) { if ($filename_list[$i]) { if ($mimefilename_list[$i]) $filename_list[$i] = $mimefilename_list[$i]; - $out.= "X-attachments: $filename_list[$i]".$this->eol2; + $out .= "X-attachments: $filename_list[$i]".$this->eol2; } } } @@ -1104,22 +1104,22 @@ class CMailFile // phpcs:enable global $conf; - $out=''; + $out = ''; - $out.= "--" . $this->mixed_boundary . $this->eol; + $out .= "--".$this->mixed_boundary.$this->eol; if ($this->atleastoneimage) { - $out.= "Content-Type: multipart/alternative;".$this->eol." boundary=\"".$this->alternative_boundary."\"".$this->eol; - $out.= $this->eol; - $out.= "--" . $this->alternative_boundary . $this->eol; + $out .= "Content-Type: multipart/alternative;".$this->eol." boundary=\"".$this->alternative_boundary."\"".$this->eol; + $out .= $this->eol; + $out .= "--".$this->alternative_boundary.$this->eol; } // Make RFC821 Compliant, replace bare linefeeds - $strContent = preg_replace("/(?global->MAIN_FIX_FOR_BUGGED_MTA)) + $strContent = preg_replace("/(?global->MAIN_FIX_FOR_BUGGED_MTA)) { - $strContent = preg_replace("/\r\n/si", "\n", $strContent); // PCRE modifier /s means new lines are common chars + $strContent = preg_replace("/\r\n/si", "\n", $strContent); // PCRE modifier /s means new lines are common chars } $strContentAltText = ''; @@ -1128,7 +1128,7 @@ class CMailFile // Similar code to forge a text from html is also in smtps.class.php $strContentAltText = preg_replace("/]*>/", " ", $strContent); $strContentAltText = html_entity_decode(strip_tags($strContentAltText)); - $strContentAltText = trim(wordwrap($strContentAltText, 75, empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)?"\r\n":"\n")); + $strContentAltText = trim(wordwrap($strContentAltText, 75, empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA) ? "\r\n" : "\n")); // Check if html header already in message, if not complete the message $strContent = $this->checkIfHTML($strContent); @@ -1137,57 +1137,57 @@ class CMailFile // Make RFC2045 Compliant, split lines //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content // TODO Encode main content into base64 and use the chunk_split, or quoted-printable - $strContent = rtrim(wordwrap($strContent, 75, empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)?"\r\n":"\n")); // TODO Using this method creates unexpected line break on text/plain content. + $strContent = rtrim(wordwrap($strContent, 75, empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA) ? "\r\n" : "\n")); // TODO Using this method creates unexpected line break on text/plain content. if ($this->msgishtml) { if ($this->atleastoneimage) { - $out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; + $out .= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; //$out.= "Content-Transfer-Encoding: 7bit".$this->eol; - $out.= $this->eol.($strContentAltText?$strContentAltText:strip_tags($strContent)).$this->eol; // Add plain text message - $out.= "--" . $this->alternative_boundary . $this->eol; - $out.= "Content-Type: multipart/related;".$this->eol." boundary=\"".$this->related_boundary."\"".$this->eol; - $out.= $this->eol; - $out.= "--" . $this->related_boundary . $this->eol; + $out .= $this->eol.($strContentAltText ? $strContentAltText : strip_tags($strContent)).$this->eol; // Add plain text message + $out .= "--".$this->alternative_boundary.$this->eol; + $out .= "Content-Type: multipart/related;".$this->eol." boundary=\"".$this->related_boundary."\"".$this->eol; + $out .= $this->eol; + $out .= "--".$this->related_boundary.$this->eol; } - if (! $this->atleastoneimage && $strContentAltText && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part + if (!$this->atleastoneimage && $strContentAltText && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part { - $out.= "Content-Type: multipart/alternative;".$this->eol." boundary=\"".$this->alternative_boundary."\"".$this->eol; - $out.= $this->eol; - $out.= "--" . $this->alternative_boundary . $this->eol; - $out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; + $out .= "Content-Type: multipart/alternative;".$this->eol." boundary=\"".$this->alternative_boundary."\"".$this->eol; + $out .= $this->eol; + $out .= "--".$this->alternative_boundary.$this->eol; + $out .= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; //$out.= "Content-Transfer-Encoding: 7bit".$this->eol; - $out.= $this->eol.$strContentAltText.$this->eol; - $out.= "--" . $this->alternative_boundary . $this->eol; + $out .= $this->eol.$strContentAltText.$this->eol; + $out .= "--".$this->alternative_boundary.$this->eol; } - $out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol; + $out .= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol; //$out.= "Content-Transfer-Encoding: 7bit".$this->eol; // TODO Use base64 - $out.= $this->eol.$strContent.$this->eol; + $out .= $this->eol.$strContent.$this->eol; - if (! $this->atleastoneimage && $strContentAltText && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part + if (!$this->atleastoneimage && $strContentAltText && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part { - $out.= "--" . $this->alternative_boundary . "--". $this->eol; + $out .= "--".$this->alternative_boundary."--".$this->eol; } } else { - $out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; + $out .= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; //$out.= "Content-Transfer-Encoding: 7bit".$this->eol; - $out.= $this->eol.$strContent.$this->eol; + $out .= $this->eol.$strContent.$this->eol; } - $out.= $this->eol; + $out .= $this->eol; // Encode images if ($this->atleastoneimage) { $out .= $this->write_images($this->images_encoded); // always end related and end alternative after inline images - $out .= "--" . $this->related_boundary . "--" . $this->eol; - $out .= $this->eol . "--" . $this->alternative_boundary . "--" . $this->eol; + $out .= "--".$this->related_boundary."--".$this->eol; + $out .= $this->eol."--".$this->alternative_boundary."--".$this->eol; $out .= $this->eol; } @@ -1208,8 +1208,8 @@ class CMailFile // phpcs:enable $out = ''; - $filename_list_size=count($filename_list); - for($i=0;$i < $filename_list_size;$i++) + $filename_list_size = count($filename_list); + for ($i = 0; $i < $filename_list_size; $i++) { if ($filename_list[$i]) { @@ -1218,18 +1218,18 @@ class CMailFile if ($encoded >= 0) { if ($mimefilename_list[$i]) $filename_list[$i] = $mimefilename_list[$i]; - if (! $mimetype_list[$i]) { + if (!$mimetype_list[$i]) { $mimetype_list[$i] = "application/octet-stream"; } - $out.= "--" . $this->mixed_boundary . $this->eol; - $out.= "Content-Disposition: attachment; filename=\"".$filename_list[$i]."\"".$this->eol; - $out.= "Content-Type: " . $mimetype_list[$i] . "; name=\"".$filename_list[$i]."\"".$this->eol; - $out.= "Content-Transfer-Encoding: base64".$this->eol; - $out.= "Content-Description: ".$filename_list[$i].$this->eol; - $out.= $this->eol; - $out.= $encoded; - $out.= $this->eol; + $out .= "--".$this->mixed_boundary.$this->eol; + $out .= "Content-Disposition: attachment; filename=\"".$filename_list[$i]."\"".$this->eol; + $out .= "Content-Type: ".$mimetype_list[$i]."; name=\"".$filename_list[$i]."\"".$this->eol; + $out .= "Content-Transfer-Encoding: base64".$this->eol; + $out .= "Content-Description: ".$filename_list[$i].$this->eol; + $out .= $this->eol; + $out .= $encoded; + $out .= $this->eol; //$out.= $this->eol; } else @@ -1261,14 +1261,14 @@ class CMailFile { dol_syslog("CMailFile::write_images: ".$img["name"]); - $out.= "--" . $this->related_boundary . $this->eol; // always related for an inline image - $out.= "Content-Type: " . $img["content_type"] . "; name=\"".$img["name"]."\"".$this->eol; - $out.= "Content-Transfer-Encoding: base64".$this->eol; - $out.= "Content-Disposition: inline; filename=\"".$img["name"]."\"".$this->eol; - $out.= "Content-ID: <".$img["cid"].">".$this->eol; - $out.= $this->eol; - $out.= $img["image_encoded"]; - $out.= $this->eol; + $out .= "--".$this->related_boundary.$this->eol; // always related for an inline image + $out .= "Content-Type: ".$img["content_type"]."; name=\"".$img["name"]."\"".$this->eol; + $out .= "Content-Transfer-Encoding: base64".$this->eol; + $out .= "Content-Disposition: inline; filename=\"".$img["name"]."\"".$this->eol; + $out .= "Content-ID: <".$img["cid"].">".$this->eol; + $out .= $this->eol; + $out .= $img["image_encoded"]; + $out .= $this->eol; } } @@ -1289,39 +1289,39 @@ class CMailFile // phpcs:enable global $conf; - $_retVal=0; - $timeout=5; // Timeout in seconds + $_retVal = 0; + $timeout = 5; // Timeout in seconds if (function_exists('fsockopen')) { - $keyforsmtpserver='MAIN_MAIL_SMTP_SERVER'; - $keyforsmtpport ='MAIN_MAIL_SMTP_PORT'; - $keyforsmtpid ='MAIN_MAIL_SMTPS_ID'; - $keyforsmtppw ='MAIN_MAIL_SMTPS_PW'; - $keyfortls ='MAIN_MAIL_EMAIL_TLS'; - $keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS'; + $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER'; + $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT'; + $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID'; + $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW'; + $keyfortls = 'MAIN_MAIL_EMAIL_TLS'; + $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS'; if ($this->sendcontext == 'emailing' && !empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') { - $keyforsmtpserver='MAIN_MAIL_SMTP_SERVER_EMAILING'; - $keyforsmtpport ='MAIN_MAIL_SMTP_PORT_EMAILING'; - $keyforsmtpid ='MAIN_MAIL_SMTPS_ID_EMAILING'; - $keyforsmtppw ='MAIN_MAIL_SMTPS_PW_EMAILING'; - $keyfortls ='MAIN_MAIL_EMAIL_TLS_EMAILING'; - $keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS_EMAILING'; + $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_EMAILING'; + $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_EMAILING'; + $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_EMAILING'; + $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_EMAILING'; + $keyfortls = 'MAIN_MAIL_EMAIL_TLS_EMAILING'; + $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_EMAILING'; } // If we use SSL/TLS - if (! empty($conf->global->$keyfortls) && function_exists('openssl_open')) $host='ssl://'.$host; + if (!empty($conf->global->$keyfortls) && function_exists('openssl_open')) $host = 'ssl://'.$host; // tls smtp start with no encryption //if (! empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) && function_exists('openssl_open')) $host='tls://'.$host; dol_syslog("Try socket connection to host=".$host." port=".$port); //See if we can connect to the SMTP server if ($socket = @fsockopen( - $host, // Host to test, IP or domain. Add ssl:// for SSL/TLS. - $port, // which Port number to use - $errno, // actual system level error - $errstr, // and any text that goes with the error + $host, // Host to test, IP or domain. Add ssl:// for SSL/TLS. + $port, // which Port number to use + $errno, // actual system level error + $errstr, // and any text that goes with the error $timeout // timeout for reading/writing data over the socket )) { // Windows still does not have support for this timeout function @@ -1334,7 +1334,7 @@ class CMailFile } else { - $this->error = utf8_check('Error '.$errno.' - '.$errstr)?'Error '.$errno.' - '.$errstr:utf8_encode('Error '.$errno.' - '.$errstr); + $this->error = utf8_check('Error '.$errno.' - '.$errstr) ? 'Error '.$errno.' - '.$errstr : utf8_encode('Error '.$errno.' - '.$errstr); } } return $_retVal; @@ -1352,21 +1352,21 @@ class CMailFile public function server_parse($socket, $response) { // phpcs:enable - $_retVal = true; // Indicates if Object was created or not + $_retVal = true; // Indicates if Object was created or not $server_response = ''; while (substr($server_response, 3, 1) != ' ') { - if (! ($server_response = fgets($socket, 256)) ) + if (!($server_response = fgets($socket, 256))) { - $this->error="Couldn't get mail server response codes"; + $this->error = "Couldn't get mail server response codes"; return false; } } - if( !( substr($server_response, 0, 3) == $response ) ) + if (!(substr($server_response, 0, 3) == $response)) { - $this->error="Ran into problems sending Mail.\r\nResponse: $server_response"; + $this->error = "Ran into problems sending Mail.\r\nResponse: $server_response"; $_retVal = false; } @@ -1385,11 +1385,11 @@ class CMailFile $extensions = array_keys($this->image_types); $matches = array(); - preg_match_all('/(?:"|\')([^"\']+\.('.implode('|', $extensions).'))(?:"|\')/Ui', $this->html, $matches); // If "xxx.ext" or 'xxx.ext' found + preg_match_all('/(?:"|\')([^"\']+\.('.implode('|', $extensions).'))(?:"|\')/Ui', $this->html, $matches); // If "xxx.ext" or 'xxx.ext' found - if (! empty($matches)) + if (!empty($matches)) { - $i=0; + $i = 0; foreach ($matches[1] as $full) { if (preg_match('/file=([A-Za-z0-9_\-\/]+[\.]?[A-Za-z0-9]+)?$/i', $full, $regs)) // If xxx is 'file=aaa' @@ -1410,12 +1410,12 @@ class CMailFile // Content type if (preg_match('/^.+\.(\w{3,4})$/', $img, $reg)) { - $ext=strtolower($reg[1]); + $ext = strtolower($reg[1]); $this->html_images[$i]["content_type"] = $this->image_types[$ext]; } // cid - $this->html_images[$i]["cid"] = dol_hash(uniqid(time()), 3); // Force md5 hash (does not contains special chars) + $this->html_images[$i]["cid"] = dol_hash(uniqid(time()), 3); // Force md5 hash (does not contains special chars) $this->html = preg_replace("/src=\"$src\"|src='$src'/i", "src=\"cid:".$this->html_images[$i]["cid"]."\"", $this->html); } $i++; @@ -1426,7 +1426,7 @@ class CMailFile { $inline = array(); - $i=0; + $i = 0; foreach ($this->html_images as $img) { @@ -1485,13 +1485,13 @@ class CMailFile { global $conf; - $ret=''; + $ret = ''; - $arrayaddress=explode(',', $address); + $arrayaddress = explode(',', $address); // Boucle sur chaque composant de l'adresse - $i=0; - foreach($arrayaddress as $val) + $i = 0; + foreach ($arrayaddress as $val) { if (preg_match('/^(.*)<(.*)>$/i', trim($val), $regs)) { @@ -1508,36 +1508,36 @@ class CMailFile { $i++; - $newemail=''; + $newemail = ''; if ($format == 5) { - $newemail = $name?$name:$email; + $newemail = $name ? $name : $email; $newemail = ''.$newemail.''; } if ($format == 4) { - $newemail = $name?$name:$email; + $newemail = $name ? $name : $email; } if ($format == 2) { - $newemail=$email; + $newemail = $email; } if ($format == 1 || $format == 3) { - $newemail='<'.$email.'>'; + $newemail = '<'.$email.'>'; } if ($format == 0 || $format == 3) { - if (! empty($conf->global->MAIN_MAIL_NO_FULL_EMAIL)) $newemail='<'.$email.'>'; - elseif (! $name) $newemail='<'.$email.'>'; - else $newemail=($format==3?'"':'').($encode?self::encodetorfc2822($name):$name).($format==3?'"':'').' <'.$email.'>'; + if (!empty($conf->global->MAIN_MAIL_NO_FULL_EMAIL)) $newemail = '<'.$email.'>'; + elseif (!$name) $newemail = '<'.$email.'>'; + else $newemail = ($format == 3 ? '"' : '').($encode ?self::encodetorfc2822($name) : $name).($format == 3 ? '"' : '').' <'.$email.'>'; } - $ret=($ret ? $ret.',' : '').$newemail; + $ret = ($ret ? $ret.',' : '').$newemail; // Stop if we have too much records if ($maxnumberofemail && $i >= $maxnumberofemail) { - if (count($arrayaddress) > $maxnumberofemail) $ret.='...'; + if (count($arrayaddress) > $maxnumberofemail) $ret .= '...'; break; } } @@ -1556,12 +1556,12 @@ class CMailFile { global $conf; - $ret=array(); + $ret = array(); - $arrayaddress=explode(',', $address); + $arrayaddress = explode(',', $address); // Boucle sur chaque composant de l'adresse - foreach($arrayaddress as $val) + foreach ($arrayaddress as $val) { if (preg_match('/^(.*)<(.*)>$/i', trim($val), $regs)) { @@ -1574,7 +1574,7 @@ class CMailFile $email = trim($val); } - $ret[$email]=empty($conf->global->MAIN_MAIL_NO_FULL_EMAIL)?$name:null; + $ret[$email] = empty($conf->global->MAIN_MAIL_NO_FULL_EMAIL) ? $name : null; } return $ret; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 258f87d2d9f..5cb869c6817 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -27,48 +27,48 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; -require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmfiles.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/expensereport.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/expensereport/modules_expensereport.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -if (! empty($conf->accounting->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; } // Load translation files required by the page -$langs->loadLangs(array("trips","bills","mails")); +$langs->loadLangs(array("trips", "bills", "mails")); -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int')); $date_end = dol_mktime(0, 0, 0, GETPOST('date_finmonth', 'int'), GETPOST('date_finday', 'int'), GETPOST('date_finyear', 'int')); $date = dol_mktime(0, 0, 0, GETPOST('datemonth', 'int'), GETPOST('dateday', 'int'), GETPOST('dateyear', 'int')); -$fk_project=GETPOST('fk_project', 'int'); -$vatrate=GETPOST('vatrate', 'alpha'); -$ref=GETPOST("ref", 'alpha'); -$comments=GETPOST('comments', 'none'); -$fk_c_type_fees=GETPOST('fk_c_type_fees', 'int'); -$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('socid_id', 'int'); +$fk_project = GETPOST('fk_project', 'int'); +$vatrate = GETPOST('vatrate', 'alpha'); +$ref = GETPOST("ref", 'alpha'); +$comments = GETPOST('comments', 'none'); +$fk_c_type_fees = GETPOST('fk_c_type_fees', 'int'); +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('socid_id', 'int'); $childids = $user->getAllChildIds(1); // Security check -$id=GETPOST("id", 'int'); -if ($user->socid) $socid=$user->socid; +$id = GETPOST("id", 'int'); +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'expensereport', $id, 'expensereport'); @@ -76,38 +76,38 @@ $result = restrictedArea($user, 'expensereport', $id, 'expensereport'); $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; // If multicompany module is enabled, we redefine the root of data -if (! empty($conf->multicompany->enabled) && ! empty($conf->entity) && $conf->entity > 1) +if (!empty($conf->multicompany->enabled) && !empty($conf->entity) && $conf->entity > 1) { - $rootfordata.='/'.$conf->entity; + $rootfordata .= '/'.$conf->entity; } $conf->expensereport->dir_output = $rootfordata.'/expensereport'; // Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current // PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); -$object=new ExpenseReport($db); +$object = new ExpenseReport($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('expensereportcard','globalcard')); +$hookmanager->initHooks(array('expensereportcard', 'globalcard')); -$permissionnote = $user->rights->expensereport->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->expensereport->creer; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->expensereport->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->rights->expensereport->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->expensereport->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->expensereport->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref); @@ -117,9 +117,9 @@ if ($object->id > 0) { // Check current user can read this expense report $canread = 0; - if (! empty($user->rights->expensereport->readall)) $canread=1; - if (! empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) $canread=1; - if (! $canread) + if (!empty($user->rights->expensereport->readall)) $canread = 1; + if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) $canread = 1; + if (!$canread) { accessforbidden(); } @@ -138,43 +138,43 @@ if (empty($reshook)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; - $fk_project=''; - $date_start=''; - $date_end=''; - $date=''; - $comments=''; - $vatrate=''; - $value_unit_ht=''; - $value_unit=''; - $qty=1; - $fk_c_type_fees=-1; + $fk_project = ''; + $date_start = ''; + $date_end = ''; + $date = ''; + $comments = ''; + $vatrate = ''; + $value_unit_ht = ''; + $value_unit = ''; + $qty = 1; + $fk_c_type_fees = -1; } include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if (GETPOSTISSET('sendit')) // If we just submit a file { - if ($action == 'updateline') $action='editline'; // To avoid to make the updateline now - else $action=''; // To avoid to make the addline now + if ($action == 'updateline') $action = 'editline'; // To avoid to make the updateline now + else $action = ''; // To avoid to make the addline now } - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->expensereport->creer) { - if (1==0 && ! GETPOST('clone_content', 'alpha') && ! GETPOST('clone_receivers', 'alpha')) + if (1 == 0 && !GETPOST('clone_content', 'alpha') && !GETPOST('clone_receivers', 'alpha')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } @@ -185,7 +185,7 @@ if (empty($reshook)) // Because createFromClone modifies the object, we must clone it so that we can restore it later if it fails $orig = clone $object; - $result=$object->createFromClone($user, GETPOST('fk_user_author', 'int')); + $result = $object->createFromClone($user, GETPOST('fk_user_author', 'int')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -195,7 +195,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $object = $orig; - $action=''; + $action = ''; } } } @@ -224,32 +224,32 @@ if (empty($reshook)) $object->date_debut = $date_start; $object->date_fin = $date_end; - $object->fk_user_author = GETPOST('fk_user_author', 'int'); - if (! ($object->fk_user_author > 0)) $object->fk_user_author = $user->id; + $object->fk_user_author = GETPOST('fk_user_author', 'int'); + if (!($object->fk_user_author > 0)) $object->fk_user_author = $user->id; - $fuser=new User($db); + $fuser = new User($db); $fuser->fetch($object->fk_user_author); $object->fk_statut = 1; - $object->fk_c_paiement = GETPOST('fk_c_paiement', 'int'); - $object->fk_user_validator = GETPOST('fk_user_validator', 'int'); - $object->note_public = GETPOST('note_public', 'none'); - $object->note_private = GETPOST('note_private', 'none'); + $object->fk_c_paiement = GETPOST('fk_c_paiement', 'int'); + $object->fk_user_validator = GETPOST('fk_user_validator', 'int'); + $object->note_public = GETPOST('note_public', 'none'); + $object->note_private = GETPOST('note_private', 'none'); // Fill array 'array_options' with data from add form - if (! $error) + if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; } - if (! $error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS) && $object->periode_existe($fuser, $object->date_debut, $object->date_fin)) + if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS) && $object->periode_existe($fuser, $object->date_debut, $object->date_fin)) { $error++; setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors'); - $action='create'; + $action = 'create'; } - if (! $error) + if (!$error) { $db->begin(); @@ -259,7 +259,7 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $db->commit(); Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); @@ -269,7 +269,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); - $action='create'; + $action = 'create'; } } } @@ -282,7 +282,7 @@ if (empty($reshook)) $object->date_debut = $date_start; $object->date_fin = $date_end; - if($object->fk_statut < 3) + if ($object->fk_statut < 3) { $object->fk_user_validator = GETPOST('fk_user_validator', 'int'); } @@ -312,7 +312,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('EXPENSEREPORT_MODIFY'); @@ -347,11 +347,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -363,7 +363,7 @@ if (empty($reshook)) $error++; } - if (! $error && $result > 0 && $object->fk_user_validator > 0) + if (!$error && $result > 0 && $object->fk_user_validator > 0) { $langs->load("mails"); @@ -379,11 +379,11 @@ if (empty($reshook)) if ($emailTo && $emailFrom) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportWaitingForApproval"); @@ -409,10 +409,10 @@ if (empty($reshook)) if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); } else @@ -420,9 +420,9 @@ if (empty($reshook)) $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
    '.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
    '.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -434,17 +434,17 @@ if (empty($reshook)) else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } - if (! $error) + if (!$error) { $db->commit(); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); @@ -471,11 +471,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -498,11 +498,11 @@ if (empty($reshook)) if ($emailFrom && $emailTo) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportWaitingForReApproval"); @@ -533,10 +533,10 @@ if (empty($reshook)) if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; @@ -546,9 +546,9 @@ if (empty($reshook)) $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
    '.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
    '.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -560,13 +560,13 @@ if (empty($reshook)) else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } else @@ -592,11 +592,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -614,7 +614,7 @@ if (empty($reshook)) // CC $emailCC = $conf->global->NDF_CC_EMAILS; - if (empty($emailTo)) $emailTo=$emailCC; + if (empty($emailTo)) $emailTo = $emailCC; // FROM $expediteur = new User($db); @@ -623,11 +623,11 @@ if (empty($reshook)) if ($emailFrom && $emailTo) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportApproved"); @@ -655,10 +655,10 @@ if (empty($reshook)) if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; @@ -668,9 +668,9 @@ if (empty($reshook)) $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
    '.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
    '.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -682,23 +682,23 @@ if (empty($reshook)) else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("FailedtoSetToApprove"), null, 'warnings'); - $action=''; + $action = ''; } } - if ($action == "confirm_refuse" && GETPOST('confirm', 'alpha')=="yes" && $id > 0 && $user->rights->expensereport->approve) + if ($action == "confirm_refuse" && GETPOST('confirm', 'alpha') == "yes" && $id > 0 && $user->rights->expensereport->approve) { $object = new ExpenseReport($db); $object->fetch($id); @@ -714,11 +714,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -741,11 +741,11 @@ if (empty($reshook)) if ($emailFrom && $emailTo) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportRefused"); @@ -774,10 +774,10 @@ if (empty($reshook)) if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; @@ -787,9 +787,9 @@ if (empty($reshook)) $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
    '.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
    '.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -801,26 +801,26 @@ if (empty($reshook)) else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("FailedtoSetToDeny"), null, 'warnings'); - $action=''; + $action = ''; } } //var_dump($user->id == $object->fk_user_validator);exit; - if ($action == "confirm_cancel" && GETPOST('confirm', 'alpha')=="yes" && $id > 0 && $user->rights->expensereport->creer) + if ($action == "confirm_cancel" && GETPOST('confirm', 'alpha') == "yes" && $id > 0 && $user->rights->expensereport->creer) { - if (! GETPOST('detail_cancel', 'alpha')) + if (!GETPOST('detail_cancel', 'alpha')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); } @@ -842,11 +842,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -869,11 +869,11 @@ if (empty($reshook)) if ($emailFrom && $emailTo) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportCanceled"); @@ -902,10 +902,10 @@ if (empty($reshook)) if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; @@ -915,9 +915,9 @@ if (empty($reshook)) $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
    '.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
    '.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -929,19 +929,19 @@ if (empty($reshook)) else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("FailedToSetToCancel"), null, 'warnings'); - $action=''; + $action = ''; } } else @@ -951,7 +951,7 @@ if (empty($reshook)) } } - if ($action == "confirm_setdraft" && GETPOST('confirm', 'alpha')=="yes" && $id > 0 && $user->rights->expensereport->creer) + if ($action == "confirm_setdraft" && GETPOST('confirm', 'alpha') == "yes" && $id > 0 && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); $object->fetch($id); @@ -968,11 +968,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1011,11 +1011,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1039,11 +1039,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1067,11 +1067,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1094,11 +1094,11 @@ if (empty($reshook)) if ($emailFrom && $emailTo) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportPaid"); @@ -1116,10 +1116,10 @@ if (empty($reshook)) if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; @@ -1129,9 +1129,9 @@ if (empty($reshook)) $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
    '.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
    '.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -1143,19 +1143,19 @@ if (empty($reshook)) else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("FailedToSetPaid"), null, 'warnings'); - $action=''; + $action = ''; } } @@ -1167,12 +1167,12 @@ if (empty($reshook)) $fk_ecm_files = 0; if (GETPOSTISSET('attachfile')) { - $arrayoffiles=GETPOST('attachfile', 'array'); - if (is_array($arrayoffiles) && ! empty($arrayoffiles[0])) + $arrayoffiles = GETPOST('attachfile', 'array'); + if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) { include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $relativepath='expensereport/'.$object->ref.'/'.$arrayoffiles[0]; - $ecmfiles=new EcmFiles($db); + $relativepath = 'expensereport/'.$object->ref.'/'.$arrayoffiles[0]; + $ecmfiles = new EcmFiles($db); $ecmfiles->fetch(0, '', $relativepath); $fk_ecm_files = $ecmfiles->id; } @@ -1182,8 +1182,8 @@ if (empty($reshook)) if (empty($vatrate)) $vatrate = "0.000"; $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $vatrate)); - $value_unit_ht=price2num(GETPOST('value_unit_ht', 'alpha'), 'MU'); - $value_unit=price2num(GETPOST('value_unit', 'alpha'), 'MU'); + $value_unit_ht = price2num(GETPOST('value_unit_ht', 'alpha'), 'MU'); + $value_unit = price2num(GETPOST('value_unit', 'alpha'), 'MU'); if (empty($value_unit)) { $value_unit = price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100), 'MU'); @@ -1192,24 +1192,24 @@ if (empty($reshook)) $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat', 'int'); $qty = GETPOST('qty', 'int'); - if (empty($qty)) $qty=1; + if (empty($qty)) $qty = 1; - if (! ($fk_c_type_fees > 0)) + if (!($fk_c_type_fees > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $action=''; + $action = ''; } if ((int) $tmpvat < 0 || $tmpvat == '') { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("VAT")), null, 'errors'); - $action=''; + $action = ''; } // Si aucune date n'est rentrée - if (empty($date) || $date=="--") + if (empty($date) || $date == "--") { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); @@ -1227,9 +1227,9 @@ if (empty($reshook)) setEventMessages($langs->trans("WarningDateOfLineMustBeInExpenseReportRange"), null, 'warnings'); } - if (! $error) + if (!$error) { - $type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees + $type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees // Insert line $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files); @@ -1241,9 +1241,9 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = GETPOST('lang_id', 'alpha'); - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) + if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -1265,7 +1265,7 @@ if (empty($reshook)) } } - $action=''; + $action = ''; } if ($action == 'confirm_delete_line' && GETPOST("confirm", 'alpha') == "yes" && $user->rights->expensereport->creer) @@ -1278,7 +1278,7 @@ if (empty($reshook)) $total_ht = $object_ligne->total_ht; $total_tva = $object_ligne->total_tva; - $result=$object->deleteline(GETPOST("rowid", 'int'), $user); + $result = $object->deleteline(GETPOST("rowid", 'int'), $user); if ($result >= 0) { if ($result > 0) @@ -1290,11 +1290,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1320,12 +1320,12 @@ if (empty($reshook)) $fk_ecm_files = 0; if (GETPOSTISSET('attachfile')) { - $arrayoffiles=GETPOST('attachfile', 'array'); - if (is_array($arrayoffiles) && ! empty($arrayoffiles[0])) + $arrayoffiles = GETPOST('attachfile', 'array'); + if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) { include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $relativepath='expensereport/'.$object->ref.'/'.$arrayoffiles[0]; - $ecmfiles=new EcmFiles($db); + $relativepath = 'expensereport/'.$object->ref.'/'.$arrayoffiles[0]; + $ecmfiles = new EcmFiles($db); $ecmfiles->fetch(0, '', $relativepath); $fk_ecm_files = $ecmfiles->id; } @@ -1343,24 +1343,24 @@ if (empty($reshook)) if (empty($vatrate)) $vatrate = "0.000"; $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $vatrate)); - $value_unit_ht=price2num(GETPOST('value_unit_ht', 'alpha'), 'MU'); - $value_unit=price2num(GETPOST('value_unit', 'alpha'), 'MU'); + $value_unit_ht = price2num(GETPOST('value_unit_ht', 'alpha'), 'MU'); + $value_unit = price2num(GETPOST('value_unit', 'alpha'), 'MU'); if (empty($value_unit)) { $value_unit = price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100), 'MU'); } - if (! GETPOST('fk_c_type_fees', 'int') > 0) + if (!GETPOST('fk_c_type_fees', 'int') > 0) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $action=''; + $action = ''; } if ((int) $tmpvat < 0 || $tmpvat == '') { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors'); - $action=''; + $action = ''; } // Warning if date out of range if ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1))) @@ -1369,7 +1369,7 @@ if (empty($reshook)) setEventMessages($langs->trans("WarningDateOfLineMustBeInExpenseReportRange"), null, 'warnings'); } - if (! $error) + if (!$error) { // TODO Use update method of ExpenseReportLine $result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id, $fk_c_exp_tax_cat, $fk_ecm_files); @@ -1384,11 +1384,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1411,9 +1411,9 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='EXPENSEREPORT_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO'; - $trackid='exp'.$object->id; + $trigger_name = 'EXPENSEREPORT_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO'; + $trackid = 'exp'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc @@ -1427,15 +1427,15 @@ if (empty($reshook)) * View */ -$title=$langs->trans("ExpenseReport") . " - " . $langs->trans("Card"); -$helpurl="EN:Module_Expense_Reports"; +$title = $langs->trans("ExpenseReport")." - ".$langs->trans("Card"); +$helpurl = "EN:Module_Expense_Reports"; llxHeader("", $title, $helpurl); $form = new Form($db); $formfile = new FormFile($db); $formproject = new FormProjets($db); $projecttmp = new Project($db); -$paymentexpensereportstatic=new PaymentExpenseReport($db); +$paymentexpensereportstatic = new PaymentExpenseReport($db); $bankaccountstatic = new Account($db); $ecmfilesstatic = new EcmFiles($db); @@ -1457,7 +1457,7 @@ if ($action == 'create') print '
    '; print ''; print ''; print ''; @@ -1465,7 +1465,7 @@ if ($action == 'create') print ''; print ''; print ''; print ''; @@ -1473,11 +1473,11 @@ if ($action == 'create') print ''; print ''; print ''; print ''; @@ -1491,17 +1491,17 @@ if ($action == 'create') if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateExpenseReport"); else { - $defaultselectuser=(empty($user->fk_user_expense_validator) ? $user->fk_user : $user->fk_user_expense_validator); // Will work only if supervisor has permission to approve so is inside include_users - if (! empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; // Can force default approver - if (GETPOST('fk_user_validator', 'int') > 0) $defaultselectuser=GETPOST('fk_user_validator', 'int'); - $s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", ((empty($defaultselectuser) || empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE))?0:1), $include_users); + $defaultselectuser = (empty($user->fk_user_expense_validator) ? $user->fk_user : $user->fk_user_expense_validator); // Will work only if supervisor has permission to approve so is inside include_users + if (!empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser = $conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; // Can force default approver + if (GETPOST('fk_user_validator', 'int') > 0) $defaultselectuser = GETPOST('fk_user_validator', 'int'); + $s = $form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", ((empty($defaultselectuser) || empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE)) ? 0 : 1), $include_users); print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); } print ''; print ''; // Payment mode - if (! empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) + if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { print ''; print ''; @@ -1513,7 +1513,7 @@ if ($action == 'create') // Public note print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; $rowspan = 5; if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) $rowspan++; - elseif($object->fk_statut == ExpenseReport::STATUS_CANCELED) $rowspan+=2; - else $rowspan+=2; - if ($object->fk_statut == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) $rowspan+=2; - if ($object->fk_statut == ExpenseReport::STATUS_CLOSED) $rowspan+=2; + elseif ($object->fk_statut == ExpenseReport::STATUS_CANCELED) $rowspan += 2; + else $rowspan += 2; + if ($object->fk_statut == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) $rowspan += 2; + if ($object->fk_statut == ExpenseReport::STATUS_CLOSED) $rowspan += 2; print ""; print ''; @@ -1978,36 +1978,36 @@ else // List of payments already done $nbcols = 3; - if (! empty($conf->banque->enabled)) { - $nbrows ++; - $nbcols ++; + if (!empty($conf->banque->enabled)) { + $nbrows++; + $nbcols++; } print '
    '.$langs->trans("LastExpenseReports", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllExpenseReports").''.$num.''; print '
    '.$langs->trans("LastExpenseReports", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllExpenseReports").''.$num.'
    '.$langs->trans("DateStart").''; - print $form->selectDate($date_start?$date_start:-1, 'date_debut', 0, 0, 0, '', 1, 1); + print $form->selectDate($date_start ? $date_start : -1, 'date_debut', 0, 0, 0, '', 1, 1); print '
    '.$langs->trans("DateEnd").''; - print $form->selectDate($date_end?$date_end:-1, 'date_fin', 0, 0, 0, '', 1, 1); + print $form->selectDate($date_end ? $date_end : -1, 'date_fin', 0, 0, 0, '', 1, 1); print '
    '.$langs->trans("User").''; - $defaultselectuser=$user->id; - if (GETPOST('fk_user_author', 'int') > 0) $defaultselectuser=GETPOST('fk_user_author', 'int'); + $defaultselectuser = $user->id; + if (GETPOST('fk_user_author', 'int') > 0) $defaultselectuser = GETPOST('fk_user_author', 'int'); $include_users = 'hierarchyme'; - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expensereport->writeall_advance)) $include_users=array(); - $s=$form->select_dolusers($defaultselectuser, "fk_user_author", 0, "", 0, $include_users, '', '0,'.$conf->entity); + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expensereport->writeall_advance)) $include_users = array(); + $s = $form->select_dolusers($defaultselectuser, "fk_user_author", 0, "", 0, $include_users, '', '0,'.$conf->entity); print $s; print '
    '.$langs->trans("ModePaiement").'
    ' . $langs->trans('NotePublic') . ''.$langs->trans('NotePublic').''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); @@ -1523,7 +1523,7 @@ if ($action == 'create') // Private note if (empty($user->socid)) { print '
    ' . $langs->trans('NotePrivate') . ''.$langs->trans('NotePrivate').''; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); @@ -1553,7 +1553,7 @@ if ($action == 'create') } else { - if($id > 0 || $ref) + if ($id > 0 || $ref) { $result = $object->fetch($id, $ref); @@ -1561,7 +1561,7 @@ else if ($result > 0) { - if (! in_array($object->fk_user_author, $user->getAllChildIds(1))) + if (!in_array($object->fk_user_author, $user->getAllChildIds(1))) { if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) @@ -1582,7 +1582,7 @@ else $head = expensereport_prepare_head($object); - if ($action == 'edit' && ($object->fk_statut < 3 || $object->fk_statut==99)) + if ($action == 'edit' && ($object->fk_statut < 3 || $object->fk_statut == 99)) { print "\n"; print ''; @@ -1590,7 +1590,7 @@ else dol_fiche_head($head, 'card', $langs->trans("ExpenseReport"), 0, 'trip'); - if($object->fk_statut==99) + if ($object->fk_statut == 99) { print ''; } @@ -1599,14 +1599,14 @@ else print ''; } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; print ''; print ''; print ''; print ''; print ''; - if (! empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) + if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { print ''; print ''; @@ -1642,13 +1642,13 @@ else print ''; } - if($object->fk_statut<3) + if ($object->fk_statut < 3) { print ''; - print ''; // Approbator + print ''; // Approbator print ''; print ''; @@ -1658,18 +1658,18 @@ else print ''; print ''; print ''; } - if ($object->fk_statut==6) + if ($object->fk_statut == 6) { print ''; print ''; print ''; @@ -1697,70 +1697,70 @@ else // Clone confirmation if ($action == 'clone') { // Create an array for form - $criteriaforfilter='hierarchyme'; - if (! empty($user->rights->expensereport->readall)) $criteriaforfilter=''; + $criteriaforfilter = 'hierarchyme'; + if (!empty($user->rights->expensereport->readall)) $criteriaforfilter = ''; $formquestion = array( 'text' => '', - array('type' => 'other','name' => 'fk_user_author','label' => $langs->trans("SelectTargetUser"),'value' => $form->select_dolusers((GETPOST('fk_user_author', 'int')> 0 ? GETPOST('fk_user_author', 'int') : $user->id), 'fk_user_author', 0, null, 0, $criteriaforfilter)) + array('type' => 'other', 'name' => 'fk_user_author', 'label' => $langs->trans("SelectTargetUser"), 'value' => $form->select_dolusers((GETPOST('fk_user_author', 'int') > 0 ? GETPOST('fk_user_author', 'int') : $user->id), 'fk_user_author', 0, null, 0, $criteriaforfilter)) ); // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneExpenseReport', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneExpenseReport', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } if ($action == 'save') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_validate", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_validate", "", "", 1); } if ($action == 'save_from_refuse') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_save_from_refuse", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_save_from_refuse", "", "", 1); } if ($action == 'delete') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete", "", "", 1); } if ($action == 'validate') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("ValideTrip"), $langs->trans("ConfirmValideTrip"), "confirm_approve", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("ValideTrip"), $langs->trans("ConfirmValideTrip"), "confirm_approve", "", "", 1); } if ($action == 'paid') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("PaidTrip"), $langs->trans("ConfirmPaidTrip"), "confirm_paid", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("PaidTrip"), $langs->trans("ConfirmPaidTrip"), "confirm_paid", "", "", 1); } if ($action == 'cancel') { - $array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text",'label'=>''.$langs->trans("Comment").'','name'=>"detail_cancel",'value'=>"")); - $formconfirm=$form->formconfirm($_SEVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1); + $array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text", 'label'=>''.$langs->trans("Comment").'', 'name'=>"detail_cancel", 'value'=>"")); + $formconfirm = $form->formconfirm($_SEVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1); } if ($action == 'setdraft') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("BrouillonnerTrip"), $langs->trans("ConfirmBrouillonnerTrip"), "confirm_setdraft", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("BrouillonnerTrip"), $langs->trans("ConfirmBrouillonnerTrip"), "confirm_setdraft", "", "", 1); } if ($action == 'refuse') // Deny { - $array_input = array('text'=>$langs->trans("ConfirmRefuseTrip"), array('type'=>"text",'label'=>$langs->trans("Comment"),'name'=>"detail_refuse",'value'=>"")); - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("Deny"), '', "confirm_refuse", $array_input, "yes", 1); + $array_input = array('text'=>$langs->trans("ConfirmRefuseTrip"), array('type'=>"text", 'label'=>$langs->trans("Comment"), 'name'=>"detail_refuse", 'value'=>"")); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("Deny"), '', "confirm_refuse", $array_input, "yes", 1); } if ($action == 'delete_line') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id."&rowid=".GETPOST('rowid', 'int'), $langs->trans("DeleteLine"), $langs->trans("ConfirmDeleteLine"), "confirm_delete_line", '', 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id."&rowid=".GETPOST('rowid', 'int'), $langs->trans("DeleteLine"), $langs->trans("ConfirmDeleteLine"), "confirm_delete_line", '', 'yes', 1); } // Print form confirm print $formconfirm; // Expense report card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); @@ -1799,7 +1799,7 @@ else } } }*/ - $morehtmlref.='
    '; + $morehtmlref .= '
    '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -1815,8 +1815,8 @@ else print ''; print ''; - if (! empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) + if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { print ''; print ''; @@ -1849,14 +1849,14 @@ else if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) // informed { print ''; - print ''; // approver + print ''; // approver print ''; } - elseif($object->fk_statut == ExpenseReport::STATUS_CANCELED) + elseif ($object->fk_statut == ExpenseReport::STATUS_CANCELED) { print ''; print ''; print ''; } - if ($object->fk_statut==99 || !empty($object->detail_refuse)) + if ($object->fk_statut == 99 || !empty($object->detail_refuse)) { print ''; print ''; print ''; @@ -1923,7 +1923,7 @@ else print ''; } - if($object->fk_statut==6) + if ($object->fk_statut == 6) { /* TODO this fields are not yet filled print ''; @@ -1942,7 +1942,7 @@ else // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '.$langs->trans("User").''; - $userfee=new User($db); + $userfee = new User($db); if ($object->fk_user_author > 0) { $userfee->fetch($object->fk_user_author); @@ -1632,7 +1632,7 @@ else print '
    '.$langs->trans("ModePaiement").'
    '.$langs->trans("VALIDATOR").''.$langs->trans("VALIDATOR").''; $include_users = $object->fetch_users_approver_expensereport(); - $s=$form->select_dolusers($object->fk_user_validator, "fk_user_validator", 1, "", 0, $include_users); + $s = $form->select_dolusers($object->fk_user_validator, "fk_user_validator", 1, "", 0, $include_users); print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); print '
    '.$langs->trans("VALIDOR").''; - $userfee=new User($db); + $userfee = new User($db); $userfee->fetch($object->fk_user_valid); print $userfee->getNomUrl(-1); print '
    '.$langs->trans("AUTHORPAIEMENT").''; - $userfee=new User($db); + $userfee = new User($db); $userfee->fetch($user->id); print $userfee->getNomUrl(-1); print '
    '; if ($object->fk_user_author > 0) { - $userauthor=new User($db); - $result=$userauthor->fetch($object->fk_user_author); + $userauthor = new User($db); + $result = $userauthor->fetch($object->fk_user_author); if ($result < 0) dol_print_error('', $userauthor->error); elseif ($result > 0) print $userauthor->getNomUrl(-1); } @@ -1828,7 +1828,7 @@ else print get_date_range($object->date_debut, $object->date_fin, 'day', $langs, 0); print '
    '.$langs->trans("ModePaiement").'
    '.$langs->trans("VALIDATOR").''.$langs->trans("VALIDATOR").''; if ($object->fk_user_validator > 0) { - $userfee=new User($db); + $userfee = new User($db); $result = $userfee->fetch($object->fk_user_validator); if ($result > 0) print $userfee->getNomUrl(-1); - if (empty($userfee->email) || ! isValidEmail($userfee->email)) + if (empty($userfee->email) || !isValidEmail($userfee->email)) { $langs->load("errors"); print img_warning($langs->trans("ErrorBadEMail", $userfee->email)); @@ -1864,14 +1864,14 @@ else } print '
    '.$langs->trans("CANCEL_USER").''; if ($object->fk_user_cancel > 0) { - $userfee=new User($db); + $userfee = new User($db); $result = $userfee->fetch($object->fk_user_cancel); if ($result > 0) print $userfee->getNomUrl(-1); } @@ -1893,7 +1893,7 @@ else print ''; if ($object->fk_user_approve > 0) { - $userapp=new User($db); + $userapp = new User($db); $result = $userapp->fetch($object->fk_user_approve); if ($result > 0) print $userapp->getNomUrl(-1); } @@ -1905,12 +1905,12 @@ else print '
    '.$langs->trans("REFUSEUR").''; - $userfee=new User($db); + $userfee = new User($db); $result = $userfee->fetch($object->fk_user_refuse); if ($result > 0) print $userfee->getNomUrl(-1); print '
    '; @@ -1959,10 +1959,10 @@ else print '
    '.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
    '; print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) { - print ''; + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) { + print ''; } - print ''; + print ''; print ''; print ''; // Payments already done (from payment on this expensereport) $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; - $sql.= "c.code as p_code, c.libelle as payment_type,"; - $sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; - $sql.= " WHERE e.rowid = '".$id."'"; - $sql.= " AND p.fk_expensereport = e.rowid"; - $sql.= ' AND e.entity IN ('.getEntity('expensereport').')'; - $sql.= " ORDER BY dp"; + $sql .= "c.code as p_code, c.libelle as payment_type,"; + $sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= " WHERE e.rowid = '".$id."'"; + $sql .= " AND p.fk_expensereport = e.rowid"; + $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; + $sql .= " ORDER BY dp"; $resql = $db->query($sql); if ($resql) @@ -2029,16 +2029,16 @@ else print $paymentexpensereportstatic->getNomUrl(1); print ''; print '\n"; - $labeltype=$langs->trans("PaymentType".$objp->p_code)!=("PaymentType".$objp->p_code)?$langs->trans("PaymentType".$objp->p_code):$objp->payment_type; + $labeltype = $langs->trans("PaymentType".$objp->p_code) != ("PaymentType".$objp->p_code) ? $langs->trans("PaymentType".$objp->p_code) : $objp->payment_type; print "\n"; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { $bankaccountstatic->id = $objp->baid; $bankaccountstatic->ref = $objp->baref; $bankaccountstatic->label = $objp->baref; $bankaccountstatic->number = $objp->banumber; - if (! empty($conf->accounting->enabled)) { + if (!empty($conf->accounting->enabled)) { $bankaccountstatic->account_number = $objp->account_number; $accountingjournal = new AccountingJournal($db); @@ -2057,9 +2057,9 @@ else $totalpaid += $objp->amount; $i++; } - if (! is_null($totalpaid)) + if (!is_null($totalpaid)) { - $totalpaid = price2num($totalpaid); // Round $totalpaid to fix floating problem after addition into loop + $totalpaid = price2num($totalpaid); // Round $totalpaid to fix floating problem after addition into loop } $remaintopay = price2num($object->total_ttc - $totalpaid); @@ -2076,11 +2076,11 @@ else { $cssforamountpaymentcomplete = 'amountpaymentneutral'; } - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; $db->free($resql); } @@ -2098,8 +2098,8 @@ else print '
    '; - $actiontouse='updateline'; - if (($object->fk_statut==0 || $object->fk_statut==99) && $action != 'editline') $actiontouse='addline'; + $actiontouse = 'updateline'; + if (($object->fk_statut == 0 || $object->fk_statut == 99) && $action != 'editline') $actiontouse = 'addline'; print ''; print ''; @@ -2112,13 +2112,13 @@ else if (!empty($object->lines)) { - $i = 0;$total = 0; + $i = 0; $total = 0; print ''; print ''; //print ''; print ''; - if (! empty($conf->projet->enabled)) print ''; + if (!empty($conf->projet->enabled)) print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; print ''; print ''; @@ -2155,14 +2155,14 @@ else // Date print ''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { print ''; @@ -2185,7 +2185,7 @@ else print ''; // Unit price HT print ''; @@ -2312,7 +2312,7 @@ else print $numline; print ''; - print ''; - $filenamelinked=''; + $filenamelinked = ''; if ($line->fk_ecm_files > 0) { $result = $ecmfilesstatic->fetch($line->fk_ecm_files); @@ -2355,7 +2355,7 @@ else } } - $tredited='tredited'; + $tredited = 'tredited'; include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php'; include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_linktofile.tpl.php'; @@ -2369,7 +2369,7 @@ else print ''; // Select project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { print ''; // Unit price @@ -2441,8 +2441,8 @@ else && $user->rights->expensereport->creer) { $colspan = 11; - if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++; - if (! empty($conf->projet->enabled)) $colspan++; + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++; + if (!empty($conf->projet->enabled)) $colspan++; if ($action != 'editline') $colspan++; $nbFiles = $nbLinks = 0; @@ -2452,10 +2452,10 @@ else require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); - $arrayoffiles=dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png|'.preg_quote(dol_sanitizeFileName($object->ref.'.pdf'), '/').')$'); + $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); + $arrayoffiles = dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png|'.preg_quote(dol_sanitizeFileName($object->ref.'.pdf'), '/').')$'); $nbFiles = count($arrayoffiles); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); } // Add line with link to add new file or attach to an existing file @@ -2499,7 +2499,7 @@ else print ''; print ''; print ''; - if (! empty($conf->projet->enabled)) print ''; + if (!empty($conf->projet->enabled)) print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; print ''; print ''; @@ -2520,18 +2520,18 @@ else // Select date print ''; // Select project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { print ''; } - if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; // Unit price net @@ -2568,7 +2568,7 @@ else // Quantity print ''; // Picture @@ -2634,7 +2634,7 @@ if ($action != 'create' && $action != 'edit') // Send if ($object->fk_statut > ExpenseReport::STATUS_DRAFT) { //if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expensereport->expensereport_advance->send)) { - print ''; + print ''; //} else // print ''; } @@ -2665,7 +2665,7 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_author == user courant * Afficher : "Enregistrer" / "Modifier" / "Supprimer" */ - if($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_REFUSED) + if ($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_REFUSED) { if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { @@ -2729,16 +2729,16 @@ if ($action != 'create' && $action != 'edit') } // If bank module is used - if ($user->rights->expensereport->to_paid && ! empty($conf->banque->enabled) && $object->fk_statut == ExpenseReport::STATUS_APPROVED) + if ($user->rights->expensereport->to_paid && !empty($conf->banque->enabled) && $object->fk_statut == ExpenseReport::STATUS_APPROVED) { // Pay if ($remaintopay == 0) { - print '
    ' . $langs->trans('DoPayment') . '
    '; + print '
    '.$langs->trans('DoPayment').'
    '; } else { - print ''; + print ''; } } @@ -2748,7 +2748,7 @@ if ($action != 'create' && $action != 'edit') //if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) if ($object->paid == 0) { - print '"; + print '"; } } @@ -2773,7 +2773,7 @@ if ($action != 'create' && $action != 'edit') // Clone if ($user->rights->expensereport->creer) { - print ''; + print ''; } /* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */ @@ -2782,7 +2782,7 @@ if ($action != 'create' && $action != 'edit') // Delete print ''; } - elseif($user->rights->expensereport->supprimer && $object->fk_statut != ExpenseReport::STATUS_CLOSED) + elseif ($user->rights->expensereport->supprimer && $object->fk_statut != ExpenseReport::STATUS_CLOSED) { // Delete print ''; @@ -2809,14 +2809,14 @@ if ($action != 'presend') print '
    '; print ''; // ancre - if($user->rights->expensereport->creer && $action != 'create' && $action != 'edit') + if ($user->rights->expensereport->creer && $action != 'create' && $action != 'edit') { - $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->expensereport->creer; - $delallowed = $user->rights->expensereport->creer; - $var = true; + $filename = dol_sanitizeFileName($object->ref); + $filedir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->expensereport->creer; + $delallowed = $user->rights->expensereport->creer; + $var = true; print $formfile->showdocuments('expensereport', $filename, $filedir, $urlsource, $genallowed, $delallowed); $somethingshown = $formfile->numoffiles; } @@ -2832,7 +2832,7 @@ if ($action != 'presend') print '
    '; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'expensereport', null); @@ -2840,8 +2840,8 @@ if ($action != 'presend') } // Presend form -$modelmail='expensereport'; -$defaulttopic='SendExpenseReportRef'; +$modelmail = 'expensereport'; +$defaulttopic = 'SendExpenseReportRef'; $diroutput = $conf->expensereport->dir_output; $trackid = 'exp'.$object->id; diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 7644dbc1748..6b6cfb2911d 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -35,15 +35,15 @@ $allowinstall = 0; $allowupgrade = false; $checksok = 1; -$setuplang=GETPOST("selectlang", 'aZ09', 3)?GETPOST("selectlang", 'aZ09', 3):$langs->getDefaultLang(); +$setuplang = GETPOST("selectlang", 'aZ09', 3) ?GETPOST("selectlang", 'aZ09', 3) : $langs->getDefaultLang(); $langs->setDefaultLang($setuplang); $langs->load("install"); // Now we load forced/pre-set values from install.forced.php file. -$useforcedwizard=false; -$forcedfile="./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; +$useforcedwizard = false; +$forcedfile = "./install.forced.php"; +if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -56,7 +56,7 @@ dolibarr_install_syslog("- check: Dolibarr install/upgrade process started"); * View */ -pHeader('', ''); // No next step for navigation buttons. Next step is defined by click on links. +pHeader('', ''); // No next step for navigation buttons. Next step is defined by click on links. //print "
    \n"; @@ -65,28 +65,28 @@ pHeader('', ''); // No next step for navigation buttons. Next step is define print '

    Database '.$langs->trans("MiscellaneousChecks").":

    \n"; // Check browser -$useragent=$_SERVER['HTTP_USER_AGENT']; -if (! empty($useragent)) +$useragent = $_SERVER['HTTP_USER_AGENT']; +if (!empty($useragent)) { - $tmp=getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); - $browserversion=$tmp['browserversion']; - $browsername=$tmp['browsername']; + $tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); + $browserversion = $tmp['browserversion']; + $browsername = $tmp['browsername']; if ($browsername == 'ie' && $browserversion < 7) print 'Error '.$langs->trans("WarningBrowserTooOld")."
    \n"; } // Check PHP version -$arrayphpminversionerror = array(5,5,0); -$arrayphpminversionwarning = array(5,5,0); +$arrayphpminversionerror = array(5, 5, 0); +$arrayphpminversionwarning = array(5, 5, 0); if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) // Minimum to use (error if lower) { print 'Error '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror)); - $checksok=0; // 0=error, 1=warning + $checksok = 0; // 0=error, 1=warning } elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) // Minimum supported (warning if lower) { print 'Error '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning)); - $checksok=0; // 0=error, 1=warning + $checksok = 0; // 0=error, 1=warning } else { @@ -97,12 +97,12 @@ print "
    \n"; // Check PHP support for $_POST -if (! isset($_GET["testget"]) && ! isset($_POST["testpost"])) +if (!isset($_GET["testget"]) && !isset($_POST["testpost"])) { print 'Warning '.$langs->trans("PHPSupportPOSTGETKo"); print ' ('.$langs->trans("Recheck").')'; print "
    \n"; - $checksok=0; + $checksok = 0; } else { @@ -111,10 +111,10 @@ else // Check if sessions enabled -if (! function_exists("session_id")) +if (!function_exists("session_id")) { print 'Error '.$langs->trans("ErrorPHPDoesNotSupportSessions")."
    \n"; - $checksok=0; + $checksok = 0; } else { @@ -123,7 +123,7 @@ else // Check if GD supported (we need GD for image conversion) -if (! function_exists("imagecreate")) +if (!function_exists("imagecreate")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportGD")."
    \n"; @@ -136,7 +136,7 @@ else // Check if Curl supported -if (! function_exists("curl_init")) +if (!function_exists("curl_init")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCurl")."
    \n"; @@ -148,7 +148,7 @@ else } // Check if PHP calendar extension is available -if (! function_exists("easter_date")) +if (!function_exists("easter_date")) { print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCalendar")."
    \n"; } @@ -159,7 +159,7 @@ else // Check if UTF8 supported -if (! function_exists("utf8_encode")) +if (!function_exists("utf8_encode")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
    \n"; @@ -174,7 +174,7 @@ else // Check if intl methods are supported if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') { - if (! function_exists("locale_get_primary_language") || ! function_exists("locale_get_region")) + if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportIntl")."
    \n"; @@ -188,18 +188,18 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc // Check memory -$memrequiredorig='64M'; -$memrequired=64*1024*1024; -$memmaxorig=@ini_get("memory_limit"); -$memmax=@ini_get("memory_limit"); +$memrequiredorig = '64M'; +$memrequired = 64 * 1024 * 1024; +$memmaxorig = @ini_get("memory_limit"); +$memmax = @ini_get("memory_limit"); if ($memmaxorig != '') { preg_match('/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg); if ($reg[2]) { - if (strtoupper($reg[2]) == 'G') $memmax=$reg[1]*1024*1024*1024; - if (strtoupper($reg[2]) == 'M') $memmax=$reg[1]*1024*1024; - if (strtoupper($reg[2]) == 'K') $memmax=$reg[1]*1024; + if (strtoupper($reg[2]) == 'G') $memmax = $reg[1] * 1024 * 1024 * 1024; + if (strtoupper($reg[2]) == 'M') $memmax = $reg[1] * 1024 * 1024; + if (strtoupper($reg[2]) == 'K') $memmax = $reg[1] * 1024; } if ($memmax >= $memrequired || $memmax == -1) { @@ -216,37 +216,37 @@ if ($memmaxorig != '') clearstatcache(); if (is_readable($conffile) && filesize($conffile) > 8) { - dolibarr_install_syslog("check: conf file '" . $conffile . "' already defined"); - $confexists=1; + dolibarr_install_syslog("check: conf file '".$conffile."' already defined"); + $confexists = 1; include_once $conffile; - $databaseok=1; + $databaseok = 1; if ($databaseok) { // Already installed for all parts (config and database). We can propose upgrade. - $allowupgrade=true; + $allowupgrade = true; } else { - $allowupgrade=false; + $allowupgrade = false; } } else { // If not, we create it - dolibarr_install_syslog("check: we try to create conf file '" . $conffile . "'"); - $confexists=0; + dolibarr_install_syslog("check: we try to create conf file '".$conffile."'"); + $confexists = 0; // First we try by copying example if (@copy($conffile.".example", $conffile)) { // Success - dolibarr_install_syslog("check: successfully copied file " . $conffile . ".example into " . $conffile); + dolibarr_install_syslog("check: successfully copied file ".$conffile.".example into ".$conffile); } else { // If failed, we try to create an empty file - dolibarr_install_syslog("check: failed to copy file " . $conffile . ".example into " . $conffile . ". We try to create it.", LOG_WARNING); + dolibarr_install_syslog("check: failed to copy file ".$conffile.".example into ".$conffile.". We try to create it.", LOG_WARNING); $fp = @fopen($conffile, "w"); if ($fp) @@ -255,17 +255,17 @@ else @fputs($fp, "\n"); fclose($fp); } - else dolibarr_install_syslog("check: failed to create a new file " . $conffile . " into current dir " . getcwd() . ". Please check permissions.", LOG_ERR); + else dolibarr_install_syslog("check: failed to create a new file ".$conffile." into current dir ".getcwd().". Please check permissions.", LOG_ERR); } // First install: no upgrade necessary/required - $allowupgrade=false; + $allowupgrade = false; } // File is missing and cannot be created -if (! file_exists($conffile)) +if (!file_exists($conffile)) { print 'Error '.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow); print "

    "; @@ -281,7 +281,7 @@ else { print 'Warning '.$langs->trans("ConfFileMustBeAFileNotADir", $conffiletoshow); - $allowinstall=0; + $allowinstall = 0; } // File exists but cannot be modified elseif (!is_writable($conffile)) @@ -298,7 +298,7 @@ else print 'Warning '.$langs->trans("ConfFileIsNotWritable", $conffiletoshow); print "
    \n"; - $allowinstall=0; + $allowinstall = 0; } // File exists and can be modified else @@ -315,37 +315,37 @@ else print 'Ok '.$langs->trans("ConfFileIsWritable", $conffiletoshow); print "
    \n"; - $allowinstall=1; + $allowinstall = 1; } print "
    \n"; // Requirements met/all ok: display the next step button if ($checksok) { - $ok=0; + $ok = 0; // Try to create db connection if (file_exists($conffile)) { include_once $conffile; - if (! empty($dolibarr_main_db_type) && ! empty($dolibarr_main_document_root)) + if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) { - if (! file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php")) + if (!file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php")) { print 'A '.$conffiletoshow.' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.' that seems wrong. Try to fix or remove the '.$conffiletoshow.' file.
    '."\n"; - dol_syslog("A '" . $conffiletoshow . "' file exists with a dolibarr_main_document_root to " . $dolibarr_main_document_root . " that seems wrong. Try to fix or remove the '" . $conffiletoshow . "' file.", LOG_WARNING); + dol_syslog("A '".$conffiletoshow."' file exists with a dolibarr_main_document_root to ".$dolibarr_main_document_root." that seems wrong. Try to fix or remove the '".$conffiletoshow."' file.", LOG_WARNING); } else { 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)) + 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_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); @@ -358,10 +358,10 @@ 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; + $ok = true; } } } @@ -370,26 +370,26 @@ else // If database access is available, we set more variables if ($ok) { - if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0; + if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; - if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey=''; + if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; $conf->setValues($db); // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE=constant('SYSLOG_FILE'); + if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE // Version to install is DOL_VERSION - $dolibarrlastupgradeversionarray=preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL)?$conf->global->MAIN_VERSION_LAST_INSTALL:'')); - $dolibarrversiontoinstallarray=versiondolibarrarray(); + $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : '')); + $dolibarrversiontoinstallarray = versiondolibarrarray(); } // Show title - if (! empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ! empty($conf->global->MAIN_VERSION_LAST_INSTALL)) + if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL)) { - print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_INSTALL:$conf->global->MAIN_VERSION_LAST_UPGRADE).' - '; + print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).' - '; print $langs->trans("VersionProgram").': '.DOL_VERSION.''; //print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired")); print '
    '; @@ -400,7 +400,7 @@ else //print $langs->trans("InstallEasy")." "; print '

    '.$langs->trans("ChooseYourSetupMode").'

    '; - $foundrecommandedchoice=0; + $foundrecommandedchoice = 0; $available_choices = array(); $notavailable_choices = array(); @@ -417,7 +417,7 @@ else //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE); $choice .= '
    '.$langs->trans("InstallChoiceSuggested").'
    '; // Ok '; - $foundrecommandedchoice=1; // To show only once + $foundrecommandedchoice = 1; // To show only once } $choice .= ''; @@ -441,14 +441,14 @@ else } // Show upgrade lines - $allowupgrade=true; + $allowupgrade = true; if (empty($dolibarr_main_db_host)) // This means install process was not run { - $allowupgrade=false; + $allowupgrade = false; } - if (defined("MAIN_NOT_INSTALLED")) $allowupgrade=false; - if (GETPOST('allowupgrade')) $allowupgrade=true; - $migrationscript=array( array('from'=>'3.0.0', 'to'=>'3.1.0'), + if (defined("MAIN_NOT_INSTALLED")) $allowupgrade = false; + if (GETPOST('allowupgrade')) $allowupgrade = true; + $migrationscript = array(array('from'=>'3.0.0', 'to'=>'3.1.0'), array('from'=>'3.1.0', 'to'=>'3.2.0'), array('from'=>'3.2.0', 'to'=>'3.3.0'), array('from'=>'3.3.0', 'to'=>'3.4.0'), @@ -467,26 +467,26 @@ else array('from'=>'10.0.0', 'to'=>'11.0.0') ); - $count=0; + $count = 0; foreach ($migrationscript as $migarray) { $choice = ''; $count++; $recommended_choice = false; - $version=DOL_VERSION; - $versionfrom=$migarray['from']; - $versionto=$migarray['to']; - $versionarray=preg_split('/[\.-]/', $version); - $dolibarrversionfromarray=preg_split('/[\.-]/', $versionfrom); - $dolibarrversiontoarray=preg_split('/[\.-]/', $versionto); + $version = DOL_VERSION; + $versionfrom = $migarray['from']; + $versionto = $migarray['to']; + $versionarray = preg_split('/[\.-]/', $version); + $dolibarrversionfromarray = preg_split('/[\.-]/', $versionfrom); + $dolibarrversiontoarray = preg_split('/[\.-]/', $versionto); // Define string newversionxxx that are used for text to show - $newversionfrom=preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom); - $newversionto=preg_replace('/(\.[0-9]+)$/i', '.*', $versionto); - $newversionfrombis=''; + $newversionfrom = preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom); + $newversionto = preg_replace('/(\.[0-9]+)$/i', '.*', $versionto); + $newversionfrombis = ''; if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) // From x.y.z -> x.y.z+1 { - $newversionfrombis=' '.$langs->trans("or").' '.$versionto; + $newversionfrombis = ' '.$langs->trans("or").' '.$versionto; } if ($ok) @@ -498,7 +498,7 @@ else (versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2) ) { - $foundrecommandedchoice=1; // To show only once + $foundrecommandedchoice = 1; // To show only once $recommended_choice = true; } } @@ -519,7 +519,7 @@ else $choice .= '
    '; //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE); $choice .= '
    '; - $choice .= '
    '.$langs->trans("InstallChoiceSuggested").'
    '; + $choice .= '
    '.$langs->trans("InstallChoiceSuggested").'
    '; if ($count < count($migarray)) // There are other choices after { print $langs->trans("MigrateIsDoneStepByStep", DOL_VERSION); @@ -531,10 +531,10 @@ else $choice .= '
    ' . $langs->trans('Payments') . '' . $langs->trans('Date') . '' . $langs->trans('Type') . '' . $langs->trans('BankAccount') . ''.$langs->trans('Payments').''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').'' . $langs->trans('Amount') . ''.$langs->trans('Amount').' 
    '.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_payment."
    '.$langs->trans("AlreadyPaid").':'.price($totalpaid).'
    '.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
    '.$langs->trans("AlreadyPaid").':'.price($totalpaid).'
    '.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
    '.$langs->trans("RemainderToPay").':'.price($resteapayeraffiche).'
    '.$langs->trans("RemainderToPay").':'.price($resteapayeraffiche).'
    '.$langs->trans('LineNb').''.$langs->trans('Piece').''.$langs->trans('Date').''.$langs->trans('Project').''.$langs->trans('Project').''.$langs->trans('CarCategory').''.$langs->trans('Type').''.$langs->trans('Description').''.dol_print_date($db->jdate($line->date), 'day').''; if ($line->fk_project > 0) { - $projecttmp->id=$line->fk_project; - $projecttmp->ref=$line->projet_ref; - $projecttmp->title=$line->projet_title; + $projecttmp->id = $line->fk_project; + $projecttmp->ref = $line->projet_ref; + $projecttmp->title = $line->projet_title; print $projecttmp->getNomUrl(1); } print ''.vatrate($line->vatrate, true).''; - if (! empty($line->value_unit_ht)) + if (!empty($line->value_unit_ht)) { print price($line->value_unit_ht); } @@ -2211,33 +2211,33 @@ else print ''; if ($line->fk_ecm_files > 0) { - $modulepart='expensereport'; - $maxheightmini=32; + $modulepart = 'expensereport'; + $maxheightmini = 32; $result = $ecmfilesstatic->fetch($line->fk_ecm_files); if ($result > 0) { - $relativepath=preg_replace('/expensereport\//', '', $ecmfilesstatic->filepath); + $relativepath = preg_replace('/expensereport\//', '', $ecmfilesstatic->filepath); $fileinfo = pathinfo($ecmfilesstatic->filepath.'/'.$ecmfilesstatic->filename); if (image_format_supported($fileinfo['basename']) > 0) { - $minifile=getImageFileNameForSize($fileinfo['basename'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original - if (! dol_is_file($conf->expensereport->dir_output.'/'.$relativepath.'/'.$minifile)) $minifile=getImageFileNameForSize($fileinfo['basename'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension + $minifile = getImageFileNameForSize($fileinfo['basename'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original + if (!dol_is_file($conf->expensereport->dir_output.'/'.$relativepath.'/'.$minifile)) $minifile = getImageFileNameForSize($fileinfo['basename'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension //print $file['path'].'/'.$minifile.'
    '; - $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.'/'.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); + $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.'/'.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); if (empty($urlforhref)) { - $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); + $urlforhref = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); print ''; } else { print ''; } - print ''; + print ''; print ''; } else { - $modulepart='expensereport'; - $thumbshown=0; + $modulepart = 'expensereport'; + $thumbshown = 0; if (preg_match('/\.pdf$/i', $ecmfilesstatic->filename)) { $filepdf = $conf->expensereport->dir_output.'/'.$relativepath.'/'.$ecmfilesstatic->filename; @@ -2248,31 +2248,31 @@ else if ($pdfexists) { // Conversion du PDF en image png si fichier png non existant - if (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) + if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) { if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experience trouble with pdf thumb generation and imagick, you can disable here. { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png + $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png if ($ret < 0) $error++; } } } - if ($pdfexists && ! $error) + if ($pdfexists && !$error) { - $heightforphotref=70; - if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60; + $heightforphotref = 70; + if (!empty($conf->dol_optimize_smallscreen)) $heightforphotref = 60; // If the preview file is found if (file_exists($fileimage)) { - $thumbshown=1; - print ''; + $thumbshown = 1; + print ''; } } } - if (! $thumbshown) + if (!$thumbshown) { print img_mime($ecmfilesstatic->filename); } @@ -2303,7 +2303,7 @@ else { // Add line with link to add new file or attach line to an existing file $colspan = 10; - if (! empty($conf->projet->enabled)) $colspan++; + if (!empty($conf->projet->enabled)) $colspan++; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++; print '
    '; + print ''; print ''.$langs->trans("UploadANewFileNow"); print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); print ''; @@ -2345,7 +2345,7 @@ else print ''."\n"; print '
    '; $formproject->select_projects(-1, $line->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); @@ -2396,7 +2396,7 @@ else // VAT print ''; - print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, '', 0, 0, '', false, 1); + print $form->load_tva('vatrate', (isset($_POST["vatrate"]) ? $_POST["vatrate"] : $line->vatrate), $mysoc, '', 0, 0, '', false, 1); print '
    '.$langs->trans('Date').''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$langs->trans('CarCategory').''.$langs->trans('Type').''.$langs->trans('Description').''; - print $form->selectDate($date?$date:-1, 'date', 0, 0, 0, '', 1, 1); + print $form->selectDate($date ? $date : -1, 'date', 0, 0, 0, '', 1, 1); print ''; $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''; $params = array('fk_expense' => $object->id); @@ -2551,9 +2551,9 @@ else // Select VAT print ''; - $defaultvat=-1; - if (! empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; - print $form->load_tva('vatrate', ($vatrate!=''?$vatrate:$defaultvat), $mysoc, '', 0, 0, '', false, 1); + $defaultvat = -1; + if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; + print $form->load_tva('vatrate', ($vatrate != '' ? $vatrate : $defaultvat), $mysoc, '', 0, 0, '', false, 1); print ''; - print ''; // We must be able to enter decimal qty + print ''; // We must be able to enter decimal qty print ''; if ($allowupgrade) { - $disabled=false; + $disabled = false; if ($foundrecommandedchoice == 2) { - $disabled=true; + $disabled = true; } if ($foundrecommandedchoice == 1) { @@ -546,7 +546,7 @@ else } else { - $choice .= ''.$langs->trans("Start").''; + $choice .= ''.$langs->trans("Start").''; } } else @@ -566,8 +566,8 @@ else // If there is no choice at all, we show all of them. if (empty($available_choices)) { - $available_choices=$notavailable_choices; - $notavailable_choices=array(); + $available_choices = $notavailable_choices; + $notavailable_choices = array(); } // Array of install choices @@ -621,4 +621,4 @@ $(".runupgrade").click(function() { '; dolibarr_install_syslog("- check: end"); -pFooter(1); // Never display next button +pFooter(1); // Never display next button diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 49574ede476..efb3013bd6d 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -23,7 +23,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -89,27 +89,27 @@ class MyObject extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), - 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1), - 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), - 'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1), + 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), + 'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), 'fk_project' =>array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1), - 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), - 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), - 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501), + 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), + 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501), //'date_validation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'), - 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'), + 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), - 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010), - 'status' =>array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), + 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010), + 'status' =>array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')), ); /** @@ -214,11 +214,11 @@ class MyObject extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -274,7 +274,7 @@ class MyObject extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); // get lines so they will be clone //foreach($this->lines as $line) @@ -287,18 +287,18 @@ class MyObject extends CommonObject // Clear fields - $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default']; - $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref : $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach($object->array_options as $key => $option) + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); @@ -315,7 +315,7 @@ class MyObject extends CommonObject $this->errors = $object->errors; } - if (! $error) + if (!$error) { // copy internal contacts if ($this->copy_linked_contact($object, 'internal') < 0) @@ -324,7 +324,7 @@ class MyObject extends CommonObject } } - if (! $error) + if (!$error) { // copy external contacts if same company if (property_exists($this, 'socid') && $this->socid == $object->socid) @@ -356,7 +356,7 @@ class MyObject extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); return $result; } @@ -367,7 +367,7 @@ class MyObject extends CommonObject */ public function fetchLines() { - $this->lines=array(); + $this->lines = array(); $result = $this->fetchLinesCommon(); return $result; @@ -391,40 +391,40 @@ class MyObject extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $records=array(); + $records = array(); $sql = 'SELECT '; $sql .= $this->getFieldList(); - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; else $sql .= ' WHERE 1 = 1'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key=='t.rowid') { - $sqlwhere[] = $key . '='. $value; + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; } - elseif ($key=='customsql') { + elseif ($key == 'customsql') { $sqlwhere[] = $value; } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } if (count($sqlwhere) > 0) { - $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -446,8 +446,8 @@ class MyObject extends CommonObject return $records; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } @@ -587,51 +587,51 @@ class MyObject extends CommonObject { global $conf, $langs, $hookmanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = '' . $langs->trans("MyObject") . ''; - $label.= '
    '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("MyObject").''; + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -687,10 +687,10 @@ class MyObject extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -701,7 +701,7 @@ class MyObject extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -715,7 +715,7 @@ class MyObject extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); @@ -749,7 +749,7 @@ class MyObject extends CommonObject */ public function getLinesArray() { - $this->lines=array(); + $this->lines = array(); $objectline = new MyObjectLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.$this->id)); @@ -780,16 +780,16 @@ class MyObject extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("mymodule@mymodule"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'standard'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->MYOBJECT_ADDON_PDF)) { + } elseif (!empty($conf->global->MYOBJECT_ADDON_PDF)) { $modele = $conf->global->MYOBJECT_ADDON_PDF; } } @@ -814,7 +814,7 @@ class MyObject extends CommonObject $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index d65f311acbb..c4ec988b269 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -35,21 +35,21 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; $langs->loadLangs(array('stock', 'other', 'productbatch')); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $batch = GETPOST('batch', 'alpha'); $productid = GETPOST('productid', 'int'); -$ref = GETPOST('ref', 'alpha'); // ref is productid_batch +$ref = GETPOST('ref', 'alpha'); // ref is productid_batch -$search_entity=GETPOST('search_entity', 'int'); -$search_fk_product=GETPOST('search_fk_product', 'int'); -$search_batch=GETPOST('search_batch', 'alpha'); -$search_fk_user_creat=GETPOST('search_fk_user_creat', 'int'); -$search_fk_user_modif=GETPOST('search_fk_user_modif', 'int'); -$search_import_key=GETPOST('search_import_key', 'int'); +$search_entity = GETPOST('search_entity', 'int'); +$search_fk_product = GETPOST('search_fk_product', 'int'); +$search_batch = GETPOST('search_batch', 'alpha'); +$search_fk_user_creat = GETPOST('search_fk_user_creat', 'int'); +$search_fk_user_modif = GETPOST('search_fk_user_modif', 'int'); +$search_import_key = GETPOST('search_import_key', 'int'); -if (empty($action) && empty($id) && empty($ref)) $action='list'; +if (empty($action) && empty($id) && empty($ref)) $action = 'list'; // Protection if external user @@ -73,21 +73,21 @@ if ($id || $ref) { if ($ref) { - $tmp=explode('_', $ref); - $productid=$tmp[0]; - $batch=$tmp[1]; + $tmp = explode('_', $ref); + $productid = $tmp[0]; + $batch = $tmp[1]; } $object->fetch($id, $productid, $batch); $object->ref = $object->batch; // For document management ( it use $object->ref) } // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('productlotcard','globalcard')); +$hookmanager->initHooks(array('productlotcard', 'globalcard')); -$permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->stock->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->stock->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $usercanread = $user->rights->produit->lire; $usercancreate = $user->rights->produit->creer; @@ -97,8 +97,8 @@ $usercandelete = $user->rights->produit->supprimer; * Actions */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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)) @@ -112,7 +112,7 @@ if (empty($reshook)) if ($action == 'setsellby' && $user->rights->stock->creer) { - $newvalue=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); + $newvalue = dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) dol_print_error($db, $object->error); } @@ -125,7 +125,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY'); @@ -145,21 +145,21 @@ if (empty($reshook)) { if (GETPOST('cancel', 'alpha')) { - $urltogo=$backtopage?$backtopage:dol_buildpath('/stock/list.php', 1); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1); header("Location: ".$urltogo); exit; } - $error=0; + $error = 0; /* object_prop_getpost_prop */ - $object->entity=GETPOST('entity', 'int'); - $object->fk_product=GETPOST('fk_product', 'int'); - $object->batch=GETPOST('batch', 'alpha'); - $object->fk_user_creat=GETPOST('fk_user_creat', 'int'); - $object->fk_user_modif=GETPOST('fk_user_modif', 'int'); - $object->import_key=GETPOST('import_key', 'int'); + $object->entity = GETPOST('entity', 'int'); + $object->fk_product = GETPOST('fk_product', 'int'); + $object->batch = GETPOST('batch', 'alpha'); + $object->fk_user_creat = GETPOST('fk_user_creat', 'int'); + $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); + $object->import_key = GETPOST('import_key', 'int'); if (empty($object->ref)) { @@ -167,43 +167,43 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); } - if (! $error) + if (!$error) { - $result=$object->create($user); + $result = $object->create($user); if ($result > 0) { // Creation OK - $urltogo=$backtopage?$backtopage:dol_buildpath('/stock/list.php', 1); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1); header("Location: ".$urltogo); exit; } { // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); else setEventMessages($object->error, null, 'errors'); - $action='create'; + $action = 'create'; } } else { - $action='create'; + $action = 'create'; } } // Cancel - if ($action == 'update' && GETPOST('cancel', 'alpha')) $action='view'; + if ($action == 'update' && GETPOST('cancel', 'alpha')) $action = 'view'; // Action to update record - if ($action == 'update' && ! GETPOST('cancel', 'alpha')) + if ($action == 'update' && !GETPOST('cancel', 'alpha')) { - $error=0; + $error = 0; - $object->entity=GETPOST('entity', 'int'); - $object->fk_product=GETPOST('fk_product', 'int'); - $object->batch=GETPOST('batch', 'alpha'); - $object->fk_user_creat=GETPOST('fk_user_creat', 'int'); - $object->fk_user_modif=GETPOST('fk_user_modif', 'int'); - $object->import_key=GETPOST('import_key', 'int'); + $object->entity = GETPOST('entity', 'int'); + $object->fk_product = GETPOST('fk_product', 'int'); + $object->batch = GETPOST('batch', 'alpha'); + $object->fk_user_creat = GETPOST('fk_user_creat', 'int'); + $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); + $object->import_key = GETPOST('import_key', 'int'); if (empty($object->ref)) { @@ -211,31 +211,31 @@ if (empty($reshook)) setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); } - if (! $error) + if (!$error) { - $result=$object->update($user); + $result = $object->update($user); if ($result > 0) { - $action='view'; + $action = 'view'; } else { // Creation KO - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); else setEventMessages($object->error, null, 'errors'); - $action='edit'; + $action = 'edit'; } } else { - $action='edit'; + $action = 'edit'; } } // Action to delete if ($action == 'confirm_delete') { - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { // Delete OK @@ -245,7 +245,7 @@ if (empty($reshook)) } else { - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); else setEventMessages($object->error, null, 'errors'); } } @@ -265,7 +265,7 @@ if (empty($reshook)) llxHeader('', 'ProductLot', ''); -$form=new Form($db); +$form = new Form($db); // Part to create @@ -310,15 +310,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1); print $formconfirm; } - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->socid && ! in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch'); @@ -352,7 +352,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '; @@ -363,8 +363,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Buttons print '
    '."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -403,12 +403,12 @@ if (empty($action)) // Documents $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product_batch').dol_sanitizeFileName($object->ref); - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$usercanread; - $delallowed=$usercancreate; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $usercanread; + $delallowed = $usercancreate; print $formfile->showdocuments('product_batch', dol_sanitizeFileName($object->ref), $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); - $somethingshown=$formfile->numoffiles; + $somethingshown = $formfile->numoffiles; print '
    '; } diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index c10e9915c3b..bc122367312 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -35,17 +35,17 @@ class Task extends CommonObject /** * @var string ID to identify managed object */ - public $element='project_task'; + public $element = 'project_task'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='projet_task'; + public $table_element = 'projet_task'; /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element='fk_task'; + public $fk_element = 'fk_task'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -55,7 +55,7 @@ class Task extends CommonObject /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables=array('projet_task_time'); + protected $childtables = array('projet_task_time'); /** * @var int ID parent task @@ -72,7 +72,7 @@ class Task extends CommonObject */ public $description; - public $duration_effective; // total of time spent on this task + public $duration_effective; // total of time spent on this task public $planned_workload; public $date_c; public $date_start; @@ -111,8 +111,8 @@ class Task extends CommonObject public $timespent_duration; public $timespent_old_duration; public $timespent_date; - public $timespent_datehour; // More accurate start date (same than timespent_date but includes hours, minutes and seconds) - public $timespent_withhour; // 1 = we entered also start hours for timesheet line + public $timespent_datehour; // More accurate start date (same than timespent_date but includes hours, minutes and seconds) + public $timespent_withhour; // 1 = we entered also start hours for timesheet line public $timespent_fk_user; public $timespent_note; @@ -143,7 +143,7 @@ class Task extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters $this->label = trim($this->label); @@ -154,56 +154,56 @@ class Task extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task ("; - $sql.= "fk_projet"; - $sql.= ", ref"; - $sql.= ", fk_task_parent"; - $sql.= ", label"; - $sql.= ", description"; - $sql.= ", datec"; - $sql.= ", fk_user_creat"; - $sql.= ", dateo"; - $sql.= ", datee"; - $sql.= ", planned_workload"; - $sql.= ", progress"; - $sql.= ") VALUES ("; - $sql.= $this->fk_project; - $sql.= ", ".(!empty($this->ref)?"'".$this->db->escape($this->ref)."'":'null'); - $sql.= ", ".$this->fk_task_parent; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->db->escape($this->description)."'"; - $sql.= ", '".$this->db->idate($this->date_c)."'"; - $sql.= ", ".$user->id; - $sql.= ", ".($this->date_start!=''?"'".$this->db->idate($this->date_start)."'":'null'); - $sql.= ", ".($this->date_end!=''?"'".$this->db->idate($this->date_end)."'":'null'); - $sql.= ", ".(($this->planned_workload!='' && $this->planned_workload >= 0)?$this->planned_workload:'null'); - $sql.= ", ".(($this->progress!='' && $this->progress >= 0)?$this->progress:'null'); - $sql.= ")"; + $sql .= "fk_projet"; + $sql .= ", ref"; + $sql .= ", fk_task_parent"; + $sql .= ", label"; + $sql .= ", description"; + $sql .= ", datec"; + $sql .= ", fk_user_creat"; + $sql .= ", dateo"; + $sql .= ", datee"; + $sql .= ", planned_workload"; + $sql .= ", progress"; + $sql .= ") VALUES ("; + $sql .= $this->fk_project; + $sql .= ", ".(!empty($this->ref) ? "'".$this->db->escape($this->ref)."'" : 'null'); + $sql .= ", ".$this->fk_task_parent; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->escape($this->description)."'"; + $sql .= ", '".$this->db->idate($this->date_c)."'"; + $sql .= ", ".$user->id; + $sql .= ", ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); + $sql .= ", ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); + $sql .= ", ".(($this->planned_workload != '' && $this->planned_workload >= 0) ? $this->planned_workload : 'null'); + $sql .= ", ".(($this->progress != '' && $this->progress >= 0) ? $this->progress : 'null'); + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task"); - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('TASK_CREATE', $user); + $result = $this->call_trigger('TASK_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } } // Update extrafield - if (! $error) + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -214,13 +214,13 @@ class Task extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -243,41 +243,41 @@ class Task extends CommonObject global $langs, $conf; $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.ref,"; - $sql.= " t.fk_projet as fk_project,"; - $sql.= " t.fk_task_parent,"; - $sql.= " t.label,"; - $sql.= " t.description,"; - $sql.= " t.duration_effective,"; - $sql.= " t.planned_workload,"; - $sql.= " t.datec,"; - $sql.= " t.dateo,"; - $sql.= " t.datee,"; - $sql.= " t.fk_user_creat,"; - $sql.= " t.fk_user_valid,"; - $sql.= " t.fk_statut,"; - $sql.= " t.progress,"; - $sql.= " t.priority,"; - $sql.= " t.note_private,"; - $sql.= " t.note_public,"; - $sql.= " t.rang"; - if (! empty($loadparentdata)) + $sql .= " t.rowid,"; + $sql .= " t.ref,"; + $sql .= " t.fk_projet as fk_project,"; + $sql .= " t.fk_task_parent,"; + $sql .= " t.label,"; + $sql .= " t.description,"; + $sql .= " t.duration_effective,"; + $sql .= " t.planned_workload,"; + $sql .= " t.datec,"; + $sql .= " t.dateo,"; + $sql .= " t.datee,"; + $sql .= " t.fk_user_creat,"; + $sql .= " t.fk_user_valid,"; + $sql .= " t.fk_statut,"; + $sql .= " t.progress,"; + $sql .= " t.priority,"; + $sql .= " t.note_private,"; + $sql .= " t.note_public,"; + $sql .= " t.rang"; + if (!empty($loadparentdata)) { - $sql.=", t2.ref as task_parent_ref"; - $sql.=", t2.rang as task_parent_position"; + $sql .= ", t2.ref as task_parent_ref"; + $sql .= ", t2.rang as task_parent_position"; } - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as t"; - if (! empty($loadparentdata)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t2 ON t.fk_task_parent = t2.rowid"; - $sql.= " WHERE "; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t"; + if (!empty($loadparentdata)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t2 ON t.fk_task_parent = t2.rowid"; + $sql .= " WHERE "; if (!empty($ref)) { - $sql.="t.ref = '".$this->db->escape($ref)."'"; - }else { - $sql.="t.rowid = ".$id; + $sql .= "t.ref = '".$this->db->escape($ref)."'"; + } else { + $sql .= "t.rowid = ".$id; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num_rows = $this->db->num_rows($resql); @@ -286,27 +286,27 @@ class Task extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->fk_project = $obj->fk_project; - $this->fk_task_parent = $obj->fk_task_parent; - $this->label = $obj->label; - $this->description = $obj->description; - $this->duration_effective = $obj->duration_effective; - $this->planned_workload = $obj->planned_workload; - $this->date_c = $this->db->jdate($obj->datec); - $this->date_start = $this->db->jdate($obj->dateo); + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->fk_project = $obj->fk_project; + $this->fk_task_parent = $obj->fk_task_parent; + $this->label = $obj->label; + $this->description = $obj->description; + $this->duration_effective = $obj->duration_effective; + $this->planned_workload = $obj->planned_workload; + $this->date_c = $this->db->jdate($obj->datec); + $this->date_start = $this->db->jdate($obj->dateo); $this->date_end = $this->db->jdate($obj->datee); $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_valid = $obj->fk_user_valid; $this->fk_statut = $obj->fk_statut; $this->progress = $obj->progress; $this->priority = $obj->priority; - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; - $this->rang = $obj->rang; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->rang = $obj->rang; - if (! empty($loadparentdata)) + if (!empty($loadparentdata)) { $this->task_parent_ref = $obj->task_parent_ref; $this->task_parent_position = $obj->task_parent_position; @@ -321,13 +321,13 @@ class Task extends CommonObject if ($num_rows) { return 1; - }else { + } else { return 0; } } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -343,46 +343,46 @@ class Task extends CommonObject public function update($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->fk_project)) $this->fk_project=trim($this->fk_project); - if (isset($this->ref)) $this->ref=trim($this->ref); + if (isset($this->fk_project)) $this->fk_project = trim($this->fk_project); + if (isset($this->ref)) $this->ref = trim($this->ref); if (isset($this->fk_task_parent)) $this->fk_task_parent = (int) $this->fk_task_parent; - if (isset($this->label)) $this->label=trim($this->label); - if (isset($this->description)) $this->description=trim($this->description); - if (isset($this->duration_effective)) $this->duration_effective=trim($this->duration_effective); - if (isset($this->planned_workload)) $this->planned_workload=trim($this->planned_workload); + if (isset($this->label)) $this->label = trim($this->label); + if (isset($this->description)) $this->description = trim($this->description); + if (isset($this->duration_effective)) $this->duration_effective = trim($this->duration_effective); + if (isset($this->planned_workload)) $this->planned_workload = trim($this->planned_workload); // Check parameters // Put here code to add control on parameters values // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; - $sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").","; - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"'".$this->db->escape($this->id)."'").","; - $sql.= " fk_task_parent=".(isset($this->fk_task_parent)?$this->fk_task_parent:"null").","; - $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; - $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; - $sql.= " duration_effective=".(isset($this->duration_effective)?$this->duration_effective:"null").","; - $sql.= " planned_workload=".((isset($this->planned_workload) && $this->planned_workload != '')?$this->planned_workload:"null").","; - $sql.= " dateo=".($this->date_start!=''?"'".$this->db->idate($this->date_start)."'":'null').","; - $sql.= " datee=".($this->date_end!=''?"'".$this->db->idate($this->date_end)."'":'null').","; - $sql.= " progress=".(($this->progress!='' && $this->progress >= 0)?$this->progress:'null').","; - $sql.= " rang=".((!empty($this->rang))?$this->rang:"0"); - $sql.= " WHERE rowid=".$this->id; + $sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").","; + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "'".$this->db->escape($this->id)."'").","; + $sql .= " fk_task_parent=".(isset($this->fk_task_parent) ? $this->fk_task_parent : "null").","; + $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; + $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; + $sql .= " duration_effective=".(isset($this->duration_effective) ? $this->duration_effective : "null").","; + $sql .= " planned_workload=".((isset($this->planned_workload) && $this->planned_workload != '') ? $this->planned_workload : "null").","; + $sql .= " dateo=".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null').","; + $sql .= " datee=".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null').","; + $sql .= " progress=".(($this->progress != '' && $this->progress >= 0) ? $this->progress : 'null').","; + $sql .= " rang=".((!empty($this->rang)) ? $this->rang : "0"); + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } // Update extrafield - if (! $error) { + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -390,18 +390,18 @@ class Task extends CommonObject } } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('TASK_MODIFY', $user); + $result = $this->call_trigger('TASK_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } } - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) + if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { // We remove directory if ($conf->projet->dir_output) @@ -413,12 +413,12 @@ class Task extends CommonObject $newdir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($this->ref); if (file_exists($olddir)) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $res=dol_move($olddir, $newdir); - if (! $res) + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $res = dol_move($olddir, $newdir); + if (!$res) { $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToRenameDir', $olddir, $newdir); + $this->error = $langs->trans('ErrorFailToRenameDir', $olddir, $newdir); $error++; } } @@ -428,13 +428,13 @@ class Task extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -455,75 +455,75 @@ class Task extends CommonObject { global $conf, $langs; - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; $this->db->begin(); if ($this->hasChildren() > 0) { dol_syslog(get_class($this)."::delete Can't delete record as it has some sub tasks", LOG_WARNING); - $this->error='ErrorRecordHasSubTasks'; + $this->error = 'ErrorRecordHasSubTasks'; $this->db->rollback(); return 0; } $objectisused = $this->isObjectUsed($this->id); - if (! empty($objectisused)) + if (!empty($objectisused)) { dol_syslog(get_class($this)."::delete Can't delete record as it has some child", LOG_WARNING); - $this->error='ErrorRecordHasChildren'; + $this->error = 'ErrorRecordHasChildren'; $this->db->rollback(); return 0; } - if (! $error) + if (!$error) { // Delete linked contacts $res = $this->delete_linked_contact(); if ($res < 0) { - $this->error='ErrorFailToDeleteLinkedContact'; + $this->error = 'ErrorFailToDeleteLinkedContact'; //$error++; $this->db->rollback(); return 0; } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time"; - $sql.= " WHERE fk_task=".$this->id; + $sql .= " WHERE fk_task=".$this->id; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_extrafields"; - $sql.= " WHERE fk_object=".$this->id; + $sql .= " WHERE fk_object=".$this->id; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('TASK_DELETE', $user); + $result = $this->call_trigger('TASK_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -532,27 +532,27 @@ class Task extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { //Delete associated link file if ($conf->projet->dir_output) { - $projectstatic=new Project($this->db); + $projectstatic = new Project($this->db); $projectstatic->fetch($this->fk_project); - $dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($projectstatic->ref) . '/' . dol_sanitizeFileName($this->id); + $dir = $conf->projet->dir_output."/".dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($this->id); dol_syslog(get_class($this)."::delete dir=".$dir, LOG_DEBUG); if (file_exists($dir)) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $res = @dol_delete_dir_recursive($dir); if (!$res) { @@ -576,24 +576,24 @@ class Task extends CommonObject */ public function hasChildren() { - $error=0; - $ret=0; + $error = 0; + $ret = 0; $sql = "SELECT COUNT(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task"; - $sql.= " WHERE fk_task_parent=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task"; + $sql .= " WHERE fk_task_parent=".$this->id; dol_syslog(get_class($this)."::hasChildren", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } else { - $obj=$this->db->fetch_object($resql); - if ($obj) $ret=$obj->nb; + $obj = $this->db->fetch_object($resql); + if ($obj) $ret = $obj->nb; $this->db->free($resql); } - if (! $error) + if (!$error) { return $ret; } @@ -610,24 +610,24 @@ class Task extends CommonObject */ public function hasTimeSpent() { - $error=0; - $ret=0; + $error = 0; + $ret = 0; $sql = "SELECT COUNT(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time"; - $sql.= " WHERE fk_task=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; + $sql .= " WHERE fk_task=".$this->id; dol_syslog(get_class($this)."::hasTimeSpent", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } else { - $obj=$this->db->fetch_object($resql); - if ($obj) $ret=$obj->nb; + $obj = $this->db->fetch_object($resql); + if ($obj) $ret = $obj->nb; $this->db->free($resql); } - if (! $error) + if (!$error) { return $ret; } @@ -654,48 +654,48 @@ class Task extends CommonObject { global $conf, $langs, $user; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result=''; - $label = '' . $langs->trans("ShowTask") . ''; - if (! empty($this->ref)) - $label .= '
    ' . $langs->trans('Ref') . ': ' . $this->ref; - if (! empty($this->label)) - $label .= '
    ' . $langs->trans('LabelTask') . ': ' . $this->label; + $result = ''; + $label = ''.$langs->trans("ShowTask").''; + if (!empty($this->ref)) + $label .= '
    '.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->label)) + $label .= '
    '.$langs->trans('LabelTask').': '.$this->label; if ($this->date_start || $this->date_end) { $label .= "
    ".get_date_range($this->date_start, $this->date_end, '', $langs, 0); } - $url = DOL_URL_ROOT.'/projet/tasks/'.$mode.'.php?id='.$this->id.($option=='withproject'?'&withproject=1':''); + $url = DOL_URL_ROOT.'/projet/tasks/'.$mode.'.php?id='.$this->id.($option == 'withproject' ? '&withproject=1' : ''); // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowTask"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowTask"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; - $picto='projecttask'; + $picto = 'projecttask'; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; - if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + if ($withpicto != 2) $result .= (($addlabel && $this->label) ? $sep.dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); return $result; } @@ -709,17 +709,17 @@ class Task extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->fk_project=''; - $this->ref='TK01'; - $this->fk_task_parent=null; - $this->label='Specimen task TK01'; - $this->duration_effective=''; - $this->fk_user_creat=null; - $this->progress='25'; - $this->fk_statut=null; - $this->note='This is a specimen task not'; + $this->fk_project = ''; + $this->ref = 'TK01'; + $this->fk_task_parent = null; + $this->label = 'Specimen task TK01'; + $this->duration_effective = ''; + $this->fk_user_creat = null; + $this->progress = '25'; + $this->fk_statut = null; + $this->note = 'This is a specimen task not'; } /** @@ -750,123 +750,123 @@ class Task extends CommonObject // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT "; - if ($filteronprojuser > 0 || $filterontaskuser > 0) $sql.= " DISTINCT"; // We may get several time the same record if user has several roles on same project/task - $sql.= " p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus, p.usage_bill_time,"; - $sql.= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut as status,"; - $sql.= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang,"; - $sql.= " s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email,"; - $sql.= " p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; + if ($filteronprojuser > 0 || $filterontaskuser > 0) $sql .= " DISTINCT"; // We may get several time the same record if user has several roles on same project/task + $sql .= " p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus, p.usage_bill_time,"; + $sql .= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut as status,"; + $sql .= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang,"; + $sql .= " s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email,"; + $sql .= " p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; if (!empty($extrafields->attributes['projet']['label'])) { - foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql.=($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key.' as options_'.$key : ''); + foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key.' as options_'.$key : ''); } if (!empty($extrafields->attributes['projet_task']['label'])) { - foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql.=($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key.' as options_'.$key : ''); + foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key.' as options_'.$key : ''); } if ($includebilltime) { - $sql.=", SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; + $sql .= ", SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; } - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as efp ON (p.rowid = efp.fk_object)"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as efp ON (p.rowid = efp.fk_object)"; if ($mode == 0) { if ($filteronprojuser > 0) { - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; } - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; if ($includebilltime) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } if ($filterontaskuser > 0) { - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec2"; - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec2"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; } - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)"; - $sql.= " WHERE p.entity IN (".getEntity('project').")"; - $sql.= " AND t.fk_projet = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)"; + $sql .= " WHERE p.entity IN (".getEntity('project').")"; + $sql .= " AND t.fk_projet = p.rowid"; } elseif ($mode == 1) { if ($filteronprojuser > 0) { - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; } if ($filterontaskuser > 0) { - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; if ($includebilltime) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec2"; - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec2"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; } else { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; if ($includebilltime) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } } - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)"; - $sql.= " WHERE p.entity IN (".getEntity('project').")"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)"; + $sql .= " WHERE p.entity IN (".getEntity('project').")"; } else return 'BadValueForParameterMode'; if ($filteronprojuser > 0) { - $sql.= " AND p.rowid = ec.element_id"; - $sql.= " AND ctc.rowid = ec.fk_c_type_contact"; - $sql.= " AND ctc.element = 'project'"; - $sql.= " AND ec.fk_socpeople = ".$filteronprojuser; - $sql.= " AND ec.statut = 4"; - $sql.= " AND ctc.source = 'internal'"; + $sql .= " AND p.rowid = ec.element_id"; + $sql .= " AND ctc.rowid = ec.fk_c_type_contact"; + $sql .= " AND ctc.element = 'project'"; + $sql .= " AND ec.fk_socpeople = ".$filteronprojuser; + $sql .= " AND ec.statut = 4"; + $sql .= " AND ctc.source = 'internal'"; } if ($filterontaskuser > 0) { - $sql.= " AND t.fk_projet = p.rowid"; - $sql.= " AND p.rowid = ec2.element_id"; - $sql.= " AND ctc2.rowid = ec2.fk_c_type_contact"; - $sql.= " AND ctc2.element = 'project_task'"; - $sql.= " AND ec2.fk_socpeople = ".$filterontaskuser; - $sql.= " AND ec2.statut = 4"; - $sql.= " AND ctc2.source = 'internal'"; + $sql .= " AND t.fk_projet = p.rowid"; + $sql .= " AND p.rowid = ec2.element_id"; + $sql .= " AND ctc2.rowid = ec2.fk_c_type_contact"; + $sql .= " AND ctc2.element = 'project_task'"; + $sql .= " AND ec2.fk_socpeople = ".$filterontaskuser; + $sql .= " AND ec2.statut = 4"; + $sql .= " AND ctc2.source = 'internal'"; } - if ($socid) $sql.= " AND p.fk_soc = ".$socid; - if ($projectid) $sql.= " AND p.rowid in (".$projectid.")"; - if ($filteronproj) $sql.= natural_search(array("p.ref", "p.title"), $filteronproj); - if ($filteronprojstatus && $filteronprojstatus != '-1') $sql.= " AND p.fk_statut IN (".$filteronprojstatus.")"; - if ($morewherefilter) $sql.=$morewherefilter; + if ($socid) $sql .= " AND p.fk_soc = ".$socid; + if ($projectid) $sql .= " AND p.rowid in (".$projectid.")"; + if ($filteronproj) $sql .= natural_search(array("p.ref", "p.title"), $filteronproj); + if ($filteronprojstatus && $filteronprojstatus != '-1') $sql .= " AND p.fk_statut IN (".$filteronprojstatus.")"; + if ($morewherefilter) $sql .= $morewherefilter; if ($includebilltime) { - $sql.=" GROUP BY p.rowid, p.ref, p.title, p.public, p.fk_statut, p.usage_bill_time,"; - $sql.=" t.datec, t.dateo, t.datee, t.tms,"; - $sql.=" t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,"; - $sql.=" t.dateo, t.datee, t.planned_workload, t.rang,"; - $sql.=" s.rowid, s.nom, s.email,"; - $sql.=" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; + $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public, p.fk_statut, p.usage_bill_time,"; + $sql .= " t.datec, t.dateo, t.datee, t.tms,"; + $sql .= " t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,"; + $sql .= " t.dateo, t.datee, t.planned_workload, t.rang,"; + $sql .= " s.rowid, s.nom, s.email,"; + $sql .= " p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; if (!empty($extrafields->attributes['projet']['label'])) { - foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql.=($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key : ''); + foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key : ''); } if (!empty($extrafields->attributes['projet_task']['label'])) { - foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql.=($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key : ''); + foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key : ''); } } - $sql.= " ORDER BY p.ref, t.rang, t.dateo"; + $sql .= " ORDER BY p.ref, t.rang, t.dateo"; //print $sql;exit; dol_syslog(get_class($this)."::getTasksArray", LOG_DEBUG); @@ -878,56 +878,56 @@ class Task extends CommonObject // Loop on each record found, so each couple (project id, task id) while ($i < $num) { - $error=0; + $error = 0; $obj = $this->db->fetch_object($resql); - if ((! $obj->public) && (is_object($userp))) // If not public project and we ask a filter on project owned by a user + if ((!$obj->public) && (is_object($userp))) // If not public project and we ask a filter on project owned by a user { - if (! $this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) + if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) { $error++; } } if (is_object($usert)) // If we ask a filter on a user affected to a task { - if (! $this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) + if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) { $error++; } } - if (! $error) + if (!$error) { $tasks[$i] = new Task($this->db); - $tasks[$i]->id = $obj->taskid; - $tasks[$i]->ref = $obj->taskref; + $tasks[$i]->id = $obj->taskid; + $tasks[$i]->ref = $obj->taskref; $tasks[$i]->fk_project = $obj->projectid; $tasks[$i]->projectref = $obj->ref; - $tasks[$i]->projectlabel = $obj->plabel; - $tasks[$i]->projectstatus = $obj->projectstatus; - $tasks[$i]->usage_bill_time = $obj->usage_bill_time; - $tasks[$i]->label = $obj->label; - $tasks[$i]->description = $obj->description; - $tasks[$i]->fk_parent = $obj->fk_task_parent; // deprecated - $tasks[$i]->fk_task_parent = $obj->fk_task_parent; + $tasks[$i]->projectlabel = $obj->plabel; + $tasks[$i]->projectstatus = $obj->projectstatus; + $tasks[$i]->usage_bill_time = $obj->usage_bill_time; + $tasks[$i]->label = $obj->label; + $tasks[$i]->description = $obj->description; + $tasks[$i]->fk_parent = $obj->fk_task_parent; // deprecated + $tasks[$i]->fk_task_parent = $obj->fk_task_parent; $tasks[$i]->duration = $obj->duration_effective; - $tasks[$i]->planned_workload= $obj->planned_workload; + $tasks[$i]->planned_workload = $obj->planned_workload; $tasks[$i]->tobill = $obj->tobill; - $tasks[$i]->billed = $obj->billed; + $tasks[$i]->billed = $obj->billed; $tasks[$i]->progress = $obj->progress; - $tasks[$i]->fk_statut = $obj->status; - $tasks[$i]->public = $obj->public; - $tasks[$i]->date_start = $this->db->jdate($obj->date_start); + $tasks[$i]->fk_statut = $obj->status; + $tasks[$i]->public = $obj->public; + $tasks[$i]->date_start = $this->db->jdate($obj->date_start); $tasks[$i]->date_end = $this->db->jdate($obj->date_end); $tasks[$i]->rang = $obj->rang; - $tasks[$i]->socid = $obj->thirdparty_id; // For backward compatibility - $tasks[$i]->thirdparty_id = $obj->thirdparty_id; + $tasks[$i]->socid = $obj->thirdparty_id; // For backward compatibility + $tasks[$i]->thirdparty_id = $obj->thirdparty_id; $tasks[$i]->thirdparty_name = $obj->thirdparty_name; - $tasks[$i]->thirdparty_email= $obj->thirdparty_email; + $tasks[$i]->thirdparty_email = $obj->thirdparty_email; $tasks[$i]->fk_opp_status = $obj->fk_opp_status; @@ -986,41 +986,41 @@ class Task extends CommonObject // We want role of user for a projet or role of user for a task. Both are not possible. if (empty($userp) && empty($usert)) { - $this->error="CallWithWrongParameters"; + $this->error = "CallWithWrongParameters"; return -1; } - if (! empty($userp) && ! empty($usert)) + if (!empty($userp) && !empty($usert)) { - $this->error="CallWithWrongParameters"; + $this->error = "CallWithWrongParameters"; return -1; } /* Liste des taches et role sur les projets ou taches */ $sql = "SELECT pt.rowid as pid, ec.element_id, ctc.code, ctc.source"; - if ($userp) $sql.= " FROM ".MAIN_DB_PREFIX."projet as pt"; - if ($usert && $filteronprojstatus > -1) $sql.= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."projet_task as pt"; - if ($usert && $filteronprojstatus <= -1) $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sql.= " WHERE pt.rowid = ec.element_id"; - if ($userp && $filteronprojstatus > -1) $sql.= " AND pt.fk_statut = ".$filteronprojstatus; - if ($usert && $filteronprojstatus > -1) $sql.= " AND pt.fk_projet = p.rowid AND p.fk_statut = ".$filteronprojstatus; - if ($userp) $sql.= " AND ctc.element = 'project'"; - if ($usert) $sql.= " AND ctc.element = 'project_task'"; - $sql.= " AND ctc.rowid = ec.fk_c_type_contact"; - if ($userp) $sql.= " AND ec.fk_socpeople = ".$userp->id; - if ($usert) $sql.= " AND ec.fk_socpeople = ".$usert->id; - $sql.= " AND ec.statut = 4"; - $sql.= " AND ctc.source = 'internal'"; + if ($userp) $sql .= " FROM ".MAIN_DB_PREFIX."projet as pt"; + if ($usert && $filteronprojstatus > -1) $sql .= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."projet_task as pt"; + if ($usert && $filteronprojstatus <= -1) $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sql .= " WHERE pt.rowid = ec.element_id"; + if ($userp && $filteronprojstatus > -1) $sql .= " AND pt.fk_statut = ".$filteronprojstatus; + if ($usert && $filteronprojstatus > -1) $sql .= " AND pt.fk_projet = p.rowid AND p.fk_statut = ".$filteronprojstatus; + if ($userp) $sql .= " AND ctc.element = 'project'"; + if ($usert) $sql .= " AND ctc.element = 'project_task'"; + $sql .= " AND ctc.rowid = ec.fk_c_type_contact"; + if ($userp) $sql .= " AND ec.fk_socpeople = ".$userp->id; + if ($usert) $sql .= " AND ec.fk_socpeople = ".$usert->id; + $sql .= " AND ec.statut = 4"; + $sql .= " AND ctc.source = 'internal'"; if ($projectid) { - if ($userp) $sql.= " AND pt.rowid in (".$projectid.")"; - if ($usert) $sql.= " AND pt.fk_projet in (".$projectid.")"; + if ($userp) $sql .= " AND pt.rowid in (".$projectid.")"; + if ($usert) $sql .= " AND pt.fk_projet in (".$projectid.")"; } if ($taskid) { - if ($userp) $sql.= " ERROR SHOULD NOT HAPPENS"; - if ($usert) $sql.= " AND pt.rowid = ".$taskid; + if ($userp) $sql .= " ERROR SHOULD NOT HAPPENS"; + if ($usert) $sql .= " AND pt.rowid = ".$taskid; } //print $sql; @@ -1034,7 +1034,7 @@ class Task extends CommonObject { $obj = $this->db->fetch_object($resql); if (empty($arrayroles[$obj->pid])) $arrayroles[$obj->pid] = $obj->code; - else $arrayroles[$obj->pid].=','.$obj->code; + else $arrayroles[$obj->pid] .= ','.$obj->code; $i++; } $this->db->free($resql); @@ -1059,7 +1059,7 @@ class Task extends CommonObject $contactAlreadySelected = array(); $tab = $this->liste_contact(-1, $source); //var_dump($tab); - $num=count($tab); + $num = count($tab); $i = 0; while ($i < $num) { @@ -1080,14 +1080,14 @@ class Task extends CommonObject */ public function addTimeSpent($user, $notrigger = 0) { - global $conf,$langs; + global $conf, $langs; dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); $ret = 0; // Check parameters - if (! is_object($user)) + if (!is_object($user)) { dol_print_error('', "Method addTimeSpent was called with wrong parameter user"); return -1; @@ -1100,41 +1100,41 @@ class Task extends CommonObject $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time ("; - $sql.= "fk_task"; - $sql.= ", task_date"; - $sql.= ", task_datehour"; - $sql.= ", task_date_withhour"; - $sql.= ", task_duration"; - $sql.= ", fk_user"; - $sql.= ", note"; - $sql.= ") VALUES ("; - $sql.= $this->id; - $sql.= ", '".$this->db->idate($this->timespent_date)."'"; - $sql.= ", '".$this->db->idate($this->timespent_datehour)."'"; - $sql.= ", ".(empty($this->timespent_withhour)?0:1); - $sql.= ", ".$this->timespent_duration; - $sql.= ", ".$this->timespent_fk_user; - $sql.= ", ".(isset($this->timespent_note)?"'".$this->db->escape($this->timespent_note)."'":"null"); - $sql.= ")"; + $sql .= "fk_task"; + $sql .= ", task_date"; + $sql .= ", task_datehour"; + $sql .= ", task_date_withhour"; + $sql .= ", task_duration"; + $sql .= ", fk_user"; + $sql .= ", note"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", '".$this->db->idate($this->timespent_date)."'"; + $sql .= ", '".$this->db->idate($this->timespent_datehour)."'"; + $sql .= ", ".(empty($this->timespent_withhour) ? 0 : 1); + $sql .= ", ".$this->timespent_duration; + $sql .= ", ".$this->timespent_fk_user; + $sql .= ", ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); + $sql .= ")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $tasktime_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_time"); $ret = $tasktime_id; $this->timespent_id = $ret; - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('TASK_TIMESPENT_CREATE', $user); - if ($result < 0) { $ret=-1; } + $result = $this->call_trigger('TASK_TIMESPENT_CREATE', $user); + if ($result < 0) { $ret = -1; } // End call triggers } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $ret = -1; } @@ -1142,30 +1142,30 @@ class Task extends CommonObject { // Recalculate amount of time spent for task and update denormalized field $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; - if (isset($this->progress)) $sql.= ", progress = " . $this->progress; // Do not overwrite value if not provided - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; + if (isset($this->progress)) $sql .= ", progress = ".$this->progress; // Do not overwrite value if not provided + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $ret = -2; } $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; - $sql.= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->timespent_fk_user.")"; // set average hour rate of user - $sql.= " WHERE rowid = ".$tasktime_id; + $sql .= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->timespent_fk_user.")"; // set average hour rate of user + $sql .= " WHERE rowid = ".$tasktime_id; dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $ret = -2; } } - if ($ret >0) + if ($ret > 0) { $this->db->commit(); } @@ -1187,47 +1187,47 @@ class Task extends CommonObject { global $langs; - if (is_object($userobj)) $userid=$userobj->id; - else $userid=$userobj; // old method + if (is_object($userobj)) $userid = $userobj->id; + else $userid = $userobj; // old method - $id=$this->id; + $id = $this->id; if (empty($id) && empty($userid)) { dol_syslog("getSummaryOfTimeSpent called on a not loaded task without user param defined", LOG_ERR); return -1; } - $result=array(); + $result = array(); $sql = "SELECT"; - $sql.= " MIN(t.task_datehour) as min_date,"; - $sql.= " MAX(t.task_datehour) as max_date,"; - $sql.= " SUM(t.task_duration) as total_duration,"; - $sql.= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as total_amount,"; - $sql.= " COUNT(t.rowid) as nblines,"; - $sql.= " SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql.= " WHERE 1 = 1"; - if ($morewherefilter) $sql.=$morewherefilter; - if ($id > 0) $sql.= " AND t.fk_task = ".$id; - if ($userid > 0) $sql.=" AND t.fk_user = ".$userid; + $sql .= " MIN(t.task_datehour) as min_date,"; + $sql .= " MAX(t.task_datehour) as max_date,"; + $sql .= " SUM(t.task_duration) as total_duration,"; + $sql .= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as total_amount,"; + $sql .= " COUNT(t.rowid) as nblines,"; + $sql .= " SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " WHERE 1 = 1"; + if ($morewherefilter) $sql .= $morewherefilter; + if ($id > 0) $sql .= " AND t.fk_task = ".$id; + if ($userid > 0) $sql .= " AND t.fk_user = ".$userid; dol_syslog(get_class($this)."::getSummaryOfTimeSpent", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - $result['min_date'] = $obj->min_date; // deprecated. use the ->timespent_xxx instead - $result['max_date'] = $obj->max_date; // deprecated. use the ->timespent_xxx instead - $result['total_duration'] = $obj->total_duration; // deprecated. use the ->timespent_xxx instead + $result['min_date'] = $obj->min_date; // deprecated. use the ->timespent_xxx instead + $result['max_date'] = $obj->max_date; // deprecated. use the ->timespent_xxx instead + $result['total_duration'] = $obj->total_duration; // deprecated. use the ->timespent_xxx instead - $this->timespent_min_date=$this->db->jdate($obj->min_date); - $this->timespent_max_date=$this->db->jdate($obj->max_date); - $this->timespent_total_duration=$obj->total_duration; - $this->timespent_total_amount=$obj->total_amount; - $this->timespent_nblinesnull=($obj->nblinesnull?$obj->nblinesnull:0); - $this->timespent_nblines=($obj->nblines?$obj->nblines:0); + $this->timespent_min_date = $this->db->jdate($obj->min_date); + $this->timespent_max_date = $this->db->jdate($obj->max_date); + $this->timespent_total_duration = $obj->total_duration; + $this->timespent_total_amount = $obj->total_amount; + $this->timespent_nblinesnull = ($obj->nblinesnull ? $obj->nblinesnull : 0); + $this->timespent_nblines = ($obj->nblines ? $obj->nblines : 0); $this->db->free($resql); } @@ -1250,33 +1250,33 @@ class Task extends CommonObject { global $langs; - if (empty($id)) $id=$this->id; + if (empty($id)) $id = $this->id; - $result=array(); + $result = array(); $sql = "SELECT"; - $sql.= " SUM(t.task_duration) as nbseconds,"; - $sql.= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql.= " WHERE t.fk_task = ".$id; + $sql .= " SUM(t.task_duration) as nbseconds,"; + $sql .= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " WHERE t.fk_task = ".$id; if (is_object($fuser) && $fuser->id > 0) { - $sql.=" AND fk_user = ".$fuser->id; + $sql .= " AND fk_user = ".$fuser->id; } if ($dates > 0) { - $datefieldname="task_datehour"; - $sql.=" AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; + $datefieldname = "task_datehour"; + $sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; } if ($datee > 0) { - $datefieldname="task_datehour"; - $sql.=" AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; + $datefieldname = "task_datehour"; + $sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; } //print $sql; dol_syslog(get_class($this)."::getSumOfAmount", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -1306,35 +1306,35 @@ class Task extends CommonObject global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.fk_task,"; - $sql.= " t.task_date,"; - $sql.= " t.task_datehour,"; - $sql.= " t.task_date_withhour,"; - $sql.= " t.task_duration,"; - $sql.= " t.fk_user,"; - $sql.= " t.thm,"; - $sql.= " t.note"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " t.rowid,"; + $sql .= " t.fk_task,"; + $sql .= " t.task_date,"; + $sql .= " t.task_datehour,"; + $sql .= " t.task_date_withhour,"; + $sql .= " t.task_duration,"; + $sql .= " t.fk_user,"; + $sql .= " t.thm,"; + $sql .= " t.note"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetchTimeSpent", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->timespent_id = $obj->rowid; - $this->id = $obj->fk_task; - $this->timespent_date = $this->db->jdate($obj->task_date); + $this->timespent_id = $obj->rowid; + $this->id = $obj->fk_task; + $this->timespent_date = $this->db->jdate($obj->task_date); $this->timespent_datehour = $this->db->jdate($obj->task_datehour); $this->timespent_withhour = $obj->task_date_withhour; - $this->timespent_duration = $obj->task_duration; + $this->timespent_duration = $obj->task_duration; $this->timespent_fk_user = $obj->fk_user; - $this->timespent_thm = $obj->thm; // hourly rate - $this->timespent_note = $obj->note; + $this->timespent_thm = $obj->thm; // hourly rate + $this->timespent_note = $obj->note; } $this->db->free($resql); @@ -1343,7 +1343,7 @@ class Task extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -1359,41 +1359,41 @@ class Task extends CommonObject { global $langs; - $arrayres=array(); + $arrayres = array(); $sql = "SELECT"; - $sql.= " s.rowid as socid,"; - $sql.= " s.nom as thirdparty_name,"; - $sql.= " s.email as thirdparty_email,"; - $sql.= " ptt.rowid,"; - $sql.= " ptt.fk_task,"; - $sql.= " ptt.task_date,"; - $sql.= " ptt.task_datehour,"; - $sql.= " ptt.task_date_withhour,"; - $sql.= " ptt.task_duration,"; - $sql.= " ptt.fk_user,"; - $sql.= " ptt.note,"; - $sql.= " pt.rowid as task_id,"; - $sql.= " pt.ref as task_ref,"; - $sql.= " pt.label as task_label,"; - $sql.= " p.rowid as project_id,"; - $sql.= " p.ref as project_ref,"; - $sql.= " p.title as project_label,"; - $sql.= " p.public as public"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as ptt, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - $sql.= " WHERE ptt.fk_task = pt.rowid AND pt.fk_projet = p.rowid"; - $sql.= " AND ptt.fk_user = ".$userobj->id; - $sql.= " AND pt.entity IN (".getEntity('project').")"; - if ($morewherefilter) $sql.=$morewherefilter; + $sql .= " s.rowid as socid,"; + $sql .= " s.nom as thirdparty_name,"; + $sql .= " s.email as thirdparty_email,"; + $sql .= " ptt.rowid,"; + $sql .= " ptt.fk_task,"; + $sql .= " ptt.task_date,"; + $sql .= " ptt.task_datehour,"; + $sql .= " ptt.task_date_withhour,"; + $sql .= " ptt.task_duration,"; + $sql .= " ptt.fk_user,"; + $sql .= " ptt.note,"; + $sql .= " pt.rowid as task_id,"; + $sql .= " pt.ref as task_ref,"; + $sql .= " pt.label as task_label,"; + $sql .= " p.rowid as project_id,"; + $sql .= " p.ref as project_ref,"; + $sql .= " p.title as project_label,"; + $sql .= " p.public as public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as ptt, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; + $sql .= " WHERE ptt.fk_task = pt.rowid AND pt.fk_projet = p.rowid"; + $sql .= " AND ptt.fk_user = ".$userobj->id; + $sql .= " AND pt.entity IN (".getEntity('project').")"; + if ($morewherefilter) $sql .= $morewherefilter; dol_syslog(get_class($this)."::fetchAllTimeSpent", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -1406,20 +1406,20 @@ class Task extends CommonObject $newobj->fk_project = $obj->project_id; $newobj->project_ref = $obj->project_ref; - $newobj->project_label = $obj->project_label; + $newobj->project_label = $obj->project_label; $newobj->public = $obj->project_public; $newobj->fk_task = $obj->task_id; - $newobj->task_ref = $obj->task_ref; - $newobj->task_label = $obj->task_label; + $newobj->task_ref = $obj->task_ref; + $newobj->task_label = $obj->task_label; - $newobj->timespent_id = $obj->rowid; - $newobj->timespent_date = $this->db->jdate($obj->task_date); + $newobj->timespent_id = $obj->rowid; + $newobj->timespent_date = $this->db->jdate($obj->task_date); $newobj->timespent_datehour = $this->db->jdate($obj->task_datehour); $newobj->timespent_withhour = $obj->task_date_withhour; $newobj->timespent_duration = $obj->task_duration; - $newobj->timespent_fk_user = $obj->fk_user; - $newobj->timespent_note = $obj->note; + $newobj->timespent_fk_user = $obj->fk_user; + $newobj->timespent_note = $obj->note; $arrayres[] = $newobj; @@ -1431,7 +1431,7 @@ class Task extends CommonObject else { dol_print_error($this->db); - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -1447,7 +1447,7 @@ class Task extends CommonObject */ public function updateTimeSpent($user, $notrigger = 0) { - global $conf,$langs; + global $conf, $langs; $ret = 0; @@ -1457,7 +1457,7 @@ class Task extends CommonObject $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")); return -1; } - if (! ($this->timespent_fk_user > 0)) + if (!($this->timespent_fk_user > 0)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("User")); return -1; @@ -1470,21 +1470,21 @@ class Task extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; - $sql.= " task_date = '".$this->db->idate($this->timespent_date)."',"; - $sql.= " task_datehour = '".$this->db->idate($this->timespent_datehour)."',"; - $sql.= " task_date_withhour = ".(empty($this->timespent_withhour)?0:1).","; - $sql.= " task_duration = ".$this->timespent_duration.","; - $sql.= " fk_user = ".$this->timespent_fk_user.","; - $sql.= " note = ".(isset($this->timespent_note)?"'".$this->db->escape($this->timespent_note)."'":"null"); - $sql.= " WHERE rowid = ".$this->timespent_id; + $sql .= " task_date = '".$this->db->idate($this->timespent_date)."',"; + $sql .= " task_datehour = '".$this->db->idate($this->timespent_datehour)."',"; + $sql .= " task_date_withhour = ".(empty($this->timespent_withhour) ? 0 : 1).","; + $sql .= " task_duration = ".$this->timespent_duration.","; + $sql .= " fk_user = ".$this->timespent_fk_user.","; + $sql .= " note = ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); + $sql .= " WHERE rowid = ".$this->timespent_id; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); - if ($this->db->query($sql) ) + if ($this->db->query($sql)) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('TASK_TIMESPENT_MODIFY', $user); + $result = $this->call_trigger('TASK_TIMESPENT_MODIFY', $user); if ($result < 0) { $this->db->rollback(); @@ -1497,7 +1497,7 @@ class Task extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); $ret = -1; } @@ -1507,13 +1507,13 @@ class Task extends CommonObject $newDuration = $this->timespent_duration - $this->timespent_old_duration; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->db->escape($this->id).")"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->db->escape($this->id).")"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); $ret = -2; } @@ -1534,42 +1534,42 @@ class Task extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time"; - $sql.= " WHERE rowid = ".$this->timespent_id; + $sql .= " WHERE rowid = ".$this->timespent_id; dol_syslog(get_class($this)."::delTimeSpent", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('TASK_TIMESPENT_DELETE', $user); + $result = $this->call_trigger('TASK_TIMESPENT_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } } - if (! $error) + if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = duration_effective - ".$this->db->escape($this->timespent_duration?$this->timespent_duration:0); - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET duration_effective = duration_effective - ".$this->db->escape($this->timespent_duration ? $this->timespent_duration : 0); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::delTimeSpent", LOG_DEBUG); - if ($this->db->query($sql) ) + if ($this->db->query($sql)) { $result = 0; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $result = -2; } } @@ -1577,13 +1577,13 @@ class Task extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delTimeSpent ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -1608,19 +1608,19 @@ class Task extends CommonObject */ public function createFromClone(User $user, $fromid, $project_id, $parent_task_id, $clone_change_dt = false, $clone_affectation = false, $clone_time = false, $clone_file = false, $clone_note = false, $clone_prog = false) { - global $langs,$conf; + global $langs, $conf; - $error=0; + $error = 0; //Use 00:00 of today if time is use on task. - $now=dol_mktime(0, 0, 0, dol_print_date(dol_now(), '%m'), dol_print_date(dol_now(), '%d'), dol_print_date(dol_now(), '%Y')); + $now = dol_mktime(0, 0, 0, dol_print_date(dol_now(), '%m'), dol_print_date(dol_now(), '%d'), dol_print_date(dol_now(), '%Y')); $datec = $now; - $clone_task=new Task($this->db); - $origin_task=new Task($this->db); + $clone_task = new Task($this->db); + $origin_task = new Task($this->db); - $clone_task->context['createfromclone']='createfromclone'; + $clone_task->context['createfromclone'] = 'createfromclone'; $this->db->begin(); @@ -1631,11 +1631,11 @@ class Task extends CommonObject $origin_task->fetch($fromid); - $defaultref=''; - $obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON; - if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) + $defaultref = ''; + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) { - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; + require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; $modTask = new $obj; $defaultref = $modTask->getNextValue(0, $clone_task); } @@ -1644,16 +1644,16 @@ class Task extends CommonObject $clone_task->id = 0; $clone_task->ref = $defaultref; - $clone_task->fk_project = $project_id; - $clone_task->fk_task_parent = $parent_task_id; - $clone_task->date_c = $datec; - $clone_task->planned_workload = $origin_task->planned_workload; - $clone_task->rang = $origin_task->rang; + $clone_task->fk_project = $project_id; + $clone_task->fk_task_parent = $parent_task_id; + $clone_task->date_c = $datec; + $clone_task->planned_workload = $origin_task->planned_workload; + $clone_task->rang = $origin_task->rang; //Manage Task Date if ($clone_change_dt) { - $projectstatic=new Project($this->db); + $projectstatic = new Project($this->db); $projectstatic->fetch($ori_project_id); //Origin project strat date @@ -1662,50 +1662,50 @@ class Task extends CommonObject //Calcultate new task start date with difference between origin proj start date and origin task start date if (!empty($clone_task->date_start)) { - $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start; + $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start; } //Calcultate new task end date with difference between origin proj end date and origin task end date if (!empty($clone_task->date_end)) { - $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start; + $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start; } } if (!$clone_prog) { - $clone_task->progress=0; + $clone_task->progress = 0; } // Create clone - $result=$clone_task->create($user); + $result = $clone_task->create($user); // Other options if ($result < 0) { - $this->error=$clone_task->error; + $this->error = $clone_task->error; $error++; } // End - if (! $error) + if (!$error) { - $clone_task_id=$clone_task->id; + $clone_task_id = $clone_task->id; $clone_task_ref = $clone_task->ref; //Note Update if (!$clone_note) { - $clone_task->note_private=''; - $clone_task->note_public=''; + $clone_task->note_private = ''; + $clone_task->note_public = ''; } else { $this->db->begin(); - $res=$clone_task->update_note(dol_html_entity_decode($clone_task->note_public, ENT_QUOTES), '_public'); + $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_public, ENT_QUOTES), '_public'); if ($res < 0) { - $this->error.=$clone_task->error; + $this->error .= $clone_task->error; $error++; $this->db->rollback(); } @@ -1715,10 +1715,10 @@ class Task extends CommonObject } $this->db->begin(); - $res=$clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES), '_private'); + $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES), '_private'); if ($res < 0) { - $this->error.=$clone_task->error; + $this->error .= $clone_task->error; $error++; $this->db->rollback(); } @@ -1734,39 +1734,39 @@ class Task extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; //retreive project origin ref to know folder to copy - $projectstatic=new Project($this->db); + $projectstatic = new Project($this->db); $projectstatic->fetch($ori_project_id); - $ori_project_ref=$projectstatic->ref; + $ori_project_ref = $projectstatic->ref; - if ($ori_project_id!=$project_id) + if ($ori_project_id != $project_id) { $projectstatic->fetch($project_id); - $clone_project_ref=$projectstatic->ref; + $clone_project_ref = $projectstatic->ref; } else { - $clone_project_ref=$ori_project_ref; + $clone_project_ref = $ori_project_ref; } - $clone_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($clone_project_ref). "/" . dol_sanitizeFileName($clone_task_ref); - $ori_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($ori_project_ref). "/" . dol_sanitizeFileName($fromid); + $clone_task_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($clone_project_ref)."/".dol_sanitizeFileName($clone_task_ref); + $ori_task_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($ori_project_ref)."/".dol_sanitizeFileName($fromid); - $filearray=dol_dir_list($ori_task_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); - foreach($filearray as $key => $file) + $filearray = dol_dir_list($ori_task_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); + foreach ($filearray as $key => $file) { if (!file_exists($clone_task_dir)) { if (dol_mkdir($clone_task_dir) < 0) { - $this->error.=$langs->trans('ErrorInternalErrorDetected').':dol_mkdir'; + $this->error .= $langs->trans('ErrorInternalErrorDetected').':dol_mkdir'; $error++; } } - $rescopy = dol_copy($ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name'], 0, 1); + $rescopy = dol_copy($ori_task_dir.'/'.$file['name'], $clone_task_dir.'/'.$file['name'], 0, 1); if (is_numeric($rescopy) && $rescopy < 0) { - $this->error.=$langs->trans("ErrorFailToCopyFile", $ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name']); + $this->error .= $langs->trans("ErrorFailToCopyFile", $ori_task_dir.'/'.$file['name'], $clone_task_dir.'/'.$file['name']); $error++; } } @@ -1778,10 +1778,10 @@ class Task extends CommonObject $origin_task = new Task($this->db); $origin_task->fetch($fromid); - foreach(array('internal','external') as $source) + foreach (array('internal', 'external') as $source) { $tab = $origin_task->liste_contact(-1, $source); - $num=count($tab); + $num = count($tab); $i = 0; while ($i < $num) { @@ -1789,14 +1789,14 @@ class Task extends CommonObject if ($clone_task->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - $this->error.=$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); + $this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); $error++; } else { - if ($clone_task->error!='') + if ($clone_task->error != '') { - $this->error.=$clone_task->error; + $this->error .= $clone_task->error; $error++; } } @@ -1805,7 +1805,7 @@ class Task extends CommonObject } } - if($clone_time) + if ($clone_time) { //TODO clone time of affectation } @@ -1813,7 +1813,7 @@ class Task extends CommonObject unset($clone_task->context['createfromclone']); - if (! $error) + if (!$error) { $this->db->commit(); return $clone_task_id; @@ -1821,7 +1821,7 @@ class Task extends CommonObject else { $this->db->rollback(); - dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : ".$this->error, LOG_ERR); return -1; } } @@ -1852,16 +1852,16 @@ class Task extends CommonObject global $langs; // list of Statut of the task - $this->statuts[0]='Draft'; - $this->statuts[1]='ToDo'; - $this->statuts[2]='Running'; - $this->statuts[3]='Finish'; - $this->statuts[4]='Transfered'; - $this->statuts_short[0]='Draft'; - $this->statuts_short[1]='ToDo'; - $this->statuts_short[2]='Running'; - $this->statuts_short[3]='Completed'; - $this->statuts_short[4]='Transfered'; + $this->statuts[0] = 'Draft'; + $this->statuts[1] = 'ToDo'; + $this->statuts[2] = 'Running'; + $this->statuts[3] = 'Finish'; + $this->statuts[4] = 'Transfered'; + $this->statuts_short[0] = 'Draft'; + $this->statuts_short[1] = 'ToDo'; + $this->statuts_short[2] = 'Running'; + $this->statuts_short[3] = 'Completed'; + $this->statuts_short[4] = 'Transfered'; if ($mode == 0) { @@ -1873,30 +1873,30 @@ class Task extends CommonObject } elseif ($mode == 2) { - if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts_short[$status]); + if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts_short[$status]); } elseif ($mode == 3) { - if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); - elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1'); - elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3'); - elseif ($status==3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - elseif ($status==4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - elseif ($status==5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5'); + if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1'); + elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3'); + elseif ($status == 3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + elseif ($status == 4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + elseif ($status == 5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5'); } elseif ($mode == 4) { - if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); - elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts[$status]); - elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts[$status]); - elseif ($status==3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); - elseif ($status==4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); - elseif ($status==5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts[$status]); + if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts[$status]); } elseif ($mode == 5) { @@ -1936,16 +1936,16 @@ class Task extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf,$langs; + global $conf, $langs; $langs->load("projects"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'nodefault'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->PROJECT_TASK_ADDON_PDF)) { + } elseif (!empty($conf->global->PROJECT_TASK_ADDON_PDF)) { $modele = $conf->global->PROJECT_TASK_ADDON_PDF; } } @@ -1976,38 +1976,38 @@ class Task extends CommonObject // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,"; - $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; - $sql.= " t.dateo as date_start, t.datee as datee"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + $sql .= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; + $sql .= " t.dateo as date_start, t.datee as datee"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; //if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; - $sql.= " AND p.fk_statut = 1"; - $sql.= " AND t.fk_projet = p.rowid"; - $sql.= " AND t.progress < 100"; // tasks to do - if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= " WHERE p.entity IN (".getEntity('project', 0).')'; + $sql .= " AND p.fk_statut = 1"; + $sql .= " AND t.fk_projet = p.rowid"; + $sql .= " AND t.progress < 100"; // tasks to do + if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser // if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; //print $sql; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $task_static = new Task($this->db); $response = new WorkboardResponse(); - $response->warning_delay = $conf->projet->task->warning_delay/60/60/24; + $response->warning_delay = $conf->projet->task->warning_delay / 60 / 60 / 24; $response->label = $langs->trans("OpenedTasks"); if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project'; else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project'; $response->img = img_object('', "task"); // This assignment in condition is not a bug. It allows walking the results. - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; @@ -2025,7 +2025,7 @@ class Task extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2042,32 +2042,32 @@ class Task extends CommonObject // phpcs:enable global $user; - $mine=0; $socid=$user->socid; + $mine = 0; $socid = $user->socid; $projectstatic = new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $mine, 1, $socid); // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT count(p.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; - $sql.= " AND t.fk_projet = p.rowid"; // tasks to do - if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= " WHERE p.entity IN (".getEntity('project', 0).')'; + $sql .= " AND t.fk_projet = p.rowid"; // tasks to do + if ($mine || !$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id.") OR (s.rowid IS NULL))"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // This assignment in condition is not a bug. It allows walking the results. - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["tasks"]=$obj->nb; + $this->nb["tasks"] = $obj->nb; } $this->db->free($resql); return 1; @@ -2075,7 +2075,7 @@ class Task extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2089,7 +2089,7 @@ class Task extends CommonObject { global $conf; - if (! ($this->progress >= 0 && $this->progress < 100)) { + if (!($this->progress >= 0 && $this->progress < 100)) { return false; } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index c2eb7fde29e..e43782c2603 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -34,8 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT."/core/class/commonobjectline.class.php"; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; /** @@ -43,11 +43,11 @@ if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande */ class Reception extends CommonObject { - public $element="reception"; - public $fk_element="fk_reception"; - public $table_element="reception"; - public $table_element_line="commande_fournisseur_dispatch"; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $element = "reception"; + public $fk_element = "fk_reception"; + public $table_element = "reception"; + public $table_element_line = "commande_fournisseur_dispatch"; + protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -59,7 +59,7 @@ class Reception extends CommonObject public $ref_int; public $brouillon; public $entrepot_id; - public $lines=array(); + public $lines = array(); public $tracking_number; public $tracking_url; public $billed; @@ -76,7 +76,7 @@ class Reception extends CommonObject // A denormalized value public $trueSize; - public $date_delivery; // Date delivery planed + public $date_delivery; // Date delivery planed /** @@ -95,7 +95,7 @@ class Reception extends CommonObject public $date_valid; public $meths; - public $listmeths; // List of carriers + public $listmeths; // List of carriers const STATUS_DRAFT = 0; @@ -155,10 +155,10 @@ class Reception extends CommonObject $dir = dol_buildpath($reldir."core/modules/reception/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } - if (! $mybool) + if (!$mybool) { dol_print_error('', "Failed to include file ".$file); return ''; @@ -169,7 +169,7 @@ class Reception extends CommonObject $numref = ""; $numref = $obj->getNextValue($soc, $this); - if ( $numref != "") + if ($numref != "") { return $numref; } @@ -197,9 +197,9 @@ class Reception extends CommonObject { global $conf, $hookmanager; - $now=dol_now(); + $now = dol_now(); - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $error = 0; // Clean parameters @@ -213,82 +213,82 @@ class Reception extends CommonObject $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."reception ("; - $sql.= "ref"; - $sql.= ", entity"; - $sql.= ", ref_supplier"; - $sql.= ", ref_int"; - $sql.= ", date_creation"; - $sql.= ", fk_user_author"; - $sql.= ", date_reception"; - $sql.= ", date_delivery"; - $sql.= ", fk_soc"; - $sql.= ", fk_projet"; - $sql.= ", fk_shipping_method"; - $sql.= ", tracking_number"; - $sql.= ", weight"; - $sql.= ", size"; - $sql.= ", width"; - $sql.= ", height"; - $sql.= ", weight_units"; - $sql.= ", size_units"; - $sql.= ", note_private"; - $sql.= ", note_public"; - $sql.= ", model_pdf"; - $sql.= ", fk_incoterms, location_incoterms"; - $sql.= ") VALUES ("; - $sql.= "'(PROV)'"; - $sql.= ", ".$conf->entity; - $sql.= ", ".($this->ref_supplier?"'".$this->db->escape($this->ref_supplier)."'":"null"); - $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".$user->id; - $sql.= ", ".($this->date_reception>0?"'".$this->db->idate($this->date_reception)."'":"null"); - $sql.= ", ".($this->date_delivery>0?"'".$this->db->idate($this->date_delivery)."'":"null"); - $sql.= ", ".$this->socid; - $sql.= ", ".$this->fk_project; - $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:"null"); - $sql.= ", '".$this->db->escape($this->tracking_number)."'"; - $sql.= ", ".$this->weight; - $sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth - $sql.= ", ".$this->sizeW; // TODO Should use this->trueWidth - $sql.= ", ".$this->sizeH; // TODO Should use this->trueHeight - $sql.= ", ".$this->weight_units; - $sql.= ", ".$this->size_units; - $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); - $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); - $sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null"); - $sql.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ")"; + $sql .= "ref"; + $sql .= ", entity"; + $sql .= ", ref_supplier"; + $sql .= ", ref_int"; + $sql .= ", date_creation"; + $sql .= ", fk_user_author"; + $sql .= ", date_reception"; + $sql .= ", date_delivery"; + $sql .= ", fk_soc"; + $sql .= ", fk_projet"; + $sql .= ", fk_shipping_method"; + $sql .= ", tracking_number"; + $sql .= ", weight"; + $sql .= ", size"; + $sql .= ", width"; + $sql .= ", height"; + $sql .= ", weight_units"; + $sql .= ", size_units"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", model_pdf"; + $sql .= ", fk_incoterms, location_incoterms"; + $sql .= ") VALUES ("; + $sql .= "'(PROV)'"; + $sql .= ", ".$conf->entity; + $sql .= ", ".($this->ref_supplier ? "'".$this->db->escape($this->ref_supplier)."'" : "null"); + $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".$user->id; + $sql .= ", ".($this->date_reception > 0 ? "'".$this->db->idate($this->date_reception)."'" : "null"); + $sql .= ", ".($this->date_delivery > 0 ? "'".$this->db->idate($this->date_delivery)."'" : "null"); + $sql .= ", ".$this->socid; + $sql .= ", ".$this->fk_project; + $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : "null"); + $sql .= ", '".$this->db->escape($this->tracking_number)."'"; + $sql .= ", ".$this->weight; + $sql .= ", ".$this->sizeS; // TODO Should use this->trueDepth + $sql .= ", ".$this->sizeW; // TODO Should use this->trueWidth + $sql .= ", ".$this->sizeH; // TODO Should use this->trueHeight + $sql .= ", ".$this->weight_units; + $sql .= ", ".$this->size_units; + $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ", ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); + $sql .= ", ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null"); + $sql .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."reception"); $sql = "UPDATE ".MAIN_DB_PREFIX."reception"; - $sql.= " SET ref = '(PROV".$this->id.")'"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET ref = '(PROV".$this->id.")'"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::create", LOG_DEBUG); if ($this->db->query($sql)) { // Insert of lines - $num=count($this->lines); + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { $this->lines[$i]->fk_reception = $this->id; - if (! $this->lines[$i]->create($user) > 0) + if (!$this->lines[$i]->create($user) > 0) { $error++; } } - if (! $error && $this->id && $this->origin_id) + if (!$error && $this->id && $this->origin_id) { $ret = $this->add_object_linked(); if (!$ret) @@ -299,15 +299,15 @@ class Reception extends CommonObject // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! - $action='add'; + $action = 'add'; $hookmanager->initHooks(array('receptiondao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('socid'=>$this->id); + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -316,33 +316,33 @@ class Reception extends CommonObject } elseif ($reshook < 0) $error++; - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('RECEPTION_CREATE', $user); + $result = $this->call_trigger('RECEPTION_CREATE', $user); if ($result < 0) { $error++; } // End call triggers - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else { $error++; - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -3; } @@ -350,7 +350,7 @@ class Reception extends CommonObject else { $error++; - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -2; } @@ -358,7 +358,7 @@ class Reception extends CommonObject else { $error++; - $this->error=$this->db->error()." - sql=$sql"; + $this->error = $this->db->error()." - sql=$sql"; $this->db->rollback(); return -1; } @@ -383,21 +383,21 @@ class Reception extends CommonObject if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_supplier, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut"; - $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; - $sql.= ", e.date_reception as date_reception, e.model_pdf, e.date_delivery"; - $sql.= ", e.fk_shipping_method, e.tracking_number"; - $sql.= ", el.fk_source as origin_id, el.sourcetype as origin"; - $sql.= ", e.note_private, e.note_public"; - $sql.= ', e.fk_incoterms, e.location_incoterms'; - $sql.= ', i.libelle as label_incoterms'; - $sql.= " FROM ".MAIN_DB_PREFIX."reception as e"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; - $sql.= " WHERE e.entity IN (".getEntity('reception').")"; - if ($id) $sql.= " AND e.rowid=".$id; - if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'"; - if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql.= " AND e.ref_int='".$this->db->escape($ref_int)."'"; + $sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; + $sql .= ", e.date_reception as date_reception, e.model_pdf, e.date_delivery"; + $sql .= ", e.fk_shipping_method, e.tracking_number"; + $sql .= ", el.fk_source as origin_id, el.sourcetype as origin"; + $sql .= ", e.note_private, e.note_public"; + $sql .= ', e.fk_incoterms, e.location_incoterms'; + $sql .= ', i.libelle as label_incoterms'; + $sql .= " FROM ".MAIN_DB_PREFIX."reception as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; + $sql .= " WHERE e.entity IN (".getEntity('reception').")"; + if ($id) $sql .= " AND e.rowid=".$id; + if ($ref) $sql .= " AND e.ref='".$this->db->escape($ref)."'"; + if ($ref_ext) $sql .= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql .= " AND e.ref_int='".$this->db->escape($ref_int)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -410,23 +410,23 @@ class Reception extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->ref; $this->socid = $obj->socid; - $this->ref_supplier = $obj->ref_supplier; + $this->ref_supplier = $obj->ref_supplier; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date = $this->db->jdate($obj->date_reception); // TODO deprecated - $this->date_reception = $this->db->jdate($obj->date_reception); // TODO deprecated - $this->date_reception = $this->db->jdate($obj->date_reception); // Date real - $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed + $this->date = $this->db->jdate($obj->date_reception); // TODO deprecated + $this->date_reception = $this->db->jdate($obj->date_reception); // TODO deprecated + $this->date_reception = $this->db->jdate($obj->date_reception); // Date real + $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->fk_delivery_address = $obj->fk_address; $this->modelpdf = $obj->model_pdf; - $this->shipping_method_id = $obj->fk_shipping_method; + $this->shipping_method_id = $obj->fk_shipping_method; $this->tracking_number = $obj->tracking_number; - $this->origin = ($obj->origin?$obj->origin:'commande'); // For compatibility + $this->origin = ($obj->origin ? $obj->origin : 'commande'); // For compatibility $this->origin_id = $obj->origin_id; - $this->billed = ($obj->fk_statut==2?1:0); + $this->billed = ($obj->fk_statut == 2 ? 1 : 0); $this->trueWeight = $obj->weight; $this->weight_units = $obj->weight_units; @@ -442,8 +442,8 @@ class Reception extends CommonObject $this->note_private = $obj->note_private; // A denormalized value - $this->trueSize = $obj->size."x".$obj->width."x".$obj->height; - $this->size_units = $obj->size_units; + $this->trueSize = $obj->size."x".$obj->width."x".$obj->height; + $this->size_units = $obj->size_units; //Incoterms $this->fk_incoterms = $obj->fk_incoterms; @@ -454,7 +454,7 @@ class Reception extends CommonObject if ($this->statut == 0) $this->brouillon = 1; - $file = $conf->reception->dir_output . "/" .get_exdir($this->id, 2, 0, 0, $this, 'reception') . "/" . $this->id.".pdf"; + $file = $conf->reception->dir_output."/".get_exdir($this->id, 2, 0, 0, $this, 'reception')."/".$this->id.".pdf"; $this->pdf_filename = $file; // Tracking url @@ -463,20 +463,20 @@ class Reception extends CommonObject /* * Thirdparty */ - $result=$this->fetch_thirdparty(); + $result = $this->fetch_thirdparty(); // Retrieve all extrafields for reception // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); + $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id); /* * Lines */ - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { return -3; @@ -487,13 +487,13 @@ class Reception extends CommonObject else { dol_syslog(get_class($this).'::Fetch no reception found', LOG_ERR); - $this->error='Delivery with id '.$id.' not found'; + $this->error = 'Delivery with id '.$id.' not found'; return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -520,10 +520,10 @@ class Reception extends CommonObject return 0; } - if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->reception_advance->validate)))) + if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)))) { - $this->error='Permission denied'; + $this->error = 'Permission denied'; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); return -1; } @@ -538,7 +538,7 @@ class Reception extends CommonObject // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $numref = $this->getNextNumRef($soc); } @@ -548,25 +548,25 @@ class Reception extends CommonObject $this->newref = $numref; - $now=dol_now(); + $now = dol_now(); // Validate $sql = "UPDATE ".MAIN_DB_PREFIX."reception SET"; - $sql.= " ref='".$this->db->escape($numref)."'"; - $sql.= ", fk_statut = 1"; - $sql.= ", date_valid = '".$this->db->idate($now)."'"; - $sql.= ", fk_user_valid = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " ref='".$this->db->escape($numref)."'"; + $sql .= ", fk_statut = 1"; + $sql .= ", date_valid = '".$this->db->idate($now)."'"; + $sql .= ", fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::valid update reception", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } // If stock increment is done on reception (recommanded choice) - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -575,15 +575,15 @@ class Reception extends CommonObject // Loop on each product line to add a stock movement // TODO in future, reception lines may not be linked to order line $sql = "SELECT cd.fk_product, cd.subprice,"; - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql.= " ed.eatby, ed.sellby, ed.batch"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; - $sql.= " WHERE ed.fk_reception = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " ed.eatby, ed.sellby, ed.batch"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; + $sql .= " WHERE ed.fk_reception = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_commandefourndet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -605,10 +605,10 @@ class Reception extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref)); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref)); if ($result < 0) { $error++; - $this->errors[]=$mouvS->error; + $this->errors[] = $mouvS->error; $this->errors = array_merge($this->errors, $mouvS->errors); break; } @@ -619,10 +619,10 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); if ($result < 0) { $error++; - $this->errors[]=$mouvS->error; + $this->errors[] = $mouvS->error; $this->errors = array_merge($this->errors, $mouvS->errors); break; } @@ -632,7 +632,7 @@ class Reception extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -2; } } @@ -640,20 +640,20 @@ class Reception extends CommonObject // Change status of order to "reception in process" $ret = $this->setStatut(4, $this->origin_id, 'commande_fournisseur'); - if (! $ret) + if (!$ret) { $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('RECEPTION_VALIDATE', $user); + $result = $this->call_trigger('RECEPTION_VALIDATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -661,17 +661,17 @@ class Reception extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'reception/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'reception/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'reception/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'reception/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($numref); $dirsource = $conf->reception->dir_output.'/'.$oldref; $dirdest = $conf->reception->dir_output.'/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); @@ -679,13 +679,13 @@ class Reception extends CommonObject { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->reception->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->reception->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -694,26 +694,26 @@ class Reception extends CommonObject } // Set new ref and current status - if (! $error) + if (!$error) { $this->ref = $numref; $this->statut = 1; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::valid ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -748,31 +748,31 @@ class Reception extends CommonObject $supplierorderline = new CommandeFournisseurLigne($this->db); $supplierorderline->fetch($id); - if (! empty($conf->stock->enabled) && ! empty($supplierorderline->fk_product)) + if (!empty($conf->stock->enabled) && !empty($supplierorderline->fk_product)) { $fk_product = $supplierorderline->fk_product; - if (! ($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_RECEPTIONS)) + if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_RECEPTIONS)) { $langs->load("errors"); - $this->error=$langs->trans("ErrorWarehouseRequiredIntoReceptionLine"); + $this->error = $langs->trans("ErrorWarehouseRequiredIntoReceptionLine"); return -1; } } // extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used $line->array_options = $array_options; $line->fk_product = $fk_product; - $line->fk_commande = $supplierorderline->fk_commande ; - $line->fk_user = $user->id ; + $line->fk_commande = $supplierorderline->fk_commande; + $line->fk_user = $user->id; $line->comment = $comment; $line->batch = $batch; $line->eatby = $eatby; $line->sellby = $sellby; - $line->status=1; - $line->fk_reception=$this->id; + $line->status = 1; + $line->fk_reception = $this->id; $this->lines[$num] = $line; } @@ -788,29 +788,29 @@ class Reception extends CommonObject public function update($user = null, $notrigger = 0) { global $conf; - $error=0; + $error = 0; // Clean parameters - if (isset($this->ref)) $this->ref=trim($this->ref); - if (isset($this->entity)) $this->entity=trim($this->entity); - if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier); - if (isset($this->socid)) $this->socid=trim($this->socid); - if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); - if (isset($this->fk_user_valid)) $this->fk_user_valid=trim($this->fk_user_valid); - if (isset($this->fk_delivery_address)) $this->fk_delivery_address=trim($this->fk_delivery_address); - if (isset($this->shipping_method_id)) $this->shipping_method_id=trim($this->shipping_method_id); - if (isset($this->tracking_number)) $this->tracking_number=trim($this->tracking_number); - if (isset($this->statut)) $this->statut=(int) $this->statut; - if (isset($this->trueDepth)) $this->trueDepth=trim($this->trueDepth); - if (isset($this->trueWidth)) $this->trueWidth=trim($this->trueWidth); - if (isset($this->trueHeight)) $this->trueHeight=trim($this->trueHeight); - if (isset($this->size_units)) $this->size_units=trim($this->size_units); - if (isset($this->weight_units)) $this->weight_units=trim($this->weight_units); - if (isset($this->trueWeight)) $this->weight=trim($this->trueWeight); - if (isset($this->note_private)) $this->note=trim($this->note_private); - if (isset($this->note_public)) $this->note=trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); + if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->entity)) $this->entity = trim($this->entity); + if (isset($this->ref_supplier)) $this->ref_supplier = trim($this->ref_supplier); + if (isset($this->socid)) $this->socid = trim($this->socid); + if (isset($this->fk_user_author)) $this->fk_user_author = trim($this->fk_user_author); + if (isset($this->fk_user_valid)) $this->fk_user_valid = trim($this->fk_user_valid); + if (isset($this->fk_delivery_address)) $this->fk_delivery_address = trim($this->fk_delivery_address); + if (isset($this->shipping_method_id)) $this->shipping_method_id = trim($this->shipping_method_id); + if (isset($this->tracking_number)) $this->tracking_number = trim($this->tracking_number); + if (isset($this->statut)) $this->statut = (int) $this->statut; + if (isset($this->trueDepth)) $this->trueDepth = trim($this->trueDepth); + if (isset($this->trueWidth)) $this->trueWidth = trim($this->trueWidth); + if (isset($this->trueHeight)) $this->trueHeight = trim($this->trueHeight); + if (isset($this->size_units)) $this->size_units = trim($this->size_units); + if (isset($this->weight_units)) $this->weight_units = trim($this->weight_units); + if (isset($this->trueWeight)) $this->weight = trim($this->trueWeight); + if (isset($this->note_private)) $this->note = trim($this->note_private); + if (isset($this->note_public)) $this->note = trim($this->note_public); + if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); // Check parameters @@ -819,44 +819,44 @@ class Reception extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."reception SET"; - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; - $sql.= " ref_supplier=".(isset($this->ref_supplier)?"'".$this->db->escape($this->ref_supplier)."'":"null").","; - $sql.= " fk_soc=".(isset($this->socid)?$this->socid:"null").","; - $sql.= " date_creation=".(dol_strlen($this->date_creation)!=0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; - $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; - $sql.= " date_valid=".(dol_strlen($this->date_valid)!=0 ? "'".$this->db->idate($this->date_valid)."'" : 'null').","; - $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->fk_user_valid:"null").","; - $sql.= " date_reception=".(dol_strlen($this->date_reception)!=0 ? "'".$this->db->idate($this->date_reception)."'" : 'null').","; - $sql.= " date_delivery=".(dol_strlen($this->date_delivery)!=0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').","; - $sql.= " fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0)?$this->shipping_method_id:"null").","; - $sql.= " tracking_number=".(isset($this->tracking_number)?"'".$this->db->escape($this->tracking_number)."'":"null").","; - $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").","; - $sql.= " height=".(($this->trueHeight != '')?$this->trueHeight:"null").","; - $sql.= " width=".(($this->trueWidth != '')?$this->trueWidth:"null").","; - $sql.= " size_units=".(isset($this->size_units)?$this->size_units:"null").","; - $sql.= " size=".(($this->trueDepth != '')?$this->trueDepth:"null").","; - $sql.= " weight_units=".(isset($this->weight_units)?$this->weight_units:"null").","; - $sql.= " weight=".(($this->trueWeight != '')?$this->trueWeight:"null").","; - $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; - $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; - $sql.= " entity=".$conf->entity; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " ref_supplier=".(isset($this->ref_supplier) ? "'".$this->db->escape($this->ref_supplier)."'" : "null").","; + $sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").","; + $sql .= " date_creation=".(dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; + $sql .= " fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author : "null").","; + $sql .= " date_valid=".(dol_strlen($this->date_valid) != 0 ? "'".$this->db->idate($this->date_valid)."'" : 'null').","; + $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? $this->fk_user_valid : "null").","; + $sql .= " date_reception=".(dol_strlen($this->date_reception) != 0 ? "'".$this->db->idate($this->date_reception)."'" : 'null').","; + $sql .= " date_delivery=".(dol_strlen($this->date_delivery) != 0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').","; + $sql .= " fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? $this->shipping_method_id : "null").","; + $sql .= " tracking_number=".(isset($this->tracking_number) ? "'".$this->db->escape($this->tracking_number)."'" : "null").","; + $sql .= " fk_statut=".(isset($this->statut) ? $this->statut : "null").","; + $sql .= " height=".(($this->trueHeight != '') ? $this->trueHeight : "null").","; + $sql .= " width=".(($this->trueWidth != '') ? $this->trueWidth : "null").","; + $sql .= " size_units=".(isset($this->size_units) ? $this->size_units : "null").","; + $sql .= " size=".(($this->trueDepth != '') ? $this->trueDepth : "null").","; + $sql .= " weight_units=".(isset($this->weight_units) ? $this->weight_units : "null").","; + $sql .= " weight=".(($this->trueWeight != '') ? $this->trueWeight : "null").","; + $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; + $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; + $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; + $sql .= " entity=".$conf->entity; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('RECEPTION_MODIFY', $user); + $result = $this->call_trigger('RECEPTION_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -865,13 +865,13 @@ class Reception extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -891,8 +891,8 @@ class Reception extends CommonObject global $conf, $langs, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; - $this->error=''; + $error = 0; + $this->error = ''; $this->db->begin(); @@ -906,13 +906,13 @@ class Reception extends CommonObject // Loop on each product line to add a stock movement $sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.eatby, ed.sellby, ed.batch, ed.rowid as commande_fournisseur_dispatch_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; - $sql.= " WHERE ed.fk_reception = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; + $sql .= " WHERE ed.fk_reception = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_commandefourndet"; dol_syslog(get_class($this)."::delete select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -925,42 +925,42 @@ class Reception extends CommonObject // we do not log origin because it will be deleted $mouvS->origin = null; - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ReceptionDeletedInDolibarr", $this->ref), '', $obj->eatby, $obj->sellby, $obj->batch); // Price is set to 0, because we don't want to see WAP changed + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ReceptionDeletedInDolibarr", $this->ref), '', $obj->eatby, $obj->sellby, $obj->batch); // Price is set to 0, because we don't want to see WAP changed } } else { - $error++;$this->errors[]="Error ".$this->db->lasterror(); + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch"; - $sql.= " WHERE fk_reception = ".$this->id; + $sql .= " WHERE fk_reception = ".$this->id; - if ( $this->db->query($sql) ) + if ($this->db->query($sql)) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."reception"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; if ($this->db->query($sql)) { // Call trigger - $result=$this->call_trigger('RECEPTION_DELETE', $user); + $result = $this->call_trigger('RECEPTION_DELETE', $user); if ($result < 0) { $error++; } // End call triggers - if (! empty($this->origin) && $this->origin_id > 0) + if (!empty($this->origin) && $this->origin_id > 0) { $this->fetch_origin(); - $origin=$this->origin; + $origin = $this->origin; if ($this->$origin->statut == 4) // If order source of reception is "partially received" { // Check if there is no more reception. If not, we can move back status of order to "validated" instead of "reception in progress" @@ -973,19 +973,19 @@ class Reception extends CommonObject } } - if (! $error) + if (!$error) { $this->db->commit(); // We delete PDFs $ref = dol_sanitizeFileName($this->ref); - if (! empty($conf->reception->dir_output)) + if (!empty($conf->reception->dir_output)) { - $dir = $conf->reception->dir_output . '/' . $ref ; - $file = $dir . '/' . $ref . '.pdf'; + $dir = $conf->reception->dir_output.'/'.$ref; + $file = $dir.'/'.$ref.'.pdf'; if (file_exists($file)) { - if (! dol_delete_file($file)) + if (!dol_delete_file($file)) { return 0; } @@ -994,7 +994,7 @@ class Reception extends CommonObject { if (!dol_delete_dir_recursive($dir)) { - $this->error=$langs->trans("ErrorCanNotDeleteDir", $dir); + $this->error = $langs->trans("ErrorCanNotDeleteDir", $dir); return 0; } } @@ -1010,21 +1010,21 @@ class Reception extends CommonObject } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -3; } } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -2; } } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -1; } @@ -1050,41 +1050,41 @@ class Reception extends CommonObject $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch WHERE fk_reception='.$this->id; $resql = $db->query($sql); - if(!empty($resql)){ + if (!empty($resql)) { $this->lines = array(); - while ($obj = $resql->fetch_object()){ + while ($obj = $resql->fetch_object()) { $line = new CommandeFournisseurDispatch($db); $line->fetch($obj->rowid); $line->fetch_product(); $sql_commfourndet = 'SELECT qty, ref, label, tva_tx, vat_src_code, subprice, multicurrency_subprice, remise_percent FROM llx_commande_fournisseurdet WHERE rowid='.$line->fk_commandefourndet; $resql_commfourndet = $db->query($sql_commfourndet); - if(!empty($resql_commfourndet)){ + if (!empty($resql_commfourndet)) { $obj = $db->fetch_object($resql_commfourndet); $line->qty_asked = $obj->qty; $line->description = $line->comment; - $line->desc = $line->comment; + $line->desc = $line->comment; $line->tva_tx = $obj->tva_tx; $line->vat_src_code = $obj->vat_src_code; $line->subprice = $obj->subprice; $line->multicurrency_subprice = $obj->multicurrency_subprice; $line->remise_percent = $obj->remise_percent; - $line->label = !empty($obj->label)?$obj->label:$line->product->label; + $line->label = !empty($obj->label) ? $obj->label : $line->product->label; $line->ref_supplier = $obj->ref; - }else { + } else { $line->qty_asked = 0; $line->description = ''; $line->label = $obj->label; } - $pu_ht=($line->subprice*$line->qty)*(100-$line->remise_percent)/100; - $tva = $pu_ht*$line->tva_tx/100; + $pu_ht = ($line->subprice * $line->qty) * (100 - $line->remise_percent) / 100; + $tva = $pu_ht * $line->tva_tx / 100; $this->total_ht += $pu_ht; - $this->total_tva += $pu_ht*$line->tva_tx/100; + $this->total_tva += $pu_ht * $line->tva_tx / 100; - $this->total_ttc += $pu_ht+$tva; + $this->total_ttc += $pu_ht + $tva; - $this->lines[]=$line; + $this->lines[] = $line; } return 1; @@ -1107,35 +1107,35 @@ class Reception extends CommonObject public function getNomUrl($withpicto = 0, $option = 0, $max = 0, $short = 0, $notooltip = 0) { global $langs; - $result=''; - $label = '' . $langs->trans("ShowReception") . ''; - $label .= '
    ' . $langs->trans('Ref') . ': '.$this->ref; + $result = ''; + $label = ''.$langs->trans("ShowReception").''; + $label .= '
    '.$langs->trans('Ref').': '.$this->ref; $label .= '
    '.$langs->trans('RefSupplier').': '.($this->ref_supplier ? $this->ref_supplier : $this->ref_client); $url = DOL_URL_ROOT.'/reception/card.php?id='.$this->id; if ($short) return $url; - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowReception"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowReception"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } $linkstart = ''; - $linkend=''; + $linkend = ''; - $picto='sending'; + $picto = 'sending'; - if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); - if ($withpicto && $withpicto != 2) $result.=' '; - $result.=$linkstart.$this->ref.$linkend; + if ($withpicto) $result .= ($linkstart.img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend); + if ($withpicto && $withpicto != 2) $result .= ' '; + $result .= $linkstart.$this->ref.$linkend; return $result; } @@ -1186,7 +1186,7 @@ class Reception extends CommonObject include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; - $now=dol_now(); + $now = dol_now(); dol_syslog(get_class($this)."::initAsSpecimen"); @@ -1194,8 +1194,8 @@ class Reception extends CommonObject $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -1209,20 +1209,20 @@ class Reception extends CommonObject } } - $order=new CommandeFournisseur($this->db); + $order = new CommandeFournisseur($this->db); $order->initAsSpecimen(); // Initialise parametres - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->statut = 1; $this->livraison_id = 0; $this->date = $now; $this->date_creation = $now; $this->date_valid = $now; $this->date_delivery = $now; - $this->date_reception = $now + 24*3600; + $this->date_reception = $now + 24 * 3600; $this->entrepot_id = 0; $this->fk_delivery_address = 0; @@ -1241,14 +1241,14 @@ class Reception extends CommonObject $xnbp = 0; while ($xnbp < $nbp) { - $line=new CommandeFournisseurDispatch($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->libelle=$langs->trans("Description")." ".$xnbp; - $line->qty=10; + $line = new CommandeFournisseurDispatch($this->db); + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->libelle = $langs->trans("Description")." ".$xnbp; + $line->qty = 10; - $line->fk_product=$this->commande->lines[$xnbp]->fk_product; + $line->fk_product = $this->commande->lines[$xnbp]->fk_product; - $this->lines[]=$line; + $this->lines[] = $line; $xnbp++; } } @@ -1267,11 +1267,11 @@ class Reception extends CommonObject if ($user->rights->reception->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."reception"; - $sql.= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::set_date_livraison", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->date_delivery = $date_livraison; @@ -1279,7 +1279,7 @@ class Reception extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1302,17 +1302,17 @@ class Reception extends CommonObject $this->meths = array(); $sql = "SELECT em.rowid, em.code, em.libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql.= " WHERE em.active = 1"; - $sql.= " ORDER BY em.libelle ASC"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + $sql .= " WHERE em.active = 1"; + $sql .= " ORDER BY em.libelle ASC"; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { - $label=$langs->trans('ReceptionMethod'.$obj->code); - $this->meths[$obj->rowid] = ($label != 'ReceptionMethod'.$obj->code?$label:$obj->libelle); + $label = $langs->trans('ReceptionMethod'.$obj->code); + $this->meths[$obj->rowid] = ($label != 'ReceptionMethod'.$obj->code ? $label : $obj->libelle); } } } @@ -1330,19 +1330,19 @@ class Reception extends CommonObject global $langs; $this->listmeths = array(); - $i=0; + $i = 0; $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - if ($id!='') $sql.= " WHERE em.rowid=".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + if ($id != '') $sql .= " WHERE em.rowid=".$id; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { $this->listmeths[$i]['rowid'] = $obj->rowid; $this->listmeths[$i]['code'] = $obj->code; - $label=$langs->trans('ReceptionMethod'.$obj->code); - $this->listmeths[$i]['libelle'] = ($label != 'ReceptionMethod'.$obj->code?$label:$obj->libelle); + $label = $langs->trans('ReceptionMethod'.$obj->code); + $this->listmeths[$i]['libelle'] = ($label != 'ReceptionMethod'.$obj->code ? $label : $obj->libelle); $this->listmeths[$i]['description'] = $obj->description; $this->listmeths[$i]['tracking'] = $obj->tracking; $this->listmeths[$i]['active'] = $obj->active; @@ -1362,20 +1362,20 @@ class Reception extends CommonObject public function update_delivery_method($id = '') { // phpcs:enable - if ($id=='') + if ($id == '') { $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; - $sql.=" VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; + $sql .= " VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; $resql = $this->db->query($sql); } else { $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; - $sql.= " code='".$this->db->escape($this->update['code'])."'"; - $sql.= ",libelle='".$this->db->escape($this->update['libelle'])."'"; - $sql.= ",description='".$this->db->escape($this->update['description'])."'"; - $sql.= ",tracking='".$this->db->escape($this->update['tracking'])."'"; - $sql.= " WHERE rowid=".$id; + $sql .= " code='".$this->db->escape($this->update['code'])."'"; + $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; + $sql .= ",description='".$this->db->escape($this->update['description'])."'"; + $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; + $sql .= " WHERE rowid=".$id; $resql = $this->db->query($sql); } if ($resql < 0) dol_print_error($this->db, ''); @@ -1393,7 +1393,7 @@ class Reception extends CommonObject { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; - $sql.= ' WHERE rowid='.$id; + $sql .= ' WHERE rowid='.$id; $resql = $this->db->query($sql); } @@ -1410,7 +1410,7 @@ class Reception extends CommonObject { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; - $sql.= ' WHERE rowid='.$id; + $sql .= ' WHERE rowid='.$id; $resql = $this->db->query($sql); } @@ -1424,11 +1424,11 @@ class Reception extends CommonObject */ public function getUrlTrackingStatus($value = '') { - if (! empty($this->shipping_method_id)) + if (!empty($this->shipping_method_id)) { $sql = "SELECT em.code, em.tracking"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql.= " WHERE em.rowid = ".$this->shipping_method_id; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + $sql .= " WHERE em.rowid = ".$this->shipping_method_id; $resql = $this->db->query($sql); if ($resql) @@ -1443,7 +1443,7 @@ class Reception extends CommonObject if (!empty($tracking) && !empty($value)) { $url = str_replace('{TRACKID}', $value, $tracking); - $this->tracking_url = sprintf(''.($value?$value:'url').'', $url, $url); + $this->tracking_url = sprintf(''.($value ? $value : 'url').'', $url, $url); } else { @@ -1458,16 +1458,16 @@ class Reception extends CommonObject */ public function setClosed() { - global $conf,$langs,$user; + global $conf, $langs, $user; - $error=0; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET fk_statut='.self::STATUS_CLOSED; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // Set order billed if 100% of order is received (qty in reception lines match qty in order lines) @@ -1476,17 +1476,17 @@ class Reception extends CommonObject $order = new CommandeFournisseur($this->db); $order->fetch($this->origin_id); - $order->loadReceptions(self::STATUS_CLOSED); // Fill $order->receptions = array(orderlineid => qty) + $order->loadReceptions(self::STATUS_CLOSED); // Fill $order->receptions = array(orderlineid => qty) $receptions_match_order = 1; - foreach($order->lines as $line) + foreach ($order->lines as $line) { $lineid = $line->id; $qty = $line->qty; - if (($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->receptions[$lineid] < $qty) + if (($line->product_type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->receptions[$lineid] < $qty) { $receptions_match_order = 0; - $text='Qty for order line id '.$lineid.' is '.$qty.'. However in the receptions with status Reception::STATUS_CLOSED='.self::STATUS_CLOSED.' we have qty = '.$order->receptions[$lineid].', so we can t close order'; + $text = 'Qty for order line id '.$lineid.' is '.$qty.'. However in the receptions with status Reception::STATUS_CLOSED='.self::STATUS_CLOSED.' we have qty = '.$order->receptions[$lineid].', so we can t close order'; dol_syslog($text); break; } @@ -1498,11 +1498,11 @@ class Reception extends CommonObject } } - $this->statut=self::STATUS_CLOSED; + $this->statut = self::STATUS_CLOSED; // If stock increment is done on closing - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -1511,15 +1511,15 @@ class Reception extends CommonObject // Loop on each product line to add a stock movement // TODO possibilite de receptionner a partir d'une propale ou autre origine ? $sql = "SELECT cd.fk_product, cd.subprice,"; - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql.= " ed.eatby, ed.sellby, ed.batch"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; - $sql.= " WHERE ed.fk_reception = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " ed.eatby, ed.sellby, ed.batch"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; + $sql .= " WHERE ed.fk_reception = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_commandefourndet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { @@ -1541,7 +1541,7 @@ class Reception extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref)); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1553,7 +1553,7 @@ class Reception extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); if ($result < 0) { $this->error = $mouvS->error; @@ -1565,15 +1565,15 @@ class Reception extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } // Call trigger - if (! $error) + if (!$error) { - $result=$this->call_trigger('RECEPTION_CLOSED', $user); + $result = $this->call_trigger('RECEPTION_CLOSED', $user); if ($result < 0) { $error++; } @@ -1585,7 +1585,7 @@ class Reception extends CommonObject $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1607,7 +1607,7 @@ class Reception extends CommonObject { // phpcs:enable global $user; - $error=0; + $error = 0; $this->db->begin(); @@ -1616,20 +1616,20 @@ class Reception extends CommonObject $sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET billed=1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->statut=2; - $this->billed=1; + $this->statut = 2; + $this->billed = 1; // Call trigger - $result=$this->call_trigger('RECEPTION_BILLED', $user); + $result = $this->call_trigger('RECEPTION_BILLED', $user); if ($result < 0) { $error++; } } else { $error++; - $this->errors[]=$this->db->lasterror; + $this->errors[] = $this->db->lasterror; } if (empty($error)) { @@ -1650,23 +1650,23 @@ class Reception extends CommonObject */ public function reOpen() { - global $conf,$langs,$user; + global $conf, $langs, $user; - $error=0; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET fk_statut=1, billed=0'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->statut=1; - $this->billed=0; + $this->statut = 1; + $this->billed = 0; // If stock increment is done on closing - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $numref = $this->ref; @@ -1675,15 +1675,15 @@ class Reception extends CommonObject // Loop on each product line to add a stock movement // TODO possibilite de receptionner a partir d'une propale ou autre origine $sql = "SELECT ed.fk_product, cd.subprice,"; - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql.= " ed.eatby, ed.sellby, ed.batch"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; - $sql.= " WHERE ed.fk_reception = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " ed.eatby, ed.sellby, ed.batch"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; + $sql .= " WHERE ed.fk_reception = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_commandefourndet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -1706,7 +1706,7 @@ class Reception extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref)); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1718,7 +1718,7 @@ class Reception extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1729,31 +1729,31 @@ class Reception extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } - if (! $error) + if (!$error) { // Call trigger - $result=$this->call_trigger('RECEPTION_REOPEN', $user); + $result = $this->call_trigger('RECEPTION_REOPEN', $user); if ($result < 0) { $error++; } } - if($this->origin == 'order_supplier'){ + if ($this->origin == 'order_supplier') { $commande = new CommandeFournisseur($this->db); $commande->fetch($this->origin_id); $commande->setStatus($user, 4); } } else { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1774,9 +1774,9 @@ class Reception extends CommonObject public function setDraft($user) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; - $error=0; + $error = 0; // Protection if ($this->statut <= self::STATUS_DRAFT) @@ -1784,24 +1784,24 @@ class Reception extends CommonObject return 0; } - if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->reception_advance->validate)))) + if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)))) { - $this->error='Permission denied'; + $this->error = 'Permission denied'; return -1; } $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."reception"; - $sql.= " SET fk_statut = ".self::STATUS_DRAFT; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET fk_statut = ".self::STATUS_DRAFT; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); if ($this->db->query($sql)) { // If stock increment is done on closing - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -1810,15 +1810,15 @@ class Reception extends CommonObject // Loop on each product line to add a stock movement // TODO possibilite de receptionner a partir d'une propale ou autre origine $sql = "SELECT cd.fk_product, cd.subprice,"; - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql.= " ed.eatby, ed.sellby, ed.batch"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; - $sql.= " WHERE ed.fk_reception = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " ed.eatby, ed.sellby, ed.batch"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; + $sql .= " WHERE ed.fk_reception = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_commandefourndet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -1841,7 +1841,7 @@ class Reception extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref)); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1854,7 +1854,7 @@ class Reception extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1865,14 +1865,14 @@ class Reception extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } if (!$error) { // Call trigger - $result=$this->call_trigger('RECEPTION_UNVALIDATE', $user); + $result = $this->call_trigger('RECEPTION_UNVALIDATE', $user); if ($result < 0) $error++; } if ($this->origin == 'order_supplier') @@ -1907,7 +1907,7 @@ class Reception extends CommonObject } if (!$error) { - $this->statut=self::STATUS_DRAFT; + $this->statut = self::STATUS_DRAFT; $this->db->commit(); return 1; } else { @@ -1917,7 +1917,7 @@ class Reception extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -1935,17 +1935,17 @@ class Reception extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf,$langs; + global $conf, $langs; $langs->load("receptions"); - if (! dol_strlen($modele)) + if (!dol_strlen($modele)) { $modele = 'squille'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->RECEPTION_ADDON_PDF)) { + } elseif (!empty($conf->global->RECEPTION_ADDON_PDF)) { $modele = $conf->global->RECEPTION_ADDON_PDF; } } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 6b375679052..cfd3e7f8b95 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -45,24 +45,24 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $langs->loadLangs(array("companies", "commercial", "bills", "banks", "users")); -if (! empty($conf->adherent->enabled)) $langs->load("members"); -if (! empty($conf->categorie->enabled)) $langs->load("categories"); -if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); -if (! empty($conf->notification->enabled)) $langs->load("mails"); +if (!empty($conf->adherent->enabled)) $langs->load("members"); +if (!empty($conf->categorie->enabled)) $langs->load("categories"); +if (!empty($conf->incoterm->enabled)) $langs->load("incoterm"); +if (!empty($conf->notification->enabled)) $langs->load("mails"); -$mesg=''; $error=0; $errors=array(); +$mesg = ''; $error = 0; $errors = array(); $action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'); $cancel = GETPOST('cancel', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; -if (empty($socid) && $action == 'view') $action='create'; +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); +if ($user->socid) $socid = $user->socid; +if (empty($socid) && $action == 'view') $action = 'create'; $object = new Societe($db); $extrafields = new ExtraFields($db); @@ -73,11 +73,11 @@ $extrafields->fetch_name_optionals_label($object->table_element); $socialnetworks = getArrayOfSocialNetworks(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('thirdpartycard','globalcard')); +$hookmanager->initHooks(array('thirdpartycard', 'globalcard')); if ($socid > 0) $object->fetch($socid); -if (! ($object->id > 0) && $action == 'view') +if (!($object->id > 0) && $action == 'view') { $langs->load("errors"); print($langs->trans('ErrorRecordNotFound')); @@ -86,9 +86,9 @@ if (! ($object->id > 0) && $action == 'view') // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($socid); -$canvas = $object->canvas?$object->canvas:GETPOST("canvas"); -$objcanvas=null; -if (! empty($canvas)) +$canvas = $object->canvas ? $object->canvas : GETPOST("canvas"); +$objcanvas = null; +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); @@ -103,16 +103,16 @@ $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'ro * Actions */ -$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas); +$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)) { if ($cancel) { - $action=''; - if (! empty($backtopage)) + $action = ''; + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -148,7 +148,7 @@ if (empty($reshook)) // Recopy some data $object->client = $object->client | $soc_origin->client; $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; - $listofproperties=array( + $listofproperties = array( 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'twitter', 'facebook', 'linkedin', 'socialnetworks', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', @@ -162,7 +162,7 @@ if (empty($reshook)) } // Concat some data - $listofproperties=array( + $listofproperties = array( 'note_public', 'note_private' ); foreach ($listofproperties as $property) @@ -213,7 +213,7 @@ if (empty($reshook)) } // Move links - if (! $error) + if (!$error) { $objects = array( 'Adherent' => '/adherents/class/adherent.class.php', @@ -253,7 +253,7 @@ if (empty($reshook)) } // External modules should update their ones too - if (! $error) + if (!$error) { $reshook = $hookmanager->executeHooks('replaceThirdparty', array( 'soc_origin' => $soc_origin->id, @@ -268,12 +268,12 @@ if (empty($reshook)) } - if (! $error) + if (!$error) { - $object->context=array('merge'=>1, 'mergefromid'=>$soc_origin->id); + $object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id); // Call trigger - $result=$object->call_trigger('COMPANY_MODIFY', $user); + $result = $object->call_trigger('COMPANY_MODIFY', $user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -309,28 +309,28 @@ if (empty($reshook)) if (GETPOST('getcustomercode')) { // We defined value code_client - $_POST["customer_code"]="Acompleter"; + $_POST["customer_code"] = "Acompleter"; } if (GETPOST('getsuppliercode')) { // We defined value code_fournisseur - $_POST["supplier_code"]="Acompleter"; + $_POST["supplier_code"] = "Acompleter"; } - if($action=='set_localtax1') + if ($action == 'set_localtax1') { //obtidre selected del combobox - $value=GETPOST('lt1'); + $value = GETPOST('lt1'); $object->fetch($socid); - $res=$object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); + $res = $object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } - if($action=='set_localtax2') + if ($action == 'set_localtax2') { //obtidre selected del combobox - $value=GETPOST('lt2'); + $value = GETPOST('lt2'); $object->fetch($socid); - $res=$object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); + $res = $object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } if ($action == 'update_extras') { @@ -344,7 +344,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { $result = $object->insertExtraFields('COMPANY_MODIFY'); if ($result < 0) @@ -358,12 +358,12 @@ if (empty($reshook)) } // Add new or update third party - if ((! GETPOST('getcustomercode') && ! GETPOST('getsuppliercode')) + if ((!GETPOST('getcustomercode') && !GETPOST('getsuppliercode')) && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if (! GETPOST('name')) + if (!GETPOST('name')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdPartyName")), null, 'errors'); $error++; @@ -379,51 +379,51 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { if ($action == 'update') { - $ret=$object->fetch($socid); + $ret = $object->fetch($socid); $object->oldcopy = clone $object; } - else $object->canvas=$canvas; + else $object->canvas = $canvas; if (GETPOST("private", 'int') == 1) // Ask to create a contact { $object->particulier = GETPOST("private"); - $object->name = dolGetFirstLastname(GETPOST('firstname', 'alpha'), GETPOST('name', 'alpha')); - $object->civility_id = GETPOST('civility_id'); // Note: civility id is a code, not an int + $object->name = dolGetFirstLastname(GETPOST('firstname', 'alpha'), GETPOST('name', 'alpha')); + $object->civility_id = GETPOST('civility_id'); // Note: civility id is a code, not an int // Add non official properties - $object->name_bis = GETPOST('name', 'alpha'); - $object->firstname = GETPOST('firstname', 'alpha'); + $object->name_bis = GETPOST('name', 'alpha'); + $object->firstname = GETPOST('firstname', 'alpha'); } else { - $object->name = GETPOST('name', 'alpha'); + $object->name = GETPOST('name', 'alpha'); } - $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); - $object->name_alias = GETPOST('name_alias'); + $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); + $object->name_alias = GETPOST('name_alias'); $object->address = GETPOST('address'); - $object->zip = GETPOST('zipcode', 'alpha'); - $object->town = GETPOST('town', 'alpha'); - $object->country_id = GETPOST('country_id', 'int'); - $object->state_id = GETPOST('state_id', 'int'); + $object->zip = GETPOST('zipcode', 'alpha'); + $object->town = GETPOST('town', 'alpha'); + $object->country_id = GETPOST('country_id', 'int'); + $object->state_id = GETPOST('state_id', 'int'); //$object->skype = GETPOST('skype', 'alpha'); //$object->twitter = GETPOST('twitter', 'alpha'); //$object->facebook = GETPOST('facebook', 'alpha'); //$object->linkedin = GETPOST('linkedin', 'alpha'); $object->socialnetworks = array(); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } } - $object->phone = GETPOST('phone', 'alpha'); + $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax', 'alpha'); - $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); + $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); $object->url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); $object->idprof1 = trim(GETPOST('idprof1', 'alpha')); $object->idprof2 = trim(GETPOST('idprof2', 'alpha')); @@ -432,14 +432,14 @@ if (empty($reshook)) $object->idprof5 = trim(GETPOST('idprof5', 'alpha')); $object->idprof6 = trim(GETPOST('idprof6', 'alpha')); $object->prefix_comm = GETPOST('prefix_comm', 'alpha'); - $object->code_client = GETPOSTISSET('customer_code')?GETPOST('customer_code', 'alpha'):GETPOST('code_client', 'alpha'); - $object->code_fournisseur = GETPOSTISSET('supplier_code')?GETPOST('supplier_code', 'alpha'):GETPOST('code_fournisseur', 'alpha'); + $object->code_client = GETPOSTISSET('customer_code') ?GETPOST('customer_code', 'alpha') : GETPOST('code_client', 'alpha'); + $object->code_fournisseur = GETPOSTISSET('supplier_code') ?GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha'); $object->capital = GETPOST('capital', 'alpha'); $object->barcode = GETPOST('barcode', 'alpha'); $object->tva_intra = GETPOST('tva_intra', 'alpha'); $object->tva_assuj = GETPOST('assujtva_value', 'alpha'); - $object->status = GETPOST('status', 'alpha'); + $object->status = GETPOST('status', 'alpha'); // Local Taxes $object->localtax1_assuj = GETPOST('localtax1assuj_value', 'alpha'); @@ -448,17 +448,17 @@ if (empty($reshook)) $object->localtax1_value = GETPOST('lt1', 'alpha'); $object->localtax2_value = GETPOST('lt2', 'alpha'); - $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); + $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); $object->effectif_id = GETPOST('effectif_id', 'int'); - $object->typent_id = GETPOST('typent_id', 'int'); + $object->typent_id = GETPOST('typent_id', 'int'); - $object->typent_code = dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code'); // Force typent_code too so check in verify() will be done on new type + $object->typent_code = dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code'); // Force typent_code too so check in verify() will be done on new type - $object->client = GETPOST('client', 'int'); + $object->client = GETPOST('client', 'int'); $object->fournisseur = GETPOST('fournisseur', 'int'); - $object->commercial_id = GETPOST('commercial_id', 'int'); - $object->default_lang = GETPOST('default_lang'); + $object->commercial_id = GETPOST('commercial_id', 'int'); + $object->default_lang = GETPOST('default_lang'); // Webservices url/key $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL); @@ -467,8 +467,8 @@ if (empty($reshook)) // Incoterms if (!empty($conf->incoterm->enabled)) { - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); } // Multicurrency @@ -485,46 +485,46 @@ if (empty($reshook)) } if (GETPOST('deletephoto')) $object->logo = ''; - elseif (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); + elseif (!empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); // Check parameters - if (! GETPOST('cancel', 'alpha')) + if (!GETPOST('cancel', 'alpha')) { - if (! empty($object->email) && ! isValidEMail($object->email)) + if (!empty($object->email) && !isValidEMail($object->email)) { $langs->load("errors"); $error++; setEventMessages('', $langs->trans("ErrorBadEMail", $object->email), 'errors'); } - if (! empty($object->url) && ! isValidUrl($object->url)) + if (!empty($object->url) && !isValidUrl($object->url)) { $langs->load("errors"); setEventMessages('', $langs->trans("ErrorBadUrl", $object->url), 'errors'); } - if (! empty($object->webservices_url)) { + if (!empty($object->webservices_url)) { //Check if has transport, without any the soap client will give error if (strpos($object->webservices_url, "http") === false) { $object->webservices_url = "http://".$object->webservices_url; } - if (! isValidUrl($object->webservices_url)) { + if (!isValidUrl($object->webservices_url)) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorBadUrl", $object->webservices_url); } } // We set country_id, country_code and country for the selected country - $object->country_id=GETPOST('country_id')!=''?GETPOST('country_id'):$mysoc->country_id; + $object->country_id = GETPOST('country_id') != '' ?GETPOST('country_id') : $mysoc->country_id; if ($object->country_id) { - $tmparray=getCountry($object->country_id, 'all'); - $object->country_code=$tmparray['code']; - $object->country=$tmparray['label']; + $tmparray = getCountry($object->country_id, 'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; } } } - if (! $error) + if (!$error) { if ($action == 'add') { @@ -532,8 +532,8 @@ if (empty($reshook)) $db->begin(); - if (empty($object->client)) $object->code_client=''; - if (empty($object->fournisseur)) $object->code_fournisseur=''; + if (empty($object->client)) $object->code_client = ''; + if (empty($object->fournisseur)) $object->code_fournisseur = ''; $result = $object->create($user); @@ -542,7 +542,7 @@ if (empty($reshook)) if ($object->particulier) { dol_syslog("We ask to create a contact/address too", LOG_DEBUG); - $result=$object->create_individual($user); + $result = $object->create_individual($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -588,10 +588,10 @@ if (empty($reshook)) if (@is_dir($dir)) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (! $result > 0) + if (!$result > 0) { $errors[] = "ErrorFailedToSaveFile"; } @@ -605,7 +605,7 @@ if (empty($reshook)) } else { - switch($_FILES['photo']['error']) + switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form @@ -631,22 +631,22 @@ if (empty($reshook)) $error++; } - if ($result >= 0 && ! $error) + if ($result >= 0 && !$error) { $db->commit(); - if (! empty($backtopage)) + if (!empty($backtopage)) { - $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation - if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id; // Old method + $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation + if (preg_match('/\?/', $backtopage)) $backtopage .= '&socid='.$object->id; // Old method header("Location: ".$backtopage); exit; } else { - $url=$_SERVER["PHP_SELF"]."?socid=".$object->id; // Old method - if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/card.php?socid=".$object->id; - elseif ($object->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/card.php?socid=".$object->id; + $url = $_SERVER["PHP_SELF"]."?socid=".$object->id; // Old method + if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url = DOL_URL_ROOT."/comm/card.php?socid=".$object->id; + elseif ($object->fournisseur == 1) $url = DOL_URL_ROOT."/fourn/card.php?socid=".$object->id; header("Location: ".$url); exit; @@ -655,7 +655,7 @@ if (empty($reshook)) else { $db->rollback(); - $action='create'; + $action = 'create'; } } @@ -665,7 +665,7 @@ if (empty($reshook)) if (GETPOST('cancel', 'alpha')) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -678,13 +678,13 @@ if (empty($reshook)) } // To not set code if third party is not concerned. But if it had values, we keep them. - if (empty($object->client) && empty($object->oldcopy->code_client)) $object->code_client=''; - if (empty($object->fournisseur)&& empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur=''; + if (empty($object->client) && empty($object->oldcopy->code_client)) $object->code_client = ''; + if (empty($object->fournisseur) && empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur = ''; //var_dump($object);exit; $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(), 'update', 0); - if ($result <= 0) + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; @@ -700,7 +700,7 @@ if (empty($reshook)) } // Prevent thirdparty's emptying if a user hasn't rights $user->rights->categorie->lire (in such a case, post of 'custcats' is not defined) - if (! $error && !empty($user->rights->categorie->lire)) + if (!$error && !empty($user->rights->categorie->lire)) { // Customer categories association $categories = GETPOST('custcats', 'array'); @@ -726,8 +726,8 @@ if (empty($reshook)) $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if (GETPOST('deletephoto') && $object->logo) { - $fileimg=$dir.'/'.$object->logo; - $dirthumbs=$dir.'/thumbs'; + $fileimg = $dir.'/'.$object->logo; + $dirthumbs = $dir.'/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } @@ -739,10 +739,10 @@ if (empty($reshook)) if (@is_dir($dir)) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (! $result > 0) + if (!$result > 0) { $errors[] = "ErrorFailedToSaveFile"; } @@ -752,9 +752,9 @@ if (empty($reshook)) $object->addThumbs($newfile); // Index file in database - if (! empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) + if (!empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) { - require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir deleteFilesIntoDatabaseIndex(dirname($newfile), '', ''); // now we index the uploaded logo file @@ -770,7 +770,7 @@ if (empty($reshook)) } else { - switch($_FILES['photo']['error']) + switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form @@ -785,11 +785,11 @@ if (empty($reshook)) // Update linked member - if (! $error && $object->fk_soc > 0) + if (!$error && $object->fk_soc > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; - if (! $object->db->query($sql)) + $sql .= " SET fk_soc = NULL WHERE fk_soc = ".$id; + if (!$object->db->query($sql)) { $error++; $object->error .= $object->db->lasterror(); @@ -797,9 +797,9 @@ if (empty($reshook)) } } - if (! $error && ! count($errors)) + if (!$error && !count($errors)) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -813,13 +813,13 @@ if (empty($reshook)) else { $object->id = $socid; - $action= "edit"; + $action = "edit"; } } } else { - $action = ($action=='add'?'create':'edit'); + $action = ($action == 'add' ? 'create' : 'edit'); } } @@ -840,7 +840,7 @@ if (empty($reshook)) $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $error++; - $action=''; + $action = ''; } } @@ -858,20 +858,20 @@ if (empty($reshook)) $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } - $id=$socid; + $id = $socid; $object->fetch($socid); // Actions to send emails - $trigger_name='COMPANY_SENTBYMAIL'; - $paramname='socid'; - $mode='emailfromthirdparty'; - $trackid='thi'.$object->id; + $trigger_name = 'COMPANY_SENTBYMAIL'; + $paramname = 'socid'; + $mode = 'emailfromthirdparty'; + $trackid = 'thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc $id = $socid; $upload_dir = $conf->societe->dir_output; - $permissiontoadd=$user->rights->societe->creer; + $permissiontoadd = $user->rights->societe->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -887,24 +887,24 @@ $formcompany = new FormCompany($db); if ($socid > 0 && empty($object->id)) { - $result=$object->fetch($socid); + $result = $object->fetch($socid); if ($result <= 0) dol_print_error('', $object->error); } -$title=$langs->trans("ThirdParty"); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Card'); -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = $langs->trans("ThirdParty"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$langs->trans('Card'); +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + $objcanvas->display_canvas($action); // Show template } else { @@ -916,82 +916,82 @@ else /* * Creation */ - $private=GETPOST("private", "int"); - if (! empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && ! isset($_GET['private']) && ! isset($_POST['private'])) $private=1; - if (empty($private)) $private=0; + $private = GETPOST("private", "int"); + if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !isset($_GET['private']) && !isset($_POST['private'])) $private = 1; + if (empty($private)) $private = 0; // Load object modCodeTiers - $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); + $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module)-4); + $module = substr($module, 0, dol_strlen($module) - 4); } - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeClient = new $module; // Load object modCodeFournisseur - $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); + $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module)-4); + $module = substr($module, 0, dol_strlen($module) - 4); } - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeFournisseur = new $module; // Define if customer/prospect or supplier status is set or not - if (GETPOST("type")!='f') + if (GETPOST("type") != 'f') { - $object->client=-1; - if (! empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client=3; } + $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; + if (GETPOST("type") == 'c') { + if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) { + $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT; } else { - $object->client=3; + $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; } + 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; } - $object->name = GETPOST('name', 'alpha'); - $object->firstname = GETPOST('firstname', 'alpha'); + $object->name = GETPOST('name', 'alpha'); + $object->firstname = GETPOST('firstname', 'alpha'); $object->particulier = $private; $object->prefix_comm = GETPOST('prefix_comm', 'alpha'); - $object->client = GETPOST('client', 'int')?GETPOST('client', 'int'):$object->client; + $object->client = GETPOST('client', 'int') ?GETPOST('client', 'int') : $object->client; if (empty($duplicate_code_error)) { $object->code_client = GETPOST('customer_code', 'alpha'); - $object->fournisseur = GETPOST('fournisseur')?GETPOST('fournisseur'):$object->fournisseur; - $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); + $object->fournisseur = GETPOST('fournisseur') ?GETPOST('fournisseur') : $object->fournisseur; + $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); } else { setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'), '', 'warnings'); } - $object->address = GETPOST('address', 'alpha'); - $object->zip = GETPOST('zipcode', 'alpha'); - $object->town = GETPOST('town', 'alpha'); - $object->state_id = GETPOST('state_id', 'int'); + $object->address = GETPOST('address', 'alpha'); + $object->zip = GETPOST('zipcode', 'alpha'); + $object->town = GETPOST('town', 'alpha'); + $object->state_id = GETPOST('state_id', 'int'); //$object->skype = GETPOST('skype', 'alpha'); //$object->twitter = GETPOST('twitter', 'alpha'); //$object->facebook = GETPOST('facebook', 'alpha'); //$object->linkedin = GETPOST('linkedin', 'alpha'); $object->socialnetworks = array(); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } @@ -1008,30 +1008,30 @@ else $object->idprof4 = GETPOST('idprof4', 'alpha'); $object->idprof5 = GETPOST('idprof5', 'alpha'); $object->idprof6 = GETPOST('idprof6', 'alpha'); - $object->typent_id = GETPOST('typent_id', 'int'); + $object->typent_id = GETPOST('typent_id', 'int'); $object->effectif_id = GETPOST('effectif_id', 'int'); $object->civility_id = GETPOST('civility_id', 'alpha'); - $object->tva_assuj = GETPOST('assujtva_value', 'int'); - $object->status = GETPOST('status', 'int'); + $object->tva_assuj = GETPOST('assujtva_value', 'int'); + $object->status = GETPOST('status', 'int'); //Local Taxes $object->localtax1_assuj = GETPOST('localtax1assuj_value', 'int'); $object->localtax2_assuj = GETPOST('localtax2assuj_value', 'int'); - $object->localtax1_value =GETPOST('lt1', 'int'); - $object->localtax2_value =GETPOST('lt2', 'int'); + $object->localtax1_value = GETPOST('lt1', 'int'); + $object->localtax2_value = GETPOST('lt2', 'int'); - $object->tva_intra = GETPOST('tva_intra', 'alpha'); + $object->tva_intra = GETPOST('tva_intra', 'alpha'); - $object->commercial_id = GETPOST('commercial_id', 'int'); - $object->default_lang = GETPOST('default_lang'); + $object->commercial_id = GETPOST('commercial_id', 'int'); + $object->default_lang = GETPOST('default_lang'); - $object->logo = (isset($_FILES['photo'])?dol_sanitizeFileName($_FILES['photo']['name']):''); + $object->logo = (isset($_FILES['photo']) ?dol_sanitizeFileName($_FILES['photo']['name']) : ''); // Gestion du logo de la société $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos"; - $file_OK = (isset($_FILES['photo'])?is_uploaded_file($_FILES['photo']['tmp_name']):false); + $file_OK = (isset($_FILES['photo']) ?is_uploaded_file($_FILES['photo']['tmp_name']) : false); if ($file_OK) { if (image_format_supported($_FILES['photo']['name'])) @@ -1040,10 +1040,10 @@ else if (@is_dir($dir)) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (! $result > 0) + if (!$result > 0) { $errors[] = "ErrorFailedToSaveFile"; } @@ -1057,20 +1057,20 @@ else } // We set country_id, country_code and country for the selected country - $object->country_id=GETPOST('country_id')?GETPOST('country_id'):$mysoc->country_id; + $object->country_id = GETPOST('country_id') ?GETPOST('country_id') : $mysoc->country_id; if ($object->country_id) { - $tmparray=getCountry($object->country_id, 'all'); - $object->country_code=$tmparray['code']; - $object->country=$tmparray['label']; + $tmparray = getCountry($object->country_id, 'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; } - $object->forme_juridique_code=GETPOST('forme_juridique_code'); + $object->forme_juridique_code = GETPOST('forme_juridique_code'); /* Show create form */ - $linkback=""; + $linkback = ""; print load_fiche_titre($langs->trans("NewThirdParty"), $linkback, 'building'); - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) { print "\n".''; print "\n"; - $s.=''.$langs->trans("VATIntraCheck").''; + $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s.='country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -1435,30 +1435,30 @@ else // Local Taxes //TODO: Place into a function to control showing by country or study better option - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") + if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { print '
    '.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; - print $form->selectyesno('localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1:0), 1); + print $form->selectyesno('localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1); print ''.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; - print $form->selectyesno('localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0), 1); + print $form->selectyesno('localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1); print '
    '.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; - print $form->selectyesno('localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1:0), 1); + print $form->selectyesno('localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1); print '
    '.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; - print $form->selectyesno('localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0), 1); + print $form->selectyesno('localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1); print '
    '.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).''."\n"; - $sortparam=(empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. + $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam); if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ' '; print ''.$langs->trans("Currency".$conf->currency).'
    '.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; - print $formadmin->select_language(GETPOST('default_lang', 'alpha')?GETPOST('default_lang', 'alpha'):($object->default_lang?$object->default_lang:''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); + print $formadmin->select_language(GETPOST('default_lang', 'alpha') ?GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); print '
    '.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).''; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:'')); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print '
    ' . $form->editfieldkey('CustomersProspectsCategoriesShort', 'custcats', '', $object, 0) . ''; + print '
    '.$form->editfieldkey('CustomersProspectsCategoriesShort', 'custcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%"); print "
    ' . $form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0) . ''; + print '
    '.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); print $form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, null, null, "90%"); print "
    '.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1); // Note: If user has no right to "see all thirdparties", we force selection of sale representative to him, so after creation he can see the record. - $selected = (count(GETPOST('commercial', 'array')) > 0 ? GETPOST('commercial', 'array') : (GETPOST('commercial', 'int') > 0 ? array(GETPOST('commercial', 'int')) : (empty($user->rights->societe->client->voir)?array($user->id):array()))); + $selected = (count(GETPOST('commercial', 'array')) > 0 ? GETPOST('commercial', 'array') : (GETPOST('commercial', 'int') > 0 ? array(GETPOST('commercial', 'int')) : (empty($user->rights->societe->client->voir) ? array($user->id) : array()))); print $form->multiselectarray('commercial', $userlist, $selected, null, null, null, null, "90%"); print '
    '; // Ref/ID - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; // Supplier - if ((! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire)) - || (! empty($conf->supplier_proposal->enabled) && ! empty($user->rights->supplier_proposal->lire))) + if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) + || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire))) { print ''; print ''; print ''; print ''; // Address @@ -1936,14 +1936,14 @@ else // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print ''; - print ''; + print ''; print ''; - print ''; + print ''; // EMail / Web - print ''; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { print ''; @@ -2011,18 +2011,18 @@ else // } // Prof ids - $i=1; $j=0; + $i = 1; $j = 0; while ($i <= 6) { - $idprof=$langs->transcountry('ProfId'.$i, $object->country_code); - if ($idprof!='-') + $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); + if ($idprof != '-') { - $key='idprof'.$i; + $key = 'idprof'.$i; if (($j % 2) == 0) print ''; - $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; - print ''; if (($j % 2) == 1) print ''; @@ -2039,11 +2039,11 @@ else // Local Taxes //TODO: Place into a function to control showing by country or study better option - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") + if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { print ''; } - elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") + elseif ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj != "1") { print ''; } - elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") + elseif ($mysoc->localtax2_assuj == "1" && $mysoc->localtax1_assuj != "1") { print ''; print ''; print ''; // Default language - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { print ''; print ''; print ''; } // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { // Customer - print ''; + print ''; print '"; // Supplier - print ''; + print ''; print ''; print ''; @@ -2200,8 +2200,8 @@ else } // Other attributes - $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -2221,7 +2221,7 @@ else print ''; print ''; // Supplier - if (! empty($conf->fournisseur->enabled) || ! empty($conf->supplier_proposal->enabled)) + if (!empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) { print ''; print ''; @@ -2337,7 +2337,7 @@ else } // Supplier code - if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) + if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { print ''; print ''; print ''; - if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1))) + if ($object->localtax1_assuj == "1" && (!isOnlyOneLocalTax(1))) { print ''; print ''; print ''; print ''; - if($action == 'editRE') + if ($action == 'editRE') { print ''; } - if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2))) + if ($object->localtax2_assuj == "1" && (!isOnlyOneLocalTax(2))) { print ''; print ''; print ''; print ''; - if($action == 'editIRPF'){ + if ($action == 'editIRPF') { print ''; - }else{ + } else { print ''; } print ''; } } - elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") + elseif ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj != "1") { print ''; - if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1))) + if ($object->localtax1_assuj == "1" && (!isOnlyOneLocalTax(1))) { print ''; print ''; print ''; print ''; - if($action == 'editRE'){ + if ($action == 'editRE') { print ''; - }else{ + } else { print ''; } print ''; } } - elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") + elseif ($mysoc->localtax2_assuj == "1" && $mysoc->localtax1_assuj != "1") { print ''; - if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2))) + if ($object->localtax2_assuj == "1" && (!isOnlyOneLocalTax(2))) { print ''; print ''; print ''; print ''; - if($action == 'editIRPF'){ + if ($action == 'editIRPF') { print ''; - }else{ + } else { print ''; } print ''; @@ -2492,18 +2492,18 @@ else print ''; print ''; @@ -2544,11 +2544,11 @@ else print '
    '.$langs->trans("ID").''; print $object->ref; @@ -1820,7 +1820,7 @@ else print '
    '.$form->editfieldkey('Prefix', 'prefix', '', $object, 0).''; // It does not change the prefix mode using the auto numbering prefix @@ -1846,9 +1846,9 @@ else print '
    '; if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) { - $tmpcode=$object->code_client; - if (empty($tmpcode) && ! empty($object->oldcopy->code_client)) $tmpcode=$object->oldcopy->code_client; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. - if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object, 0); + $tmpcode = $object->code_client; + if (empty($tmpcode) && !empty($object->oldcopy->code_client)) $tmpcode = $object->oldcopy->code_client; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. + if (empty($tmpcode) && !empty($modCodeClient->code_auto)) $tmpcode = $modCodeClient->getNextValue($object, 0); print ''; } elseif ($object->codeclient_modifiable()) @@ -1861,34 +1861,34 @@ else print ''; } print ''; - $s=$modCodeClient->getToolTip($langs, $object, 0); + $s = $modCodeClient->getToolTip($langs, $object, 0); print $form->textwithpicto('', $s, 1); print '
    '; print '
    '.$form->editfieldkey('Supplier', 'fournisseur', '', $object, 0, 'string', '', 1).''; print $form->selectyesno("fournisseur", $object->fournisseur, 1); print ''; - if (! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire)) + if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) { print $form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0); } print ''; - if (! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire)) + if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) { print '
    '; if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) { - $tmpcode=$object->code_fournisseur; - if (empty($tmpcode) && ! empty($object->oldcopy->code_fournisseur)) $tmpcode=$object->oldcopy->code_fournisseur; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. - if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object, 1); + $tmpcode = $object->code_fournisseur; + if (empty($tmpcode) && !empty($object->oldcopy->code_fournisseur)) $tmpcode = $object->oldcopy->code_fournisseur; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. + if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) $tmpcode = $modCodeFournisseur->getNextValue($object, 1); print ''; } elseif ($object->codefournisseur_modifiable()) @@ -1901,7 +1901,7 @@ else print ''; } print ''; - $s=$modCodeFournisseur->getToolTip($langs, $object, 1); + $s = $modCodeFournisseur->getToolTip($langs, $object, 1); print $form->textwithpicto('', $s, 1); print '
    '; } @@ -1909,7 +1909,7 @@ else } // Barcode - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { print '
    '.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).''; @@ -1918,7 +1918,7 @@ else // Status print '
    '.$form->editfieldkey('Status', 'status', '', $object, 0).''; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $object->status); + print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); print '
    '.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).''; - print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id), 'country_id'); + print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
    '.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).''; } @@ -1958,17 +1958,17 @@ else // Phone / Fax print '
    '.img_picto('', 'object_phoning').' '.$form->editfieldkey('Phone', 'phone', GETPOST('phone', 'alpha'), $object, 0).''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).'
    '.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).'
    '.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).'
    '.img_picto('', 'globe').' '.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).'
    '.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', ! (empty($conf->global->$idprof_mandatory) || ! $object->isACompany())).''; + $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY'; + print ''.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).''; print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code); print '
    '.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).''; print $form->selectyesno('localtax1assuj_value', $object->localtax1_assuj, 1); - if(! isOnlyOneLocalTax(1)) + if (!isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); @@ -2053,7 +2053,7 @@ else print ''.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).''; print $form->selectyesno('localtax2assuj_value', $object->localtax2_assuj, 1); - if (! isOnlyOneLocalTax(2)) + if (!isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); @@ -2061,11 +2061,11 @@ else } print '
    '.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).''; print $form->selectyesno('localtax1assuj_value', $object->localtax1_assuj, 1); - if(! isOnlyOneLocalTax(1)) + if (!isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); @@ -2073,11 +2073,11 @@ else } print '
    '.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).''; print $form->selectyesno('localtax2assuj_value', $object->localtax2_assuj, 1); - if(! isOnlyOneLocalTax(2)) + if (!isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); @@ -2089,16 +2089,16 @@ else // VAT Code print '
    '.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).''; - $s =''; + $s = ''; if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object)) { - $s.='   '; + $s .= '   '; if ($conf->use_javascript_ajax) { $widthpopup = 600; - if (! empty($conf->dol_use_jmobile)) $widthpopup = 350; + if (!empty($conf->dol_use_jmobile)) $widthpopup = 350; $heightpopup = 400; print "\n"; print ''; print "\n"; - $s.=''.$langs->trans("VATIntraCheck").''; + $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s.='country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -2121,7 +2121,7 @@ else // Type - Size print '
    '.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).''; - print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''.$form->editfieldkey('Staff', 'effectif_id', '', $object, 0).''; @@ -2141,7 +2141,7 @@ else print '"> '.$langs->trans("Currency".$conf->currency).'
    '.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; print $formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1); @@ -2155,20 +2155,20 @@ else print '
    '.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).''; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:'')); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print '
    ' . $form->editfieldkey('CustomersCategoriesShort', 'custcats', '', $object, 0) . '
    '.$form->editfieldkey('CustomersCategoriesShort', 'custcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER); - $arrayselected=array(); + $arrayselected = array(); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } @@ -2176,12 +2176,12 @@ else print "
    ' . $form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0) . '
    '.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER); - $arrayselected=array(); + $arrayselected = array(); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } @@ -2190,7 +2190,7 @@ else } // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print '
    '.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).''; if ($object->logo) print $form->showphoto('societe', $object); - $caneditfield=1; + $caneditfield = 1; if ($caneditfield) { if ($object->logo) print "
    \n"; @@ -2264,7 +2264,7 @@ else * View */ - if (!empty($object->id)) $res=$object->fetch_optionals(); + if (!empty($object->id)) $res = $object->fetch_optionals(); //if ($res < 0) { dol_print_error($db); exit; } @@ -2292,11 +2292,11 @@ else print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 250); } - dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); + dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
    '; @@ -2311,7 +2311,7 @@ else print '
    '.$langs->trans('Supplier').''; print yn($object->fournisseur); @@ -2319,7 +2319,7 @@ else } // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print '
    '.$langs->trans('Prefix').''.$object->prefix_comm.'
    '; print $langs->trans('SupplierCode').''; @@ -2348,7 +2348,7 @@ else } // Barcode - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { print '
    '; print $langs->trans('Gencod').''.$object->barcode; @@ -2357,16 +2357,16 @@ else } // Prof ids - $i=1; $j=0; + $i = 1; $j = 0; while ($i <= 6) { - $idprof=$langs->transcountry('ProfId'.$i, $object->country_code); - if ($idprof!='-') + $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); + if ($idprof != '-') { //if (($j % 2) == 0) print '
    '.$idprof.''; - $key='idprof'.$i; + $key = 'idprof'.$i; print $object->$key; if ($object->$key) { @@ -2399,9 +2399,9 @@ else } // Local Taxes - if ($object->fournisseur || $mysoc->country_code=='ES') + if ($object->fournisseur || $mysoc->country_code == 'ES') { - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") + if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { print '
    '.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; print yn($object->localtax1_assuj); @@ -2409,13 +2409,13 @@ else print yn($object->localtax2_assuj); print '
    '.$langs->transcountry("Localtax1", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); @@ -2427,59 +2427,59 @@ else } print '
    '.$langs->transcountry("Localtax2", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); print ''.$object->localtax2_value.'
    '.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; print yn($object->localtax1_assuj); print '
    '.$langs->transcountry("Localtax1", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); print ''.$object->localtax1_value.'
    '.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; print yn($object->localtax2_assuj); print '
    '.$langs->transcountry("Localtax2", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); print ''.$object->localtax2_value.'
    '.$langs->trans('VATIntra').''; if ($object->tva_intra) { - $s=''; - $s.=$object->tva_intra; - $s.=''; + $s = ''; + $s .= $object->tva_intra; + $s .= ''; if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object)) { - $s.='   '; + $s .= '   '; if ($conf->use_javascript_ajax) { $widthpopup = 600; - if (! empty($conf->dol_use_jmobile)) $widthpopup = 350; + if (!empty($conf->dol_use_jmobile)) $widthpopup = 350; $heightpopup = 400; print "\n"; print ''; print "\n"; - $s.=''.$langs->trans("VATIntraCheck").''; + $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s.='country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -2531,7 +2531,7 @@ else // Type + Staff $arr = $formcompany->typent_array(1); - $object->typent= $arr[$object->typent_code]; + $object->typent = $arr[$object->typent_code]; print '
    '.$langs->trans("ThirdPartyType").''.$object->typent.'
    '.$langs->trans("Staff").''.$object->effectif.'
    '; // Tags / categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { // Customer - if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { - print ''; + if ($object->prospect || $object->client || (!$object->fournisseur && !empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { + print ''; print '"; @@ -2556,7 +2556,7 @@ else // Supplier if ($object->fournisseur) { - print ''; + print ''; print '"; @@ -2573,14 +2573,14 @@ else print ''; // Default language - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print ''; } @@ -2603,13 +2603,13 @@ else } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?socid='.$object->id); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?socid='.$object->id); } print ''; } // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; print ''; @@ -2619,8 +2619,8 @@ else } // Other attributes - $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Parent company if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) @@ -2648,16 +2648,16 @@ else include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; // Module Adherent - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { $langs->load("members"); print ''; print ''; } @@ -827,18 +827,18 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print ''; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) dol_print_error($db); $obj = $db->fetch_object($resql); $nbFactsClient = $obj->nb; - $thirdTypeArray['customer']=$langs->trans("customer"); - if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); - if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); - if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); - if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); + $thirdTypeArray['customer'] = $langs->trans("customer"); + if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); + if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); + if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); + if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); - if (! empty($conf->stripe->enabled)) + if (!empty($conf->stripe->enabled)) { $permissiontowrite = $user->rights->societe->creer; // Stripe customer key 'cu_....' stored into llx_societe_account @@ -846,14 +846,14 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); print ''; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) dol_print_error($db); $obj = $db->fetch_object($resql); $nbFactsClient = $obj->nb; - $thirdTypeArray['customer']=$langs->trans("customer"); - if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); - if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); - if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); - if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); + $thirdTypeArray['customer'] = $langs->trans("customer"); + if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); + if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); + if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); + if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); } - if (! empty($conf->stripe->enabled) && ! empty($conf->stripeconnect->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2) + if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { $permissiontowrite = $user->rights->societe->creer; - $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here) + $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here) // Stripe customer key 'cu_....' stored into llx_societe_account print ''; print ''; // Hook fields - $parameters=array('arrayfields'=>array(),'param'=>'','sortfield'=>'','sortorder'=>'', 'linetype'=>'stripetitle'); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>array(), 'param'=>'', 'sortfield'=>'', 'sortorder'=>'', 'linetype'=>'stripetitle'); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ""; @@ -1018,15 +1018,15 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $arrayofstripecard = array(); // Show local sources - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { //$societeaccount = new SocieteAccount($db); $companypaymentmodetemp = new CompanyPaymentMode($db); - $sql='SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib"; - $sql.=" WHERE type in ('card')"; - $sql.=" AND fk_soc = ".$object->id; - $sql.=" AND status = ".$servicestatus; + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib"; + $sql .= " WHERE type in ('card')"; + $sql .= " AND fk_soc = ".$object->id; + $sql .= " AND status = ".$servicestatus; $resql = $db->query($sql); if ($resql) @@ -1034,7 +1034,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $num_rows = $db->num_rows($resql); if ($num_rows) { - $i=0; + $i = 0; while ($i < $num_rows) { $nblocal++; @@ -1044,7 +1044,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { $companypaymentmodetemp->fetch($obj->rowid); - $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref]=$companypaymentmodetemp->stripe_card_ref; + $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref; print ''; print ''; // Fields from hook - $parameters=array('arrayfields'=>array(), 'obj'=>$obj, 'linetype'=>'stripecard'); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>array(), 'obj'=>$obj, 'linetype'=>'stripecard'); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; // Local ID - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { print ''; } // Src ID print ''; // Img of credit card print ''; print ''; // Fields from hook - $parameters=array('arrayfields'=>array(), 'stripesource'=>$src, 'linetype'=>'stripecardremoteonly'); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>array(), 'stripesource'=>$src, 'linetype'=>'stripecardremoteonly'); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; } print "
    ' . $langs->trans("CustomersCategoriesShort") . '
    '.$langs->trans("CustomersCategoriesShort").''; print $form->showCategories($object->id, 'customer', 1); print "
    ' . $langs->trans("SuppliersCategoriesShort") . '
    '.$langs->trans("SuppliersCategoriesShort").''; print $form->showCategories($object->id, 'supplier', 1); print "
    '.$langs->trans("DefaultLang").''; //$s=picto_from_langcode($object->default_lang); //print ($s?$s.' ':''); $langs->load("languages"); - $labellang = ($object->default_lang?$langs->trans('Language_'.$object->default_lang):''); + $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); print $labellang; print '
    '.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'
    '.$langs->trans("LinkedToDolibarrMember").''; - $adh=new Adherent($db); - $result=$adh->fetch('', '', $object->id); + $adh = new Adherent($db); + $result = $adh->fetch('', '', $object->id); if ($result > 0) { - $adh->ref=$adh->getFullName($langs); + $adh->ref = $adh->getFullName($langs); print $adh->getNomUrl(1); } else @@ -2690,8 +2690,8 @@ else { print '
    '."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $at_least_one_email_contact = false; @@ -2705,7 +2705,7 @@ else } } - if (! empty($object->email) || $at_least_one_email_contact) + if (!empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); print ''.$langs->trans('SendMail').''; @@ -2721,11 +2721,11 @@ else print ''.$langs->trans("Modify").''."\n"; } - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { $adh = new Adherent($db); - $result=$adh->fetch('', '', $object->id); - if ($result == 0 && ($object->client == 1 || $object->client == 3) && ! empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS)) + $result = $adh->fetch('', '', $object->id); + if ($result == 0 && ($object->client == 1 || $object->client == 3) && !empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS)) { print ''.$langs->trans("NewMember").''; } @@ -2768,10 +2768,10 @@ else /* * Documents generes */ - $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; - $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; - $genallowed=$user->rights->societe->lire; - $delallowed=$user->rights->societe->creer; + $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; + $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; + $genallowed = $user->rights->societe->lire; + $delallowed = $user->rights->societe->creer; print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); } @@ -2779,7 +2779,7 @@ else // Subsidiaries list if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES)) { - $result=show_subsidiaries($conf, $langs, $db, $object); + $result = show_subsidiaries($conf, $langs, $db, $object); } print '
    '; @@ -2789,31 +2789,31 @@ else $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt', DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id); // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty + $somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty print '
    '; - if (! empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) + if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) { // Contacts list if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - $result=show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); + $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); } // Addresses list - if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) + if (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) { - $result=show_addresses($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); + $result = show_addresses($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); } } } // Presend form - $modelmail='thirdparty'; - $defaulttopic='Information'; + $modelmail = 'thirdparty'; + $defaulttopic = 'Information'; $diroutput = $conf->societe->dir_output; $trackid = 'thi'.$object->id; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 027527d20d7..788fc45ee7e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -47,7 +47,7 @@ class Societe extends CommonObject /** * @var string ID to identify managed object */ - public $element='societe'; + public $element = 'societe'; /** * @var string Name of table without prefix where object is stored @@ -57,18 +57,18 @@ class Societe extends CommonObject /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element='fk_soc'; + public $fk_element = 'fk_soc'; - public $fieldsforcombobox='nom,name_alias'; + public $fieldsforcombobox = 'nom,name_alias'; /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); + protected $childtables = array("supplier_proposal"=>'SupplierProposal', "propal"=>'Proposal', "commande"=>'Order', "facture"=>'Invoice', "facture_rec"=>'RecurringInvoiceTemplate', "contrat"=>'Contract', "fichinter"=>'Fichinter', "facture_fourn"=>'SupplierInvoice', "commande_fournisseur"=>'SupplierOrder', "projet"=>'Project', "expedition"=>'Shipment', "prelevement_lignes"=>'DirectDebitRecord'); /** * @var array List of child tables. To know object to delete on cascade. */ - protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_account", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm"); + protected $childtablesoncascade = array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_account", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm"); /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -92,20 +92,20 @@ class Societe extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'nom' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'name_alias' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), - 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'nom' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'name_alias' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), ); @@ -147,7 +147,7 @@ class Societe extends CommonObject * Thirdparty status : 0=activity ceased, 1= in activity * @var int */ - public $status=1; + public $status = 1; /** * Id of department @@ -285,7 +285,7 @@ class Societe extends CommonObject public $prefix_comm; - public $tva_assuj=1; + public $tva_assuj = 1; /** * Intracommunitary VAT ID * @var string @@ -300,12 +300,12 @@ class Societe extends CommonObject public $managers; public $capital; - public $typent_id=0; + public $typent_id = 0; public $typent_code; public $effectif; - public $effectif_id=0; + public $effectif_id = 0; public $forme_juridique_code; - public $forme_juridique=0; + public $forme_juridique = 0; public $remise_percent; public $remise_supplier_percent; @@ -350,12 +350,12 @@ class Societe extends CommonObject * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect * @var int */ - public $client=0; + public $client = 0; /** * 0=no prospect, 1=prospect * @var int */ - public $prospect=0; + public $prospect = 0; /** * 0=no supplier, 1=supplier * @var int @@ -501,7 +501,7 @@ class Societe extends CommonObject public $fk_incoterms; public $location_incoterms; - public $label_incoterms; //Used into tooltip + public $label_incoterms; //Used into tooltip // Multicurrency /** @@ -527,9 +527,9 @@ class Societe extends CommonObject $this->client = 0; $this->prospect = 0; $this->fournisseur = 0; - $this->typent_id = 0; - $this->effectif_id = 0; - $this->forme_juridique_code = 0; + $this->typent_id = 0; + $this->effectif_id = 0; + $this->forme_juridique_code = 0; $this->tva_assuj = 1; $this->status = 1; } @@ -544,17 +544,17 @@ class Societe extends CommonObject */ public function create(User $user) { - global $langs,$conf,$mysoc; + global $langs, $conf, $mysoc; - $error=0; + $error = 0; // Clean parameters - if (empty($this->status)) $this->status=0; - $this->name=$this->name?trim($this->name):trim($this->nom); - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name=ucwords($this->name); - $this->nom=$this->name; // For backward compatibility - if (empty($this->client)) $this->client=0; - if (empty($this->fournisseur)) $this->fournisseur=0; + if (empty($this->status)) $this->status = 0; + $this->name = $this->name ?trim($this->name) : trim($this->nom); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = ucwords($this->name); + $this->nom = $this->name; // For backward compatibility + if (empty($this->client)) $this->client = 0; + if (empty($this->fournisseur)) $this->fournisseur = 0; $this->import_key = trim($this->import_key); if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); @@ -566,7 +566,7 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::create ".$this->name); - $now=dol_now(); + $now = dol_now(); $this->db->begin(); @@ -580,24 +580,24 @@ class Societe extends CommonObject if ($result >= 0) { - $this->entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity); + $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code)"; - $sql.= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; - $sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null"); - $sql.= ", ".(! empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'":"null"); - $sql.= ", ".$this->status; - $sql.= ", ".(! empty($this->ref_int) ? "'".$this->db->escape($this->ref_int)."'":"null"); - $sql.= ", ".(! empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'":"null"); - $sql.= ", 0"; - $sql.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".(! empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'":"null"); - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."')"; + $sql .= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; + $sql .= ", ".(!empty($user->id) ? "'".$user->id."'" : "null"); + $sql .= ", ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null"); + $sql .= ", ".$this->status; + $sql .= ", ".(!empty($this->ref_int) ? "'".$this->db->escape($this->ref_int)."'" : "null"); + $sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); + $sql .= ", 0"; + $sql .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."')"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe"); @@ -618,13 +618,13 @@ class Societe extends CommonObject if ($ret >= 0) { // Call trigger - $result=$this->call_trigger('COMPANY_CREATE', $user); + $result = $this->call_trigger('COMPANY_CREATE', $user); if ($result < 0) $error++; // End call triggers } else $error++; - if (! $error) + if (!$error) { dol_syslog(get_class($this)."::Create success id=".$this->id); $this->db->commit(); @@ -641,13 +641,13 @@ class Societe extends CommonObject { if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$langs->trans("ErrorCompanyNameAlreadyExists", $this->name); // duplicate on a field (code or profid or ...) - $result=-1; + $this->error = $langs->trans("ErrorCompanyNameAlreadyExists", $this->name); // duplicate on a field (code or profid or ...) + $result = -1; } else { - $this->error=$this->db->lasterror(); - $result=-2; + $this->error = $this->db->lasterror(); + $result = -2; } $this->db->rollback(); return $result; @@ -673,12 +673,12 @@ class Societe extends CommonObject { // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $contact=new Contact($this->db); + $contact = new Contact($this->db); $contact->name = $this->name_bis; $contact->firstname = $this->firstname; $contact->civility_id = $this->civility_id; - $contact->socid = $this->id; // fk_soc + $contact->socid = $this->id; // fk_soc $contact->statut = 1; $contact->priv = 0; $contact->country_id = $this->country_id; @@ -694,7 +694,7 @@ class Societe extends CommonObject { $this->error = $contact->error; $this->errors = $contact->errors; - dol_syslog(get_class($this)."::create_individual ERROR:" . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::create_individual ERROR:".$this->error, LOG_ERR); } return $result; @@ -711,13 +711,13 @@ class Societe extends CommonObject global $conf, $langs, $mysoc; $error = 0; - $this->errors=array(); + $this->errors = array(); $result = 0; - $this->name = trim($this->name); - $this->nom=$this->name; // For backward compatibility + $this->name = trim($this->name); + $this->nom = $this->name; // For backward compatibility - if (! $this->name) + if (!$this->name) { $this->errors[] = 'ErrorBadThirdPartyName'; $result = -2; @@ -774,12 +774,12 @@ class Societe extends CommonObject } // Check for duplicate or mandatory fields defined into setup - $array_to_check=array('IDPROF1','IDPROF2','IDPROF3','IDPROF4','IDPROF5','IDPROF6','EMAIL'); - foreach($array_to_check as $key) + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); + foreach ($array_to_check as $key) { - $keymin=strtolower($key); - $i=(int) preg_replace('/[^0-9]/', '', $key); - $vallabel=$this->$keymin; + $keymin = strtolower($key); + $i = (int) preg_replace('/[^0-9]/', '', $key); + $vallabel = $this->$keymin; if ($i > 0) { @@ -788,8 +788,8 @@ class Societe extends CommonObject // Check for mandatory prof id (but only if country is same than ours) if ($mysoc->country_id > 0 && $this->country_id == $mysoc->country_id) { - $idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY'; - if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) + $idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY'; + if (!$vallabel && !empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); $error++; @@ -799,7 +799,7 @@ class Societe extends CommonObject } // Check for unicity - if (! $error && $vallabel && $this->id_prof_verifiable($i)) + if (!$error && $vallabel && $this->id_prof_verifiable($i)) { if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) { @@ -816,7 +816,7 @@ class Societe extends CommonObject if ($key == 'EMAIL') { // Check for mandatory - if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY) && ! isValidEMail($this->email)) + if (!empty($conf->global->SOCIETE_EMAIL_MANDATORY) && !isValidEMail($this->email)) { $langs->load("errors"); $error++; @@ -824,7 +824,7 @@ class Societe extends CommonObject } // Check for unicity - if (! $error && $vallabel && ! empty($conf->global->SOCIETE_EMAIL_UNIQUE)) + if (!$error && $vallabel && !empty($conf->global->SOCIETE_EMAIL_UNIQUE)) { if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) { @@ -855,47 +855,47 @@ class Societe extends CommonObject */ public function update($id, $user = '', $call_trigger = 1, $allowmodcodeclient = 0, $allowmodcodefournisseur = 0, $action = 'update', $nosyncmember = 1) { - global $langs,$conf,$hookmanager; + global $langs, $conf, $hookmanager; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; if (empty($id)) $id = $this->id; - $error=0; + $error = 0; dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); - $now=dol_now(); + $now = dol_now(); // Clean parameters - $this->id = $id; - $this->entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity); - $this->name = $this->name?trim($this->name):trim($this->nom); - $this->nom = $this->name; // For backward compatibility - $this->name_alias = trim($this->name_alias); + $this->id = $id; + $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); + $this->name = $this->name ?trim($this->name) : trim($this->nom); + $this->nom = $this->name; // For backward compatibility + $this->name_alias = trim($this->name_alias); $this->ref_ext = trim($this->ref_ext); - $this->address = $this->address?trim($this->address):trim($this->address); - $this->zip = $this->zip?trim($this->zip):trim($this->zip); - $this->town = $this->town?trim($this->town):trim($this->town); - $this->state_id = trim($this->state_id); - $this->country_id = ($this->country_id > 0)?$this->country_id:0; + $this->address = $this->address ?trim($this->address) : trim($this->address); + $this->zip = $this->zip ?trim($this->zip) : trim($this->zip); + $this->town = $this->town ?trim($this->town) : trim($this->town); + $this->state_id = trim($this->state_id); + $this->country_id = ($this->country_id > 0) ? $this->country_id : 0; $this->phone = trim($this->phone); $this->phone = preg_replace("/\s/", "", $this->phone); $this->phone = preg_replace("/\./", "", $this->phone); $this->fax = trim($this->fax); $this->fax = preg_replace("/\s/", "", $this->fax); $this->fax = preg_replace("/\./", "", $this->fax); - $this->email = trim($this->email); - $this->url = $this->url?clean_url($this->url, 0):''; + $this->email = trim($this->email); + $this->url = $this->url ?clean_url($this->url, 0) : ''; $this->note_private = trim($this->note_private); $this->note_public = trim($this->note_public); $this->idprof1 = trim($this->idprof1); $this->idprof2 = trim($this->idprof2); $this->idprof3 = trim($this->idprof3); $this->idprof4 = trim($this->idprof4); - $this->idprof5 = (! empty($this->idprof5)?trim($this->idprof5):''); - $this->idprof6 = (! empty($this->idprof6)?trim($this->idprof6):''); - $this->prefix_comm = trim($this->prefix_comm); + $this->idprof5 = (!empty($this->idprof5) ?trim($this->idprof5) : ''); + $this->idprof6 = (!empty($this->idprof6) ?trim($this->idprof6) : ''); + $this->prefix_comm = trim($this->prefix_comm); $this->outstanding_limit = price2num($this->outstanding_limit); $this->order_min_amount = price2num($this->order_min_amount); $this->supplier_order_min_amount = price2num($this->supplier_order_min_amount); @@ -912,64 +912,64 @@ class Societe extends CommonObject } // Local taxes - $this->localtax1_assuj=trim($this->localtax1_assuj); - $this->localtax2_assuj=trim($this->localtax2_assuj); + $this->localtax1_assuj = trim($this->localtax1_assuj); + $this->localtax2_assuj = trim($this->localtax2_assuj); - $this->localtax1_value=trim($this->localtax1_value); - $this->localtax2_value=trim($this->localtax2_value); + $this->localtax1_value = trim($this->localtax1_value); + $this->localtax2_value = trim($this->localtax2_value); - if ($this->capital != '') $this->capital=price2num(trim($this->capital)); - if (! is_numeric($this->capital)) $this->capital = ''; // '' = undef + if ($this->capital != '') $this->capital = price2num(trim($this->capital)); + if (!is_numeric($this->capital)) $this->capital = ''; // '' = undef - $this->effectif_id=trim($this->effectif_id); - $this->forme_juridique_code=trim($this->forme_juridique_code); + $this->effectif_id = trim($this->effectif_id); + $this->forme_juridique_code = trim($this->forme_juridique_code); //Gencod - $this->barcode=trim($this->barcode); + $this->barcode = trim($this->barcode); // For automatic creation if ($this->code_client == -1 || $this->code_client === 'auto') $this->get_codeclient($this, 0); if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') $this->get_codefournisseur($this, 1); - $this->code_compta=trim($this->code_compta); - $this->code_compta_fournisseur=trim($this->code_compta_fournisseur); + $this->code_compta = trim($this->code_compta); + $this->code_compta_fournisseur = trim($this->code_compta_fournisseur); // Check parameters. More tests are done later in the ->verify() - if (! is_numeric($this->client) && ! is_numeric($this->fournisseur)) + if (!is_numeric($this->client) && !is_numeric($this->fournisseur)) { $langs->load("errors"); $this->error = $langs->trans("BadValueForParameterClientOrSupplier"); return -1; } - $customer=false; - if (! empty($allowmodcodeclient) && ! empty($this->client)) + $customer = false; + if (!empty($allowmodcodeclient) && !empty($this->client)) { // Attention get_codecompta peut modifier le code suivant le module utilise if (empty($this->code_compta)) { - $ret=$this->get_codecompta('customer'); + $ret = $this->get_codecompta('customer'); if ($ret < 0) return -1; } - $customer=true; + $customer = true; } - $supplier=false; - if (! empty($allowmodcodefournisseur) && ! empty($this->fournisseur)) + $supplier = false; + if (!empty($allowmodcodefournisseur) && !empty($this->fournisseur)) { // Attention get_codecompta peut modifier le code suivant le module utilise if ($this->code_compta_fournisseur == "") { - $ret=$this->get_codecompta('supplier'); + $ret = $this->get_codecompta('supplier'); if ($ret < 0) return -1; } - $supplier=true; + $supplier = true; } //Web services - $this->webservices_url = $this->webservices_url?clean_url($this->webservices_url, 0):''; + $this->webservices_url = $this->webservices_url ?clean_url($this->webservices_url, 0) : ''; $this->webservices_key = trim($this->webservices_key); //Incoterms @@ -993,11 +993,11 @@ class Societe extends CommonObject { if (in_array('ErrorBadCustomerCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_client == $this->code_client) { - if (($key = array_search('ErrorBadCustomerCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message + if (($key = array_search('ErrorBadCustomerCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message } if (in_array('ErrorBadSupplierCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_fournisseur == $this->code_fournisseur) { - if (($key = array_search('ErrorBadSupplierCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message + if (($key = array_search('ErrorBadSupplierCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message } if (empty($this->errors)) // If there is no more error, we can make like if there is no error at all { @@ -1011,117 +1011,117 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::update verify ok or not done"); $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql .= "entity = " . $this->db->escape($this->entity); - $sql .= ",nom = '" . $this->db->escape($this->name) ."'"; // Required - $sql .= ",name_alias = '" . $this->db->escape($this->name_alias) ."'"; - $sql .= ",ref_ext = " .(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext) ."'":"null"); - $sql .= ",address = '" . $this->db->escape($this->address) ."'"; + $sql .= "entity = ".$this->db->escape($this->entity); + $sql .= ",nom = '".$this->db->escape($this->name)."'"; // Required + $sql .= ",name_alias = '".$this->db->escape($this->name_alias)."'"; + $sql .= ",ref_ext = ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); + $sql .= ",address = '".$this->db->escape($this->address)."'"; - $sql .= ",zip = ".(! empty($this->zip)?"'".$this->db->escape($this->zip)."'":"null"); - $sql .= ",town = ".(! empty($this->town)?"'".$this->db->escape($this->town)."'":"null"); + $sql .= ",zip = ".(!empty($this->zip) ? "'".$this->db->escape($this->zip)."'" : "null"); + $sql .= ",town = ".(!empty($this->town) ? "'".$this->db->escape($this->town)."'" : "null"); - $sql .= ",fk_departement = '" . (! empty($this->state_id)?$this->state_id:'0') ."'"; - $sql .= ",fk_pays = '" . (! empty($this->country_id)?$this->country_id:'0') ."'"; + $sql .= ",fk_departement = '".(!empty($this->state_id) ? $this->state_id : '0')."'"; + $sql .= ",fk_pays = '".(!empty($this->country_id) ? $this->country_id : '0')."'"; - $sql .= ",phone = ".(! empty($this->phone)?"'".$this->db->escape($this->phone)."'":"null"); - $sql .= ",fax = ".(! empty($this->fax)?"'".$this->db->escape($this->fax)."'":"null"); - $sql .= ",email = ".(! empty($this->email)?"'".$this->db->escape($this->email)."'":"null"); + $sql .= ",phone = ".(!empty($this->phone) ? "'".$this->db->escape($this->phone)."'" : "null"); + $sql .= ",fax = ".(!empty($this->fax) ? "'".$this->db->escape($this->fax)."'" : "null"); + $sql .= ",email = ".(!empty($this->email) ? "'".$this->db->escape($this->email)."'" : "null"); $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; - $sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null"); + $sql .= ",url = ".(!empty($this->url) ? "'".$this->db->escape($this->url)."'" : "null"); - $sql .= ",parent = " . ($this->parent > 0 ? $this->parent : "null"); + $sql .= ",parent = ".($this->parent > 0 ? $this->parent : "null"); - $sql .= ",note_private = ".(! empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); - $sql .= ",note_public = ".(! empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); + $sql .= ",note_private = ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ",note_public = ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); - $sql .= ",siren = '". $this->db->escape($this->idprof1) ."'"; - $sql .= ",siret = '". $this->db->escape($this->idprof2) ."'"; - $sql .= ",ape = '". $this->db->escape($this->idprof3) ."'"; - $sql .= ",idprof4 = '". $this->db->escape($this->idprof4) ."'"; - $sql .= ",idprof5 = '". $this->db->escape($this->idprof5) ."'"; - $sql .= ",idprof6 = '". $this->db->escape($this->idprof6) ."'"; + $sql .= ",siren = '".$this->db->escape($this->idprof1)."'"; + $sql .= ",siret = '".$this->db->escape($this->idprof2)."'"; + $sql .= ",ape = '".$this->db->escape($this->idprof3)."'"; + $sql .= ",idprof4 = '".$this->db->escape($this->idprof4)."'"; + $sql .= ",idprof5 = '".$this->db->escape($this->idprof5)."'"; + $sql .= ",idprof6 = '".$this->db->escape($this->idprof6)."'"; - $sql .= ",tva_assuj = ".($this->tva_assuj!=''?"'".$this->db->escape($this->tva_assuj)."'":"null"); - $sql .= ",tva_intra = '" . $this->db->escape($this->tva_intra) ."'"; - $sql .= ",status = " .$this->status; + $sql .= ",tva_assuj = ".($this->tva_assuj != '' ? "'".$this->db->escape($this->tva_assuj)."'" : "null"); + $sql .= ",tva_intra = '".$this->db->escape($this->tva_intra)."'"; + $sql .= ",status = ".$this->status; // Local taxes - $sql .= ",localtax1_assuj = ".($this->localtax1_assuj!=''?"'".$this->db->escape($this->localtax1_assuj)."'":"null"); - $sql .= ",localtax2_assuj = ".($this->localtax2_assuj!=''?"'".$this->db->escape($this->localtax2_assuj)."'":"null"); - if($this->localtax1_assuj==1) + $sql .= ",localtax1_assuj = ".($this->localtax1_assuj != '' ? "'".$this->db->escape($this->localtax1_assuj)."'" : "null"); + $sql .= ",localtax2_assuj = ".($this->localtax2_assuj != '' ? "'".$this->db->escape($this->localtax2_assuj)."'" : "null"); + if ($this->localtax1_assuj == 1) { - if($this->localtax1_value!='') + if ($this->localtax1_value != '') { - $sql .=",localtax1_value =".$this->localtax1_value; + $sql .= ",localtax1_value =".$this->localtax1_value; } - else $sql .=",localtax1_value =0.000"; + else $sql .= ",localtax1_value =0.000"; } - else $sql .=",localtax1_value =0.000"; + else $sql .= ",localtax1_value =0.000"; - if($this->localtax2_assuj==1) + if ($this->localtax2_assuj == 1) { - if($this->localtax2_value!='') + if ($this->localtax2_value != '') { - $sql .=",localtax2_value =".$this->localtax2_value; + $sql .= ",localtax2_value =".$this->localtax2_value; } - else $sql .=",localtax2_value =0.000"; + else $sql .= ",localtax2_value =0.000"; } - else $sql .=",localtax2_value =0.000"; + else $sql .= ",localtax2_value =0.000"; $sql .= ",capital = ".($this->capital == '' ? "null" : $this->capital); - $sql .= ",prefix_comm = ".(! empty($this->prefix_comm)?"'".$this->db->escape($this->prefix_comm)."'":"null"); + $sql .= ",prefix_comm = ".(!empty($this->prefix_comm) ? "'".$this->db->escape($this->prefix_comm)."'" : "null"); - $sql .= ",fk_effectif = ".(! empty($this->effectif_id)?"'".$this->db->escape($this->effectif_id)."'":"null"); + $sql .= ",fk_effectif = ".(!empty($this->effectif_id) ? "'".$this->db->escape($this->effectif_id)."'" : "null"); if (isset($this->stcomm_id)) { - $sql .= ",fk_stcomm=".(!empty($this->stcomm_id) ? $this->stcomm_id : "0"); + $sql .= ",fk_stcomm=".(!empty($this->stcomm_id) ? $this->stcomm_id : "0"); } - $sql .= ",fk_typent = ".(! empty($this->typent_id)?"'".$this->db->escape($this->typent_id)."'":"0"); + $sql .= ",fk_typent = ".(!empty($this->typent_id) ? "'".$this->db->escape($this->typent_id)."'" : "0"); - $sql .= ",fk_forme_juridique = ".(! empty($this->forme_juridique_code)?"'".$this->db->escape($this->forme_juridique_code)."'":"null"); + $sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape($this->forme_juridique_code)."'" : "null"); - $sql .= ",mode_reglement = ".(! empty($this->mode_reglement_id)?"'".$this->db->escape($this->mode_reglement_id)."'":"null"); - $sql .= ",cond_reglement = ".(! empty($this->cond_reglement_id)?"'".$this->db->escape($this->cond_reglement_id)."'":"null"); - $sql .= ",mode_reglement_supplier = ".(! empty($this->mode_reglement_supplier_id)?"'".$this->db->escape($this->mode_reglement_supplier_id)."'":"null"); - $sql .= ",cond_reglement_supplier = ".(! empty($this->cond_reglement_supplier_id)?"'".$this->db->escape($this->cond_reglement_supplier_id)."'":"null"); - $sql .= ",fk_shipping_method = ".(! empty($this->shipping_method_id)?"'".$this->db->escape($this->shipping_method_id)."'":"null"); + $sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape($this->mode_reglement_id)."'" : "null"); + $sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape($this->cond_reglement_id)."'" : "null"); + $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape($this->mode_reglement_supplier_id)."'" : "null"); + $sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape($this->cond_reglement_supplier_id)."'" : "null"); + $sql .= ",fk_shipping_method = ".(!empty($this->shipping_method_id) ? "'".$this->db->escape($this->shipping_method_id)."'" : "null"); - $sql .= ",client = " . (! empty($this->client)?$this->client:0); - $sql .= ",fournisseur = " . (! empty($this->fournisseur)?$this->fournisseur:0); - $sql .= ",barcode = ".(! empty($this->barcode)?"'".$this->db->escape($this->barcode)."'":"null"); - $sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->db->escape($this->default_lang)."'":"null"); - $sql .= ",logo = ".(! empty($this->logo)?"'".$this->db->escape($this->logo)."'":"null"); - $sql .= ",logo_squarred = ".(! empty($this->logo_squarred)?"'".$this->db->escape($this->logo_squarred)."'":"null"); - $sql .= ",outstanding_limit= ".($this->outstanding_limit!=''?$this->outstanding_limit:'null'); - $sql .= ",order_min_amount= ".($this->order_min_amount!=''?$this->order_min_amount:'null'); - $sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount!=''?$this->supplier_order_min_amount:'null'); + $sql .= ",client = ".(!empty($this->client) ? $this->client : 0); + $sql .= ",fournisseur = ".(!empty($this->fournisseur) ? $this->fournisseur : 0); + $sql .= ",barcode = ".(!empty($this->barcode) ? "'".$this->db->escape($this->barcode)."'" : "null"); + $sql .= ",default_lang = ".(!empty($this->default_lang) ? "'".$this->db->escape($this->default_lang)."'" : "null"); + $sql .= ",logo = ".(!empty($this->logo) ? "'".$this->db->escape($this->logo)."'" : "null"); + $sql .= ",logo_squarred = ".(!empty($this->logo_squarred) ? "'".$this->db->escape($this->logo_squarred)."'" : "null"); + $sql .= ",outstanding_limit= ".($this->outstanding_limit != '' ? $this->outstanding_limit : 'null'); + $sql .= ",order_min_amount= ".($this->order_min_amount != '' ? $this->order_min_amount : 'null'); + $sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount != '' ? $this->supplier_order_min_amount : 'null'); $sql .= ",fk_prospectlevel='".$this->db->escape($this->fk_prospectlevel)."'"; - $sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null"); - $sql .= ",webservices_key = ".(! empty($this->webservices_key)?"'".$this->db->escape($this->webservices_key)."'":"null"); + $sql .= ",webservices_url = ".(!empty($this->webservices_url) ? "'".$this->db->escape($this->webservices_url)."'" : "null"); + $sql .= ",webservices_key = ".(!empty($this->webservices_key) ? "'".$this->db->escape($this->webservices_key)."'" : "null"); //Incoterms - $sql.= ", fk_incoterms = ".$this->fk_incoterms; - $sql.= ", location_incoterms = ".(! empty($this->location_incoterms)?"'".$this->db->escape($this->location_incoterms)."'":"null"); + $sql .= ", fk_incoterms = ".$this->fk_incoterms; + $sql .= ", location_incoterms = ".(!empty($this->location_incoterms) ? "'".$this->db->escape($this->location_incoterms)."'" : "null"); if ($customer) { - $sql .= ", code_client = ".(! empty($this->code_client)?"'".$this->db->escape($this->code_client)."'":"null"); - $sql .= ", code_compta = ".(! empty($this->code_compta)?"'".$this->db->escape($this->code_compta)."'":"null"); + $sql .= ", code_client = ".(!empty($this->code_client) ? "'".$this->db->escape($this->code_client)."'" : "null"); + $sql .= ", code_compta = ".(!empty($this->code_compta) ? "'".$this->db->escape($this->code_compta)."'" : "null"); } if ($supplier) { - $sql .= ", code_fournisseur = ".(! empty($this->code_fournisseur)?"'".$this->db->escape($this->code_fournisseur)."'":"null"); - $sql .= ", code_compta_fournisseur = ".(($this->code_compta_fournisseur != "")?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null"); + $sql .= ", code_fournisseur = ".(!empty($this->code_fournisseur) ? "'".$this->db->escape($this->code_fournisseur)."'" : "null"); + $sql .= ", code_compta_fournisseur = ".(($this->code_compta_fournisseur != "") ? "'".$this->db->escape($this->code_compta_fournisseur)."'" : "null"); } - $sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id:"null"); + $sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : "null"); $sql .= ", fk_multicurrency = ".(int) $this->fk_multicurrency; $sql .= ", multicurrency_code = '".$this->db->escape($this->multicurrency_code)."'"; - $sql .= " WHERE rowid = " . (int) $id; + $sql .= " WHERE rowid = ".(int) $id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if (is_object($this->oldcopy)) // If we have information on old values @@ -1139,7 +1139,7 @@ class Societe extends CommonObject } else { - unset($this->country_code); // We clean this, in the doubt, because it may have been changed after an update of country_id + unset($this->country_code); // We clean this, in the doubt, because it may have been changed after an update of country_id unset($this->country); unset($this->state_code); unset($this->state); @@ -1147,33 +1147,33 @@ class Societe extends CommonObject $nbrowsaffected = $this->db->affected_rows($resql); - if (! $error && $nbrowsaffected) + if (!$error && $nbrowsaffected) { // Update information on linked member if it is an update - if (! $nosyncmember && ! empty($conf->adherent->enabled)) + if (!$nosyncmember && !empty($conf->adherent->enabled)) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; dol_syslog(get_class($this)."::update update linked member"); - $lmember=new Adherent($this->db); - $result=$lmember->fetch(0, 0, $this->id); + $lmember = new Adherent($this->db); + $result = $lmember->fetch(0, 0, $this->id); if ($result > 0) { - $lmember->company=$this->name; + $lmember->company = $this->name; //$lmember->firstname=$this->firstname?$this->firstname:$lmember->firstname; // We keep firstname and lastname of member unchanged //$lmember->lastname=$this->lastname?$this->lastname:$lmember->lastname; // We keep firstname and lastname of member unchanged - $lmember->address=$this->address; - $lmember->zip=$this->zip; - $lmember->town=$this->town; - $lmember->email=$this->email; - $lmember->socialnetworks=$this->socialnetworks; - $lmember->phone=$this->phone; - $lmember->state_id=$this->state_id; - $lmember->country_id=$this->country_id; + $lmember->address = $this->address; + $lmember->zip = $this->zip; + $lmember->town = $this->town; + $lmember->email = $this->email; + $lmember->socialnetworks = $this->socialnetworks; + $lmember->phone = $this->phone; + $lmember->state_id = $this->state_id; + $lmember->country_id = $this->country_id; - $result=$lmember->update($user, 0, 1, 1, 1); // Use nosync to 1 to avoid cyclic updates + $result = $lmember->update($user, 0, 1, 1, 1); // Use nosync to 1 to avoid cyclic updates if ($result < 0) { $this->error = $lmember->error; @@ -1184,33 +1184,33 @@ class Societe extends CommonObject } elseif ($result < 0) { - $this->error=$lmember->error; + $this->error = $lmember->error; $error++; } } } - $action='update'; + $action = 'update'; // Actions on extra fields - 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->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && $call_trigger) + if (!$error && $call_trigger) { // Call trigger - $result=$this->call_trigger('COMPANY_MODIFY', $user); + $result = $this->call_trigger('COMPANY_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { dol_syslog(get_class($this)."::Update success"); $this->db->commit(); @@ -1323,13 +1323,13 @@ class Societe extends CommonObject if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; if ($email) $sql .= " AND s.email = '".$this->db->escape($email)."'"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); + $num = $this->db->num_rows($resql); if ($num > 1) { - $this->error='Fetch found several records. Rename one of thirdparties to avoid duplicate.'; + $this->error = 'Fetch found several records. Rename one of thirdparties to avoid duplicate.'; dol_syslog($this->error, LOG_ERR); $result = -2; } @@ -1339,11 +1339,11 @@ class Societe extends CommonObject $this->id = $obj->rowid; $this->entity = $obj->entity; - $this->canvas = $obj->canvas; + $this->canvas = $obj->canvas; $this->ref = $obj->rowid; - $this->name = $obj->name; - $this->nom = $obj->name; // deprecated + $this->name = $obj->name; + $this->nom = $obj->name; // deprecated $this->name_alias = $obj->name_alias; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; @@ -1353,22 +1353,22 @@ class Societe extends CommonObject $this->user_creation = $obj->fk_user_creat; $this->user_modification = $obj->fk_user_modif; - $this->address = $obj->address; + $this->address = $obj->address; $this->zip = $obj->zip; $this->town = $obj->town; $this->country_id = $obj->country_id; - $this->country_code = $obj->country_id?$obj->country_code:''; - $this->country = $obj->country_id?($langs->transnoentities('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; + $this->country_code = $obj->country_id ? $obj->country_code : ''; + $this->country = $obj->country_id ? ($langs->transnoentities('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : ''; $this->state_id = $obj->state_id; $this->state_code = $obj->state_code; - $this->state = ($obj->state!='-'?$obj->state:''); + $this->state = ($obj->state != '-' ? $obj->state : ''); - $transcode=$langs->trans('StatusProspect'.$obj->fk_stcomm); - $label = ($transcode!='StatusProspect'.$obj->fk_stcomm ? $transcode : $obj->stcomm); - $this->stcomm_id = $obj->fk_stcomm; // id status prospect - $this->status_prospect_label = $label; // label status prospect + $transcode = $langs->trans('StatusProspect'.$obj->fk_stcomm); + $label = ($transcode != 'StatusProspect'.$obj->fk_stcomm ? $transcode : $obj->stcomm); + $this->stcomm_id = $obj->fk_stcomm; // id status prospect + $this->status_prospect_label = $label; // label status prospect $this->email = $obj->email; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); @@ -1377,7 +1377,7 @@ class Societe extends CommonObject $this->phone = $obj->phone; $this->fax = $obj->fax; - $this->parent = $obj->parent; + $this->parent = $obj->parent; $this->idprof1 = $obj->idprof1; $this->idprof2 = $obj->idprof2; @@ -1386,7 +1386,7 @@ class Societe extends CommonObject $this->idprof5 = $obj->idprof5; $this->idprof6 = $obj->idprof6; - $this->capital = $obj->capital; + $this->capital = $obj->capital; $this->code_client = $obj->code_client; $this->code_fournisseur = $obj->code_fournisseur; @@ -1411,23 +1411,23 @@ class Societe extends CommonObject $this->typent_code = $obj->typent_code; $this->effectif_id = $obj->effectif_id; - $this->effectif = $obj->effectif_id?$obj->effectif:''; + $this->effectif = $obj->effectif_id ? $obj->effectif : ''; - $this->forme_juridique_code= $obj->forme_juridique_code; - $this->forme_juridique = $obj->forme_juridique_code?$obj->forme_juridique:''; + $this->forme_juridique_code = $obj->forme_juridique_code; + $this->forme_juridique = $obj->forme_juridique_code ? $obj->forme_juridique : ''; $this->fk_prospectlevel = $obj->fk_prospectlevel; $this->prefix_comm = $obj->prefix_comm; - $this->remise_percent = price2num($obj->remise_client); // 0.000000 must be 0 - $this->remise_supplier_percent = $obj->remise_supplier; + $this->remise_percent = price2num($obj->remise_client); // 0.000000 must be 0 + $this->remise_supplier_percent = $obj->remise_supplier; $this->mode_reglement_id = $obj->mode_reglement; $this->cond_reglement_id = $obj->cond_reglement; $this->mode_reglement_supplier_id = $obj->mode_reglement_supplier; $this->cond_reglement_supplier_id = $obj->cond_reglement_supplier; - $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; - $this->fk_account = $obj->fk_account; + $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; + $this->fk_account = $obj->fk_account; $this->client = $obj->client; $this->fournisseur = $obj->fournisseur; @@ -1445,7 +1445,7 @@ class Societe extends CommonObject $this->outstanding_limit = $obj->outstanding_limit; $this->order_min_amount = $obj->order_min_amount; - $this->supplier_order_min_amount = $obj->supplier_order_min_amount; + $this->supplier_order_min_amount = $obj->supplier_order_min_amount; // multiprix $this->price_level = $obj->price_level; @@ -1475,12 +1475,12 @@ class Societe extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $result = -3; } // Use first price level if level not defined for third party - if ((! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && empty($this->price_level)) $this->price_level=1; + if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && empty($this->price_level)) $this->price_level = 1; return $result; } @@ -1497,11 +1497,11 @@ class Societe extends CommonObject { global $langs, $conf, $user; - if (empty($fuser)) $fuser=$user; + if (empty($fuser)) $fuser = $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $entity=isset($this->entity)?$this->entity:$conf->entity; + $entity = isset($this->entity) ? $this->entity : $conf->entity; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $error = 0; @@ -1513,15 +1513,15 @@ class Societe extends CommonObject $this->db->begin(); // User is mandatory for trigger call - if (! $error && $call_trigger) + if (!$error && $call_trigger) { // Call trigger - $result=$this->call_trigger('COMPANY_DELETE', $fuser); + $result = $this->call_trigger('COMPANY_DELETE', $fuser); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $static_cat = new Categorie($this->db); @@ -1549,11 +1549,11 @@ class Societe extends CommonObject foreach ($this->childtablesoncascade as $tabletodelete) { - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete; - $sql.= " WHERE fk_soc = " . $id; - if (! $this->db->query($sql)) + $sql .= " WHERE fk_soc = ".$id; + if (!$this->db->query($sql)) { $error++; $this->errors[] = $this->db->lasterror(); @@ -1562,9 +1562,9 @@ class Societe 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(); + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -1573,12 +1573,12 @@ class Societe extends CommonObject } // Remove links to subsidiaries companies - if (! $error) + if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql.= " SET parent = NULL"; - $sql.= " WHERE parent = " . $id; - if (! $this->db->query($sql)) + $sql .= " SET parent = NULL"; + $sql .= " WHERE parent = ".$id; + if (!$this->db->query($sql)) { $error++; $this->errors[] = $this->db->lasterror(); @@ -1586,25 +1586,25 @@ class Societe extends CommonObject } // Remove third party - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE rowid = " . $id; - if (! $this->db->query($sql)) + $sql .= " WHERE rowid = ".$id; + if (!$this->db->query($sql)) { $error++; $this->errors[] = $this->db->lasterror(); } } - if (! $error) + if (!$error) { $this->db->commit(); // Delete directory - if (! empty($conf->societe->multidir_output[$entity])) + if (!empty($conf->societe->multidir_output[$entity])) { - $docdir = $conf->societe->multidir_output[$entity] . "/" . $id; + $docdir = $conf->societe->multidir_output[$entity]."/".$id; if (dol_is_dir($docdir)) { dol_delete_dir_recursive($docdir); @@ -1635,13 +1635,13 @@ class Societe extends CommonObject // phpcs:enable if ($this->id) { - $newclient=1; - if ($this->client == 2 || $this->client == 3) $newclient=3; //If prospect, we keep prospect tag + $newclient = 1; + if ($this->client == 2 || $this->client == 3) $newclient = 3; //If prospect, we keep prospect tag $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql.= " SET client = ".$newclient; - $sql.= " WHERE rowid = " . $this->id; + $sql .= " SET client = ".$newclient; + $sql .= " WHERE rowid = ".$this->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->client = $newclient; @@ -1667,10 +1667,10 @@ class Societe extends CommonObject global $conf, $langs; // Parameter cleaning - $note=trim($note); - if (! $note) + $note = trim($note); + if (!$note) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NoteReason")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NoteReason")); return -2; } @@ -1680,33 +1680,33 @@ class Societe extends CommonObject { $this->db->begin(); - $now=dol_now(); + $now = dol_now(); // Position current discount $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; - $sql.= " SET remise_client = '".$this->db->escape($remise)."'"; - $sql.= " WHERE rowid = " . $this->id; - $resql=$this->db->query($sql); - if (! $resql) + $sql .= " SET remise_client = '".$this->db->escape($remise)."'"; + $sql .= " WHERE rowid = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } // Writes trace in discount history $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise"; - $sql.= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; - $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; - $sql.= " '".$this->db->escape($note)."',"; - $sql.= " ".$user->id; - $sql.= ")"; + $sql .= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; + $sql .= " '".$this->db->escape($note)."',"; + $sql .= " ".$user->id; + $sql .= ")"; - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } @@ -1730,10 +1730,10 @@ class Societe extends CommonObject global $conf, $langs; // Parameter cleaning - $note=trim($note); - if (! $note) + $note = trim($note); + if (!$note) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NoteReason")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NoteReason")); return -2; } @@ -1743,33 +1743,33 @@ class Societe extends CommonObject { $this->db->begin(); - $now=dol_now(); + $now = dol_now(); // Position current discount $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; - $sql.= " SET remise_supplier = '".$this->db->escape($remise)."'"; - $sql.= " WHERE rowid = " . $this->id; - $resql=$this->db->query($sql); - if (! $resql) + $sql .= " SET remise_supplier = '".$this->db->escape($remise)."'"; + $sql .= " WHERE rowid = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } // Writes trace in discount history $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_supplier"; - $sql.= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)"; - $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; - $sql.= " '".$this->db->escape($note)."',"; - $sql.= " ".$user->id; - $sql.= ")"; + $sql .= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; + $sql .= " '".$this->db->escape($note)."',"; + $sql .= " ".$user->id; + $sql .= ")"; - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } @@ -1799,14 +1799,14 @@ class Societe extends CommonObject $desc = trim($desc); // Check parameters - if (! $remise > 0) + if (!$remise > 0) { - $this->error=$langs->trans("ErrorWrongValueForParameter", "1"); + $this->error = $langs->trans("ErrorWrongValueForParameter", "1"); return -1; } - if (! $desc) + if (!$desc) { - $this->error=$langs->trans("ErrorWrongValueForParameter", "3"); + $this->error = $langs->trans("ErrorWrongValueForParameter", "3"); return -2; } @@ -1815,25 +1815,25 @@ class Societe extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($this->db); - $discount->fk_soc=$this->id; + $discount->fk_soc = $this->id; - $discount->discount_type=$discount_type; + $discount->discount_type = $discount_type; - $discount->amount_ht=$discount->multicurrency_amount_ht=price2num($remise, 'MT'); - $discount->amount_tva=$discount->multicurrency_amount_tva=price2num($remise*$tva_tx/100, 'MT'); - $discount->amount_ttc=$discount->multicurrency_amount_ttc=price2num($discount->amount_ht+$discount->amount_tva, 'MT'); + $discount->amount_ht = $discount->multicurrency_amount_ht = price2num($remise, 'MT'); + $discount->amount_tva = $discount->multicurrency_amount_tva = price2num($remise * $tva_tx / 100, 'MT'); + $discount->amount_ttc = $discount->multicurrency_amount_ttc = price2num($discount->amount_ht + $discount->amount_tva, 'MT'); - $discount->tva_tx=price2num($tva_tx, 'MT'); - $discount->description=$desc; + $discount->tva_tx = price2num($tva_tx, 'MT'); + $discount->description = $desc; - $result=$discount->create($user); + $result = $discount->create($user); if ($result > 0) { return $result; } else { - $this->error=$discount->error; + $this->error = $discount->error; return -3; } } @@ -1853,15 +1853,15 @@ class Societe extends CommonObject { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic=new DiscountAbsolute($this->db); - $result=$discountstatic->getAvailableDiscounts($this, $user, $filter, $maxvalue, $discount_type); + $discountstatic = new DiscountAbsolute($this->db); + $result = $discountstatic->getAvailableDiscounts($this, $user, $filter, $maxvalue, $discount_type); if ($result >= 0) { return $result; } else { - $this->error=$discountstatic->error; + $this->error = $discountstatic->error; return -1; } } @@ -1877,47 +1877,47 @@ class Societe extends CommonObject { global $conf; - $reparray=array(); + $reparray = array(); $sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.office_phone, u.job, u.email, u.statut, u.entity, u.photo"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + $sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE ((ug.fk_user = sc.fk_user"; - $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1)"; + $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE ((ug.fk_user = sc.fk_user"; + $sql .= " AND ug.entity = ".$conf->entity.")"; + $sql .= " OR u.admin = 1)"; } else - $sql.= " WHERE entity in (0, ".$conf->entity.")"; + $sql .= " WHERE entity in (0, ".$conf->entity.")"; - $sql.= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".$this->id; + $sql .= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".$this->id; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); if (empty($mode)) { - $reparray[$i]['id']=$obj->rowid; - $reparray[$i]['lastname']=$obj->lastname; - $reparray[$i]['firstname']=$obj->firstname; - $reparray[$i]['email']=$obj->email; - $reparray[$i]['phone']=$obj->office_phone; - $reparray[$i]['job']=$obj->job; - $reparray[$i]['statut']=$obj->statut; - $reparray[$i]['entity']=$obj->entity; - $reparray[$i]['login']=$obj->login; - $reparray[$i]['photo']=$obj->photo; + $reparray[$i]['id'] = $obj->rowid; + $reparray[$i]['lastname'] = $obj->lastname; + $reparray[$i]['firstname'] = $obj->firstname; + $reparray[$i]['email'] = $obj->email; + $reparray[$i]['phone'] = $obj->office_phone; + $reparray[$i]['job'] = $obj->job; + $reparray[$i]['statut'] = $obj->statut; + $reparray[$i]['entity'] = $obj->entity; + $reparray[$i]['login'] = $obj->login; + $reparray[$i]['photo'] = $obj->photo; } else { - $reparray[]=$obj->rowid; + $reparray[] = $obj->rowid; } $i++; } @@ -1942,13 +1942,13 @@ class Societe extends CommonObject // phpcs:enable if ($this->id) { - $now=dol_now(); + $now = dol_now(); $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; $sql .= " SET price_level = '".$this->db->escape($price_level)."'"; - $sql .= " WHERE rowid = " . $this->id; + $sql .= " WHERE rowid = ".$this->id; - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; @@ -1958,7 +1958,7 @@ class Societe extends CommonObject $sql .= " (datec, fk_soc, price_level, fk_user_author)"; $sql .= " VALUES ('".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($price_level)."', ".$user->id.")"; - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; @@ -1979,51 +1979,51 @@ class Societe extends CommonObject public function add_commercial(User $user, $commid) { // phpcs:enable - $error=0; + $error = 0; if ($this->id > 0 && $commid > 0) { $this->db->begin(); - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; - $sql.= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; + $sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { dol_syslog(get_class($this)."::add_commercial Error ".$this->db->lasterror()); $error++; } } - if (! $error) + if (!$error) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_commerciaux"; - $sql.= " (fk_soc, fk_user)"; - $sql.= " VALUES (".$this->id.", ".$commid.")"; + $sql .= " (fk_soc, fk_user)"; + $sql .= " VALUES (".$this->id.", ".$commid.")"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { dol_syslog(get_class($this)."::add_commercial Error ".$this->db->lasterror()); $error++; } } - if (! $error) + if (!$error) { - $this->context=array('commercial_modified'=>$commid); + $this->context = array('commercial_modified'=>$commid); - $result=$this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE', $user); + $result = $this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE', $user); if ($result < 0) { $error++; } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -2049,10 +2049,10 @@ class Societe extends CommonObject public function del_commercial(User $user, $commid) { // phpcs:enable - $error=0; - $this->context=array('commercial_modified'=>$commid); + $error = 0; + $this->context = array('commercial_modified'=>$commid); - $result=$this->call_trigger('COMPANY_UNLINK_SALE_REPRESENTATIVE', $user); + $result = $this->call_trigger('COMPANY_UNLINK_SALE_REPRESENTATIVE', $user); if ($result < 0) $error++; if ($this->id > 0 && $commid > 0) @@ -2060,7 +2060,7 @@ class Societe extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux "; $sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { dol_syslog(get_class($this)."::del_commercial Erreur"); } @@ -2082,160 +2082,160 @@ class Societe extends CommonObject { global $conf, $langs, $hookmanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $name=$this->name?$this->name:$this->nom; + $name = $this->name ? $this->name : $this->nom; - if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)){ + if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) { if (empty($option) && $this->client > 0) $option = 'customer'; if (empty($option) && $this->fournisseur > 0) $option = 'supplier'; } - if (! empty($conf->global->SOCIETE_ADD_REF_IN_LIST) && (!empty($withpicto))) + if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST) && (!empty($withpicto))) { $code = ''; - if (($this->client) && (! empty($this->code_client)) + if (($this->client) && (!empty($this->code_client)) && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 || $conf->global->SOCIETE_ADD_REF_IN_LIST == 2 ) ) { - $code = $this->code_client . ' - '; + $code = $this->code_client.' - '; } - if (($this->fournisseur) && (! empty($this->code_fournisseur)) - && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 || $conf->global->SOCIETE_ADD_REF_IN_LIST == 3 + if (($this->fournisseur) && (!empty($this->code_fournisseur)) + && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 || $conf->global->SOCIETE_ADD_REF_IN_LIST == 3 ) ) { - $code .= $this->code_fournisseur . ' - '; + $code .= $this->code_fournisseur.' - '; } if ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1) { - $name =$code.' '.$name; + $name = $code.' '.$name; } else { - $name =$code; + $name = $code; } } if (!empty($this->name_alias)) $name .= ' ('.$this->name_alias.')'; - $result=''; $label=''; - $linkstart=''; $linkend=''; + $result = ''; $label = ''; + $linkstart = ''; $linkend = ''; - if (! empty($this->logo) && class_exists('Form')) + if (!empty($this->logo) && class_exists('Form')) { - $label.= '
    '; - $label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. - $label.= '
    '; + $label .= '
    '; + $label .= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. + $label .= '
    '; } - elseif (! empty($this->logo_squarred) && class_exists('Form')) + elseif (!empty($this->logo_squarred) && class_exists('Form')) { /*$label.= '
    '; $label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. $label.= '
    ';*/ } - $label.= '
    '; + $label .= '
    '; if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier') { - $label.= '' . $langs->trans("ShowCustomer") . ''; + $label .= ''.$langs->trans("ShowCustomer").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowProspect").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowSupplier").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowAgenda").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowProject").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowMargin").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowContacts").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowBan").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowCompany").''; $linkstart = 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowCompany"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowCompany"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip refurl"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip refurl"'; /* $hookmanager->initHooks(array('thirdpartydao')); @@ -2244,25 +2244,25 @@ class Societe extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - $linkstart.=$linkclose.'>'; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; global $user; - if (! $user->rights->societe->client->voir && $user->socid > 0 && $this->id != $user->socid) + if (!$user->rights->societe->client->voir && $user->socid > 0 && $this->id != $user->socid) { - $linkstart=''; - $linkend=''; + $linkstart = ''; + $linkend = ''; } - $result.=$linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valignmiddle"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.=($maxlen?dol_trunc($name, $maxlen):$name); - $result.=$linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valignmiddle"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($name, $maxlen) : $name); + $result .= $linkend; global $action; $hookmanager->initHooks(array('thirdpartydao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -2323,8 +2323,8 @@ class Societe extends CommonObject $contact_emails = $this->contact_property_array('email', 1); if ($this->email && $addthirdparty) { - if (empty($this->name)) $this->name=$this->nom; - $contact_emails['thirdparty']=$langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name, 16)." <".$this->email.">"; + if (empty($this->name)) $this->name = $this->nom; + $contact_emails['thirdparty'] = $langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name, 16)." <".$this->email.">"; } //var_dump($contact_emails) return $contact_emails; @@ -2343,11 +2343,11 @@ class Societe extends CommonObject $contact_phone = $this->contact_property_array('mobile'); - if (! empty($this->phone)) // If a phone of thirdparty is defined, we add it ot mobile of contacts + if (!empty($this->phone)) // If a phone of thirdparty is defined, we add it ot mobile of contacts { - if (empty($this->name)) $this->name=$this->nom; + if (empty($this->name)) $this->name = $this->nom; // TODO: Tester si tel non deja present dans tableau contact - $contact_phone['thirdparty']=$langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name, 16)." <".$this->phone.">"; + $contact_phone['thirdparty'] = $langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name, 16)." <".$this->phone.">"; } return $contact_phone; } @@ -2369,46 +2369,46 @@ class Societe extends CommonObject $sql = "SELECT rowid, email, statut, phone_mobile, lastname, poste, firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; - $sql.= " WHERE fk_soc = ".$this->id; - $sql.= " ORDER BY lastname, firstname"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople"; + $sql .= " WHERE fk_soc = ".$this->id; + $sql .= " ORDER BY lastname, firstname"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $nump = $this->db->num_rows($resql); if ($nump) { - $sepa="("; $sepb=")"; + $sepa = "("; $sepb = ")"; if ($mode == 'email') { //$sepa="<"; $sepb=">"; - $sepa="<"; $sepb=">"; + $sepa = "<"; $sepb = ">"; } $i = 0; while ($i < $nump) { $obj = $this->db->fetch_object($resql); - if ($mode == 'email') $property=$obj->email; - elseif ($mode == 'mobile') $property=$obj->phone_mobile; - else $property=$obj->$mode; + if ($mode == 'email') $property = $obj->email; + elseif ($mode == 'mobile') $property = $obj->phone_mobile; + else $property = $obj->$mode; // Show all contact. If hidedisabled is 1, showonly contacts with status = 1 if ($obj->statut == 1 || empty($hidedisabled)) { if (empty($property)) { - if ($mode == 'email') $property=$langs->transnoentitiesnoconv("NoEMail"); - elseif ($mode == 'mobile') $property=$langs->transnoentitiesnoconv("NoMobilePhone"); + if ($mode == 'email') $property = $langs->transnoentitiesnoconv("NoEMail"); + elseif ($mode == 'mobile') $property = $langs->transnoentitiesnoconv("NoMobilePhone"); } if (!empty($obj->poste)) { - $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname, $obj->lastname)).($obj->poste?" - ".$obj->poste:"").(($mode != 'poste' && $property)?" ".$sepa.$property.$sepb:''); + $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname, $obj->lastname)).($obj->poste ? " - ".$obj->poste : "").(($mode != 'poste' && $property) ? " ".$sepa.$property.$sepb : ''); } else { - $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname, $obj->lastname)).(($mode != 'poste' && $property)?" ".$sepa.$property.$sepb:''); + $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname, $obj->lastname)).(($mode != 'poste' && $property) ? " ".$sepa.$property.$sepb : ''); } } $i++; @@ -2435,7 +2435,7 @@ class Societe extends CommonObject $contacts = array(); $sql = "SELECT rowid, lastname, firstname FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$this->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $nump = $this->db->num_rows($resql); @@ -2466,11 +2466,11 @@ class Societe extends CommonObject public function contact_array_objects() { // phpcs:enable - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contacts = array(); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$this->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $nump = $this->db->num_rows($resql); @@ -2505,15 +2505,15 @@ class Societe extends CommonObject public function contact_get_property($rowid, $mode) { // phpcs:enable - $contact_property=''; + $contact_property = ''; if (empty($rowid)) return ''; $sql = "SELECT rowid, email, phone_mobile, lastname, firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; - $sql.= " WHERE rowid = '".$rowid."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople"; + $sql .= " WHERE rowid = '".$rowid."'"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $nump = $this->db->num_rows($resql); @@ -2544,7 +2544,7 @@ class Societe extends CommonObject public function display_rib($mode = 'label') { // phpcs:enable - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $bac = new CompanyBankAccount($this->db); $bac->fetch(0, $this->id); @@ -2557,7 +2557,7 @@ class Societe extends CommonObject { if (empty($bac->rum)) { - require_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/bonprelevement.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; $prelevement = new BonPrelevement($this->db); $bac->fetch_thirdparty(); $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id); @@ -2581,7 +2581,7 @@ class Societe extends CommonObject public function get_all_rib() { // phpcs:enable - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib WHERE type='ban' AND fk_soc = ".$this->id; $result = $this->db->query($sql); if (!$result) { @@ -2615,14 +2615,14 @@ class Societe extends CommonObject { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $mod = new $module(); @@ -2647,14 +2647,14 @@ class Societe extends CommonObject { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $mod = new $module(); @@ -2676,23 +2676,23 @@ class Societe extends CommonObject { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $mod = new $module(); dol_syslog(get_class($this)."::codeclient_modifiable code_client=".$this->code_client." module=".$module); - if ($mod->code_modifiable_null && ! $this->code_client) return 1; + if ($mod->code_modifiable_null && !$this->code_client) return 1; if ($mod->code_modifiable_invalide && $this->check_codeclient() < 0) return 1; - if ($mod->code_modifiable) return 1; // A mettre en dernier + if ($mod->code_modifiable) return 1; // A mettre en dernier return 0; } else @@ -2712,23 +2712,23 @@ class Societe extends CommonObject { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $mod = new $module(); dol_syslog(get_class($this)."::codefournisseur_modifiable code_founisseur=".$this->code_fournisseur." module=".$module); - if ($mod->code_modifiable_null && ! $this->code_fournisseur) return 1; + if ($mod->code_modifiable_null && !$this->code_fournisseur) return 1; if ($mod->code_modifiable_invalide && $this->check_codefournisseur() < 0) return 1; - if ($mod->code_modifiable) return 1; // A mettre en dernier + if ($mod->code_modifiable) return 1; // A mettre en dernier return 0; } else @@ -2752,14 +2752,14 @@ class Societe extends CommonObject { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } @@ -2789,14 +2789,14 @@ class Societe extends CommonObject { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } @@ -2826,13 +2826,13 @@ class Societe extends CommonObject // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECOMPTA_ADDON)) + if (!empty($conf->global->SOCIETE_CODECOMPTA_ADDON)) { - $res=false; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $res = false; + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.'.php'); + $res = dol_include_once($dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.'.php'); if ($res) break; } @@ -2877,10 +2877,10 @@ class Societe extends CommonObject if ($this->id) { $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql.= " SET parent = ".($id > 0 ? $id : "null"); - $sql.= " WHERE rowid = " . $this->id; + $sql .= " SET parent = ".($id > 0 ? $id : "null"); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this).'::set_parent', LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->parent = $id; @@ -2906,28 +2906,28 @@ class Societe extends CommonObject // phpcs:enable global $conf; - switch($idprof) + switch ($idprof) { case 1: - $ret=(!$conf->global->SOCIETE_IDPROF1_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF1_UNIQUE ?false:true); break; case 2: - $ret=(!$conf->global->SOCIETE_IDPROF2_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF2_UNIQUE ?false:true); break; case 3: - $ret=(!$conf->global->SOCIETE_IDPROF3_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF3_UNIQUE ?false:true); break; case 4: - $ret=(!$conf->global->SOCIETE_IDPROF4_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF4_UNIQUE ?false:true); break; case 5: - $ret=(!$conf->global->SOCIETE_IDPROF5_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF5_UNIQUE ?false:true); break; case 6: - $ret=(!$conf->global->SOCIETE_IDPROF6_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF6_UNIQUE ?false:true); break; default: - $ret=false; + $ret = false; } return $ret; @@ -2947,35 +2947,35 @@ class Societe extends CommonObject // phpcs:enable $field = $idprof; - switch($idprof) // For backward compatibility + switch ($idprof) // For backward compatibility { case '1': case 'idprof1': - $field="siren"; + $field = "siren"; break; case '2': case 'idprof2': - $field="siret"; + $field = "siret"; break; case '3': case 'idprof3': - $field="ape"; + $field = "ape"; break; case '4': case 'idprof4': - $field="idprof4"; + $field = "idprof4"; break; case '5': - $field="idprof5"; + $field = "idprof5"; break; case '6': - $field="idprof6"; + $field = "idprof6"; break; } //Verify duplicate entries - $sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe').")"; - if($socid) $sql .= " AND rowid <> ".$socid; + $sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe').")"; + if ($socid) $sql .= " AND rowid <> ".$socid; $resql = $this->db->query($sql); if ($resql) { @@ -3007,15 +3007,15 @@ class Societe extends CommonObject // phpcs:enable global $conf; - $ok=1; + $ok = 1; - if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1; + if (!empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1; // Check SIREN if country FR if ($idprof == 1 && $soc->country_code == 'FR') { - $chaine=trim($this->idprof1); - $chaine=preg_replace('/(\s)/', '', $chaine); + $chaine = trim($this->idprof1); + $chaine = preg_replace('/(\s)/', '', $chaine); if (!is_numeric($chaine)) return -1; if (dol_strlen($chaine) != 9) return -1; @@ -3025,7 +3025,7 @@ class Societe extends CommonObject // on double sa valeur et si cette dernière est supérieure à 9, on lui retranche 9 // on ajoute cette valeur à la somme totale - for ($index = 0; $index < 9; $index ++) + for ($index = 0; $index < 9; $index++) { $number = (int) $chaine[$index]; if (($index % 2) != 0) { if (($number *= 2) > 9) $number -= 9; } @@ -3039,8 +3039,8 @@ class Societe extends CommonObject // Verifie SIRET si pays FR if ($idprof == 2 && $soc->country_code == 'FR') { - $chaine=trim($this->idprof2); - $chaine=preg_replace('/(\s)/', '', $chaine); + $chaine = trim($this->idprof2); + $chaine = preg_replace('/(\s)/', '', $chaine); if (!is_numeric($chaine)) return -1; if (dol_strlen($chaine) != 14) return -1; @@ -3050,7 +3050,7 @@ class Societe extends CommonObject // on double sa valeur et si cette dernière est supérieure à 9, on lui retranche 9 // on ajoute cette valeur à la somme totale - for ($index = 0; $index < 14; $index ++) + for ($index = 0; $index < 14; $index++) { $number = (int) $chaine[$index]; if (($index % 2) == 0) { if (($number *= 2) > 9) $number -= 9; } @@ -3065,8 +3065,8 @@ class Societe extends CommonObject //Returns: 1 if NIF ok, 2 if CIF ok, 3 if NIE ok, -1 if NIF bad, -2 if CIF bad, -3 if NIE bad, 0 if unexpected bad if ($idprof == 1 && $soc->country_code == 'ES') { - $string=trim($this->idprof1); - $string=preg_replace('/(\s)/', '', $string); + $string = trim($this->idprof1); + $string = preg_replace('/(\s)/', '', $string); $string = strtoupper($string); //Check format @@ -3074,7 +3074,7 @@ class Societe extends CommonObject return 0; $num = array(); - for ($i = 0; $i < 9; $i ++) + for ($i = 0; $i < 9; $i++) { $num[$i] = substr($string, $i, 1); } @@ -3115,7 +3115,7 @@ class Societe extends CommonObject //Check NIE XYZ if (preg_match('/^[XYZ]{1}/', $string)) - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X', 'Y', 'Z'), array('0', '1', '2'), $string), 0, 8) % 23, 1)) return 3; else return -3; @@ -3128,10 +3128,10 @@ class Societe extends CommonObject //Returns: 1 if NIF ok, -1 if NIF bad, 0 if unexpected bad if ($idprof == 1 && $soc->country_code == 'PT') { - $string=trim($this->idprof1); - $string=preg_replace('/(\s)/', '', $string); + $string = trim($this->idprof1); + $string = preg_replace('/(\s)/', '', $string); - for ($i = 0; $i < 9; $i ++) { + for ($i = 0; $i < 9; $i++) { $num[$i] = substr($string, $i, 1); } @@ -3159,35 +3159,35 @@ class Societe extends CommonObject public function id_prof_url($idprof, $thirdparty) { // phpcs:enable - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; - $url=''; + $url = ''; $action = ''; $hookmanager->initHooks(array('idprofurl')); - $parameters=array('idprof'=>$idprof, 'company'=>$thirdparty); - $reshook=$hookmanager->executeHooks('getIdProfUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('idprof'=>$idprof, 'company'=>$thirdparty); + $reshook = $hookmanager->executeHooks('getIdProfUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) { + if (!empty($conf->global->MAIN_DISABLEPROFIDRULES)) { return ''; } // TODO Move links to validate professional ID into a dictionary table "country" + "link" $strippedIdProf1 = str_replace(' ', '', $thirdparty->idprof1); if ($idprof == 1 && $thirdparty->country_code == 'FR') { - $url='http://www.societe.com/cgi-bin/search?champs='.$strippedIdProf1; // See also http://avis-situation-sirene.insee.fr/ + $url = 'http://www.societe.com/cgi-bin/search?champs='.$strippedIdProf1; // See also http://avis-situation-sirene.insee.fr/ } if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) { - $url='https://beta.companieshouse.gov.uk/company/'.$strippedIdProf1; + $url = 'https://beta.companieshouse.gov.uk/company/'.$strippedIdProf1; } if ($idprof == 1 && $thirdparty->country_code == 'ES') { - $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$strippedIdProf1; + $url = 'http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$strippedIdProf1; } if ($idprof == 1 && $thirdparty->country_code == 'IN') { - $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$strippedIdProf1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; + $url = 'http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$strippedIdProf1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; } if ($idprof == 1 && $thirdparty->country_code == 'PT') { - $url='http://www.nif.pt/'.$strippedIdProf1; + $url = 'http://www.nif.pt/'.$strippedIdProf1; } if ($url) { @@ -3210,7 +3210,7 @@ class Societe extends CommonObject public function has_projects() { // phpcs:enable - $sql = 'SELECT COUNT(*) as numproj FROM '.MAIN_DB_PREFIX.'projet WHERE fk_soc = ' . $this->id; + $sql = 'SELECT COUNT(*) as numproj FROM '.MAIN_DB_PREFIX.'projet WHERE fk_soc = '.$this->id; $resql = $this->db->query($sql); if ($resql) { @@ -3236,11 +3236,11 @@ class Societe extends CommonObject public function info($id) { $sql = "SELECT s.rowid, s.nom as name, s.datec as date_creation, tms as date_modification,"; - $sql.= " fk_user_creat, fk_user_modif"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.rowid = ".$id; + $sql .= " fk_user_creat, fk_user_modif"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.rowid = ".$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -3252,7 +3252,7 @@ class Societe extends CommonObject if ($obj->fk_user_creat) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_creat); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_modif) { @@ -3261,7 +3261,7 @@ class Societe extends CommonObject $this->user_modification = $muser; } - $this->ref = $obj->name; + $this->ref = $obj->name; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); } @@ -3284,14 +3284,14 @@ class Societe extends CommonObject global $conf; // Define if third party is treated as company (or not) when nature is unknown - $isacompany=empty($conf->global->MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES)?0:1; // 0 by default - if (! empty($this->tva_intra)) { + $isacompany = empty($conf->global->MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES) ? 0 : 1; // 0 by default + if (!empty($this->tva_intra)) { $isacompany = 1; } - elseif (! empty($this->idprof1) || ! empty($this->idprof2) || ! empty($this->idprof3) || ! empty($this->idprof4) || ! empty($this->idprof5) || ! empty($this->idprof6)) { + elseif (!empty($this->idprof1) || !empty($this->idprof2) || !empty($this->idprof3) || !empty($this->idprof4) || !empty($this->idprof5) || !empty($this->idprof6)) { $isacompany = 1; } - elseif (! empty($this->typent_code) && $this->typent_code != 'TE_UNKNOWN') + elseif (!empty($this->typent_code) && $this->typent_code != 'TE_UNKNOWN') { // TODO Add a field is_a_company into dictionary if (preg_match('/^TE_PRIVATE/', $this->typent_code)) $isacompany = 0; @@ -3323,13 +3323,13 @@ class Societe extends CommonObject // phpcs:enable $this->SupplierCategories = array(); $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE type = ".Categorie::TYPE_SUPPLIER; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; + $sql .= " WHERE type = ".Categorie::TYPE_SUPPLIER; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj = $this->db->fetch_object($resql) ) + while ($obj = $this->db->fetch_object($resql)) { $this->SupplierCategories[$obj->rowid] = $obj->label; } @@ -3354,9 +3354,9 @@ class Societe extends CommonObject if ($categorie_id > 0 && $this->id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_fournisseur (fk_categorie, fk_soc) "; - $sql.= " VALUES (".$categorie_id.", ".$this->id.")"; + $sql .= " VALUES (".$categorie_id.", ".$this->id.")"; - if ($resql=$this->db->query($sql)) return 0; + if ($resql = $this->db->query($sql)) return 0; } else { @@ -3379,43 +3379,43 @@ class Societe extends CommonObject public function create_from_member(Adherent $member, $socname = '', $socalias = '', $customercode = '') { // phpcs:enable - global $user,$langs; + global $user, $langs; dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG); - $name = $socname?$socname:$member->societe; - if (empty($name)) $name=$member->getFullName($langs); + $name = $socname ? $socname : $member->societe; + if (empty($name)) $name = $member->getFullName($langs); - $alias = $socalias?$socalias:''; + $alias = $socalias ? $socalias : ''; // Positionne parametres - $this->nom=$name; // TODO deprecated - $this->name=$name; - $this->name_alias=$alias; - $this->address=$member->address; - $this->zip=$member->zip; - $this->town=$member->town; - $this->country_code=$member->country_code; - $this->country_id=$member->country_id; - $this->phone=$member->phone; // Prof phone - $this->email=$member->email; + $this->nom = $name; // TODO deprecated + $this->name = $name; + $this->name_alias = $alias; + $this->address = $member->address; + $this->zip = $member->zip; + $this->town = $member->town; + $this->country_code = $member->country_code; + $this->country_id = $member->country_id; + $this->phone = $member->phone; // Prof phone + $this->email = $member->email; $this->socialnetworks = $member->socialnetworks; - $this->client = 1; // A member is a customer by default - $this->code_client = ($customercode?$customercode:-1); + $this->client = 1; // A member is a customer by default + $this->code_client = ($customercode ? $customercode : -1); $this->code_fournisseur = -1; $this->db->begin(); // Cree et positionne $this->id - $result=$this->create($user); + $result = $this->create($user); if ($result >= 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql.= " SET fk_soc=".$this->id; - $sql.= " WHERE rowid=".$member->id; + $sql .= " SET fk_soc=".$this->id; + $sql .= " WHERE rowid=".$member->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); @@ -3423,7 +3423,7 @@ class Societe extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -3449,96 +3449,96 @@ class Societe extends CommonObject { global $langs; - $this->id=0; - $this->name=empty($conf->global->MAIN_INFO_SOCIETE_NOM)?'':$conf->global->MAIN_INFO_SOCIETE_NOM; - $this->address=empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS)?'':$conf->global->MAIN_INFO_SOCIETE_ADDRESS; - $this->zip=empty($conf->global->MAIN_INFO_SOCIETE_ZIP)?'':$conf->global->MAIN_INFO_SOCIETE_ZIP; - $this->town=empty($conf->global->MAIN_INFO_SOCIETE_TOWN)?'':$conf->global->MAIN_INFO_SOCIETE_TOWN; - $this->region_code=empty($conf->global->MAIN_INFO_SOCIETE_REGION)?'':$conf->global->MAIN_INFO_SOCIETE_REGION; - $this->object=empty($conf->global->MAIN_INFO_SOCIETE_OBJECT)?'':$conf->global->MAIN_INFO_SOCIETE_OBJECT; + $this->id = 0; + $this->name = empty($conf->global->MAIN_INFO_SOCIETE_NOM) ? '' : $conf->global->MAIN_INFO_SOCIETE_NOM; + $this->address = empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS) ? '' : $conf->global->MAIN_INFO_SOCIETE_ADDRESS; + $this->zip = empty($conf->global->MAIN_INFO_SOCIETE_ZIP) ? '' : $conf->global->MAIN_INFO_SOCIETE_ZIP; + $this->town = empty($conf->global->MAIN_INFO_SOCIETE_TOWN) ? '' : $conf->global->MAIN_INFO_SOCIETE_TOWN; + $this->region_code = empty($conf->global->MAIN_INFO_SOCIETE_REGION) ? '' : $conf->global->MAIN_INFO_SOCIETE_REGION; + $this->object = empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? '' : $conf->global->MAIN_INFO_SOCIETE_OBJECT; - $this->note_private=empty($conf->global->MAIN_INFO_SOCIETE_NOTE)?'':$conf->global->MAIN_INFO_SOCIETE_NOTE; + $this->note_private = empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? '' : $conf->global->MAIN_INFO_SOCIETE_NOTE; - $this->nom=$this->name; // deprecated + $this->nom = $this->name; // deprecated // We define country_id, country_code and country - $country_id=$country_code=$country_label=''; - if (! empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) + $country_id = $country_code = $country_label = ''; + if (!empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { - $tmp=explode(':', $conf->global->MAIN_INFO_SOCIETE_COUNTRY); - $country_id=$tmp[0]; - if (! empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label" + $tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_COUNTRY); + $country_id = $tmp[0]; + if (!empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label" { - $country_code=$tmp[1]; - $country_label=$tmp[2]; + $country_code = $tmp[1]; + $country_label = $tmp[2]; } else // For backward compatibility { dol_syslog("Your country setup use an old syntax. Reedit it using setup area.", LOG_WARNING); include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $country_code=getCountry($country_id, 2, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore - $country_label=getCountry($country_id, 0, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore + $country_code = getCountry($country_id, 2, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore + $country_label = getCountry($country_id, 0, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore } } - $this->country_id=$country_id; - $this->country_code=$country_code; - $this->country=$country_label; - if (is_object($langs)) $this->country=($langs->trans('Country'.$country_code)!='Country'.$country_code)?$langs->trans('Country'.$country_code):$country_label; + $this->country_id = $country_id; + $this->country_code = $country_code; + $this->country = $country_label; + if (is_object($langs)) $this->country = ($langs->trans('Country'.$country_code) != 'Country'.$country_code) ? $langs->trans('Country'.$country_code) : $country_label; //TODO This could be replicated for region but function `getRegion` didn't exist, so I didn't added it. // We define state_id, state_code and state - $state_id=0;$state_code=$state_label=''; - if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) + $state_id = 0; $state_code = $state_label = ''; + if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE)) { - $tmp=explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE); - $state_id=$tmp[0]; - if (! empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_STATE is "id:code:label" + $tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE); + $state_id = $tmp[0]; + if (!empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_STATE is "id:code:label" { - $state_code=$tmp[1]; - $state_label=$tmp[2]; + $state_code = $tmp[1]; + $state_label = $tmp[2]; } else // For backward compatibility { dol_syslog("Your state setup use an old syntax. Reedit it using setup area.", LOG_ERR); include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $state_code=getState($state_id, 2, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore - $state_label=getState($state_id, 0, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore + $state_code = getState($state_id, 2, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore + $state_label = getState($state_id, 0, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore } } - $this->state_id=$state_id; - $this->state_code=$state_code; - $this->state=$state_label; - if (is_object($langs)) $this->state=($langs->trans('State'.$state_code)!='State'.$state_code)?$langs->trans('State'.$state_code):$state_label; + $this->state_id = $state_id; + $this->state_code = $state_code; + $this->state = $state_label; + if (is_object($langs)) $this->state = ($langs->trans('State'.$state_code) != 'State'.$state_code) ? $langs->trans('State'.$state_code) : $state_label; - $this->phone=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; - $this->fax=empty($conf->global->MAIN_INFO_SOCIETE_FAX)?'':$conf->global->MAIN_INFO_SOCIETE_FAX; - $this->url=empty($conf->global->MAIN_INFO_SOCIETE_WEB)?'':$conf->global->MAIN_INFO_SOCIETE_WEB; + $this->phone = empty($conf->global->MAIN_INFO_SOCIETE_TEL) ? '' : $conf->global->MAIN_INFO_SOCIETE_TEL; + $this->fax = empty($conf->global->MAIN_INFO_SOCIETE_FAX) ? '' : $conf->global->MAIN_INFO_SOCIETE_FAX; + $this->url = empty($conf->global->MAIN_INFO_SOCIETE_WEB) ? '' : $conf->global->MAIN_INFO_SOCIETE_WEB; // Id prof generiques - $this->idprof1=empty($conf->global->MAIN_INFO_SIREN)?'':$conf->global->MAIN_INFO_SIREN; - $this->idprof2=empty($conf->global->MAIN_INFO_SIRET)?'':$conf->global->MAIN_INFO_SIRET; - $this->idprof3=empty($conf->global->MAIN_INFO_APE)?'':$conf->global->MAIN_INFO_APE; - $this->idprof4=empty($conf->global->MAIN_INFO_RCS)?'':$conf->global->MAIN_INFO_RCS; - $this->idprof5=empty($conf->global->MAIN_INFO_PROFID5)?'':$conf->global->MAIN_INFO_PROFID5; - $this->idprof6=empty($conf->global->MAIN_INFO_PROFID6)?'':$conf->global->MAIN_INFO_PROFID6; - $this->tva_intra=empty($conf->global->MAIN_INFO_TVAINTRA)?'':$conf->global->MAIN_INFO_TVAINTRA; // VAT number, not necessarly INTRA. - $this->managers=empty($conf->global->MAIN_INFO_SOCIETE_MANAGERS)?'':$conf->global->MAIN_INFO_SOCIETE_MANAGERS; - $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; - $this->logo_squarred=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED; - $this->logo_squarred_small=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL; - $this->logo_squarred_mini=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI; + $this->idprof1 = empty($conf->global->MAIN_INFO_SIREN) ? '' : $conf->global->MAIN_INFO_SIREN; + $this->idprof2 = empty($conf->global->MAIN_INFO_SIRET) ? '' : $conf->global->MAIN_INFO_SIRET; + $this->idprof3 = empty($conf->global->MAIN_INFO_APE) ? '' : $conf->global->MAIN_INFO_APE; + $this->idprof4 = empty($conf->global->MAIN_INFO_RCS) ? '' : $conf->global->MAIN_INFO_RCS; + $this->idprof5 = empty($conf->global->MAIN_INFO_PROFID5) ? '' : $conf->global->MAIN_INFO_PROFID5; + $this->idprof6 = empty($conf->global->MAIN_INFO_PROFID6) ? '' : $conf->global->MAIN_INFO_PROFID6; + $this->tva_intra = empty($conf->global->MAIN_INFO_TVAINTRA) ? '' : $conf->global->MAIN_INFO_TVAINTRA; // VAT number, not necessarly INTRA. + $this->managers = empty($conf->global->MAIN_INFO_SOCIETE_MANAGERS) ? '' : $conf->global->MAIN_INFO_SOCIETE_MANAGERS; + $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; + $this->logo_squarred = empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED; + $this->logo_squarred_small = empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL; + $this->logo_squarred_mini = empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI; // Define if company use vat or not - $this->tva_assuj=$conf->global->FACTURE_TVAOPTION; + $this->tva_assuj = $conf->global->FACTURE_TVAOPTION; // Define if company use local taxes - $this->localtax1_assuj=((isset($conf->global->FACTURE_LOCAL_TAX1_OPTION) && ($conf->global->FACTURE_LOCAL_TAX1_OPTION=='1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on'))?1:0); - $this->localtax2_assuj=((isset($conf->global->FACTURE_LOCAL_TAX2_OPTION) && ($conf->global->FACTURE_LOCAL_TAX2_OPTION=='1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on'))?1:0); + $this->localtax1_assuj = ((isset($conf->global->FACTURE_LOCAL_TAX1_OPTION) && ($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on')) ? 1 : 0); + $this->localtax2_assuj = ((isset($conf->global->FACTURE_LOCAL_TAX2_OPTION) && ($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on')) ? 1 : 0); } /** @@ -3550,51 +3550,51 @@ class Societe extends CommonObject */ public function initAsSpecimen() { - $now=dol_now(); + $now = dol_now(); // Initialize parameters - $this->id=0; + $this->id = 0; $this->name = 'THIRDPARTY SPECIMEN '.dol_print_date($now, 'dayhourlog'); - $this->nom = $this->name; // For backward compatibility + $this->nom = $this->name; // For backward compatibility $this->ref_ext = 'Ref ext'; - $this->specimen=1; - $this->address='21 jump street'; - $this->zip='99999'; - $this->town='MyTown'; - $this->state_id=1; - $this->state_code='AA'; - $this->state='MyState'; - $this->country_id=1; - $this->country_code='FR'; - $this->email='specimen@specimen.com'; + $this->specimen = 1; + $this->address = '21 jump street'; + $this->zip = '99999'; + $this->town = 'MyTown'; + $this->state_id = 1; + $this->state_code = 'AA'; + $this->state = 'MyState'; + $this->country_id = 1; + $this->country_code = 'FR'; + $this->email = 'specimen@specimen.com'; $this->socialnetworks = array( 'skype' => 'tom.hanson', 'twitter' => 'tomhanson', 'facebook' => 'tomhanson', 'linkedin' => 'tomhanson', ); - $this->url='http://www.specimen.com'; + $this->url = 'http://www.specimen.com'; - $this->phone='0909090901'; - $this->fax='0909090909'; + $this->phone = '0909090901'; + $this->fax = '0909090909'; - $this->code_client='CC-'.dol_print_date($now, 'dayhourlog'); - $this->code_fournisseur='SC-'.dol_print_date($now, 'dayhourlog'); - $this->capital=10000; - $this->client=1; - $this->prospect=1; - $this->fournisseur=1; - $this->tva_assuj=1; - $this->tva_intra='EU1234567'; - $this->note_public='This is a comment (public)'; - $this->note_private='This is a comment (private)'; + $this->code_client = 'CC-'.dol_print_date($now, 'dayhourlog'); + $this->code_fournisseur = 'SC-'.dol_print_date($now, 'dayhourlog'); + $this->capital = 10000; + $this->client = 1; + $this->prospect = 1; + $this->fournisseur = 1; + $this->tva_assuj = 1; + $this->tva_intra = 'EU1234567'; + $this->note_public = 'This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; - $this->idprof1='idprof1'; - $this->idprof2='idprof2'; - $this->idprof3='idprof3'; - $this->idprof4='idprof4'; - $this->idprof5='idprof5'; - $this->idprof6='idprof6'; + $this->idprof1 = 'idprof1'; + $this->idprof2 = 'idprof2'; + $this->idprof3 = 'idprof3'; + $this->idprof4 = 'idprof4'; + $this->idprof5 = 'idprof5'; + $this->idprof6 = 'idprof6'; return 1; } @@ -3615,7 +3615,7 @@ class Societe extends CommonObject elseif ($localTaxNum == 2) $sql .= " AND t.localtax2_type <> '0'"; dol_syslog("useLocalTax", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { return ($this->db->num_rows($resql) > 0); @@ -3636,7 +3636,7 @@ class Societe extends CommonObject $sql .= " AND t.active = 1 AND t.recuperableonly = 1"; dol_syslog("useNPR", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { return ($this->db->num_rows($resql) > 0); @@ -3657,15 +3657,15 @@ class Societe extends CommonObject $sql .= " AND r.active = 1"; dol_syslog("useRevenueStamp", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - return (($obj->nb > 0)?true:false); + $obj = $this->db->fetch_object($resql); + return (($obj->nb > 0) ?true:false); } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return false; } } @@ -3692,11 +3692,11 @@ class Societe extends CommonObject // phpcs:enable global $langs; - $lib=$langs->trans("ProspectLevel".$fk_prospectlevel); + $lib = $langs->trans("ProspectLevel".$fk_prospectlevel); // If lib not found in language file, we get label from cache/databse if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) { - $lib=$langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label'); + $lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label'); } return $lib; } @@ -3746,10 +3746,10 @@ class Societe extends CommonObject if ($mode == 2) { if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); - elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); - elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); - elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); - elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); else { return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); @@ -3758,10 +3758,10 @@ class Societe extends CommonObject if ($mode == 3) { if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1); - elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0); - elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1); - elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2); - elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3); else { return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0); @@ -3770,10 +3770,10 @@ class Societe extends CommonObject if ($mode == 4) { if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); - elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); - elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); - elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); - elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); else { return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); @@ -3805,11 +3805,11 @@ class Societe extends CommonObject */ public function getOutstandingProposals($mode = 'customer') { - $table='propal'; + $table = 'propal'; if ($mode == 'supplier') $table = 'supplier_proposal'; $sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + $sql .= " WHERE fk_soc = ".$this->id; if ($mode == 'supplier') { $sql .= " AND entity IN (".getEntity('supplier_proposal').")"; } else { @@ -3817,21 +3817,21 @@ class Societe extends CommonObject } dol_syslog("getOutstandingProposals", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $outstandingOpened = 0; $outstandingTotal = 0; $outstandingTotalIncTax = 0; - while($obj=$this->db->fetch_object($resql)) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; + while ($obj = $this->db->fetch_object($resql)) { + $outstandingTotal += $obj->total_ht; + $outstandingTotalIncTax += $obj->total_ttc; if ($obj->fk_statut != 0) // Not a draft { - $outstandingOpened+=$obj->total_ttc; + $outstandingOpened += $obj->total_ttc; } } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } else return array(); @@ -3845,11 +3845,11 @@ class Societe extends CommonObject */ public function getOutstandingOrders($mode = 'customer') { - $table='commande'; + $table = 'commande'; if ($mode == 'supplier') $table = 'commande_fournisseur'; $sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + $sql .= " WHERE fk_soc = ".$this->id; if ($mode == 'supplier') { $sql .= " AND entity IN (".getEntity('supplier_order').")"; } else { @@ -3857,21 +3857,21 @@ class Societe extends CommonObject } dol_syslog("getOutstandingOrders", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $outstandingOpened = 0; $outstandingTotal = 0; $outstandingTotalIncTax = 0; - while($obj=$this->db->fetch_object($resql)) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; + while ($obj = $this->db->fetch_object($resql)) { + $outstandingTotal += $obj->total_ht; + $outstandingTotalIncTax += $obj->total_ttc; if ($obj->fk_statut != 0) // Not a draft { - $outstandingOpened+=$obj->total_ttc; + $outstandingOpened += $obj->total_ttc; } } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } else return array(); @@ -3885,7 +3885,7 @@ class Societe extends CommonObject */ public function getOutstandingBills($mode = 'customer') { - $table='facture'; + $table = 'facture'; if ($mode == 'supplier') $table = 'facture_fourn'; /* Accurate value of remain to pay is to sum remaintopay for each invoice @@ -3895,9 +3895,9 @@ class Societe extends CommonObject $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); */ - if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, type, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; - else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, type, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + $sql .= " WHERE fk_soc = ".$this->id; if ($mode == 'supplier') { $sql .= " AND entity IN (".getEntity('facture_fourn').")"; } else { @@ -3905,7 +3905,7 @@ class Societe extends CommonObject } dol_syslog("getOutstandingBills", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $outstandingOpened = 0; @@ -3914,22 +3914,22 @@ class Societe extends CommonObject if ($mode == 'supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $tmpobject=new FactureFournisseur($this->db); + $tmpobject = new FactureFournisseur($this->db); } else { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $tmpobject=new Facture($this->db); + $tmpobject = new Facture($this->db); } - while($obj=$this->db->fetch_object($resql)) { - $tmpobject->id=$obj->rowid; + while ($obj = $this->db->fetch_object($resql)) { + $tmpobject->id = $obj->rowid; if ($obj->fk_statut != $tmpobject::STATUS_DRAFT // Not a draft - && ! ($obj->fk_statut == $tmpobject::STATUS_ABANDONED && $obj->close_code == 'replaced') // Not a replaced invoice + && !($obj->fk_statut == $tmpobject::STATUS_ABANDONED && $obj->close_code == 'replaced') // Not a replaced invoice ) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; + $outstandingTotal += $obj->total_ht; + $outstandingTotalIncTax += $obj->total_ttc; } if ($obj->paye == 0 && $obj->fk_statut != $tmpobject::STATUS_DRAFT // Not a draft @@ -3941,17 +3941,17 @@ class Societe extends CommonObject $creditnotes = $tmpobject->getSumCreditNotesUsed(); $deposits = $tmpobject->getSumDepositsUsed(); - $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; + $outstandingOpened += $obj->total_ttc - $paiement - $creditnotes - $deposits; } //if credit note is converted but not used // TODO Do this also for customer ? - if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed()) + if ($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed()) { - $outstandingOpened-=$tmpobject->getSumFromThisCreditNotesNotUsed(); + $outstandingOpened -= $tmpobject->getSumFromThisCreditNotesNotUsed(); } } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } else { @@ -3982,10 +3982,10 @@ class Societe extends CommonObject global $langs; $langs->load('companies'); - if ($status==0) return $langs->trans("NorProspectNorCustomer"); - elseif ($status==1) return $langs->trans("Customer"); - elseif ($status==2) return $langs->trans("Prospect"); - elseif ($status==3) return $langs->trans("ProspectCustomer"); + if ($status == 0) return $langs->trans("NorProspectNorCustomer"); + elseif ($status == 1) return $langs->trans("Customer"); + elseif ($status == 2) return $langs->trans("Prospect"); + elseif ($status == 3) return $langs->trans("ProspectCustomer"); } @@ -4002,24 +4002,24 @@ class Societe extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$user,$langs; + global $conf, $user, $langs; - if (! empty($moreparams) && ! empty($moreparams['use_companybankid'])) + if (!empty($moreparams) && !empty($moreparams['use_companybankid'])) { $modelpath = "core/modules/bank/doc/"; include_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $companybankaccount = new CompanyBankAccount($this->db); $result = $companybankaccount->fetch($moreparams['use_companybankid']); - if (! $result) dol_print_error($this->db, $companybankaccount->error, $companybankaccount->errors); - $result=$companybankaccount->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + if (!$result) dol_print_error($this->db, $companybankaccount->error, $companybankaccount->errors); + $result = $companybankaccount->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } else { // Positionne le modele sur le nom du modele a utiliser - if (! dol_strlen($modele)) + if (!dol_strlen($modele)) { - if (! empty($conf->global->COMPANY_ADDON_PDF)) + if (!empty($conf->global->COMPANY_ADDON_PDF)) { $modele = $conf->global->COMPANY_ADDON_PDF; } @@ -4032,7 +4032,7 @@ class Societe extends CommonObject $modelpath = "core/modules/societe/doc/"; - $result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } return $result; @@ -4052,11 +4052,11 @@ class Societe extends CommonObject */ public function setCategories($categories, $type_categ) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Decode type - if (! in_array($type_categ, array(Categorie::TYPE_CUSTOMER, Categorie::TYPE_SUPPLIER))) { - dol_syslog(__METHOD__ . ': Type ' . $type_categ . 'is an unknown company category type. Done nothing.', LOG_ERR); + if (!in_array($type_categ, array(Categorie::TYPE_CUSTOMER, Categorie::TYPE_SUPPLIER))) { + dol_syslog(__METHOD__.': Type '.$type_categ.'is an unknown company category type. Done nothing.', LOG_ERR); return -1; } diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 5636f09b3a4..20721dd28ab 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -39,19 +39,19 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; -$langs->loadLangs(array("companies","commercial","banks","bills",'paypal','stripe','withdrawals')); +$langs->loadLangs(array("companies", "commercial", "banks", "bills", 'paypal', 'stripe', 'withdrawals')); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'societe', '', ''); -$id=GETPOST("id", "int"); -$source=GETPOST("source", "alpha"); // source can be a source or a paymentmode -$ribid=GETPOST("ribid", "int"); -$action=GETPOST("action", 'alpha', 3); -$cancel=GETPOST('cancel', 'alpha'); +$id = GETPOST("id", "int"); +$source = GETPOST("source", "alpha"); // source can be a source or a paymentmode +$ribid = GETPOST("ribid", "int"); +$action = GETPOST("action", 'alpha', 3); +$cancel = GETPOST('cancel', 'alpha'); $object = new Societe($db); $object->fetch($socid); @@ -66,22 +66,22 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('thirdpartybancard','globalcard')); +$hookmanager->initHooks(array('thirdpartybancard', 'globalcard')); -if (! empty($conf->stripe->enabled)) +if (!empty($conf->stripe->enabled)) { $service = 'StripeTest'; $servicestatus = 0; - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { $service = 'StripeLive'; $servicestatus = 1; } $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no network access here) - $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get remote Stripe customer 'cus_...' (no network access here) + $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no network access here) + $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get remote Stripe customer 'cus_...' (no network access here) } @@ -92,19 +92,19 @@ if (! empty($conf->stripe->enabled)) if ($cancel) { - $action=''; + $action = ''; } -$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas); +$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)) { if ($cancel) { - $action=''; - if (! empty($backtopage)) + $action = ''; + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -114,31 +114,31 @@ if (empty($reshook)) if ($action == 'update') { // Modification - if (! GETPOST('label', 'alpha') || ! GETPOST('bank', 'alpha')) + if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) { - if (! GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - if (! GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - $action='edit'; + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); + $action = 'edit'; $error++; } if ($companybankaccount->needIBAN() == 1) { - if (! GETPOST('iban')) + if (!GETPOST('iban')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); - $action='edit'; + $action = 'edit'; $error++; } - if (! GETPOST('bic')) + if (!GETPOST('bic')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); - $action='edit'; + $action = 'edit'; $error++; } } $companybankaccount->fetch($id); - if (! $error) + if (!$error) { $companybankaccount->socid = $object->id; @@ -168,7 +168,7 @@ if (empty($reshook)) } $result = $companybankaccount->update($user); - if (! $result) + if (!$result) { setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); } @@ -177,10 +177,10 @@ if (empty($reshook)) // If this account is the default bank account, we disable others if ($companybankaccount->default_rib) { - $companybankaccount->setAsDefault($id); // This will make sure there is only one default rib + $companybankaccount->setAsDefault($id); // This will make sure there is only one default rib } - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; header('Location: '.$url); exit; } @@ -190,19 +190,19 @@ if (empty($reshook)) if ($action == 'updatecard') { // Modification - if (! GETPOST('label', 'alpha') || ! GETPOST('proprio', 'alpha') || ! GETPOST('cardnumber', 'alpha') || ! GETPOST('exp_date_month', 'alpha') || ! GETPOST('exp_date_year', 'alpha') || ! GETPOST('cvn', 'alpha')) + if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('cardnumber', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha') || !GETPOST('cvn', 'alpha')) { - if (! GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - if (! GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); - if (! GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); - if (! (GETPOST('exp_date_month', 'alpha') > 0) || ! (GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); - if (! GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); - $action='createcard'; + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); + if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); + if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); + if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); + $action = 'createcard'; $error++; } $companypaymentmode->fetch($id); - if (! $error) + if (!$error) { $companypaymentmode->fk_soc = $object->id; @@ -219,7 +219,7 @@ if (empty($reshook)) $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha'); $result = $companypaymentmode->update($user); - if (! $result) + if (!$result) { setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); } @@ -228,10 +228,10 @@ if (empty($reshook)) // If this account is the default bank account, we disable others if ($companypaymentmode->default_rib) { - $companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib + $companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib } - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; header('Location: '.$url); exit; } @@ -240,17 +240,17 @@ if (empty($reshook)) if ($action == 'add') { - $error=0; + $error = 0; - if (! GETPOST('label', 'alpha') || ! GETPOST('bank', 'alpha')) + if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) { - if (! GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - if (! GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - $action='create'; + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); + $action = 'create'; $error++; } - if (! $error) + if (!$error) { // Ajout $companybankaccount = new CompanyBankAccount($db); @@ -273,7 +273,7 @@ if (empty($reshook)) $companybankaccount->frstrecur = GETPOST('frstrecur'); $companybankaccount->rum = GETPOST('rum', 'alpha'); $companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear')); - $companybankaccount->datec = dol_now(); + $companybankaccount->datec = dol_now(); $companybankaccount->status = 1; $db->begin(); @@ -281,28 +281,28 @@ if (empty($reshook)) // This test can be done only once properties were set if ($companybankaccount->needIBAN() == 1) { - if (! GETPOST('iban')) + if (!GETPOST('iban')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } - if (! GETPOST('bic')) + if (!GETPOST('bic')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } } - if (! $error) + if (!$error) { $result = $companybankaccount->create($user); if ($result < 0) { $error++; setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); - $action='create'; // Force chargement page création + $action = 'create'; // Force chargement page création } if (empty($companybankaccount->rum)) @@ -312,22 +312,22 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { - $result = $companybankaccount->update($user); // This will set the UMR number. + $result = $companybankaccount->update($user); // This will set the UMR number. if ($result < 0) { $error++; setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); - $action='create'; + $action = 'create'; } } - if (! $error) + if (!$error) { $db->commit(); - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; header('Location: '.$url); exit; } @@ -340,20 +340,20 @@ if (empty($reshook)) if ($action == 'addcard') { - $error=0; + $error = 0; - if (! GETPOST('label', 'alpha') || ! GETPOST('proprio', 'alpha') || ! GETPOST('cardnumber', 'alpha') || ! GETPOST('exp_date_month', 'alpha') || ! GETPOST('exp_date_year', 'alpha') || ! GETPOST('cvn', 'alpha')) + if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('cardnumber', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha') || !GETPOST('cvn', 'alpha')) { - if (! GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - if (! GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); - if (! GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); - if (! (GETPOST('exp_date_month', 'alpha') > 0) || ! (GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); - if (! GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); - $action='createcard'; + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); + if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); + if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); + if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); + $action = 'createcard'; $error++; } - if (! $error) + if (!$error) { // Ajout $companypaymentmode = new CompanyPaymentMode($db); @@ -377,22 +377,22 @@ if (empty($reshook)) $db->begin(); - if (! $error) + if (!$error) { $result = $companypaymentmode->create($user); if ($result < 0) { $error++; setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); - $action='createcard'; // Force chargement page création + $action = 'createcard'; // Force chargement page création } } - if (! $error) + if (!$error) { $db->commit(); - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; header('Location: '.$url); exit; } @@ -409,7 +409,7 @@ if (empty($reshook)) $res = $companybankaccount->setAsDefault(GETPOST('ribid', 'int')); if ($res) { - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; } @@ -422,7 +422,7 @@ if (empty($reshook)) if ($action == 'confirm_deletecard' && GETPOST('confirm', 'alpha') == 'yes') { $companypaymentmode = new CompanyPaymentMode($db); - if ($companypaymentmode->fetch($ribid?$ribid:$id)) + if ($companypaymentmode->fetch($ribid ? $ribid : $id)) { /*if ($companypaymentmode->stripe_card_ref && preg_match('/pm_/', $companypaymentmode->stripe_card_ref)) { @@ -453,7 +453,7 @@ if (empty($reshook)) if ($action == 'confirm_delete' && GETPOST('confirm', 'alpha') == 'yes') { $companybankaccount = new CompanyBankAccount($db); - if ($companybankaccount->fetch($ribid?$ribid:$id)) + if ($companybankaccount->fetch($ribid ? $ribid : $id)) { $result = $companybankaccount->delete($user); if ($result > 0) @@ -473,7 +473,7 @@ if (empty($reshook)) } } - $savid=$id; + $savid = $id; // Actions to build doc if ($action == 'builddocrib') @@ -484,18 +484,18 @@ if (empty($reshook)) 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id) ); $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid', 'int'), 'alpha'); - $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid', 'int'), 'alpha'); + $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid', 'int'), 'alpha'); } $id = $socid; $upload_dir = $conf->societe->multidir_output[$object->entity]; - $permissiontoadd=$user->rights->societe->creer; + $permissiontoadd = $user->rights->societe->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; $id = $savid; // Action for stripe - if (! empty($conf->stripe->enabled) && class_exists('Stripe')) + if (!empty($conf->stripe->enabled) && class_exists('Stripe')) { if ($action == 'synccustomertostripe') { @@ -508,7 +508,7 @@ if (empty($reshook)) { // Creation of Stripe customer + update of societe_account $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1); - if (! $cu) + if (!$cu) { $error++; setEventMessages($stripe->error, $stripe->errors, 'errors'); @@ -533,17 +533,17 @@ if (empty($reshook)) { // Get the Stripe customer $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); - if (! $cu) + if (!$cu) { $error++; setEventMessages($stripe->error, $stripe->errors, 'errors'); } - if (! $error) + if (!$error) { // Creation of Stripe card + update of societe_account $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); - if (! $card) + if (!$card) { $error++; setEventMessages($stripe->error, $stripe->errors, 'errors'); @@ -565,11 +565,11 @@ if (empty($reshook)) $db->begin(); if (empty($newcu)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; } else { $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; - $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; - $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + $sql .= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; + $sql .= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! } $resql = $db->query($sql); @@ -590,7 +590,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $stripecu = $newcu; $db->commit(); @@ -610,16 +610,16 @@ if (empty($reshook)) $db->begin(); if (empty($newsup)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; } else { try { $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); $tokenstring['stripe_user_id'] = $stripesup->id; $tokenstring['type'] = $stripesup->type; $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; - $sql.= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; - $sql.= " WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! - } catch(Exception $e) { + $sql .= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; + $sql .= " WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + } catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } @@ -635,14 +635,14 @@ if (empty($reshook)) $tokenstring['type'] = $stripesup->type; $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)"; $sql .= " VALUES ('".$service."', ".$object->id.", ".$conf->entity.", '".dol_json_encode($tokenstring)."')"; - } catch(Exception $e) { + } catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } $resql = $db->query($sql); } - if (! $error) + if (!$error) { $stripesupplieracc = $newsup; $db->commit(); @@ -658,11 +658,11 @@ if (empty($reshook)) try { $companypaymentmode->setAsDefault($id); - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; } - catch(Exception $e) + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); @@ -671,22 +671,22 @@ if (empty($reshook)) elseif ($action == 'setassourcedefault') // Set as default when payment mode defined remotely only { try { - $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); + $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); if (preg_match('/pm_/', $source)) { - $cu->invoice_settings->default_payment_method = (string) $source; // New + $cu->invoice_settings->default_payment_method = (string) $source; // New } else { - $cu->default_source = (string) $source; // Old + $cu->default_source = (string) $source; // Old } $result = $cu->save(); - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; } - catch(Exception $e) + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); @@ -717,11 +717,11 @@ if (empty($reshook)) } } - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; } - catch(Exception $e) + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); @@ -742,20 +742,20 @@ $formfile = new FormFile($db); llxHeader(); -$head=societe_prepare_head($object); +$head = societe_prepare_head($object); // Show sandbox warning /*if (! empty($conf->paypal->enabled) && (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))) // We can force sand box with param 'forcesandbox' { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Paypal'),'','warning'); }*/ -if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) +if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } // Load Bank account -if (! $id) +if (!$id) { $companybankaccount->fetch(0, $object->id); $companypaymentmode->fetch(0, null, $object->id, 'card'); @@ -765,14 +765,14 @@ else $companybankaccount->fetch($id); $companypaymentmode->fetch($id); } -if (empty($companybankaccount->socid)) $companybankaccount->socid=$object->id; +if (empty($companybankaccount->socid)) $companybankaccount->socid = $object->id; if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer) { print '
    '; print ''; - $actionforadd='update'; - if ($action == 'editcard') $actionforadd='updatecard'; + $actionforadd = 'update'; + if ($action == 'editcard') $actionforadd = 'updatecard'; print ''; print ''; } @@ -780,8 +780,8 @@ if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights- { print ''; print ''; - $actionforadd='add'; - if ($action == 'createcard') $actionforadd='addcard'; + $actionforadd = 'add'; + if ($action == 'createcard') $actionforadd = 'addcard'; print ''; } @@ -794,20 +794,20 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // Confirm delete ban if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid ? $ribid : $id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1); } // Confirm delete card if ($action == 'deletecard') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteACard"), $langs->trans("ConfirmDeleteCard", $companybankaccount->getRibLabel()), "confirm_deletecard", '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid ? $ribid : $id), $langs->trans("DeleteACard"), $langs->trans("ConfirmDeleteCard", $companybankaccount->getRibLabel()), "confirm_deletecard", '', 0, 1); } $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print '
    '.$langs->trans('Prefix').''.$object->prefix_comm.'
    '; print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); - if (! empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') + if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') { - $connect=''; - if (!empty($stripeacc)) $connect=$stripeacc.'/'; - $url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; + $connect = ''; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; + $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; if ($servicestatus) { - $url='https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; + $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; } print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; } @@ -879,35 +879,35 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
    '; print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); - if (! empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') + if (!empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') { - $connect=''; + $connect = ''; - $url='https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc; + $url = 'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc; if ($servicestatus) { - $url='https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc; + $url = 'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc; } print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; } @@ -933,31 +933,31 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print '
    '; // List of Stripe payment modes - if (! (empty($conf->stripe->enabled)) && $object->client) + if (!(empty($conf->stripe->enabled)) && $object->client) { - $morehtmlright=''; - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) + $morehtmlright = ''; + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { - $morehtmlright.= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard'); + $morehtmlright .= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard'); } - print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc?' (Stripe connection with StripeConnect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); + print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); $listofsources = array(); if (is_object($stripe)) { try { - $customerstripe=$stripe->customerStripe($object, $stripeacc, $servicestatus); + $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus); if ($customerstripe->id) { // When using the Charge API architecture if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - $listofsources=$customerstripe->sources->data; + $listofsources = $customerstripe->sources->data; } else { $service = 'StripeTest'; $servicestatus = 0; - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { $service = 'StripeLive'; $servicestatus = 1; @@ -976,7 +976,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $listofsources = $paymentmethodobjs->data; } - catch(Exception $e) + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); @@ -1006,8 +1006,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print '
    '.$langs->trans('Note').''.$langs->trans('DateModification').'
    '; @@ -1054,12 +1054,12 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $companypaymentmodetemp->stripe_card_ref; if ($companypaymentmodetemp->stripe_card_ref) { - $connect=''; - if (!empty($stripeacc)) $connect=$stripeacc.'/'; - $url='https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref; + $connect = ''; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; + $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref; if ($servicestatus) { - $url='https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref; + $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref; } print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; } @@ -1073,8 +1073,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; if ($companypaymentmodetemp->country_code) { - $img=picto_from_langcode($companypaymentmodetemp->country_code); - print $img?$img.' ':''; + $img = picto_from_langcode($companypaymentmodetemp->country_code); + print $img ? $img.' ' : ''; print getCountry($companypaymentmodetemp->country_code, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -1083,7 +1083,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; if (empty($companypaymentmodetemp->default_rib)) { - print ''; + print ''; print img_picto($langs->trans("Default"), 'off'); print ''; } else { @@ -1098,8 +1098,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print dol_print_date($companypaymentmodetemp->tms, 'dayhour'); print ''; @@ -1110,11 +1110,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''.$langs->trans("CreateCardOnStripe").''; } - print ''; + print ''; print img_picto($langs->trans("Modify"), 'edit'); print ''; print ' '; - print ''; // source='.$companypaymentmodetemp->stripe_card_ref.'& + print ''; // source='.$companypaymentmodetemp->stripe_card_ref.'& print img_picto($langs->trans("Delete"), 'delete'); print ''; } @@ -1133,113 +1133,113 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($listofsources as $src) { - if (! empty($arrayofstripecard[$src->id])) continue; // Already in previous list + if (!empty($arrayofstripecard[$src->id])) continue; // Already in previous list $nbremote++; print '
    '; print ''; - $connect=''; + $connect = ''; print $src->id; - if (!empty($stripeacc)) $connect=$stripeacc.'/'; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; //$url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id; - $url='https://dashboard.stripe.com/'.$connect.'test/search?query='.$src->id; + $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$src->id; if ($servicestatus) { //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; - $url='https://dashboard.stripe.com/'.$connect.'search?query='.$src->id; + $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$src->id; } print " ".img_picto($langs->trans('ShowInStripe'), 'globe').""; print ''; - if ($src->object=='card') + if ($src->object == 'card') { print img_credit_card($src->brand); } - elseif ($src->object=='source' && $src->type=='card') + elseif ($src->object == 'source' && $src->type == 'card') { print img_credit_card($src->card->brand); } - elseif ($src->object=='source' && $src->type=='sepa_debit') + elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print ''; } - elseif ($src->object=='payment_method' && $src->type=='card') + elseif ($src->object == 'payment_method' && $src->type == 'card') { print img_credit_card($src->card->brand); } - elseif ($src->object=='payment_method' && $src->type=='sepa_debit') + elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { print ''; } print''; - if ($src->object=='card') + if ($src->object == 'card') { print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; print ''; if ($src->country) { - $img=picto_from_langcode($src->country); - print $img?$img.' ':''; + $img = picto_from_langcode($src->country); + print $img ? $img.' ' : ''; print getCountry($src->country, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - elseif ($src->object=='source' && $src->type=='card') + elseif ($src->object == 'source' && $src->type == 'card') { print $src->owner->name.'
    ....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; print '
    '; if ($src->card->country) { - $img=picto_from_langcode($src->card->country); - print $img?$img.' ':''; + $img = picto_from_langcode($src->card->country); + print $img ? $img.' ' : ''; print getCountry($src->card->country, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - elseif ($src->object=='source' && $src->type=='sepa_debit') + elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print 'info sepa'; print ''; if ($src->sepa_debit->country) { - $img=picto_from_langcode($src->sepa_debit->country); - print $img?$img.' ':''; + $img = picto_from_langcode($src->sepa_debit->country); + print $img ? $img.' ' : ''; print getCountry($src->sepa_debit->country, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - elseif ($src->object=='payment_method' && $src->type=='card') + elseif ($src->object == 'payment_method' && $src->type == 'card') { print $src->billing_details->name.'
    ....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; print '
    '; if ($src->card->country) { - $img=picto_from_langcode($src->card->country); - print $img?$img.' ':''; + $img = picto_from_langcode($src->card->country); + print $img ? $img.' ' : ''; print getCountry($src->card->country, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - elseif ($src->object=='payment_method' && $src->type=='sepa_debit') + elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { print 'info sepa'; print ''; if ($src->sepa_debit->country) { - $img=picto_from_langcode($src->sepa_debit->country); - print $img?$img.' ':''; + $img = picto_from_langcode($src->sepa_debit->country); + print $img ? $img.' ' : ''; print getCountry($src->sepa_debit->country, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -1251,9 +1251,9 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // Default print ''; if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) || - (! empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) + (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) { - print ''; + print ''; print img_picto($langs->trans("Default"), 'off'); print ''; } else { @@ -1269,14 +1269,14 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; print ''; if ($user->rights->societe->creer) { - print ''; + print ''; print img_picto($langs->trans("Delete"), 'delete'); print ''; } @@ -1288,8 +1288,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if ($nbremote == 0 && $nblocal == 0) { - $colspan=8; - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) $colspan++; + $colspan = 8; + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) $colspan++; print '
    '.$langs->trans("None").'
    "; @@ -1298,9 +1298,9 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // List of Stripe payment modes - if (! empty($conf->stripe->enabled) && ! empty($conf->stripeconnect->enabled) && $object->fournisseur && ! empty($stripesupplieracc)) + if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $object->fournisseur && !empty($stripesupplieracc)) { - print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc?' (Stripe connection with StripeConnect account '.$stripesupplieracc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); + print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); print ''."\n"; print ''; @@ -1315,13 +1315,13 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($balance->available as $cpt) { - $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) { - $currencybalance[$cpt->currency]->available=$cpt->amount / 100; + $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (!in_array($cpt->currency, $arrayzerounitcurrency)) { + $currencybalance[$cpt->currency]->available = $cpt->amount / 100; } else { - $currencybalance[$cpt->currency]->available=$cpt->amount; + $currencybalance[$cpt->currency]->available = $cpt->amount; } - $currencybalance[$cpt->currency]->currency=$cpt->currency; + $currencybalance[$cpt->currency]->currency = $cpt->currency; } } @@ -1329,11 +1329,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($balance->pending as $cpt) { - $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) { - $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount / 100; + $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (!in_array($cpt->currency, $arrayzerounitcurrency)) { + $currencybalance[$cpt->currency]->pending = $currencybalance[$cpt->currency]->available + $cpt->amount / 100; } else { - $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount; + $currencybalance[$cpt->currency]->pending = $currencybalance[$cpt->currency]->available + $cpt->amount; } } } @@ -1342,7 +1342,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($currencybalance as $cpt) { - print ''; + print ''; } } @@ -1368,7 +1368,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print_liste_field_titre("RIB"); print_liste_field_titre("IBAN"); print_liste_field_titre("BIC"); - if (! empty($conf->prelevement->enabled)) + if (!empty($conf->prelevement->enabled)) { print_liste_field_titre("RUM"); print_liste_field_titre("DateRUM"); @@ -1388,7 +1388,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; // Account number print ''; // IBAN print ''; // BIC print ''; - if (! empty($conf->prelevement->enabled)) + if (!empty($conf->prelevement->enabled)) { // RUM //print ''; @@ -1460,54 +1460,54 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; @@ -1533,8 +1533,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if (count($rib_list) == 0) { - $colspan=9; - if (! empty($conf->prelevement->enabled)) $colspan+=2; + $colspan = 9; + if (!empty($conf->prelevement->enabled)) $colspan += 2; print ''; } @@ -1555,15 +1555,15 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' /* * Documents generes */ - $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; - $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; - $genallowed=$user->rights->societe->lire; - $delallowed=$user->rights->societe->creer; + $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; + $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; + $genallowed = $user->rights->societe->lire; + $delallowed = $user->rights->societe->creer; print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); // Show direct download link - if (! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) + if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { $companybankaccounttemp = new CompanyBankAccount($db); $companypaymentmodetemp = new CompanyPaymentMode($db); @@ -1615,7 +1615,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
    '; @@ -1630,7 +1630,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) // Show fields of bank account foreach ($companybankaccount->getFieldsToShow(1) as $val) { - $require=false; + $require = false; if ($val == 'BankCode') { $name = 'code_banque'; $size = 8; @@ -1651,15 +1651,15 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) $name = 'iban'; $size = 30; $content = $companybankaccount->iban; - if ($companybankaccount->needIBAN()) $require=true; + if ($companybankaccount->needIBAN()) $require = true; } elseif ($val == 'BIC') { $name = 'bic'; $size = 12; $content = $companybankaccount->bic; - if ($companybankaccount->needIBAN()) $require=true; + if ($companybankaccount->needIBAN()) $require = true; } - print '
    '.$langs->trans($val).''; + print ''.$langs->trans($val).''; print ''; print ''; } @@ -1693,11 +1693,11 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) print ''; print ''; - print ''; + print ''; print ''; print '
    '.$langs->trans("Currency".strtoupper($cpt->currency)).''.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'
    '.$langs->trans("Currency".strtoupper($cpt->currency)).''.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->available + $cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'
    '.$rib->bank.''; - $string=''; + $string = ''; foreach ($rib->getFieldsToShow() as $val) { if ($val == 'BankCode') { $string .= $rib->code_banque.' '; @@ -1406,11 +1406,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // $string .= $rib->iban.' ';*/ //} } - if (! empty($rib->label) && $rib->number) { - if (! checkBanForAccount($rib)) { - $string.= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning'); + if (!empty($rib->label) && $rib->number) { + if (!checkBanForAccount($rib)) { + $string .= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning'); } else { - $string.= ' '.img_picto($langs->trans("ValueIsValid"), 'info'); + $string .= ' '.img_picto($langs->trans("ValueIsValid"), 'info'); } } @@ -1418,22 +1418,22 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''.$rib->iban; - if (! empty($rib->iban)) { - if (! checkIbanForAccount($rib)) { + if (!empty($rib->iban)) { + if (!checkIbanForAccount($rib)) { print ' '.img_picto($langs->trans("IbanNotValid"), 'warning'); } } print ''.$rib->bic; - if (! empty($rib->bic)) { - if (! checkSwiftForAccount($rib)) { + if (!empty($rib->bic)) { + if (!checkSwiftForAccount($rib)) { print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning'); } } print ''.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).''; $buttonlabel = $langs->trans("BuildDoc"); - $forname='builddocrib'.$rib->id; + $forname = 'builddocrib'.$rib->id; include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; - $modellist=ModeleBankAccountDoc::liste_modeles($db); + $modellist = ModeleBankAccountDoc::liste_modeles($db); $out = ''; if (is_array($modellist) && count($modellist)) { - $out.= ''; - $out.= ''; - $out.= ''; - $out.= ''; - $out.= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; if (is_array($modellist) && count($modellist) == 1) // If there is only one element { - $arraykeys=array_keys($modellist); - $modelselected=$arraykeys[0]; + $arraykeys = array_keys($modellist); + $modelselected = $arraykeys[0]; } - if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; + if (!empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; - $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); - $out.= ajax_combobox('modelrib'.$rib->id); + $out .= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + $out .= ajax_combobox('modelrib'.$rib->id); // Language code (if multilang) if ($conf->global->MAIN_MULTILANGS) { include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin=new FormAdmin($db); - $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); - $morecss='maxwidth150'; - if ($conf->browser->layout == 'phone') $morecss='maxwidth100'; - $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); + $formadmin = new FormAdmin($db); + $defaultlang = $codelang ? $codelang : $langs->getDefaultLang(); + $morecss = 'maxwidth150'; + if ($conf->browser->layout == 'phone') $morecss = 'maxwidth100'; + $out .= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); } // Button $genbutton = 'dol_no_mouse_hover) && $modulepart != 'unpaid') + $genbutton .= ' type="submit" value="'.$buttonlabel.'"'; + if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) $genbutton .= ' disabled'; + $genbutton .= '>'; + if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') { $langs->load("errors"); - $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); + $genbutton .= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); } - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; - if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; - $out.= $genbutton; - $out.= ''; + if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton = ''; + if (empty($modellist) && !$showempty && $modulepart != 'unpaid') $genbutton = ''; + $out .= $genbutton; + $out .= ''; } print $out; print '
    '.$langs->trans("NoBANRecord").'
    '.$langs->trans("DateRUM").''.$form->selectDate(GETPOST('date_rum')?GETPOST('date_rum'):$companybankaccount->date_rum, 'date_rum', 0, 0, 1, 'date_rum').'
    '.$form->selectDate(GETPOST('date_rum') ?GETPOST('date_rum') : $companybankaccount->date_rum, 'date_rum', 0, 0, 1, 'date_rum').'
    '.$langs->trans("WithdrawMode").''; $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); - print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha')?GETPOST('frstrecur', 'alpha'):$companybankaccount->frstrecur), 0); + print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha') ?GETPOST('frstrecur', 'alpha') : $companybankaccount->frstrecur), 0); print '
    '; @@ -1721,7 +1721,7 @@ if ($socid && $action == 'editcard' && $user->rights->societe->creer) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
    '; @@ -1769,7 +1769,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
    '; @@ -1784,7 +1784,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) // Show fields of bank account foreach ($companybankaccount->getFieldsToShow(1) as $val) { - $require=false; + $require = false; if ($val == 'BankCode') { $name = 'code_banque'; $size = 8; @@ -1800,14 +1800,14 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) } elseif ($val == 'IBAN') { $name = 'iban'; $size = 30; - if ($companybankaccount->needIBAN()) $require=true; + if ($companybankaccount->needIBAN()) $require = true; } elseif ($val == 'BIC') { $name = 'bic'; $size = 12; - if ($companybankaccount->needIBAN()) $require=true; + if ($companybankaccount->needIBAN()) $require = true; } - print '
    '.$langs->trans("WithdrawMode").''; $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); - print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0); + print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur']) ?GETPOST('frstrecur') : 'FRST'), 0); print '
    '; @@ -1869,7 +1869,7 @@ if ($socid && $action == 'createcard' && $user->rights->societe->creer) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
    '; From d10be4f1699ba8f3aa8978ed5c53160e5aacd9da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Nov 2019 18:40:24 +0100 Subject: [PATCH 225/299] FIX #12409 FIX #12408 --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index fa7efdfa2a5..54736ebc40f 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -390,7 +390,7 @@ if ($action == 'confirm_generateinvoice') // Define qty per hour $qtyhour = round($value['timespent'] / 3600, 2); - $qtyhourtext = convertSecondToTime($value['timespent']); + $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); // If no unit price known if (empty($pu_ht)) From cc70ffd1b36dc8b25398d7bfd9361570d1cb4ac8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Nov 2019 18:47:35 +0100 Subject: [PATCH 226/299] Update list.php --- htdocs/societe/list.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index a62dde1d79d..da5d4c268fd 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -232,9 +232,7 @@ if ($action == "change") // Change customer for TakePOS $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant // Check if draft invoice already exists, if not create it - $sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'facture - where ref=\'(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')\' - AND entity IN ('.getEntity('invoice').')'; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' AND entity IN (".getEntity('invoice').")"; $result = $db->query($sql); $num_lines = $db->num_rows($result); if ($num_lines==0) From a14042e4b21b04566dedde76830d26f2c1ac6d9f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Nov 2019 18:48:39 +0100 Subject: [PATCH 227/299] Update list.php --- htdocs/societe/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index da5d4c268fd..504ccb37a25 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -239,7 +239,8 @@ if ($action == "change") // Change customer for TakePOS { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $invoice = new Facture($db); - $invoice->socid = $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}; + $constforthirdpartyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; + $invoice->socid = $conf->global->$constforthirdpartyid; $invoice->date = dol_now(); $invoice->module_source = 'takepos'; $invoice->pos_source = $_SESSION["takeposterminal"]; From 366dfc0e5cfc01b2747cb5180b7c27e2584e24ee Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 13 Nov 2019 18:15:19 +0000 Subject: [PATCH 228/299] Fixing style errors. --- htdocs/societe/paymentmodes.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 25d38692ee0..fc9068b8127 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1318,10 +1318,10 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); if (! in_array($cpt->currency, $arrayzerounitcurrency)) { $currencybalance[$cpt->currency]['available'] = $cpt->amount / 100; - } else { - $currencybalance[$cpt->currency]['available'] = $cpt->amount; - } - $currencybalance[$cpt->currency]['currency'] = $cpt->currency; + } else { + $currencybalance[$cpt->currency]['available'] = $cpt->amount; + } + $currencybalance[$cpt->currency]['currency'] = $cpt->currency; } } @@ -1329,8 +1329,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($balance->pending as $cpt) { - $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) { + $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (! in_array($cpt->currency, $arrayzerounitcurrency)) { $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available']+$cpt->amount / 100; } else { $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available']+$cpt->amount; @@ -1342,7 +1342,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($currencybalance as $cpt) { - print '
    '.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available']+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'
    '.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available']+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'
    ' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
    '; if ($row[0] == 'tobind') { @@ -355,11 +355,11 @@ if ($resql) { else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
    ' . $row[0] . '' . price($row[$i]) . '
    '.$row[0].''.price($row[$i]).'' . price($row[13]) . ''.price($row[13]).'
    ' . $row[0] . '' . price(price2num($row[$i])) . '
    '.$row[0].''.price(price2num($row[$i])).'' . price(price2num($row[13])) . ''.price(price2num($row[13])).'
    '; print ''; -print ''; +print ''; print "\n"; $num = count($main_option); @@ -207,11 +207,11 @@ if ($num) { // Param $label = $langs->trans($key); - print ''; + print ''; // Value print ''; } } @@ -226,13 +226,13 @@ print "
    \n"; print '
    ' . $langs->trans('Options') . ''.$langs->trans('Options').'
    ' . $label . ''.$label.''; - print ''; + print ''; print '
    '; print ''; -print ''; +print ''; print ''; print ''; -print ''; -if (! $conf->use_javascript_ajax) { +print ''; +if (!$conf->use_javascript_ajax) { print '"; @@ -256,7 +256,7 @@ $num2 = count($model_option); if ($num2) { print '
    ' . $langs->trans("Modelcsv") . ''.$langs->trans("Modelcsv").'
    ' . $langs->trans("Selectmodelcsv") . ''.$langs->trans("Selectmodelcsv").''; print $langs->trans("NotAvailableWhenAjaxDisabled"); print "
    '; print ''; - print ''; + print ''; print "\n"; foreach ($model_option as $key) { @@ -264,14 +264,14 @@ if ($num2) { // Param $label = $key['label']; - print ''; + print ''; // Value print ''; @@ -280,7 +280,7 @@ if ($num2) { print "
    ' . $langs->trans('OtherOptions') . ''.$langs->trans('OtherOptions').'
    ' . $langs->trans($label) . ''.$langs->trans($label).''; if (is_array($key['param'])) { print $form->selectarray($label, $key['param'], $conf->global->$label, 0); } else { - print ''; + print ''; } print '
    \n"; } -print '
    '; +print '
    '; print ''; diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 6d321e60756..7dd4ae1a935 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -22,13 +22,13 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; $action = GETPOST('action', 'aZ09'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -36,32 +36,32 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="f.rowid"; // Set here default search field -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "f.rowid"; // Set here default search field +if (!$sortorder) $sortorder = "ASC"; // Load translation files required by the page -$langs->loadLangs(array("admin","compta")); +$langs->loadLangs(array("admin", "compta")); // Security check if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->fiscalyear->write) // If we can read accounting records, we should be able to see fiscal year. +if (!$user->rights->accounting->fiscalyear->write) // If we can read accounting records, we should be able to see fiscal year. accessforbidden(); $error = 0; // List of status -static $tmpstatut2label = array ( +static $tmpstatut2label = array( '0' => 'OpenFiscalYear', '1' => 'CloseFiscalYear' ); -$statut2label = array ( +$statut2label = array( '' ); foreach ($tmpstatut2label as $key => $val) $statut2label[$key] = $langs->trans($val); -$errors = array (); +$errors = array(); $object = new Fiscalyear($db); @@ -85,9 +85,9 @@ $helpurl = ""; llxHeader('', $title, $helpurl); $sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f"; -$sql .= " WHERE f.entity = " . $conf->entity; -$sql.=$db->order($sortfield, $sortorder); +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f"; +$sql .= " WHERE f.entity = ".$conf->entity; +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -102,7 +102,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -112,7 +112,7 @@ if ($result) $i = 0; - $addbutton.= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write); + $addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write); $title = $langs->trans('AccountingPeriods'); @@ -122,34 +122,34 @@ if ($result) print '
    '; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; if ($num) { $fiscalyearstatic = new Fiscalyear($db); - while ( $i < $num && $i < $max ) { + while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); $fiscalyearstatic->id = $obj->rowid; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; $i++; } } else { - print ''; + print ''; } print '
    ' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("DateStart") . '' . $langs->trans("DateEnd") . '' . $langs->trans("NumberOfAccountancyEntries") . '' . $langs->trans("NumberOfAccountancyMovements") . '' . $langs->trans("Statut") . ''.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("DateStart").''.$langs->trans("DateEnd").''.$langs->trans("NumberOfAccountancyEntries").''.$langs->trans("NumberOfAccountancyMovements").''.$langs->trans("Statut").'
    ' . img_object($langs->trans("ShowFiscalYear"), "technic") . ' ' . $obj->rowid . '' . $obj->label . '' . dol_print_date($db->jdate($obj->date_start), 'day') . '' . dol_print_date($db->jdate($obj->date_end), 'day') . '' . $object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end) . '' . $object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end) . '' . $fiscalyearstatic->LibStatut($obj->statut, 5) . ''.img_object($langs->trans("ShowFiscalYear"), "technic").' '.$obj->rowid.''.$obj->label.''.dol_print_date($db->jdate($obj->date_start), 'day').''.dol_print_date($db->jdate($obj->date_end), 'day').''.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).''.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).''.$fiscalyearstatic->LibStatut($obj->statut, 5).'
    ' . $langs->trans("None") . '
    '.$langs->trans("None").'
    '; print '
    '; diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 31000b8ec8a..3656a8f16a2 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -24,11 +24,11 @@ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","compta")); +$langs->loadLangs(array("admin", "compta")); // Security check if ($user->socid > 0) @@ -43,11 +43,11 @@ $confirm = GETPOST('confirm', 'alpha'); $id = GETPOST('id', 'int'); // List of statut -static $tmpstatut2label = array ( +static $tmpstatut2label = array( '0' => 'OpenFiscalYear', '1' => 'CloseFiscalYear' ); -$statut2label = array ( +$statut2label = array( '' ); foreach ($tmpstatut2label as $key => $val) @@ -74,7 +74,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { } elseif ($action == 'add') { - if (! GETPOST('cancel', 'alpha')) { + if (!GETPOST('cancel', 'alpha')) { $error = 0; $object->date_start = $date_start; @@ -85,14 +85,14 @@ elseif ($action == 'add') { if (empty($object->date_start) && empty($object->date_end)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); - $error ++; + $error++; } if (empty($object->label)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $error ++; + $error++; } - if (! $error) { + if (!$error) { $db->begin(); $id = $object->create($user); @@ -100,7 +100,7 @@ elseif ($action == 'add') { if ($id > 0) { $db->commit(); - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit(); } else { $db->rollback(); @@ -119,7 +119,7 @@ elseif ($action == 'add') { // Update record elseif ($action == 'update') { - if (! GETPOST('cancel', 'alpha')) { + if (!GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); $object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start; @@ -130,13 +130,13 @@ elseif ($action == 'update') { $result = $object->update($user); if ($result > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit(); } else { setEventMessages($object->error, $object->errors, 'errors'); } } else { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit(); } } @@ -149,7 +149,7 @@ elseif ($action == 'update') { $form = new Form($db); -$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card"); +$title = $langs->trans("Fiscalyear")." - ".$langs->trans("Card"); $helpurl = ""; llxHeader("", $title, $helpurl); @@ -157,8 +157,8 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("NewFiscalYear")); - print '
    '; - print ''; + print ''; + print ''; print ''; dol_fiche_head(); @@ -166,15 +166,15 @@ if ($action == 'create') print ''; // Label - print ''; + print ''; // Date start - print ''; // Date end - print ''; @@ -192,9 +192,9 @@ if ($action == 'create') dol_fiche_end(); print '
    '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
    '; print ''; @@ -206,36 +206,36 @@ if ($action == 'create') if ($action == 'edit') { dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); - print '' . "\n"; - print ''; + print ''."\n"; + print ''; print ''; - print ''; + print ''; print '
    ' . $langs->trans("Label") . '
    '.$langs->trans("Label").'
    ' . $langs->trans("DateStart") . ''; + print '
    '.$langs->trans("DateStart").''; print $form->selectDate(($date_start ? $date_start : ''), 'fiscalyear'); print '
    ' . $langs->trans("DateEnd") . ''; + print '
    '.$langs->trans("DateEnd").''; print $form->selectDate(($date_end ? $date_end : - 1), 'fiscalyearend'); print '
    '; // Ref print ""; - print ''; // Label - print ''; // Date start - print ''; // Date end - print ''; // Statut - print ''; @@ -243,9 +243,9 @@ if ($action == 'create') print '
    ' . $langs->trans("Ref") . ''; + print ''.$langs->trans("Ref").''; print $object->ref; print '
    ' . $langs->trans("Label") . ''; - print ''; + print '
    '.$langs->trans("Label").''; + print ''; print '
    ' . $langs->trans("DateStart") . ''; + print '
    '.$langs->trans("DateStart").''; print $form->selectDate($object->date_start ? $object->date_start : - 1, 'fiscalyear'); print '
    ' . $langs->trans("DateEnd") . ''; + print '
    '.$langs->trans("DateEnd").''; print $form->selectDate($object->date_end ? $object->date_end : - 1, 'fiscalyearend'); print '
    ' . $langs->trans("Statut") . ''; + print '
    '.$langs->trans("Statut").''; // print $form->selectarray('statut', $statut2label, $object->statut); print $object->getLibStatut(4); print '
    '; print '
    '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
    '; print ''; @@ -256,17 +256,17 @@ if ($action == 'create') * Confirm delete */ if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete"); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete"); } dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); print ''; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; // Ref - print ''; // Statut - print ''; + print ''; print "
    ' . $langs->trans("Ref") . ''; + print '
    '.$langs->trans("Ref").''; print $object->ref; print ''; print $linkback; @@ -294,20 +294,20 @@ if ($action == 'create') print '
    ' . $langs->trans("Status") . '' . $object->getLibStatut(4) . '
    '.$langs->trans("Status").''.$object->getLibStatut(4).'
    "; dol_fiche_end(); - if (! empty($user->rights->accounting->fiscalyear->write)) + if (!empty($user->rights->accounting->fiscalyear->write)) { /* * Barre d'actions */ print '
    '; - print '' . $langs->trans('Modify') . ''; + print ''.$langs->trans('Modify').''; // print '' . $langs->trans('Delete') . ''; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index dcc2e608f0b..d4630c4505f 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -29,11 +29,11 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","admin","accountancy")); +$langs->loadLangs(array("compta", "bills", "admin", "accountancy")); // Security access if (empty($user->rights->accounting->chartofaccount)) @@ -44,9 +44,9 @@ if (empty($user->rights->accounting->chartofaccount)) $action = GETPOST('action', 'aZ09'); // Parameters ACCOUNTING_* and others -$list = array ( +$list = array( 'ACCOUNTING_LENGTH_GACCOUNT', - 'ACCOUNTING_LENGTH_AACCOUNT' , + 'ACCOUNTING_LENGTH_AACCOUNT', // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc ); @@ -62,13 +62,13 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : if ($action == 'update') { $error = 0; - if (! $error) + if (!$error) { foreach ($list as $constname) { $constvalue = GETPOST($constname, 'alpha'); - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { $error++; } } @@ -77,7 +77,7 @@ if ($action == 'update') { } } - if (! $error) { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } } @@ -85,10 +85,10 @@ if ($action == 'update') { if ($action == 'setlistsorttodo') { $setlistsorttodo = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); - if (! $res > 0) - $error ++; + if (!$res > 0) + $error++; - if (! $error) { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'mesgs'); @@ -98,9 +98,9 @@ if ($action == 'setlistsorttodo') { if ($action == 'setlistsortdone') { $setlistsortdone = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); - if (! $res > 0) - $error ++; - if (! $error) { + if (!$res > 0) + $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'mesgs'); @@ -110,9 +110,9 @@ if ($action == 'setlistsortdone') { if ($action == 'setmanagezero') { $setmanagezero = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity); - if (! $res > 0) - $error ++; - if (! $error) { + if (!$res > 0) + $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'mesgs'); @@ -122,9 +122,9 @@ if ($action == 'setmanagezero') { if ($action == 'setdisabledirectinput') { $setdisabledirectinput = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity); - if (! $res > 0) - $error ++; - if (! $error) { + if (!$res > 0) + $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'mesgs'); @@ -134,9 +134,9 @@ if ($action == 'setdisabledirectinput') { if ($action == 'setenabledraftexport') { $setenabledraftexport = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity); - if (! $res > 0) - $error ++; - if (! $error) { + if (!$res > 0) + $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'mesgs'); @@ -146,9 +146,9 @@ if ($action == 'setenabledraftexport') { if ($action == 'setenablesubsidiarylist') { $setenablesubsidiarylist = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); - if (! $res > 0) - $error ++; - if (! $error) { + if (!$res > 0) + $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'mesgs'); @@ -159,15 +159,15 @@ if ($action == 'setenablesubsidiarylist') { * View */ -$title= $langs->trans('ConfigAccountingExpert'); +$title = $langs->trans('ConfigAccountingExpert'); llxHeader('', $title); -$linkback=''; +$linkback = ''; //$linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy'); -print '
    '; -print ''; +print ''; +print ''; print ''; // Default mode for calculating turnover (parameter ACCOUNTING_MODE) @@ -204,85 +204,85 @@ print '
    '; print ''; print ''; -print ''; +print ''; print "\n"; -if (! empty($user->admin)) +if (!empty($user->admin)) { // TO DO Mutualize code for yes/no constants print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { - print ''; + if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { - print ''; + if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { - print ''; + if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - print ''; + if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print ''; + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { - print ''; + if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { + print ''; } else { - print ''; } @@ -295,14 +295,14 @@ foreach ($list as $key) { print ''; - if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; + if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; // Param $label = $langs->trans($key); print ''; // Value print ''; print ''; @@ -311,7 +311,7 @@ foreach ($list as $key) print '
    ' . $langs->trans('OtherOptions') . ''.$langs->trans('OtherOptions').'
    ' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . ''; + print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    ' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . ''; + print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    ' . $langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL") . ''; + print ''.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    ' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . ''; + print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    ' . $langs->trans("ACCOUNTANCY_COMBO_FOR_AUX") . ''; + print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    ' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . ''; + print ''.$langs->trans("ACCOUNTING_MANAGE_ZERO").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    '.$label.''; - print ''; + print ''; print '
    '; -print '
    '; +print '
    '; print '
    '; print '
    '; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 6fedd7706d0..13abe51ccaf 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -26,22 +26,22 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","compta","accountancy","products")); +$langs->loadLangs(array("companies", "compta", "accountancy", "products")); // Security check if (empty($conf->accounting->enabled)) { accessforbidden(); } -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); // search & action GETPOST @@ -77,23 +77,23 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "ASC"; -if (empty($action)) $action='list'; +if (empty($action)) $action = 'list'; -$arrayfields=array(); +$arrayfields = array(); /* * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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'); // Purge search criteria @@ -110,10 +110,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' // Sales or Purchase mode ? if ($action == 'update') { - if (! empty($btn_changetype)) { + if (!empty($btn_changetype)) { $error = 0; - $accounting_product_modes = array ( + $accounting_product_modes = array( 'ACCOUNTANCY_SELL', 'ACCOUNTANCY_SELL_INTRA', 'ACCOUNTANCY_SELL_EXPORT', @@ -121,17 +121,17 @@ if ($action == 'update') { ); if (in_array($accounting_product_mode, $accounting_product_modes)) { - if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) { + $error++; } } else { - $error ++; + $error++; } } - if (! empty($btn_changeaccount)) { + if (!empty($btn_changeaccount)) { //$msg = '
    ' . $langs->trans("Processing") . '...
    '; - if (! empty($chk_prod)) { + if (!empty($chk_prod)) { $accounting = new AccountingAccount($db); //$msg .= '
    ' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '
    '; @@ -140,37 +140,37 @@ if ($action == 'update') { $cpt = 0; $ok = 0; $ko = 0; foreach ($chk_prod as $productid) { - $accounting_account_id = GETPOST('codeventil_' . $productid); + $accounting_account_id = GETPOST('codeventil_'.$productid); $result = 0; if ($accounting_account_id > 0) { - $arrayofdifferentselectedvalues[$accounting_account_id]=$accounting_account_id; + $arrayofdifferentselectedvalues[$accounting_account_id] = $accounting_account_id; $result = $accounting->fetch($accounting_account_id, null, 1); } if ($result <= 0) { // setEventMessages(null, $accounting->errors, 'errors'); - $msg .= '
    ' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '
    ' . $sql . '
    '; + $msg .= '
    '.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
    '.$sql.'
    '; $ko++; } else { $db->begin(); - $sql = " UPDATE " . MAIN_DB_PREFIX . "product"; + $sql = " UPDATE ".MAIN_DB_PREFIX."product"; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $sql .= " SET accountancy_code_buy = " . $accounting->account_number; + $sql .= " SET accountancy_code_buy = ".$accounting->account_number; } if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $sql .= " SET accountancy_code_sell = " . $accounting->account_number; + $sql .= " SET accountancy_code_sell = ".$accounting->account_number; } if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $sql .= " SET accountancy_code_sell_intra = " . $accounting->account_number; + $sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number; } if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $sql .= " SET accountancy_code_sell_export = " . $accounting->account_number; + $sql .= " SET accountancy_code_sell_export = ".$accounting->account_number; } - $sql .= " WHERE rowid = " . $productid; + $sql .= " WHERE rowid = ".$productid; - dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG); + dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); if ($db->query($sql)) { $ok++; @@ -305,24 +305,24 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); -dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG); +dol_syslog("/accountancy/admin/productaccount.php:: sql=".$sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $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_ref > 0) $param.="&search_desc=".urlencode($search_ref); - if ($search_label > 0) $param.="&search_desc=".urlencode($search_label); - if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc); - if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account); - if ($search_current_account_valid && $search_current_account_valid != '-1') $param.="&search_current_account_valid=".urlencode($search_current_account_valid); - if ($accounting_product_mode) $param.='&accounting_product_mode='.urlencode($accounting_product_mode); + $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_ref > 0) $param .= "&search_desc=".urlencode($search_ref); + if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label); + if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc); + if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account); + if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid); + if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode); - print ''; + print ''; if ($optioncss != '') print ''; print ''; print ''; @@ -497,13 +497,13 @@ if ($result) print ''.$obj->label.''; - if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) + if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) { // TODO ADJUST DESCRIPTION SIZE // print '' . $obj->description . ''; // TODO: we shoul set a user defined value to adjust user square / wide screen size $trunclengh = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; - print '' . nl2br(dol_trunc($obj->description, $trunclengh)) . ''; + print ''.nl2br(dol_trunc($obj->description, $trunclengh)).''; } if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index 1d77a9a2186..f27d535f57c 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -26,11 +26,11 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","compta","accountancy","other")); +$langs->loadLangs(array("bills", "compta", "accountancy", "other")); // Filter $year = GETPOST("year", 'int'); @@ -49,17 +49,17 @@ if ($year == 0) { llxHeader('', $langs->trans("Bookkeeping")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("AccountBalanceByMonth") . ' ' . $textprevyear . ' ' . $langs->trans("Year") . ' ' . $year_start . ' ' . $textnextyear); +print load_fiche_titre($langs->trans("AccountBalanceByMonth").' '.$textprevyear.' '.$langs->trans("Year").' '.$year_start.' '.$textnextyear); -$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " , " . MAIN_DB_PREFIX . "facture as f"; +$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet as fd"; +$sql .= " , ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE fd.fk_code_ventilation = 0"; $sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;"; -dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql=' . $sql); +dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql='.$sql); $result = $db->query($sql); if ($result) { $row = $db->fetch_row($result); @@ -72,10 +72,10 @@ $y = $year_current; print ''; print ''; -print ''; -for($i = 1; $i <= 12; $i++) +print ''; +for ($i = 1; $i <= 12; $i++) { - print ''; + print ''; } print ''; print ''; @@ -94,9 +94,9 @@ $sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',"; $sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',"; $sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',"; $sql .= " ROUND(SUM(bk.montant),2) as 'Total'"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; -$sql .= " WHERE bk.doc_date >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; -$sql .= " AND bk.doc_date <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; +$sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; +$sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; $sql .= " GROUP BY bk.numero_compte"; $resql = $db->query($sql); @@ -104,26 +104,26 @@ if ($resql) { $i = 0; $num = $db->num_rows($resql); - while ( $i < $num ) { + while ($i < $num) { $row = $db->fetch_row($resql); - 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 ''; - $i ++; + $i++; } $db->free($resql); } else { diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 35c556807f8..39ed325b5fe 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -23,12 +23,12 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -36,16 +36,16 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->fiscalyear->write) +if (!$user->rights->accounting->fiscalyear->write) accessforbidden(); -$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); +$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -69,54 +69,54 @@ $year_current = $year_start; llxHeader('', $langs->trans("Closure")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("Closure") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); +print load_fiche_titre($langs->trans("Closure")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); -print ''.$langs->trans("DescClosure") . '
    '; +print ''.$langs->trans("DescClosure").'
    '; print '
    '; $y = $year_current; -$buttonbind = '' . $langs->trans("ValidateMovements") . ''; +$buttonbind = ''.$langs->trans("ValidateMovements").''; print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); print '
    '; print '
    ' . $langs->trans("Label") . ''.$langs->trans("Label").'' . $langs->trans("MonthShort".sprintf("%02s", $i)) . ''.$langs->trans("MonthShort".sprintf("%02s", $i)).''.$langs->trans("Total").'
    ' . length_accountg($row[0]) . '' . price($row[1]) . '' . price($row[2]) . '' . price($row[3]) . '' . price($row[4]) . '' . price($row[5]) . '' . price($row[6]) . '' . price($row[7]) . '' . price($row[8]) . '' . price($row[9]) . '' . price($row[10]) . '' . price($row[11]) . '' . price($row[12]) . '' . price($row[13]) . '
    '.length_accountg($row[0]).''.price($row[1]).''.price($row[2]).''.price($row[3]).''.price($row[4]).''.price($row[5]).''.price($row[6]).''.price($row[7]).''.price($row[8]).''.price($row[9]).''.price($row[10]).''.price($row[11]).''.price($row[12]).''.price($row[13]).'
    '; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; $sql = "SELECT COUNT(b.rowid) as detail,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " COUNT(b.rowid) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; -$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'"; -$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; +$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'"; +$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; +$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy -dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG); +dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } diff --git a/htdocs/accountancy/closure/validate.php b/htdocs/accountancy/closure/validate.php index 0b079c57b20..fe7fda5054f 100644 --- a/htdocs/accountancy/closure/validate.php +++ b/htdocs/accountancy/closure/validate.php @@ -23,12 +23,12 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -36,16 +36,16 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); - if (! $user->rights->accounting->fiscalyear->write) + if (!$user->rights->accounting->fiscalyear->write) accessforbidden(); -$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); +$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -68,14 +68,14 @@ if ($action == 'validate') // Update database $db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; - $sql .= " SET b.date_validated = '" . $db->idate($now) . "'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql .= " SET b.date_validated = '".$db->idate($now)."'"; $sql .= ' WHERE b.date_validated IS NULL'; dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); $resql = $db->query($sql); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -91,13 +91,13 @@ if ($action == 'validate') llxHeader('', $langs->trans("ValidateMovements")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("ValidateMovements") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); +print load_fiche_titre($langs->trans("ValidateMovements")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); -print $langs->trans("DescValidateMovements") . '
    '; +print $langs->trans("DescValidateMovements").'
    '; print '
    '; @@ -108,38 +108,38 @@ print_barre_liste($langs->trans("SelectMonthAndValidate"), '', '', '', '', '', ' print '
    '; print '
    ' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . ''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    ' . $row[$i] . ''.$row[$i].'' . $row[13] . ''.$row[13].'
    '; print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; print ''; $sql = "SELECT COUNT(b.rowid) as detail,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " COUNT(b.rowid) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; -$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'"; -$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; +$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'"; +$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; +$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy -dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG); +dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - for($i = 1; $i <= 12; $i ++) { - print '' ; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; } $db->free($resql); @@ -149,7 +149,7 @@ if ($resql) { print ''; print "
    ' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . ''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    ' . $row[$i] . '

    '; - print ''; - print '
    '.$row[$i].'

    '; + print ''; + print '
    ' . $row[13] . ''.$row[13].'
    \n"; -print '
    '; +print '
    '; print '
    '; // End of page diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 6b64d969518..eb7156eee82 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -24,11 +24,11 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","accountancy")); +$langs->loadLangs(array("bills", "accountancy")); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -48,16 +48,16 @@ if ($user->socid > 0) if ($action == 'ventil' && $user->rights->accounting->bind->write) { - if (! $cancel) + if (!$cancel) { if ($codeventil < 0) $codeventil = 0; - $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; - $sql .= " SET fk_code_ventilation = " . $codeventil; - $sql .= " WHERE rowid = " . $id; + $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sql .= " SET fk_code_ventilation = ".$codeventil; + $sql .= " WHERE rowid = ".$id; $resql = $db->query($sql); - if (! $resql) { + if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); } else @@ -93,18 +93,18 @@ $form = new Form($db); $facture_static = new Facture($db); $formaccounting = new FormAccounting($db); -if (! empty($id)) { +if (!empty($id)) { $sql = "SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,"; $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, p.accountancy_code_sell as code_sell,"; $sql .= " l.fk_code_ventilation, aa.account_number, aa.label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as l"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture"; - $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; - $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = l.fk_facture"; + $sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".$id; + $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy - dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG); + dol_syslog("/accounting/customer/card.php sql=".$sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -114,8 +114,8 @@ if (! empty($id)) { if ($num_lines) { $objp = $db->fetch_object($result); - print '' . "\n"; - print ''; + print ''."\n"; + print ''; print ''; print ''; @@ -126,15 +126,15 @@ if (! empty($id)) { print ''; // Ref facture - print ''; + print ''; $facture_static->ref = $objp->ref; $facture_static->id = $objp->facid; - print ''; + print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; print '
    ' . $langs->trans("Invoice") . '
    '.$langs->trans("Invoice").'' . $facture_static->getNomUrl(1) . ''.$facture_static->getNomUrl(1).'
    ' . $langs->trans("Line") . '' . nl2br($objp->description) . '
    ' . $langs->trans("Account") . ''; + print '
    '.$langs->trans("Line").''.nl2br($objp->description).'
    '.$langs->trans("Account").''; print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
    '; @@ -142,9 +142,9 @@ if (! empty($id)) { dol_fiche_end(); print '
    '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
    '; print ''; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 2aa6072f2c2..49bda732640 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -27,13 +27,13 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -41,16 +41,16 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); -$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); +$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -77,20 +77,20 @@ if ($action == 'clean' || $action == 'validatehistory') { // Clean database $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; $sql1 .= " SET fk_code_ventilation = 0"; $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN'; $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')'; - $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture WHERE entity = '.$conf->entity.')'; + $sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; + $sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')'; + $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture WHERE entity = '.$conf->entity.')'; $sql1 .= ' AND fk_code_ventilation <> 0'; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -121,26 +121,26 @@ if ($action == 'validatehistory') { // Customer Invoice lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; - $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; - $sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; - $sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; - $sql.= " co.code as country_code, co.label as country_label,"; - $sql.= " s.tva_intra"; - $sql.= " FROM " . MAIN_DB_PREFIX . "facture as f"; - $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; - $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; - $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; - $sql.= " AND l.product_type <= 2"; + $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; + $sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; + $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; + $sql .= " co.code as country_code, co.label as country_label,"; + $sql .= " s.tva_intra"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql .= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/customer/index.php'); $result = $db->query($sql); - if (! $result) { + if (!$result) { $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -172,12 +172,12 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { - $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; - $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; - $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; $resqlupdate = $db->query($sqlupdate); - if (! $resqlupdate) + if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); @@ -206,64 +206,64 @@ if ($action == 'validatehistory') { llxHeader('', $langs->trans("CustomersVentilation")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); +print load_fiche_titre($langs->trans("CustomersVentilation")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); -print ''.$langs->trans("DescVentilCustomer") . '
    '; -print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
    '; +print ''.$langs->trans("DescVentilCustomer").'
    '; +print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'
    '; print '

    '; $y = $year_current; -$buttonbind = '' . $langs->trans("ValidateHistory") . ''; +$buttonbind = ''.$langs->trans("ValidateHistory").''; print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); //print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); print '
    '; print ''; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(fd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; -$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; +$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND f.fk_statut > 0"; -$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; -dol_syslog('htdocs/accountancy/customer/index.php sql=' . $sql, LOG_DEBUG); +dol_syslog('htdocs/accountancy/customer/index.php sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -301,34 +301,34 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', print '
    '; print '
    ' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
    '.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    '; if ($row[0] == 'tobind') { @@ -278,11 +278,11 @@ if ($resql) { } else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
    '; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(fd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; -$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; -$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy +$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; +$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; +$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; @@ -338,7 +338,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -380,31 +380,31 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print '
    '; print '
    ' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
    '.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    '; if ($row[0] == 'tobind') { @@ -355,11 +355,11 @@ if ($resql) { else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
    '; - print ''; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } - print ''; + print ''; - $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; + $sql = "SELECT '".$langs->trans("TotalVente")."' AS total,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(fd.total_ht) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; - $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; - $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; + $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; + $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } dol_syslog('htdocs/accountancy/customer/index.php'); @@ -413,11 +413,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } $db->free($resql); @@ -428,35 +428,35 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print ''; - if (! empty($conf->margin->enabled)) { + if (!empty($conf->margin->enabled)) { print "
    \n"; print '
    '; print '
    ' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
    '.$langs->trans("TotalVente").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    ' . $row[0] . '' . price($row[$i]) . '
    '.$row[0].''.price($row[$i]).'' . price($row[13]) . ''.price($row[13]).'
    '; - print ''; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } - print ''; + print ''; - $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; + $sql = "SELECT '".$langs->trans("Vide")."' AS marge,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; - $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; - $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; + $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; + $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } dol_syslog('htdocs/accountancy/customer/index.php'); @@ -465,11 +465,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } $db->free($resql); diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index 0d0e6509769..5d9bc60c6ac 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -28,11 +28,11 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","accountancy","trips")); +$langs->loadLangs(array("bills", "accountancy", "trips")); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -52,16 +52,16 @@ if ($user->socid > 0) if ($action == 'ventil' && $user->rights->accounting->bind->write) { - if (! $cancel) + if (!$cancel) { if ($codeventil < 0) $codeventil = 0; - $sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det"; - $sql .= " SET fk_code_ventilation = " . $codeventil; - $sql .= " WHERE rowid = " . $id; + $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; + $sql .= " SET fk_code_ventilation = ".$codeventil; + $sql .= " WHERE rowid = ".$id; $resql = $db->query($sql); - if (! $resql) { + if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); } else @@ -95,18 +95,18 @@ $form = new Form($db); $expensereport_static = new ExpenseReport($db); $formaccounting = new FormAccounting($db); -if (! empty($id)) { +if (!empty($id)) { $sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,"; $sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,"; $sql .= " aa.account_number, aa.label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; - $sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id; - $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON erd.fk_code_ventilation = aa.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; + $sql .= " WHERE er.fk_statut > 0 AND erd.rowid = ".$id; + $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy - dol_syslog("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG); + dol_syslog("/accounting/expensereport/card.php sql=".$sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -116,8 +116,8 @@ if (! empty($id)) { if ($num_lines) { $objp = $db->fetch_object($result); - print '' . "\n"; - print ''; + print ''."\n"; + print ''; print ''; print ''; @@ -128,22 +128,22 @@ if (! empty($id)) { print '
    ' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
    '.$langs->trans("TotalMarge").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    ' . $row[0] . '' . price(price2num($row[$i])) . '
    '.$row[0].''.price(price2num($row[$i])).'' . price(price2num($row[13])) . ''.price(price2num($row[13])).'
    '; // Ref - print ''; + print ''; $expensereport_static->ref = $objp->ref; $expensereport_static->id = $objp->erid; - print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; print '
    ' . $langs->trans("ExpenseReport") . '
    '.$langs->trans("ExpenseReport").'' . $expensereport_static->getNomUrl(1) . ''.$expensereport_static->getNomUrl(1).'
    ' . $langs->trans("Line") . '' . stripslashes(nl2br($objp->rowid)) . '
    '.$langs->trans("Line").''.stripslashes(nl2br($objp->rowid)).'
    ' . $langs->trans("Description") . '' . stripslashes(nl2br($objp->comments)) . '
    '.$langs->trans("Description").''.stripslashes(nl2br($objp->comments)).'
    ' . $langs->trans("TypeFees") . '' . ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))) . '
    '.$langs->trans("TypeFees").''.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).'
    ' . $langs->trans("Account") . ''; + print '
    '.$langs->trans("Account").''; print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
    '; @@ -151,9 +151,9 @@ if (! empty($id)) { dol_fiche_end(); print '
    '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
    '; print ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 29fe4a7aea3..2f22344e8fb 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -25,12 +25,12 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -38,15 +38,15 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); -$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); +$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -72,19 +72,19 @@ if ($action == 'clean' || $action == 'validatehistory') { // Clean database $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd"; $sql1 .= " SET fk_code_ventilation = 0"; $sql1 .= ' WHERE erd.fk_code_ventilation NOT IN'; $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')'; - $sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'expensereport WHERE entity = '.$conf->entity.')'; + $sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; + $sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')'; + $sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'expensereport WHERE entity = '.$conf->entity.')'; $sql1 .= ' AND fk_code_ventilation <> 0'; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -99,16 +99,16 @@ if ($action == 'validatehistory') { // Now make the binding if ($db->type == 'pgsql') { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " FROM " . MAIN_DB_PREFIX . "c_type_fees as t, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " WHERE " . MAIN_DB_PREFIX . "expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; + $sql1 .= " WHERE ".MAIN_DB_PREFIX."expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND t.accountancy_code = accnt.account_number"; - $sql1 .= " AND " . MAIN_DB_PREFIX . "expensereport_det.fk_code_ventilation = 0"; + $sql1 .= " AND ".MAIN_DB_PREFIX."expensereport_det.fk_code_ventilation = 0"; } else { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd, " . MAIN_DB_PREFIX . "c_type_fees as t, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd, ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; $sql1 .= " SET erd.fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND t.accountancy_code=accnt.account_number"; $sql1 .= " AND erd.fk_code_ventilation = 0"; } @@ -116,8 +116,8 @@ if ($action == 'validatehistory') { dol_syslog('htdocs/accountancy/expensereport/index.php'); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -133,19 +133,19 @@ if ($action == 'validatehistory') { llxHeader('', $langs->trans("ExpenseReportsVentilation")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("ExpenseReportsVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); +print load_fiche_titre($langs->trans("ExpenseReportsVentilation")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); -print ''.$langs->trans("DescVentilExpenseReport") . '
    '; -print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
    '; +print ''.$langs->trans("DescVentilExpenseReport").'
    '; +print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'
    '; print '

    '; $y = $year_current; -$buttonbind = '' . $langs->trans("ValidateHistory") . ''; +$buttonbind = ''.$langs->trans("ValidateHistory").''; print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); @@ -153,39 +153,39 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', print '
    '; print ''; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(erd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; -$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; +$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; +$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; -$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; -dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); +dol_syslog('/accountancy/expensereport/index.php:: sql='.$sql); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -224,30 +224,30 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', print '
    '; print '
    ' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
    '.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    '; if ($row[0] == 'tobind') { @@ -200,11 +200,11 @@ if ($resql) { } else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
    '; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " ROUND(SUM(erd.total_ht),2) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; -$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; +$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; +$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; -$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; @@ -256,7 +256,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -298,27 +298,27 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print '
    '; print '
    ' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
    '.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    '; if ($row[0] == 'tobind') { @@ -272,11 +272,11 @@ if ($resql) { } else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
    '; - print ''; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } - print ''; + print ''; - $sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,"; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; + $sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(erd.total_ht) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; - $sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'"; - $sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; + $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; + $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; - $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy + $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy dol_syslog('htdocs/accountancy/expensereport/index.php'); $resql = $db->query($sql); @@ -326,11 +326,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index e39decd7c57..622ac801fbc 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -28,11 +28,11 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","accountancy")); +$langs->loadLangs(array("bills", "accountancy")); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -52,16 +52,16 @@ if ($user->socid > 0) if ($action == 'ventil' && $user->rights->accounting->bind->write) { - if (! $cancel) + if (!$cancel) { if ($codeventil < 0) $codeventil = 0; - $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sql .= " SET fk_code_ventilation = " . $codeventil; - $sql .= " WHERE rowid = " . $id; + $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; + $sql .= " SET fk_code_ventilation = ".$codeventil; + $sql .= " WHERE rowid = ".$id; $resql = $db->query($sql); - if (! $resql) { + if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); } else @@ -95,18 +95,18 @@ $form = new Form($db); $facturefournisseur_static = new FactureFournisseur($db); $formaccounting = new FormAccounting($db); -if (! empty($id)) { +if (!empty($id)) { $sql = "SELECT f.ref as ref, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, "; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label"; $sql .= ", aa.account_number, aa.label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn "; - $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; - $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn "; + $sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".$id; + $sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy - dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG); + dol_syslog("/accounting/supplier/card.php sql=".$sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -116,8 +116,8 @@ if (! empty($id)) { if ($num_lines) { $objp = $db->fetch_object($result); - print '' . "\n"; - print ''; + print ''."\n"; + print ''; print ''; print ''; @@ -128,17 +128,17 @@ if (! empty($id)) { print '
    ' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
    '.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    ' . $row[0] . '' . price($row[$i]) . '
    '.$row[0].''.price($row[$i]).'' . price($row[13]) . ''.price($row[13]).'
    '; // ref invoice - print ''; + print ''; $facturefournisseur_static->ref = $objp->ref; $facturefournisseur_static->id = $objp->facid; - print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print '
    ' . $langs->trans("BillsSuppliers") . '
    '.$langs->trans("BillsSuppliers").'' . $facturefournisseur_static->getNomUrl(1) . ''.$facturefournisseur_static->getNomUrl(1).'
    ' . $langs->trans("Line") . '' . stripslashes(nl2br($objp->description)) . '
    ' . $langs->trans("ProductLabel") . '' . dol_trunc($objp->product_label, 24) . '
    ' . $langs->trans("Account") . ''; + print '
    '.$langs->trans("Line").''.stripslashes(nl2br($objp->description)).'
    '.$langs->trans("ProductLabel").''.dol_trunc($objp->product_label, 24).'
    '.$langs->trans("Account").''; print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
    '; @@ -146,9 +146,9 @@ if (! empty($id)) { dol_fiche_end(); print '
    '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
    '; print ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 945c5567b0b..2955ddec881 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -25,13 +25,13 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -39,16 +39,16 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); -$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); +$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -75,19 +75,19 @@ if ($action == 'clean' || $action == 'validatehistory') { // Clean database $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as fd"; $sql1 .= " SET fk_code_ventilation = 0"; $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN'; $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')'; - $sql1 .= ' AND fd.fk_facture_fourn IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture_fourn WHERE entity = '.$conf->entity.')'; + $sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; + $sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')'; + $sql1 .= ' AND fd.fk_facture_fourn IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE entity = '.$conf->entity.')'; $sql1 .= ' AND fk_code_ventilation <> 0'; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -118,24 +118,24 @@ if ($action == 'validatehistory') { // Supplier Invoice Lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; - $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; - $sql.= " aa.rowid as aarowid,"; - $sql.= " co.code as country_code, co.label as country_label,"; - $sql.= " s.tva_intra"; - $sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; - $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; - $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; - $sql.= " AND l.product_type <= 2"; + $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; + $sql .= " aa.rowid as aarowid,"; + $sql .= " co.code as country_code, co.label as country_label,"; + $sql .= " s.tva_intra"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql .= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/supplier/index.php'); $result = $db->query($sql); - if (! $result) { + if (!$result) { $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -171,12 +171,12 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { - $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; - $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; + $sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; $resqlupdate = $db->query($sqlupdate); - if (! $resqlupdate) + if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); @@ -205,18 +205,18 @@ if ($action == 'validatehistory') { llxHeader('', $langs->trans("SuppliersVentilation")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); +print load_fiche_titre($langs->trans("SuppliersVentilation")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); -print ''.$langs->trans("DescVentilSupplier") . '
    '; -print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
    '; +print ''.$langs->trans("DescVentilSupplier").'
    '; +print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'
    '; print '

    '; $y = $year_current; -$buttonbind = '' . $langs->trans("ValidateHistory") . ''; +$buttonbind = ''.$langs->trans("ValidateHistory").''; print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); @@ -224,30 +224,30 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', print '
    '; print ''; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(ffd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; -$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; +$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; +$sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND ff.fk_statut > 0"; -$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy +$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; @@ -256,7 +256,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -294,30 +294,30 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', print '
    '; print '
    ' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
    '.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    '; if ($row[0] == 'tobind') { @@ -271,11 +271,11 @@ if ($resql) { } else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
    '; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(ffd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; -$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; +$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; +$sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND ff.fk_statut > 0"; -$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy +$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; @@ -326,7 +326,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -367,27 +367,27 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print '
    '; print '
    ' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
    '.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    '; if ($row[0] == 'tobind') { @@ -341,11 +341,11 @@ if ($resql) { } else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
    '; - print ''; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } - print ''; + print ''; - $sql = "SELECT '" . $langs->trans("CAHTF") . "' AS label,"; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; + $sql = "SELECT '".$langs->trans("CAHTF")."' AS label,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(ffd.total_ht) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; - $sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'"; - $sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; + $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; + $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND ff.fk_statut > 0"; - $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy + $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy dol_syslog('htdocs/accountancy/supplier/index.php'); $resql = $db->query($sql); @@ -395,11 +395,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } $db->free($resql); diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index aa203ffca42..bca4236bfa2 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -27,29 +27,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -if (! empty($conf->banque->enabled)) { +if (!empty($conf->banque->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; } // Load translation files required by the page -$langs->loadLangs(array("companies","members","bills","users")); +$langs->loadLangs(array("companies", "members", "bills", "users")); $adh = new Adherent($db); $adht = new AdherentType($db); $object = new Subscription($db); -$errmsg=''; +$errmsg = ''; -$action=GETPOST("action", 'alpha'); -$rowid=GETPOST("rowid", "int")?GETPOST("rowid", "int"):GETPOST("id", "int"); -$typeid=GETPOST("typeid", "int"); -$cancel=GETPOST('cancel', 'alpha'); -$confirm=GETPOST('confirm'); +$action = GETPOST("action", 'alpha'); +$rowid = GETPOST("rowid", "int") ?GETPOST("rowid", "int") : GETPOST("id", "int"); +$typeid = GETPOST("typeid", "int"); +$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm'); -if (! $user->rights->adherent->cotisation->lire) +if (!$user->rights->adherent->cotisation->lire) accessforbidden(); $permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php +$permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php @@ -57,60 +57,60 @@ $permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the i * Actions */ -if ($cancel) $action=''; +if ($cancel) $action = ''; //include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once -include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once +include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once -if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $cancel) +if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cancel) { // Load current object - $result=$object->fetch($rowid); + $result = $object->fetch($rowid); if ($result > 0) { $db->begin(); - $errmsg=''; + $errmsg = ''; if ($object->fk_bank) { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); + $accountline = new AccountLine($db); + $result = $accountline->fetch($object->fk_bank); // If transaction consolidated if ($accountline->rappro) { - $errmsg=$langs->trans("SubscriptionLinkedToConciliatedTransaction"); + $errmsg = $langs->trans("SubscriptionLinkedToConciliatedTransaction"); } else { - $accountline->datev=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); - $accountline->dateo=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); - $accountline->amount=$_POST["amount"]; - $result=$accountline->update($user); + $accountline->datev = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); + $accountline->dateo = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); + $accountline->amount = $_POST["amount"]; + $result = $accountline->update($user); if ($result < 0) { - $errmsg=$accountline->error; + $errmsg = $accountline->error; } } } - if (! $errmsg) + if (!$errmsg) { // Modify values - $object->dateh=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); - $object->datef=dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']); - $object->fk_type=$_POST["typeid"]; - $object->note=$_POST["note"]; - $object->amount=$_POST["amount"]; + $object->dateh = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); + $object->datef = dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']); + $object->fk_type = $_POST["typeid"]; + $object->note = $_POST["note"]; + $object->amount = $_POST["amount"]; //print 'datef='.$object->datef.' '.$_POST['datesubendday']; - $result=$object->update($user); - if ($result >= 0 && ! count($object->errors)) + $result = $object->update($user); + if ($result >= 0 && !count($object->errors)) { $db->commit(); @@ -123,17 +123,17 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $canc if ($object->error) { - $errmsg=$object->error; + $errmsg = $object->error; } else { - foreach($object->errors as $error) + foreach ($object->errors as $error) { - if ($errmsg) $errmsg.='
    '; - $errmsg.=$error; + if ($errmsg) $errmsg .= '
    '; + $errmsg .= $error; } } - $action=''; + $action = ''; } } else @@ -145,8 +145,8 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $canc if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent->cotisation->creer) { - $result=$object->fetch($rowid); - $result=$object->delete($user); + $result = $object->fetch($rowid); + $result = $object->delete($user); if ($result > 0) { header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent); @@ -154,7 +154,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent- } else { - $mesg=$adh->error; + $mesg = $adh->error; } } @@ -182,7 +182,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') ********************************************/ $object->fetch($rowid); - $result=$adh->fetch($object->fk_adherent); + $result = $adh->fetch($object->fk_adherent); $head = subscription_prepare_head($object); @@ -206,7 +206,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') print ''; // Member - $adh->ref=$adh->getFullName($langs); + $adh->ref = $adh->getFullName($langs); print ''; print ''; print ''; @@ -214,7 +214,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') // Type print ''; print ''; // Date start subscription @@ -238,15 +238,15 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') print ''; // Bank line - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) { print '
    ' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
    '.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
    '.$langs->trans("Total").'
    ' . $row[0] . '' . price($row[$i]) . '
    '.$row[0].''.price($row[$i]).'' . price($row[13]) . ''.price($row[13]).'
    '.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
    '.$langs->trans("Type").''; - print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type)); + print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"]) ? $_POST["typeid"] : $object->fk_type)); print'
    '.$langs->trans("BankTransactionLine").''; if ($object->fk_bank) { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); + $bankline = new AccountLine($db); + $result = $bankline->fetch($object->fk_bank); print $bankline->getNomUrl(1, 0, 'showall'); } else @@ -279,8 +279,8 @@ if ($rowid && $action != 'edit') * ********************************************/ - $result=$object->fetch($rowid); - $result=$adh->fetch($object->fk_adherent); + $result = $object->fetch($rowid); + $result = $adh->fetch($object->fk_adherent); $head = subscription_prepare_head($object); @@ -291,8 +291,8 @@ if ($rowid && $action != 'edit') { //$formquestion=array(); //$formquestion['text']=''.$langs->trans("ThisWillAlsoDeleteBankRecord").''; - $text=$langs->trans("ConfirmDeleteSubscription"); - if (! empty($conf->banque->enabled) && ! empty($conf->global->ADHERENT_BANK_USE)) $text.='
    '.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord"); + $text = $langs->trans("ConfirmDeleteSubscription"); + if (!empty($conf->banque->enabled) && !empty($conf->global->ADHERENT_BANK_USE)) $text .= '
    '.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord"); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("DeleteSubscription"), $text, "confirm_delete", $formquestion, 0, 1); } @@ -310,7 +310,7 @@ if ($rowid && $action != 'edit') print ''; // Member - $adh->ref=$adh->getFullName($langs); + $adh->ref = $adh->getFullName($langs); print ''; print ''; print ''; @@ -345,15 +345,15 @@ if ($rowid && $action != 'edit') print ''; // Bank line - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) { print ''; print '
    '; @@ -626,7 +626,7 @@ if ($rowid > 0) $moreforfilter = ''; print '
    '; - print '
    '.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
    '.$langs->trans("Label").''.$object->note.'
    '.$langs->trans("BankTransactionLine").''; if ($object->fk_bank) { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); + $bankline = new AccountLine($db); + $result = $bankline->fetch($object->fk_bank); print $bankline->getNomUrl(1, 0, 'showall'); } else @@ -379,7 +379,7 @@ if ($rowid && $action != 'edit') if ($user->rights->adherent->cotisation->creer) { - if (! $bankline->rappro) + if (!$bankline->rappro) { print '"; } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 0c1ec419a32..d98dcd9f693 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -41,35 +41,35 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$search_lastname = GETPOST('search_lastname', 'alpha'); +$search_lastname = GETPOST('search_lastname', 'alpha'); $search_login = GETPOST('search_login', 'alpha'); $search_email = GETPOST('search_email', 'alpha'); -$type = GETPOST('type', 'intcomma'); +$type = GETPOST('type', 'intcomma'); $status = GETPOST('status', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$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) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page ; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) { $sortorder="DESC"; } -if (! $sortfield) { $sortfield="d.lastname"; } +if (!$sortorder) { $sortorder = "DESC"; } +if (!$sortfield) { $sortfield = "d.lastname"; } -$label=GETPOST("label", "alpha"); -$morphy=GETPOST("morphy", "alpha"); -$statut=GETPOST("statut", "int"); -$subscription=GETPOST("subscription", "int"); +$label = GETPOST("label", "alpha"); +$morphy = GETPOST("morphy", "alpha"); +$statut = GETPOST("statut", "int"); +$subscription = GETPOST("subscription", "int"); $duration_value = GETPOST('duration_value', 'int'); $duration_unit = GETPOST('duration_unit', 'alpha'); -$vote=GETPOST("vote", "int"); -$comment=GETPOST("comment", 'alphanohtml'); -$mail_valid=GETPOST("mail_valid", 'none'); +$vote = GETPOST("vote", "int"); +$comment = GETPOST("comment", 'alphanohtml'); +$mail_valid = GETPOST("mail_valid", 'none'); // Security check -$result=restrictedArea($user, 'adherent', $rowid, 'adherent_type'); +$result = restrictedArea($user, 'adherent', $rowid, 'adherent_type'); $object = new AdherentType($db); @@ -80,16 +80,16 @@ $extrafields->fetch_name_optionals_label($object->table_element); 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_lastname=""; - $search_login=""; - $search_email=""; - $type=""; - $sall=""; + $search_lastname = ""; + $search_login = ""; + $search_email = ""; + $type = ""; + $sall = ""; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('membertypecard','globalcard')); +$hookmanager->initHooks(array('membertypecard', 'globalcard')); /* @@ -97,23 +97,23 @@ $hookmanager->initHooks(array('membertypecard','globalcard')); */ if ($cancel) { - $action=''; + $action = ''; - if (! empty($backtopage)) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } } if ($action == 'add' && $user->rights->adherent->configurer) { - $object->label = trim($label); + $object->label = trim($label); $object->morphy = trim($morphy); $object->statut = (int) $statut; $object->subscription = (int) $subscription; $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; $object->note = trim($comment); - $object->mail_valid = trim($mail_valid); + $object->mail_valid = trim($mail_valid); $object->vote = (int) $vote; // Fill array 'array_options' with data from add form @@ -137,9 +137,9 @@ if ($action == 'add' && $user->rights->adherent->configurer) { } } - if (! $error) + if (!$error) { - $id=$object->create($user); + $id = $object->create($user); if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -164,22 +164,22 @@ if ($action == 'update' && $user->rights->adherent->configurer) $object->oldcopy = clone $object; $object->label = trim($label); - $object->morphy = trim($morphy); + $object->morphy = trim($morphy); $object->statut = (int) $statut; $object->subscription = (int) $subscription; $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; $object->note = trim($comment); - $object->mail_valid = trim($mail_valid); + $object->mail_valid = trim($mail_valid); $object->vote = (boolean) trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - $ret=$object->update($user); + $ret = $object->update($user); - if ($ret >= 0 && ! count($object->errors)) + if ($ret >= 0 && !count($object->errors)) { setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs'); } @@ -195,7 +195,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) if ($action == 'confirm_delete' && $user->rights->adherent->configurer) { $object->fetch($rowid); - $res=$object->delete(); + $res = $object->delete(); if ($res > 0) { @@ -206,7 +206,7 @@ if ($action == 'confirm_delete' && $user->rights->adherent->configurer) else { setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors'); - $action=''; + $action = ''; } } @@ -215,20 +215,20 @@ if ($action == 'confirm_delete' && $user->rights->adherent->configurer) * View */ -$form=new Form($db); +$form = new Form($db); $formproduct = new FormProduct($db); llxHeader('', $langs->trans("MembersTypeSetup"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); // List of members type -if (! $rowid && $action != 'create' && $action != 'edit') +if (!$rowid && $action != 'create' && $action != 'edit') { //dol_fiche_head(''); $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut, d.morphy"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; - $sql.= " WHERE d.entity IN (".getEntity('member_type').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; + $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; $result = $db->query($sql); if ($result) @@ -240,10 +240,10 @@ if (! $rowid && $action != 'create' && $action != 'edit') $param = ''; - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->adherent->configurer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); } print '
    '; @@ -260,7 +260,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') $moreforfilter = ''; print '
    '; - print ''."\n"; + print '
    '."\n"; print ''; print ''; @@ -295,7 +295,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; print ''; print ''; print ''; // Morphy @@ -351,7 +351,7 @@ if ($action == 'create') $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print '"; print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -433,7 +433,7 @@ if ($rowid > 0) print '
    '.$langs->trans("Ref").''.yn($objp->subscription).''.yn($objp->vote).''; - if ( !empty($objp->statut) ) { + if (!empty($objp->statut)) { print img_picto($langs->trans("InActivity"), 'statut4'); } else { print img_picto($langs->trans("ActivityCeased"), 'statut5'); @@ -343,7 +343,7 @@ if ($action == 'create') print '
    '.$langs->trans("Label").'
    '.$langs->trans("Status").''; - print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), 1); + print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1); print '
    '.$langs->trans("MemberNature").''; - print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); + print $form->selectarray("morphy", $morphys, isset($_POST["morphy"]) ? $_POST["morphy"] : $object->morphy); print "
    '.$langs->trans("SubscriptionRequired").''; @@ -372,13 +372,13 @@ if ($action == 'create') print '
    '.$langs->trans("WelcomeEMail").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print '
    '; print ''; print '"; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '.$langs->trans("Status").''; - if ( !empty($object->statut) ) { + if (!empty($object->statut)) { print img_picto($langs->trans('TypeStatusActive'), 'statut4').' '.$langs->trans("InActivity"); } else { print img_picto($langs->trans('TypeStatusInactive'), 'statut5').' '.$langs->trans("ActivityCeased"); @@ -455,13 +455,13 @@ if ($rowid > 0) print '
    '.$langs->trans("Duration").''.$object->duration_value.' '; if ($object->duration_value > 1) { - $dur=array("i"=>$langs->trans("Minute"),"h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); } elseif ($object->duration_value > 0) { - $dur=array("i"=>$langs->trans("Minute"),"h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } - print (! empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; + print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; print '
    '.$langs->trans("Description").''; @@ -471,7 +471,7 @@ if ($rowid > 0) print nl2br($object->mail_valid)."
    '; print '
    '; @@ -491,7 +491,7 @@ if ($rowid > 0) } // Add - if ( $user->rights->adherent->configurer && !empty($object->statut) ) + if ($user->rights->adherent->configurer && !empty($object->statut)) { print ''; } else { @@ -509,55 +509,55 @@ if ($rowid > 0) // Show list of members (nearly same code than in page list.php) - $membertypestatic=new AdherentType($db); + $membertypestatic = new AdherentType($db); - $now=dol_now(); + $now = dol_now(); $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe as company,"; - $sql.= " d.datefin,"; - $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; - $sql.= " t.libelle as type, t.subscription"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE d.fk_adherent_type = t.rowid "; - $sql.= " AND d.entity IN (".getEntity('adherent').")"; - $sql.= " AND t.rowid = ".$object->id; + $sql .= " d.datefin,"; + $sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; + $sql .= " t.libelle as type, t.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= " WHERE d.fk_adherent_type = t.rowid "; + $sql .= " AND d.entity IN (".getEntity('adherent').")"; + $sql .= " AND t.rowid = ".$object->id; if ($sall) { - $sql.=natural_search(array("f.firstname","d.lastname","d.societe","d.email","d.login","d.address","d.town","d.note_public","d.note_private"), $sall); + $sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall); } if ($status != '') { - $sql.= natural_search('d.statut', $status, 2); + $sql .= natural_search('d.statut', $status, 2); } if ($action == 'search') { if (GETPOST('search', 'alpha')) { - $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search', 'alpha')); + $sql .= natural_search(array("d.firstname", "d.lastname"), GETPOST('search', 'alpha')); } } - if (! empty($search_lastname)) + if (!empty($search_lastname)) { - $sql.= natural_search(array("d.firstname","d.lastname"), $search_lastname); + $sql .= natural_search(array("d.firstname", "d.lastname"), $search_lastname); } - if (! empty($search_login)) + if (!empty($search_login)) { - $sql.= natural_search("d.login", $search_login); + $sql .= natural_search("d.login", $search_login); } - if (! empty($search_email)) + if (!empty($search_email)) { - $sql.= natural_search("d.email", $search_email); + $sql .= natural_search("d.email", $search_email); } if ($filter == 'uptodate') { - $sql.=" AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)"; + $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)"; } if ($filter == 'outofdate') { - $sql.=" AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; + $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; } - $sql.= " ".$db->order($sortfield, $sortorder); + $sql .= " ".$db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -573,7 +573,7 @@ if ($rowid > 0) } } - $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); + $sql .= " ".$db->plimit($conf->liste_limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -581,35 +581,35 @@ if ($rowid > 0) $num = $db->num_rows($resql); $i = 0; - $titre=$langs->trans("MembersList"); + $titre = $langs->trans("MembersList"); if ($status != '') { - if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); } - elseif ($status == '-1') { $titre=$langs->trans("MembersListToValid"); } - elseif ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); } - elseif ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); } - elseif ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } - elseif ($status == '0') { $titre=$langs->trans("MembersListResiliated"); } + if ($status == '-1,1') { $titre = $langs->trans("MembersListQualified"); } + elseif ($status == '-1') { $titre = $langs->trans("MembersListToValid"); } + elseif ($status == '1' && !$filter) { $titre = $langs->trans("MembersListValid"); } + elseif ($status == '1' && $filter == 'uptodate') { $titre = $langs->trans("MembersListUpToDate"); } + elseif ($status == '1' && $filter == 'outofdate') { $titre = $langs->trans("MembersListNotUpToDate"); } + elseif ($status == '0') { $titre = $langs->trans("MembersListResiliated"); } } elseif ($action == 'search') { - $titre=$langs->trans("MembersListQualified"); + $titre = $langs->trans("MembersListQualified"); } if ($type > 0) { - $membertype=new AdherentType($db); - $result=$membertype->fetch($type); - $titre.=" (".$membertype->label.")"; + $membertype = new AdherentType($db); + $result = $membertype->fetch($type); + $titre .= " (".$membertype->label.")"; } - $param="&rowid=".$object->id; - if (! empty($status)) $param.="&status=".$status; - if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname; - if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname; - if (! empty($search_login)) $param.="&search_login=".$search_login; - if (! empty($search_email)) $param.="&search_email=".$search_email; - if (! empty($filter)) $param.="&filter=".$filter; + $param = "&rowid=".$object->id; + if (!empty($status)) $param .= "&status=".$status; + if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname; + if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname; + if (!empty($search_login)) $param .= "&search_login=".$search_login; + if (!empty($search_email)) $param .= "&search_email=".$search_email; + if (!empty($filter)) $param .= "&filter=".$filter; if ($sall) { @@ -617,7 +617,7 @@ if ($rowid > 0) } print ''; - print ''; + print ''; print '
    '."\n"; + print '
    '."\n"; // Fields title search print ''; @@ -666,11 +666,11 @@ if ($rowid > 0) { $objp = $db->fetch_object($resql); - $datefin=$db->jdate($objp->datefin); + $datefin = $db->jdate($objp->datefin); - $adh=new Adherent($db); - $adh->lastname=$objp->lastname; - $adh->firstname=$objp->firstname; + $adh = new Adherent($db); + $adh->lastname = $objp->lastname; + $adh->firstname = $objp->firstname; // Lastname print ''; @@ -794,7 +794,7 @@ if ($rowid > 0) print ''; print ''; // Morphy @@ -802,7 +802,7 @@ if ($rowid > 0) $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print '"; print '"; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index 08504a39df6..b70327271f0 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -35,15 +35,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $langs->loadLangs(array('members', 'languages')); $id = GETPOST('rowid', 'int'); -$action=GETPOST('action', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid=$user->socid; +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) $socid = $user->socid; // Security check -$result=restrictedArea($user, 'adherent', $id, 'adherent_type'); +$result = restrictedArea($user, 'adherent', $id, 'adherent_type'); /* @@ -105,21 +105,21 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->a foreach ($object->multilangs as $key => $value) // saving new values in the object { - if ( $key == $current_lang ) + if ($key == $current_lang) { $object->label = $_POST["libelle-".$key]; - $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->other = dol_htmlcleanlastbr($_POST["other-".$key]); } else { $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; - $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]); } } - if ( $object->setMultiLangs($user) > 0 ) + if ($object->setMultiLangs($user) > 0) { $action = ''; } @@ -135,10 +135,10 @@ if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->rights- { $object = new AdherentType($db); $object->fetch($id); - $langtodelete=GETPOST('langdel', 'alpha'); + $langtodelete = GETPOST('langdel', 'alpha'); - if ( $object->delMultiLangs($langtodelete, $user) > 0 ) + if ($object->delMultiLangs($langtodelete, $user) > 0) { $action = ''; } @@ -161,20 +161,20 @@ $title = $langs->trans('MemberTypeCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); -$title = $langs->trans('MemberType')." ". $shortlabel ." - ".$langs->trans('Translation'); -$helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +$title = $langs->trans('MemberType')." ".$shortlabel." - ".$langs->trans('Translation'); +$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; llxHeader('', $title, $helpurl); $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); $head = member_type_prepare_head($object); -$titre=$langs->trans("MemberType".$object->type); +$titre = $langs->trans("MemberType".$object->type); // Calculate $cnt_trans $cnt_trans = 0; -if (! empty($object->multilangs)) +if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { @@ -224,12 +224,12 @@ if ($action == 'edit') print ''; print ''; - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { - $s=picto_from_langcode($key); - print "
    ".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"')."
    "; + $s = picto_from_langcode($key); + print "
    ".($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"')."
    "; print '
    '; print '
    '.$langs->trans("Label").'
    '.$langs->trans("Status").''; - print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $object->statut); + print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->statut); print '
    '.$langs->trans("MemberNature").''; - print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); + print $form->selectarray("morphy", $morphys, isset($_POST["morphy"]) ? $_POST["morphy"] : $object->morphy); print "
    '.$langs->trans("SubscriptionRequired").''; @@ -823,16 +823,16 @@ if ($rowid > 0) print '
    '.$langs->trans("WelcomeEMail").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print "
    '; @@ -255,12 +255,12 @@ if ($action == 'edit') } elseif ($action != 'add') { - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { - $s=picto_from_langcode($key); - print ($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; + $s = picto_from_langcode($key); + print ($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; print '
    '; print '
    '; @@ -271,7 +271,7 @@ elseif ($action != 'add') print '
    '; } } - if (! $cnt_trans && $action != 'add') print '
    '. $langs->trans('NoTranslation').'
    '; + if (!$cnt_trans && $action != 'add') print '
    '.$langs->trans('NoTranslation').'
    '; } diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 0a87f4eda17..65e9cc88856 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -41,9 +41,9 @@ $search_event = GETPOST('search_event', 'alpha'); // Get list of triggers available $sql = "SELECT a.rowid, a.code, a.label, a.elementtype, a.rang as position"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; -$sql.= " ORDER BY a.rang ASC"; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; +$sql .= " ORDER BY a.rang ASC"; +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -51,11 +51,11 @@ if ($resql) while ($i < $num) { $obj = $db->fetch_object($resql); - $triggers[$i]['rowid'] = $obj->rowid; + $triggers[$i]['rowid'] = $obj->rowid; $triggers[$i]['code'] = $obj->code; - $triggers[$i]['element'] = $obj->elementtype; - $triggers[$i]['label'] = ($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label); - $triggers[$i]['position'] = $obj->position; + $triggers[$i]['element'] = $obj->elementtype; + $triggers[$i]['label'] = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label); + $triggers[$i]['position'] = $obj->position; $i++; } @@ -74,35 +74,35 @@ else */ // 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 +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_event = ''; $action = ''; } -if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') ||GETPOST('button_search', 'alpha')) // To avoid the save when we click on search +if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) // To avoid the save when we click on search { $action = ''; } if ($action == "save" && empty($cancel)) { - $i=0; + $i = 0; $db->begin(); foreach ($triggers as $trigger) { - $keyparam='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; + $keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; //print "param=".$param." - ".$_POST[$param]; if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam)) { - $res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha')?GETPOST($keyparam, 'alpha'):''), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + $res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); $db->commit(); @@ -120,10 +120,10 @@ if ($action == "save" && empty($cancel)) * View */ -$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup'); print ''; @@ -131,23 +131,23 @@ print ''; print ''; $param = ''; -$param.= '&search_event='.urlencode($search_event); +$param .= '&search_event='.urlencode($search_event); -$head=agenda_prepare_head(); +$head = agenda_prepare_head(); dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action'); print ''.$langs->trans("AgendaAutoActionDesc")." ".$langs->trans("OnlyActiveElementsAreShown", 'modules.php').'
    '; print "
    \n"; -print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
    '; print ''; print ''; print ''; // Action column print ''; print ''; @@ -155,10 +155,10 @@ print ''."\n"; print ''; print ''; -print ''; +print ''; print ''."\n"; // Show each trigger (list is in c_action_trigger) -if (! empty($triggers)) +if (!empty($triggers)) { foreach ($triggers as $trigger) { @@ -170,7 +170,7 @@ if (! empty($triggers)) if ($module == 'proposal_supplier') $module = 'supplier_proposal'; //print 'module='.$module.'
    '; - if (! empty($conf->$module->enabled)) + if (!empty($conf->$module->enabled)) { // Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; @@ -182,9 +182,9 @@ if (! empty($triggers)) print ''; print ''; print ''."\n"; } } diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index c0150ce5111..0dc682a32f8 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -25,20 +25,20 @@ * \brief Page to setup the bank module */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","companies","bills","other","banks")); +$langs->loadLangs(array("admin", "companies", "bills", "other", "banks")); if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); -$actionsave=GETPOST('save', 'alpha'); +$actionsave = GETPOST('save', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); @@ -53,7 +53,7 @@ $type = 'bankaccount'; if ($action == 'setbankorder') { if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -65,7 +65,7 @@ if ($action == 'setbankorder') { if ($action == 'setreportlastnumreleve') { if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -75,7 +75,7 @@ if ($action == 'setreportlastnumreleve') { elseif ($action == 'unsetreportlastnumreleve') { if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -87,7 +87,7 @@ elseif ($action == 'unsetreportlastnumreleve') { if ($action == 'setbankcolorizemovement') { if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -97,7 +97,7 @@ if ($action == 'setbankcolorizemovement') { elseif ($action == 'unsetbankcolorizemovement') { if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -109,21 +109,21 @@ if ($actionsave) { $db->begin(); - $i=1; $errorsaved=0; - $error=0; + $i = 1; $errorsaved = 0; + $error = 0; // Save colors while ($i <= 2) { - $color=trim(GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha')); - if ($color=='-1') $color=''; + $color = trim(GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha')); + if ($color == '-1') $color = ''; - $res=dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + $res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; $i++; } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -153,10 +153,10 @@ if ($action == 'specimen') { $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir . "core/modules/bank/doc/pdf_" . $modele . ".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; - $classname = "pdf_" . $modele; + $classname = "pdf_".$modele; break; } } @@ -167,7 +167,7 @@ if ($action == 'specimen') { $module = new $classname($db); if ($module->write_file($object, $langs) > 0) { - header("Location: " . DOL_URL_ROOT . "/document.php?modulepart=bank&file=SPECIMEN.pdf"); + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf"); return; } else { @@ -214,13 +214,13 @@ elseif ($action == 'setdoc') { */ $form = new Form($db); -$formother=new FormOther($db); +$formother = new FormOther($db); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader("", $langs->trans("BankSetupModule")); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup'); print ''; @@ -235,10 +235,10 @@ print load_fiche_titre($langs->trans("BankOrderShow"), '', ''); print '
    '; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
    '.$langs->trans("ActionsEvents").''.$langs->trans("All").'/'.$langs->trans("None").''.$langs->trans("All").'/'.$langs->trans("None").'
    '.$trigger['code'].''.$trigger['label'].''; - $key='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; - $value=$conf->global->$key; - print ''; + $key = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; + $value = $conf->global->$key; + print ''; print '
    '; print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; print ''; print "\n"; @@ -254,7 +254,7 @@ $i = 0; $nbofbank = count($bankorder); while ($i < $nbofbank) { print ''; - print ''; print ''; } else { - print ''; } print ''; - print '' . "\n"; + print ''."\n"; $i++; } -print '
    ' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Example") . '' . $langs->trans("Status") . ''.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").' 
    ' . $bankorder[$i][0] . "\n"; + print ''.$bankorder[$i][0]."\n"; print $bankorder[$i][1]; print ''; @@ -272,16 +272,16 @@ while ($i < $nbofbank) { print ''; + print ''; print img_picto($langs->trans("Disabled"), 'off'); print ' 
    ' . "\n"; +print '
    '."\n"; print '

    '; @@ -296,9 +296,9 @@ print load_fiche_titre($langs->trans("BankAccountModelModule"), '', ''); // Load array def with activated templates $def = array(); $sql = "SELECT nom"; -$sql .= " FROM " . MAIN_DB_PREFIX . "document_model"; -$sql .= " WHERE type = '" . $type . "'"; -$sql .= " AND entity = " . $conf->entity; +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { $i = 0; @@ -315,19 +315,19 @@ else { print "\n"; print "\n"; -print ''; -print ''; -print '\n"; -print '\n"; -print ''; -print ''; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; +print ''; print "\n"; clearstatcache(); foreach ($dirmodels as $reldir) { foreach (array('', '/doc') as $valdir) { - $dir = dol_buildpath($reldir . "core/modules/bank" . $valdir); + $dir = dol_buildpath($reldir."core/modules/bank".$valdir); if (is_dir($dir)) { $handle = opendir($dir); @@ -340,11 +340,11 @@ foreach ($dirmodels as $reldir) { foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir . '/' . $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir . '/' . $file; + require_once $dir.'/'.$file; $module = new $classname($db); $modulequalified = 1; @@ -365,15 +365,15 @@ foreach ($dirmodels as $reldir) { // Active if (in_array($name, $def)) { - print ''; } else { - print '"; } @@ -383,21 +383,21 @@ foreach ($dirmodels as $reldir) { print img_picto($langs->trans("Default"), 'on'); } else { - print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; } print ''; // Info - $htmltooltip = '' . $langs->trans("Name") . ': ' . $module->name; - $htmltooltip .= '
    ' . $langs->trans("Type") . ': ' . ($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
    '.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip .= '
    ' . $langs->trans("Width") . '/' . $langs->trans("Height") . ': ' . $module->page_largeur . '/' . $module->page_hauteur; + $htmltooltip .= '
    '.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } - $htmltooltip .= '

    ' . $langs->trans("FeaturesSupported") . ':'; - $htmltooltip .= '
    ' . $langs->trans("Logo") . ': ' . yn($module->option_logo, 1, 1); + $htmltooltip .= '

    '.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
    '.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); //$htmltooltip .= '
    ' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); //$htmltooltip .= '
    ' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); - $htmltooltip .= '
    ' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, 1, 1); + $htmltooltip .= '
    '.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); // $htmltooltip.='
    '.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); // $htmltooltip.='
    '.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); //$htmltooltip .= '
    ' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); @@ -409,7 +409,7 @@ foreach ($dirmodels as $reldir) { // Preview print ''; @@ -1509,13 +1509,13 @@ if ($id > 0) print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1622,7 +1622,7 @@ if ($id > 0) print '
    ' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Status") . "' . $langs->trans("Default") . "' . $langs->trans("ShortInfo") . '' . $langs->trans("Preview") . ''.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
    ' . "\n"; - print ''; + print ''."\n"; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print '' . "\n"; - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'; if ($module->type == 'pdf') { - print '' . img_object($langs->trans("Preview"), 'bill') . ''; + print ''.img_object($langs->trans("Preview"), 'bill').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); @@ -433,7 +433,7 @@ print '

    '; print load_fiche_titre($langs->trans("BankColorizeMovement"), '', ''); print ''; print "\n"; -print ''; +print ''; print ''."\n"; print "\n"; @@ -442,28 +442,28 @@ print $langs->trans('BankColorizeMovementDesc'); print ""; // Active if ($conf->global->BANK_COLORIZE_MOVEMENT) { - print ''; } else { - print '"; } print "\n"; -if(! empty($conf->global->BANK_COLORIZE_MOVEMENT)) +if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) { - $i=1; + $i = 1; while ($i <= 2) { - $key=$i; - $color='BANK_COLORIZE_MOVEMENT_COLOR'.$key; + $key = $i; + $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key; print ''; @@ -471,7 +471,7 @@ if(! empty($conf->global->BANK_COLORIZE_MOVEMENT)) print '"; // Color print ''; print ""; $i++; @@ -491,9 +491,9 @@ print load_fiche_titre($langs->trans("Other"), '', ''); print "
    ' . $langs->trans("Name") . ''.$langs->trans("Name").''.$langs->trans("Value").'
    ' . "\n"; - print ''; + print ''."\n"; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print '' . "\n"; - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print ''."\n"; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; print "
    '.$langs->trans("BankColorizeMovementName".$key)."'; - print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key)?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key):$conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); + print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); print '
    \n"; print "\n"; -print ''; -print ''; -print '\n"; +print ''; +print ''; +print '\n"; print "\n"; print ''; // Active if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { - print ''; } else { - print '"; } diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index a531a9c870c..80bb04f4852 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","other","agenda")); +$langs->loadLangs(array("admin", "other", "agenda")); if (!$user->admin) accessforbidden(); @@ -37,7 +37,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); -$arrayofparameters=array( +$arrayofparameters = array( 'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1), 'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2), 'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1), @@ -60,14 +60,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; llxHeader('', $langs->trans("DAVSetup"), $wikihelp); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("DAVSetup"), $linkback, 'title_setup'); print ''; print ''; -$head=dav_admin_prepare_head(); +$head = dav_admin_prepare_head(); dol_fiche_head($head, 'webdav', '', -1, 'action'); @@ -80,7 +80,7 @@ if ($action == 'edit') print '
    ' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Status") . "'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."
    '; @@ -503,16 +503,16 @@ print $langs->trans('AutoReportLastAccountStatement'); print '' . "\n"; - print ''; + print ''."\n"; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print '' . "\n"; - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print ''."\n"; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; print "
    '; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) continue; @@ -100,7 +100,7 @@ if ($action == 'edit') } else { - print ''; + print ''; } print ''; } @@ -119,7 +119,7 @@ else print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; print "\n"; // Load array of available notifications -$notificationtrigger=new InterfaceNotification($db); -$listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); +$notificationtrigger = new InterfaceNotification($db); +$listofnotifiedevents = $notificationtrigger->getListOfManagedEvents(); -foreach($listofnotifiedevents as $notifiedevent) +foreach ($listofnotifiedevents as $notifiedevent) { - $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; + $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); // Special cases @@ -226,35 +226,35 @@ foreach($listofnotifiedevents as $notifiedevent) print ''; print ''; print ''; // Show prof id in address into pdf -for($i=1; $i<=6; $i++) +for ($i = 1; $i <= 6; $i++) { - if (! $noCountryCode) + if (!$noCountryCode) { - $pid=$langs->transcountry("ProfId".$i, $mysoc->country_code); - if ($pid == '-') $pid=false; + $pid = $langs->transcountry("ProfId".$i, $mysoc->country_code); + if ($pid == '-') $pid = false; } else { @@ -194,7 +194,7 @@ for($i=1; $i<=6; $i++) { print ''; } } @@ -207,32 +207,32 @@ print '
    '; // Localtaxes -$locales =''; -$text=''; +$locales = ''; +$text = ''; if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) { if ($mysoc->useLocalTax(1)) { $locales = $langs->transcountry("LT1", $mysoc->country_code); - $text =''; } if ($mysoc->useLocalTax(2)) { - $locales.=($locales?' & ':'').$langs->transcountry("LT2", $mysoc->country_code); + $locales .= ($locales ? ' & ' : '').$langs->transcountry("LT2", $mysoc->country_code); - $text.= ''; + $text .= ''; } } $title = $langs->trans("PDFRulesForSalesTax"); if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) { - $title.=' - '.$langs->trans("PDFLocaltax", $locales); + $title .= ' - '.$langs->trans("PDFLocaltax", $locales); } print load_fiche_titre($title, '', ''); @@ -243,7 +243,7 @@ print ''; // Locataxes @@ -263,31 +263,31 @@ print ''; //Ref print ''; //Details print ''; //Invert sender and recipient print ''; // Place customer adress to the ISO location print ''; @@ -317,9 +317,9 @@ print "\n"; print ''."\n"; print ''."\n"; print ''; foreach ($arrayhandler as $key => $module) { // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) @@ -265,9 +265,9 @@ foreach ($arrayhandler as $key => $module) // Show example of numbering module print ''."\n"; @@ -288,7 +288,7 @@ print ''; //if($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK == 1) // Patter for Password Perso -if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ +if ($conf->global->USER_PASSWORD_GENERATED == "Perso") { $tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN); print '
    '; print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); @@ -166,22 +166,22 @@ print "
    "; // Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current // Show message -$message=''; -$url=''.$urlwithroot.'/dav/fileserver.php'; -$message.=img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV', $url); -$message.='
    '; -if (! empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) +$message = ''; +$url = ''.$urlwithroot.'/dav/fileserver.php'; +$message .= img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV', $url); +$message .= '
    '; +if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) { - $urlEntity = (! empty($conf->multicompany->enabled)?'?entity='.$conf->entity:''); - $url=''.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.''; - $message.=img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV public', $url); - $message.='
    '; + $urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : ''); + $url = ''.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.''; + $message .= img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV public', $url); + $message .= '
    '; } print $message; diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index f4922a33bbb..ae383242b11 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -36,12 +36,12 @@ $langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'error if (!$user->admin) accessforbidden(); -$id=GETPOST('rowid', 'int'); -$action=GETPOST('action', 'alpha'); +$id = GETPOST('rowid', 'int'); +$action = GETPOST('action', 'alpha'); -$mode = GETPOST('mode', 'aZ09')?GETPOST('mode', 'aZ09'):'createform'; // 'createform', 'filters', 'sortorder', 'focus' +$mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'createform'; // 'createform', 'filters', 'sortorder', 'focus' -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -49,32 +49,32 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='page,param'; -if (! $sortorder) $sortorder='ASC'; +if (!$sortfield) $sortfield = 'page,param'; +if (!$sortorder) $sortorder = 'ASC'; $defaulturl = GETPOST('defaulturl'); $defaultkey = GETPOST('defaultkey', 'alpha'); $defaultvalue = GETPOST('defaultvalue'); -$defaulturl=preg_replace('/^\//', '', $defaulturl); +$defaulturl = preg_replace('/^\//', '', $defaulturl); $urlpage = GETPOST('urlpage'); $key = GETPOST('key'); $value = GETPOST('value'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('admindefaultvalues','globaladmin')); +$hookmanager->initHooks(array('admindefaultvalues', 'globaladmin')); /* * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -82,11 +82,11 @@ 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 { - $defaulturl=''; - $defaultkey=''; - $defaultvalue=''; - $toselect=''; - $search_array_options=array(); + $defaulturl = ''; + $defaultkey = ''; + $defaultvalue = ''; + $toselect = ''; + $search_array_options = array(); } if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') @@ -97,7 +97,7 @@ if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) { - $error=0; + $error = 0; if (($action == 'add' || (GETPOST('add') && $action != 'update'))) { @@ -126,7 +126,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac } } - if (! $error) + if (!$error) { $db->begin(); @@ -137,7 +137,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac if (GETPOST('actionmodify')) { $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; - $sql.= " WHERE rowid = ".$id; + $sql .= " WHERE rowid = ".$id; } $result = $db->query($sql); @@ -145,16 +145,16 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac { $db->commit(); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $action=""; - $defaulturl=''; - $defaultkey=''; - $defaultvalue=''; + $action = ""; + $defaulturl = ''; + $defaultkey = ''; + $defaultvalue = ''; } else { $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); - $action=''; + $action = ''; } } } @@ -181,28 +181,28 @@ if ($action == 'delete') * View */ -$form=new Form($db); +$form = new Form($db); $formadmin = new FormAdmin($db); -$wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración'; +$wikihelp = 'EN:Setup|FR:Paramétrage|ES:Configuración'; llxHeader('', $langs->trans("Setup"), $wikihelp); -$param='&mode='.$mode; +$param = '&mode='.$mode; -$enabledisablehtml.= $langs->trans("EnableDefaultValues").' '; +$enabledisablehtml .= $langs->trans("EnableDefaultValues").' '; if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { // Button off, click to enable - $enabledisablehtml.= ''; - $enabledisablehtml.= img_picto($langs->trans("Disabled"), 'switch_off'); - $enabledisablehtml.= ''; + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); + $enabledisablehtml .= ''; } else { // Button on, click to disable - $enabledisablehtml.= ''; - $enabledisablehtml.= img_picto($langs->trans("Activated"), 'switch_on'); - $enabledisablehtml.= ''; + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); + $enabledisablehtml .= ''; } print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'title_setup'); @@ -210,15 +210,15 @@ print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'titl print ''.$langs->trans("DefaultValuesDesc")."
    \n"; print "
    \n"; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($optioncss != '') $param.='&optioncss='.$optioncss; -if ($defaulturl) $param.='&defaulturl='.urlencode($defaulturl); -if ($defaultkey) $param.='&defaultkey='.urlencode($defaultkey); -if ($defaultvalue) $param.='&defaultvalue='.urlencode($defaultvalue); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($optioncss != '') $param .= '&optioncss='.$optioncss; +if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl); +if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey); +if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue); -print 'entity) && $debug)?'?debug=1':'').'" method="POST">'; +print 'entity) && $debug) ? '?debug=1' : '').'" method="POST">'; if ($optioncss != '') print ''; print ''; print ''; @@ -227,7 +227,7 @@ print ''; print ''; print ''; -$head=defaultvalues_prepare_head(); +$head = defaultvalues_prepare_head(); dol_fiche_head($head, $mode, '', -1, ''); @@ -248,22 +248,22 @@ print '
    '; print ''; print ''; // Page -$texthelp=$langs->trans("PageUrlForDefaultValues"); -if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2'); -else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2'); -$texthelp.='

    '.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate"); -$texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); +$texthelp = $langs->trans("PageUrlForDefaultValues"); +if ($mode == 'createform') $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2'); +else $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2'); +$texthelp .= '

    '.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate"); +$texturl = $form->textwithpicto($langs->trans("Url"), $texthelp); print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder); // Field -$texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField"); +$texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField"); if ($mode != 'sortorder') { - $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); + $textkey = $form->textwithpicto($langs->trans("Field"), $texthelp); } else { - $texthelp='field or alias.field'; - $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); + $texthelp = 'field or alias.field'; + $textkey = $form->textwithpicto($langs->trans("Field"), $texthelp); } print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder); // Value @@ -271,24 +271,24 @@ if ($mode != 'focus' && $mode != 'mandatory') { if ($mode != 'sortorder') { - $substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount')); // Must match list into GETPOST + $substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST unset($substitutionarray['__USER_SIGNATURE__']); - $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
    '; - foreach($substitutionarray as $key => $val) + $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
    '; + foreach ($substitutionarray as $key => $val) { - $texthelp.=$key.' -> '.$val.'
    '; + $texthelp .= $key.' -> '.$val.'
    '; } - $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip'); + $textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip'); } else { - $texthelp='ASC or DESC'; - $textvalue=$form->textwithpicto($langs->trans("SortOrder"), $texthelp); + $texthelp = 'ASC or DESC'; + $textvalue = $form->textwithpicto($langs->trans("SortOrder"), $texthelp); } print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); } // Entity -if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder); +if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder); else print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); // Actions print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); @@ -315,10 +315,10 @@ if ($mode != 'focus' && $mode != 'mandatory') print ''; } // Limit to superadmin -if (! empty($conf->multicompany->enabled) && !$user->entity) +if (!empty($conf->multicompany->enabled) && !$user->entity) { print ''; } else @@ -328,8 +328,8 @@ else print ''; } print '\n"; print ''; @@ -337,10 +337,10 @@ print ''; // Show constants $sql = "SELECT rowid, entity, type, page, param, value"; -$sql.= " FROM ".MAIN_DB_PREFIX."default_values"; -$sql.= " WHERE type = '".$db->escape($mode)."'"; -$sql.= " AND entity IN (".$user->entity.",".$conf->entity.")"; -$sql.= $db->order($sortfield, $sortorder); +$sql .= " FROM ".MAIN_DB_PREFIX."default_values"; +$sql .= " WHERE type = '".$db->escape($mode)."'"; +$sql .= " AND entity IN (".$user->entity.",".$conf->entity.")"; +$sql .= $db->order($sortfield, $sortorder); dol_syslog("translation::select from table", LOG_DEBUG); $result = $db->query($sql); @@ -389,15 +389,15 @@ if ($result) print ''; - $filterfound=0; + $filterfound = 0; foreach ($fieldlist as $field => $value) { if ($fieldlist[$field] == 'entity') continue; - $showfield=1; // By default + $showfield = 1; // By default - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } if ($showfield) { @@ -1283,7 +1283,7 @@ if ($id) print ''; @@ -1297,84 +1297,84 @@ if ($id) // Determines the name of the field in relation to the possible names // in data dictionaries - $showfield=1; // By defaut - $align="left"; - $cssprefix=''; - $sortable=1; - $valuetoshow=ucfirst($fieldlist[$field]); // By defaut - $valuetoshow=$langs->trans($valuetoshow); // try to translate + $showfield = 1; // By defaut + $align = "left"; + $cssprefix = ''; + $sortable = 1; + $valuetoshow = ucfirst($fieldlist[$field]); // By defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate // Special cases - if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } - if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } - if ($fieldlist[$field]=='taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); - else $valuetoshow=$langs->trans("Amount"); - $align='center'; + if ($fieldlist[$field] == 'source') { $valuetoshow = $langs->trans("Contact"); } + if ($fieldlist[$field] == 'price') { $valuetoshow = $langs->trans("PriceUHT"); } + if ($fieldlist[$field] == 'taux') { + if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow = $langs->trans("Rate"); + else $valuetoshow = $langs->trans("Amount"); + $align = 'center'; } - if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } - if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } - if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } - if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='position') { $align='right'; } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } - if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments"); } - if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); } - if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; } - if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } - if ($fieldlist[$field]=='type_cdr') { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; } - if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } - if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx') { $valuetoshow=$langs->trans("Width"); } - if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny') { $valuetoshow=$langs->trans("Height"); } - if ($fieldlist[$field]=='unit' || $fieldlist[$field]=='metric') { $valuetoshow=$langs->trans("MeasuringUnit"); } - if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); } - if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; } - if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; } - if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } - if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountsparent"); } - if ($fieldlist[$field]=='pcg_type') { $valuetoshow=$langs->trans("Pcg_type"); } - if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } - if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); } - if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); } - if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } - if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } - if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } - if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); } - if ($fieldlist[$field]=='paper_size') { $valuetoshow=$langs->trans("PaperSize"); } - if ($fieldlist[$field]=='orientation') { $valuetoshow=$langs->trans("Orientation"); } - if ($fieldlist[$field]=='leftmargin') { $valuetoshow=$langs->trans("LeftMargin"); } - if ($fieldlist[$field]=='topmargin') { $valuetoshow=$langs->trans("TopMargin"); } - if ($fieldlist[$field]=='spacex') { $valuetoshow=$langs->trans("SpaceX"); } - if ($fieldlist[$field]=='spacey') { $valuetoshow=$langs->trans("SpaceY"); } - if ($fieldlist[$field]=='font_size') { $valuetoshow=$langs->trans("FontSize"); } - if ($fieldlist[$field]=='custom_x') { $valuetoshow=$langs->trans("CustomX"); } - if ($fieldlist[$field]=='custom_y') { $valuetoshow=$langs->trans("CustomY"); } - if ($fieldlist[$field]=='percent') { $valuetoshow=$langs->trans("Percentage"); } - if ($fieldlist[$field]=='affect') { $valuetoshow=$langs->trans("WithCounter"); } - if ($fieldlist[$field]=='delay') { $valuetoshow=$langs->trans("NoticePeriod"); } - if ($fieldlist[$field]=='newbymonth') { $valuetoshow=$langs->trans("NewByMonth"); } - if ($fieldlist[$field]=='fk_tva') { $valuetoshow=$langs->trans("VAT"); } - if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); } - if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); } - if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); } - if ($fieldlist[$field]=='use_default') { $valuetoshow=$langs->trans('Default'); } + if ($fieldlist[$field] == 'localtax1_type') { $valuetoshow = $langs->trans("UseLocalTax")." 2"; $align = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'localtax1') { $valuetoshow = $langs->trans("Rate")." 2"; $align = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'localtax2_type') { $valuetoshow = $langs->trans("UseLocalTax")." 3"; $align = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'localtax2') { $valuetoshow = $langs->trans("Rate")." 3"; $align = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'organization') { $valuetoshow = $langs->trans("Organization"); } + if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } + if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } + if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); } + if ($fieldlist[$field] == 'position') { $align = 'right'; } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Label"); } + if ($fieldlist[$field] == 'libelle_facture') { $valuetoshow = $langs->trans("LabelOnDocuments"); } + if ($fieldlist[$field] == 'country') { $valuetoshow = $langs->trans("Country"); } + if ($fieldlist[$field] == 'recuperableonly') { $valuetoshow = $langs->trans("NPR"); $align = "center"; } + if ($fieldlist[$field] == 'nbjour') { $valuetoshow = $langs->trans("NbOfDays"); } + if ($fieldlist[$field] == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $align = "center"; } + if ($fieldlist[$field] == 'decalage') { $valuetoshow = $langs->trans("Offset"); } + if ($fieldlist[$field] == 'width' || $fieldlist[$field] == 'nx') { $valuetoshow = $langs->trans("Width"); } + if ($fieldlist[$field] == 'height' || $fieldlist[$field] == 'ny') { $valuetoshow = $langs->trans("Height"); } + if ($fieldlist[$field] == 'unit' || $fieldlist[$field] == 'metric') { $valuetoshow = $langs->trans("MeasuringUnit"); } + if ($fieldlist[$field] == 'accountancy_code') { $valuetoshow = $langs->trans("AccountancyCode"); } + if ($fieldlist[$field] == 'accountancy_code_sell') { $valuetoshow = $langs->trans("AccountancyCodeSell"); $sortable = 0; } + if ($fieldlist[$field] == 'accountancy_code_buy') { $valuetoshow = $langs->trans("AccountancyCodeBuy"); $sortable = 0; } + if ($fieldlist[$field] == 'fk_pcg_version') { $valuetoshow = $langs->trans("Pcg_version"); } + if ($fieldlist[$field] == 'account_parent') { $valuetoshow = $langs->trans("Accountsparent"); } + if ($fieldlist[$field] == 'pcg_type') { $valuetoshow = $langs->trans("Pcg_type"); } + if ($fieldlist[$field] == 'pcg_subtype') { $valuetoshow = $langs->trans("Pcg_subtype"); } + if ($fieldlist[$field] == 'sortorder') { $valuetoshow = $langs->trans("SortOrder"); } + if ($fieldlist[$field] == 'short_label') { $valuetoshow = $langs->trans("ShortLabel"); } + if ($fieldlist[$field] == 'range_account') { $valuetoshow = $langs->trans("Range"); } + if ($fieldlist[$field] == 'sens') { $valuetoshow = $langs->trans("Sens"); } + if ($fieldlist[$field] == 'category_type') { $valuetoshow = $langs->trans("Calculated"); } + if ($fieldlist[$field] == 'formula') { $valuetoshow = $langs->trans("Formula"); } + if ($fieldlist[$field] == 'paper_size') { $valuetoshow = $langs->trans("PaperSize"); } + if ($fieldlist[$field] == 'orientation') { $valuetoshow = $langs->trans("Orientation"); } + if ($fieldlist[$field] == 'leftmargin') { $valuetoshow = $langs->trans("LeftMargin"); } + if ($fieldlist[$field] == 'topmargin') { $valuetoshow = $langs->trans("TopMargin"); } + if ($fieldlist[$field] == 'spacex') { $valuetoshow = $langs->trans("SpaceX"); } + if ($fieldlist[$field] == 'spacey') { $valuetoshow = $langs->trans("SpaceY"); } + if ($fieldlist[$field] == 'font_size') { $valuetoshow = $langs->trans("FontSize"); } + if ($fieldlist[$field] == 'custom_x') { $valuetoshow = $langs->trans("CustomX"); } + if ($fieldlist[$field] == 'custom_y') { $valuetoshow = $langs->trans("CustomY"); } + if ($fieldlist[$field] == 'percent') { $valuetoshow = $langs->trans("Percentage"); } + if ($fieldlist[$field] == 'affect') { $valuetoshow = $langs->trans("WithCounter"); } + if ($fieldlist[$field] == 'delay') { $valuetoshow = $langs->trans("NoticePeriod"); } + if ($fieldlist[$field] == 'newbymonth') { $valuetoshow = $langs->trans("NewByMonth"); } + if ($fieldlist[$field] == 'fk_tva') { $valuetoshow = $langs->trans("VAT"); } + if ($fieldlist[$field] == 'range_ik') { $valuetoshow = $langs->trans("RangeIk"); } + if ($fieldlist[$field] == 'fk_c_exp_tax_cat') { $valuetoshow = $langs->trans("CarCategory"); } + if ($fieldlist[$field] == 'revenuestamp_type') { $valuetoshow = $langs->trans('TypeOfRevenueStamp'); } + if ($fieldlist[$field] == 'use_default') { $valuetoshow = $langs->trans('Default'); } - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } // Show field title if ($showfield) { - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder, $cssprefix); + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder, $cssprefix); } } // Favorite - Only activated on country dictionary - if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder); + if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); - print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder); + print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print ''; @@ -1387,12 +1387,12 @@ if ($id) $obj = $db->fetch_object($resql); //print_r($obj); print ''; - if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) + if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) { - $tmpaction='edit'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $tmpaction = 'edit'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; // Show fields if (empty($reshook)) { @@ -1400,10 +1400,10 @@ if ($id) } print ''; } @@ -1635,34 +1635,34 @@ if ($id) // Can an entry be erased or disabled ? // all true by default - $iserasable=1; - $canbedisabled=1; - $canbemodified=1; + $iserasable = 1; + $canbedisabled = 1; + $canbemodified = 1; if (isset($obj->code) && $id != 10) { if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; } elseif ($obj->code == 'RECEP') { $iserasable = 0; $canbedisabled = 0; } - elseif ($obj->code == 'EF0') { $iserasable = 0; $canbedisabled = 0; } + elseif ($obj->code == 'EF0') { $iserasable = 0; $canbedisabled = 0; } } if ($id == 25 && in_array($obj->code, array('banner', 'blogpost', 'other', 'page'))) { $iserasable = 0; $canbedisabled = 0; if (in_array($obj->code, array('banner'))) $canbedisabled = 1; } - if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable=0; } - if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled=0; $canbedisabled = 0; } - $canbemodified=$iserasable; - if ($obj->code == 'RECEP') $canbemodified=1; - if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm") $canbemodified=1; + if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable = 0; } + if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled = 0; $canbedisabled = 0; } + $canbemodified = $iserasable; + if ($obj->code == 'RECEP') $canbemodified = 1; + if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm") $canbemodified = 1; // Build Url. The table is id=, the id of line is rowid= - $rowidcol=$tabrowid[$id]; + $rowidcol = $tabrowid[$id]; // If rowidcol not defined - if (empty($rowidcol) || in_array($id, array(6,7,8,13,17,19,27,32))) $rowidcol='rowid'; - $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((! empty($obj->{$rowidcol}) || $obj->{$rowidcol} == '0')?$obj->{$rowidcol}:(! empty($obj->code)?urlencode($obj->code):'')).'&code='.(! empty($obj->code)?urlencode($obj->code):''); - if (! empty($param)) $url .= '&'.$param; - if (! is_null($withentity)) $url .= '&entity='.$withentity; - $url.='&'; + if (empty($rowidcol) || in_array($id, array(6, 7, 8, 13, 17, 19, 27, 32))) $rowidcol = 'rowid'; + $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((!empty($obj->{$rowidcol}) || $obj->{$rowidcol} == '0') ? $obj->{$rowidcol}:(!empty($obj->code) ?urlencode($obj->code) : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); + if (!empty($param)) $url .= '&'.$param; + if (!is_null($withentity)) $url .= '&entity='.$withentity; + $url .= '&'; // Favorite // Only activated on country dictionary @@ -1679,9 +1679,9 @@ if ($id) if ($canbedisabled) print ''.$actl[$obj->active].''; else { - if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive"); + if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO'))) print $langs->trans("AlwaysActive"); elseif (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated"); - elseif (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption"); + elseif (isset($obj->type) && in_array($obj->type, array('system')) && !empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption"); else print $langs->trans("AlwaysActive"); } print ""; @@ -1721,7 +1721,7 @@ else * Show list of dictionary to show */ - $lastlineisempty=false; + $lastlineisempty = false; print '
    '; print '
    '; - print ''; // We see environment, but to change it we must switch on other entity + print ''; // We see environment, but to change it we must switch on other entity print ''; -$disabled=''; -if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled=' disabled="disabled"'; +$disabled = ''; +if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled = ' disabled="disabled"'; print ''; print "
    '; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) { - print ''.img_edit().''; + print ''.img_edit().''; print '   '; - print ''.img_delete().''; + print ''.img_delete().''; } else { print ''; print ''; - print '
    '; + print '
    '; print ''; print ''; } diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 23a9aa4b3b1..ec494d5a812 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -30,11 +30,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->load("admin"); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); -$modules=array( +$modules = array( 'agenda' => array( array( 'code' => 'MAIN_DELAY_ACTIONS_TODO', @@ -137,11 +137,11 @@ $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs-> if ($action == 'update') { - foreach($modules as $module => $delays) + foreach ($modules as $module => $delays) { - if (! empty($conf->$module->enabled)) + if (!empty($conf->$module->enabled)) { - foreach($delays as $delay) + foreach ($delays as $delay) { if (GETPOST($delay['code']) != '') { @@ -155,11 +155,11 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity); // For update value with percentage - $plus=''; - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; + $plus = ''; + if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; // Update values - for($i=0; $i<4; $i++) { - if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); + for ($i = 0; $i < 4; $i++) { + if (isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); } } @@ -178,7 +178,7 @@ print ''.$langs->transnoentities("DelaysOfToleranceD print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."
    \n"; print "
    \n"; -$countrynotdefined=''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = ''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($action == 'edit') { @@ -189,13 +189,13 @@ if ($action == 'edit') print ''; print ''; - foreach($modules as $module => $delays) + foreach ($modules as $module => $delays) { - if (! empty($conf->$module->enabled)) + if (!empty($conf->$module->enabled)) { - foreach($delays as $delay) + foreach ($delays as $delay) { - $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); + $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); print ''; print ''; print ''; print ''; print '
    '.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
    '.img_object('', $delay['img']).''.$langs->trans('Delays_'.$delay['code']).''; @@ -214,7 +214,7 @@ if ($action == 'edit') print '
    '.$langs->trans("MAIN_DISABLE_METEO").''; - print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO)?0:$conf->global->MAIN_DISABLE_METEO)); + print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO)); print '
    '; @@ -228,13 +228,13 @@ else print ''; print ''; - foreach($modules as $module => $delays) + foreach ($modules as $module => $delays) { - if (! empty($conf->$module->enabled)) + if (!empty($conf->$module->enabled)) { - foreach($delays as $delay) + foreach ($delays as $delay) { - $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); + $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); print ''; print ''; print ''; @@ -264,30 +264,30 @@ print '
    '; // Show logo for weather print ''.$langs->trans("DescWeather").' '; -if($action == 'edit') { +if ($action == 'edit') { $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod')); $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod')); - if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; + if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; else $str_mode_enabled = $str_mode_percentage; print ''.$str_mode_enabled.''; print ''; print '

    '; } else { - if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled'); + if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled'); else print $langs->trans('MeteoPercentageModEnabled'); print '

    '; } -$offset=0; -$cursor=10; // By default +$offset = 0; +$cursor = 10; // By default //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET; //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP; -$level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0; -$level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1; -$level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; -$level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; -$text=''; $options='class="valignmiddle" height="60px"'; +$level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) $level0 = $conf->global->MAIN_METEO_LEVEL0; +$level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) $level1 = $conf->global->MAIN_METEO_LEVEL1; +$level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) $level2 = $conf->global->MAIN_METEO_LEVEL2; +$level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) $level3 = $conf->global->MAIN_METEO_LEVEL3; +$text = ''; $options = 'class="valignmiddle" height="60px"'; if ($action == 'edit') { @@ -361,7 +361,7 @@ if ($action == 'edit') { global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { print '
    '; print '
    '; print img_weather($text, 0, $options); @@ -404,7 +404,7 @@ if ($action == 'edit') { print '
    '; -if($action == 'edit') { +if ($action == 'edit') { print '
    '; print '
    '; } else { diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 8254c5931b8..bc0f57d40fb 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -43,35 +43,35 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("errors","admin","main","companies","resource","holiday","accountancy","hrm","orders","contracts","projects","propal","bills","interventions")); +$langs->loadLangs(array("errors", "admin", "main", "companies", "resource", "holiday", "accountancy", "hrm", "orders", "contracts", "projects", "propal", "bills", "interventions")); -$action=GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view'; -$confirm=GETPOST('confirm', 'alpha'); -$id=GETPOST('id', 'int'); -$rowid=GETPOST('rowid', 'alpha'); -$entity=GETPOST('entity', 'int'); -$code=GETPOST('code', 'alpha'); +$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; +$confirm = GETPOST('confirm', 'alpha'); +$id = GETPOST('id', 'int'); +$rowid = GETPOST('rowid', 'alpha'); +$entity = GETPOST('entity', 'int'); +$code = GETPOST('code', 'alpha'); -$allowed=$user->admin; -if ($id == 7 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Tax page allowed to manager of chart account -if ($id == 10 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Vat page allowed to manager of chart account -if ($id == 17 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Dictionary with type of expense report and accounting account allowed to manager of chart account -if (! $allowed) accessforbidden(); +$allowed = $user->admin; +if ($id == 7 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Tax page allowed to manager of chart account +if ($id == 10 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Vat page allowed to manager of chart account +if ($id == 17 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Dictionary with type of expense report and accounting account allowed to manager of chart account +if (!$allowed) accessforbidden(); $acts[0] = "activate"; $acts[1] = "disable"; $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off'); $actl[1] = img_picto($langs->trans("Activated"), 'switch_on'); -$listoffset=GETPOST('listoffset'); -$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; // To avoid too long dictionaries +$listoffset = GETPOST('listoffset'); +$listlimit = GETPOST('listlimit') > 0 ?GETPOST('listlimit') : 1000; // To avoid too long dictionaries $active = 1; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $listlimit * $page ; +$offset = $listlimit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -89,10 +89,10 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,27,38,0,5,11,0,32,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,37,0,25,0); +$taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 27, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 0, 15, 30, 0, 37, 0, 25, 0); // Name of SQL tables of dictionaries -$tabname=array(); +$tabname = array(); $tabname[1] = MAIN_DB_PREFIX."c_forme_juridique"; $tabname[2] = MAIN_DB_PREFIX."c_departements"; $tabname[3] = MAIN_DB_PREFIX."c_regions"; @@ -102,39 +102,39 @@ $tabname[6] = MAIN_DB_PREFIX."c_actioncomm"; $tabname[7] = MAIN_DB_PREFIX."c_chargesociales"; $tabname[8] = MAIN_DB_PREFIX."c_typent"; $tabname[9] = MAIN_DB_PREFIX."c_currencies"; -$tabname[10]= MAIN_DB_PREFIX."c_tva"; -$tabname[11]= MAIN_DB_PREFIX."c_type_contact"; -$tabname[12]= MAIN_DB_PREFIX."c_payment_term"; -$tabname[13]= MAIN_DB_PREFIX."c_paiement"; -$tabname[14]= MAIN_DB_PREFIX."c_ecotaxe"; -$tabname[15]= MAIN_DB_PREFIX."c_paper_format"; -$tabname[16]= MAIN_DB_PREFIX."c_prospectlevel"; -$tabname[17]= MAIN_DB_PREFIX."c_type_fees"; -$tabname[18]= MAIN_DB_PREFIX."c_shipment_mode"; -$tabname[19]= MAIN_DB_PREFIX."c_effectif"; -$tabname[20]= MAIN_DB_PREFIX."c_input_method"; -$tabname[21]= MAIN_DB_PREFIX."c_availability"; -$tabname[22]= MAIN_DB_PREFIX."c_input_reason"; -$tabname[23]= MAIN_DB_PREFIX."c_revenuestamp"; -$tabname[24]= MAIN_DB_PREFIX."c_type_resource"; -$tabname[25]= MAIN_DB_PREFIX."c_type_container"; +$tabname[10] = MAIN_DB_PREFIX."c_tva"; +$tabname[11] = MAIN_DB_PREFIX."c_type_contact"; +$tabname[12] = MAIN_DB_PREFIX."c_payment_term"; +$tabname[13] = MAIN_DB_PREFIX."c_paiement"; +$tabname[14] = MAIN_DB_PREFIX."c_ecotaxe"; +$tabname[15] = MAIN_DB_PREFIX."c_paper_format"; +$tabname[16] = MAIN_DB_PREFIX."c_prospectlevel"; +$tabname[17] = MAIN_DB_PREFIX."c_type_fees"; +$tabname[18] = MAIN_DB_PREFIX."c_shipment_mode"; +$tabname[19] = MAIN_DB_PREFIX."c_effectif"; +$tabname[20] = MAIN_DB_PREFIX."c_input_method"; +$tabname[21] = MAIN_DB_PREFIX."c_availability"; +$tabname[22] = MAIN_DB_PREFIX."c_input_reason"; +$tabname[23] = MAIN_DB_PREFIX."c_revenuestamp"; +$tabname[24] = MAIN_DB_PREFIX."c_type_resource"; +$tabname[25] = MAIN_DB_PREFIX."c_type_container"; //$tabname[26]= MAIN_DB_PREFIX."c_units"; -$tabname[27]= MAIN_DB_PREFIX."c_stcomm"; -$tabname[28]= MAIN_DB_PREFIX."c_holiday_types"; -$tabname[29]= MAIN_DB_PREFIX."c_lead_status"; -$tabname[30]= MAIN_DB_PREFIX."c_format_cards"; +$tabname[27] = MAIN_DB_PREFIX."c_stcomm"; +$tabname[28] = MAIN_DB_PREFIX."c_holiday_types"; +$tabname[29] = MAIN_DB_PREFIX."c_lead_status"; +$tabname[30] = MAIN_DB_PREFIX."c_format_cards"; //$tabname[31]= MAIN_DB_PREFIX."accounting_system"; -$tabname[32]= MAIN_DB_PREFIX."c_hrm_public_holiday"; -$tabname[33]= MAIN_DB_PREFIX."c_hrm_department"; -$tabname[34]= MAIN_DB_PREFIX."c_hrm_function"; +$tabname[32] = MAIN_DB_PREFIX."c_hrm_public_holiday"; +$tabname[33] = MAIN_DB_PREFIX."c_hrm_department"; +$tabname[34] = MAIN_DB_PREFIX."c_hrm_function"; -$tabname[35]= MAIN_DB_PREFIX."c_exp_tax_cat"; -$tabname[36]= MAIN_DB_PREFIX."c_exp_tax_range"; -$tabname[37]= MAIN_DB_PREFIX."c_units"; -$tabname[38]= MAIN_DB_PREFIX."c_socialnetworks"; +$tabname[35] = MAIN_DB_PREFIX."c_exp_tax_cat"; +$tabname[36] = MAIN_DB_PREFIX."c_exp_tax_range"; +$tabname[37] = MAIN_DB_PREFIX."c_units"; +$tabname[38] = MAIN_DB_PREFIX."c_socialnetworks"; // Dictionary labels -$tablib=array(); +$tablib = array(); $tablib[1] = "DictionaryCompanyJuridicalType"; $tablib[2] = "DictionaryCanton"; $tablib[3] = "DictionaryRegion"; @@ -144,38 +144,38 @@ $tablib[6] = "DictionaryActions"; $tablib[7] = "DictionarySocialContributions"; $tablib[8] = "DictionaryCompanyType"; $tablib[9] = "DictionaryCurrency"; -$tablib[10]= "DictionaryVAT"; -$tablib[11]= "DictionaryTypeContact"; -$tablib[12]= "DictionaryPaymentConditions"; -$tablib[13]= "DictionaryPaymentModes"; -$tablib[14]= "DictionaryEcotaxe"; -$tablib[15]= "DictionaryPaperFormat"; -$tablib[16]= "DictionaryProspectLevel"; -$tablib[17]= "DictionaryFees"; -$tablib[18]= "DictionarySendingMethods"; -$tablib[19]= "DictionaryStaff"; -$tablib[20]= "DictionaryOrderMethods"; -$tablib[21]= "DictionaryAvailability"; -$tablib[22]= "DictionarySource"; -$tablib[23]= "DictionaryRevenueStamp"; -$tablib[24]= "DictionaryResourceType"; -$tablib[25]= "DictionaryTypeOfContainer"; +$tablib[10] = "DictionaryVAT"; +$tablib[11] = "DictionaryTypeContact"; +$tablib[12] = "DictionaryPaymentConditions"; +$tablib[13] = "DictionaryPaymentModes"; +$tablib[14] = "DictionaryEcotaxe"; +$tablib[15] = "DictionaryPaperFormat"; +$tablib[16] = "DictionaryProspectLevel"; +$tablib[17] = "DictionaryFees"; +$tablib[18] = "DictionarySendingMethods"; +$tablib[19] = "DictionaryStaff"; +$tablib[20] = "DictionaryOrderMethods"; +$tablib[21] = "DictionaryAvailability"; +$tablib[22] = "DictionarySource"; +$tablib[23] = "DictionaryRevenueStamp"; +$tablib[24] = "DictionaryResourceType"; +$tablib[25] = "DictionaryTypeOfContainer"; //$tablib[26]= "DictionaryUnits"; -$tablib[27]= "DictionaryProspectStatus"; -$tablib[28]= "DictionaryHolidayTypes"; -$tablib[29]= "DictionaryOpportunityStatus"; -$tablib[30]= "DictionaryFormatCards"; +$tablib[27] = "DictionaryProspectStatus"; +$tablib[28] = "DictionaryHolidayTypes"; +$tablib[29] = "DictionaryOpportunityStatus"; +$tablib[30] = "DictionaryFormatCards"; //$tablib[31]= "DictionaryAccountancysystem"; -$tablib[32]= "DictionaryPublicHolidays"; -$tablib[33]= "DictionaryDepartment"; -$tablib[34]= "DictionaryFunction"; -$tablib[35]= "DictionaryExpenseTaxCat"; -$tablib[36]= "DictionaryExpenseTaxRange"; -$tablib[37]= "DictionaryMeasuringUnits"; -$tablib[38]= "DictionarySocialNetworks"; +$tablib[32] = "DictionaryPublicHolidays"; +$tablib[33] = "DictionaryDepartment"; +$tablib[34] = "DictionaryFunction"; +$tablib[35] = "DictionaryExpenseTaxCat"; +$tablib[36] = "DictionaryExpenseTaxRange"; +$tablib[37] = "DictionaryMeasuringUnits"; +$tablib[38] = "DictionarySocialNetworks"; // Requests to extract data -$tabsql=array(); +$tabsql = array(); $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid"; $tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1"; $tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1"; @@ -185,161 +185,161 @@ $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.t $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1"; $tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, c.code as country_code, c.label as country, t.position, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON t.fk_country=c.rowid"; $tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c"; -$tabsql[10]= "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; -$tabsql[11]= "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; -$tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = " . getEntity($tabname[12]); -$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = " . getEntity($tabname[13]); -$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.label, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1"; -$tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format"; -$tabsql[16]= "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel"; -$tabsql[17]= "SELECT id as rowid, code, label, accountancy_code, active FROM ".MAIN_DB_PREFIX."c_type_fees"; -$tabsql[18]= "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode"; -$tabsql[19]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif"; -$tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method"; -$tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c"; -$tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; -$tabsql[23]= "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; -$tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; -$tabsql[25]= "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity('c_type_container').")"; +$tabsql[10] = "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; +$tabsql[11] = "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; +$tabsql[12] = "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = ".getEntity($tabname[12]); +$tabsql[13] = "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = ".getEntity($tabname[13]); +$tabsql[14] = "SELECT e.rowid as rowid, e.code as code, e.label, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1"; +$tabsql[15] = "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format"; +$tabsql[16] = "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel"; +$tabsql[17] = "SELECT id as rowid, code, label, accountancy_code, active FROM ".MAIN_DB_PREFIX."c_type_fees"; +$tabsql[18] = "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode"; +$tabsql[19] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif"; +$tabsql[20] = "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method"; +$tabsql[21] = "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c"; +$tabsql[22] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; +$tabsql[23] = "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; +$tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; +$tabsql[25] = "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity('c_type_container').")"; //$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; -$tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; -$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; -$tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; -$tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; +$tabsql[27] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; +$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; +$tabsql[29] = "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; +$tabsql[30] = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; //$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s"; -$tabsql[32]= "SELECT a.id as rowid, a.entity, a.code, a.fk_country as country_id, c.code as country_code, c.label as country, a.dayrule, a.day, a.month, a.year, a.active FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday as a LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country=c.rowid AND c.active=1"; -$tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department"; -$tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; -$tabsql[35]= "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat c"; -$tabsql[36]= "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r"; -$tabsql[37]= "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r"; -$tabsql[38]= "SELECT rowid, entity, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; +$tabsql[32] = "SELECT a.id as rowid, a.entity, a.code, a.fk_country as country_id, c.code as country_code, c.label as country, a.dayrule, a.day, a.month, a.year, a.active FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday as a LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country=c.rowid AND c.active=1"; +$tabsql[33] = "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department"; +$tabsql[34] = "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; +$tabsql[35] = "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat c"; +$tabsql[36] = "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r"; +$tabsql[37] = "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r"; +$tabsql[38] = "SELECT rowid, entity, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; // Criteria to sort dictionaries -$tabsqlsort=array(); -$tabsqlsort[1] ="country ASC, code ASC"; -$tabsqlsort[2] ="country ASC, code ASC"; -$tabsqlsort[3] ="country ASC, code ASC"; -$tabsqlsort[4] ="code ASC"; -$tabsqlsort[5] ="label ASC"; -$tabsqlsort[6] ="a.type ASC, a.module ASC, a.position ASC, a.code ASC"; -$tabsqlsort[7] ="country ASC, code ASC, a.libelle ASC"; -$tabsqlsort[8] ="country DESC,".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?' t.position ASC,':'')." libelle ASC"; -$tabsqlsort[9] ="label ASC"; -$tabsqlsort[10]="country ASC, code ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC"; -$tabsqlsort[11]="t.element ASC, t.source ASC, t.position ASC, t.code ASC"; -$tabsqlsort[12]="sortorder ASC, code ASC"; -$tabsqlsort[13]="code ASC"; -$tabsqlsort[14]="country ASC, e.organization ASC, code ASC"; -$tabsqlsort[15]="rowid ASC"; -$tabsqlsort[16]="sortorder ASC"; -$tabsqlsort[17]="code ASC"; -$tabsqlsort[18]="code ASC, libelle ASC"; -$tabsqlsort[19]="id ASC"; -$tabsqlsort[20]="code ASC, libelle ASC"; -$tabsqlsort[21]="code ASC, label ASC"; -$tabsqlsort[22]="code ASC, label ASC"; -$tabsqlsort[23]="country ASC, taux ASC"; -$tabsqlsort[24]="code ASC, label ASC"; -$tabsqlsort[25]="t.module ASC, t.code ASC, t.label ASC"; +$tabsqlsort = array(); +$tabsqlsort[1] = "country ASC, code ASC"; +$tabsqlsort[2] = "country ASC, code ASC"; +$tabsqlsort[3] = "country ASC, code ASC"; +$tabsqlsort[4] = "code ASC"; +$tabsqlsort[5] = "label ASC"; +$tabsqlsort[6] = "a.type ASC, a.module ASC, a.position ASC, a.code ASC"; +$tabsqlsort[7] = "country ASC, code ASC, a.libelle ASC"; +$tabsqlsort[8] = "country DESC,".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ' t.position ASC,' : '')." libelle ASC"; +$tabsqlsort[9] = "label ASC"; +$tabsqlsort[10] = "country ASC, code ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC"; +$tabsqlsort[11] = "t.element ASC, t.source ASC, t.position ASC, t.code ASC"; +$tabsqlsort[12] = "sortorder ASC, code ASC"; +$tabsqlsort[13] = "code ASC"; +$tabsqlsort[14] = "country ASC, e.organization ASC, code ASC"; +$tabsqlsort[15] = "rowid ASC"; +$tabsqlsort[16] = "sortorder ASC"; +$tabsqlsort[17] = "code ASC"; +$tabsqlsort[18] = "code ASC, libelle ASC"; +$tabsqlsort[19] = "id ASC"; +$tabsqlsort[20] = "code ASC, libelle ASC"; +$tabsqlsort[21] = "code ASC, label ASC"; +$tabsqlsort[22] = "code ASC, label ASC"; +$tabsqlsort[23] = "country ASC, taux ASC"; +$tabsqlsort[24] = "code ASC, label ASC"; +$tabsqlsort[25] = "t.module ASC, t.code ASC, t.label ASC"; //$tabsqlsort[26]="code ASC"; -$tabsqlsort[27]="code ASC"; -$tabsqlsort[28]="country ASC, code ASC"; -$tabsqlsort[29]="position ASC"; -$tabsqlsort[30]="code ASC"; +$tabsqlsort[27] = "code ASC"; +$tabsqlsort[28] = "country ASC, code ASC"; +$tabsqlsort[29] = "position ASC"; +$tabsqlsort[30] = "code ASC"; //$tabsqlsort[31]="pcg_version ASC"; -$tabsqlsort[32]="country, year ASC, month ASC, day ASC"; -$tabsqlsort[33]="code ASC"; -$tabsqlsort[34]="code ASC"; -$tabsqlsort[35]="c.label ASC"; -$tabsqlsort[36]="r.fk_c_exp_tax_cat ASC, r.range_ik ASC"; -$tabsqlsort[37]="r.unit_type ASC, r.scale ASC, r.code ASC"; -$tabsqlsort[38]="rowid, code ASC"; +$tabsqlsort[32] = "country, year ASC, month ASC, day ASC"; +$tabsqlsort[33] = "code ASC"; +$tabsqlsort[34] = "code ASC"; +$tabsqlsort[35] = "c.label ASC"; +$tabsqlsort[36] = "r.fk_c_exp_tax_cat ASC, r.range_ik ASC"; +$tabsqlsort[37] = "r.unit_type ASC, r.scale ASC, r.code ASC"; +$tabsqlsort[38] = "rowid, code ASC"; // Field names in select result for dictionary display -$tabfield=array(); +$tabfield = array(); $tabfield[1] = "code,libelle,country"; -$tabfield[2] = "code,libelle,region_id,region,country"; // "code,libelle,region,country_code-country" +$tabfield[2] = "code,libelle,region_id,region,country"; // "code,libelle,region,country_code-country" $tabfield[3] = "code,libelle,country_id,country"; $tabfield[4] = "code,label"; $tabfield[5] = "code,label"; $tabfield[6] = "code,libelle,type,color,position"; $tabfield[7] = "code,libelle,country,accountancy_code,deductible"; -$tabfield[8] = "code,libelle,country_id,country".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?',position':''); +$tabfield[8] = "code,libelle,country_id,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : ''); $tabfield[9] = "code,label,unicode"; -$tabfield[10]= "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; -$tabfield[11]= "element,source,code,libelle,position"; -$tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; -$tabfield[13]= "code,libelle,type,entity"; -$tabfield[14]= "code,label,price,organization,country"; -$tabfield[15]= "code,libelle,width,height,unit"; -$tabfield[16]= "code,libelle,sortorder"; -$tabfield[17]= "code,label,accountancy_code"; -$tabfield[18]= "code,libelle,tracking"; -$tabfield[19]= "code,libelle"; -$tabfield[20]= "code,libelle"; -$tabfield[21]= "code,label"; -$tabfield[22]= "code,label"; -$tabfield[23]= "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; -$tabfield[24]= "code,label"; -$tabfield[25]= "code,label"; +$tabfield[10] = "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; +$tabfield[11] = "element,source,code,libelle,position"; +$tabfield[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; +$tabfield[13] = "code,libelle,type,entity"; +$tabfield[14] = "code,label,price,organization,country"; +$tabfield[15] = "code,libelle,width,height,unit"; +$tabfield[16] = "code,libelle,sortorder"; +$tabfield[17] = "code,label,accountancy_code"; +$tabfield[18] = "code,libelle,tracking"; +$tabfield[19] = "code,libelle"; +$tabfield[20] = "code,libelle"; +$tabfield[21] = "code,label"; +$tabfield[22] = "code,label"; +$tabfield[23] = "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; +$tabfield[24] = "code,label"; +$tabfield[25] = "code,label"; //$tabfield[26]= "code,label,short_label"; -$tabfield[27]= "code,libelle"; -$tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country"; -$tabfield[29]= "code,label,percent,position"; -$tabfield[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; +$tabfield[27] = "code,libelle"; +$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country"; +$tabfield[29] = "code,label,percent,position"; +$tabfield[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfield[31]= "pcg_version,label"; -$tabfield[32]= "code,dayrule,year,month,day,country_id,country"; -$tabfield[33]= "code,label"; -$tabfield[34]= "code,label"; -$tabfield[35]= "label"; -$tabfield[36]= "range_ik,fk_c_exp_tax_cat"; -$tabfield[37]= "code,label,short_label,unit_type,scale"; -$tabfield[38]= "code,label,url,icon,entity"; +$tabfield[32] = "code,dayrule,year,month,day,country_id,country"; +$tabfield[33] = "code,label"; +$tabfield[34] = "code,label"; +$tabfield[35] = "label"; +$tabfield[36] = "range_ik,fk_c_exp_tax_cat"; +$tabfield[37] = "code,label,short_label,unit_type,scale"; +$tabfield[38] = "code,label,url,icon,entity"; // Edit field names for editing a record -$tabfieldvalue=array(); +$tabfieldvalue = array(); $tabfieldvalue[1] = "code,libelle,country"; -$tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region" +$tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region" $tabfieldvalue[3] = "code,libelle,country"; $tabfieldvalue[4] = "code,label"; $tabfieldvalue[5] = "code,label"; $tabfieldvalue[6] = "code,libelle,type,color,position"; $tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible"; -$tabfieldvalue[8] = "code,libelle,country".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?',position':''); +$tabfieldvalue[8] = "code,libelle,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : ''); $tabfieldvalue[9] = "code,label,unicode"; -$tabfieldvalue[10]= "country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldvalue[11]= "element,source,code,libelle,position"; -$tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder"; -$tabfieldvalue[13]= "code,libelle,type"; -$tabfieldvalue[14]= "code,label,price,organization,country"; -$tabfieldvalue[15]= "code,libelle,width,height,unit"; -$tabfieldvalue[16]= "code,libelle,sortorder"; -$tabfieldvalue[17]= "code,label,accountancy_code"; -$tabfieldvalue[18]= "code,libelle,tracking"; -$tabfieldvalue[19]= "code,libelle"; -$tabfieldvalue[20]= "code,libelle"; -$tabfieldvalue[21]= "code,label"; -$tabfieldvalue[22]= "code,label"; -$tabfieldvalue[23]= "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldvalue[24]= "code,label"; -$tabfieldvalue[25]= "code,label"; +$tabfieldvalue[10] = "country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldvalue[11] = "element,source,code,libelle,position"; +$tabfieldvalue[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder"; +$tabfieldvalue[13] = "code,libelle,type"; +$tabfieldvalue[14] = "code,label,price,organization,country"; +$tabfieldvalue[15] = "code,libelle,width,height,unit"; +$tabfieldvalue[16] = "code,libelle,sortorder"; +$tabfieldvalue[17] = "code,label,accountancy_code"; +$tabfieldvalue[18] = "code,libelle,tracking"; +$tabfieldvalue[19] = "code,libelle"; +$tabfieldvalue[20] = "code,libelle"; +$tabfieldvalue[21] = "code,label"; +$tabfieldvalue[22] = "code,label"; +$tabfieldvalue[23] = "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldvalue[24] = "code,label"; +$tabfieldvalue[25] = "code,label"; //$tabfieldvalue[26]= "code,label,short_label"; -$tabfieldvalue[27]= "code,libelle"; -$tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country"; -$tabfieldvalue[29]= "code,label,percent,position"; -$tabfieldvalue[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; +$tabfieldvalue[27] = "code,libelle"; +$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country"; +$tabfieldvalue[29] = "code,label,percent,position"; +$tabfieldvalue[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldvalue[31]= "pcg_version,label"; -$tabfieldvalue[32]= "code,dayrule,day,month,year,country"; -$tabfieldvalue[33]= "code,label"; -$tabfieldvalue[34]= "code,label"; -$tabfieldvalue[35]= "label"; -$tabfieldvalue[36]= "range_ik,fk_c_exp_tax_cat"; -$tabfieldvalue[37]= "code,label,short_label,unit_type,scale"; -$tabfieldvalue[38]= "code,label,url,icon"; +$tabfieldvalue[32] = "code,dayrule,day,month,year,country"; +$tabfieldvalue[33] = "code,label"; +$tabfieldvalue[34] = "code,label"; +$tabfieldvalue[35] = "label"; +$tabfieldvalue[36] = "range_ik,fk_c_exp_tax_cat"; +$tabfieldvalue[37] = "code,label,short_label,unit_type,scale"; +$tabfieldvalue[38] = "code,label,url,icon"; // Field names in the table for inserting a record -$tabfieldinsert=array(); +$tabfieldinsert = array(); $tabfieldinsert[1] = "code,libelle,fk_pays"; $tabfieldinsert[2] = "code_departement,nom,fk_region"; $tabfieldinsert[3] = "code_region,nom,fk_pays"; @@ -347,43 +347,43 @@ $tabfieldinsert[4] = "code,label"; $tabfieldinsert[5] = "code,label"; $tabfieldinsert[6] = "code,libelle,type,color,position"; $tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code,deductible"; -$tabfieldinsert[8] = "code,libelle,fk_country".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?',position':''); +$tabfieldinsert[8] = "code,libelle,fk_country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : ''); $tabfieldinsert[9] = "code_iso,label,unicode"; -$tabfieldinsert[10]= "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldinsert[11]= "element,source,code,libelle,position"; -$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; -$tabfieldinsert[13]= "code,libelle,type,entity"; -$tabfieldinsert[14]= "code,label,price,organization,fk_pays"; -$tabfieldinsert[15]= "code,label,width,height,unit"; -$tabfieldinsert[16]= "code,label,sortorder"; -$tabfieldinsert[17]= "code,label,accountancy_code"; -$tabfieldinsert[18]= "code,libelle,tracking"; -$tabfieldinsert[19]= "code,libelle"; -$tabfieldinsert[20]= "code,libelle"; -$tabfieldinsert[21]= "code,label"; -$tabfieldinsert[22]= "code,label"; -$tabfieldinsert[23]= "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldinsert[24]= "code,label"; -$tabfieldinsert[25]= "code,label"; +$tabfieldinsert[10] = "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldinsert[11] = "element,source,code,libelle,position"; +$tabfieldinsert[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; +$tabfieldinsert[13] = "code,libelle,type,entity"; +$tabfieldinsert[14] = "code,label,price,organization,fk_pays"; +$tabfieldinsert[15] = "code,label,width,height,unit"; +$tabfieldinsert[16] = "code,label,sortorder"; +$tabfieldinsert[17] = "code,label,accountancy_code"; +$tabfieldinsert[18] = "code,libelle,tracking"; +$tabfieldinsert[19] = "code,libelle"; +$tabfieldinsert[20] = "code,libelle"; +$tabfieldinsert[21] = "code,label"; +$tabfieldinsert[22] = "code,label"; +$tabfieldinsert[23] = "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldinsert[24] = "code,label"; +$tabfieldinsert[25] = "code,label"; //$tabfieldinsert[26]= "code,label,short_label"; -$tabfieldinsert[27]= "code,libelle"; -$tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country"; -$tabfieldinsert[29]= "code,label,percent,position"; -$tabfieldinsert[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; +$tabfieldinsert[27] = "code,libelle"; +$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country"; +$tabfieldinsert[29] = "code,label,percent,position"; +$tabfieldinsert[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldinsert[31]= "pcg_version,label"; //$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country"; -$tabfieldinsert[32]= "code,dayrule,day,month,year,fk_country"; -$tabfieldinsert[33]= "code,label"; -$tabfieldinsert[34]= "code,label"; -$tabfieldinsert[35]= "label"; -$tabfieldinsert[36]= "range_ik,fk_c_exp_tax_cat"; -$tabfieldinsert[37]= "code,label,short_label,unit_type,scale"; -$tabfieldinsert[38]= "code,label,url,icon,entity"; +$tabfieldinsert[32] = "code,dayrule,day,month,year,fk_country"; +$tabfieldinsert[33] = "code,label"; +$tabfieldinsert[34] = "code,label"; +$tabfieldinsert[35] = "label"; +$tabfieldinsert[36] = "range_ik,fk_c_exp_tax_cat"; +$tabfieldinsert[37] = "code,label,short_label,unit_type,scale"; +$tabfieldinsert[38] = "code,label,url,icon,entity"; // Rowid name of field depending if field is autoincrement on or off.. // Use "" if id field is "rowid" and has autoincrement on // Use "nameoffield" if id field is not "rowid" or has not autoincrement on -$tabrowid=array(); +$tabrowid = array(); $tabrowid[1] = ""; $tabrowid[2] = ""; $tabrowid[3] = ""; @@ -393,79 +393,79 @@ $tabrowid[6] = "id"; $tabrowid[7] = "id"; $tabrowid[8] = "id"; $tabrowid[9] = "code_iso"; -$tabrowid[10]= ""; -$tabrowid[11]= "rowid"; -$tabrowid[12]= ""; -$tabrowid[13]= "id"; -$tabrowid[14]= ""; -$tabrowid[15]= ""; -$tabrowid[16]= "code"; -$tabrowid[17]= "id"; -$tabrowid[18]= "rowid"; -$tabrowid[19]= "id"; -$tabrowid[20]= ""; -$tabrowid[21]= "rowid"; -$tabrowid[22]= "rowid"; -$tabrowid[23]= ""; -$tabrowid[24]= ""; -$tabrowid[25]= ""; +$tabrowid[10] = ""; +$tabrowid[11] = "rowid"; +$tabrowid[12] = ""; +$tabrowid[13] = "id"; +$tabrowid[14] = ""; +$tabrowid[15] = ""; +$tabrowid[16] = "code"; +$tabrowid[17] = "id"; +$tabrowid[18] = "rowid"; +$tabrowid[19] = "id"; +$tabrowid[20] = ""; +$tabrowid[21] = "rowid"; +$tabrowid[22] = "rowid"; +$tabrowid[23] = ""; +$tabrowid[24] = ""; +$tabrowid[25] = ""; //$tabrowid[26]= ""; -$tabrowid[27]= "id"; -$tabrowid[28]= ""; -$tabrowid[29]= ""; -$tabrowid[30]= ""; +$tabrowid[27] = "id"; +$tabrowid[28] = ""; +$tabrowid[29] = ""; +$tabrowid[30] = ""; //$tabrowid[31]= ""; -$tabrowid[32]= "id"; -$tabrowid[33]= "rowid"; -$tabrowid[34]= "rowid"; -$tabrowid[35]= ""; -$tabrowid[36]= ""; -$tabrowid[37]= ""; -$tabrowid[38]= ""; +$tabrowid[32] = "id"; +$tabrowid[33] = "rowid"; +$tabrowid[34] = "rowid"; +$tabrowid[35] = ""; +$tabrowid[36] = ""; +$tabrowid[37] = ""; +$tabrowid[38] = ""; // Condition to show dictionary in setup page -$tabcond=array(); -$tabcond[1] = (! empty($conf->societe->enabled)); +$tabcond = array(); +$tabcond[1] = (!empty($conf->societe->enabled)); $tabcond[2] = true; $tabcond[3] = true; $tabcond[4] = true; -$tabcond[5] = (! empty($conf->societe->enabled) || ! empty($conf->adherent->enabled)); -$tabcond[6] = ! empty($conf->agenda->enabled); -$tabcond[7] = ! empty($conf->tax->enabled); -$tabcond[8] = ! empty($conf->societe->enabled); +$tabcond[5] = (!empty($conf->societe->enabled) || !empty($conf->adherent->enabled)); +$tabcond[6] = !empty($conf->agenda->enabled); +$tabcond[7] = !empty($conf->tax->enabled); +$tabcond[8] = !empty($conf->societe->enabled); $tabcond[9] = true; -$tabcond[10]= true; -$tabcond[11]= (! empty($conf->societe->enabled)); -$tabcond[12]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)); -$tabcond[13]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)); -$tabcond[14]= (! empty($conf->product->enabled) && (! empty($conf->ecotax->enabled) || ! empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY))); -$tabcond[15]= true; -$tabcond[16]= (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)); -$tabcond[17]= (! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)); -$tabcond[18]= ! empty($conf->expedition->enabled) || ! empty($conf->reception->enabled); -$tabcond[19]= ! empty($conf->societe->enabled); -$tabcond[20]= ! empty($conf->fournisseur->enabled); -$tabcond[21]= ! empty($conf->propal->enabled); -$tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled)); -$tabcond[23]= true; -$tabcond[24]= ! empty($conf->resource->enabled); -$tabcond[25]= ! empty($conf->website->enabled); +$tabcond[10] = true; +$tabcond[11] = (!empty($conf->societe->enabled)); +$tabcond[12] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled)); +$tabcond[13] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled)); +$tabcond[14] = (!empty($conf->product->enabled) && (!empty($conf->ecotax->enabled) || !empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY))); +$tabcond[15] = true; +$tabcond[16] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)); +$tabcond[17] = (!empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled)); +$tabcond[18] = !empty($conf->expedition->enabled) || !empty($conf->reception->enabled); +$tabcond[19] = !empty($conf->societe->enabled); +$tabcond[20] = !empty($conf->fournisseur->enabled); +$tabcond[21] = !empty($conf->propal->enabled); +$tabcond[22] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled)); +$tabcond[23] = true; +$tabcond[24] = !empty($conf->resource->enabled); +$tabcond[25] = !empty($conf->website->enabled); //$tabcond[26]= ! empty($conf->product->enabled); -$tabcond[27]= ! empty($conf->societe->enabled); -$tabcond[28]= ! empty($conf->holiday->enabled); -$tabcond[29]= ! empty($conf->projet->enabled); -$tabcond[30]= ! empty($conf->label->enabled); +$tabcond[27] = !empty($conf->societe->enabled); +$tabcond[28] = !empty($conf->holiday->enabled); +$tabcond[29] = !empty($conf->projet->enabled); +$tabcond[30] = !empty($conf->label->enabled); //$tabcond[31]= ! empty($conf->accounting->enabled); -$tabcond[32]= (! empty($conf->holiday->enabled) || ! empty($conf->hrm->enabled)); -$tabcond[33]= ! empty($conf->hrm->enabled); -$tabcond[34]= ! empty($conf->hrm->enabled); -$tabcond[35]= ! empty($conf->expensereport->enabled); -$tabcond[36]= ! empty($conf->expensereport->enabled); -$tabcond[37]= ! empty($conf->product->enabled); -$tabcond[38]= ! empty($conf->socialnetworks->enabled); +$tabcond[32] = (!empty($conf->holiday->enabled) || !empty($conf->hrm->enabled)); +$tabcond[33] = !empty($conf->hrm->enabled); +$tabcond[34] = !empty($conf->hrm->enabled); +$tabcond[35] = !empty($conf->expensereport->enabled); +$tabcond[36] = !empty($conf->expensereport->enabled); +$tabcond[37] = !empty($conf->product->enabled); +$tabcond[38] = !empty($conf->socialnetworks->enabled); // List of help for fields -$tabhelp=array(); +$tabhelp = array(); $tabhelp[1] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[2] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[3] = array('code'=>$langs->trans("EnterAnyCode")); @@ -493,7 +493,7 @@ $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[25] = array('code'=>$langs->trans('EnterAnyCode')); //$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically")); +$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"), 'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically")); $tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList")); $tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize")); //$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode")); @@ -506,7 +506,7 @@ $tabhelp[37] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[38] = array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc')); // List of check for fields (NOT USED YET) -$tabfieldcheck=array(); +$tabfieldcheck = array(); $tabfieldcheck[1] = array(); $tabfieldcheck[2] = array(); $tabfieldcheck[3] = array(); @@ -555,12 +555,12 @@ if (empty($sortfield)) { $tmp1 = explode(',', $tabsqlsort[$id]); $tmp2 = explode(' ', $tmp1[0]); - $sortfield=preg_replace('/^.*\./', '', $tmp2[0]); + $sortfield = preg_replace('/^.*\./', '', $tmp2[0]); } // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); -$sourceList=array(); +$sourceList = array(); if ($id == 11) { $elementList = array( @@ -585,7 +585,7 @@ if ($id == 11) 'fichinter' => $langs->trans('InterventionCard'), 'contrat' => $langs->trans('Contract'), ); - if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); + if (!empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); complete_elementList_with_modules($elementList); @@ -602,11 +602,11 @@ if ($id == 10) { $localtax_typeList = array( "0" => $langs->trans("No"), - "1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"), - "2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"), - "3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"), - "4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"), - "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"), + "1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"), + "2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"), + "3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"), + "4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"), + "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"), "6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)" //$langs->trans("%ageOnServiceBeforeVAT"), ); } @@ -626,37 +626,37 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', // Actions add or modify an entry into a dictionary if (GETPOST('actionadd') || GETPOST('actionmodify')) { - $listfield=explode(',', str_replace(' ', '', $tabfield[$id])); - $listfieldinsert=explode(',', $tabfieldinsert[$id]); - $listfieldmodify=explode(',', $tabfieldinsert[$id]); - $listfieldvalue=explode(',', $tabfieldvalue[$id]); + $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); + $listfieldinsert = explode(',', $tabfieldinsert[$id]); + $listfieldmodify = explode(',', $tabfieldinsert[$id]); + $listfieldvalue = explode(',', $tabfieldvalue[$id]); // Check that all fields are filled - $ok=1; + $ok = 1; foreach ($listfield as $f => $value) { // Discard check of mandatory fields for country for some tables - if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays','DictionaryVAT','DictionaryRegion','DictionaryCompanyType','DictionaryHolidayTypes','DictionaryRevenueStamp','DictionaryAccountancysystem','DictionaryAccountancyCategory'))) continue; // For some pages, country is not mandatory - if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays','DictionaryCanton','DictionaryCompanyType','DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory + if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) continue; // For some pages, country is not mandatory + if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory // Discard check of mandatory fiedls for other fields if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue; if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; if ($value == 'color' && empty($_POST['color'])) continue; if ($value == 'formula' && empty($_POST['formula'])) continue; - if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position' - if ((! isset($_POST[$value]) || $_POST[$value]=='') - && (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy','tracking')) // Fields that are not mandatory - && (! ($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10 + if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position' + if ((!isset($_POST[$value]) || $_POST[$value] == '') + && (!in_array($listfield[$f], array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking')) // Fields that are not mandatory + && (!($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10 ) ) { - $ok=0; - $fieldnamekey=$listfield[$f]; + $ok = 0; + $fieldnamekey = $listfield[$f]; // We take translate key of field - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments'; - if ($fieldnamekey == 'nbjour') $fieldnamekey='NbOfDays'; - if ($fieldnamekey == 'decalage') $fieldnamekey='Offset'; - if ($fieldnamekey == 'module') $fieldnamekey='Module'; + if ($fieldnamekey == 'nbjour') $fieldnamekey = 'NbOfDays'; + if ($fieldnamekey == 'decalage') $fieldnamekey = 'Offset'; + if ($fieldnamekey == 'module') $fieldnamekey = 'Module'; if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; if ($fieldnamekey == 'taux') $fieldnamekey = 'Rate'; @@ -673,15 +673,15 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) } } // Other checks - if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"], array('system','systemauto'))) { - $ok=0; + if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"], array('system', 'systemauto'))) { + $ok = 0; setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors'); } if (isset($_POST["code"])) { - if ($_POST["code"]=='0') + if ($_POST["code"] == '0') { - $ok=0; + $ok = 0; setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); } /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base @@ -690,33 +690,33 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
    '; }*/ } - if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2)) + if (isset($_POST["country"]) && ($_POST["country"] == '0') && ($id != 2)) { - if (in_array($tablib[$id], array('DictionaryCompanyType','DictionaryHolidayTypes'))) // Field country is no mandatory for such dictionaries + if (in_array($tablib[$id], array('DictionaryCompanyType', 'DictionaryHolidayTypes'))) // Field country is no mandatory for such dictionaries { - $_POST["country"]=''; + $_POST["country"] = ''; } else { - $ok=0; + $ok = 0; setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors'); } } - if ($id == 3 && ! is_numeric($_POST["code"])) + if ($id == 3 && !is_numeric($_POST["code"])) { - $ok=0; + $ok = 0; setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors'); } // Clean some parameters - if ((! empty($_POST["localtax1_type"]) || ($_POST['localtax1_type'] == '0')) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 - if ((! empty($_POST["localtax2_type"]) || ($_POST['localtax2_type'] == '0')) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 - if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null - if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null - if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null + if ((!empty($_POST["localtax1_type"]) || ($_POST['localtax1_type'] == '0')) && empty($_POST["localtax1"])) $_POST["localtax1"] = '0'; // If empty, we force to 0 + if ((!empty($_POST["localtax2_type"]) || ($_POST['localtax2_type'] == '0')) && empty($_POST["localtax2"])) $_POST["localtax2"] = '0'; // If empty, we force to 0 + if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null + if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null + if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null if ($id == 10 && isset($_POST["code"])) // Spaces are not allowed into code { - $_POST["code"]=preg_replace('/\s/', '', $_POST["code"]); + $_POST["code"] = preg_replace('/\s/', '', $_POST["code"]); } // If check ok and action add, add the line @@ -725,13 +725,13 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($tabrowid[$id]) { // Get free id for insert - $newid=0; + $newid = 0; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; $result = $db->query($sql); if ($result) { $obj = $db->fetch_object($result); - $newid=($obj->newid + 1); + $newid = ($obj->newid + 1); } else { dol_print_error($db); } @@ -740,16 +740,16 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) // Add new entry $sql = "INSERT INTO ".$tabname[$id]." ("; // List of fields - if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) - $sql.= $tabrowid[$id].","; - $sql.= $tabfieldinsert[$id]; - $sql.=",active)"; - $sql.= " VALUES("; + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) + $sql .= $tabrowid[$id].","; + $sql .= $tabfieldinsert[$id]; + $sql .= ",active)"; + $sql .= " VALUES("; // List of values - if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) - $sql.= $newid.","; - $i=0; + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) + $sql .= $newid.","; + $i = 0; foreach ($listfieldinsert as $f => $value) { if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') { @@ -758,23 +758,23 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) elseif ($value == 'entity') { $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]); } - if ($i) $sql.=","; + if ($i) $sql .= ","; if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position' { - $sql.="'".(int) $db->escape($_POST['position'])."'"; + $sql .= "'".(int) $db->escape($_POST['position'])."'"; } - elseif ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + elseif ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $i++; } - $sql.=",1)"; + $sql .= ",1)"; dol_syslog("actionadd", LOG_DEBUG); $result = $db->query($sql); if ($result) // Add is ok { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST=array('id'=>$id); // Clean $_POST array, we keep only + $_POST = array('id'=>$id); // Clean $_POST array, we keep only } else { @@ -790,16 +790,16 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) // If verif ok and action modify, modify the line if ($ok && GETPOST('actionmodify')) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; // Modifie valeur des champs - if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify)) + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) { - $sql.= $tabrowid[$id]."="; - $sql.= "'".$db->escape($rowid)."', "; + $sql .= $tabrowid[$id]."="; + $sql .= "'".$db->escape($rowid)."', "; } $i = 0; foreach ($listfieldmodify as $field) @@ -810,23 +810,23 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) elseif ($field == 'entity') { $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]); } - if ($i) $sql.=","; - $sql.= $field."="; + if ($i) $sql .= ","; + $sql .= $field."="; if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position' { - $sql.="'".(int) $db->escape($_POST['position'])."'"; + $sql .= "'".(int) $db->escape($_POST['position'])."'"; } - elseif ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + elseif ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $i++; } - $sql.= " WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; - if (in_array('entity', $listfieldmodify)) $sql.= " AND entity = '".getEntity($tabname[$id])."'"; + $sql .= " WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; + if (in_array('entity', $listfieldmodify)) $sql .= " AND entity = '".getEntity($tabname[$id])."'"; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); - if (! $resql) + if (!$resql) { setEventMessages($db->error(), null, 'errors'); } @@ -841,14 +841,14 @@ if (GETPOST('actioncancel')) if ($action == 'confirm_delete' && $confirm == 'yes') // delete { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } - $sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); - if (! $result) + if (!$result) { if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') { @@ -864,14 +864,14 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete // activate if ($action == $acts[0]) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -884,14 +884,14 @@ if ($action == $acts[0]) // disable if ($action == $acts[1]) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -904,14 +904,14 @@ if ($action == $acts[1]) // favorite if ($action == 'activate_favorite') { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -924,14 +924,14 @@ if ($action == 'activate_favorite') // disable favorite if ($action == 'disable_favorite') { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -947,28 +947,28 @@ if ($action == 'disable_favorite') */ $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); -$title=$langs->trans("DictionarySetup"); +$title = $langs->trans("DictionarySetup"); llxHeader('', $title); -$linkback=''; +$linkback = ''; if ($id) { - $title.=' - '.$langs->trans($tablib[$id]); - $linkback=''.$langs->trans("BackToDictionaryList").''; + $title .= ' - '.$langs->trans($tablib[$id]); + $linkback = ''.$langs->trans("BackToDictionaryList").''; } -$titlepicto='title_setup'; +$titlepicto = 'title_setup'; if ($id == 10 && GETPOST('from') == 'accountancy') { - $title=$langs->trans("MenuVatAccounts"); - $titlepicto='accountancy'; + $title = $langs->trans("MenuVatAccounts"); + $titlepicto = 'accountancy'; } if ($id == 7 && GETPOST('from') == 'accountancy') { - $title=$langs->trans("MenuTaxAccounts"); - $titlepicto='accountancy'; + $title = $langs->trans("MenuTaxAccounts"); + $titlepicto = 'accountancy'; } print load_fiche_titre($title, $linkback, $titlepicto); @@ -982,19 +982,19 @@ if (empty($id)) $param = '&id='.urlencode($id); -if ($search_country_id > 0) $param.= '&search_country_id='.urlencode($search_country_id); -if ($search_code != '') $param.= '&search_code='.urlencode($search_country_id); -if ($entity != '') $param.= '&entity=' . (int) $entity; +if ($search_country_id > 0) $param .= '&search_country_id='.urlencode($search_country_id); +if ($search_code != '') $param .= '&search_code='.urlencode($search_country_id); +if ($entity != '') $param .= '&entity='.(int) $entity; $paramwithsearch = $param; -if ($sortorder) $paramwithsearch.= '&sortorder='.urlencode($sortorder); -if ($sortfield) $paramwithsearch.= '&sortfield='.urlencode($sortfield); -if (GETPOST('from')) $paramwithsearch.= '&from='.urlencode(GETPOST('from', 'alpha')); +if ($sortorder) $paramwithsearch .= '&sortorder='.urlencode($sortorder); +if ($sortfield) $paramwithsearch .= '&sortfield='.urlencode($sortfield); +if (GETPOST('from')) $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); // Confirmation of the deletion of the line if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'rowid='.urlencode($rowid).'&code='.urlencode($code).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'rowid='.urlencode($rowid).'&code='.urlencode($code).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } //var_dump($elementList); @@ -1004,34 +1004,34 @@ if ($action == 'delete') if ($id) { // Complete search values request with sort criteria - $sql=$tabsql[$id]; + $sql = $tabsql[$id]; - if (! preg_match('/ WHERE /', $sql)) $sql.= " WHERE 1 = 1"; - if ($search_country_id > 0) $sql.= " AND c.rowid = ".$search_country_id; - if ($search_code != '' && $id == 9) $sql.= natural_search("code_iso", $search_code); - elseif ($search_code != '' && $id == 28) $sql.= natural_search("h.code", $search_code); - elseif ($search_code != '' && $id == 32) $sql.= natural_search("a.code", $search_code); - elseif ($search_code != '' && $id != 9) $sql.= natural_search("code", $search_code); + if (!preg_match('/ WHERE /', $sql)) $sql .= " WHERE 1 = 1"; + if ($search_country_id > 0) $sql .= " AND c.rowid = ".$search_country_id; + if ($search_code != '' && $id == 9) $sql .= natural_search("code_iso", $search_code); + elseif ($search_code != '' && $id == 28) $sql .= natural_search("h.code", $search_code); + elseif ($search_code != '' && $id == 32) $sql .= natural_search("a.code", $search_code); + elseif ($search_code != '' && $id != 9) $sql .= natural_search("code", $search_code); if ($sortfield) { // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$db->escape($sortfield); + if ($sortfield == 'country') $sortfield = 'country_code'; + $sql .= " ORDER BY ".$db->escape($sortfield); if ($sortorder) { - $sql.=" ".strtoupper($db->escape($sortorder)); + $sql .= " ".strtoupper($db->escape($sortorder)); } - $sql.=", "; + $sql .= ", "; // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i', '', $tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i', '', $tabsqlsort[$id]); + $tabsqlsort[$id] = preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i', '', $tabsqlsort[$id]); + $tabsqlsort[$id] = preg_replace('/([a-z]+\.)?'.$sortfield.',/i', '', $tabsqlsort[$id]); } else { - $sql.=" ORDER BY "; + $sql .= " ORDER BY "; } - $sql.=$tabsqlsort[$id]; - $sql.=$db->plimit($listlimit+1, $offset); + $sql .= $tabsqlsort[$id]; + $sql .= $db->plimit($listlimit + 1, $offset); //print $sql; if (empty($tabfield[$id])) @@ -1039,7 +1039,7 @@ if ($id) dol_print_error($db, 'The table with id '.$id.' has no array tabfield defined'); exit; } - $fieldlist=explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); print '
    '; print ''; @@ -1054,10 +1054,10 @@ if ($id) // Form to add a new line if ($tabname[$id]) { - $alabelisused=0; - $withentity=null; + $alabelisused = 0; + $withentity = null; - $fieldlist=explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); print '
    '; print '
    '.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
    '.img_object('', $delay['img']).''.$langs->trans('Delays_'.$delay['code']).'
    '; @@ -1072,101 +1072,101 @@ if ($id) } // Define field friendly name from its technical name - $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut - $valuetoshow=$langs->trans($valuetoshow); // try to translate - $class=''; + $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + $class = ''; - if ($fieldlist[$field]=='pos') { $valuetoshow=$langs->trans("Position"); $class='maxwidth100'; } - if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } - if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } - if ($fieldlist[$field]=='taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); - else $valuetoshow=$langs->trans("Amount"); - $class='center'; + if ($fieldlist[$field] == 'pos') { $valuetoshow = $langs->trans("Position"); $class = 'maxwidth100'; } + if ($fieldlist[$field] == 'source') { $valuetoshow = $langs->trans("Contact"); } + if ($fieldlist[$field] == 'price') { $valuetoshow = $langs->trans("PriceUHT"); } + if ($fieldlist[$field] == 'taux') { + if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow = $langs->trans("Rate"); + else $valuetoshow = $langs->trans("Amount"); + $class = 'center'; } - if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $class="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $class="center"; } - if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $class="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $class="center"; } - if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } - if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } - if ($fieldlist[$field]=='type') { - if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow=$form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); - else $valuetoshow=$langs->trans("Type"); + if ($fieldlist[$field] == 'localtax1_type') { $valuetoshow = $langs->trans("UseLocalTax")." 2"; $class = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'localtax1') { $valuetoshow = $langs->trans("Rate")." 2"; $class = "center"; } + if ($fieldlist[$field] == 'localtax2_type') { $valuetoshow = $langs->trans("UseLocalTax")." 3"; $class = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'localtax2') { $valuetoshow = $langs->trans("Rate")." 3"; $class = "center"; } + if ($fieldlist[$field] == 'organization') { $valuetoshow = $langs->trans("Organization"); } + if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } + if ($fieldlist[$field] == 'type') { + if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); + else $valuetoshow = $langs->trans("Type"); } - if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); $class='maxwidth100'; } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') + if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); $class = 'maxwidth100'; } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { - $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); + $valuetoshow = $form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); } - if ($fieldlist[$field]=='libelle_facture') { - $valuetoshow=$form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); + if ($fieldlist[$field] == 'libelle_facture') { + $valuetoshow = $form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); } - if ($fieldlist[$field]=='country') { + if ($fieldlist[$field] == 'country') { if (in_array('region_id', $fieldlist)) { print ''; continue; } // For region page, we do not show the country input - $valuetoshow=$langs->trans("Country"); + $valuetoshow = $langs->trans("Country"); } - if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $class="center"; } - if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } - if ($fieldlist[$field]=='type_cdr') { $valuetoshow=$langs->trans("AtEndOfMonth"); $class="center"; } - if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } - if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx') { $valuetoshow=$langs->trans("Width"); } - if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny') { $valuetoshow=$langs->trans("Height"); } - if ($fieldlist[$field]=='unit' || $fieldlist[$field]=='metric') { $valuetoshow=$langs->trans("MeasuringUnit"); } - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $valuetoshow=''; } - if ($fieldlist[$field]=='accountancy_code') { $valuetoshow=$langs->trans("AccountancyCode"); } - if ($fieldlist[$field]=='accountancy_code_sell') { $valuetoshow=$langs->trans("AccountancyCodeSell"); } - if ($fieldlist[$field]=='accountancy_code_buy') { $valuetoshow=$langs->trans("AccountancyCodeBuy"); } - if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } - if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountparent"); } - if ($fieldlist[$field]=='pcg_type') { $valuetoshow=$langs->trans("Pcg_type"); } - if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } - if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); } - if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); } - if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } - if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } - if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } - if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); } - if ($fieldlist[$field]=='paper_size') { $valuetoshow=$langs->trans("PaperSize"); } - if ($fieldlist[$field]=='orientation') { $valuetoshow=$langs->trans("Orientation"); } - if ($fieldlist[$field]=='leftmargin') { $valuetoshow=$langs->trans("LeftMargin"); } - if ($fieldlist[$field]=='topmargin') { $valuetoshow=$langs->trans("TopMargin"); } - if ($fieldlist[$field]=='spacex') { $valuetoshow=$langs->trans("SpaceX"); } - if ($fieldlist[$field]=='spacey') { $valuetoshow=$langs->trans("SpaceY"); } - if ($fieldlist[$field]=='font_size') { $valuetoshow=$langs->trans("FontSize"); } - if ($fieldlist[$field]=='custom_x') { $valuetoshow=$langs->trans("CustomX"); } - if ($fieldlist[$field]=='custom_y') { $valuetoshow=$langs->trans("CustomY"); } - if ($fieldlist[$field]=='percent') { $valuetoshow=$langs->trans("Percentage"); } - if ($fieldlist[$field]=='affect') { $valuetoshow=$langs->trans("WithCounter"); } - if ($fieldlist[$field]=='delay') { $valuetoshow=$langs->trans("NoticePeriod"); } - if ($fieldlist[$field]=='newbymonth') { $valuetoshow=$langs->trans("NewByMonth"); } - if ($fieldlist[$field]=='fk_tva') { $valuetoshow=$langs->trans("VAT"); } - if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); } - if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); } - if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); } - if ($fieldlist[$field]=='use_default') { $valuetoshow=$langs->trans('Default'); } + if ($fieldlist[$field] == 'recuperableonly') { $valuetoshow = $langs->trans("NPR"); $class = "center"; } + if ($fieldlist[$field] == 'nbjour') { $valuetoshow = $langs->trans("NbOfDays"); } + if ($fieldlist[$field] == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $class = "center"; } + if ($fieldlist[$field] == 'decalage') { $valuetoshow = $langs->trans("Offset"); } + if ($fieldlist[$field] == 'width' || $fieldlist[$field] == 'nx') { $valuetoshow = $langs->trans("Width"); } + if ($fieldlist[$field] == 'height' || $fieldlist[$field] == 'ny') { $valuetoshow = $langs->trans("Height"); } + if ($fieldlist[$field] == 'unit' || $fieldlist[$field] == 'metric') { $valuetoshow = $langs->trans("MeasuringUnit"); } + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $valuetoshow = ''; } + if ($fieldlist[$field] == 'accountancy_code') { $valuetoshow = $langs->trans("AccountancyCode"); } + if ($fieldlist[$field] == 'accountancy_code_sell') { $valuetoshow = $langs->trans("AccountancyCodeSell"); } + if ($fieldlist[$field] == 'accountancy_code_buy') { $valuetoshow = $langs->trans("AccountancyCodeBuy"); } + if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { $valuetoshow = $langs->trans("Pcg_version"); } + if ($fieldlist[$field] == 'account_parent') { $valuetoshow = $langs->trans("Accountparent"); } + if ($fieldlist[$field] == 'pcg_type') { $valuetoshow = $langs->trans("Pcg_type"); } + if ($fieldlist[$field] == 'pcg_subtype') { $valuetoshow = $langs->trans("Pcg_subtype"); } + if ($fieldlist[$field] == 'sortorder') { $valuetoshow = $langs->trans("SortOrder"); } + if ($fieldlist[$field] == 'short_label') { $valuetoshow = $langs->trans("ShortLabel"); } + if ($fieldlist[$field] == 'range_account') { $valuetoshow = $langs->trans("Range"); } + if ($fieldlist[$field] == 'sens') { $valuetoshow = $langs->trans("Sens"); } + if ($fieldlist[$field] == 'category_type') { $valuetoshow = $langs->trans("Calculated"); } + if ($fieldlist[$field] == 'formula') { $valuetoshow = $langs->trans("Formula"); } + if ($fieldlist[$field] == 'paper_size') { $valuetoshow = $langs->trans("PaperSize"); } + if ($fieldlist[$field] == 'orientation') { $valuetoshow = $langs->trans("Orientation"); } + if ($fieldlist[$field] == 'leftmargin') { $valuetoshow = $langs->trans("LeftMargin"); } + if ($fieldlist[$field] == 'topmargin') { $valuetoshow = $langs->trans("TopMargin"); } + if ($fieldlist[$field] == 'spacex') { $valuetoshow = $langs->trans("SpaceX"); } + if ($fieldlist[$field] == 'spacey') { $valuetoshow = $langs->trans("SpaceY"); } + if ($fieldlist[$field] == 'font_size') { $valuetoshow = $langs->trans("FontSize"); } + if ($fieldlist[$field] == 'custom_x') { $valuetoshow = $langs->trans("CustomX"); } + if ($fieldlist[$field] == 'custom_y') { $valuetoshow = $langs->trans("CustomY"); } + if ($fieldlist[$field] == 'percent') { $valuetoshow = $langs->trans("Percentage"); } + if ($fieldlist[$field] == 'affect') { $valuetoshow = $langs->trans("WithCounter"); } + if ($fieldlist[$field] == 'delay') { $valuetoshow = $langs->trans("NoticePeriod"); } + if ($fieldlist[$field] == 'newbymonth') { $valuetoshow = $langs->trans("NewByMonth"); } + if ($fieldlist[$field] == 'fk_tva') { $valuetoshow = $langs->trans("VAT"); } + if ($fieldlist[$field] == 'range_ik') { $valuetoshow = $langs->trans("RangeIk"); } + if ($fieldlist[$field] == 'fk_c_exp_tax_cat') { $valuetoshow = $langs->trans("CarCategory"); } + if ($fieldlist[$field] == 'revenuestamp_type') { $valuetoshow = $langs->trans('TypeOfRevenueStamp'); } + if ($fieldlist[$field] == 'use_default') { $valuetoshow = $langs->trans('Default'); } if ($id == 2) // Special cas for state page { - if ($fieldlist[$field]=='region_id') { $valuetoshow=' '; $showfield=1; } - if ($fieldlist[$field]=='region') { $valuetoshow=$langs->trans("Country").'/'.$langs->trans("Region"); $showfield=1; } + if ($fieldlist[$field] == 'region_id') { $valuetoshow = ' '; $showfield = 1; } + if ($fieldlist[$field] == 'region') { $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region"); $showfield = 1; } } 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]); + 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; print ''; } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; } if ($id == 4) print ''; print ''; print ''; @@ -1184,14 +1184,14 @@ if ($id) foreach ($fieldlist as $key=>$val) { if (GETPOST($val) != '') - $obj->$val=GETPOST($val); + $obj->$val = GETPOST($val); } } $tmpaction = 'create'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; if ($id == 3) unset($fieldlist[2]); // Remove field ??? if dictionary Regions @@ -1209,7 +1209,7 @@ if ($id) print ''; print ""; - $colspan=count($fieldlist)+3; + $colspan = count($fieldlist) + 3; if ($id == 4) $colspan++; print '
     '; print ''; - if (! is_null($withentity)) + if (!is_null($withentity)) print ''; print '
    '; @@ -1228,7 +1228,7 @@ if ($id) // List of available record in database dol_syslog("htdocs/admin/dict", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1237,7 +1237,7 @@ if ($id) // There is several pages if ($num > $listlimit || $page) { - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); print '
    '; } @@ -1246,14 +1246,14 @@ if ($id) // Title line with search input fields print '
    '; if ($filterfound) { - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; } print '
    '; - print '
    '; + print '
    '; print ''; print ''; - if (! is_null($withentity)) + if (!is_null($withentity)) print ''; print ''; print ''; @@ -1412,21 +1412,21 @@ if ($id) else { $tmpaction = 'view'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $error = $hookmanager->error; $errors = $hookmanager->errors; if (empty($reshook)) { - $withentity=null; + $withentity = null; foreach ($fieldlist as $field => $value) { //var_dump($fieldlist); - $showfield=1; - $align="left"; - $valuetoshow=$obj->{$fieldlist[$field]}; + $showfield = 1; + $align = "left"; + $valuetoshow = $obj->{$fieldlist[$field]}; if ($fieldlist[$field] == 'entity') { $withentity = $valuetoshow; @@ -1435,111 +1435,111 @@ if ($id) if ($value == 'element') { - $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; + $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; } elseif ($value == 'source') { - $valuetoshow = isset($sourceList[$valuetoshow])?$sourceList[$valuetoshow]:$valuetoshow; + $valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow; } - elseif ($valuetoshow=='all') { - $valuetoshow=$langs->trans('All'); + elseif ($valuetoshow == 'all') { + $valuetoshow = $langs->trans('All'); } - elseif ($fieldlist[$field]=='country') { + elseif ($fieldlist[$field] == 'country') { if (empty($obj->country_code)) { - $valuetoshow='-'; + $valuetoshow = '-'; } else { - $key=$langs->trans("Country".strtoupper($obj->country_code)); - $valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country); + $key = $langs->trans("Country".strtoupper($obj->country_code)); + $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); } } - elseif ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { - $valuetoshow=yn($valuetoshow); - $align="center"; + elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { + $valuetoshow = yn($valuetoshow); + $align = "center"; } - elseif ($fieldlist[$field]=='type_cdr') { - if(empty($valuetoshow)) $valuetoshow = $langs->trans('None'); - elseif($valuetoshow == 1) $valuetoshow = $langs->trans('AtEndOfMonth'); - elseif($valuetoshow == 2) $valuetoshow = $langs->trans('CurrentNext'); - $align="center"; - } elseif ($fieldlist[$field]=='price' || preg_match('/^amount/i', $fieldlist[$field])) { - $valuetoshow=price($valuetoshow); + elseif ($fieldlist[$field] == 'type_cdr') { + if (empty($valuetoshow)) $valuetoshow = $langs->trans('None'); + elseif ($valuetoshow == 1) $valuetoshow = $langs->trans('AtEndOfMonth'); + elseif ($valuetoshow == 2) $valuetoshow = $langs->trans('CurrentNext'); + $align = "center"; + } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i', $fieldlist[$field])) { + $valuetoshow = price($valuetoshow); } if ($value == 'private') { $valuetoshow = yn($elementList[$valuetoshow]); } - elseif ($fieldlist[$field]=='libelle_facture') { + elseif ($fieldlist[$field] == 'libelle_facture') { $langs->load("bills"); - $key=$langs->trans("PaymentCondition".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); - $valuetoshow=nl2br($valuetoshow); + $key = $langs->trans("PaymentCondition".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); + $valuetoshow = nl2br($valuetoshow); } - elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') { - $key=$langs->trans("Country".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') { + $key = $langs->trans("Country".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') { $langs->load("propal"); - $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') { - $key=$langs->trans("Action".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') { + $key = $langs->trans("Action".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif (! empty($obj->code_iso) && $fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') { - $key=$langs->trans("Currency".strtoupper($obj->code_iso)); - $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->{$fieldlist[$field]}); + elseif (!empty($obj->code_iso) && $fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_currencies') { + $key = $langs->trans("Currency".strtoupper($obj->code_iso)); + $valuetoshow = ($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_typent') { - $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_typent') { + $key = $langs->trans(strtoupper($obj->code)); + $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_prospectlevel') { - $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_prospectlevel') { + $key = $langs->trans(strtoupper($obj->code)); + $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_civility') { - $key=$langs->trans("Civility".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_civility') { + $key = $langs->trans("Civility".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') { + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_contact') { $langs->load('agenda'); - $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + $key = $langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') { + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_payment_term') { $langs->load("bills"); - $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + $key = $langs->trans("PaymentConditionShort".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_paiement') { $langs->load("bills"); - $key=$langs->trans("PaymentType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + $key = $langs->trans("PaymentType".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='type' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { + elseif ($fieldlist[$field] == 'type' && $tabname[$id] == MAIN_DB_PREFIX.'c_paiement') { $payment_type_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth')); $valuetoshow = $payment_type_list[$valuetoshow]; } - elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_reason') { - $key=$langs->trans("DemandReasonType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_input_reason') { + $key = $langs->trans("DemandReasonType".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') { + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_input_method') { $langs->load("orders"); - $key=$langs->trans($obj->code); - $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->{$fieldlist[$field]}; + $key = $langs->trans($obj->code); + $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->{$fieldlist[$field]}; } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') { + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_shipment_mode') { $langs->load("sendings"); - $key=$langs->trans("SendingMethod".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + $key = $langs->trans("SendingMethod".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field] == 'libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paper_format') + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_paper_format') { $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); @@ -1550,17 +1550,17 @@ if ($id) $key = $langs->trans(strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { - $showfield=0; + elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { + $showfield = 0; } - elseif ($fieldlist[$field]=='unicode') { + elseif ($fieldlist[$field] == 'unicode') { $valuetoshow = $langs->getCurrencySymbol($obj->code, 1); } - elseif ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { + elseif ($fieldlist[$field] == 'label' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX.'c_units') { $langs->load("products"); - $valuetoshow=$langs->trans($obj->{$fieldlist[$field]}); + $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { + elseif ($fieldlist[$field] == 'short_label' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX.'c_units') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); } @@ -1569,30 +1569,30 @@ if ($id) $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='localtax1' || $fieldlist[$field]=='localtax2') { - $class="center"; + elseif ($fieldlist[$field] == 'localtax1' || $fieldlist[$field] == 'localtax2') { + $class = "center"; } - elseif ($fieldlist[$field]=='localtax1_type') { + elseif ($fieldlist[$field] == 'localtax1_type') { if ($obj->localtax1 != 0) - $valuetoshow=$localtax_typeList[$valuetoshow]; + $valuetoshow = $localtax_typeList[$valuetoshow]; else $valuetoshow = ''; - $align="center"; + $align = "center"; } - elseif ($fieldlist[$field]=='localtax2_type') { + elseif ($fieldlist[$field] == 'localtax2_type') { if ($obj->localtax2 != 0) - $valuetoshow=$localtax_typeList[$valuetoshow]; + $valuetoshow = $localtax_typeList[$valuetoshow]; else $valuetoshow = ''; - $align="center"; + $align = "center"; } - elseif ($fieldlist[$field]=='taux') { + elseif ($fieldlist[$field] == 'taux') { $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - $align="center"; + $align = "center"; } elseif (in_array($fieldlist[$field], array('recuperableonly'))) { - $align="center"; + $align = "center"; } - elseif ($fieldlist[$field]=='accountancy_code' || $fieldlist[$field]=='accountancy_code_sell' || $fieldlist[$field]=='accountancy_code_buy') { + elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy') { $valuetoshow = length_accountg($valuetoshow); } elseif ($fieldlist[$field] == 'fk_tva') @@ -1622,12 +1622,12 @@ if ($id) $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$fieldlist[$field]}); } - $class='tddict'; - if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200'; - if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto'; - if ($fieldlist[$field] == 'position') $class.=' right'; - if ($fieldlist[$field] == 'localtax1_type') $class.=' nowrap'; - if ($fieldlist[$field] == 'localtax2_type') $class.=' nowrap'; + $class = 'tddict'; + if ($fieldlist[$field] == 'note' && $id == 10) $class .= ' tdoverflowmax200'; + if ($fieldlist[$field] == 'tracking') $class .= ' tdoverflowauto'; + if ($fieldlist[$field] == 'position') $class .= ' right'; + if ($fieldlist[$field] == 'localtax1_type') $class .= ' nowrap'; + if ($fieldlist[$field] == 'localtax2_type') $class .= ' nowrap'; // Show value for field if ($showfield) print '
    '.$valuetoshow.'
    '; @@ -1730,7 +1730,7 @@ else print ''; print ''; - $showemptyline=''; + $showemptyline = ''; foreach ($taborder as $i) { if (isset($tabname[$i]) && empty($tabcond[$i])) continue; @@ -1740,13 +1740,13 @@ else if ($showemptyline) { print ''; - $showemptyline=0; + $showemptyline = 0; } - $value=$tabname[$i]; + $value = $tabname[$i]; print ''; print ''; - $lastlineisempty=false; + $lastlineisempty = false; } else { - if (! $lastlineisempty) + if (!$lastlineisempty) { - $showemptyline=1; - $lastlineisempty=true; + $showemptyline = 1; + $lastlineisempty = true; } } } @@ -1795,16 +1795,16 @@ $db->close(); */ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') { - global $conf,$langs,$db,$mysoc; + global $conf, $langs, $db, $mysoc; global $form; global $region_id; - global $elementList,$sourceList,$localtax_typeList; + global $elementList, $sourceList, $localtax_typeList; $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); $formaccounting = new FormAccounting($db); - $withentity=''; + $withentity = ''; foreach ($fieldlist as $field => $value) { @@ -1813,9 +1813,9 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') continue; } - if (in_array($fieldlist[$field], array('code', 'libelle', 'type')) && $tabname == MAIN_DB_PREFIX."c_actioncomm" && in_array($obj->type, array('system','systemauto'))) + if (in_array($fieldlist[$field], array('code', 'libelle', 'type')) && $tabname == MAIN_DB_PREFIX."c_actioncomm" && in_array($obj->type, array('system', 'systemauto'))) { - $hidden = (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''); + $hidden = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''); print ''; } elseif ($fieldlist[$field] == 'country_id') { - if (! in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) + if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) { - $country_id = (! empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); + $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); print ''; @@ -1852,7 +1852,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') } elseif ($fieldlist[$field] == 'region_id') { - $region_id = (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:0); + $region_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:0); print ''; @@ -1867,25 +1867,25 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') elseif ($fieldlist[$field] == 'element') { print ''; } // The source of the element (for contact types) elseif ($fieldlist[$field] == 'source') { print ''; } elseif ($fieldlist[$field] == 'private') { print ''; } elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm") { - $type = (! empty($obj->type)?$obj->type:'user'); // Check if type is different of 'user' (external module) + $type = (!empty($obj->type) ? $obj->type : 'user'); // Check if type is different of 'user' (external module) print ''; @@ -1894,57 +1894,57 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') { print ''; } elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'type_cdr' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { if ($fieldlist[$field] == 'type_cdr') print ''; } - elseif (in_array($fieldlist[$field], array('nbjour','decalage','taux','localtax1','localtax2'))) { - $align="left"; - if (in_array($fieldlist[$field], array('taux','localtax1','localtax2'))) $align="center"; // Fields aligned on right + elseif (in_array($fieldlist[$field], array('nbjour', 'decalage', 'taux', 'localtax1', 'localtax2'))) { + $align = "left"; + if (in_array($fieldlist[$field], array('taux', 'localtax1', 'localtax2'))) $align = "center"; // Fields aligned on right print ''; } elseif (in_array($fieldlist[$field], array('libelle_facture'))) { print ''; } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i', $fieldlist[$field])) { - print ''; + print ''; } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { - print ''; + print ''; } - elseif ($fieldlist[$field]=='unit') { + elseif ($fieldlist[$field] == 'unit') { print ''; } // Le type de taxe locale elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type') { print ''; } elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy') { print ''; } @@ -1998,41 +1998,41 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') } else { - $fieldValue = isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''; + $fieldValue = isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''; - if ($fieldlist[$field]=='sortorder') + if ($fieldlist[$field] == 'sortorder') { - $fieldlist[$field]='position'; + $fieldlist[$field] = 'position'; } - $classtd=''; $class=''; - if ($fieldlist[$field]=='code') $class='maxwidth100'; - if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'pos', 'use_default', 'affect', 'delay', 'position', 'sortorder', 'sens', 'category_type'))) $class='maxwidth50'; - if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) $class='quatrevingtpercent'; + $classtd = ''; $class = ''; + if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; + if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'pos', 'use_default', 'affect', 'delay', 'position', 'sortorder', 'sens', 'category_type'))) $class = 'maxwidth50'; + if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) $class = 'quatrevingtpercent'; print ''; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index dc3f8638e10..284427e4536 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","errors")); +$langs->loadLangs(array("admin", "errors")); if (!$user->admin) accessforbidden(); @@ -48,25 +48,25 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'setvalue' && $user->admin) { - $error=0; + $error = 0; $db->begin(); - if (! dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; //if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++; // This one must be after the others - $valkey=''; - $key=GETPOST("key"); - if ($key) $valkey=$conf->global->$key; - if (! dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + $valkey = ''; + $key = GETPOST("key"); + if ($key) $valkey = $conf->global->$key; + if (!dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -85,14 +85,14 @@ if ($action == 'setvalue' && $user->admin) */ llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (! function_exists("ldap_connect")) +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -107,7 +107,7 @@ print '
    '; print ''; print ''; -$form=new Form($db); +$form = new Form($db); print '
    '.$langs->trans("Table").'
       
    '; - if (! empty($tabcond[$i])) + if (!empty($tabcond[$i])) { print ''.$langs->trans($tablib[$i]).''; } @@ -1762,14 +1762,14 @@ else }*/ print ''.$tabname[$i].'
    '; print ''; print $langs->trans($hidden); @@ -1830,15 +1830,15 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') continue; } // For state page, we do not show the country input (we link to region, not country) print ''; - $fieldname='country'; - print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone'); + $fieldname = 'country'; + print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone'); print ''; print ''; print ''; print ''; print ''; - print $form->selectarray('element', $elementList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectarray('element', $elementList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print ''; - print $form->selectarray('source', $sourceList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectarray('source', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print ''; - print $form->selectyesno("private", (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectyesno("private", (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print ''; print $type.''; print ''; $select_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth')); - print $form->selectarray($fieldlist[$field], $select_list, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'2')); + print $form->selectarray($fieldlist[$field], $select_list, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'2')); print ''; else print ''; if ($fieldlist[$field] == 'type_cdr') { - print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); } else { - print $form->selectyesno($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1); + print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); } print ''; print ''; print ''; - $transfound=0; - $transkey=''; + $transfound = 0; + $transkey = ''; // Special case for labels if ($tabname == MAIN_DB_PREFIX.'c_payment_term') { $langs->load("bills"); - $transkey="PaymentCondition".strtoupper($obj->code); + $transkey = "PaymentCondition".strtoupper($obj->code); if ($langs->trans($transkey) != $transkey) { - $transfound=1; + $transfound = 1; print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis")); } } - if (! $transfound) + if (!$transfound) { - print ''; + print ''; } - else{ + else { print ''; } print ''; $units = array( 'mm' => $langs->trans('SizeUnitmm'), @@ -1952,29 +1952,29 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') 'point' => $langs->trans('SizeUnitpoint'), 'inch' => $langs->trans('SizeUnitinch') ); - print $form->selectarray('unit', $units, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 0, 0, 0); + print $form->selectarray('unit', $units, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 0, 0, 0); print ''; - print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectarray($fieldlist[$field], $localtax_typeList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $fieldname = $fieldlist[$field]; - $accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0); + $accountancy_account = (!empty($obj->$fieldname) ? $obj->$fieldname : 0); print $formaccounting->select_account($accountancy_account, '.'.$fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); } else { $fieldname = $fieldlist[$field]; - print ''; + print ''; } print ''; - $transfound=0; - $transkey=''; - if (in_array($fieldlist[$field], array('label','libelle'))) // For label + $transfound = 0; + $transkey = ''; + if (in_array($fieldlist[$field], array('label', 'libelle'))) // For label { // Special case for labels if ($tabname == MAIN_DB_PREFIX.'c_civility') { - $transkey="Civility".strtoupper($obj->code); + $transkey = "Civility".strtoupper($obj->code); } if ($tabname == MAIN_DB_PREFIX.'c_payment_term') { $langs->load("bills"); - $transkey="PaymentConditionShort".strtoupper($obj->code); + $transkey = "PaymentConditionShort".strtoupper($obj->code); } if ($transkey && $langs->trans($transkey) != $transkey) { - $transfound=1; + $transfound = 1; print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis")); } } - if (! $transfound) + if (!$transfound) { - print ''; + print ''; } - else{ + else { print ''; } print '
    '; @@ -145,7 +145,7 @@ print "\n"; print ''; -print '"; +print '"; print ''; // Name @@ -161,14 +161,14 @@ print ''; print ''; -print '"; +print '"; print ''; // User group print ''; -print '"; +print '"; print ''; // Group id @@ -194,11 +194,11 @@ print ''; */ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { - $butlabel=$langs->trans("LDAPTestSynchroGroup"); - $testlabel='testgroup'; - $key=$conf->global->LDAP_KEY_GROUPS; - $dn=$conf->global->LDAP_GROUP_DN; - $objectclass=$conf->global->LDAP_GROUP_OBJECT_CLASS; + $butlabel = $langs->trans("LDAPTestSynchroGroup"); + $testlabel = 'testgroup'; + $key = $conf->global->LDAP_KEY_GROUPS; + $dn = $conf->global->LDAP_GROUP_DN; + $objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); } @@ -208,26 +208,26 @@ if (function_exists("ldap_connect")) if ($_GET["action"] == 'testgroup') { // Creation objet - $object=new UserGroup($db); + $object = new UserGroup($db); $object->initAsSpecimen(); // Test synchro - $ldap=new Ldap(); - $result=$ldap->connect_bind(); + $ldap = new Ldap(); + $result = $ldap->connect_bind(); if ($result > 0) { - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info); + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info); // Get a gid number for objectclass PosixGroup if (in_array('posixGroup', $info['objectclass'])) { $info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS'); } - $result1=$ldap->delete($dn); // To be sure to delete existing records - $result2=$ldap->add($dn, $info, $user); // Now the test - $result3=$ldap->delete($dn); // Clean what we did + $result1 = $ldap->delete($dn); // To be sure to delete existing records + $result2 = $ldap->add($dn, $info, $user); // Now the test + $result3 = $ldap->delete($dn); // Clean what we did if ($result2 > 0) { diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 2a2aff88507..adc60f8969c 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -48,23 +48,23 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'setvalue' && $user->admin) { - $error=0; + $error = 0; $db->begin(); - if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN', GETPOST("membertype"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN', GETPOST("membertype"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS', GETPOST("fieldmembertypemembers"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS', GETPOST("fieldmembertypemembers"), 'chaine', 0, '', $conf->entity)) $error++; // This one must be after the others - $valkey=''; - $key=GETPOST("key"); - if ($key) $valkey=$conf->global->$key; - if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + $valkey = ''; + $key = GETPOST("key"); + if ($key) $valkey = $conf->global->$key; + if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES', $valkey, 'chaine', 0, '', $conf->entity)) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -83,14 +83,14 @@ if ($action == 'setvalue' && $user->admin) */ llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (! function_exists("ldap_connect")) +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -105,7 +105,7 @@ print '
    '; print ''; print ''; -$form=new Form($db); +$form = new Form($db); print '
    '.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldCommonNameExample").'global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_FULLNAME)?' checked':'').">global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_FULLNAME) ? ' checked' : '').">
    '.$langs->trans("LDAPFieldDescription").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").'global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_DESCRIPTION)?' checked':'').">global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_DESCRIPTION) ? ' checked' : '').">
    '.$langs->trans("LDAPFieldGroupMembers").''; print ''; print ''.$langs->trans("LDAPFieldGroupMembersExample").'global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)?' checked':'').">global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS) ? ' checked' : '').">
    '; @@ -143,21 +143,21 @@ print "\n"; print ''; -print '"; +print '"; print ''; // Description print ''; -print '"; +print '"; print ''; // User group print ''; -print '"; +print '"; print ''; print '
    '.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldCommonNameExample").'global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)?' checked':'').">global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME) ? ' checked' : '').">
    '.$langs->trans("LDAPFieldDescription").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").'global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBER_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)?' checked':'').">global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBER_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION) ? ' checked' : '').">
    '.$langs->trans("LDAPFieldGroupMembers").''; print ''; print ''.$langs->trans("LDAPFieldGroupMembersExample").'global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)?' checked':'').">global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS) ? ' checked' : '').">
    '; @@ -176,11 +176,11 @@ print ''; */ if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { - $butlabel=$langs->trans("LDAPTestSynchroMemberType"); - $testlabel='testmembertype'; - $key=$conf->global->LDAP_KEY_MEMBERS_TYPES; - $dn=$conf->global->LDAP_MEMBER_TYPE_DN; - $objectclass=$conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS; + $butlabel = $langs->trans("LDAPTestSynchroMemberType"); + $testlabel = 'testmembertype'; + $key = $conf->global->LDAP_KEY_MEMBERS_TYPES; + $dn = $conf->global->LDAP_MEMBER_TYPE_DN; + $objectclass = $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); } @@ -190,26 +190,26 @@ if (function_exists("ldap_connect")) if ($_GET["action"] == 'testmembertype') { // Creation objet - $object=new AdherentType($db); + $object = new AdherentType($db); $object->initAsSpecimen(); // Test synchro - $ldap=new Ldap(); - $result=$ldap->connect_bind(); + $ldap = new Ldap(); + $result = $ldap->connect_bind(); if ($result > 0) { - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info); + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info); // Get a gid number for objectclass PosixGroup if (in_array('posixGroup', $info['objectclass'])) { $info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPES'); } - $result1=$ldap->delete($dn); // To be sure to delete existing records - $result2=$ldap->add($dn, $info, $user); // Now the test - $result3=$ldap->delete($dn); // Clean what we did + $result1 = $ldap->delete($dn); // To be sure to delete existing records + $result2 = $ldap->add($dn, $info, $user); // Now the test + $result3 = $ldap->delete($dn); // Clean what we did if ($result2 > 0) { diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index ccc33ab3cee..a97952cb2df 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -26,7 +26,7 @@ require '../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'loan')); @@ -38,7 +38,7 @@ if (!$user->admin) $action = GETPOST('action', 'alpha'); // Other parameters LOAN_* -$list = array ( +$list = array( 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL', 'LOAN_ACCOUNTING_ACCOUNT_INTEREST', 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE' @@ -60,7 +60,7 @@ if ($action == 'update') } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -77,9 +77,9 @@ if ($action == 'update') llxHeader(); $form = new Form($db); -if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup'); print '
    '; @@ -91,7 +91,7 @@ print ''; */ print ''; print ''; -print ''; +print ''; print "\n"; foreach ($list as $key) @@ -104,7 +104,7 @@ foreach ($list as $key) // Value print ''; print ''; print ''; @@ -361,15 +361,15 @@ if ($action == 'create') { print ''; } print ''; // Mainmenu code print ''; - print ''; + print ''; print ''; @@ -382,7 +382,7 @@ if ($action == 'create') } else { - print ''; + print ''; } print ''; // Position - print ''; + print ''; // Target print ''; // Enabled - print ''; + print ''; // Perms - print ''; + print ''; print '
    ' . $langs->trans('Options') . ''.$langs->trans('Options').'
    '; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); } diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index f0ebb0f7794..b55edaa4ba7 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -29,32 +29,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; // Load translation files required by the page -$langs->loadLangs(array("other","admin")); +$langs->loadLangs(array("other", "admin")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $dirstandard = array(); $dirsmartphone = array(); -$dirmenus=array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); -foreach($dirmenus as $dirmenu) +$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); +foreach ($dirmenus as $dirmenu) { - $dirstandard[]=$dirmenu.'standard'; - $dirsmartphone[]=$dirmenu.'smartphone'; + $dirstandard[] = $dirmenu.'standard'; + $dirsmartphone[] = $dirmenu.'smartphone'; } -$action=GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); -$menu_handler_top=$conf->global->MAIN_MENU_STANDARD; -$menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE; -$menu_handler_top=preg_replace('/_backoffice.php/i', '', $menu_handler_top); -$menu_handler_top=preg_replace('/_frontoffice.php/i', '', $menu_handler_top); -$menu_handler_smartphone=preg_replace('/_backoffice.php/i', '', $menu_handler_smartphone); -$menu_handler_smartphone=preg_replace('/_frontoffice.php/i', '', $menu_handler_smartphone); +$menu_handler_top = $conf->global->MAIN_MENU_STANDARD; +$menu_handler_smartphone = $conf->global->MAIN_MENU_SMARTPHONE; +$menu_handler_top = preg_replace('/_backoffice.php/i', '', $menu_handler_top); +$menu_handler_top = preg_replace('/_frontoffice.php/i', '', $menu_handler_top); +$menu_handler_smartphone = preg_replace('/_backoffice.php/i', '', $menu_handler_smartphone); +$menu_handler_smartphone = preg_replace('/_frontoffice.php/i', '', $menu_handler_smartphone); -$menu_handler=$menu_handler_top; +$menu_handler = $menu_handler_top; -if (GETPOST("handler_origine")) $menu_handler=GETPOST("handler_origine"); -if (GETPOST("menu_handler")) $menu_handler=GETPOST("menu_handler"); +if (GETPOST("handler_origine")) $menu_handler = GETPOST("handler_origine"); +if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler"); @@ -64,53 +64,53 @@ if (GETPOST("menu_handler")) $menu_handler=GETPOST("menu_handler"); if ($action == 'update') { - if (! $_POST['cancel']) + if (!$_POST['cancel']) { - $leftmenu=''; $mainmenu=''; - if (! empty($_POST['menuIdParent']) && ! is_numeric($_POST['menuIdParent'])) + $leftmenu = ''; $mainmenu = ''; + if (!empty($_POST['menuIdParent']) && !is_numeric($_POST['menuIdParent'])) { - $tmp=explode('&', $_POST['menuIdParent']); - foreach($tmp as $s) + $tmp = explode('&', $_POST['menuIdParent']); + foreach ($tmp as $s) { if (preg_match('/fk_mainmenu=/', $s)) { - $mainmenu=preg_replace('/fk_mainmenu=/', '', $s); + $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); } if (preg_match('/fk_leftmenu=/', $s)) { - $leftmenu=preg_replace('/fk_leftmenu=/', '', $s); + $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); } } } $menu = new Menubase($db); - $result=$menu->fetch(GETPOST('menuId', 'int')); + $result = $menu->fetch(GETPOST('menuId', 'int')); if ($result > 0) { - $menu->titre=GETPOST('titre', 'alpha'); // deprecated - $menu->title=GETPOST('titre', 'alpha'); - $menu->leftmenu=GETPOST('leftmenu', 'aZ09'); - $menu->url=GETPOST('url', 'alpha'); - $menu->langs=GETPOST('langs', 'alpha'); - $menu->position=GETPOST('position', 'int'); - $menu->enabled=GETPOST('enabled', 'alpha'); - $menu->perms=GETPOST('perms', 'alpha'); - $menu->target=GETPOST('target', 'alpha'); - $menu->user=GETPOST('user', 'alpha'); - $menu->mainmenu=GETPOST('propertymainmenu', 'alpha'); + $menu->titre = GETPOST('titre', 'alpha'); // deprecated + $menu->title = GETPOST('titre', 'alpha'); + $menu->leftmenu = GETPOST('leftmenu', 'aZ09'); + $menu->url = GETPOST('url', 'alpha'); + $menu->langs = GETPOST('langs', 'alpha'); + $menu->position = GETPOST('position', 'int'); + $menu->enabled = GETPOST('enabled', 'alpha'); + $menu->perms = GETPOST('perms', 'alpha'); + $menu->target = GETPOST('target', 'alpha'); + $menu->user = GETPOST('user', 'alpha'); + $menu->mainmenu = GETPOST('propertymainmenu', 'alpha'); if (is_numeric(GETPOST('menuIdParent', 'alpha'))) { - $menu->fk_menu=GETPOST('menuIdParent', 'alpha'); + $menu->fk_menu = GETPOST('menuIdParent', 'alpha'); } else { - if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu=0; - else $menu->fk_menu=-1; - $menu->fk_mainmenu=$mainmenu; - $menu->fk_leftmenu=$leftmenu; + if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0; + else $menu->fk_menu = -1; + $menu->fk_mainmenu = $mainmenu; + $menu->fk_leftmenu = $leftmenu; } - $result=$menu->update($user); + $result = $menu->update($user); if ($result > 0) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); @@ -144,91 +144,91 @@ if ($action == 'add') exit; } - $leftmenu=''; $mainmenu=''; - if (GETPOST('menuId', 'alpha', 3) && ! is_numeric(GETPOST('menuId', 'alpha', 3))) + $leftmenu = ''; $mainmenu = ''; + if (GETPOST('menuId', 'alpha', 3) && !is_numeric(GETPOST('menuId', 'alpha', 3))) { - $tmp=explode('&', GETPOST('menuId', 'alpha', 3)); - foreach($tmp as $s) + $tmp = explode('&', GETPOST('menuId', 'alpha', 3)); + foreach ($tmp as $s) { if (preg_match('/fk_mainmenu=/', $s)) { - $mainmenu=preg_replace('/fk_mainmenu=/', '', $s); + $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); } if (preg_match('/fk_leftmenu=/', $s)) { - $leftmenu=preg_replace('/fk_leftmenu=/', '', $s); + $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); } } } $langs->load("errors"); - $error=0; - if (! $error && ! $_POST['menu_handler']) + $error = 0; + if (!$error && !$_POST['menu_handler']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors'); $action = 'create'; $error++; } - if (! $error && ! $_POST['type']) + if (!$error && !$_POST['type']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); $action = 'create'; $error++; } - if (! $error && ! $_POST['url']) + if (!$error && !$_POST['url']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); $action = 'create'; $error++; } - if (! $error && ! $_POST['titre']) + if (!$error && !$_POST['titre']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); $action = 'create'; $error++; } - if (! $error && $_POST['menuId'] && $_POST['type'] == 'top') + if (!$error && $_POST['menuId'] && $_POST['type'] == 'top') { setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors'); $action = 'create'; $error++; } - if (! $error && ! $_POST['menuId'] && $_POST['type'] == 'left') + if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left') { setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors'); $action = 'create'; $error++; } - if (! $error) + if (!$error) { $menu = new Menubase($db); - $menu->menu_handler=preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); - $menu->type=GETPOST('type', 'alpha'); - $menu->titre=GETPOST('titre', 'alpha'); // deprecated - $menu->title=GETPOST('titre', 'alpha'); - $menu->url=GETPOST('url', 'alpha'); - $menu->langs=GETPOST('langs', 'alpha'); - $menu->position=GETPOST('position', 'int'); - $menu->enabled=GETPOST('enabled', 'alpha'); - $menu->perms=GETPOST('perms', 'alpha'); - $menu->target=GETPOST('target', 'alpha'); - $menu->user=GETPOST('user', 'alpha'); - $menu->mainmenu=GETPOST('propertymainmenu', 'alpha'); + $menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); + $menu->type = GETPOST('type', 'alpha'); + $menu->titre = GETPOST('titre', 'alpha'); // deprecated + $menu->title = GETPOST('titre', 'alpha'); + $menu->url = GETPOST('url', 'alpha'); + $menu->langs = GETPOST('langs', 'alpha'); + $menu->position = GETPOST('position', 'int'); + $menu->enabled = GETPOST('enabled', 'alpha'); + $menu->perms = GETPOST('perms', 'alpha'); + $menu->target = GETPOST('target', 'alpha'); + $menu->user = GETPOST('user', 'alpha'); + $menu->mainmenu = GETPOST('propertymainmenu', 'alpha'); if (is_numeric(GETPOST('menuId', 'alpha', 3))) { - $menu->fk_menu=GETPOST('menuId', 'alpha', 3); + $menu->fk_menu = GETPOST('menuId', 'alpha', 3); } else { - if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu=0; - else $menu->fk_menu=-1; - $menu->fk_mainmenu=$mainmenu; - $menu->fk_leftmenu=$leftmenu; + 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); + $result = $menu->create($user); if ($result > 0) { header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".GETPOST('menu_handler', 'aZ09')); @@ -248,7 +248,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes') $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int'); - $result=$db->query($sql); + $result = $db->query($sql); if ($result == 0) { @@ -257,14 +257,14 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes') llxHeader(); setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs'); llxFooter(); - exit ; + exit; } else { $this->db->rollback(); $reload = 0; - $_GET["action"]=''; + $_GET["action"] = ''; } } @@ -274,8 +274,8 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes') * View */ -$form=new Form($db); -$formadmin=new FormAdmin($db); +$form = new Form($db); +$formadmin = new FormAdmin($db); llxHeader('', $langs->trans("Menu")); @@ -320,7 +320,7 @@ if ($action == 'create') if (GETPOST('menuId', 'int')) { $sql = "SELECT m.rowid, m.mainmenu, m.leftmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".GETPOST('menuId', 'int'); - $res = $db->query($sql); + $res = $db->query($sql); if ($res) { while ($menu = $db->fetch_array($res)) @@ -337,7 +337,7 @@ if ($action == 'create') // Handler print '
    '.$langs->trans('MenuHandler').''; - $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler)?'':'_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone)); + $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler) ? '' : '_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone)); print ''.$langs->trans('DetailMenuHandler').'
    '.$langs->trans('DetailType').'
    '.$langs->trans('MainMenuCode').''; print $langs->trans("Example").': mytopmenukey'; print '
    '.$langs->trans('DetailMenuIdParent'); print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; @@ -398,19 +398,19 @@ if ($action == 'create') print '
    '.$langs->trans('LangFile').''.$langs->trans('DetailLangs').'
    '.$langs->trans('Position').''.$langs->trans('DetailPosition').'
    '.$langs->trans('Position').''.$langs->trans('DetailPosition').'
    '.$langs->trans('Target').''.$langs->trans('DetailTarget').'
    '.$langs->trans('Enabled').''.$langs->trans('DetailEnabled').'
    '.$langs->trans('Enabled').''.$langs->trans('DetailEnabled').'
    '.$langs->trans('Rights').''.$langs->trans('DetailRight').'
    '.$langs->trans('Rights').''.$langs->trans('DetailRight').'
    '; @@ -439,7 +439,7 @@ elseif ($action == 'edit') print ''; $menu = new Menubase($db); - $result=$menu->fetch(GETPOST('menuId', 'int')); + $result = $menu->fetch(GETPOST('menuId', 'int')); //var_dump($menu); // Id @@ -455,9 +455,9 @@ elseif ($action == 'edit') // User print ''; // Type @@ -473,7 +473,7 @@ elseif ($action == 'edit') } else {*/ - print ''; + print ''; //} print ''; - $valtouse=$menu->fk_menu; - if ($menu->fk_mainmenu) $valtouse='fk_mainmenu='.$menu->fk_mainmenu; - if ($menu->fk_leftmenu) $valtouse.='&fk_leftmenu='.$menu->fk_leftmenu; + $valtouse = $menu->fk_menu; + if ($menu->fk_mainmenu) $valtouse = 'fk_mainmenu='.$menu->fk_mainmenu; + if ($menu->fk_leftmenu) $valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu; print ''; print ''; // Enabled print ''; // Perms print ''; print '
    '.$langs->trans('MenuForUsers').''.$langs->trans('DetailUser').'
    mainmenu).'">mainmenu).'">'; print $langs->trans("Example").': mytopmenukey'; @@ -483,9 +483,9 @@ elseif ($action == 'edit') // MenuId Parent print '
    '.$langs->trans('MenuIdParent'); print ''.$langs->trans('DetailMenuIdParent'); print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; @@ -508,18 +508,18 @@ elseif ($action == 'edit') // Target print '
    '.$langs->trans('Target').''.$langs->trans('DetailTarget').'
    '.$langs->trans('Enabled').''.$langs->trans('DetailEnabled'); - if (! empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')'; + if (!empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')'; print '
    '.$langs->trans('Rights').''.$langs->trans('DetailRight'); - if (! empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')'; + if (!empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')'; print '
    '; diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 515340efe89..d6a7fb26a98 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; $langs->loadLangs(array('admin', 'multicurrency')); // Access control -if (! $user->admin) { +if (!$user->admin) { accessforbidden(); } @@ -48,8 +48,8 @@ $action = GETPOST('action', 'alpha'); if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; - $value=GETPOST($code, 'alpha'); + $code = $reg[1]; + $value = GETPOST($code, 'alpha'); if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -62,7 +62,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -75,7 +75,7 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if ($action == 'add_currency') { - $error=0; + $error = 0; $langs->loadCacheCurrencies(''); @@ -90,7 +90,7 @@ if ($action == 'add_currency') setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { if ($currency->create($user) > 0) { @@ -115,12 +115,12 @@ elseif ($action == 'update_currency') setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { if ($currency->fetch($fk_multicurrency) > 0) { - $result=$currency->updateRate($rate); - if ($result<0) { + $result = $currency->updateRate($rate); + if ($result < 0) { setEventMessages(null, $currency->errors, 'errors'); } } @@ -171,14 +171,14 @@ if ($resql) * View */ -$form=new Form($db); +$form = new Form($db); $page_name = "MultiCurrencySetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback); // Configuration header @@ -272,7 +272,7 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) print '
    '; print ''; - $urlforapilayer='https://currencylayer.com'; //https://apilayer.net + $urlforapilayer = 'https://currencylayer.com'; //https://apilayer.net print ''; print ''."\n"; diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index fb2be946169..eb6f8d18fe4 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -47,45 +47,45 @@ if ($action == 'setvalue' && $user->admin) { $db->begin(); - $result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", $_POST["email_from"], 'chaine', 0, '', $conf->entity); + $result = dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", $_POST["email_from"], 'chaine', 0, '', $conf->entity); if ($result < 0) $error++; - if (! $error && is_array($_POST)) + if (!$error && is_array($_POST)) { //var_dump($_POST); - foreach($_POST as $key => $val) + foreach ($_POST as $key => $val) { - if (! preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue; + if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue; - $newval=''; - $newkey=''; + $newval = ''; + $newkey = ''; - $shortkey=preg_replace('/_key$/', '', $key); + $shortkey = preg_replace('/_key$/', '', $key); //print $shortkey.'
    '; if (preg_match('/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) { dolibarr_del_const($db, 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.$reg[2], $conf->entity); - $newkey='NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); - $newval=GETPOST($shortkey.'_key'); + $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); + $newval = GETPOST($shortkey.'_key'); //print $newkey.' - '.$newval.'
    '; } elseif (preg_match('/^NOTIF_(.*)_new_key/', $key, $reg)) { // Add a new entry - $newkey='NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); - $newval=GETPOST($shortkey.'_key'); + $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); + $newval = GETPOST($shortkey.'_key'); } if ($newkey && $newval) { - $result=dolibarr_set_const($db, $newkey, $newval, 'chaine', 0, '', $conf->entity); + $result = dolibarr_set_const($db, $newkey, $newval, 'chaine', 0, '', $conf->entity); } } } - if (! $error) + if (!$error) { $db->commit(); @@ -105,17 +105,17 @@ if ($action == 'setvalue' && $user->admin) * View */ -$form=new Form($db); +$form = new Form($db); $notify = new Notify($db); llxHeader('', $langs->trans("NotificationSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("NotificationSetup"), $linkback, 'title_setup'); print $langs->trans("NotificationsDesc").'
    '; print $langs->trans("NotificationsDescUser").'
    '; -if (! empty($conf->societe->enabled)) print $langs->trans("NotificationsDescContact").'
    '; +if (!empty($conf->societe->enabled)) print $langs->trans("NotificationsDescContact").'
    '; print $langs->trans("NotificationsDescGlobal").'
    '; print '
    '; @@ -133,7 +133,7 @@ print ''; print ''; print ''; print '
    '.$form->textwithpicto($langs->trans("CurrencyLayerAccount"), $langs->trans("CurrencyLayerAccount_help_to_synchronize", $urlforapilayer)).'
    '; print $langs->trans("NotificationEMailFrom").''; print ''; -if (! empty($conf->global->NOTIFICATION_EMAIL_FROM) && ! isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("ErrorBadEMail")); +if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("ErrorBadEMail")); print '
    '; @@ -142,8 +142,8 @@ print '

    '; // Notification per contacts -$title=$langs->trans("ListOfNotificationsPerUser"); -if (! empty($conf->societe->enabled)) $title=$langs->trans("ListOfNotificationsPerUserOrContact"); +$title = $langs->trans("ListOfNotificationsPerUser"); +if (!empty($conf->societe->enabled)) $title = $langs->trans("ListOfNotificationsPerUserOrContact"); print load_fiche_titre($title, '', ''); print ''; @@ -155,16 +155,16 @@ print ''; print "\n"; // Load array of available notifications -$notificationtrigger=new InterfaceNotification($db); -$listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); +$notificationtrigger = new InterfaceNotification($db); +$listofnotifiedevents = $notificationtrigger->getListOfManagedEvents(); print ''; print ''; print '
    '.$langs->trans("Label").'
    '; -$i=0; -foreach($listofnotifiedevents as $notifiedevent) +$i = 0; +foreach ($listofnotifiedevents as $notifiedevent) { - $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; + $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); @@ -185,7 +185,7 @@ print '
    '; print '
    '; print '* '.$langs->trans("GoOntoUserCardToAddMore").'
    '; -if (! empty($conf->societe->enabled)) print '** '.$langs->trans("GoOntoContactCardToAddMore").'
    '; +if (!empty($conf->societe->enabled)) print '** '.$langs->trans("GoOntoContactCardToAddMore").'
    '; print '
    '; print '

    '; @@ -203,12 +203,12 @@ print '
    '.'
    '.$label.''; // Notification with threshold - foreach($conf->global as $key => $val) + foreach ($conf->global as $key => $val) { - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; - $param='NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1]; - $value=GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key')?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha'):$conf->global->$param; + $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1]; + $value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : $conf->global->$param; - $s=''; // Do not use type="email" here, we must be able to enter a list of email with , separator. - $arrayemail=explode(',', $value); - $showwarning=0; - foreach($arrayemail as $keydet => $valuedet) + $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. + $arrayemail = explode(',', $value); + $showwarning = 0; + foreach ($arrayemail as $keydet => $valuedet) { - $valuedet=trim($valuedet); - if (! empty($valuedet) && ! isValidEmail($valuedet, 1)) $showwarning++; + $valuedet = trim($valuedet); + if (!empty($valuedet) && !isValidEmail($valuedet, 1)) $showwarning++; } - if ((! empty($conf->global->$param)) && $showwarning) $s.=' '.img_warning($langs->trans("ErrorBadEMail")); + if ((!empty($conf->global->$param)) && $showwarning) $s .= ' '.img_warning($langs->trans("ErrorBadEMail")); print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
    '.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); print '
    '; } // New entry input fields - $s=''; // Do not use type="email" here, we must be able to enter a list of email with , separator. + $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
    '.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); print '
    '; // Notification with threshold - foreach($conf->global as $key => $val) + foreach ($conf->global as $key => $val) { - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; print $langs->trans("AmountHT").' >= '; print '
    '; diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 780f22894e9..25afbaad943 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -29,8 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current // Load translation files required by the page @@ -60,7 +60,7 @@ if ($action == 'update') $error++; } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null); } else { @@ -76,7 +76,7 @@ llxHeader(); $form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); print ''; @@ -92,29 +92,29 @@ print $langs->trans("ListOfSupportedOauthProviders").'

    '; print ''; -$i=0; +$i = 0; // $list is defined into oauth.lib.php foreach ($list as $key) { - $supported=0; - if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1; - if (! $supported) continue; // show only supported + $supported = 0; + if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1; + if (!$supported) continue; // show only supported $i++; - print ''; + print ''; // Api Name $label = $langs->trans($key[0]); print ''; print ''; print ''; if ($supported) { - $redirect_uri=$urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; + $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; print ''; print ''; print '\n"; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("OAuthIDSecret").''; print ''."\n"; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("IsTokenGenerated"); print ''; @@ -270,7 +270,7 @@ if ($mode == 'setup' && $user->admin) print ''; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("Token").''; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("TOKEN_REFRESH").''; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("TOKEN_EXPIRED").''; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("TOKEN_EXPIRE_AT").''; print '
    '.$label.''; - if (! empty($key[3])) print $langs->trans($key[3]); + if (!empty($key[3])) print $langs->trans($key[3]); print '
    '.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 125ef2458b7..01d36898c78 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -31,7 +31,7 @@ use OAuth\Common\Storage\DoliStorage; // Load translation files required by the page $langs->loadLangs(array('admin', 'printing', 'oauth')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $mode = GETPOST('mode', 'alpha'); @@ -39,9 +39,9 @@ $value = GETPOST('value', 'alpha'); $varname = GETPOST('varname', 'alpha'); $driver = GETPOST('driver', 'alpha'); -if (! empty($driver)) $langs->load($driver); +if (!empty($driver)) $langs->load($driver); -if (!$mode) $mode='setup'; +if (!$mode) $mode = 'setup'; /* @@ -57,15 +57,15 @@ if (!$mode) $mode='setup'; if ($action == 'setconst' && $user->admin) { - $error=0; + $error = 0; $db->begin(); foreach ($_POST['setupdriver'] as $setupconst) { //print '
    '.print_r($setupconst, true).'
    '; - $result=dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity); - if (! $result > 0) $error++; + $result = dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity); + if (!$result > 0) $error++; } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null); @@ -75,17 +75,17 @@ if ($action == 'setconst' && $user->admin) $db->rollback(); dol_print_error($db); } - $action=''; + $action = ''; } if ($action == 'setvalue' && $user->admin) { $db->begin(); - $result=dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity); - if (! $result > 0) $error++; + $result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity); + if (!$result > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null); @@ -104,15 +104,15 @@ if ($action == 'setvalue' && $user->admin) */ // Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current $form = new Form($db); llxHeader('', $langs->trans("PrintingSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); $head = oauthadmin_prepare_head(); @@ -124,52 +124,52 @@ if ($mode == 'setup' && $user->admin) { print $langs->trans("OAuthSetupForLogin")."

    \n"; - foreach($list as $key) + foreach ($list as $key) { - $supported=0; - if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1; - if (! $supported) continue; // show only supported + $supported = 0; + if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1; + if (!$supported) continue; // show only supported - $OAUTH_SERVICENAME='Unknown'; + $OAUTH_SERVICENAME = 'Unknown'; if ($key[0] == 'OAUTH_GITHUB_NAME') { - $OAUTH_SERVICENAME='GitHub'; - $urltorenew=$urlwithroot.'/core/modules/oauth/github_oauthcallback.php?state=user,public_repo&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltodelete=$urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltocheckperms='https://github.com/settings/applications/'; + $OAUTH_SERVICENAME = 'GitHub'; + $urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?state=user,public_repo&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltocheckperms = 'https://github.com/settings/applications/'; } elseif ($key[0] == 'OAUTH_GOOGLE_NAME') { - $OAUTH_SERVICENAME='Google'; - $urltorenew=$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltodelete=$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltocheckperms='https://security.google.com/settings/security/permissions'; + $OAUTH_SERVICENAME = 'Google'; + $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltocheckperms = 'https://security.google.com/settings/security/permissions'; } elseif ($key[0] == 'OAUTH_STRIPE_TEST_NAME') { - $OAUTH_SERVICENAME='StripeTest'; - $urltorenew=$urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltodelete=''; - $urltocheckperms=''; + $OAUTH_SERVICENAME = 'StripeTest'; + $urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete = ''; + $urltocheckperms = ''; } elseif ($key[0] == 'OAUTH_STRIPE_LIVE_NAME') { - $OAUTH_SERVICENAME='StripeLive'; - $urltorenew=$urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltodelete=''; - $urltocheckperms=''; + $OAUTH_SERVICENAME = 'StripeLive'; + $urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete = ''; + $urltocheckperms = ''; } else { - $urltorenew=''; - $urltodelete=''; - $urltocheckperms=''; + $urltorenew = ''; + $urltodelete = ''; + $urltocheckperms = ''; } // Show value of token - $tokenobj=null; + $tokenobj = null; // Token require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; @@ -179,14 +179,14 @@ if ($mode == 'setup' && $user->admin) { $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME); } - catch(Exception $e) + catch (Exception $e) { // Return an error if token not found } // Set other properties - $refreshtoken=false; - $expiredat=''; + $refreshtoken = false; + $expiredat = ''; $expire = false; // Is token expired or will token expire in the next 30 seconds @@ -209,12 +209,12 @@ if ($mode == 'setup' && $user->admin) } else { - $expiredat=dol_print_date($endoflife, "dayhour"); + $expiredat = dol_print_date($endoflife, "dayhour"); } } } - $submit_enabled=0; + $submit_enabled = 0; print ''; print ''; @@ -230,7 +230,7 @@ if ($mode == 'setup' && $user->admin) print "
    '; @@ -241,7 +241,7 @@ if ($mode == 'setup' && $user->admin) print '
    '; @@ -292,7 +292,7 @@ if ($mode == 'setup' && $user->admin) { // Token refresh print '
    '; @@ -302,7 +302,7 @@ if ($mode == 'setup' && $user->admin) // Token expired print '
    '; @@ -312,7 +312,7 @@ if ($mode == 'setup' && $user->admin) // Token expired at print '
    '; @@ -323,7 +323,7 @@ if ($mode == 'setup' && $user->admin) print '
    '; - if (! empty($driver)) + if (!empty($driver)) { if ($submit_enabled) { print '
    '; @@ -340,7 +340,7 @@ if ($mode == 'test' && $user->admin) print $langs->trans('PrintTestDesc'.$driver)."

    \n"; print ''; - if (! empty($driver)) + if (!empty($driver)) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; $classname = 'printing_'.$driver; @@ -348,7 +348,7 @@ if ($mode == 'test' && $user->admin) $printer = new $classname($db); //print '
    '.print_r($printer, true).'
    '; if (count($printer->getlistAvailablePrinters())) { - if ($printer->listAvailablePrinters()==0) { + if ($printer->listAvailablePrinters() == 0) { print $printer->resprint; } else { setEventMessages($printer->error, $printer->errors, 'errors'); @@ -379,7 +379,7 @@ if ($mode == 'userconf' && $user->admin) print "\n"; $sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid'; $resql = $db->query($sql); - while ($row=$db->fetch_array($resql)) { + while ($row = $db->fetch_array($resql)) { print ''; print ''; print ''; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index da04a88ac2c..144eabf9aab 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -46,7 +46,7 @@ $cancel = GETPOST('cancel', 'alpha'); */ if ($cancel) { - $action=''; + $action = ''; } if ($action == 'update') @@ -102,12 +102,12 @@ elseif ($action == 'disable_pdfsecurity') * View */ -$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; +$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('', $langs->trans("Setup"), $wikihelp); -$form=new Form($db); -$formother=new FormOther($db); -$formadmin=new FormAdmin($db); +$form = new Form($db); +$formother = new FormOther($db); +$formadmin = new FormAdmin($db); $arraydetailsforpdffoot = array( 0 => $langs->transnoentitiesnoconv('NoDetails'), @@ -137,8 +137,8 @@ print '
    '; print '
    '.$row['login'].''.$row['module'].'
    '; print ''; -$selected=$conf->global->MAIN_PDF_FORMAT; -if (empty($selected)) $selected=dol_getDefaultFormat(); +$selected = $conf->global->MAIN_PDF_FORMAT; +if (empty($selected)) $selected = dol_getDefaultFormat(); // Show pdf format @@ -147,16 +147,16 @@ print $formadmin->select_paper_format($selected, 'MAIN_PDF_FORMAT'); print ''; print ''; print ''; print ''; print ''; print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$langs->trans("MAIN_PDF_MARGIN_LEFT").''; -print ''; +print ''; print '
    '.$langs->trans("MAIN_PDF_MARGIN_RIGHT").''; -print ''; +print ''; print '
    '.$langs->trans("MAIN_PDF_MARGIN_TOP").''; -print ''; +print ''; print '
    '.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").''; -print ''; +print ''; print '
    '; @@ -175,16 +175,16 @@ print '
    '.$langs->trans("Parameter").''.$langs->trans("ShowVATIntaInAddress").''; -print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS', (! empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS))?$conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS:0, 1); +print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS', (!empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) ? $conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS : 0, 1); print '
    '.$langs->trans("ShowProfIdInAddress").' - '.$pid.''; $keyforconstant = 'MAIN_PROFID'.$i.'_IN_ADDRESS'; - print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant)?$conf->global->$keyforconstant:0, 1, $noCountryCode); + print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant) ? $conf->global->$keyforconstant : 0, 1, $noCountryCode); print '
    ' . $langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT1", $mysoc->country_code)) . ''; - $text.= $form->selectyesno('MAIN_PDF_MAIN_HIDE_SECOND_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX : 0, 1); + $text = '
    '.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT1", $mysoc->country_code)).''; + $text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_SECOND_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX : 0, 1); $text .= '
    ' . $langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT2", $mysoc->country_code)) . ''; - $text.= $form->selectyesno('MAIN_PDF_MAIN_HIDE_THIRD_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX : 0, 1); - $text.= '
    '.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT2", $mysoc->country_code)).''; + $text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_THIRD_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX : 0, 1); + $text .= '
    '.$langs->trans("Parameter").''.$langs->trans("HideAnyVATInformationOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))?$conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT:0, 1); +print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT : 0, 1); print '
    '.$langs->trans("Parameter").''.$langs->trans("HideDescOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC:0, 1); +print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC : 0, 1); print '
    '.$langs->trans("HideRefOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF:0, 1); +print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF : 0, 1); print '
    '.$langs->trans("HideDetailsOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0, 1); +print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS : 0, 1); print '
    '.$langs->trans("SwapSenderAndRecipientOnPDF").''; -print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT))?$conf->global->MAIN_INVERT_SENDER_RECIPIENT:0, 1); +print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1); print '
    '.$langs->trans("PlaceCustomerAddressToIsoLocation").''; -print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (! empty($conf->global->MAIN_PDF_USE_ISO_LOCATION))?$conf->global->MAIN_PDF_USE_ISO_LOCATION:0, 1); +print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1); print '
    '.$langs->trans("LibraryToBuildPDF").''; -$i=0; -$pdf=pdf_getInstance('A4'); -if (class_exists('FPDF') && ! class_exists('TCPDF')) +$i = 0; +$pdf = pdf_getInstance('A4'); +if (class_exists('FPDF') && !class_exists('TCPDF')) { if ($i) print ' + '; print 'FPDF'; diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 9be75bf125b..1760651b693 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -27,22 +27,22 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; -$action=GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); // Load translation files required by the page -$langs->loadLangs(array("users","admin","other")); +$langs->loadLangs(array("users", "admin", "other")); if (!$user->admin) accessforbidden(); // Allow/Disallow change to clear passwords once passwords are crypted -$allow_disable_encryption=true; +$allow_disable_encryption = true; /* * Actions */ if ($action == 'setgeneraterule') { - if (! dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', $_GET["value"], 'chaine', 0, '', $conf->entity)) + if (!dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', $_GET["value"], 'chaine', 0, '', $conf->entity)) { dol_print_error($db); } @@ -55,33 +55,33 @@ if ($action == 'setgeneraterule') if ($action == 'activate_encrypt') { - $error=0; + $error = 0; $db->begin(); dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $numrows=$db->num_rows($resql); - $i=0; + $numrows = $db->num_rows($resql); + $i = 0; while ($i < $numrows) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); if (dol_hash($obj->pass)) { $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql.= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL"; - $sql.= " WHERE rowid=".$obj->rowid; + $sql .= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL"; + $sql .= " WHERE rowid=".$obj->rowid; //print $sql; $resql2 = $db->query($sql); - if (! $resql2) + if (!$resql2) { dol_print_error($db); $error++; @@ -96,7 +96,7 @@ if ($action == 'activate_encrypt') //print $error." ".$sql; //exit; - if (! $error) + if (!$error) { $db->commit(); header("Location: security.php"); @@ -125,7 +125,7 @@ if ($action == 'activate_encryptdbpassconf') $result = encodedecode_dbpassconf(1); if ($result > 0) { - sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. + sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. // database value not required //dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1"); @@ -142,7 +142,7 @@ elseif ($action == 'disable_encryptdbpassconf') $result = encodedecode_dbpassconf(0); if ($result > 0) { - sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. + sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. // database value not required //dolibarr_del_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED",$conf->entity); @@ -196,7 +196,7 @@ if ($action == 'maj_pattern') */ $form = new Form($db); -$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; +$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; llxHeader('', $langs->trans("Passwords"), $wikihelp); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); @@ -205,7 +205,7 @@ print $langs->trans("GeneratedPasswordDesc")."
    \n"; print "
    \n"; -$head=security_prepare_head(); +$head = security_prepare_head(); dol_fiche_head($head, 'passwords', $langs->trans("Security"), -1); @@ -220,11 +220,11 @@ print ''; // Charge tableau des modules generation $dir = "../core/modules/security/generate"; clearstatcache(); -$handle=opendir($dir); -$i=1; +$handle = opendir($dir); +$i = 1; if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) { @@ -233,7 +233,7 @@ if (is_resource($handle)) require_once $dir.'/'.$file; $obj = new $classname($db, $conf, $langs, $user); - $arrayhandler[$obj->id]=$obj; + $arrayhandler[$obj->id] = $obj; $i++; } } @@ -251,7 +251,7 @@ print '
    '; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
    '.$langs->trans($tmp).'
    '; } - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
    '; @@ -298,37 +298,37 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ 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 ''; @@ -398,7 +398,7 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ // Cryptage mot de passe print '
    '; -print ""; +print ""; print ''; print ""; @@ -413,12 +413,12 @@ print ''; print ''; print ''; print ''; -if (! $conf->global->DATABASE_PWD_ENCRYPTED) +if (!$conf->global->DATABASE_PWD_ENCRYPTED) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; @@ -514,17 +514,17 @@ if ($action == 'create') print '
    ' . $langs->trans("MinLength")."'.$langs->trans("MinLength")."
    ' . $langs->trans("NbMajMin")."'.$langs->trans("NbMajMin")."
    ' . $langs->trans("NbNumMin")."'.$langs->trans("NbNumMin")."
    ' . $langs->trans("NbSpeMin")."'.$langs->trans("NbSpeMin")."
    ' . $langs->trans("NbIteConsecutive")."'.$langs->trans("NbIteConsecutive")."
    ' . $langs->trans("NoAmbiCaracAutoGeneration")."'.$langs->trans("NoAmbiCaracAutoGeneration")." '.($tabConf[5] ? $langs->trans("Activated") : $langs->trans("Disabled")).'
    '.$langs->trans("DoNotStoreClearPassword").''; -if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) +if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { print img_picto($langs->trans("Active"), 'tick'); } print ''; print ''.$langs->trans("Activate").''; @@ -426,7 +426,7 @@ if (! $conf->global->DATABASE_PWD_ENCRYPTED) } // Database conf file encryption -if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) +if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { print ''; if ($allow_disable_encryption) @@ -449,7 +449,7 @@ print '
    '.$langs->trans("MainDbPasswordFileConfEncrypted").''; -if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) +if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { print img_picto($langs->trans("Active"), 'tick'); } @@ -468,7 +468,7 @@ else { print ''.$langs->trans("Activate").''; } - if (! empty($dolibarr_main_db_encrypted_pass)) + if (!empty($dolibarr_main_db_encrypted_pass)) { print ''.$langs->trans("Disable").''; } @@ -484,7 +484,7 @@ print '
    '.$langs->trans("DisableForgetPasswordLinkOnLogonPage").''; -if(! empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) +if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) { print img_picto($langs->trans("Active"), 'tick'); } diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 181ecad5c6b..aeb2ee0fe19 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -31,19 +31,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; // Load translation files required by the page $langs->loadLangs(array('users', 'admin', 'other')); -if (! $user->admin) +if (!$user->admin) accessforbidden(); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); -$upload_dir=$conf->admin->dir_temp; +$upload_dir = $conf->admin->dir_temp; /* * Actions */ -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -52,15 +52,15 @@ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) if ($action == 'updateform') { - $antivircommand = GETPOST('MAIN_ANTIVIRUS_COMMAND', 'none'); // Use GETPOST none because we must accept ". Example c:\Progra~1\ClamWin\bin\clamscan.exe - $antivirparam = GETPOST('MAIN_ANTIVIRUS_PARAM', 'none'); // Use GETPOST none because we must accept ". Example --database="C:\Program Files (x86)\ClamWin\lib" - $antivircommand = dol_string_nospecial($antivircommand, '', array("|", ";", "<", ">", "&")); // Sanitize command - $antivirparam = dol_string_nospecial($antivirparam, '', array("|", ";", "<", ">", "&")); // Sanitize params + $antivircommand = GETPOST('MAIN_ANTIVIRUS_COMMAND', 'none'); // Use GETPOST none because we must accept ". Example c:\Progra~1\ClamWin\bin\clamscan.exe + $antivirparam = GETPOST('MAIN_ANTIVIRUS_PARAM', 'none'); // Use GETPOST none because we must accept ". Example --database="C:\Program Files (x86)\ClamWin\lib" + $antivircommand = dol_string_nospecial($antivircommand, '', array("|", ";", "<", ">", "&")); // Sanitize command + $antivirparam = dol_string_nospecial($antivirparam, '', array("|", ";", "<", ">", "&")); // Sanitize params - $res3=dolibarr_set_const($db, 'MAIN_UPLOAD_DOC', GETPOST('MAIN_UPLOAD_DOC', 'alpha'), 'chaine', 0, '', $conf->entity); - $res4=dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK', 'alpha'), 'chaine', 0, '', $conf->entity); - $res5=dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand), 'chaine', 0, '', $conf->entity); - $res6=dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam), 'chaine', 0, '', $conf->entity); + $res3 = dolibarr_set_const($db, 'MAIN_UPLOAD_DOC', GETPOST('MAIN_UPLOAD_DOC', 'alpha'), 'chaine', 0, '', $conf->entity); + $res4 = dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK', 'alpha'), 'chaine', 0, '', $conf->entity); + $res5 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand), 'chaine', 0, '', $conf->entity); + $res6 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam), 'chaine', 0, '', $conf->entity); if ($res3 && $res4 && $res5 && $res6) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } @@ -70,8 +70,8 @@ if ($action == 'updateform') elseif ($action == 'delete') { $langs->load("other"); - $file = $conf->admin->dir_temp . '/' . GETPOST('urlfile', 'alpha'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - $ret=dol_delete_file($file); + $file = $conf->admin->dir_temp.'/'.GETPOST('urlfile', 'alpha'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $ret = dol_delete_file($file); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile', 'alpha')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile', 'alpha')), null, 'errors'); Header('Location: '.$_SERVER["PHP_SELF"]); @@ -85,7 +85,7 @@ elseif ($action == 'delete') $form = new Form($db); -$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; +$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; llxHeader('', $langs->trans("Files"), $wikihelp); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); @@ -98,13 +98,13 @@ print ''; print ''; print ''; -$head=security_prepare_head(); +$head = security_prepare_head(); dol_fiche_head($head, 'file', $langs->trans("Security"), -1); // Upload options -$var=false; +$var = false; print '
    '; print ''; @@ -115,8 +115,8 @@ print ''; print ''; print ''; print ''; print '"; print ''; @@ -164,7 +164,7 @@ print ''; print '"; print ''; @@ -180,11 +180,11 @@ print ''; // Form to test upload print '
    '; -$formfile=new FormFile($db); +$formfile = new FormFile($db); $formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestFileUploadForm"), 0, 0, 1, 50, '', '', 1, '', 0); // List of document -$filearray=dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1); +$filearray = dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1); $formfile->list_of_documents($filearray, null, 'admin_temp', ''); // End of page diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index ce4161ea147..021d6d99d4e 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -26,12 +26,12 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","admin","products","sms","other","errors")); +$langs->loadLangs(array("companies", "admin", "products", "sms", "other", "errors")); if (!$user->admin) accessforbidden(); -$substitutionarrayfortest=array( +$substitutionarrayfortest = array( '__ID__' => 'TESTIdRecord', '__PHONEFROM__' => 'TESTPhoneFrom', '__PHONETO__' => 'TESTPhoneTo', @@ -39,7 +39,7 @@ $substitutionarrayfortest=array( '__FIRSTNAME__' => 'TESTFirstname' ); -$action=GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); /* @@ -63,16 +63,16 @@ if ($action == 'update' && empty($_POST["cancel"])) /* * Send sms */ -if ($action == 'send' && ! $_POST['cancel']) +if ($action == 'send' && !$_POST['cancel']) { - $error=0; + $error = 0; - $smsfrom=''; - if (! empty($_POST["fromsms"])) $smsfrom=GETPOST("fromsms"); - if (empty($smsfrom)) $smsfrom=GETPOST("fromname"); + $smsfrom = ''; + if (!empty($_POST["fromsms"])) $smsfrom = GETPOST("fromsms"); + if (empty($smsfrom)) $smsfrom = GETPOST("fromname"); $sendto = GETPOST("sendto"); $body = GETPOST('message'); - $deliveryreceipt= GETPOST("deliveryreceipt"); + $deliveryreceipt = GETPOST("deliveryreceipt"); $deferred = GETPOST('deferred'); $priority = GETPOST('priority'); $class = GETPOST('class'); @@ -82,40 +82,40 @@ if ($action == 'send' && ! $_POST['cancel']) include_once DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php'; $formsms = new FormSms($db); - if (! empty($formsms->error)) + if (!empty($formsms->error)) { setEventMessages($formsms->error, $formsms->errors, 'errors'); - $action='test'; + $action = 'test'; $error++; } if (empty($body)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); - $action='test'; + $action = 'test'; $error++; } - if (empty($smsfrom) || ! str_replace('+', '', $smsfrom)) + if (empty($smsfrom) || !str_replace('+', '', $smsfrom)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsFrom")), null, 'errors'); - $action='test'; + $action = 'test'; $error++; } - if (empty($sendto) || ! str_replace('+', '', $sendto)) + if (empty($sendto) || !str_replace('+', '', $sendto)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsTo")), null, 'errors'); - $action='test'; + $action = 'test'; $error++; } - if (! $error) + if (!$error) { // Make substitutions into message complete_substitutions_array($substitutionarrayfortest, $langs); - $body=make_substitutions($body, $substitutionarrayfortest); + $body = make_substitutions($body, $substitutionarrayfortest); require_once DOL_DOCUMENT_ROOT.'/core/class/CSMSFile.class.php'; - $smsfile = new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class); // This define OvhSms->login, pass, session and account - $result=$smsfile->sendfile(); // This send SMS + $smsfile = new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class); // This define OvhSms->login, pass, session and account + $result = $smsfile->sendfile(); // This send SMS if ($result) { @@ -128,7 +128,7 @@ if ($action == 'send' && ! $_POST['cancel']) setEventMessages($smsfile->error, $smsfile->errors, 'errors'); } - $action=''; + $action = ''; } } @@ -138,11 +138,11 @@ if ($action == 'send' && ! $_POST['cancel']) * View */ -$linuxlike=1; -if (preg_match('/^win/i', PHP_OS)) $linuxlike=0; -if (preg_match('/^mac/i', PHP_OS)) $linuxlike=0; +$linuxlike = 1; +if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; +if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; -$wikihelp='EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms'; +$wikihelp = 'EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms'; llxHeader('', $langs->trans("Setup"), $wikihelp); print load_fiche_titre($langs->trans("SmsSetup"), '', 'title_setup'); @@ -151,14 +151,14 @@ print ''.$langs->trans("SmsDesc")."
    \n"; print "
    \n"; // List of sending methods -$listofmethods=(is_array($conf->modules_parts['sms'])?$conf->modules_parts['sms']:array()); +$listofmethods = (is_array($conf->modules_parts['sms']) ? $conf->modules_parts['sms'] : array()); asort($listofmethods); if ($action == 'edit') { - $form=new Form($db); + $form = new Form($db); - if (! count($listofmethods)) print '
    '.$langs->trans("NoSmsEngine", 'DoliStore').'
    '; + if (!count($listofmethods)) print '
    '.$langs->trans("NoSmsEngine", 'DoliStore').'
    '; print ''; print ''; @@ -185,7 +185,7 @@ if ($action == 'edit') // From print ''; - print ''; // Autocopy to @@ -197,7 +197,7 @@ if ($action == 'edit') print '
    '.$langs->trans("MaxSizeForUploadedFiles").'.'; -$max=@ini_get('upload_max_filesize'); -if ($max) print ' '.$langs->trans("MustBeLowerThanPHPLimit", $max*1024, $langs->trans("Kb")).'.'; +$max = @ini_get('upload_max_filesize'); +if ($max) print ' '.$langs->trans("MustBeLowerThanPHPLimit", $max * 1024, $langs->trans("Kb")).'.'; else print ' '.$langs->trans("NoMaxSizeByPHPLimit").'.'; print ''; @@ -142,18 +142,18 @@ print $langs->trans("AntiVirusCommandExample"); // Check command in inside safe_mode print ''; -if (ini_get('safe_mode') && ! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) +if (ini_get('safe_mode') && !empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) { $langs->load("errors"); - $basedir=preg_replace('/"/', '', dirname($conf->global->MAIN_ANTIVIRUS_COMMAND)); - $listdir=explode(';', ini_get('safe_mode_exec_dir')); - if (! in_array($basedir, $listdir)) + $basedir = preg_replace('/"/', '', dirname($conf->global->MAIN_ANTIVIRUS_COMMAND)); + $listdir = explode(';', ini_get('safe_mode_exec_dir')); + if (!in_array($basedir, $listdir)) { print img_warning($langs->trans('WarningSafeModeOnCheckExecDir')); dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING); } } -print ''; +print ''; print "
    '.$langs->trans("AntiVirusParam").'
    '; print $langs->trans("AntiVirusParamExample"); print '
    '; -print ''; +print ''; print "
    '.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).'
    '; print '
    '; - print ''; + print ''; print '     '; print ''; print '
    '; @@ -207,7 +207,7 @@ if ($action == 'edit') } else { - if (! count($listofmethods)) print '
    '.$langs->trans("NoSmsEngine", 'DoliStore').'
    '; + if (!count($listofmethods)) print '
    '.$langs->trans("NoSmsEngine", 'DoliStore').'
    '; print ''; print ''; @@ -220,15 +220,15 @@ else // Method print ''; // From print ''; print ''; // Autocopy to @@ -260,7 +260,7 @@ else print ''.$langs->trans("DoTestServerAvailability").''; }*/ - if (count($listofmethods) && ! empty($conf->global->MAIN_SMS_SENDMODE)) + if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) { print ''.$langs->trans("DoTestSend").''; } diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index e822371bc4f..695d5363f78 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -30,15 +30,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("install","other","admin")); +$langs->loadLangs(array("install", "other", "admin")); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); -if (! $user->admin) +if (!$user->admin) accessforbidden(); $sfurl = ''; -$version='0.0'; +$version = '0.0'; @@ -58,9 +58,9 @@ if ($action == 'getlastversion') * View */ -$form=new Form($db); +$form = new Form($db); -$title=$langs->trans("InfoDolibarr"); +$title = $langs->trans("InfoDolibarr"); llxHeader('', $title); @@ -91,39 +91,39 @@ if (function_exists('curl_init')) { if ($sfurl) { - while (! empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) + while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) { - $title=$sfurl->channel[0]->item[$i]->title; + $title = $sfurl->channel[0]->item[$i]->title; if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) { - $newversion=$reg[1]; - $newversionarray=explode('.', $newversion); - $versionarray=explode('.', $version); + $newversion = $reg[1]; + $newversionarray = explode('.', $newversion); + $versionarray = explode('.', $version); //var_dump($newversionarray);var_dump($versionarray); - if (versioncompare($newversionarray, $versionarray) > 0) $version=$newversion; + if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; } $i++; } // Show version - print $langs->trans("LastStableVersion").' : '. (($version != '0.0')?$version:$langs->trans("Unknown")) .''; + print $langs->trans("LastStableVersion").' : '.(($version != '0.0') ? $version : $langs->trans("Unknown")).''; } else { - print $langs->trans("LastStableVersion").' : ' .$langs->trans("UpdateServerOffline").''; + print $langs->trans("LastStableVersion").' : '.$langs->trans("UpdateServerOffline").''; } } else { - print $langs->trans("LastStableVersion").' : ' .$langs->trans("Check").''; + print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").''; } } // Now show link to the changelog print '     -     '; -$version=DOL_VERSION; -if (preg_match('/[a-z]+/i', $version)) $version='develop'; // If version contains text, it is not an official tagged version, so we use the full change log. +$version = DOL_VERSION; +if (preg_match('/[a-z]+/i', $version)) $version = 'develop'; // If version contains text, it is not an official tagged version, so we use the full change log. print ''.$langs->trans("SeeChangeLog").''; print ''."\n"; @@ -155,8 +155,8 @@ print ''."\n"; print ''; print ''; print ''."\n"; -foreach($configfileparameters as $key => $value) +foreach ($configfileparameters as $key => $value) { - $ignore=0; + $ignore = 0; if (empty($ignore)) { @@ -357,7 +357,7 @@ foreach($configfileparameters as $key => $value) if (preg_match('/^\?/', $key) && empty(${$newkey})) { if ($newkey != 'multicompany_transverse_mode' || empty($conf->multicompany->enabled)) - continue; // We discard parameters starting with ? + continue; // We discard parameters starting with ? } if (strpos($newkey, 'separator') !== false && $lastkeyshown == 'separator') continue; @@ -378,13 +378,13 @@ foreach($configfileparameters as $key => $value) elseif ($newkey == 'dolibarr_main_url_root' && preg_match('/__auto__/', ${$newkey})) print ${$newkey}.' => '.constant('DOL_MAIN_URL_ROOT'); elseif ($newkey == 'dolibarr_main_document_root_alt') { - $tmparray=explode(',', ${$newkey}); - $i=0; - foreach($tmparray as $value2) + $tmparray = explode(',', ${$newkey}); + $i = 0; + foreach ($tmparray as $value2) { if ($i > 0) print ', '; print $value2; - if (! is_readable($value2)) + if (!is_readable($value2)) { $langs->load("errors"); print ' '.img_warning($langs->trans("ErrorCantReadDir", $value2)); @@ -410,7 +410,7 @@ foreach($configfileparameters as $key => $value) print ""; } print "\n"; - $lastkeyshown=$newkey; + $lastkeyshown = $newkey; } } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$langs->trans("MAIN_SMS_SENDMODE").''; - $text=$listofmethods[$conf->global->MAIN_SMS_SENDMODE]; - if (empty($text)) $text=$langs->trans("Undefined").' '.img_warning(); + $text = $listofmethods[$conf->global->MAIN_SMS_SENDMODE]; + if (empty($text)) $text = $langs->trans("Undefined").' '.img_warning(); print $text; print '
    '.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_SMS_FROM; - if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && ! isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) print ' '.img_warning($langs->trans("ErrorBadPhone")); + if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && !isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) print ' '.img_warning($langs->trans("ErrorBadPhone")); print '
    '.$langs->trans("Screen").'' print $_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; print '
    '.$langs->trans("Session").''; -$i=0; -foreach($_SESSION as $key => $val) +$i = 0; +foreach ($_SESSION as $key => $val) { if ($i > 0) print ', '; if (is_array($val)) print $key.' => array(...)'; @@ -172,7 +172,7 @@ print '
    '; // Shmop if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { - $shmoparray=dol_listshmop(); + $shmoparray = dol_listshmop(); print '
    '; print ''; @@ -182,7 +182,7 @@ if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_S print ''; print ''."\n"; - foreach($shmoparray as $key => $val) + foreach ($shmoparray as $key => $val) { print ''; print ''; @@ -203,15 +203,15 @@ print ''."\n"; print ''."\n"; // Thousands -$thousand=$langs->transnoentitiesnoconv("SeparatorThousand"); -if ($thousand == 'SeparatorThousand') $thousand=' '; // ' ' does not work on trans method -if ($thousand == 'None') $thousand=''; -print ''."\n"; +$thousand = $langs->transnoentitiesnoconv("SeparatorThousand"); +if ($thousand == 'SeparatorThousand') $thousand = ' '; // ' ' does not work on trans method +if ($thousand == 'None') $thousand = ''; +print ''."\n"; // Decimals -$dec=$langs->transnoentitiesnoconv("SeparatorDecimal"); +$dec = $langs->transnoentitiesnoconv("SeparatorDecimal"); print ''."\n"; // Show results of functions to see if everything works -print ''."\n"; +print ''."\n"; print '\n"; if (($thousand != ',' && $thousand != '.') || ($thousand != ' ')) { @@ -220,21 +220,21 @@ if (($thousand != ',' && $thousand != '.') || ($thousand != ' ')) } print ''."\n"; // Timezone -$txt =$langs->trans("OSTZ").' (variable system TZ): '.(! empty($_ENV["TZ"])?$_ENV["TZ"]:$langs->trans("NotDefined")).'
    '."\n"; -$txt.=$langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone")?ini_get("date.timezone"):$langs->trans("NotDefined")).''."
    \n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php -$txt.=$langs->trans("Dolibarr constant MAIN_SERVER_TZ").': '.(empty($conf->global->MAIN_SERVER_TZ)?$langs->trans("NotDefined"):$conf->global->MAIN_SERVER_TZ); -print ''."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php +print ''."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php print ''."\n"; print ''; print ''; @@ -242,8 +242,8 @@ print ''."\n"; } // Client -$tz=(int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']; -print ''."\n"; print ''."\n"; print ''."\n"; -$filesystemencoding=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 +$filesystemencoding = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 print ''."\n"; -$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; -print ''."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php +$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; +print ''."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php print '
    '.$langs->trans("Address").'
    '.$key.''.count($val).'
    '.$langs->trans("Localisat print '
    '.$langs->trans("LanguageBrowserParameter", "HTTP_ACCEPT_LANGUAGE").''.$_SERVER["HTTP_ACCEPT_LANGUAGE"].'
    '.$langs->trans("CurrentUserLanguage").''.$langs->getDefaultLang().'
    '.$langs->trans("CurrentValueSeparatorThousand").''.($thousand==' '?$langs->transnoentitiesnoconv("Space"):$thousand).'
    '.$langs->trans("CurrentValueSeparatorThousand").''.($thousand == ' ' ? $langs->transnoentitiesnoconv("Space") : $thousand).'
    '.$langs->trans("CurrentValueSeparatorDecimal").''.$dec.'
      => price2num(1233.56+1)'.price2num(1233.56+1, '2').'
      => price2num(1233.56+1)'.price2num(1233.56 + 1, '2').'
      => price2num('."'1".$thousand."234".$dec."56')".price2num("1".$thousand."234".$dec."56", '2')."
      => price(1234.56)'.price(1234.56).'
    '.$langs->trans("CurrentTimeZone").''; // Timezone server PHP -$a=getServerTimeZoneInt('now'); -$b=getServerTimeZoneInt('winter'); -$c=getServerTimeZoneInt('summer'); -$daylight=(is_numeric($c) && is_numeric($b))?round($c-$b):'unknown'; +$txt = $langs->trans("OSTZ").' (variable system TZ): '.(!empty($_ENV["TZ"]) ? $_ENV["TZ"] : $langs->trans("NotDefined")).'
    '."\n"; +$txt .= $langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone") ?ini_get("date.timezone") : $langs->trans("NotDefined")).''."
    \n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php +$txt .= $langs->trans("Dolibarr constant MAIN_SERVER_TZ").': '.(empty($conf->global->MAIN_SERVER_TZ) ? $langs->trans("NotDefined") : $conf->global->MAIN_SERVER_TZ); +print '
    '.$langs->trans("CurrentTimeZone").''; // Timezone server PHP +$a = getServerTimeZoneInt('now'); +$b = getServerTimeZoneInt('winter'); +$c = getServerTimeZoneInt('summer'); +$daylight = (is_numeric($c) && is_numeric($b)) ?round($c - $b) : 'unknown'; //print $a." ".$b." ".$c." ".$daylight; -$val=($a>=0?'+':'').$a; -$val.=' ('.($a=='unknown'?'unknown':($a>=0?'+':'').($a*3600)).')'; -$val.='       '.getServerTimeZoneString(); -$val.='       '.$langs->trans("DaylingSavingTime").': '.($daylight==='unknown'?'unknown':($a==$c?yn($daylight):yn(0).($daylight?'     ('.$langs->trans('YesInSummer').')':''))); +$val = ($a >= 0 ? '+' : '').$a; +$val .= ' ('.($a == 'unknown' ? 'unknown' : ($a >= 0 ? '+' : '').($a * 3600)).')'; +$val .= '       '.getServerTimeZoneString(); +$val .= '       '.$langs->trans("DaylingSavingTime").': '.($daylight === 'unknown' ? 'unknown' : ($a == $c ?yn($daylight) : yn(0).($daylight ? '     ('.$langs->trans('YesInSummer').')' : ''))); print $form->textwithtooltip($val, $txt, 2, 1, img_info('')); -print '
      => '.$langs->trans("CurrentHour").''.dol_print_date(dol_now(), 'dayhour', 'tzserver').'
      => dol_print_date(0,"dayhourtext")'.dol_print_date(0, "dayhourtext").'
      => dol_get_first_day(1970,1,false)'.dol_get_first_day(1970, 1, false).'     (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970, 1, false), 'dayhour').')
      => dol_get_first_day(1970,1,true) // Database timezone if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') { - print '
    '.$langs->trans("MySQLTimeZone").' (database)'; // Timezone server base - $sql="SHOW VARIABLES where variable_name = 'system_time_zone'"; + print '
    '.$langs->trans("MySQLTimeZone").' (database)'; // Timezone server base + $sql = "SHOW VARIABLES where variable_name = 'system_time_zone'"; $resql = $db->query($sql); if ($resql) { @@ -253,25 +253,25 @@ if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') print '
    '.$langs->trans("ClientTZ").''.($tz?($tz>=0?'+':'').$tz:'').' ('.($tz>=0?'+':'').($tz*60*60).')'; +$tz = (int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']; +print '
    '.$langs->trans("ClientTZ").''.($tz ? ($tz >= 0 ? '+' : '').$tz : '').' ('.($tz >= 0 ? '+' : '').($tz * 60 * 60).')'; print '       '.$_SESSION['dol_tz_string']; print '       '.$langs->trans("DaylingSavingTime").': '; -if ($_SESSION['dol_dst']>0) print yn(1); +if ($_SESSION['dol_dst'] > 0) print yn(1); else print yn(0); -if (! empty($_SESSION['dol_dst_first'])) print '     ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']), 'dayhour', 'gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']), 'dayhour', 'gmt').')'; +if (!empty($_SESSION['dol_dst_first'])) print '     ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']), 'dayhour', 'gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']), 'dayhour', 'gmt').')'; print '
      => '.$langs->trans("ClientHour").''.dol_print_date(dol_now(), 'dayhour', 'tzuser').'
    '.$langs->trans("File encoding").' (php.ini unicode.filesystem_encoding)'.$filesystemencoding.'
      => '.$langs->trans("File encoding").''.$tmp.'
      => '.$langs->trans("File encoding").''.$tmp.'
    '; print '
    '; @@ -280,7 +280,7 @@ print '
    '; // Parameters in conf.php file (when a parameter start with ?, it is shown only if defined) -$configfileparameters=array( +$configfileparameters = array( 'dolibarr_main_url_root' => $langs->trans("URLRoot"), '?dolibarr_main_url_root_alt' => $langs->trans("URLRoot").' (alt)', 'dolibarr_main_document_root'=> $langs->trans("DocumentRootServer"), @@ -346,9 +346,9 @@ print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; @@ -425,28 +425,28 @@ print ''; print ''; print ''; print ''; -if (empty($conf->multicompany->enabled) || !$user->entity) print ''; // If superadmin or multicompany disabled +if (empty($conf->multicompany->enabled) || !$user->entity) print ''; // If superadmin or multicompany disabled print "\n"; $sql = "SELECT"; -$sql.= " rowid"; -$sql.= ", ".$db->decrypt('name')." as name"; -$sql.= ", ".$db->decrypt('value')." as value"; -$sql.= ", type"; -$sql.= ", note"; -$sql.= ", entity"; -$sql.= " FROM ".MAIN_DB_PREFIX."const"; +$sql .= " rowid"; +$sql .= ", ".$db->decrypt('name')." as name"; +$sql .= ", ".$db->decrypt('value')." as value"; +$sql .= ", type"; +$sql .= ", note"; +$sql .= ", entity"; +$sql .= " FROM ".MAIN_DB_PREFIX."const"; if (empty($conf->multicompany->enabled)) { // If no multicompany mode, admins can see global and their constantes - $sql.= " WHERE entity IN (0,".$conf->entity.")"; + $sql .= " WHERE entity IN (0,".$conf->entity.")"; } else { // If multicompany mode, superadmin (user->entity=0) can see everything, admin are limited to their entities. - if ($user->entity) $sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; + if ($user->entity) $sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; } -$sql.= " ORDER BY entity, name ASC"; +$sql .= " ORDER BY entity, name ASC"; $resql = $db->query($sql); if ($resql) { @@ -460,7 +460,7 @@ if ($resql) print ''; print ''."\n"; print ''."\n"; - if (empty($conf->multicompany->enabled) || !$user->entity) print ''."\n"; // If superadmin or multicompany disabled + if (empty($conf->multicompany->enabled) || !$user->entity) print ''."\n"; // If superadmin or multicompany disabled print "\n"; $i++; diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index cdb9e7dfcea..06003068bb2 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "user", "install")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); /* @@ -49,7 +49,7 @@ print load_fiche_titre($langs->trans("SummarySystem"), '', 'title_setup'); print '
    '.$langs->trans("Parameters").' '.$langs->trans("Database").''.$langs->trans("Value").''.$langs->trans("Entity").''.$langs->trans("Entity").'
    '.$obj->name.''.dol_escape_htmltag($obj->value).''.$obj->entity.''.$obj->entity.'
    '; print "\n"; -$dolversion=version_dolibarr(); +$dolversion = version_dolibarr(); print "\n"; print '
    Dolibarr
    ".$langs->trans("Version")."".$dolversion."
    '; @@ -57,7 +57,7 @@ print "
    \n"; print ''; print "\n"; -$osversion=version_os(); +$osversion = version_os(); print "\n"; print '
    ".$langs->trans("OS")."
    ".$langs->trans("Version")."".$osversion."
    '; @@ -66,7 +66,7 @@ print "
    \n"; // Serveur web print ''; print "\n"; -$apacheversion=version_webserver(); +$apacheversion = version_webserver(); print "\n"; print '
    ".$langs->trans("WebServer")."
    ".$langs->trans("Version")."".$apacheversion."
    '; @@ -75,7 +75,7 @@ print "
    \n"; // Php print ''; print "\n"; -$phpversion=version_php(); +$phpversion = version_php(); print "\n"; print "\n"; print '
    ".$langs->trans("PHP")."
    ".$langs->trans("Version")."".$phpversion."
    ".$langs->trans("PhpWebLink")."".php_sapi_name()."
    '; @@ -85,15 +85,15 @@ print "
    \n"; // Database print ''; print "\n"; -$dblabel=$db::LABEL; -$dbversion=$db->getVersion(); -print "\n"; +$dblabel = $db::LABEL; +$dbversion = $db->getVersion(); +print "\n"; print '
    ".$langs->trans("Database")."
    ".$langs->trans("Version")."" .$dblabel." ".$dbversion."
    ".$langs->trans("Version")."".$dblabel." ".$dbversion."
    '; // Add checks on database options if ($db->type == 'pgsql') { // Check option standard_conforming_strings is on - $paramarray=$db->getServerParametersValues('standard_conforming_strings'); + $paramarray = $db->getServerParametersValues('standard_conforming_strings'); // if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1) // { // $langs->load("errors"); @@ -104,8 +104,8 @@ print '
    '; // Browser print ''; print "\n"; -print "\n"; -print "\n"; +print "\n"; +print "\n"; print '
    ".$langs->trans("Browser")."
    ".$langs->trans("UserAgent")."" .$_SERVER["HTTP_USER_AGENT"]."
    ".$langs->trans("Smartphone")."".(($conf->browser->layout != 'phone')?$langs->trans("No"):$langs->trans("Yes"))."
    ".$langs->trans("UserAgent")."".$_SERVER["HTTP_USER_AGENT"]."
    ".$langs->trans("Smartphone")."".(($conf->browser->layout != 'phone') ? $langs->trans("No") : $langs->trans("Yes"))."
    '; print '
    '; diff --git a/htdocs/admin/system/web.php b/htdocs/admin/system/web.php index 114a251c8f3..1fb98a3b42f 100644 --- a/htdocs/admin/system/web.php +++ b/htdocs/admin/system/web.php @@ -48,20 +48,20 @@ print '
    '; print ''; print '\n"; print '\n"; -print '\n"; +print '\n"; print '\n"; -print '\n"; +print '\n"; print '\n"; -print '\n"; +print '\n"; // Web user group by default -$labeluser=dol_getwebuser('user'); -$labelgroup=dol_getwebuser('group'); +$labeluser = dol_getwebuser('user'); +$labelgroup = dol_getwebuser('group'); if ($labeluser && $labelgroup) { print '\n"; } // Web user group real (detected by 'id' external command) -$arrayout=array(); $varout=0; +$arrayout = array(); $varout = 0; exec('id', $arrayout, $varout); if (empty($varout)) // Test command is ok. Work only on Linux OS. { diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index fa6a558e444..98d77d47118 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -74,7 +74,7 @@ if ($action == 'updateMask') { dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity); } elseif ($action == 'setvar') { - include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; + include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha'); if (!empty($notification_email)) { @@ -177,7 +177,7 @@ $page_name = "TicketSetup"; llxHeader('', $langs->trans($page_name), $help_url); // Subheader -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); @@ -186,7 +186,7 @@ $head = ticketAdminPrepareHead(); dol_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "ticket"); -print ''.$langs->trans("TicketSetupDictionaries") . ' : '.$langs->trans("ClickHereToGoTo", $langs->transnoentitiesnoconv("DictionarySetup")).'
    '; +print ''.$langs->trans("TicketSetupDictionaries").' : '.$langs->trans("ClickHereToGoTo", $langs->transnoentitiesnoconv("DictionarySetup")).'
    '; dol_fiche_end(); @@ -199,17 +199,17 @@ print load_fiche_titre($langs->trans("TicketNumberingModules")); print '
    '.$langs->trans("Parameter")."".$langs->trans("Value")."
    '.$langs->trans("Version")."".$_SERVER["SERVER_SOFTWARE"]."
    '.$langs->trans("VirtualServerName")."" . $_SERVER["SERVER_NAME"] . "
    '.$langs->trans("VirtualServerName")."".$_SERVER["SERVER_NAME"]."
    '.$langs->trans("IP")."".$_SERVER["SERVER_ADDR"]."
    '.$langs->trans("Port")."" . $_SERVER["SERVER_PORT"] . "
    '.$langs->trans("Port")."".$_SERVER["SERVER_PORT"]."
    '.$langs->trans("DocumentRootServer")."".$_SERVER["DOCUMENT_ROOT"]."
    '.$langs->trans("DataRootServer")."" . DOL_DATA_ROOT . "
    '.$langs->trans("DataRootServer")."".DOL_DATA_ROOT."
    '.$langs->trans("WebUserGroup")." (env vars)".$labeluser.'/'.$labelgroup."
    '; print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; +print ''; print "\n"; clearstatcache(); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir . "core/modules/ticket/"); + $dir = dol_buildpath($reldir."core/modules/ticket/"); if (is_dir($dir)) { $handle = opendir($dir); @@ -219,7 +219,7 @@ foreach ($dirmodels as $reldir) { $file = $reg[1]; $classname = substr($file, 4); - include_once $dir . $file . '.php'; + include_once $dir.$file.'.php'; $module = new $file; @@ -233,7 +233,7 @@ foreach ($dirmodels as $reldir) { } if ($module->isEnabled()) { - print ''; @@ -241,20 +241,20 @@ foreach ($dirmodels as $reldir) { print '' . "\n"; + print ''."\n"; print ''; @@ -263,14 +263,14 @@ foreach ($dirmodels as $reldir) { // Info $htmltooltip = ''; - $htmltooltip .= '' . $langs->trans("Version") . ': ' . $module->getVersion() . '
    '; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
    '; $nextval = $module->getNextValue($mysoc, $ticket); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= '' . $langs->trans("NextValue") . ': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - $htmltooltip .= $nextval . '
    '; + $htmltooltip .= $nextval.'
    '; } else { - $htmltooltip .= $langs->trans($module->error) . '
    '; + $htmltooltip .= $langs->trans($module->error).'
    '; } } @@ -290,8 +290,8 @@ foreach ($dirmodels as $reldir) { print '
    ' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Example") . '' . $langs->trans("Activated") . '' . $langs->trans("ShortInfo") . ''.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Activated").''.$langs->trans("ShortInfo").'
    ' . $module->name . "\n"; + print '
    '.$module->name."\n"; print $module->info(); print ''; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { - print '
    ' . $langs->trans($tmp) . '
    '; + print '
    '.$langs->trans($tmp).'
    '; } elseif ($tmp == 'NotConfigured') { print $langs->trans($tmp); } else { print $tmp; } - print '
    '; - if ($conf->global->TICKET_ADDON == 'mod_' . $classname) { + if ($conf->global->TICKET_ADDON == 'mod_'.$classname) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; } print '

    '; if (!$conf->use_javascript_ajax) { - print ''; - print ''; + print ''; + print ''; print ''; } @@ -299,7 +299,7 @@ print load_fiche_titre($langs->trans("TicketParams")); print ''; print ''; -print ''; +print ''; print ''; print ''; print "\n"; @@ -339,7 +339,7 @@ print ''; // Also send to main email address if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; + print ''; print ''; }*/ // Auto assign ticket at user who created it -print ''; +print ''; print '"; print ""; - $i=0; + $i = 0; while ($i < $num) { diff --git a/htdocs/core/lib/doleditor.lib.php b/htdocs/core/lib/doleditor.lib.php index 2cffa7a2b9d..df9e3d94619 100644 --- a/htdocs/core/lib/doleditor.lib.php +++ b/htdocs/core/lib/doleditor.lib.php @@ -33,39 +33,39 @@ */ function show_skin($fuser, $edit = 0) { - global $conf,$langs,$db; + global $conf, $langs, $db; global $bc; - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $formother = new FormOther($db); - $dirskins=array('/includes/ckeditor/ckeditor/skins'); - if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application + $dirskins = array('/includes/ckeditor/ckeditor/skins'); + if (!empty($conf->modules_parts['theme'])) // Using this feature slow down application { - foreach($conf->modules_parts['theme'] as $reldir) + foreach ($conf->modules_parts['theme'] as $reldir) { - $dirskins=array_merge($dirskins, (array) ($reldir.'theme')); + $dirskins = array_merge($dirskins, (array) ($reldir.'theme')); } } - $dirskins=array_unique($dirskins); + $dirskins = array_unique($dirskins); // Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme') - $selected_theme=''; - if (empty($conf->global->FCKEDITOR_SKIN)) $selected_theme='moono-lisa'; - else $selected_theme=$conf->global->FCKEDITOR_SKIN; + $selected_theme = ''; + if (empty($conf->global->FCKEDITOR_SKIN)) $selected_theme = 'moono-lisa'; + else $selected_theme = $conf->global->FCKEDITOR_SKIN; - $colspan=2; + $colspan = 2; - $thumbsbyrow=6; + $thumbsbyrow = 6; print '
    ' . $langs->trans("Parameter") . ''.$langs->trans("Parameter").'
    ' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . '
    '.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); @@ -377,7 +377,7 @@ print '
    ' . $langs->trans("TicketsAutoAssignTicket") . '
    '.$langs->trans("TicketsAutoAssignTicket").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); @@ -402,17 +402,17 @@ print load_fiche_titre($langs->trans("Notification")); print ''; -print ''; -print ''; +print ''; +print ''; print ''; print ''; -print ''; +print ''; print "\n"; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { print ''; - print ''; + print ''; print "\n"; } @@ -435,18 +435,18 @@ print ''; // @TODO Use module notification instead... // Email de réception des notifications -print ''; +print ''; print ''; +print ''; print ''; print ''; // Email d'envoi des notifications -print ''; +print ''; print ''; +print ''; print ''; @@ -454,9 +454,9 @@ print ''; // Texte d'introduction $mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText'); -print ''; @@ -466,9 +466,9 @@ print ''; // Texte de signature $mail_signature = $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText'); -print ''; @@ -479,7 +479,7 @@ print ''; print '
    ' . $langs->trans("Email") . ''.$langs->trans("Email").'
    ' . $langs->trans("TicketCkEditorEmailNotActivated") . '
    '.$langs->trans("TicketCkEditorEmailNotActivated").'
    ' . $langs->trans("TicketEmailNotificationTo") . '
    '.$langs->trans("TicketEmailNotificationTo").''; -print ''; print $form->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help'); print '
    ' . $langs->trans("TicketEmailNotificationFrom") . '
    '.$langs->trans("TicketEmailNotificationFrom").''; -print ''; print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); print '
    ' . $langs->trans("TicketMessageMailIntroLabelAdmin") . ''; +print '
    '.$langs->trans("TicketMessageMailIntroLabelAdmin").''; print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); $doleditor->Create(); print '
    ' . $langs->trans("TicketMessageMailSignatureLabelAdmin") . ''; +print '
    '.$langs->trans("TicketMessageMailSignatureLabelAdmin").''; print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); $doleditor->Create(); print '
    '; print '
    '; -print ''; +print ''; print '
    '; print ''; diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index d6ab0d3830e..d216252c329 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -55,7 +55,7 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') } if ($action == 'setvar') { - include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; + include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml'); if (!empty($topic_interface)) { @@ -158,7 +158,7 @@ $page_name = "TicketSetup"; llxHeader('', $langs->trans($page_name), $help_url); // Subheader -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); @@ -167,7 +167,7 @@ $head = ticketAdminPrepareHead(); dol_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket"); -print ''.$langs->trans("TicketPublicAccess") . ' : ' . dol_buildpath('/public/ticket/index.php', 2) . ''; +print ''.$langs->trans("TicketPublicAccess").' : '.dol_buildpath('/public/ticket/index.php', 2).''; dol_fiche_end(); @@ -176,32 +176,32 @@ $enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' '; if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { // Button off, click to enable - $enabledisablehtml.=''; - $enabledisablehtml.=img_picto($langs->trans("Disabled"), 'switch_off'); - $enabledisablehtml.=''; + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); + $enabledisablehtml .= ''; } else { // Button on, click to disable - $enabledisablehtml.=''; - $enabledisablehtml.=img_picto($langs->trans("Activated"), 'switch_on'); - $enabledisablehtml.=''; + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); + $enabledisablehtml .= ''; } print $enabledisablehtml; -print ''; +print ''; print '

    '; -if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) +if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { if (empty($conf->use_javascript_ajax)) { - print '
    '; - print ''; + print ''; + print ''; print ''; } print ''; - print ''; + print ''; print ''; print ''; // Check if email exists - print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; } @@ -290,25 +290,25 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
    ' . $langs->trans("Parameters") . '
    '.$langs->trans("Parameters").''; print ''; @@ -209,7 +209,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
    ' . $langs->trans("TicketsEmailMustExist") . '
    '.$langs->trans("TicketsEmailMustExist").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); @@ -242,7 +242,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) }*/ // Show logo for company - print '
    ' . $langs->trans("TicketsShowCompanyLogo") . '
    '.$langs->trans("TicketsShowCompanyLogo").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); @@ -259,7 +259,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) // Also send to main email address if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print '
    ' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . '
    '.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); @@ -275,7 +275,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) } if (!$conf->use_javascript_ajax) { - print '
    '; - print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; + print ''; print "\n"; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { print ''; - print ''; + print ''; print "\n"; } // Interface topic $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; - print ''; + print ''; print ''; print ''; @@ -328,9 +328,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) // Texte d'aide à la saisie du message $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); - print ''; @@ -339,7 +339,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print ''; // Activate email creation to user - print ''; + print ''; print ''; @@ -367,9 +367,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) // Url public interface $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; - print ''; + print ''; print ''; print '
    ' . $langs->trans("Parameter") . ''.$langs->trans("Parameter").'
    ' . $langs->trans("TicketCkEditorEmailNotActivated") . '
    '.$langs->trans("TicketCkEditorEmailNotActivated").'
    ' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . ''; + print '
    '.$langs->trans("TicketPublicInterfaceTopicLabelAdmin").''; print ''; - print ''; print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); @@ -316,9 +316,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) // Texte d'accueil homepage $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); - print '
    ' . $langs->trans("TicketPublicInterfaceTextHomeLabelAdmin") . ''; + print '
    '.$langs->trans("TicketPublicInterfaceTextHomeLabelAdmin").''; print ''; - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); $doleditor->Create(); print '
    ' . $langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin") . ''; + print '
    '.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").''; print ''; - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); $doleditor->Create(); print '
    ' . $langs->trans("TicketsDisableCustomerEmail") . '
    '.$langs->trans("TicketsDisableCustomerEmail").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); @@ -355,9 +355,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) // Texte de création d'un ticket $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); - print '
    ' . $langs->trans("TicketNewEmailBodyLabel") . ''; + print '
    '.$langs->trans("TicketNewEmailBodyLabel").''; print ''; - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); $doleditor->Create(); print '
    ' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; + print '
    '.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").''; print ''; - print ''; print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); @@ -377,7 +377,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
    '; - print '
    '; + print '
    '; print '
    '; } diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php index b72941cd6de..31995f2d90e 100644 --- a/htdocs/admin/website_options.php +++ b/htdocs/admin/website_options.php @@ -34,18 +34,18 @@ require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; // Load translation files required by the page $langs->loadLangs(array('errors', 'admin', 'companies', 'website')); -$action=GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view'; -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; +$confirm = GETPOST('confirm', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$rowid=GETPOST('rowid', 'alpha'); +$rowid = GETPOST('rowid', 'alpha'); if (!$user->admin) accessforbidden(); $status = 1; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -57,7 +57,7 @@ $pagenext = $page + 1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admin')); -$arrayofparameters=array('WEBSITE_USE_WEBSITE_ACCOUNTS'=>array('css'=>'minwidth200')); +$arrayofparameters = array('WEBSITE_USE_WEBSITE_ACCOUNTS'=>array('css'=>'minwidth200')); /* @@ -72,16 +72,16 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; */ $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); llxHeader('', $langs->trans("WebsiteSetup")); -$titre=$langs->trans("WebsiteSetup"); -$linkback=''.$langs->trans("BackToModuleList").''; +$titre = $langs->trans("WebsiteSetup"); +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($titre, $linkback, 'title_setup'); // Onglets -$head=array(); +$head = array(); $h = 0; $head[$h][0] = DOL_URL_ROOT."/admin/website.php"; @@ -106,11 +106,11 @@ if ($action == 'edit') print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '
    '; @@ -127,11 +127,11 @@ else print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '' . $conf->global->$key . '
    '.$conf->global->$key.'
    '; diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index cb9e61e9da1..81899fee0f0 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -28,9 +28,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","workflow","propal","workflow","orders","supplier_proposals","receptions")); +$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposals", "receptions")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); @@ -41,7 +41,7 @@ $action = GETPOST('action', 'alpha'); if (preg_match('/set(.*)/', $action, $reg)) { - if (! dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) + if (!dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) { dol_print_error($db); } @@ -49,7 +49,7 @@ if (preg_match('/set(.*)/', $action, $reg)) if (preg_match('/del(.*)/', $action, $reg)) { - if (! dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0) + if (!dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0) { dol_print_error($db); } @@ -62,7 +62,7 @@ if (preg_match('/del(.*)/', $action, $reg)) llxHeader('', $langs->trans("WorkflowSetup"), ''); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("WorkflowSetup"), $linkback, 'title_setup'); print ''.$langs->trans("WorkflowDesc").'
    '; @@ -72,29 +72,29 @@ print "
    "; clearstatcache(); -$workflowcodes=array( +$workflowcodes = array( // Automatic creation 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'), 'separator1'=>array('family'=>'separator', 'position'=>25), // Automatic classification of proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal','warning'=>''), - 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal','warning'=>''), + 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal', 'warning'=>''), + 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal', 'warning'=>''), // Automatic classification of order 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify_order', 'position'=>40, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order', 'warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. 'separator2'=>array('family'=>'separator', 'position'=>50), // Automatic classification supplier proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'propal','warning'=>''), + 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'propal', 'warning'=>''), // Automatic classification supplier order - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'! empty($conf->fournisseur->enabled)', 'picto'=>'order','warning'=>''), + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'! empty($conf->fournisseur->enabled)', 'picto'=>'order', 'warning'=>''), //Automatic classification reception 'WORKFLOW_BILL_ON_RECEPTION'=>array('family'=>'classify_reception', 'position'=>64, 'enabled'=>'! empty($conf->reception->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'bill'), ); -if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) +if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) { - foreach($conf->modules_parts['workflow'] as $workflow) + foreach ($conf->modules_parts['workflow'] as $workflow) { $workflowcodes = array_merge($workflowcodes, $workflow); } @@ -103,16 +103,16 @@ if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts[' // Sort on position $workflowcodes = dol_sort_array($workflowcodes, 'position'); -$nbqualified=0; -$oldfamily=''; +$nbqualified = 0; +$oldfamily = ''; print ''."\n"; -foreach($workflowcodes as $key => $params) +foreach ($workflowcodes as $key => $params) { - $picto=$params['picto']; - $enabled=$params['enabled']; - $family=$params['family']; + $picto = $params['picto']; + $enabled = $params['enabled']; + $family = $params['family']; if ($family == 'separator') { @@ -122,7 +122,7 @@ foreach($workflowcodes as $key => $params) continue; } - if (! verifCond($enabled)) continue; + if (!verifCond($enabled)) continue; $nbqualified++; @@ -156,20 +156,20 @@ foreach($workflowcodes as $key => $params) print "\n"; print "\n"; print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { // Accountancy_code_asset print ''; @@ -601,8 +601,8 @@ if ($rowid > 0) print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -615,17 +615,17 @@ if ($rowid > 0) if (empty($reshook)) { print '

    ".img_object('', $picto).$langs->trans('desc'.$key); - if (! empty($params['warning'])) + if (!empty($params['warning'])) { $langs->load("errors"); print ' '.img_warning($langs->transnoentitiesnoconv($params['warning'])); } print "'; - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff($key); } else { - if (! empty($conf->global->$key)) + if (!empty($conf->global->$key)) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index f43093d0936..1aee94fb715 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -24,7 +24,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; -require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; global $langs, $user; @@ -32,13 +32,13 @@ global $langs, $user; $langs->loadLangs(array("admin", "assets")); // Access control -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$arrayofparameters=array('FIXEDASSETS_MYPARAM1'=>array('css'=>'minwidth200'), 'FIXEDASSETS_MYPARAM2'=>array('css'=>'minwidth500')); +$arrayofparameters = array('FIXEDASSETS_MYPARAM1'=>array('css'=>'minwidth200'), 'FIXEDASSETS_MYPARAM2'=>array('css'=>'minwidth500')); /* @@ -54,7 +54,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; llxHeader('', $langs->trans("AssetsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup'); @@ -72,11 +72,11 @@ if ($action == 'edit') print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '
    '; @@ -93,11 +93,11 @@ else print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '' . $conf->global->$key . '
    '.$conf->global->$key.'
    '; diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index db8dfb60a2b..70191b5eb28 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -26,9 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; // Load translation files required by the page $langs->load("assets"); @@ -40,25 +40,25 @@ $backtopage = GETPOST('backtopage', 'alpha'); $type = GETPOST('type', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$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) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page ; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) { $sortorder="DESC"; } -if (! $sortfield) { $sortfield="a.label"; } +if (!$sortorder) { $sortorder = "DESC"; } +if (!$sortfield) { $sortfield = "a.label"; } -$label=GETPOST("label", "alpha"); -$accountancy_code_asset=GETPOST('accountancy_code_asset', 'string'); -$accountancy_code_depreciation_asset=GETPOST('accountancy_code_depreciation_asset', 'string'); -$accountancy_code_depreciation_expense=GETPOST('accountancy_code_depreciation_expense', 'string'); -$comment=GETPOST('comment', 'string'); +$label = GETPOST("label", "alpha"); +$accountancy_code_asset = GETPOST('accountancy_code_asset', 'string'); +$accountancy_code_depreciation_asset = GETPOST('accountancy_code_depreciation_asset', 'string'); +$accountancy_code_depreciation_expense = GETPOST('accountancy_code_depreciation_expense', 'string'); +$comment = GETPOST('comment', 'string'); // Security check -$result=restrictedArea($user, 'asset', $rowid, 'asset_type'); +$result = restrictedArea($user, 'asset', $rowid, 'asset_type'); $object = new AssetType($db); @@ -69,13 +69,13 @@ $extrafields->fetch_name_optionals_label($object->table_element); 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 { - $type=""; - $sall=""; + $type = ""; + $sall = ""; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('assettypecard','globalcard')); +$hookmanager->initHooks(array('assettypecard', 'globalcard')); /* @@ -83,9 +83,9 @@ $hookmanager->initHooks(array('assettypecard','globalcard')); */ if ($cancel) { - $action=''; + $action = ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -94,11 +94,11 @@ if ($cancel) { if ($action == 'add' && $user->rights->asset->write) { - $object->label = trim($label); - $object->accountancy_code_asset = trim($accountancy_code_asset); - $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); - $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); - $object->note = trim($comment); + $object->label = trim($label); + $object->accountancy_code_asset = trim($accountancy_code_asset); + $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); + $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); + $object->note = trim($comment); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -121,9 +121,9 @@ if ($action == 'add' && $user->rights->asset->write) } } - if (! $error) + if (!$error) { - $id=$object->create($user); + $id = $object->create($user); if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -147,19 +147,19 @@ if ($action == 'update' && $user->rights->asset->write) $object->oldcopy = clone $object; - $object->label = trim($label); - $object->accountancy_code_asset = trim($accountancy_code_asset); - $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); - $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); - $object->note = trim($comment); + $object->label = trim($label); + $object->accountancy_code_asset = trim($accountancy_code_asset); + $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); + $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); + $object->note = trim($comment); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - $ret=$object->update($user); + $ret = $object->update($user); - if ($ret >= 0 && ! count($object->errors)) + if ($ret >= 0 && !count($object->errors)) { setEventMessages($langs->trans("AssetsTypeModified"), null, 'mesgs'); } @@ -175,7 +175,7 @@ if ($action == 'update' && $user->rights->asset->write) if ($action == 'confirm_delete' && $user->rights->asset->write) { $object->fetch($rowid); - $res=$object->delete(); + $res = $object->delete(); if ($res > 0) { @@ -186,7 +186,7 @@ if ($action == 'confirm_delete' && $user->rights->asset->write) else { setEventMessages($langs->trans("AssetsTypeCanNotBeDeleted"), null, 'errors'); - $action=''; + $action = ''; } } @@ -195,20 +195,20 @@ if ($action == 'confirm_delete' && $user->rights->asset->write) * View */ -$form=new Form($db); +$form = new Form($db); -$helpurl=''; +$helpurl = ''; llxHeader('', $langs->trans("AssetsTypeSetup"), $helpurl); // List of asset type -if (! $rowid && $action != 'create' && $action != 'edit') +if (!$rowid && $action != 'create' && $action != 'edit') { //dol_fiche_head(''); $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; - $sql.= " FROM ".MAIN_DB_PREFIX."asset_type as d"; - $sql.= " WHERE d.entity IN (".getEntity('asset_type').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; + $sql .= " WHERE d.entity IN (".getEntity('asset_type').")"; $result = $db->query($sql); if ($result) @@ -220,12 +220,12 @@ if (! $rowid && $action != 'create' && $action != 'edit') $param = ''; - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->asset->configurer) { - $newcardbutton=''.$langs->trans('NewAssetType').''; - $newcardbutton.= ''; - $newcardbutton.= ''; + $newcardbutton = ''.$langs->trans('NewAssetType').''; + $newcardbutton .= ''; + $newcardbutton .= ''; } print '
    '; @@ -242,7 +242,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') $moreforfilter = ''; print '
    '; - print ''."\n"; + print '
    '."\n"; print ''; print ''; @@ -271,7 +271,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; print ''; print ''; print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { // Accountancy_code_asset print ''; @@ -390,8 +390,8 @@ if ($action == 'create') print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -438,11 +438,11 @@ if ($rowid > 0) $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Ref asset type - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1); - $morehtmlref.='
    '; + $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1); + $morehtmlref .= '
    '; dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -455,7 +455,7 @@ if ($rowid > 0) print '"; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '.$langs->trans("Ref").''.dol_escape_htmltag($objp->label).''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $objp->accountancy_code_asset, 1); @@ -283,7 +283,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount2 = new AccountingAccount($db); $accountingaccount2->fetch('', $objp->accountancy_code_depreciation_asset, 1); @@ -295,7 +295,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount3 = new AccountingAccount($db); $accountingaccount3->fetch('', $objp->accountancy_code_depreciation_expense, 1); @@ -333,7 +333,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') if ($action == 'create') { $object = new AssetType($db); - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); + if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); print load_fiche_titre($langs->trans("NewAssetType")); @@ -348,7 +348,7 @@ if ($action == 'create') print '
    '.$langs->trans("Label").'
    '.$langs->trans("AccountancyCodeAsset").'
    '; print $langs->trans("AccountancyCodeAsset"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->accountancy_code_asset, 1); @@ -471,7 +471,7 @@ if ($rowid > 0) print ''; print $langs->trans("AccountancyCodeDepreciationAsset"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount2 = new AccountingAccount($db); $accountingaccount2->fetch('', $object->accountancy_code_depreciation_asset, 1); @@ -487,7 +487,7 @@ if ($rowid > 0) print ''; print $langs->trans("AccountancyCodeDepreciationExpense"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount3 = new AccountingAccount($db); $accountingaccount3->fetch('', $object->accountancy_code_depreciation_expense, 1); @@ -503,7 +503,7 @@ if ($rowid > 0) print nl2br($object->note)."
    '; print '
    '; @@ -542,7 +542,7 @@ if ($rowid > 0) $object = new AssetType($db); $object->fetch($rowid); $object->fetch_optionals(); - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); + if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); $head = asset_type_prepare_head($object); @@ -559,7 +559,7 @@ if ($rowid > 0) print '
    '.$langs->trans("Label").'
    '.$langs->trans("AccountancyCodeAsset").'
    '; - foreach($extrafields->attributes[$object->element]['label'] as $key=>$label) + foreach ($extrafields->attributes[$object->element]['label'] as $key=>$label) { - if (isset($_POST["options_" . $key])) { - if (is_array($_POST["options_" . $key])) { + if (isset($_POST["options_".$key])) { + if (is_array($_POST["options_".$key])) { // $_POST["options"] is an array but following code expects a comma separated string - $value = implode(",", $_POST["options_" . $key]); + $value = implode(",", $_POST["options_".$key]); } else { - $value = $_POST["options_" . $key]; + $value = $_POST["options_".$key]; } } else { - $value = $adht->array_options["options_" . $key]; + $value = $adht->array_options["options_".$key]; } print ''; - print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; print ''; - $total_ttc += $obj->total_ttc; + $total_ttc += $obj->total_ttc; $total += $obj->total_ht; - $totalam += $obj->am; + $totalam += $obj->am; $i++; } - print ''; + print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -938,8 +938,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) } else { - $colspan=6; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + $colspan = 6; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''; } print '
    '.$label.''; print $extrafields->showInputField($key, $value); diff --git a/htdocs/bom/admin/setup.php b/htdocs/bom/admin/setup.php index b8fc1f1c1c1..3e3a03e139c 100644 --- a/htdocs/bom/admin/setup.php +++ b/htdocs/bom/admin/setup.php @@ -26,7 +26,7 @@ // Load Dolibarr environment require '../../main.inc.php'; // Libraries -require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/bom.lib.php'; //require_once "../class/myclass.class.php"; @@ -34,15 +34,15 @@ require_once '../lib/bom.lib.php'; $langs->loadLangs(array("admin", "mrp")); // Access control -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$arrayofparameters=array( - 'BILLOFMATERIALS_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1), - 'BILLOFMATERIALS_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1) +$arrayofparameters = array( + 'BILLOFMATERIALS_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), + 'BILLOFMATERIALS_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) ); @@ -59,7 +59,7 @@ $page_name = "BomSetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom'); @@ -80,11 +80,11 @@ if ($action == 'edit') print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '
    '; @@ -97,16 +97,16 @@ if ($action == 'edit') } else { - if (! empty($arrayofparameters)) + if (!empty($arrayofparameters)) { print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '' . $conf->global->$key . '
    '.$conf->global->$key.'
    '; diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index 1602c02beaa..d66b57deaf3 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; // If socid provided by ajax company selector -if (! empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) +if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) { $_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); $_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); @@ -49,7 +49,7 @@ if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - if (GETPOST('socid', 'int') < 0) $_POST["socid"]=''; + if (GETPOST('socid', 'int') < 0) $_POST["socid"] = ''; $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY", (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH", (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') : ''), 'chaine', 0, '', $conf->entity); @@ -62,9 +62,9 @@ if (GETPOST('action', 'alpha') == 'set') dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -80,12 +80,12 @@ if (GETPOST('action', 'alpha') == 'set') * View */ -$form=new Form($db); -$formproduct=new FormProduct($db); +$form = new Form($db); +$formproduct = new FormProduct($db); llxHeader('', $langs->trans("CashDeskSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("CashDeskSetup").' (SimplePOS)', $linkback, 'title_setup'); print '
    '; @@ -95,7 +95,7 @@ print ''; print ''; print ''; -if (! empty($conf->service->enabled)) +if (!empty($conf->service->enabled)) { print ''; print ''; @@ -123,7 +123,7 @@ print ''; -if (! empty($conf->banque->enabled)) +if (!empty($conf->banque->enabled)) { print ''; print ''; } -if (! empty($conf->stock->enabled)) +if (!empty($conf->stock->enabled)) { - print ''; // Force warehouse (this is not a default value) + print ''; // Force warehouse (this is not a default value) print ''; - $disabled=$conf->global->CASHDESK_NO_DECREASE_STOCK; + $disabled = $conf->global->CASHDESK_NO_DECREASE_STOCK; - print ''; // Force warehouse (this is not a default value) + print ''; // Force warehouse (this is not a default value) print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; - print ''; + print ''; print ''; print ''; $tot_ht += $obj->total_ht; $tot_ttc += $obj->total_ttc; //print "x".$tot_ttc."z".$obj->tot_fttc; - $tot_tobill += ($obj->total_ttc-$obj->tot_fttc); + $tot_tobill += ($obj->total_ttc - $obj->tot_fttc); $i++; } print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -821,32 +821,32 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us /* * Unpaid customers invoices */ -if (! empty($conf->facture->enabled) && $user->rights->facture->lire) +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { - $facstatic=new Facture($db); + $facstatic = new Facture($db); $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; - $sql.= ", f.date_lim_reglement as datelimite"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid, s.email"; - $sql.= ", s.code_client, s.code_compta"; - $sql.= ", cc.rowid as country_id, cc.code as country_code"; - $sql.= ", sum(pf.amount) as am"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; - $sql.= " AND f.entity IN (".getEntity('invoice').')'; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND f.fk_soc = ".$socid; + $sql .= ", f.date_lim_reglement as datelimite"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= ", sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; + $sql .= " AND f.entity IN (".getEntity('invoice').')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerUnpaid', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerUnpaid', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; - $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code"; - $sql.= " ORDER BY f.datef ASC, f.ref ASC"; + $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code"; + $sql .= " ORDER BY f.datef ASC, f.ref ASC"; $resql = $db->query($sql); if ($resql) @@ -858,7 +858,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print '
    '.$langs->trans("CashDeskThirdParty print ''; print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client in (1,3) AND s.status = 1)', 1, 0, 0, array(), 0); print '
    '.$langs->trans("CashDeskBankAccountForSell").''; @@ -143,9 +143,9 @@ if (! empty($conf->banque->enabled)) print '
    '.$langs->trans("CashDeskDoNotDecreaseStock").'
    '.$langs->trans("CashDeskDoNotDecreaseStock").''; if (empty($conf->productbatch->enabled)) { print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1); @@ -160,12 +160,12 @@ if (! empty($conf->stock->enabled)) } print '
    '.$langs->trans("CashDeskIdWareHouse").'
    '.$langs->trans("CashDeskIdWareHouse").''; - if (! $disabled) + if (!$disabled) { print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE, 'CASHDESK_ID_WAREHOUSE', '', 1, $disabled); print ' ('.$langs->trans("Create").')'; @@ -178,7 +178,7 @@ if (! empty($conf->stock->enabled)) } // Use Dolibarr Receipt Printer -if (! empty($conf->receiptprinter->enabled)) +if (!empty($conf->receiptprinter->enabled)) { print '
    '; print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index c898fef8be1..56363870dd7 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -41,11 +41,11 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $type = GETPOST('type', 'aZ09'); -if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($id == "") { @@ -74,7 +74,7 @@ if ($cancel == $langs->trans("Cancel")) // Validation de l'ajout if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && -($user->rights->categorie->creer )) +($user->rights->categorie->creer)) { $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -92,7 +92,7 @@ $cancel != $langs->trans("Cancel") && if (!$error) { if (empty($libelle)) { $error++; - $object->errors[] = $langs->trans('Language_' . $forcelangprod) . ' : ' . $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); + $object->errors[] = $langs->trans('Language_'.$forcelangprod).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); } if (!$error) { @@ -129,15 +129,15 @@ $cancel != $langs->trans("Cancel") && foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet { - $libelle = GETPOST('libelle-'. $key, 'alpha'); - $desc = GETPOST('desc-' . $key); + $libelle = GETPOST('libelle-'.$key, 'alpha'); + $desc = GETPOST('desc-'.$key); if (empty($libelle)) { $error++; - $object->errors[] = $langs->trans('Language_' . $key) . ' : ' . $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); + $object->errors[] = $langs->trans('Language_'.$key).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); } - if ( $key == $current_lang ) { + if ($key == $current_lang) { $object->label = $libelle; $object->description = dol_htmlcleanlastbr($desc); } else { @@ -169,24 +169,24 @@ $result = $object->fetch($id, $ref); llxHeader("", "", $langs->trans("Translation")); $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); $formother = new FormOther($db); -if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort"); -elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort"); -elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); -elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); -elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); -elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); -elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort"); -elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort"); -else $title=$langs->trans("Category"); +if ($type == Categorie::TYPE_PRODUCT) $title = $langs->trans("ProductsCategoryShort"); +elseif ($type == Categorie::TYPE_SUPPLIER) $title = $langs->trans("SuppliersCategoryShort"); +elseif ($type == Categorie::TYPE_CUSTOMER) $title = $langs->trans("CustomersCategoryShort"); +elseif ($type == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoryShort"); +elseif ($type == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort"); +elseif ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans("AccountsCategoriesShort"); +elseif ($type == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort"); +elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("UsersCategoriesShort"); +else $title = $langs->trans("Category"); $head = categories_prepare_head($object, $type); // Calculate $cnt_trans $cnt_trans = 0; -if (! empty($object->multilangs)) +if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { @@ -199,15 +199,15 @@ dol_fiche_head($head, 'translation', $title, -1, 'category'); $linkback = ''.$langs->trans("BackToList").''; $object->ref = $object->label; -$morehtmlref='
    '.$langs->trans("Root").' >> '; +$morehtmlref = '
    '.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); foreach ($ways as $way) { - $morehtmlref.=$way."
    \n"; + $morehtmlref .= $way."
    \n"; } -$morehtmlref.='
    '; +$morehtmlref .= '
    '; -dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); +dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); print '
    '; @@ -266,9 +266,9 @@ if ($action == 'edit') print ''; print ''; print ''; - print ''; + print ''; - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { @@ -304,23 +304,23 @@ elseif ($action != 'add') { if ($cnt_trans) print '
    '; - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { - $s=picto_from_langcode($key); + $s = picto_from_langcode($key); print ''; - print ''; + print ''; print ''; print ''; - if (! empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) + if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) { print ''; } print '
    '.($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
    '.($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
    '.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
    '.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
    '.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'.$object->multilangs[$key]["other"].'
    '; } } - if (! $cnt_trans && $action != 'add') print '
    '. $langs->trans('NoTranslation').'
    '; + if (!$cnt_trans && $action != 'add') print '
    '.$langs->trans('NoTranslation').'
    '; } @@ -338,14 +338,14 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print '"; print ''; print ''."\n"; - if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''; } else { @@ -883,7 +883,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 42c1f191a0a..94e885d53dc 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -22,30 +22,30 @@ * \brief Page to define emailing targets */ -if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); +if (!defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/mailing.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/emailing.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/advtargetemailing.class.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/html.formadvtargetemailing.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/mailings/advthirdparties.modules.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/advtargetemailing.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/html.formadvtargetemailing.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/advthirdparties.modules.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('mails', 'companies')); -if (! empty($conf->categorie->enabled)) { +if (!empty($conf->categorie->enabled)) { $langs->load("categories"); } // Security check -if (! $user->rights->mailing->lire || $user->socid > 0) +if (!$user->rights->mailing->lire || $user->socid > 0) accessforbidden(); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -53,9 +53,9 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) +if (!$sortorder) $sortorder = "ASC"; -if (! $sortfield) +if (!$sortfield) $sortfield = "email"; $id = GETPOST('id', 'int'); @@ -72,7 +72,7 @@ if (GETPOST('button_removefilter_x', 'alpha')) { $search_prenom = ''; $search_email = ''; } -$array_query = array (); +$array_query = array(); $object = new Mailing($db); $advTarget = new AdvanceTargetingMailing($db); @@ -90,7 +90,7 @@ if ($result < 0) } else { - if (! empty($advTarget->id)) { + if (!empty($advTarget->id)) { $array_query = json_decode($advTarget->filtervalue, true); } } @@ -101,12 +101,12 @@ else */ if ($action == 'loadfilter') { - if (! empty($template_id)) { + if (!empty($template_id)) { $result = $advTarget->fetch($template_id); if ($result < 0) { setEventMessages($advTarget->error, $advTarget->errors, 'errors'); } else { - if (! empty($advTarget->id)) { + if (!empty($advTarget->id)) { $array_query = json_decode($advTarget->filtervalue, true); } } @@ -116,7 +116,7 @@ if ($action == 'loadfilter') { if ($action == 'add') { $user_contact_query = false; - $array_query = array (); + $array_query = array(); // Get extra fields @@ -125,17 +125,17 @@ if ($action == 'add') { if (preg_match("/^options_.*(?contact_lines) == 0) { - $advTarget->contact_lines = array ( + $advTarget->contact_lines = array( 0 ); } } else { - $advTarget->contact_lines = array (); + $advTarget->contact_lines = array(); } if ((count($advTarget->thirdparty_lines) > 0) || (count($advTarget->contact_lines) > 0)) { @@ -234,11 +234,11 @@ if ($action == 'add') { if ($result > 0) { $query_temlate_id = ''; - if (! empty($template_id)) { - $query_temlate_id = '&template_id=' . $template_id; + if (!empty($template_id)) { + $query_temlate_id = '&template_id='.$template_id; } setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs'); - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id . $query_temlate_id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id.$query_temlate_id); exit(); } if ($result == 0) { @@ -255,7 +255,7 @@ if ($action == 'clear') { $obj = new $classname($db); $obj->clear_target($id); - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit(); } @@ -265,28 +265,28 @@ if ($action == 'savefilter' || $action == 'createfilter') { if ($action == 'createfilter' && empty($template_name)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('AdvTgtOrCreateNewFilter')), null, 'errors'); - $error ++; + $error++; } if (empty($error)) { - $array_query = array (); + $array_query = array(); // Get extra fields foreach ($_POST as $key => $value) { if (preg_match("/^options_.*(?error, $advTarget->errors, 'errors'); } - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit(); } if ($action == 'delete') { // Ici, rowid indique le destinataire et id le mailing - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing_cibles WHERE rowid=" . $rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid; $resql = $db->query($sql); if ($resql) { - if (! empty($id)) { + if (!empty($id)) { $classname = "MailingTargets"; $obj = new $classname($db); $obj->update_nb($id); - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit(); } else { header("Location: liste.php"); @@ -421,30 +421,30 @@ if ($object->fetch($id) >= 0) { print '
    '.$langs->trans('Translation').''; print $formadmin->select_language(GETPOST('forcelangprod', 'alpha'), 'forcelangprod', 0, $object->multilangs); print '
    ' . $langs->trans('Label') . '
    '.$langs->trans('Label').'
    '.$langs->trans('Description').''; $doleditor = new DolEditor('desc', GETPOST('desc', 'none'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index e4e204c11e3..47feb0e75ae 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -133,13 +133,13 @@ $hookmanager->initHooks(array('agenda')); if (GETPOST("viewlist", 'alpha') || $action == 'show_list') { - $param=''; + $param = ''; if (is_array($_POST)) { - foreach($_POST as $key => $val) + foreach ($_POST as $key => $val) { - if ($key=='token') continue; - $param.='&'.$key.'='.urlencode($val); + if ($key == 'token') continue; + $param .= '&'.$key.'='.urlencode($val); } } //print $param; @@ -149,13 +149,13 @@ if (GETPOST("viewlist", 'alpha') || $action == 'show_list') if (GETPOST("viewperuser", 'alpha') || $action == 'show_peruser') { - $param=''; + $param = ''; if (is_array($_POST)) { - foreach($_POST as $key => $val) + foreach ($_POST as $key => $val) { - if ($key=='token') continue; - $param.='&'.$key.'='.urlencode($val); + if ($key == 'token') continue; + $param .= '&'.$key.'='.urlencode($val); } } //print $param; @@ -163,11 +163,11 @@ if (GETPOST("viewperuser", 'alpha') || $action == 'show_peruser') exit; } -if ($action =='delete_action') +if ($action == 'delete_action') { $event = new ActionComm($db); $event->fetch($actionid); - $result=$event->delete(); + $result = $event->delete(); } @@ -195,62 +195,62 @@ $parameters = array( $reshook = $hookmanager->executeHooks('beforeAgenda', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; llxHeader('', $langs->trans("Agenda"), $help_url); -$form=new Form($db); -$companystatic=new Societe($db); -$contactstatic=new Contact($db); +$form = new Form($db); +$companystatic = new Societe($db); +$contactstatic = new Contact($db); -$now=dol_now(); -$nowarray=dol_getdate($now); -$nowyear=$nowarray['year']; -$nowmonth=$nowarray['mon']; -$nowday=$nowarray['mday']; +$now = dol_now(); +$nowarray = dol_getdate($now); +$nowyear = $nowarray['year']; +$nowmonth = $nowarray['mon']; +$nowday = $nowarray['mday']; -$listofextcals=array(); +$listofextcals = array(); // Define list of external calendars (global admin setup) if (empty($conf->global->AGENDA_DISABLE_EXT)) { - $i=0; - while($i < $MAXAGENDA) + $i = 0; + while ($i < $MAXAGENDA) { $i++; - $source='AGENDA_EXT_SRC'.$i; - $name='AGENDA_EXT_NAME'.$i; - $offsettz='AGENDA_EXT_OFFSETTZ'.$i; - $color='AGENDA_EXT_COLOR'.$i; - $buggedfile='AGENDA_EXT_BUGGEDFILE'.$i; - if (! empty($conf->global->$source) && ! empty($conf->global->$name)) + $source = 'AGENDA_EXT_SRC'.$i; + $name = 'AGENDA_EXT_NAME'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; + $color = 'AGENDA_EXT_COLOR'.$i; + $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; + if (!empty($conf->global->$source) && !empty($conf->global->$name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' - $listofextcals[]=array('src'=>$conf->global->$source,'name'=>$conf->global->$name,'offsettz'=>$conf->global->$offsettz,'color'=>$conf->global->$color,'buggedfile'=>(isset($conf->global->buggedfile)?$conf->global->buggedfile:0)); + $listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)); } } } // Define list of external calendars (user setup) if (empty($user->conf->AGENDA_DISABLE_EXT)) { - $i=0; - while($i < $MAXAGENDA) + $i = 0; + while ($i < $MAXAGENDA) { $i++; - $source='AGENDA_EXT_SRC_'.$user->id.'_'.$i; - $name='AGENDA_EXT_NAME_'.$user->id.'_'.$i; - $offsettz='AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; - $color='AGENDA_EXT_COLOR_'.$user->id.'_'.$i; - $enabled='AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; - $buggedfile='AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; - if (! empty($user->conf->$source) && ! empty($user->conf->$name)) + $source = 'AGENDA_EXT_SRC_'.$user->id.'_'.$i; + $name = 'AGENDA_EXT_NAME_'.$user->id.'_'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; + $color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i; + $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; + $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; + if (!empty($user->conf->$source) && !empty($user->conf->$name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' - $listofextcals[]=array('src'=>$user->conf->$source,'name'=>$user->conf->$name,'offsettz'=>$user->conf->$offsettz,'color'=>$user->conf->$color,'buggedfile'=>(isset($user->conf->buggedfile)?$user->conf->buggedfile:0)); + $listofextcals[] = array('src'=>$user->conf->$source, 'name'=>$user->conf->$name, 'offsettz'=>$user->conf->$offsettz, 'color'=>$user->conf->$color, 'buggedfile'=>(isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0)); } } } -if (empty($action) || $action=='show_month') +if (empty($action) || $action == 'show_month') { $prev = dol_get_prev_month($month, $year); $prev_year = $prev['year']; @@ -259,26 +259,26 @@ if (empty($action) || $action=='show_month') $next_year = $next['year']; $next_month = $next['month']; - $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month - $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month + $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month + $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) - $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true))+2; // date('w') is 0 fo sunday - $tmpday+=((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)-1); - if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. + $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday + $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); + if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow=dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month+$tmpday, $prev_year); - $next_day=7 - ($max_day_in_month+1-$tmpday) % 7; - if ($next_day < 6) $next_day+=7; - $lastdaytoshow=dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); + $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year); + $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7; + if ($next_day < 6) $next_day += 7; + $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); } -if ($action=='show_week') +if ($action == 'show_week') { $prev = dol_get_first_day_week($day, $month, $year); $prev_year = $prev['prev_year']; $prev_month = $prev['prev_month']; $prev_day = $prev['prev_day']; $first_day = $prev['first_day']; - $first_month= $prev['first_month']; + $first_month = $prev['first_month']; $first_year = $prev['first_year']; $week = $prev['week']; @@ -290,8 +290,8 @@ if ($action=='show_week') $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow=dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); - $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); + $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); + $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); @@ -309,79 +309,79 @@ if ($action == 'show_day') $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow=dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year); - $lastdaytoshow=dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); + $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year); + $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); } //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; //print dol_print_date($firstdaytoshow,'day'); //print dol_print_date($lastdaytoshow,'day'); -$title=$langs->trans("DoneAndToDoActions"); -if ($status == 'done') $title=$langs->trans("DoneActions"); -if ($status == 'todo') $title=$langs->trans("ToDoActions"); +$title = $langs->trans("DoneAndToDoActions"); +if ($status == 'done') $title = $langs->trans("DoneActions"); +if ($status == 'todo') $title = $langs->trans("ToDoActions"); -$param=''; +$param = ''; if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { - if(is_array($actioncode)) { - foreach($actioncode as $str_action) $param.="&search_actioncode[]=".urlencode($str_action); - } else $param.="&search_actioncode=".urlencode($actioncode); + if (is_array($actioncode)) { + foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); + } else $param .= "&search_actioncode=".urlencode($actioncode); } -if ($resourceid > 0) $param.="&search_resourceid=".urlencode($resourceid); -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&search_status=".urlencode($status); -if ($filter) $param.="&search_filter=".urlencode($filter); -if ($filtert) $param.="&search_filtert=".urlencode($filtert); -if ($usergroup) $param.="&search_usergroup=".urlencode($usergroup); -if ($socid) $param.="&search_socid=".urlencode($socid); -if ($showbirthday) $param.="&search_showbirthday=1"; -if ($pid) $param.="&search_projectid=".urlencode($pid); -if ($type) $param.="&search_type=".urlencode($type); -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month') $param.='&action='.urlencode($action); -$param.="&maxprint=".urlencode($maxprint); +if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); +if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status); +if ($filter) $param .= "&search_filter=".urlencode($filter); +if ($filtert) $param .= "&search_filtert=".urlencode($filtert); +if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); +if ($socid) $param .= "&search_socid=".urlencode($socid); +if ($showbirthday) $param .= "&search_showbirthday=1"; +if ($pid) $param .= "&search_projectid=".urlencode($pid); +if ($type) $param .= "&search_type=".urlencode($type); +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month') $param .= '&action='.urlencode($action); +$param .= "&maxprint=".urlencode($maxprint); // Show navigation bar -if (empty($action) || $action=='show_month') +if (empty($action) || $action == 'show_month') { - $nav ="  \n"; - $nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y"); - $nav.=" \n"; - $nav.="   \n"; - $nav.="   (".$langs->trans("Today").")"; - $picto='calendar'; + $nav = "  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y"); + $nav .= " \n"; + $nav .= "   \n"; + $nav .= "   (".$langs->trans("Today").")"; + $picto = 'calendar'; } -if ($action=='show_week') +if ($action == 'show_week') { - $nav ="trans("Previous"))."\">  \n"; - $nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; - $nav.=" \n"; - $nav.="   trans("Next"))."\">\n"; - $nav.="   (".$langs->trans("Today").")"; - $picto='calendarweek'; + $nav = "trans("Previous"))."\">  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; + $nav .= " \n"; + $nav .= "   trans("Next"))."\">\n"; + $nav .= "   (".$langs->trans("Today").")"; + $picto = 'calendarweek'; } -if ($action=='show_day') +if ($action == 'show_day') { - $nav ="  \n"; - $nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort"); - $nav.=" \n"; - $nav.="   \n"; - $nav.="   (".$langs->trans("Today").")"; - $picto='calendarday'; + $nav = "  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort"); + $nav .= " \n"; + $nav .= "   \n"; + $nav .= "   (".$langs->trans("Today").")"; + $picto = 'calendarday'; } // Must be after the nav definition -$param.='&year='.$year.'&month='.$month.($day?'&day='.$day:''); +$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : ''); //print 'x'.$param; -$tabactive=''; -if ($action == 'show_month') $tabactive='cardmonth'; -if ($action == 'show_week') $tabactive='cardweek'; -if ($action == 'show_day') $tabactive='cardday'; -if ($action == 'show_list') $tabactive='cardlist'; +$tabactive = ''; +if ($action == 'show_month') $tabactive = 'cardmonth'; +if ($action == 'show_week') $tabactive = 'cardweek'; +if ($action == 'show_day') $tabactive = 'cardday'; +if ($action == 'show_list') $tabactive = 'cardlist'; -$paramnoaction=preg_replace('/action=[a-z_]+/', '', $param); +$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); $head = calendars_prepare_head($paramnoaction); @@ -395,66 +395,66 @@ dol_fiche_end(); // Define the legend/list of calendard to show -$s=''; $link=''; +$s = ''; $link = ''; -$showextcals=$listofextcals; +$showextcals = $listofextcals; -if (! empty($conf->use_javascript_ajax)) // If javascript on +if (!empty($conf->use_javascript_ajax)) // If javascript on { - $s.="\n".''."\n"; - $s.='' . "\n"; + $s .= '});'."\n"; + $s .= ''."\n"; // Local calendar - $s.='
    ' . $langs->trans("LocalAgenda").'  
    '; + $s .= '
    '.$langs->trans("LocalAgenda").'  
    '; // External calendars if (is_array($showextcals) && count($showextcals) > 0) { - $s.='' . "\n"; + $s .= ''."\n"; foreach ($showextcals as $val) { $htmlname = md5($val['name']); - $s.='
    ' . $val['name'] . '  
    '; + $s .= '
    '.$val['name'].'  
    '; } } // Birthdays - $s.='
    '.$langs->trans("AgendaShowBirthdayEvents").'  
    '; + $s .= '
    '.$langs->trans("AgendaShowBirthdayEvents").'  
    '; // Calendars from hooks - $parameters=array(); $object=null; - $reshook=$hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); + $parameters = array(); $object = null; + $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); if (empty($reshook)) { - $s.= $hookmanager->resPrint; + $s .= $hookmanager->resPrint; } elseif ($reshook > 1) { @@ -463,182 +463,182 @@ if (! empty($conf->use_javascript_ajax)) // If javascript on } else // If javascript off { - $newparam=$param; // newparam is for birthday links - $newparam=preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday)?1:0), $newparam); - if (! preg_match('/showbirthday=/i', $newparam)) $newparam.='&showbirthday=1'; - $link=''; - if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents"); - else $link.=$langs->trans("AgendaHideBirthdayEvents"); - $link.=''; + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); + if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1'; + $link = ''; + if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents"); + else $link .= $langs->trans("AgendaHideBirthdayEvents"); + $link .= ''; } print load_fiche_titre($s, $link.'     '.$nav, '', 0, 0, 'tablelistofcalendars'); // Load events from database into $eventarray -$eventarray=array(); +$eventarray = array(); $sql = 'SELECT '; -if ($usergroup > 0) $sql.=" DISTINCT"; -$sql.= ' a.id, a.label,'; -$sql.= ' a.datep,'; -$sql.= ' a.datep2,'; -$sql.= ' a.percent,'; -$sql.= ' a.fk_user_author,a.fk_user_action,'; -$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; -$sql.= ' a.fk_soc, a.fk_contact,'; -$sql.= ' a.fk_element, a.elementtype,'; -$sql.= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; +if ($usergroup > 0) $sql .= " DISTINCT"; +$sql .= ' a.id, a.label,'; +$sql .= ' a.datep,'; +$sql .= ' a.datep2,'; +$sql .= ' a.percent,'; +$sql .= ' a.fk_user_author,a.fk_user_action,'; +$sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,'; +$sql .= ' a.fk_soc, a.fk_contact,'; +$sql .= ' a.fk_element, a.elementtype,'; +$sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; // We must filter on resource table -if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; +if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; -if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; -$sql.= ' WHERE a.fk_action = ca.id'; -$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; +if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; +$sql .= ' WHERE a.fk_action = ca.id'; +$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode -if (! empty($actioncode)) +if (!empty($actioncode)) { if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; else { - if ($actioncode == 'AC_OTH') $sql.= " AND ca.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND ca.type = 'systemauto'"; + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; } } else { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; else { if (is_array($actioncode)) { - $sql.=" AND ca.code IN ('".implode("','", $actioncode)."')"; + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; } else { - $sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; } } } } -if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); -if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; -if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid; +if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); +if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; +if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; +if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { - $sql.= " AND ("; - $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql.= " OR "; - $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql.= " OR "; - $sql.= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql.= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; } else { // To limit array - $sql.= " AND ("; - $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year)-(60*60*24*7))."'"; // Start 7 days before - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year)+(60*60*24*10))."')"; // End 7 days after + 3 to go from 28 to 31 - $sql.= " OR "; - $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year)-(60*60*24*7))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year)+(60*60*24*10))."')"; - $sql.= " OR "; - $sql.= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year)-(60*60*24*7))."'"; - $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year)+(60*60*24*10))."')"; - $sql.= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31 + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; + $sql .= ')'; } -if ($type) $sql.= " AND ca.id = ".$type; -if ($status == '0') { $sql.= " AND a.percent = 0"; } -if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable -if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started -if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100)"; } -if ($status == 'todo') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; } +if ($type) $sql .= " AND ca.id = ".$type; +if ($status == '0') { $sql .= " AND a.percent = 0"; } +if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable +if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started +if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } +if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql.= " AND ("; - if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; - $sql.= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // Sort on date -$sql.= ' ORDER BY datep'; +$sql .= ' ORDER BY datep'; //print $sql; dol_syslog("comm/action/index.php", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $MAXONSAMEPAGE=10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import) - $i=0; + $MAXONSAMEPAGE = 10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import) + $i = 0; while ($i < $num && $i < $MAXONSAMEPAGE) { $obj = $db->fetch_object($resql); // Discard auto action if option is on - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') { $i++; continue; } // Create a new object action - $event=new ActionComm($db); - $event->id=$obj->id; + $event = new ActionComm($db); + $event->id = $obj->id; - $event->datep=$db->jdate($obj->datep); // datep and datef are GMT date. Example: 1970-01-01 01:00:00, jdate will return 0 if TZ of PHP server is Europe/Berlin - $event->datef=$db->jdate($obj->datep2); + $event->datep = $db->jdate($obj->datep); // datep and datef are GMT date. Example: 1970-01-01 01:00:00, jdate will return 0 if TZ of PHP server is Europe/Berlin + $event->datef = $db->jdate($obj->datep2); //var_dump($obj->datep); //var_dump($event->datep); - $event->type_code=$obj->type_code; - $event->type_label=$obj->type_label; - $event->type_color=$obj->type_color; + $event->type_code = $obj->type_code; + $event->type_label = $obj->type_label; + $event->type_color = $obj->type_color; - $event->libelle=$obj->label; // deprecated - $event->label=$obj->label; - $event->percentage=$obj->percent; - $event->authorid=$obj->fk_user_author; // user id of creator - $event->userownerid=$obj->fk_user_action; // user id of owner - $event->fetch_userassigned(); // This load $event->userassigned - $event->priority=$obj->priority; - $event->fulldayevent=$obj->fulldayevent; - $event->location=$obj->location; - $event->transparency=$obj->transparency; - $event->fk_element=$obj->fk_element; - $event->elementtype=$obj->elementtype; + $event->libelle = $obj->label; // deprecated + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->fetch_userassigned(); // This load $event->userassigned + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; - $event->thirdparty_id=$obj->fk_soc; - $event->contact_id=$obj->fk_contact; + $event->thirdparty_id = $obj->fk_soc; + $event->contact_id = $obj->fk_contact; // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. - $event->date_start_in_calendar=$event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; + $event->date_start_in_calendar = $event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; + else $event->date_end_in_calendar = $event->datep; // Define ponctual property if ($event->date_start_in_calendar == $event->date_end_in_calendar) { - $event->ponctuel=1; + $event->ponctuel = 1; } // Check values @@ -649,27 +649,27 @@ if ($resql) } else { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1); + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); // Add an entry in actionarray for each day - $daycursor=$event->date_start_in_calendar; + $daycursor = $event->date_start_in_calendar; $annee = date('Y', $daycursor); $mois = date('m', $daycursor); $jour = date('d', $daycursor); // Loop on each day covered by action to prepare an index to show on calendar - $loop=true; $j=0; - $daykey=dol_mktime(0, 0, 0, $mois, $jour, $annee); + $loop = true; $j = 0; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); do { //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
    '; - $eventarray[$daykey][]=$event; + $eventarray[$daykey][] = $event; $j++; - $daykey+=60*60*24; - if ($daykey > $event->date_end_in_calendar) $loop=false; + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; } while ($loop); @@ -689,58 +689,58 @@ if ($showbirthday) { // Add events in array $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; - $sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; - $sql.= " AND sp.entity IN (".getEntity('socpeople').")"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; + $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; + $sql .= " AND sp.entity IN (".getEntity('socpeople').")"; if ($action == 'show_day') { - $sql.= ' AND MONTH(birthday) = '.$month; - $sql.= ' AND DAY(birthday) = '.$day; + $sql .= ' AND MONTH(birthday) = '.$month; + $sql .= ' AND DAY(birthday) = '.$day; } else { - $sql.= ' AND MONTH(birthday) = '.$month; + $sql .= ' AND MONTH(birthday) = '.$month; } - $sql.= ' ORDER BY birthday'; + $sql .= ' ORDER BY birthday'; dol_syslog("comm/action/index.php", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - $event=new ActionComm($db); - $event->id=$obj->rowid; // We put contact id in action id for birthdays events - $datebirth=dol_stringtotime($obj->birthday, 1); + $event = new ActionComm($db); + $event->id = $obj->rowid; // We put contact id in action id for birthdays events + $datebirth = dol_stringtotime($obj->birthday, 1); //print 'ee'.$obj->birthday.'-'.$datebirth; - $datearray=dol_getdate($datebirth, true); - $event->datep=dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output - $event->datef=$event->datep; - $event->type_code='BIRTHDAY'; - $event->label=$langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname); - $event->percentage=100; - $event->fulldayevent=1; + $datearray = dol_getdate($datebirth, true); + $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output + $event->datef = $event->datep; + $event->type_code = 'BIRTHDAY'; + $event->label = $langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname); + $event->percentage = 100; + $event->fulldayevent = 1; - $event->date_start_in_calendar=$event->datep; - $event->date_end_in_calendar=$event->datef; - $event->ponctuel=0; + $event->date_start_in_calendar = $event->datep; + $event->date_end_in_calendar = $event->datef; + $event->ponctuel = 0; // Add an entry in actionarray for each day - $daycursor=$event->date_start_in_calendar; + $daycursor = $event->date_start_in_calendar; $annee = date('Y', $daycursor); $mois = date('m', $daycursor); $jour = date('d', $daycursor); - $loop=true; - $daykey=dol_mktime(0, 0, 0, $mois, $jour, $annee); + $loop = true; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); do { - $eventarray[$daykey][]=$event; - $daykey+=60*60*24; - if ($daykey > $event->date_end_in_calendar) $loop=false; + $eventarray[$daykey][] = $event; + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; } while ($loop); $i++; @@ -756,28 +756,28 @@ if ($showbirthday) if (count($listofextcals)) { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/ical.class.php'; - foreach($listofextcals as $extcal) + foreach ($listofextcals as $extcal) { - $url=$extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics + $url = $extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics $namecal = $extcal['name']; $offsettz = $extcal['offsettz']; $colorcal = $extcal['color']; $buggedfile = $extcal['buggedfile']; //print "url=".$url." namecal=".$namecal." colorcal=".$colorcal." buggedfile=".$buggedfile; - $ical=new ICal(); + $ical = new ICal(); $ical->parse($url); // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... //var_dump($ical->cal); exit; - $icalevents=array(); - if (is_array($ical->get_event_list())) $icalevents=array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] - if (is_array($ical->get_freebusy_list())) $icalevents=array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] + $icalevents = array(); + if (is_array($ical->get_event_list())) $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] + if (is_array($ical->get_freebusy_list())) $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] - if (count($icalevents)>0) + if (count($icalevents) > 0) { // Duplicate all repeatable events into new entries - $moreicalevents=array(); - foreach($icalevents as $icalevent) + $moreicalevents = array(); + foreach ($icalevents as $icalevent) { if (isset($icalevent['RRULE']) && is_array($icalevent['RRULE'])) //repeatable event { @@ -785,26 +785,26 @@ if (count($listofextcals)) //if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1); if ($icalevent['DTSTART;VALUE=DATE']) //fullday event { - $datecurstart=dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); - $datecurend=dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1)-1; // We remove one second to get last second of day + $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); + $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day } - elseif (is_array($icalevent['DTSTART']) && ! empty($icalevent['DTSTART']['unixtime'])) + elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) { - $datecurstart=$icalevent['DTSTART']['unixtime']; - $datecurend=$icalevent['DTEND']['unixtime']; - if (! empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) + $datecurstart = $icalevent['DTSTART']['unixtime']; + $datecurend = $icalevent['DTEND']['unixtime']; + if (!empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) { //var_dump($ical->cal); - $tmpcurstart=$datecurstart; - $tmpcurend=$datecurend; - $tmpdaylightstart=dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['DAYLIGHT']['DTSTART']; - $tmpdaylightend=dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART']; + $tmpcurstart = $datecurstart; + $tmpcurend = $datecurend; + $tmpdaylightstart = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['DAYLIGHT']['DTSTART']; + $tmpdaylightend = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART']; //var_dump($tmpcurstart);var_dump($tmpcurend); var_dump($ical->cal['DAYLIGHT']['DTSTART']);var_dump($ical->cal['STANDARD']['DTSTART']); // Edit datecurstart and datecurend - if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurstart-=((int) $ical->cal['DAYLIGHT']['TZOFFSETTO'])*36; - else $datecurstart-=((int) $ical->cal['STANDARD']['TZOFFSETTO'])*36; - if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurend-=((int) $ical->cal['DAYLIGHT']['TZOFFSETTO'])*36; - else $datecurend-=((int) $ical->cal['STANDARD']['TZOFFSETTO'])*36; + if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + else $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; + if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + else $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; } // datecurstart and datecurend are now GMT date //var_dump($datecurstart); var_dump($datecurend); exit; @@ -817,106 +817,106 @@ if (count($listofextcals)) } //print 'xx'.$datecurstart;exit; - $interval=(empty($icalevent['RRULE']['INTERVAL'])?1:$icalevent['RRULE']['INTERVAL']); - $until=empty($icalevent['RRULE']['UNTIL'])?0:dol_stringtotime($icalevent['RRULE']['UNTIL'], 1); - $maxrepeat=empty($icalevent['RRULE']['COUNT'])?0:$icalevent['RRULE']['COUNT']; - if ($until && ($until+($datecurend-$datecurstart)) < $firstdaytoshow) continue; // We discard repeatable event that end before start date to show - if ($datecurstart >= $lastdaytoshow) continue; // We discard repeatable event that start after end date to show + $interval = (empty($icalevent['RRULE']['INTERVAL']) ? 1 : $icalevent['RRULE']['INTERVAL']); + $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1); + $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT']; + if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) continue; // We discard repeatable event that end before start date to show + if ($datecurstart >= $lastdaytoshow) continue; // We discard repeatable event that start after end date to show - $numofevent=0; + $numofevent = 0; while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) { if ($datecurend >= $firstdaytoshow) // We add event { - $newevent=$icalevent; + $newevent = $icalevent; unset($newevent['RRULE']); if ($icalevent['DTSTART;VALUE=DATE']) { - $newevent['DTSTART;VALUE=DATE']=dol_print_date($datecurstart, '%Y%m%d'); - $newevent['DTEND;VALUE=DATE']=dol_print_date($datecurend+1, '%Y%m%d'); + $newevent['DTSTART;VALUE=DATE'] = dol_print_date($datecurstart, '%Y%m%d'); + $newevent['DTEND;VALUE=DATE'] = dol_print_date($datecurend + 1, '%Y%m%d'); } else { - $newevent['DTSTART']=$datecurstart; - $newevent['DTEND']=$datecurend; + $newevent['DTSTART'] = $datecurstart; + $newevent['DTEND'] = $datecurend; } - $moreicalevents[]=$newevent; + $moreicalevents[] = $newevent; } // Jump on next occurence $numofevent++; - $savdatecurstart=$datecurstart; - if ($icalevent['RRULE']['FREQ']=='DAILY') + $savdatecurstart = $datecurstart; + if ($icalevent['RRULE']['FREQ'] == 'DAILY') { - $datecurstart=dol_time_plus_duree($datecurstart, $interval, 'd'); - $datecurend=dol_time_plus_duree($datecurend, $interval, 'd'); + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'd'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'd'); } - if ($icalevent['RRULE']['FREQ']=='WEEKLY') + if ($icalevent['RRULE']['FREQ'] == 'WEEKLY') { - $datecurstart=dol_time_plus_duree($datecurstart, $interval, 'w'); - $datecurend=dol_time_plus_duree($datecurend, $interval, 'w'); + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'w'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'w'); } - elseif ($icalevent['RRULE']['FREQ']=='MONTHLY') + elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') { - $datecurstart=dol_time_plus_duree($datecurstart, $interval, 'm'); - $datecurend=dol_time_plus_duree($datecurend, $interval, 'm'); + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'm'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'm'); } - elseif ($icalevent['RRULE']['FREQ']=='YEARLY') + elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') { - $datecurstart=dol_time_plus_duree($datecurstart, $interval, 'y'); - $datecurend=dol_time_plus_duree($datecurend, $interval, 'y'); + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'y'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'y'); } // Test to avoid infinite loop ($datecurstart must increase) if ($savdatecurstart >= $datecurstart) { dol_syslog("Found a rule freq ".$icalevent['RRULE']['FREQ']." not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR); - $datecurstart+=3600*24*7; - $datecurend+=3600*24*7; + $datecurstart += 3600 * 24 * 7; + $datecurend += 3600 * 24 * 7; } } } } - $icalevents=array_merge($icalevents, $moreicalevents); + $icalevents = array_merge($icalevents, $moreicalevents); // Loop on each entry into cal file to know if entry is qualified and add an ActionComm into $eventarray - foreach($icalevents as $icalevent) + foreach ($icalevents as $icalevent) { //var_dump($icalevent); //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'
    ';exit; - if (! empty($icalevent['RRULE'])) continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. + if (!empty($icalevent['RRULE'])) continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. // Create a new object action - $event=new ActionComm($db); + $event = new ActionComm($db); $addevent = false; if (isset($icalevent['DTSTART;VALUE=DATE'])) // fullday event { // For full day events, date are also GMT but they wont but converted using tz during output - $datestart=dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); - $dateend=dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1)-1; // We remove one second to get last second of day + $datestart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); + $dateend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day //print 'x'.$datestart.'-'.$dateend;exit; //print dol_print_date($dateend,'dayhour','gmt'); - $event->fulldayevent=1; - $addevent=true; + $event->fulldayevent = 1; + $addevent = true; } elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) { - $datestart=$icalevent['DTSTART']; - $dateend=$icalevent['DTEND']; + $datestart = $icalevent['DTSTART']; + $dateend = $icalevent['DTEND']; - $datestart+=+($offsettz * 3600); - $dateend+=+($offsettz * 3600); + $datestart += +($offsettz * 3600); + $dateend += +($offsettz * 3600); - $addevent=true; + $addevent = true; //var_dump($offsettz); //var_dump(dol_print_date($datestart, 'dayhour', 'gmt')); } elseif (isset($icalevent['DTSTART']['unixtime'])) // File contains a local timezone + a TZ (for example when using bluemind) { - $datestart=$icalevent['DTSTART']['unixtime']; - $dateend=$icalevent['DTEND']['unixtime']; + $datestart = $icalevent['DTSTART']['unixtime']; + $dateend = $icalevent['DTEND']['unixtime']; - $datestart+=+($offsettz * 3600); - $dateend+=+($offsettz * 3600); + $datestart += +($offsettz * 3600); + $dateend += +($offsettz * 3600); // $buggedfile is set to uselocalandtznodaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtznodaylight' if ($buggedfile === 'uselocalandtznodaylight') // unixtime is a local date that does not take daylight into account, TZID is +1 for example for 'Europe/Paris' in summer instead of 2 @@ -930,38 +930,38 @@ if (count($listofextcals)) $localtze = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTEND']['TZID'])); $localdts = new DateTime(dol_print_date($datestart, 'dayrfc', 'gmt'), $localtzs); $localdte = new DateTime(dol_print_date($dateend, 'dayrfc', 'gmt'), $localtze); - $tmps=-1*$localtzs->getOffset($localdts); - $tmpe=-1*$localtze->getOffset($localdte); - $datestart+=$tmps; - $dateend+=$tmpe; + $tmps = -1 * $localtzs->getOffset($localdts); + $tmpe = -1 * $localtze->getOffset($localdte); + $datestart += $tmps; + $dateend += $tmpe; //var_dump($datestart); } - $addevent=true; + $addevent = true; } if ($addevent) { - $event->id=$icalevent['UID']; - $event->icalname=$namecal; - $event->icalcolor=$colorcal; - $usertime=0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. - $event->datep=$datestart+$usertime; - $event->datef=$dateend+$usertime; - $event->type_code="ICALEVENT"; + $event->id = $icalevent['UID']; + $event->icalname = $namecal; + $event->icalcolor = $colorcal; + $usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. + $event->datep = $datestart + $usertime; + $event->datef = $dateend + $usertime; + $event->type_code = "ICALEVENT"; - if($icalevent['SUMMARY']) $event->label=$icalevent['SUMMARY']; - elseif($icalevent['DESCRIPTION']) $event->label=dol_nl2br($icalevent['DESCRIPTION'], 1); + if ($icalevent['SUMMARY']) $event->label = $icalevent['SUMMARY']; + elseif ($icalevent['DESCRIPTION']) $event->label = dol_nl2br($icalevent['DESCRIPTION'], 1); else $event->label = $langs->trans("ExtSiteNoLabel"); - $event->date_start_in_calendar=$event->datep; + $event->date_start_in_calendar = $event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; + else $event->date_end_in_calendar = $event->datep; // Define ponctual property if ($event->date_start_in_calendar == $event->date_end_in_calendar) { - $event->ponctuel=1; + $event->ponctuel = 1; //print 'x'.$datestart.'-'.$dateend;exit; } @@ -975,26 +975,26 @@ if (count($listofextcals)) } else { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); // Add an entry in actionarray for each day - $daycursor=$event->date_start_in_calendar; + $daycursor = $event->date_start_in_calendar; $annee = date('Y', $daycursor); $mois = date('m', $daycursor); $jour = date('d', $daycursor); // Loop on each day covered by action to prepare an index to show on calendar - $loop=true; $j=0; + $loop = true; $j = 0; // daykey must be date that represent day box in calendar so must be a user time - $daykey=dol_mktime(0, 0, 0, $mois, $jour, $annee); - $daykeygmt=dol_mktime(0, 0, 0, $mois, $jour, $annee, true, 0); + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + $daykeygmt = dol_mktime(0, 0, 0, $mois, $jour, $annee, true, 0); do { //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' '; - $eventarray[$daykey][]=$event; - $daykey+=60*60*24; $daykeygmt+=60*60*24; // Add one day - if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop=false; + $eventarray[$daykey][] = $event; + $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24; // Add one day + if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop = false; } while ($loop); } @@ -1007,28 +1007,28 @@ if (count($listofextcals)) // Complete $eventarray with events coming from external module -$parameters=array(); $object=null; -$reshook=$hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action); -if (! empty($hookmanager->resArray['eventarray'])) { +$parameters = array(); $object = null; +$reshook = $hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action); +if (!empty($hookmanager->resArray['eventarray'])) { foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) { if (!isset($eventarray[$keyDate])) { - $eventarray[$keyDate]=array(); + $eventarray[$keyDate] = array(); } - $eventarray[$keyDate]=array_merge($eventarray[$keyDate], $events); + $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events); } } // Sort events -foreach($eventarray as $keyDate => &$dateeventarray) +foreach ($eventarray as $keyDate => &$dateeventarray) { usort($dateeventarray, 'sort_events_by_date'); } -$maxnbofchar=0; -$cachethirdparties=array(); -$cachecontacts=array(); -$cacheusers=array(); +$maxnbofchar = 0; +$cachethirdparties = array(); +$cachecontacts = array(); +$cacheusers = array(); // Define theme_datacolor array $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; @@ -1036,34 +1036,34 @@ if (is_readable($color_file)) { include_once $color_file; } -if (! is_array($theme_datacolor)) $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220)); +if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); if (empty($action) || $action == 'show_month') // View by month { - $newparam=$param; // newparam is for birthday links - $newparam=preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done - $newparam=preg_replace('/action=show_month&?/i', '', $newparam); - $newparam=preg_replace('/action=show_week&?/i', '', $newparam); - $newparam=preg_replace('/day=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/month=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/year=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/viewcal=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter - $newparam.='&viewcal=1'; + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/viewcal=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter + $newparam .= '&viewcal=1'; print '
    '; print ''; print ' '; - $i=0; + $i = 0; while ($i < 7) { print ' '."\n"; - $todayarray=dol_getdate($now, 'fast'); - $todaytms=dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']); + $todayarray = dol_getdate($now, 'fast'); + $todaytms = dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']); // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) //var_dump($eventarray); - for ($iter_week = 0; $iter_week < 6 ; $iter_week++) + for ($iter_week = 0; $iter_week < 6; $iter_week++) { echo " \n"; for ($iter_day = 0; $iter_day < 7; $iter_day++) @@ -1085,8 +1085,8 @@ if (empty($action) || $action == 'show_month') // View by month /* Show days before the beginning of the current month (previous month) */ if ($tmpday <= 0) { - $style='cal_other_month cal_past'; - if ($iter_day == 6) $style.=' cal_other_month_right'; + $style = 'cal_other_month cal_past'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; echo ' \n"; @@ -1095,12 +1095,12 @@ if (empty($action) || $action == 'show_month') // View by month elseif ($tmpday <= $max_day_in_month) { $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); - $style='cal_current_month'; - if ($iter_day == 6) $style.=' cal_current_month_right'; - $today=0; - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1; - if ($today) $style='cal_today'; - if ($curtime < $todaytms) $style.=' cal_past'; + $style = 'cal_current_month'; + if ($iter_day == 6) $style .= ' cal_current_month_right'; + $today = 0; + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; + if ($today) $style = 'cal_today'; + if ($curtime < $todaytms) $style .= ' cal_past'; //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style); echo ' \n"; @@ -1124,28 +1124,28 @@ if (empty($action) || $action == 'show_month') // View by month print ''; print ''; - print '' ; + print ''; } elseif ($action == 'show_week') // View by week { - $newparam=$param; // newparam is for birthday links - $newparam=preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done - $newparam=preg_replace('/action=show_month&?/i', '', $newparam); - $newparam=preg_replace('/action=show_week&?/i', '', $newparam); - $newparam=preg_replace('/day=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/month=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/year=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter - $newparam.='&viewweek=1'; + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter + $newparam .= '&viewweek=1'; print '
    '; print '
    '; - $numdayinweek=(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7); - if (! empty($conf->dol_optimize_smallscreen)) + $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7); + if (!empty($conf->dol_optimize_smallscreen)) { - $labelshort=array(0=>'SundayMin',1=>'MondayMin',2=>'TuesdayMin',3=>'WednesdayMin',4=>'ThursdayMin',5=>'FridayMin',6=>'SaturdayMin'); + $labelshort = array(0=>'SundayMin', 1=>'MondayMin', 2=>'TuesdayMin', 3=>'WednesdayMin', 4=>'ThursdayMin', 5=>'FridayMin', 6=>'SaturdayMin'); print $langs->trans($labelshort[$numdayinweek]); } else print $langs->trans("Day".$numdayinweek); @@ -1072,12 +1072,12 @@ if (empty($action) || $action == 'show_month') // View by month } echo '
    '; show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo " '; show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); @@ -1109,8 +1109,8 @@ if (empty($action) || $action == 'show_month') // View by month /* Show days after the current month (next month) */ else { - $style='cal_other_month'; - if ($iter_day == 6) $style.=' cal_other_month_right'; + $style = 'cal_other_month'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; echo ' '; show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo "
    '; print ' '; - $i=0; + $i = 0; while ($i < 7) { - echo ' \n"; + echo ' \n"; $i++; } echo " \n"; @@ -1161,12 +1161,12 @@ elseif ($action == 'show_week') // View by week $tmpmonth = $tmparray['mon']; $tmpyear = $tmparray['year']; - $style='cal_current_month'; - if ($iter_day == 6) $style.=' cal_other_month_right'; - $today=0; - $todayarray=dol_getdate($now, 'fast'); - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; - if ($today) $style='cal_today'; + $style = 'cal_current_month'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; + $today = 0; + $todayarray = dol_getdate($now, 'fast'); + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; + if ($today) $style = 'cal_today'; echo ' "; print ''; print ''."\n"; - if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''; } else { @@ -779,7 +779,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -796,23 +796,23 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) /* * Opened Order */ -if (! empty($conf->commande->enabled) && $user->rights->commande->lire) +if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; - $sql.= ", s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - $sql.= " AND (c.fk_statut = ".Commande::STATUS_VALIDATED." or c.fk_statut = ".Commande::STATUS_SHIPMENTONPROCESS.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY c.rowid DESC"; + $sql .= ", s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND (c.fk_statut = ".Commande::STATUS_VALIDATED." or c.fk_statut = ".Commande::STATUS_SHIPMENTONPROCESS.")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY c.rowid DESC"; - $result=$db->query($sql); + $result = $db->query($sql); if ($result) { $total = 0; @@ -824,7 +824,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print '
    '.$langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7))."'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."
    '; show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); @@ -1179,24 +1179,24 @@ elseif ($action == 'show_week') // View by week echo ''; echo ''; - echo '' ; + echo ''; } else // View by day { - $newparam=$param; // newparam is for birthday links - $newparam=preg_replace('/action=show_month&?/i', '', $newparam); - $newparam=preg_replace('/action=show_week&?/i', '', $newparam); - $newparam=preg_replace('/viewday=[0-9]+&?/i', '', $newparam); - $newparam.='&viewday=1'; + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/viewday=[0-9]+&?/i', '', $newparam); + $newparam .= '&viewday=1'; // Code to show just one day - $style='cal_current_month cal_current_month_oneday'; - $today=0; - $todayarray=dol_getdate($now, 'fast'); - if ($todayarray['mday']==$day && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1; + $style = 'cal_current_month cal_current_month_oneday'; + $today = 0; + $todayarray = dol_getdate($now, 'fast'); + if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; //if ($today) $style='cal_today'; - $timestamp=dol_mktime(12, 0, 0, $month, $day, $year); - $arraytimestamp=dol_getdate($timestamp); + $timestamp = dol_mktime(12, 0, 0, $month, $day, $year); + $arraytimestamp = dol_getdate($timestamp); //echo ''; echo '
    '; @@ -1221,14 +1221,14 @@ else // View by day $useviewhour = 0; if ($useviewhour) { - print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table - $maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500)?($_SESSION["dol_screenheight"]-200):660; // Also into index.php file + $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file echo '
    '; echo '
    '; - $maxnbofchar=80; + $maxnbofchar = 80; $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS); $minhour = round($tmp[0], 0); @@ -1242,7 +1242,7 @@ else // View by day while ($i < 24) { echo '
    '."\n"; - echo '
    '.dol_print_date($i*3600, 'hour', 'gmt').'
    '; + echo '
    '.dol_print_date($i * 3600, 'hour', 'gmt').'
    '; echo '
    '; echo "
    \n"; echo "
    \n"; @@ -1258,7 +1258,7 @@ else // View by day } else { - print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); @@ -1294,7 +1294,7 @@ $db->close(); function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0) { global $user, $conf, $langs; - global $action, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form + global $action, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form global $theme_datacolor; global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused; @@ -1319,11 +1319,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print '
    '; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { - $newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; //$param='month='.$monthshown.'&year='.$year; - $hourminsec='100000'; - print ''; + $hourminsec = '100000'; + print ''; print img_picto($langs->trans("NewAction"), 'edit_add.png'); print ''; } @@ -1341,11 +1341,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print '
    '; //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); - $i=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); - $ymd=sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); + $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); + $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); - $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 - $nextindextouse=is_array($colorindexused)?count($colorindexused):0; // At first run this is 0, so fist user has 0, next 1, ... + $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 + $nextindextouse = is_array($colorindexused) ?count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ... //var_dump($colorindexused); foreach ($eventarray as $daykey => $notused) @@ -1353,117 +1353,117 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $annee = date('Y', $daykey); $mois = date('m', $daykey); $jour = date('d', $daykey); - if ($day==$jour && $month==$mois && $year==$annee) + if ($day == $jour && $month == $mois && $year == $annee) { foreach ($eventarray[$daykey] as $index => $event) { - if ($i < $maxprint || $maxprint == 0 || ! empty($conf->global->MAIN_JS_SWITCH_AGENDA)) + if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) { - $keysofuserassigned=array_keys($event->userassigned); - $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); + $keysofuserassigned = array_keys($event->userassigned); + $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); // Define $color (Hex string like '0088FF') and $cssclass of event - $color=-1; $cssclass=''; $colorindex=-1; + $color = -1; $cssclass = ''; $colorindex = -1; if (in_array($user->id, $keysofuserassigned)) { - $cssclass='family_mytasks'; + $cssclass = 'family_mytasks'; if (empty($cacheusers[$event->userownerid])) { - $newuser=new User($db); + $newuser = new User($db); $newuser->fetch($event->userownerid); - $cacheusers[$event->userownerid]=$newuser; + $cacheusers[$event->userownerid] = $newuser; } //var_dump($cacheusers[$event->userownerid]->color); // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; } elseif ($event->type_code == 'ICALEVENT') // Event come from external ical file { $numical++; - if (! empty($event->icalname)) { - if (! isset($numicals[dol_string_nospecial($event->icalname)])) { + if (!empty($event->icalname)) { + if (!isset($numicals[dol_string_nospecial($event->icalname)])) { $numicals[dol_string_nospecial($event->icalname)] = 0; } $numicals[dol_string_nospecial($event->icalname)]++; } - $color=($event->icalcolor?$event->icalcolor:-1); - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other'); + $color = ($event->icalcolor ? $event->icalcolor : -1); + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); } elseif ($event->type_code == 'BIRTHDAY') { - $numbirthday++; $colorindex=2; $cssclass='family_birthday unmovable'; $color=sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unmovable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } else { $numother++; - $color=($event->icalcolor?$event->icalcolor:-1); - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other'); + $color = ($event->icalcolor ? $event->icalcolor : -1); + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); if (empty($cacheusers[$event->userownerid])) { - $newuser=new User($db); + $newuser = new User($db); $newuser->fetch($event->userownerid); - $cacheusers[$event->userownerid]=$newuser; + $cacheusers[$event->userownerid] = $newuser; } //var_dump($cacheusers[$event->userownerid]->color); // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; } if ($color < 0) // Color was not set on user card. Set color according to color index. { // Define color index if not yet defined - $idusertouse=($event->userownerid?$event->userownerid:0); + $idusertouse = ($event->userownerid ? $event->userownerid : 0); if (isset($colorindexused[$idusertouse])) { - $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user + $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user } else { - $colorindex=$nextindextouse; - $colorindexused[$idusertouse]=$colorindex; - if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color + $colorindex = $nextindextouse; + $colorindexused[$idusertouse] = $colorindex; + if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color } //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'
    '; // Define color - $color=sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } - $cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd; + $cssclass = $cssclass.' '.$cssclass.'_day_'.$ymd; // Defined style to disable drag and drop feature - if ($event->type_code =='AC_OTH_AUTO') + if ($event->type_code == 'AC_OTH_AUTO') { - $cssclass.= " unmovable"; + $cssclass .= " unmovable"; } elseif ($event->type_code == 'ICALEVENT') { - $cssclass.= " unmovable"; + $cssclass .= " unmovable"; } elseif ($event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) { $tmpyearend = date('Y', $event->date_end_in_calendar); $tmpmonthend = date('m', $event->date_end_in_calendar); $tmpdayend = date('d', $event->date_end_in_calendar); if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) { - $cssclass.= " unmovable"; + $cssclass .= " unmovable"; } } - else{ + else { if ($user->rights->agenda->allactions->create || (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { - $cssclass.= " movable cursormove"; - }else{ - $cssclass.= " unmovable"; + $cssclass .= " movable cursormove"; + } else { + $cssclass .= " unmovable"; } } - $h=''; $nowrapontd=1; - if ($action == 'show_day') { $h='height: 100%; '; $nowrapontd=0; } - if ($action == 'show_week') { $h='height: 100%; '; $nowrapontd=0; } + $h = ''; $nowrapontd = 1; + if ($action == 'show_day') { $h = 'height: 100%; '; $nowrapontd = 0; } + if ($action == 'show_week') { $h = 'height: 100%; '; $nowrapontd = 0; } // Show rect of event print "\n"; @@ -1499,9 +1499,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa //print 'border: 1px solid #ccc" width="100%"'; print '">'; print '
    '; - print ''; // Status - Percent - $withstatus=0; + $withstatus = 0; if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') { - $withstatus=1; - if ($event->percentage >= 0) $withstatus=2; + $withstatus = 1; + if ($event->percentage >= 0) $withstatus = 2; } - print '
    '; + print ''; - $daterange=''; + $daterange = ''; if ($event->type_code == 'BIRTHDAY') // It's a birthday { @@ -1528,11 +1528,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // Hour start if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) { - $daterange.=dol_print_date($event->date_start_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user + $daterange .= dol_print_date($event->date_start_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) - $daterange.='-'; + $daterange .= '-'; //else //print '...'; } @@ -1541,14 +1541,14 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa { if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) { - $daterange.='...'; + $daterange .= '...'; } } // Hour end if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) - $daterange.=dol_print_date($event->date_end_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user + $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user } } else @@ -1561,34 +1561,34 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // Show title $titletoshow = $daterange; - $titletoshow.=($titletoshow?' ':'').($event->label?$event->label:$event->libelle); + $titletoshow .= ($titletoshow ? ' ' : '').($event->label ? $event->label : $event->libelle); if ($event->type_code == 'ICALEVENT') print $titletoshow; else { - $savlabel=$event->label?$event->label:$event->libelle; - $event->label=$titletoshow; - $event->libelle=$titletoshow; + $savlabel = $event->label ? $event->label : $event->libelle; + $event->label = $titletoshow; + $event->libelle = $titletoshow; print $event->getNomUrl(0, $maxnbofchar, 'cal_event', '', 0, 0); - $event->label=$savlabel; - $event->libelle=$savlabel; + $event->label = $savlabel; + $event->libelle = $savlabel; } // Loop on each assigned user - $listofusertoshow=''; - $posuserassigned=0; - foreach($event->userassigned as $tmpid => $tmpdata) + $listofusertoshow = ''; + $posuserassigned = 0; + foreach ($event->userassigned as $tmpid => $tmpdata) { - if (! $posuserassigned && $titletoshow) $listofusertoshow.='
    '; + if (!$posuserassigned && $titletoshow) $listofusertoshow .= '
    '; $posuserassigned++; if (empty($cacheusers[$tmpid])) { - $newuser=new User($db); + $newuser = new User($db); $newuser->fetch($tmpid); - $cacheusers[$tmpid]=$newuser; + $cacheusers[$tmpid] = $newuser; } - $listofusertoshow.=$cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom'); + $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom'); } print $listofusertoshow; @@ -1598,35 +1598,35 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->cotact->id > 0) ? $event->contact->id : 0)); // If action related to company / contact - $linerelatedto=''; + $linerelatedto = ''; if ($thirdparty_id > 0) { - if (! isset($cachethirdparties[$thirdparty_id]) || ! is_object($cachethirdparties[$thirdparty_id])) + if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) { - $thirdparty=new Societe($db); + $thirdparty = new Societe($db); $thirdparty->fetch($thirdparty_id); - $cachethirdparties[$thirdparty_id]=$thirdparty; + $cachethirdparties[$thirdparty_id] = $thirdparty; } - else $thirdparty=$cachethirdparties[$thirdparty_id]; - if (! empty($thirdparty->id)) $linerelatedto.=$thirdparty->getNomUrl(1, '', 0); + else $thirdparty = $cachethirdparties[$thirdparty_id]; + if (!empty($thirdparty->id)) $linerelatedto .= $thirdparty->getNomUrl(1, '', 0); } - if (! empty($contact_id) && $contact_id > 0) + if (!empty($contact_id) && $contact_id > 0) { - if (! is_object($cachecontacts[$contact_id])) + if (!is_object($cachecontacts[$contact_id])) { - $contact=new Contact($db); + $contact = new Contact($db); $contact->fetch($contact_id); - $cachecontacts[$contact_id]=$contact; + $cachecontacts[$contact_id] = $contact; } - else $contact=$cachecontacts[$contact_id]; - if ($linerelatedto) $linerelatedto.=' '; - if (! empty($contact->id)) $linerelatedto.=$contact->getNomUrl(1, '', 0); + else $contact = $cachecontacts[$contact_id]; + if ($linerelatedto) $linerelatedto .= ' '; + if (!empty($contact->id)) $linerelatedto .= $contact->getNomUrl(1, '', 0); } - if (! empty($event->fk_element) && $event->fk_element > 0 && ! empty($event->elementtype) && ! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) + if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if ($linerelatedto) $linerelatedto.='
    '; - $linerelatedto.=dolGetElementUrl($event->fk_element, $event->elementtype, 1); + if ($linerelatedto) $linerelatedto .= '
    '; + $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1); } if ($linerelatedto) print '
    '.$linerelatedto; } @@ -1643,13 +1643,13 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print '
    '; + print ''; if ($withstatus) print $event->getLibStatut(3, 1); else print ' '; print '
    '; @@ -1674,9 +1674,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa break; } } - if (! $i) print ' '; + if (!$i) print ' '; - if (! empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) + if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) { print '
    '.img_picto("all", "1downarrow_selected.png").' +'.$langs->trans("More").'...
    '; //print ' +'.(count($eventarray[$daykey])-$maxprint); @@ -1695,9 +1695,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print ''."\n"; } - print ''; // td tr + print ''; // td tr - print ''; // table + print ''; // table print "\n"; } @@ -1712,12 +1712,12 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa */ function dol_color_minus($color, $minus, $minusunit = 16) { - $newcolor=$color; + $newcolor = $color; if ($minusunit == 16) { - $newcolor[0]=dechex(max(min(hexdec($newcolor[0])-$minus, 15), 0)); - $newcolor[2]=dechex(max(min(hexdec($newcolor[2])-$minus, 15), 0)); - $newcolor[4]=dechex(max(min(hexdec($newcolor[4])-$minus, 15), 0)); + $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0)); + $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0)); + $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0)); } else { @@ -1745,7 +1745,7 @@ function sort_events_by_date($a, $b) } // Events have same start time and no end time - if ((! is_numeric($b->datef)) || (! is_numeric($a->datef))) + if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) { return sort_events_by_percentage($a, $b); } diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index d405d2526d3..6e26e732010 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -30,13 +30,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -if (! $user->rights->societe->lire) accessforbidden(); +if (!$user->rights->societe->lire) accessforbidden(); $hookmanager = new HookManager($db); @@ -46,19 +46,19 @@ $hookmanager->initHooks(array('commercialindex')); // Load translation files required by the page $langs->loadLangs(array("commercial", "propal")); -$action=GETPOST('action', 'alpha'); -$bid=GETPOST('bid', 'int'); +$action = GETPOST('action', 'alpha'); +$bid = GETPOST('bid', 'int'); // Securite acces client -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } -$max=3; -$now=dol_now(); +$max = 3; +$now = dol_now(); /* * Actions @@ -71,11 +71,11 @@ $now=dol_now(); $form = new Form($db); $formfile = new FormFile($db); -$companystatic=new Societe($db); -if (! empty($conf->propal->enabled)) $propalstatic=new Propal($db); -if (! empty($conf->supplier_proposal->enabled)) $supplierproposalstatic=new SupplierProposal($db); -if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db); -if (! empty($conf->fournisseur->enabled)) $supplierorderstatic=new CommandeFournisseur($db); +$companystatic = new Societe($db); +if (!empty($conf->propal->enabled)) $propalstatic = new Propal($db); +if (!empty($conf->supplier_proposal->enabled)) $supplierproposalstatic = new SupplierProposal($db); +if (!empty($conf->commande->enabled)) $orderstatic = new Commande($db); +if (!empty($conf->fournisseur->enabled)) $supplierorderstatic = new CommandeFournisseur($db); llxHeader("", $langs->trans("CommercialArea")); @@ -83,37 +83,37 @@ print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial'); print '
    '; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search proposal - if (! empty($conf->propal->enabled) && $user->rights->propal->lire) + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { - $listofsearchfields['search_proposal']=array('text'=>'Proposal'); + $listofsearchfields['search_proposal'] = array('text'=>'Proposal'); } // Search customer order - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { - $listofsearchfields['search_customer_order']=array('text'=>'CustomerOrder'); + $listofsearchfields['search_customer_order'] = array('text'=>'CustomerOrder'); } // Search supplier proposal - if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) + if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { - $listofsearchfields['search_supplier_proposal']=array('text'=>'SupplierProposalShort'); + $listofsearchfields['search_supplier_proposal'] = array('text'=>'SupplierProposalShort'); } // Search supplier order - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { - $listofsearchfields['search_supplier_order']=array('text'=>'SupplierOrder'); + $listofsearchfields['search_supplier_order'] = array('text'=>'SupplierOrder'); } // Search intervention - if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { - $listofsearchfields['search_intervention']=array('text'=>'Intervention'); + $listofsearchfields['search_intervention'] = array('text'=>'Intervention'); } // Search contract - if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { - $listofsearchfields['search_contract']=array('text'=>'Contract'); + $listofsearchfields['search_contract'] = array('text'=>'Contract'); } if (count($listofsearchfields)) @@ -122,8 +122,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; print '
    '; print ''; - $i=0; - foreach($listofsearchfields as $key => $value) + $i = 0; + foreach ($listofsearchfields as $key => $value) { if ($i == 0) print ''; print ''; @@ -143,22 +143,22 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele /* * Draft proposals */ -if (! empty($conf->propal->enabled) && $user->rights->propal->lire) +if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql.= ", s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_statut = 0"; - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; + $sql .= ", s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_statut = 0"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $total = 0; @@ -172,27 +172,27 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) if ($num > 0) { $i = 0; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($resql); print ''; print ''; print ''; @@ -203,7 +203,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -227,22 +227,22 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) /* * Draft supplier proposals */ -if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) +if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { $langs->load("supplier_proposal"); $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql.= ", s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_statut = 0"; - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; + $sql .= ", s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_statut = 0"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $total = 0; @@ -251,31 +251,31 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos print '
    '; print '
    '.$langs->trans("Search").'
    '; - $propalstatic->id=$obj->rowid; - $propalstatic->ref=$obj->ref; - $propalstatic->ref_client=$obj->ref_client; + $propalstatic->id = $obj->rowid; + $propalstatic->ref = $obj->ref; + $propalstatic->ref_client = $obj->ref_client; $propalstatic->total_ht = $obj->total_ht; $propalstatic->total_tva = $obj->total_tva; $propalstatic->total_ttc = $obj->total_ttc; print $propalstatic->getNomUrl(1); print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'customer', 16); print ''.price($obj->total_ht).'
    '.$langs->trans("XMoreLines", ($num - $nbofloop))."
    '.$langs->trans("Total").''.price($total)."
    '; print ''; - print ''; + print ''; if ($num > 0) { $i = 0; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($resql); print ''; print ''; print ''; @@ -286,7 +286,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -309,20 +309,20 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos /* * Draft orders */ -if (! empty($conf->commande->enabled) && $user->rights->commande->lire) +if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql.= ", s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.fk_statut = 0"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; + $sql .= ", s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.fk_statut = 0"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; $resql = $db->query($sql); if ($resql) @@ -333,34 +333,34 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print '
    '; print '
    '.$langs->trans("SupplierProposalsDraft").($num?' '.$num.'':'').'
    '.$langs->trans("SupplierProposalsDraft").($num ? ' '.$num.'' : '').'
    '; - $supplierproposalstatic->id=$obj->rowid; - $supplierproposalstatic->ref=$obj->ref; + $supplierproposalstatic->id = $obj->rowid; + $supplierproposalstatic->ref = $obj->ref; $supplierproposalstatic->total_ht = $obj->total_ht; $supplierproposalstatic->total_tva = $obj->total_tva; $supplierproposalstatic->total_ttc = $obj->total_ttc; print $supplierproposalstatic->getNomUrl(1); print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'supplier', 16); print ''.price($obj->total_ht).'
    '.$langs->trans("XMoreLines", ($num - $nbofloop))."
    '.$langs->trans("Total").''.price($total)."
    '; print ''; - print ''; + print ''; if ($num > 0) { $i = 0; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($resql); print ''; print ''; - if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''; } else { @@ -373,7 +373,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -397,21 +397,21 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) /* * Draft suppliers orders */ -if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { $langs->load("orders"); $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql.= ", s.code_client"; - $sql.= ", s.code_fournisseur"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE cf.fk_soc = s.rowid"; - $sql.= " AND cf.fk_statut = 0"; - $sql.= " AND cf.entity IN (".getEntity('supplier_order').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND cf.fk_soc = ".$socid; + $sql .= ", s.code_client"; + $sql .= ", s.code_fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE cf.fk_soc = s.rowid"; + $sql .= " AND cf.fk_statut = 0"; + $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND cf.fk_soc = ".$socid; $resql = $db->query($sql); if ($resql) @@ -422,34 +422,34 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande print '
    '; print '
    '.$langs->trans("DraftOrders").($num?' '.$num.'':'').'
    '.$langs->trans("DraftOrders").($num ? ' '.$num.'' : '').'
    '; - $orderstatic->id=$obj->rowid; - $orderstatic->ref=$obj->ref; - $orderstatic->ref_client=$obj->ref_client; + $orderstatic->id = $obj->rowid; + $orderstatic->ref = $obj->ref; + $orderstatic->ref_client = $obj->ref_client; $orderstatic->total_ht = $obj->total_ht; $orderstatic->total_tva = $obj->total_tva; $orderstatic->total_ttc = $obj->total_ttc; print $orderstatic->getNomUrl(1); print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'customer', 16); print ''.price($obj->total_ht).'
    '.$langs->trans("XMoreLines", ($num - $nbofloop))."
    '.$langs->trans("Total").''.price($total)."
    '; print ''; - print ''; + print ''; if ($num > 0) { $i = 0; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($resql); print ''; print ''; - if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''; } else { @@ -462,7 +462,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -484,24 +484,24 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande print '
    '; -$max=3; +$max = 3; /* * Last modified customers or prospects */ -if (! empty($conf->societe->enabled) && $user->rights->societe->lire) +if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { $langs->load("boxes"); $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; - $sql.= ", s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.client IN (1, 2, 3)"; - $sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = $socid"; + $sql .= ", s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.client IN (1, 2, 3)"; + $sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = $socid"; $sql .= " ORDER BY s.tms DESC"; $sql .= $db->plimit($max, 0); @@ -516,7 +516,7 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) print '
    '; print ''; print ''; @@ -526,12 +526,12 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) while ($i < $num) { $objp = $db->fetch_object($resql); - $companystatic->id=$objp->rowid; - $companystatic->name=$objp->name; - $companystatic->client=$objp->client; + $companystatic->id = $objp->rowid; + $companystatic->name = $objp->name; + $companystatic->client = $objp->client; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas=$objp->canvas; + $companystatic->canvas = $objp->canvas; print ''; print ''; print ''; print ''; print ''; @@ -630,26 +630,26 @@ if ($user->rights->agenda->myactions->read) /* * Last contracts */ -if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT +if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT { $langs->load("contracts"); $sql = "SELECT s.nom as name, s.rowid, s.canvas, "; - $sql.= ", s.code_client"; - $sql.= " c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; - $sql.= ", ".MAIN_DB_PREFIX."product as p"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('contract').")"; - $sql.= " AND c.fk_product = p.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY c.tms DESC"; - $sql.= $db->plimit(5, 0); + $sql .= ", s.code_client"; + $sql .= " c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('contract').")"; + $sql .= " AND c.fk_product = p.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY c.tms DESC"; + $sql .= $db->plimit(5, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -661,18 +661,18 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO print ''; $i = 0; - $staticcontrat=new Contrat($db); + $staticcontrat = new Contrat($db); while ($i < $num) { $obj = $db->fetch_object($resql); print ''; print ''."\n"; print "\n"; @@ -692,23 +692,23 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO /* * Opened proposals */ -if (! empty($conf->propal->enabled) && $user->rights->propal->lire) +if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT s.nom as name, s.rowid, s.code_client"; - $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - $sql.= " AND p.fk_statut = 1"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY p.rowid DESC"; + $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " AND p.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY p.rowid DESC"; - $result=$db->query($sql); + $result = $db->query($sql); if ($result) { $total = 0; @@ -720,7 +720,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print '
    '.$langs->trans("DraftSuppliersOrders").($num?' '.$num.'':'').'
    '.$langs->trans("DraftSuppliersOrders").($num ? ' '.$num.'' : '').'
    '; - $supplierorderstatic->id=$obj->rowid; - $supplierorderstatic->ref=$obj->ref; - $supplierorderstatic->ref_supplier=$obj->ref_suppliert; + $supplierorderstatic->id = $obj->rowid; + $supplierorderstatic->ref = $obj->ref; + $supplierorderstatic->ref_supplier = $obj->ref_suppliert; $supplierorderstatic->total_ht = $obj->total_ht; $supplierorderstatic->total_tva = $obj->total_tva; $supplierorderstatic->total_ttc = $obj->total_ttc; print $supplierorderstatic->getNomUrl(1); print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'supplier', 16); print ''.price($obj->total_ht).'
    '.$langs->trans("XMoreLines", ($num - $nbofloop))."
    '.$langs->trans("Total").''.price($total)."
    '; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects", $max); - elseif (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects", $max); + elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects", $max); else print $langs->trans("BoxTitleLastModifiedCustomers", $max); print ''.$langs->trans("FullList").'
    '.$companystatic->getNomUrl(1, 'customer', 48).''; @@ -554,20 +554,20 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) } // Last suppliers -if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->societe->lire) { $langs->load("boxes"); $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm"; - $sql.= ", s.code_fournisseur"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.fournisseur = 1"; - $sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; - if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY s.datec DESC"; - $sql.= $db->plimit($max, 0); + $sql .= ", s.code_fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.fournisseur = 1"; + $sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY s.datec DESC"; + $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) @@ -586,11 +586,11 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) while ($i < $num && $i < $max) { $objp = $db->fetch_object($result); - $companystatic->id=$objp->rowid; - $companystatic->name=$objp->name; + $companystatic->id = $objp->rowid; + $companystatic->name = $objp->name; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas=$objp->canvas; + $companystatic->canvas = $objp->canvas; print '
    '.$companystatic->getNomUrl(1, 'supplier', 44).''.dol_print_date($db->jdate($objp->dm), 'day').'
    '.$langs->trans("LastContracts", 5).'
    contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."'; - $companystatic->id=$objp->rowid; - $companystatic->name=$objp->name; + $companystatic->id = $objp->rowid; + $companystatic->name = $objp->name; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas=$objp->canvas; + $companystatic->canvas = $objp->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print '".$staticcontrat->LibStatut($obj->statut, 3)."
    '; print ''; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($result); @@ -730,9 +730,9 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) // Ref print ''; print '
    '.$langs->trans("ProposalsOpened").' '.$num.'
    '; - $propalstatic->id=$obj->propalid; - $propalstatic->ref=$obj->ref; - $propalstatic->ref_client=$obj->ref_client; + $propalstatic->id = $obj->propalid; + $propalstatic->ref = $obj->ref; + $propalstatic->ref_client = $obj->ref_client; $propalstatic->total_ht = $obj->total_ht; $propalstatic->total_tva = $obj->total_tva; $propalstatic->total_ttc = $obj->total_ttc; @@ -745,26 +745,26 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print '
    '; print "
    '; - $companystatic->id=$obj->rowid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; print dol_print_date($db->jdate($obj->dp), 'day').''.price($obj->total_ht).'
    '.$langs->trans("XMoreLines", ($num - $nbofloop))."
    '.$langs->trans("Total")."".price($total)." 
    '; print ''; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($result); @@ -834,9 +834,9 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) // Ref print ''; print '
    '.$langs->trans("OrdersOpened").' '.$num.'
    '; - $orderstatic->id=$obj->commandeid; - $orderstatic->ref=$obj->ref; - $orderstatic->ref_client=$obj->ref_client; + $orderstatic->id = $obj->commandeid; + $orderstatic->ref = $obj->ref; + $orderstatic->ref_client = $obj->ref_client; $orderstatic->total_ht = $obj->total_ht; $orderstatic->total_tva = $obj->total_tva; $orderstatic->total_ttc = $obj->total_ttc; @@ -849,26 +849,26 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) //if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir); print '
    '; print "
    '; - $companystatic->id=$obj->rowid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; print dol_print_date($db->jdate($obj->dp), 'day').''.price($obj->total_ht).'
    '.$langs->trans("XMoreLines", ($num - $nbofloop))."
    '.$langs->trans("Total")."".price($total)." 
    '; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - print ''; + print ''; print ''; - print ''; + print ''; - print ''; + print ''; // Errors to - print ''; // Status - print ''; + print ''; // Nb of distinct emails print ''; print ''; @@ -617,36 +617,36 @@ if (! empty($conf->don->enabled) && $user->rights->societe->lire) /** * Social contributions to pay */ -if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { if (!$socid) { - $chargestatic=new ChargeSociales($db); + $chargestatic = new ChargeSociales($db); $sql = "SELECT c.rowid, c.amount, c.date_ech, c.paye,"; - $sql.= " cc.libelle as label,"; - $sql.= " SUM(pc.amount) as sumpaid"; - $sql.= " FROM (".MAIN_DB_PREFIX."c_chargesociales as cc, ".MAIN_DB_PREFIX."chargesociales as c)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = c.rowid"; - $sql.= " WHERE c.fk_type = cc.id"; - $sql.= " AND c.entity IN (".getEntity('tax').')'; - $sql.= " AND c.paye = 0"; + $sql .= " cc.libelle as label,"; + $sql .= " SUM(pc.amount) as sumpaid"; + $sql .= " FROM (".MAIN_DB_PREFIX."c_chargesociales as cc, ".MAIN_DB_PREFIX."chargesociales as c)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = c.rowid"; + $sql .= " WHERE c.fk_type = cc.id"; + $sql .= " AND c.entity IN (".getEntity('tax').')'; + $sql .= " AND c.paye = 0"; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereSocialContributions', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSocialContributions', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY c.rowid, c.amount, c.date_ech, c.paye, cc.libelle"; + $sql .= " GROUP BY c.rowid, c.amount, c.date_ech, c.paye, cc.libelle"; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); print '
    '; print '
    ' . $langs->trans("Ref") . '
    '.$langs->trans("Ref").''; print $form->showrefnav($object, 'id', $linkback); print '
    ' . $langs->trans("MailTitle") . '' . $object->titre . '
    '.$langs->trans("MailTitle").''.$object->titre.'
    ' . $langs->trans("MailFrom") . '' . dol_print_email($object->email_from, 0, 0, 0, 0, 1) . '
    '.$langs->trans("MailFrom").''.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'
    ' . $langs->trans("MailErrorsTo") . '' . dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1); + print '
    '.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1); print '
    ' . $langs->trans("Status") . '' . $object->getLibStatut(4) . '
    '.$langs->trans("Status").''.$object->getLibStatut(4).'
    '; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; $nbemail = ($object->nbemail ? $object->nbemail : '0'); - if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) { + if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) { $text = $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); print $form->textwithpicto($nbemail, $text, 1, 'warning'); } else { @@ -458,7 +458,7 @@ if ($object->fetch($id) >= 0) { // Show email selectors if ($object->statut == 0 && $user->rights->mailing->creer) { - include DOL_DOCUMENT_ROOT . '/core/tpl/advtarget.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/advtarget.tpl.php'; } } diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index f6e27fffaa3..f2754658f37 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -36,11 +36,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("mails"); // Security check -if (! $user->rights->mailing->lire || $user->socid > 0) accessforbidden(); +if (!$user->rights->mailing->lire || $user->socid > 0) accessforbidden(); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -48,23 +48,23 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="email"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "email"; +if (!$sortorder) $sortorder = "ASC"; -$id=GETPOST('id', 'int'); -$rowid=GETPOST('rowid', 'int'); -$action=GETPOST('action', 'aZ09'); -$search_lastname=GETPOST("search_lastname", 'alphanohtml'); -$search_firstname=GETPOST("search_firstname", 'alphanohtml'); -$search_email=GETPOST("search_email", 'alphanohtml'); -$search_other=GETPOST("search_other", 'alphanohtml'); -$search_dest_status=GETPOST('search_dest_status', 'alphanohtml'); +$id = GETPOST('id', 'int'); +$rowid = GETPOST('rowid', 'int'); +$action = GETPOST('action', 'aZ09'); +$search_lastname = GETPOST("search_lastname", 'alphanohtml'); +$search_firstname = GETPOST("search_firstname", 'alphanohtml'); +$search_email = GETPOST("search_email", 'alphanohtml'); +$search_other = GETPOST("search_other", 'alphanohtml'); +$search_dest_status = GETPOST('search_dest_status', 'alphanohtml'); // Search modules dirs $modulesdir = dolGetModulesDirs('/mailings'); $object = new Mailing($db); -$result=$object->fetch($id); +$result = $object->fetch($id); /* @@ -73,8 +73,8 @@ $result=$object->fetch($id); if ($action == 'add') { - $module=GETPOST("module", 'alpha'); - $result=-1; + $module = GETPOST("module", 'alpha'); + $result = -1; foreach ($modulesdir as $dir) { @@ -93,7 +93,7 @@ if ($action == 'add') // Add targets into database $obj = new $classname($db); dol_syslog("Call add_to_target on class ".$classname); - $result=$obj->add_to_target($id); + $result = $obj->add_to_target($id); } } if ($result > 0) @@ -109,7 +109,7 @@ if ($action == 'add') } if ($result < 0) { - setEventMessages($langs->trans("Error").($obj->error?' '.$obj->error:''), null, 'errors'); + setEventMessages($langs->trans("Error").($obj->error ? ' '.$obj->error : ''), null, 'errors'); } } @@ -128,7 +128,7 @@ if (GETPOST('exportcsv', 'int')) { $completefilename = 'targets_emailing'.$object->id.'_'.dol_print_date(dol_now(), 'dayhourlog').'.csv'; header('Content-Type: text/csv'); - header('Content-Disposition: attachment;filename=' . $completefilename); + header('Content-Disposition: attachment;filename='.$completefilename); // List of selected targets $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms,"; @@ -137,7 +137,7 @@ if (GETPOST('exportcsv', 'int')) $sql .= " WHERE mc.fk_mailing=".$object->id; $sql .= $db->order($sortfield, $sortorder); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -145,17 +145,17 @@ if (GETPOST('exportcsv', 'int')) while ($obj = $db->fetch_object($resql)) { - print $obj->rowid . $sep; - print $obj->lastname . $sep; - print $obj->firstname . $sep; - print $obj->email . $sep; - print $obj->other . $sep; - print $obj->date_envoi . $sep; - print $obj->tms . $sep; - print $obj->source_url . $sep; - print $obj->source_id . $sep; - print $obj->source_type . $sep; - print $obj->error_text . $sep; + print $obj->rowid.$sep; + print $obj->lastname.$sep; + print $obj->firstname.$sep; + print $obj->email.$sep; + print $obj->other.$sep; + print $obj->date_envoi.$sep; + print $obj->tms.$sep; + print $obj->source_url.$sep; + print $obj->source_id.$sep; + print $obj->source_type.$sep; + print $obj->error_text.$sep; print "\n"; } @@ -171,11 +171,11 @@ if (GETPOST('exportcsv', 'int')) if ($action == 'delete') { // Ici, rowid indique le destinataire et id le mailing - $sql="DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid; - $resql=$db->query($sql); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid; + $resql = $db->query($sql); if ($resql) { - if (! empty($id)) + if (!empty($id)) { $obj = new MailingTargets($db); $obj->update_nb($id); @@ -195,13 +195,13 @@ if ($action == 'delete') } // 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 +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_lastname=''; - $search_firstname=''; - $search_email=''; - $search_other=''; - $search_dest_status=''; + $search_lastname = ''; + $search_firstname = ''; + $search_email = ''; + $search_other = ''; + $search_dest_status = ''; } @@ -223,16 +223,16 @@ if ($object->fetch($id) >= 0) $linkback = ''.$langs->trans("BackToList").''; - $morehtmlright=''; + $morehtmlright = ''; $nbtry = $nbok = 0; if ($object->statut == 2 || $object->statut == 3) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); - $morehtmlright.=' ('.$nbtry.'/'.$object->nbemail; - if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error"); - $morehtmlright.=')   '; + $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; + if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + $morehtmlright .= ')   '; } dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); @@ -254,22 +254,22 @@ if ($object->fetch($id) >= 0) print '
    '; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; - $nbemail = ($object->nbemail?$object->nbemail:0); + $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { - $text=''; - if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) + $text = ''; + if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) { if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { - $text.=$langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); + $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); } else { - $text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed'); + $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } - if (empty($nbemail)) $nbemail.=' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); @@ -290,12 +290,12 @@ if ($object->fetch($id) >= 0) print '
    '; - $allowaddtarget=($object->statut == 0); + $allowaddtarget = ($object->statut == 0); // Show email selectors if ($allowaddtarget && $user->rights->mailing->creer) { - print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1):''), 'generic'); + print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin ?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), 'generic'); //print ''; print '
    '; @@ -317,22 +317,22 @@ if ($object->fetch($id) >= 0) foreach ($modulesdir as $dir) { - $modulenames=array(); + $modulenames = array(); // Load modules attributes in arrays (name, numero, orders) from dir directory //print $dir."\n
    "; dol_syslog("Scan directory ".$dir." for modules"); - $handle=@opendir($dir); + $handle = @opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') { if (preg_match("/(.*)\.modules\.php$/i", $file, $reg)) { if ($reg[1] == 'example') continue; - $modulenames[]=$reg[1]; + $modulenames[] = $reg[1]; } } } @@ -345,7 +345,7 @@ if ($object->fetch($id) >= 0) $var = true; // Loop on each submodule - foreach($modulenames as $modulename) + foreach ($modulenames as $modulename) { // Loading Class $file = $dir.$modulename.".modules.php"; @@ -355,12 +355,12 @@ if ($object->fetch($id) >= 0) $obj = new $classname($db); // Check dependencies - $qualified=(isset($obj->enabled)?$obj->enabled:1); + $qualified = (isset($obj->enabled) ? $obj->enabled : 1); foreach ($obj->require_module as $key) { - if (! $conf->$key->enabled || (! $user->admin && $obj->require_admin)) + if (!$conf->$key->enabled || (!$user->admin && $obj->require_admin)) { - $qualified=0; + $qualified = 0; //print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif"; break; } @@ -369,7 +369,7 @@ if ($object->fetch($id) >= 0) // Si le module mailing est qualifie if ($qualified) { - $var = ! $var; + $var = !$var; if ($allowaddtarget) { @@ -382,16 +382,16 @@ if ($object->fetch($id) >= 0) } print '
    '; - if (empty($obj->picto)) $obj->picto='generic'; + if (empty($obj->picto)) $obj->picto = 'generic'; print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj), $obj->picto, 'class="valignmiddle pictomodule"'); print ' '; print $obj->getDesc(); print '
    '; try { - $nbofrecipient=$obj->getNbOfRecipients(''); + $nbofrecipient = $obj->getNbOfRecipients(''); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -411,9 +411,9 @@ if ($object->fetch($id) >= 0) if ($allowaddtarget) { try { - $filter=$obj->formFilter(); + $filter = $obj->formFilter(); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -451,11 +451,11 @@ if ($object->fetch($id) >= 0) $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE mc.fk_mailing=".$object->id; - if ($search_lastname) $sql.= natural_search("mc.lastname", $search_lastname); - if ($search_firstname) $sql.= natural_search("mc.firstname", $search_firstname); - if ($search_email) $sql.= natural_search("mc.email", $search_email); - if ($search_other) $sql.= natural_search("mc.other", $search_other); - if ($search_dest_status != '' && $search_dest_status >= -1) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." "; + if ($search_lastname) $sql .= natural_search("mc.lastname", $search_lastname); + if ($search_firstname) $sql .= natural_search("mc.firstname", $search_firstname); + if ($search_email) $sql .= natural_search("mc.email", $search_email); + if ($search_other) $sql .= natural_search("mc.other", $search_other); + if ($search_dest_status != '' && $search_dest_status >= -1) $sql .= " AND mc.statut=".$db->escape($search_dest_status)." "; $sql .= $db->order($sortfield, $sortorder); // Count total nb of records @@ -472,20 +472,20 @@ if ($object->fetch($id) >= 0) } //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets - $sql .= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $param = "&id=".$object->id; //if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($search_lastname) $param.= "&search_lastname=".urlencode($search_lastname); - if ($search_firstname) $param.= "&search_firstname=".urlencode($search_firstname); - if ($search_email) $param.= "&search_email=".urlencode($search_email); - if ($search_other) $param.= "&search_other=".urlencode($search_other); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_lastname) $param .= "&search_lastname=".urlencode($search_lastname); + if ($search_firstname) $param .= "&search_firstname=".urlencode($search_firstname); + if ($search_email) $param .= "&search_email=".urlencode($search_email); + if ($search_other) $param .= "&search_other=".urlencode($search_other); print ''; print ''; @@ -494,11 +494,11 @@ if ($object->fetch($id) >= 0) print ''; print ''; - $morehtmlcenter=''; + $morehtmlcenter = ''; if ($allowaddtarget) { - $morehtmlcenter=''.$langs->trans("ToClearAllRecipientsClickHere").' id.'" class="button reposition">'.$langs->trans("TargetsReset").''; + $morehtmlcenter = ''.$langs->trans("ToClearAllRecipientsClickHere").' id.'" class="button reposition">'.$langs->trans("TargetsReset").''; } - $morehtmlcenter.=' id.'">'.$langs->trans("Download").''; + $morehtmlcenter .= ' id.'">'.$langs->trans("Download").''; print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); @@ -555,12 +555,12 @@ if ($object->fetch($id) >= 0) print ''; // Action column print '
    '; print ''; - if ($page) $param.= "&page=".urlencode($page); + if ($page) $param .= "&page=".urlencode($page); print ''; print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", $param, "", "", $sortfield, $sortorder); @@ -584,10 +584,10 @@ if ($object->fetch($id) >= 0) include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $objectstaticmember=new Adherent($db); - $objectstaticuser=new User($db); - $objectstaticcompany=new Societe($db); - $objectstaticcontact=new Contact($db); + $objectstaticmember = new Adherent($db); + $objectstaticuser = new User($db); + $objectstaticcompany = new Societe($db); + $objectstaticcontact = new Contact($db); while ($i < min($num, $limit)) { @@ -601,7 +601,7 @@ if ($object->fetch($id) >= 0) print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; print ''; - $total_ttc += $obj->total_ttc; + $total_ttc += $obj->total_ttc; $total += $obj->total_ht; - $totalam += $obj->am; + $totalam += $obj->am; $i++; } } else { - $colspan=5; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + $colspan = 5; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''; } print '
    '; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print '
    '; if (empty($obj->source_id) || empty($obj->source_type)) { - print empty($obj->source_url)?'':$obj->source_url; // For backward compatibility + print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility } else { diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 1a15ac2ca64..1dc7a430575 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -25,7 +25,7 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT .'/comm/mailing/class/mailing.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $hookmanager = new HookManager($db); @@ -38,14 +38,14 @@ $langs->loadLangs(array('commercial', 'orders')); // Security check -$result=restrictedArea($user, 'mailing'); +$result = restrictedArea($user, 'mailing'); /* * View */ -$help_url='EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'; +$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'; llxHeader('', 'EMailing', $help_url); print load_fiche_titre($langs->trans("MailingArea")); @@ -77,18 +77,18 @@ print '
    '; print ''; print ''; -$dir=DOL_DOCUMENT_ROOT."/core/modules/mailings"; -$handle=opendir($dir); +$dir = DOL_DOCUMENT_ROOT."/core/modules/mailings"; +$handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') { if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) { - $modulename=$reg[1]; + $modulename = $reg[1]; if ($modulename == 'example') continue; // Loading Class @@ -97,12 +97,12 @@ if (is_resource($handle)) require_once $file; $mailmodule = new $classname($db); - $qualified=1; + $qualified = 1; foreach ($mailmodule->require_module as $key) { - if (! $conf->$key->enabled || (! $user->admin && $mailmodule->require_admin)) + if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) { - $qualified=0; + $qualified = 0; //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; break; } @@ -115,13 +115,13 @@ if (is_resource($handle)) { print ''; - $result=$db->query($sql); + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - while ($i < $num ) + while ($i < $num) { $obj = $db->fetch_object($result); print ''; print ''; print ''; - print ''; + print ''; // Label print ''; - print ''; + print ''; // Type print ''; print ''; // Currency @@ -854,9 +854,9 @@ else print ''; print ''; print ''; @@ -864,15 +864,15 @@ else // Status print ''; print ''; // Country - $object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; - $selectedcode=$object->country_code; - if (isset($_POST["account_country_id"])) $selectedcode=$_POST["account_country_id"]; - elseif (empty($selectedcode)) $selectedcode=$mysoc->country_code; - $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules + $object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id; + $selectedcode = $object->country_code; + if (isset($_POST["account_country_id"])) $selectedcode = $_POST["account_country_id"]; + elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; + $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules print ''; print ''; print ''; // Balance print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Web print ''; - print ''; // Tags-Categories @@ -935,13 +935,13 @@ else print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -973,7 +973,7 @@ else print ''; // Accountancy journal - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print ''; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 5199903b9ff..37400ab25a3 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -32,11 +32,11 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -if (! empty($conf->tax->enabled)) +if (!empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; // L'espace compta/treso doit toujours etre actif car c'est un espace partage @@ -48,21 +48,21 @@ if (! empty($conf->tax->enabled)) // Load translation files required by the page $langs->loadLangs(array('compta', 'bills')); -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) $langs->load("orders"); -$action=GETPOST('action', 'alpha'); -$bid=GETPOST('bid', 'int'); +$action = GETPOST('action', 'alpha'); +$bid = GETPOST('bid', 'int'); // Security check -$socid=''; +$socid = ''; if ($user->socid > 0) { $action = ''; $socid = $user->socid; } -$max=3; +$max = 3; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('invoiceindex')); @@ -76,10 +76,10 @@ $hookmanager->initHooks(array('invoiceindex')); * View */ -$now=dol_now(); +$now = dol_now(); -$facturestatic=new Facture($db); -$facturesupplierstatic=new FactureFournisseur($db); +$facturestatic = new Facture($db); +$facturesupplierstatic = new FactureFournisseur($db); $form = new Form($db); $formfile = new FormFile($db); @@ -93,22 +93,22 @@ print load_fiche_titre($langs->trans("AccountancyTreasuryArea"), '', 'invoicing' print '
    '; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search customer invoices - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { - $listofsearchfields['search_invoice']=array('text'=>'CustomerInvoice'); + $listofsearchfields['search_invoice'] = array('text'=>'CustomerInvoice'); } // Search supplier invoices - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { - $listofsearchfields['search_supplier_invoice']=array('text'=>'SupplierInvoice'); + $listofsearchfields['search_supplier_invoice'] = array('text'=>'SupplierInvoice'); } - if (! empty($conf->don->enabled) && $user->rights->don->lire) + if (!empty($conf->don->enabled) && $user->rights->don->lire) { $langs->load("donations"); - $listofsearchfields['search_donation']=array('text'=>'Donation'); + $listofsearchfields['search_donation'] = array('text'=>'Donation'); } if (count($listofsearchfields)) @@ -117,8 +117,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; print '
    '; print '
    '.$langs->trans("TargetsStatistics").'
    '.img_object('', $mailmodule->picto).' '.$obj->label.''.$obj->nb.''; @@ -154,12 +154,12 @@ print '
    '; /* * List of last emailings */ -$limit=10; +$limit = 10; $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat"; -$sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; -$sql.= " ORDER BY m.date_creat DESC"; -$sql.= " LIMIT ".$limit; -$result=$db->query($sql); +$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 ''; @@ -174,10 +174,10 @@ if ($result) { { $i = 0; - while ($i < $num ) + while ($i < $num) { $obj = $db->fetch_object($result); - $mailstatic=new Mailing($db); + $mailstatic = new Mailing($db); $mailstatic->id = $obj->rowid; $mailstatic->ref = $obj->rowid; @@ -185,7 +185,7 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; $i++; diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index 82bf49261a1..32fe301489e 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -60,13 +60,13 @@ if ($_POST["action"] == 'setpricelevel') llxHeader(); -$userstatic=new User($db); +$userstatic = new User($db); if ($_socid > 0) { // On recupere les donnees societes par l'objet $objsoc = new Societe($db); - $objsoc->id=$_socid; + $objsoc->id = $_socid; $objsoc->fetch($_socid, $to); if ($errmesg) @@ -81,9 +81,9 @@ if ($_socid > 0) $head = societe_prepare_head($objsoc); - $tabchoice=''; - if ($objsoc->client == 1) $tabchoice='customer'; - if ($objsoc->client == 2) $tabchoice='prospect'; + $tabchoice = ''; + if ($objsoc->client == 1) $tabchoice = 'customer'; + if ($objsoc->client == 2) $tabchoice = 'prospect'; print ''; print ''; @@ -99,14 +99,14 @@ if ($_socid > 0) print ''; print "\n"; print ""; } @@ -235,20 +235,20 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) * */ $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE s.fk_stcomm = 1"; -$sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " ORDER BY s.tms ASC"; -$sql.= $db->plimit(15, 0); +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE s.fk_stcomm = 1"; +$sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " ORDER BY s.tms ASC"; +$sql .= $db->plimit(15, 0); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num > 0 ) + if ($num > 0) { print '
    '.$mailstatic->getNomUrl(1).''.dol_trunc($obj->titre, 38).''.dol_print_date($db->jdate($obj->date_creat), 'day').''.($obj->nbemail?$obj->nbemail:"0").''.($obj->nbemail ? $obj->nbemail : "0").''.$mailstatic->LibStatut($obj->statut, 5).'
    '; print $langs->trans("NewValue").''; print ''; @@ -129,11 +129,11 @@ if ($_socid > 0) */ $sql = "SELECT rc.rowid,rc.price_level, rc.datec as dc, u.rowid as uid, u.login"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_prices as rc, ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE rc.fk_soc =". $objsoc->id; + $sql .= " WHERE rc.fk_soc =".$objsoc->id; $sql .= " AND u.rowid = rc.fk_user_author"; $sql .= " ORDER BY rc.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print ''; @@ -143,18 +143,18 @@ if ($_socid > 0) print ''; print ''; print ''; - $i = 0 ; + $i = 0; $num = $db->num_rows($resql); - while ($i < $num ) + while ($i < $num) { $obj = $db->fetch_object($resql); print ''; print ''; print ''; - $userstatic->id=$obj->uid; - $userstatic->lastname=$obj->login; + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->login; print ''; print ''; $i++; diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 459b6637230..bfd7bdb7baf 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -26,7 +26,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT .'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $hookmanager = new HookManager($db); @@ -37,8 +37,8 @@ $hookmanager->initHooks(array('proposalindex')); $langs->loadLangs(array('propal', 'companies')); // Security check -$socid=GETPOST('socid', 'int'); -if (isset($user->socid) && $user->socid > 0) +$socid = GETPOST('socid', 'int'); +if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; @@ -49,12 +49,12 @@ $result = restrictedArea($user, 'propal'); /* * View */ -$now=dol_now(); -$propalstatic=new Propal($db); -$companystatic=new Societe($db); +$now = dol_now(); +$propalstatic = new Propal($db); +$companystatic = new Societe($db); $form = new Form($db); $formfile = new FormFile($db); -$help_url="EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos"; +$help_url = "EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos"; llxHeader("", $langs->trans("ProspectionArea"), $help_url); @@ -65,7 +65,7 @@ print load_fiche_titre($langs->trans("ProspectionArea"), '', 'commercial'); print '
    '; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { print ''; print '
    '; @@ -83,25 +83,25 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele */ $sql = "SELECT count(p.rowid), p.fk_statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."propal as p"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE p.fk_soc = s.rowid"; -$sql.= " AND p.entity IN (".getEntity('propal').")"; -if ($user->socid) $sql.=' AND p.fk_soc = '.$user->socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " AND p.fk_statut IN (0,1,2,3,4)"; -$sql.= " GROUP BY p.fk_statut"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= ", ".MAIN_DB_PREFIX."propal as p"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE p.fk_soc = s.rowid"; +$sql .= " AND p.entity IN (".getEntity('propal').")"; +if ($user->socid) $sql .= ' AND p.fk_soc = '.$user->socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " AND p.fk_statut IN (0,1,2,3,4)"; +$sql .= " GROUP BY p.fk_statut"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - $total=0; - $totalinprocess=0; - $dataseries=array(); - $vals=array(); + $total = 0; + $totalinprocess = 0; + $dataseries = array(); + $vals = array(); // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) while ($i < $num) { @@ -110,10 +110,10 @@ if ($resql) { //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) { - $vals[$row[1]]=$row[0]; - $totalinprocess+=$row[0]; + $vals[$row[1]] = $row[0]; + $totalinprocess += $row[0]; } - $total+=$row[0]; + $total += $row[0]; } $i++; } @@ -122,15 +122,15 @@ if ($resql) print '
    '; print '
    '.$langs->trans("PriceLevel").''.$langs->trans("User").'
    '.dol_print_date($db->jdate($obj->dc), "dayhour").''.$obj->price_level.' '.$userstatic->getNomUrl(1).'
    '; print ''."\n"; - $listofstatus=array(0,1,2,3,4); + $listofstatus = array(0, 1, 2, 3, 4); foreach ($listofstatus as $status) { - $dataseries[]=array($propalstatic->LibStatut($status, 1), (isset($vals[$status])?(int) $vals[$status]:0)); - if (! $conf->use_javascript_ajax) + $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); + if (!$conf->use_javascript_ajax) { print ''; print ''; - print ''; + print ''; print "\n"; } } @@ -146,7 +146,7 @@ if ($resql) $dolgraph->SetType(array('pie')); $dolgraph->setWidth('100%'); $dolgraph->draw('idgraphthirdparties'); - print $dolgraph->show($total?0:1); + print $dolgraph->show($total ? 0 : 1); print ''; } @@ -164,19 +164,19 @@ else /* * Draft proposals */ -if (! empty($conf->propal->enabled)) +if (!empty($conf->propal->enabled)) { $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('propal').")"; - $sql.= " AND c.fk_statut = 0"; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('propal').")"; + $sql .= " AND c.fk_statut = 0"; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -189,20 +189,20 @@ if (! empty($conf->propal->enabled)) print ''; $i = 0; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($resql); print ''; - $propalstatic->id=$obj->rowid; - $propalstatic->ref=$obj->ref; + $propalstatic->id = $obj->rowid; + $propalstatic->ref = $obj->ref; print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->socname; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->socname; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; print ''; print ''; @@ -212,7 +212,7 @@ if (! empty($conf->propal->enabled)) { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -227,26 +227,26 @@ if (! empty($conf->propal->enabled)) print '
    '; -$max=5; +$max = 5; /* * Last modified proposals */ $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; -$sql.= " date_cloture as datec"; -$sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; -$sql.= ", ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity IN (".getEntity('propal').")"; +$sql .= " date_cloture as datec"; +$sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; +$sql .= ", ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE c.fk_soc = s.rowid"; +$sql .= " AND c.entity IN (".getEntity('propal').")"; //$sql.= " AND c.fk_statut > 2"; if ($socid) $sql .= " AND c.fk_soc = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " ORDER BY c.tms DESC"; -$sql.= $db->plimit($max, 0); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " ORDER BY c.tms DESC"; +$sql .= $db->plimit($max, 0); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { print '
    '; @@ -265,8 +265,8 @@ if ($resql) print '
    '; print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->socname; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->socname; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; print ''; print ''; @@ -307,25 +307,25 @@ else dol_print_error($db); /* * Opened proposals */ -if (! empty($conf->propal->enabled) && $user->rights->propale->lire) +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $langs->load("propal"); - $now=dol_now(); + $now = dol_now(); $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; - $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - $sql.= " AND p.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY p.rowid DESC"; + $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " AND p.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY p.rowid DESC"; - $result=$db->query($sql); + $result = $db->query($sql); if ($result) { $total = 0; @@ -337,7 +337,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) print '
    '.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'
    '.$propalstatic->LibStatut($status, 0).''.(isset($vals[$status])?$vals[$status]:0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
    '.$langs->trans("DraftPropals").' '.$num.'
    '.$propalstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer', 24).'
    '.$langs->trans("XMoreLines", ($num - $nbofloop))."
    '.$langs->trans("Total").''.price($total)."
    '; - $propalstatic->id=$obj->rowid; - $propalstatic->ref=$obj->ref; + $propalstatic->id = $obj->rowid; + $propalstatic->ref = $obj->ref; print ''; print ''; print '
    '; @@ -278,18 +278,18 @@ if ($resql) print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print '
    '; print '
    '.$companystatic->getNomUrl(1, 'customer').''.dol_print_date($db->jdate($obj->datec), 'day').'
    '; print ''; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($result); @@ -347,8 +347,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) // Ref print '"; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->socname; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->socname; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; print ''."\n"; print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index b2cc1d8bbda..4bdcbae59a8 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -41,7 +41,7 @@ if ($user->socid > 0) * View */ -$companystatic=new Societe($db); +$companystatic = new Societe($db); llxHeader(); @@ -52,9 +52,9 @@ print load_fiche_titre($langs->trans("ProspectionArea")); print '
    '; -if (! empty($conf->propal->enabled)) +if (!empty($conf->propal->enabled)) { - $var=false; + $var = false; print ''; print ''; print '
    '.$langs->trans("ProposalsOpened").' '.$num.'
    '; - $propalstatic->id=$obj->propalid; - $propalstatic->ref=$obj->ref; + $propalstatic->id = $obj->propalid; + $propalstatic->ref = $obj->ref; print ''; print ''; print '
    '; @@ -358,18 +358,18 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print '
    '; print "
    '.$companystatic->getNomUrl(1, 'customer', 44).''; @@ -384,7 +384,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { print '
    '.$langs->trans("XMoreLines", ($num - $nbofloop))."
    '.$langs->trans("Total")."".price($total)." 
    '; @@ -72,22 +72,22 @@ if (! empty($conf->propal->enabled)) */ $sql = "SELECT count(*) as cc, st.libelle, st.id"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st "; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE s.fk_stcomm = st.id"; -$sql.= " AND s.client IN (2, 3)"; -$sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " GROUP BY st.id"; -$sql.= " ORDER BY st.id"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st "; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE s.fk_stcomm = st.id"; +$sql .= " AND s.client IN (2, 3)"; +$sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " GROUP BY st.id"; +$sql .= " ORDER BY st.id"; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num > 0 ) + if ($num > 0) { print '
    '; print ''; @@ -111,21 +111,21 @@ if ($resql) /* * Liste des propal brouillons */ -if (! empty($conf->propal->enabled) && $user->rights->propale->lire) +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT p.rowid, p.ref, p.price, s.nom as sname"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_statut = 0"; - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_statut = 0"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $total=0; + $total = 0; $num = $db->num_rows($resql); $i = 0; if ($num > 0) @@ -146,7 +146,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $i++; $total += $obj->price; } - if ($total>0) { + if ($total > 0) { print '"; } print "
    '.$langs->trans("Total")."".price($total)."

    "; @@ -163,29 +163,29 @@ print '
    '; /* * Actions commerciales a faire */ -if (! empty($conf->agenda->enabled)) show_array_actions_to_do(10); +if (!empty($conf->agenda->enabled)) show_array_actions_to_do(10); /* * Dernieres propales ouvertes */ -if (! empty($conf->propal->enabled) && $user->rights->propale->lire) +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas,"; - $sql.= " p.rowid as propalid, p.total as total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; - $sql.= ", ".MAIN_DB_PREFIX."c_propalst as c"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.fk_statut = c.id"; - $sql.= " AND p.fk_statut = 1"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY p.rowid DESC"; - $sql.= $db->plimit(5, 0); + $sql .= " p.rowid as propalid, p.total as total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + $sql .= ", ".MAIN_DB_PREFIX."c_propalst as c"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_soc = s.rowid"; + $sql .= " AND p.fk_statut = c.id"; + $sql .= " AND p.fk_statut = 1"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY p.rowid DESC"; + $sql .= $db->plimit(5, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $total = 0; @@ -205,10 +205,10 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) print img_object($langs->trans("ShowPropal"), "propal").' '.$obj->ref.'
    "; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, '', 44); print ""; @@ -217,7 +217,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $i++; $total += $obj->price; } - if ($total>0) + if ($total > 0) { print '
    '.$langs->trans("Total")."".price($total)."
    '; print ''; @@ -258,10 +258,10 @@ if ($resql) $obj = $db->fetch_object($resql); print ''; $i++; diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 229fca58d18..a4f3fb0503b 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -29,9 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'orders', 'bills')); -$id=GETPOST("id", 'int'); +$id = GETPOST("id", 'int'); -$socid = GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('socid', 'int'); +$socid = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); // Security check if ($user->socid > 0) { @@ -45,7 +45,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); * Actions */ -if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) +if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -58,15 +58,15 @@ if (GETPOST('action', 'aZ09') == 'setremise') $discount_type = GETPOST('discount_type', 'int'); - if(! empty($discount_type)) { - $result=$object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note"), $user); + if (!empty($discount_type)) { + $result = $object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note"), $user); } else { - $result=$object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note"), $user); + $result = $object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note"), $user); } if ($result > 0) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -88,7 +88,7 @@ if (GETPOST('action', 'aZ09') == 'setremise') * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); @@ -116,13 +116,13 @@ if ($socid > 0) dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"), -1, 'company'); - dol_banner_tab($object, 'socid', '', ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
    '; print '
    '; - if (! $isCustomer && ! $isSupplier) { + if (!$isCustomer && !$isSupplier) { print '

    '.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

    '; dol_fiche_end(); @@ -176,7 +176,7 @@ if ($socid > 0) print ' '; } if ($isSupplier) { - print ' '; + print ' '; } print ''; } @@ -197,7 +197,7 @@ if ($socid > 0) print '
    '; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -208,8 +208,8 @@ if ($socid > 0) print '
    '; - if($isCustomer) { - if($isSupplier) { + if ($isCustomer) { + if ($isSupplier) { print '
    '; print '
    '; print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); @@ -218,15 +218,15 @@ if ($socid > 0) /* * List log of all customer percent discounts */ - $sql = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,"; - $sql.= " u.login, u.rowid as user_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND u.rowid = rc.fk_user_author"; - $sql.= " ORDER BY rc.datec DESC"; + $sql = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,"; + $sql .= " u.login, u.rowid as user_id"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND u.rowid = rc.fk_user_author"; + $sql .= " ORDER BY rc.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print '
    '.$langs->trans("ProspectToContact").'
    '; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'prospect', 44); print '
    '; @@ -266,8 +266,8 @@ if ($socid > 0) } } - if($isSupplier) { - if($isCustomer) { + if ($isSupplier) { + if ($isCustomer) { print ''; // class="fichehalfleft" print '
    '; print '
    '; @@ -277,15 +277,15 @@ if ($socid > 0) /* * List log of all supplier percent discounts */ - $sql = "SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,"; - $sql.= " u.login, u.rowid as user_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_supplier as rc, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND u.rowid = rc.fk_user_author"; - $sql.= " ORDER BY rc.datec DESC"; + $sql = "SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,"; + $sql .= " u.login, u.rowid as user_id"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_supplier as rc, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND u.rowid = rc.fk_user_author"; + $sql .= " ORDER BY rc.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print '
    '; @@ -324,7 +324,7 @@ if ($socid > 0) dol_print_error($db); } - if($isCustomer) { + if ($isCustomer) { print ''; // class="ficheaddleft" print ''; // class="fichehalfright" print ''; // class="fichecenter" diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index b3d3140db09..ac79c1fe0a7 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -33,13 +33,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; // Load translation files required by the page $langs->loadLangs(array('orders', 'bills', 'companies')); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); -$action=GETPOST('action', 'alpha'); -$backtopage=GETPOST('backtopage', 'alpha'); +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); // Security check -$socid = GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('socid', 'int'); +$socid = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); if ($user->socid > 0) { $socid = $user->socid; @@ -50,7 +50,7 @@ if ($user->socid > 0) * Actions */ -if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) +if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -61,82 +61,82 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) - $amount_ttc_1=GETPOST('amount_ttc_1'); - $amount_ttc_2=GETPOST('amount_ttc_2'); + $amount_ttc_1 = GETPOST('amount_ttc_1'); + $amount_ttc_2 = GETPOST('amount_ttc_2'); - $error=0; - $remid=GETPOST("remid")?GETPOST("remid"):0; - $discount=new DiscountAbsolute($db); - $res=$discount->fetch($remid); - if (! $res > 0) + $error = 0; + $remid = GETPOST("remid") ?GETPOST("remid") : 0; + $discount = new DiscountAbsolute($db); + $res = $discount->fetch($remid); + if (!$res > 0) { $error++; setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors'); } - if (! $error && price2num($amount_ttc_1+$amount_ttc_2) != $discount->amount_ttc) + if (!$error && price2num($amount_ttc_1 + $amount_ttc_2) != $discount->amount_ttc) { $error++; setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors'); } - if (! $error && $discount->fk_facture_line) + if (!$error && $discount->fk_facture_line) { $error++; setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors'); } - if (! $error) + if (!$error) { - $newdiscount1=new DiscountAbsolute($db); - $newdiscount2=new DiscountAbsolute($db); - $newdiscount1->fk_facture_source=$discount->fk_facture_source; - $newdiscount2->fk_facture_source=$discount->fk_facture_source; - $newdiscount1->fk_facture=$discount->fk_facture; - $newdiscount2->fk_facture=$discount->fk_facture; - $newdiscount1->fk_facture_line=$discount->fk_facture_line; - $newdiscount2->fk_facture_line=$discount->fk_facture_line; - $newdiscount1->fk_invoice_supplier_source=$discount->fk_invoice_supplier_source; - $newdiscount2->fk_invoice_supplier_source=$discount->fk_invoice_supplier_source; - $newdiscount1->fk_invoice_supplier=$discount->fk_invoice_supplier; - $newdiscount2->fk_invoice_supplier=$discount->fk_invoice_supplier; - $newdiscount1->fk_invoice_supplier_line=$discount->fk_invoice_supplier_line; - $newdiscount2->fk_invoice_supplier_line=$discount->fk_invoice_supplier_line; + $newdiscount1 = new DiscountAbsolute($db); + $newdiscount2 = new DiscountAbsolute($db); + $newdiscount1->fk_facture_source = $discount->fk_facture_source; + $newdiscount2->fk_facture_source = $discount->fk_facture_source; + $newdiscount1->fk_facture = $discount->fk_facture; + $newdiscount2->fk_facture = $discount->fk_facture; + $newdiscount1->fk_facture_line = $discount->fk_facture_line; + $newdiscount2->fk_facture_line = $discount->fk_facture_line; + $newdiscount1->fk_invoice_supplier_source = $discount->fk_invoice_supplier_source; + $newdiscount2->fk_invoice_supplier_source = $discount->fk_invoice_supplier_source; + $newdiscount1->fk_invoice_supplier = $discount->fk_invoice_supplier; + $newdiscount2->fk_invoice_supplier = $discount->fk_invoice_supplier; + $newdiscount1->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line; + $newdiscount2->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line; if ($discount->description == '(CREDIT_NOTE)' || $discount->description == '(DEPOSIT)') { - $newdiscount1->description=$discount->description; - $newdiscount2->description=$discount->description; + $newdiscount1->description = $discount->description; + $newdiscount2->description = $discount->description; } else { - $newdiscount1->description=$discount->description.' (1)'; - $newdiscount2->description=$discount->description.' (2)'; + $newdiscount1->description = $discount->description.' (1)'; + $newdiscount2->description = $discount->description.' (2)'; } - $newdiscount1->fk_user=$discount->fk_user; - $newdiscount2->fk_user=$discount->fk_user; - $newdiscount1->fk_soc=$discount->fk_soc; - $newdiscount2->fk_soc=$discount->fk_soc; - $newdiscount1->discount_type=$discount->discount_type; - $newdiscount2->discount_type=$discount->discount_type; - $newdiscount1->datec=$discount->datec; - $newdiscount2->datec=$discount->datec; - $newdiscount1->tva_tx=$discount->tva_tx; - $newdiscount2->tva_tx=$discount->tva_tx; - $newdiscount1->amount_ttc=$_POST["amount_ttc_1"]; - $newdiscount2->amount_ttc=price2num($discount->amount_ttc-$newdiscount1->amount_ttc); - $newdiscount1->amount_ht=price2num($newdiscount1->amount_ttc/(1+$newdiscount1->tva_tx/100), 'MT'); - $newdiscount2->amount_ht=price2num($newdiscount2->amount_ttc/(1+$newdiscount2->tva_tx/100), 'MT'); - $newdiscount1->amount_tva=price2num($newdiscount1->amount_ttc-$newdiscount1->amount_ht); - $newdiscount2->amount_tva=price2num($newdiscount2->amount_ttc-$newdiscount2->amount_ht); + $newdiscount1->fk_user = $discount->fk_user; + $newdiscount2->fk_user = $discount->fk_user; + $newdiscount1->fk_soc = $discount->fk_soc; + $newdiscount2->fk_soc = $discount->fk_soc; + $newdiscount1->discount_type = $discount->discount_type; + $newdiscount2->discount_type = $discount->discount_type; + $newdiscount1->datec = $discount->datec; + $newdiscount2->datec = $discount->datec; + $newdiscount1->tva_tx = $discount->tva_tx; + $newdiscount2->tva_tx = $discount->tva_tx; + $newdiscount1->amount_ttc = $_POST["amount_ttc_1"]; + $newdiscount2->amount_ttc = price2num($discount->amount_ttc - $newdiscount1->amount_ttc); + $newdiscount1->amount_ht = price2num($newdiscount1->amount_ttc / (1 + $newdiscount1->tva_tx / 100), 'MT'); + $newdiscount2->amount_ht = price2num($newdiscount2->amount_ttc / (1 + $newdiscount2->tva_tx / 100), 'MT'); + $newdiscount1->amount_tva = price2num($newdiscount1->amount_ttc - $newdiscount1->amount_ht); + $newdiscount2->amount_tva = price2num($newdiscount2->amount_ttc - $newdiscount2->amount_ht); $db->begin(); - $discount->fk_facture_source=0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source + $discount->fk_facture_source = 0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_invoice_supplier_source - $discount->fk_invoice_supplier_source=0; - $res=$discount->delete($user); - $newid1=$newdiscount1->create($user); - $newid2=$newdiscount2->create($user); + $discount->fk_invoice_supplier_source = 0; + $res = $discount->delete($user); + $newid1 = $newdiscount1->create($user); + $newid2 = $newdiscount2->create($user); if ($res > 0 && $newid1 > 0 && $newid2 > 0) { $db->commit(); - header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage?'&backtopage='.urlencode($backtopage):'')); // To avoid pb whith back + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage ? '&backtopage='.urlencode($backtopage) : '')); // To avoid pb whith back exit; } else @@ -151,29 +151,29 @@ if ($action == 'setremise' && $user->rights->societe->creer) //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) - $amount_ht=GETPOST('amount_ht'); - $desc=GETPOST('desc', 'alpha'); - $tva_tx=GETPOST('tva_tx', 'alpha'); - $discount_type=! empty($_POST['discount_type'])?GETPOST('discount_type', 'alpha'):0; + $amount_ht = GETPOST('amount_ht'); + $desc = GETPOST('desc', 'alpha'); + $tva_tx = GETPOST('tva_tx', 'alpha'); + $discount_type = !empty($_POST['discount_type']) ?GETPOST('discount_type', 'alpha') : 0; if (price2num($amount_ht) > 0) { - $error=0; + $error = 0; if (empty($desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReasonDiscount")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $soc = new Societe($db); $soc->fetch($id); - $discountid=$soc->set_remise_except($amount_ht, $user, $desc, $tva_tx, $discount_type); + $discountid = $soc->set_remise_except($amount_ht, $user, $desc, $tva_tx, $discount_type); if ($discountid > 0) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage.'&discountid='.$discountid); exit; @@ -197,7 +197,7 @@ if ($action == 'setremise' && $user->rights->societe->creer) } } -if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm")=='yes') +if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes') { //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) @@ -205,12 +205,12 @@ if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm")=='yes') $db->begin(); $discount = new DiscountAbsolute($db); - $result=$discount->fetch(GETPOST("remid")); - $result=$discount->delete($user); + $result = $discount->fetch(GETPOST("remid")); + $result = $discount->delete($user); if ($result > 0) { $db->commit(); - header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back exit; } else @@ -225,9 +225,9 @@ if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm")=='yes') * View */ -$form=new Form($db); -$facturestatic=new Facture($db); -$facturefournstatic=new FactureFournisseur($db); +$form = new Form($db); +$facturestatic = new Facture($db); +$facturefournstatic = new FactureFournisseur($db); llxHeader('', $langs->trans("GlobalDiscount")); @@ -252,13 +252,13 @@ if ($socid > 0) dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object, 'socid', '', ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
    '; print '
    '; - if(! $isCustomer && ! $isSupplier) { + if (!$isCustomer && !$isSupplier) { print '

    '.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

    '; dol_fiche_end(); @@ -273,21 +273,21 @@ if ($socid > 0) print '
    '; - if($isCustomer) { // Calcul avoirs client en cours - $remise_all=$remise_user=0; + if ($isCustomer) { // Calcul avoirs client en cours + $remise_all = $remise_user = 0; $sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND discount_type = 0"; // Exclude supplier discounts - $sql.= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)"; - $sql.= " GROUP BY rc.fk_user"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND discount_type = 0"; // Exclude supplier discounts + $sql .= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)"; + $sql .= " GROUP BY rc.fk_user"; + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - $remise_all+=$obj->amount; - if ($obj->fk_user == $user->id) $remise_user+=$obj->amount; + $remise_all += $obj->amount; + if ($obj->fk_user == $user->id) $remise_user += $obj->amount; } else { @@ -297,29 +297,29 @@ if ($socid > 0) print ''; print ''; - if (! empty($user->fk_soc)) // No need to show this for external users + if (!empty($user->fk_soc)) // No need to show this for external users { print ''; print ''; } } - if($isSupplier) { + if ($isSupplier) { // Calcul avoirs fournisseur en cours - $remise_all=$remise_user=0; + $remise_all = $remise_user = 0; $sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND discount_type = 1"; // Exclude customer discounts - $sql.= " AND (fk_invoice_supplier_line IS NULL AND fk_invoice_supplier IS NULL)"; - $sql.= " GROUP BY rc.fk_user"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND discount_type = 1"; // Exclude customer discounts + $sql .= " AND (fk_invoice_supplier_line IS NULL AND fk_invoice_supplier IS NULL)"; + $sql .= " GROUP BY rc.fk_user"; + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - $remise_all+=$obj->amount; - if ($obj->fk_user == $user->id) $remise_user+=$obj->amount; + $remise_all += $obj->amount; + if ($obj->fk_user == $user->id) $remise_user += $obj->amount; } else { @@ -329,7 +329,7 @@ if ($socid > 0) print ''; print ''; - if (! empty($user->fk_soc)) // No need to show this for external users + if (!empty($user->fk_soc)) // No need to show this for external users { print ''; print ''; @@ -348,16 +348,16 @@ if ($socid > 0) print '
    '; - if($isCustomer && ! $isSupplier) { + if ($isCustomer && !$isSupplier) { print ''; } - if(! $isCustomer && $isSupplier) { + if (!$isCustomer && $isSupplier) { print ''; } print '
    '.$langs->trans("CustomerAbsoluteDiscountAllUsers").''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
    '.$langs->trans("CustomerAbsoluteDiscountMy").''.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
    '.$langs->trans("SupplierAbsoluteDiscountAllUsers").''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
    '.$langs->trans("SupplierAbsoluteDiscountMy").''.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
    '; - if($isCustomer && $isSupplier) { + if ($isCustomer && $isSupplier) { print ''; print ''; - print ''; + print ''; print ''; // Show fields of bank account @@ -500,32 +500,32 @@ if ($action == 'create') } print ''; - print ''; + print ''; print ''; } $ibankey = FormBank::getIBANLabel($object); - $bickey="BICNumber"; - if ($object->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($object->getCountryCode() == 'IN') $bickey = "SWIFT"; // IBAN print ''; - print ''; + print ''; print ''; - print ''; + print ''; print '"; print ''; - print ''; print '"; print '
    '.$langs->trans('DiscountType').' '; print '   '; @@ -382,7 +382,7 @@ if ($socid > 0) { print '
    '; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -407,44 +407,44 @@ if ($socid > 0) print load_fiche_titre($langs->trans("DiscountStillRemaining")); - if($isCustomer) { - if($isSupplier) { + if ($isCustomer) { + if ($isSupplier) { print '
    '; print '
    '; print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); } $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; - $sql.= " rc.datec as dc, rc.description,"; - $sql.= " rc.fk_facture_source,"; - $sql.= " u.login, u.rowid as user_id,"; - $sql.= " fa.ref as ref, fa.type as type"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND u.rowid = rc.fk_user"; - $sql.= " AND rc.discount_type = 0"; // Eliminate supplier discounts - $sql.= " AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)"; - $sql.= " ORDER BY rc.datec DESC"; + $sql .= " rc.datec as dc, rc.description,"; + $sql .= " rc.fk_facture_source,"; + $sql .= " u.login, u.rowid as user_id,"; + $sql .= " fa.ref as ref, fa.type as type"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND u.rowid = rc.fk_user"; + $sql .= " AND rc.discount_type = 0"; // Eliminate supplier discounts + $sql .= " AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)"; + $sql .= " ORDER BY rc.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print '
    '; print ''; print ''; - print ''; // Need 120+ for format with AM/PM + print ''; // Need 120+ for format with AM/PM print ''; print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -452,7 +452,7 @@ if ($socid > 0) print ''; print ''; - $showconfirminfo=array(); + $showconfirminfo = array(); $i = 0; $num = $db->num_rows($resql); @@ -467,27 +467,27 @@ if ($socid > 0) if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) { print ''; } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) { print ''; } @@ -499,13 +499,13 @@ if ($socid > 0) } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -515,18 +515,18 @@ if ($socid > 0) if ($user->rights->societe->creer || $user->rights->facture->creer) { print ''; } else print ''; print ''; - if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid) + if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) { - $showconfirminfo['rowid']=$obj->rowid; - $showconfirminfo['amount_ttc']=$obj->amount_ttc; + $showconfirminfo['rowid'] = $obj->rowid; + $showconfirminfo['amount_ttc'] = $obj->amount_ttc; } $i++; } @@ -541,15 +541,15 @@ if ($socid > 0) if (count($showconfirminfo)) { - $amount1=price2num($showconfirminfo['amount_ttc']/2, 'MT'); - $amount2=($showconfirminfo['amount_ttc']-$amount1); - $formquestion=array( + $amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT'); + $amount2 = ($showconfirminfo['amount_ttc'] - $amount1); + $formquestion = array( 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') ); $langs->load("dict"); - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage?'&backtopage='.urlencode($backtopage):''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); } } else @@ -558,8 +558,8 @@ if ($socid > 0) } } - if($isSupplier) { - if($isCustomer) { + if ($isSupplier) { + if ($isCustomer) { print ''; // class="fichehalfleft" print '
    '; print '
    '; @@ -570,36 +570,36 @@ if ($socid > 0) * Liste remises fixes fournisseur restant en cours (= liees a aucune facture ni ligne de facture) */ $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; - $sql.= " rc.datec as dc, rc.description,"; - $sql.= " rc.fk_invoice_supplier_source,"; - $sql.= " u.login, u.rowid as user_id,"; - $sql.= " fa.ref, fa.type as type"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND u.rowid = rc.fk_user"; - $sql.= " AND rc.discount_type = 1"; // Eliminate customer discounts - $sql.= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; - $sql.= " ORDER BY rc.datec DESC"; + $sql .= " rc.datec as dc, rc.description,"; + $sql .= " rc.fk_invoice_supplier_source,"; + $sql .= " u.login, u.rowid as user_id,"; + $sql .= " fa.ref, fa.type as type"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND u.rowid = rc.fk_user"; + $sql .= " AND rc.discount_type = 1"; // Eliminate customer discounts + $sql .= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; + $sql .= " ORDER BY rc.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print '
    '; print '
    '.$langs->trans("Date").''.$langs->trans("Date").''.$langs->trans("ReasonDiscount").''.$langs->trans("ConsumedBy").''.$langs->trans("AmountHT").''.$langs->trans("MulticurrencyAmountHT").''.$langs->trans("VATRate").''.$langs->trans("AmountTTC").''.$langs->trans("MulticurrencyAmountTTC").' 
    '; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $obj->description).' '.$facturestatic->getNomURl(1); print ''.$langs->trans("NotConsumed").''.price($obj->amount_ht).''.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.price($obj->amount_ttc).''.price($obj->multicurrency_amount_ttc).''; - print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; //print '   '; - print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_delete($langs->trans("RemoveDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ' 
    '; print ''; - print ''; // Need 120+ for format with AM/PM + print ''; // Need 120+ for format with AM/PM print ''; print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -607,7 +607,7 @@ if ($socid > 0) print ''; print ''; - $showconfirminfo=array(); + $showconfirminfo = array(); $i = 0; $num = $db->num_rows($resql); @@ -622,27 +622,27 @@ if ($socid > 0) if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) { print ''; } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; } elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) { print ''; } @@ -654,13 +654,13 @@ if ($socid > 0) } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -670,18 +670,18 @@ if ($socid > 0) if ($user->rights->societe->creer || $user->rights->facture->creer) { print ''; } else print ''; print ''; - if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid) + if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) { - $showconfirminfo['rowid']=$obj->rowid; - $showconfirminfo['amount_ttc']=$obj->amount_ttc; + $showconfirminfo['rowid'] = $obj->rowid; + $showconfirminfo['amount_ttc'] = $obj->amount_ttc; } $i++; } @@ -696,15 +696,15 @@ if ($socid > 0) if (count($showconfirminfo)) { - $amount1=price2num($showconfirminfo['amount_ttc']/2, 'MT'); - $amount2=($showconfirminfo['amount_ttc']-$amount1); - $formquestion=array( + $amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT'); + $amount2 = ($showconfirminfo['amount_ttc'] - $amount1); + $formquestion = array( 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') ); $langs->load("dict"); - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage?'&backtopage='.urlencode($backtopage):''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); } } else @@ -727,8 +727,8 @@ if ($socid > 0) print load_fiche_titre($langs->trans("DiscountAlreadyCounted")); - if($isCustomer) { - if($isSupplier) { + if ($isCustomer) { + if ($isSupplier) { print '
    '; print '
    '; print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); @@ -736,59 +736,59 @@ if ($socid > 0) // Discount linked to invoice lines $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; - $sql.= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; - $sql.= " rc.fk_facture_source,"; - $sql.= " u.login, u.rowid as user_id,"; - $sql.= " f.rowid, f.ref,"; - $sql.= " fa.ref as ref, fa.type as type"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " , ".MAIN_DB_PREFIX."user as u"; - $sql.= " , ".MAIN_DB_PREFIX."facturedet as fc"; - $sql.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; - $sql.= " WHERE rc.fk_soc =". $object->id; - $sql.= " AND rc.fk_facture_line = fc.rowid"; - $sql.= " AND fc.fk_facture = f.rowid"; - $sql.= " AND rc.fk_user = u.rowid"; - $sql.= " AND rc.discount_type = 0"; // Eliminate supplier discounts - $sql.= " ORDER BY dc DESC"; + $sql .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; + $sql .= " rc.fk_facture_source,"; + $sql .= " u.login, u.rowid as user_id,"; + $sql .= " f.rowid, f.ref,"; + $sql .= " fa.ref as ref, fa.type as type"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " , ".MAIN_DB_PREFIX."user as u"; + $sql .= " , ".MAIN_DB_PREFIX."facturedet as fc"; + $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; + $sql .= " WHERE rc.fk_soc =".$object->id; + $sql .= " AND rc.fk_facture_line = fc.rowid"; + $sql .= " AND fc.fk_facture = f.rowid"; + $sql .= " AND rc.fk_user = u.rowid"; + $sql .= " AND rc.discount_type = 0"; // Eliminate supplier discounts + $sql .= " ORDER BY dc DESC"; //$sql.= " UNION "; // Remises liees a factures $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; - $sql2.= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; - $sql2.= " rc.fk_facture_source,"; - $sql2.= " u.login, u.rowid as user_id,"; - $sql2.= " f.rowid, f.ref,"; - $sql2.= " fa.ref as ref, fa.type as type"; - $sql2.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql2.= " , ".MAIN_DB_PREFIX."user as u"; - $sql2.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; - $sql2.= " WHERE rc.fk_soc =". $object->id; - $sql2.= " AND rc.fk_facture = f.rowid"; - $sql2.= " AND rc.fk_user = u.rowid"; - $sql2.= " AND rc.discount_type = 0"; // Eliminate supplier discounts - $sql2.= " ORDER BY dc DESC"; + $sql2 .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; + $sql2 .= " rc.fk_facture_source,"; + $sql2 .= " u.login, u.rowid as user_id,"; + $sql2 .= " f.rowid, f.ref,"; + $sql2 .= " fa.ref as ref, fa.type as type"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql2 .= " , ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; + $sql2 .= " WHERE rc.fk_soc =".$object->id; + $sql2 .= " AND rc.fk_facture = f.rowid"; + $sql2 .= " AND rc.fk_user = u.rowid"; + $sql2 .= " AND rc.discount_type = 0"; // Eliminate supplier discounts + $sql2 .= " ORDER BY dc DESC"; - $resql=$db->query($sql); - $resql2=null; - if ($resql) $resql2=$db->query($sql2); + $resql = $db->query($sql); + $resql2 = null; + if ($resql) $resql2 = $db->query($sql2); if ($resql2) { print '
    '; print '
    '.$langs->trans("Date").''.$langs->trans("Date").''.$langs->trans("ReasonDiscount").''.$langs->trans("ConsumedBy").''.$langs->trans("AmountHT").''.$langs->trans("MulticurrencyAmountHT").''.$langs->trans("VATRate").''.$langs->trans("AmountTTC").''.$langs->trans("MulticurrencyAmountTTC").' 
    '; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(EXCESS PAID\)/', $langs->trans("ExcessPaid"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''.$langs->trans("NotConsumed").''.price($obj->amount_ht).''.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.price($obj->amount_ttc).''.price($obj->multicurrency_amount_ttc).''; - print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; //print '   '; - print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_delete($langs->trans("RemoveDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ' 
    '; print ''; - print ''; // Need 120+ for format with AM/PM + print ''; // Need 120+ for format with AM/PM print ''; print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -796,26 +796,26 @@ if ($socid > 0) print ''; print ''; - $tab_sqlobj=array(); - $tab_sqlobjOrder=array(); + $tab_sqlobj = array(); + $tab_sqlobjOrder = array(); $num = $db->num_rows($resql); if ($num > 0) { - for ($i = 0;$i < $num; $i++) + for ($i = 0; $i < $num; $i++) { $sqlobj = $db->fetch_object($resql); $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]=$db->jdate($sqlobj->dc); + $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); } } $db->free($resql); $num = $db->num_rows($resql2); - for ($i = 0;$i < $num;$i++) + for ($i = 0; $i < $num; $i++) { $sqlobj = $db->fetch_object($resql2); $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dc); + $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); } $db->free($resql2); array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj); @@ -823,8 +823,8 @@ if ($socid > 0) $num = count($tab_sqlobj); if ($num > 0) { - $i = 0 ; - while ($i < $num ) + $i = 0; + while ($i < $num) { $obj = array_shift($tab_sqlobj); print ''; @@ -832,27 +832,27 @@ if ($socid > 0) if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) { print ''; } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) { print ''; } @@ -864,13 +864,13 @@ if ($socid > 0) } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -896,8 +896,8 @@ if ($socid > 0) } } - if($isSupplier) { - if($isCustomer) { + if ($isSupplier) { + if ($isCustomer) { print ''; // class="fichehalfleft" print '
    '; print '
    '; @@ -906,59 +906,59 @@ if ($socid > 0) // Discount linked to invoice lines $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; - $sql.= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; - $sql.= " rc.fk_invoice_supplier_source,"; - $sql.= " u.login, u.rowid as user_id,"; - $sql.= " f.rowid, f.ref as ref,"; - $sql.= " fa.ref, fa.type as type"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql.= " , ".MAIN_DB_PREFIX."user as u"; - $sql.= " , ".MAIN_DB_PREFIX."facture_fourn_det as fc"; - $sql.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; - $sql.= " WHERE rc.fk_soc =". $object->id; - $sql.= " AND rc.fk_invoice_supplier_line = fc.rowid"; - $sql.= " AND fc.fk_facture_fourn = f.rowid"; - $sql.= " AND rc.fk_user = u.rowid"; - $sql.= " AND rc.discount_type = 1"; // Eliminate customer discounts - $sql.= " ORDER BY dc DESC"; + $sql .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; + $sql .= " rc.fk_invoice_supplier_source,"; + $sql .= " u.login, u.rowid as user_id,"; + $sql .= " f.rowid, f.ref as ref,"; + $sql .= " fa.ref, fa.type as type"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= " , ".MAIN_DB_PREFIX."user as u"; + $sql .= " , ".MAIN_DB_PREFIX."facture_fourn_det as fc"; + $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; + $sql .= " WHERE rc.fk_soc =".$object->id; + $sql .= " AND rc.fk_invoice_supplier_line = fc.rowid"; + $sql .= " AND fc.fk_facture_fourn = f.rowid"; + $sql .= " AND rc.fk_user = u.rowid"; + $sql .= " AND rc.discount_type = 1"; // Eliminate customer discounts + $sql .= " ORDER BY dc DESC"; //$sql.= " UNION "; // Remises liees a factures $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; - $sql2.= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; - $sql2.= " rc.fk_invoice_supplier_source,"; - $sql2.= " u.login, u.rowid as user_id,"; - $sql2.= " f.rowid, f.ref as ref,"; - $sql2.= " fa.ref, fa.type as type"; - $sql2.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql2.= " , ".MAIN_DB_PREFIX."user as u"; - $sql2.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; - $sql2.= " WHERE rc.fk_soc =". $object->id; - $sql2.= " AND rc.fk_invoice_supplier = f.rowid"; - $sql2.= " AND rc.fk_user = u.rowid"; - $sql2.= " AND rc.discount_type = 1"; // Eliminate customer discounts - $sql2.= " ORDER BY dc DESC"; + $sql2 .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; + $sql2 .= " rc.fk_invoice_supplier_source,"; + $sql2 .= " u.login, u.rowid as user_id,"; + $sql2 .= " f.rowid, f.ref as ref,"; + $sql2 .= " fa.ref, fa.type as type"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql2 .= " , ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; + $sql2 .= " WHERE rc.fk_soc =".$object->id; + $sql2 .= " AND rc.fk_invoice_supplier = f.rowid"; + $sql2 .= " AND rc.fk_user = u.rowid"; + $sql2 .= " AND rc.discount_type = 1"; // Eliminate customer discounts + $sql2 .= " ORDER BY dc DESC"; - $resql=$db->query($sql); - $resql2=null; - if ($resql) $resql2=$db->query($sql2); + $resql = $db->query($sql); + $resql2 = null; + if ($resql) $resql2 = $db->query($sql2); if ($resql2) { print '
    '; print '
    '.$langs->trans("Date").''.$langs->trans("Date").''.$langs->trans("ReasonDiscount").''.$langs->trans("ConsumedBy").''.$langs->trans("AmountHT").''.$langs->trans("MulticurrencyAmountHT").''.$langs->trans("VATRate").''.$langs->trans("AmountTTC").''.$langs->trans("MulticurrencyAmountTTC").' 
    '; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("Invoice"), $obj->description).' '.$facturestatic->getNomURl(1); print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''.price($obj->amount_ht).''.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.price($obj->amount_ttc).''.price($obj->multicurrency_amount_ttc).'
    '; print ''; - print ''; // Need 120+ for format with AM/PM + print ''; // Need 120+ for format with AM/PM print ''; print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -966,26 +966,26 @@ if ($socid > 0) print ''; print ''; - $tab_sqlobj=array(); - $tab_sqlobjOrder=array(); + $tab_sqlobj = array(); + $tab_sqlobjOrder = array(); $num = $db->num_rows($resql); if ($num > 0) { - for ($i = 0;$i < $num; $i++) + for ($i = 0; $i < $num; $i++) { $sqlobj = $db->fetch_object($resql); $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]=$db->jdate($sqlobj->dc); + $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); } } $db->free($resql); $num = $db->num_rows($resql2); - for ($i = 0;$i < $num;$i++) + for ($i = 0; $i < $num; $i++) { $sqlobj = $db->fetch_object($resql2); $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dc); + $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); } $db->free($resql2); array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj); @@ -993,8 +993,8 @@ if ($socid > 0) $num = count($tab_sqlobj); if ($num > 0) { - $i = 0 ; - while ($i < $num ) + $i = 0; + while ($i < $num) { $obj = array_shift($tab_sqlobj); print ''; @@ -1002,27 +1002,27 @@ if ($socid > 0) if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) { print ''; } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; } elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) { print ''; } @@ -1034,13 +1034,13 @@ if ($socid > 0) } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -1065,7 +1065,7 @@ if ($socid > 0) dol_print_error($db); } - if($isCustomer) { + if ($isCustomer) { print ''; // class="ficheaddleft" print ''; // class="fichehalfright" print ''; // class="fichecenter" diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 79e7c11001c..d097b39b644 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -27,9 +27,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; -require_once DOL_DOCUMENT_ROOT .'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (!$user->rights->commande->lire) accessforbidden(); @@ -42,7 +42,7 @@ $hookmanager->initHooks(array('ordersindex')); $langs->loadLangs(array('orders', 'bills')); // Security check -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); if ($user->socid > 0) { $action = ''; @@ -55,11 +55,11 @@ if ($user->socid > 0) * View */ -$commandestatic=new Commande($db); -$companystatic=new Societe($db); +$commandestatic = new Commande($db); +$companystatic = new Societe($db); $form = new Form($db); $formfile = new FormFile($db); -$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; +$help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; llxHeader("", $langs->trans("Orders"), $help_url); @@ -69,10 +69,10 @@ print load_fiche_titre($langs->trans("OrdersArea"), '', 'commercial'); print '
    '; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search customer orders - $var=false; + $var = false; print ''; print ''; print '
    '; @@ -89,14 +89,14 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele */ $sql = "SELECT count(c.rowid), c.fk_statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."commande as c"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity IN (".getEntity('societe').")"; -if ($user->socid) $sql.=' AND c.fk_soc = '.$user->socid; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " GROUP BY c.fk_statut"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= ", ".MAIN_DB_PREFIX."commande as c"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE c.fk_soc = s.rowid"; +$sql .= " AND c.entity IN (".getEntity('societe').")"; +if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " GROUP BY c.fk_statut"; $resql = $db->query($sql); if ($resql) @@ -104,10 +104,10 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - $total=0; - $totalinprocess=0; - $dataseries=array(); - $vals=array(); + $total = 0; + $totalinprocess = 0; + $dataseries = array(); + $vals = array(); // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) while ($i < $num) { @@ -145,7 +145,7 @@ if ($resql) $dolgraph->SetType(array('pie')); $dolgraph->setWidth('100%'); $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total?0:1); + print $dolgraph->show($total ? 0 : 1); print '
    '; } @@ -155,7 +155,7 @@ if ($resql) { print ''; print ''; - print ''; @@ -175,22 +175,22 @@ else /* * Draft orders */ -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) { $sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid"; - $sql.= ", s.client"; - $sql.= ", s.code_client"; - $sql.= ", s.canvas"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - $sql.= " AND c.fk_statut = 0"; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND c.fk_statut = 0"; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print '
    '; @@ -207,14 +207,14 @@ if (! empty($conf->commande->enabled)) { $obj = $db->fetch_object($resql); - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->code_client=$obj->code_client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->canvas = $obj->canvas; print '
    '; print ''; print ''; print ''; print ''; - print ''; + print ''; // Label print ''; @@ -359,15 +359,15 @@ if ($action == 'create') // Type print ''; print ''; // Currency print ''; print ''; @@ -375,17 +375,17 @@ if ($action == 'create') // Status print ''; print ''; // Country - $selectedcode=''; + $selectedcode = ''; if (isset($_POST["account_country_id"])) { - $selectedcode=$_POST["account_country_id"]?$_POST["account_country_id"]:$object->country_code; + $selectedcode = $_POST["account_country_id"] ? $_POST["account_country_id"] : $object->country_code; } - elseif (empty($selectedcode)) $selectedcode=$mysoc->country_code; - $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules + elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; + $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules print ''; print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -454,7 +454,7 @@ if ($action == 'create') // Sold print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print '
    '.$langs->trans("Date").''.$langs->trans("Date").''.$langs->trans("ReasonDiscount").''.$langs->trans("ConsumedBy").''.$langs->trans("AmountHT").''.$langs->trans("MulticurrencyAmountHT").''.$langs->trans("VATRate").''.$langs->trans("AmountTTC").''.$langs->trans("MulticurrencyAmountTTC").' 
    '; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(EXCESS PAID\)/', $langs->trans("Invoice"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''.price($obj->amount_ht).''.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.price($obj->amount_ttc).''.price($obj->multicurrency_amount_ttc).'
    '.$commandestatic->LibStatut($status, $bool, 0).''.(isset($vals[$status.$bool])?$vals[$status.$bool]:0).' '; + print ''.(isset($vals[$status.$bool]) ? $vals[$status.$bool] : 0).' '; print $commandestatic->LibStatut($status, $bool, 3); print ''; print '
    '; @@ -238,29 +238,29 @@ if (! empty($conf->commande->enabled)) print '
    '; -$max=5; +$max = 5; /* * Last modified orders */ $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_cloture as datec, c.tms as datem,"; -$sql.= " s.nom as name, s.rowid as socid"; -$sql.= ", s.client"; -$sql.= ", s.code_client"; -$sql.= ", s.canvas"; -$sql.= " FROM ".MAIN_DB_PREFIX."commande as c,"; -$sql.= " ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity IN (".getEntity('commande').")"; +$sql .= " s.nom as name, s.rowid as socid"; +$sql .= ", s.client"; +$sql .= ", s.code_client"; +$sql .= ", s.canvas"; +$sql .= " FROM ".MAIN_DB_PREFIX."commande as c,"; +$sql .= " ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE c.fk_soc = s.rowid"; +$sql .= " AND c.entity IN (".getEntity('commande').")"; //$sql.= " AND c.fk_statut > 2"; if ($socid) $sql .= " AND c.fk_soc = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " ORDER BY c.tms DESC"; -$sql.= $db->plimit($max, 0); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " ORDER BY c.tms DESC"; +$sql .= $db->plimit($max, 0); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { print '
    '; @@ -280,14 +280,14 @@ if ($resql) print '
    '; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->code_client=$obj->code_client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->canvas = $obj->canvas; print ''; print ''; print '
    '; @@ -299,9 +299,9 @@ if ($resql) print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print '
    '; @@ -324,23 +324,23 @@ else dol_print_error($db); /* * Orders to process */ -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) { $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; - $sql.= ", s.client"; - $sql.= ", s.code_client"; - $sql.= ", s.canvas"; - $sql.=" FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - $sql.= " AND c.fk_statut = 1"; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - $sql.= " ORDER BY c.rowid DESC"; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND c.fk_statut = 1"; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " ORDER BY c.rowid DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -359,14 +359,14 @@ if (! empty($conf->commande->enabled)) print '
    '; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->code_client=$obj->code_client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->canvas = $obj->canvas; print ''; print ''; print '
    '; @@ -378,9 +378,9 @@ if (! empty($conf->commande->enabled)) print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print '
    '; @@ -405,23 +405,23 @@ if (! empty($conf->commande->enabled)) /* * Orders thar are in a shipping process */ -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) { $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; - $sql.= ", s.client"; - $sql.= ", s.code_client"; - $sql.= ", s.canvas"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - $sql.= " AND c.fk_statut = 2 "; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - $sql.= " ORDER BY c.rowid DESC"; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND c.fk_statut = 2 "; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " ORDER BY c.rowid DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -441,14 +441,14 @@ if (! empty($conf->commande->enabled)) print '
    '; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->code_client=$obj->code_client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->canvas = $obj->canvas; print ''; print ''; print '
    '; @@ -460,9 +460,9 @@ if (! empty($conf->commande->enabled)) print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print '
    '; diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index bc260a4e527..2af8ea7de22 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -26,13 +26,13 @@ * \brief Page de gestion des documents attaches a un compte bancaire */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . "/core/lib/bank.lib.php"; -require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; -require_once DOL_DOCUMENT_ROOT . "/core/lib/images.lib.php"; -require_once DOL_DOCUMENT_ROOT . "/core/class/html.formfile.class.php"; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/bank.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -global $conf,$db,$langs; +global $conf, $db, $langs; // Load translation files required by the page $langs->loadLangs(array('banks', 'companies', 'other')); @@ -70,7 +70,7 @@ if (!$sortfield) $sortfield = "name"; $object = new Account($db); -if ($id > 0 || ! empty($ref)) $object->fetch($id, $ref); +if ($id > 0 || !empty($ref)) $object->fetch($id, $ref); $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); @@ -82,10 +82,10 @@ $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); if (!empty($num)) { $object->fetch_thirdparty(); - $upload_dir = $conf->bank->dir_output . "/".$id."/statement/" . dol_sanitizeFileName($num); + $upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num); } $backtopage = $_SERVER['PHP_SELF']."?account=".$id."&num=".$num; -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -100,7 +100,7 @@ $form = new Form($db); if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref)) { - $upload_dir = $conf->bank->dir_output . "/".$id."/statement/" . dol_sanitizeFileName($num); + $upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num); // Onglets $head = account_statement_prepare_head($object, $num); @@ -111,13 +111,13 @@ if ($id > 0 || !empty($ref)) { $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); $totalsize = 0; foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } $morehtmlref = ''; - $title=$langs->trans("AccountStatement").' '.$num.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); + $title = $langs->trans("AccountStatement").' '.$num.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); print load_fiche_titre($title, '', 'title_bank.png'); @@ -125,8 +125,8 @@ if ($id > 0 || !empty($ref)) { print '
    '; print ''; - print ''; - print ''; + print ''; + print ''; print "
    ' . $langs->trans("NbOfAttachedFiles") . '' . count($filearray) . '
    ' . $langs->trans("TotalSizeOfAttachedFiles") . '' .dol_print_size($totalsize, 1, 1).'
    '.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
    '.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
    \n"; print ''; @@ -137,10 +137,10 @@ if ($id > 0 || !empty($ref)) { $modulepart = 'bank'; $permission = $user->rights->banque->modifier; $permtoedit = $user->rights->banque->modifier; - $param = '&id=' . $object->id.'&num='.$num; + $param = '&id='.$object->id.'&num='.$num; $uri = '&num='.$num; $relativepathwithnofile = $id."/statement/".$num."/"; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { dol_print_error($db); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 980cf6bd8f2..3baf50fcc2c 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -29,28 +29,28 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","bills","categories","companies","compta")); +$langs->loadLangs(array("banks", "bills", "categories", "companies", "compta")); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); // Security check -$id = GETPOST("id", 'int') ? GETPOST("id", 'int'): GETPOST('ref', 'alpha'); +$id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha'); $fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid'; -$result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); +$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); $object = new Account($db); $extrafields = new ExtraFields($db); @@ -59,17 +59,17 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('bankcard','globalcard')); +$hookmanager->initHooks(array('bankcard', 'globalcard')); /* * Actions */ -if ($cancel) $action=''; +if ($cancel) $action = ''; if ($action == 'add') { - $error=0; + $error = 0; $db->begin(); @@ -92,10 +92,10 @@ if ($action == 'add') $object->iban = trim($_POST["iban"]); $object->domiciliation = trim(GETPOST("domiciliation", "nohtml")); - $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); + $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); - $account_number = GETPOST('account_number', 'alphanohtml'); + $account_number = GETPOST('account_number', 'alphanohtml'); if (empty($account_number) || $account_number == '-1') { $object->account_number = ''; @@ -124,26 +124,26 @@ if ($action == 'add') if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation $error++; } if (empty($object->ref)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation $error++; } if (empty($object->label)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation $error++; } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if (! $error) + if (!$error) { $id = $object->create($user); if ($id > 0) @@ -152,19 +152,19 @@ if ($action == 'add') $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - $_GET["id"]=$id; // Force chargement page en mode visu + $_GET["id"] = $id; // Force chargement page en mode visu - $action=''; + $action = ''; } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation } } - if (! $error) + if (!$error) { $db->commit(); } @@ -176,7 +176,7 @@ if ($action == 'add') if ($action == 'update') { - $error=0; + $error = 0; // Update account $object = new Account($db); @@ -198,10 +198,10 @@ if ($action == 'update') $object->iban = trim($_POST["iban"]); $object->domiciliation = trim(GETPOST("domiciliation", "nohtml")); - $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); + $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); - $account_number = GETPOST('account_number', 'alpha'); + $account_number = GETPOST('account_number', 'alpha'); if (empty($account_number) || $account_number == '-1') { $object->account_number = ''; @@ -225,31 +225,31 @@ if ($action == 'update') if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); - $action='edit'; // Force chargement page en mode creation + $action = 'edit'; // Force chargement page en mode creation $error++; } if (empty($object->ref)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); - $action='edit'; // Force chargement page en mode creation + $action = 'edit'; // Force chargement page en mode creation $error++; } if (empty($object->label)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors'); - $action='edit'; // Force chargement page en mode creation + $action = 'edit'; // Force chargement page en mode creation $error++; } $db->begin(); - if (! $error) + if (!$error) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); } - if (! $error) + if (!$error) { $result = $object->update($user); if ($result >= 0) @@ -258,17 +258,17 @@ if ($action == 'update') $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu + $_GET["id"] = $_POST["id"]; // Force chargement page en mode visu } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); - $action='edit'; // Force chargement page edition + $action = 'edit'; // Force chargement page edition } } - if (! $error) + if (!$error) { $db->commit(); } @@ -294,7 +294,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights-> else { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } @@ -306,11 +306,11 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights-> $form = new Form($db); $formbank = new FormBank($db); $formcompany = new FormCompany($db); -if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); -$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; -$title = $langs->trans("FinancialAccount") . " - " . $langs->trans("Card"); +$title = $langs->trans("FinancialAccount")." - ".$langs->trans("Card"); $helpurl = ""; llxHeader("", $title, $helpurl); @@ -319,7 +319,7 @@ llxHeader("", $title, $helpurl); if ($action == 'create') { - $object=new Account($db); + $object = new Account($db); print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'title_bank.png'); @@ -350,7 +350,7 @@ if ($action == 'create') // Ref print '
    '.$langs->trans("Ref").'ref).'" maxlength="12" autofocus>
    ref).'" maxlength="12" autofocus>
    '.$langs->trans("LabelBankCashAccount").'
    '.$langs->trans("AccountType").''; - $formbank->selectTypeOfBankAccount(isset($_POST["type"])?$_POST["type"]: Account::TYPE_CURRENT, "type"); + $formbank->selectTypeOfBankAccount(isset($_POST["type"]) ? $_POST["type"] : Account::TYPE_CURRENT, "type"); print '
    '.$langs->trans("Currency").''; - $selectedcode=$object->currency_code; - if (! $selectedcode) $selectedcode=$conf->currency; - print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); + $selectedcode = $object->currency_code; + if (!$selectedcode) $selectedcode = $conf->currency; + print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
    '.$langs->trans("Status").''; - print $form->selectarray("clos", $object->status, (GETPOST("clos", 'int')!=''?GETPOST("clos", 'int'):$object->clos)); + print $form->selectarray("clos", $object->status, (GETPOST("clos", 'int') != '' ?GETPOST("clos", 'int') : $object->clos)); print '
    '.$langs->trans("BankAccountCountry").''; @@ -397,7 +397,7 @@ if ($action == 'create') print '
    '.$langs->trans('State').''; if ($selectedcode) { - $formcompany->select_departement(isset($_POST["account_state_id"])?$_POST["account_state_id"]:'', $selectedcode, 'account_state_id'); + $formcompany->select_departement(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : '', $selectedcode, 'account_state_id'); } else { @@ -420,7 +420,7 @@ if ($action == 'create') $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT); if (is_array($cats)) { - foreach($cats as $cat) { + foreach ($cats as $cat) { $arrayselected[] = $cat->id; } } @@ -433,13 +433,13 @@ if ($action == 'create') print ''; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('account_comment', (GETPOST("account_comment")?GETPOST("account_comment"):$object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '90%'); + $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '90%'); $doleditor->Create(); print '
    '.$langs->trans("InitialBankBalance").'solde)).'">
    solde)).'">
    '.$langs->trans("Date").''; @@ -462,10 +462,10 @@ if ($action == 'create') print '
    '.$langs->trans("BalanceMinimalAllowed").'min_allowed).'">
    min_allowed).'">
    '.$langs->trans("BalanceMinimalDesired").'min_desired).'">
    min_desired).'">
    '; print '
    '; @@ -476,7 +476,7 @@ if ($action == 'create') // If bank account print '
    '.$langs->trans("BankName").'
    '.$langs->trans($val).'
    '.$langs->trans($ibankey).'
    '.$langs->trans($bickey).'
    '.$langs->trans("BankAccountDomiciliation").''; print "
    '.$langs->trans("BankAccountOwner").''; + print ''; print '
    '.$langs->trans("BankAccountOwnerAddress").''; print "
    '; @@ -534,10 +534,10 @@ if ($action == 'create') print ''; // Accountancy code - $fieldrequired=''; - if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired '; + $fieldrequired = ''; + if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired = 'fieldrequired '; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print ''; - print ''; + print ''; } // Accountancy journal - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print ''; print ''; // Conciliate print ''; print ''; print ''; @@ -648,7 +648,7 @@ else // Accountancy code print ''; print ''; // Accountancy journal - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print '
    '.$langs->trans("AccountancyCode").''; @@ -547,11 +547,11 @@ if ($action == 'create') else { print '
    '.$langs->trans("AccountancyCode").'account_number).'">
    account_number).'">
    '.$langs->trans("AccountancyJournal").''; @@ -564,9 +564,9 @@ if ($action == 'create') dol_fiche_end(); print '
    '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
    '; print ''; @@ -588,11 +588,11 @@ else if ($_GET["ref"]) { $object->fetch(0, $_GET["ref"]); - $_GET["id"]=$object->id; + $_GET["id"] = $object->id; } // Show tabs - $head=bank_prepare_head($object); + $head = bank_prepare_head($object); dol_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account'); $formconfirm = ''; @@ -608,7 +608,7 @@ else $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref=''; + $morehtmlref = ''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -625,18 +625,18 @@ else // Currency print '
    '.$langs->trans("Currency").''; - $selectedcode=$object->currency_code; - if (! $selectedcode) $selectedcode=$conf->currency; + $selectedcode = $object->currency_code; + if (!$selectedcode) $selectedcode = $conf->currency; print $langs->trans("Currency".$selectedcode); print '
    '.$langs->trans("Conciliable").''; - $conciliate=$object->canBeConciliated(); + $conciliate = $object->canBeConciliated(); if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; elseif ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')'; - else print ($object->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')')); + else print ($object->rappro == 1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')')); print '
    '.$langs->trans("BalanceMinimalAllowed").'
    '.$langs->trans("AccountancyCode").''; - if (! empty($conf->accounting->enabled)) { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_number, 1); @@ -659,7 +659,7 @@ else print '
    '.$langs->trans("AccountancyJournal").''; @@ -675,7 +675,7 @@ else // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '; @@ -725,13 +725,13 @@ else } $ibankey = FormBank::getIBANLabel($object); - $bickey="BICNumber"; - if ($object->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($object->getCountryCode() == 'IN') $bickey = "SWIFT"; print '
    '.$langs->trans($ibankey).''.$object->iban.' '; - if (! empty($object->iban)) { - if (! checkIbanForAccount($object)) { + if (!empty($object->iban)) { + if (!checkIbanForAccount($object)) { print img_picto($langs->trans("IbanNotValid"), 'warning'); } else { print img_picto($langs->trans("IbanValid"), 'info'); @@ -741,8 +741,8 @@ else print '
    '.$langs->trans($bickey).''.$object->bic.' '; - if (! empty($object->bic)) { - if (! checkSwiftForAccount($object)) { + if (!empty($object->bic)) { + if (!checkSwiftForAccount($object)) { print img_picto($langs->trans("SwiftNotValid"), 'warning'); } else { print img_picto($langs->trans("SwiftValid"), 'info'); @@ -783,7 +783,7 @@ else print 'id.'">'.$langs->trans("Modify").''; } - $canbedeleted=$object->can_be_deleted(); // Renvoi vrai si compte sans mouvements + $canbedeleted = $object->can_be_deleted(); // Renvoi vrai si compte sans mouvements if ($user->rights->banque->configurer && $canbedeleted) { print 'id.'">'.$langs->trans("Delete").''; @@ -837,16 +837,16 @@ else // Ref print '
    '.$langs->trans("Ref").'ref).'">
    ref).'">
    '.$langs->trans("Label").'label).'">
    label).'">
    '.$langs->trans("AccountType").''; - $formbank->selectTypeOfBankAccount((isset($_POST["type"])?$_POST["type"]:$object->type), "type"); + $formbank->selectTypeOfBankAccount((isset($_POST["type"]) ? $_POST["type"] : $object->type), "type"); print '
    '; - $selectedcode=$object->currency_code; - if (! $selectedcode) $selectedcode=$conf->currency; - print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); + $selectedcode = $object->currency_code; + if (!$selectedcode) $selectedcode = $conf->currency; + print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
    '.$langs->trans("Status").''; - print $form->selectarray("clos", $object->status, (isset($_POST["clos"])?$_POST["clos"]:$object->clos)); + print $form->selectarray("clos", $object->status, (isset($_POST["clos"]) ? $_POST["clos"] : $object->clos)); print '
    '.$langs->trans("Country").''; @@ -884,7 +884,7 @@ else print '
    '.$langs->trans('State').''; if ($selectedcode) { - print $formcompany->select_state(isset($_POST["account_state_id"])?$_POST["account_state_id"]:$object->state_id, $selectedcode, 'account_state_id'); + print $formcompany->select_state(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : $object->state_id, $selectedcode, 'account_state_id'); } else { @@ -895,22 +895,22 @@ else // Conciliable print '
    '.$langs->trans("Conciliable").''; - $conciliate=$object->canBeConciliated(); + $conciliate = $object->canBeConciliated(); if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; elseif ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')'; - else print ' 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation"); + else print ' 0) ? '' : ' checked="checked"').'"> '.$langs->trans("DisableConciliation"); print '
    '.$langs->trans("BalanceMinimalAllowed").'min_allowed).'">
    min_allowed).'">
    '.$langs->trans("BalanceMinimalDesired").'min_desired).'">
    min_desired).'">
    '.$langs->trans("Web").'url).'">'; + print 'url).'">'; print '
    '; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('account_comment', (GETPOST("account_comment")?GETPOST("account_comment"):$object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '95%'); + $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '95%'); $doleditor->Create(); print '
    '.$langs->trans("AccountancyJournal").''; @@ -1022,8 +1022,8 @@ else } $ibankey = FormBank::getIBANLabel($object); - $bickey="BICNumber"; - if ($object->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($object->getCountryCode() == 'IN') $bickey = "SWIFT"; // IBAN print '
    '.$langs->trans($ibankey).'
    '; - $i=0; - foreach($listofsearchfields as $key => $value) + $i = 0; + foreach ($listofsearchfields as $key => $value) { if ($i == 0) print ''; print ''; @@ -138,42 +138,42 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele /** * Draft customers invoices */ -if (! empty($conf->facture->enabled) && $user->rights->facture->lire) +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $sql = "SELECT f.rowid, f.ref, f.datef as date, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client"; - $sql.= ", f.type"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid, s.email"; - $sql.= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= ", f.type"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) { $sql .= " AND f.fk_soc = $socid"; } // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); + $sql .= $hookmanager->resPrint; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); print '
    '; print '
    '.$langs->trans("Search").'
    '; print ''; - print ''; + print ''; if ($num) { - $companystatic=new Societe($db); + $companystatic = new Societe($db); $i = 0; $tot_ttc = 0; @@ -181,18 +181,18 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); - $facturestatic->id=$obj->rowid; - $facturestatic->ref=$obj->ref; - $facturestatic->date=$db->jdate($obj->date); - $facturestatic->type=$obj->type; - $facturestatic->total_ht=$obj->total_ht; - $facturestatic->total_tva=$obj->total_tva; - $facturestatic->total_ttc=$obj->total_ttc; - $facturestatic->ref_client=$obj->ref_client; + $facturestatic->id = $obj->rowid; + $facturestatic->ref = $obj->ref; + $facturestatic->date = $db->jdate($obj->date); + $facturestatic->type = $obj->type; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_tva; + $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->ref_client = $obj->ref_client; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->email=$obj->email; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->email = $obj->email; $companystatic->client = 1; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; @@ -207,7 +207,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print ''; print ''; print ''; - $tot_ttc+=$obj->total_ttc; + $tot_ttc += $obj->total_ttc; $i++; } @@ -231,36 +231,36 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) /** * Draft suppliers invoices */ -if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { - $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid, s.email"; - $sql.= ", s.code_fournisseur, s.code_compta_fournisseur"; - $sql.= ", cc.rowid as country_id, cc.code as country_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; - $sql.= " AND f.entity IN (".getEntity('invoice').')'; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND f.fk_soc = ".$socid; + $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; + $sql .= " AND f.entity IN (".getEntity('invoice').')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereSupplierDraft', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierDraft', $parameters); + $sql .= $hookmanager->resPrint; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); print '
    '; print '
    '.$langs->trans("CustomersDraftInvoices").($num?' '.$num.'':'').'
    '.$langs->trans("CustomersDraftInvoices").($num ? ' '.$num.'' : '').'
    '.price($obj->total_ttc).'
    '; print ''; - print ''; + print ''; if ($num) { - $companystatic=new Societe($db); + $companystatic = new Societe($db); $i = 0; $tot_ttc = 0; @@ -268,19 +268,19 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { $obj = $db->fetch_object($resql); - $facturesupplierstatic->ref=$obj->ref; - $facturesupplierstatic->id=$obj->rowid; - $facturesupplierstatic->total_ht=$obj->total_ht; - $facturesupplierstatic->total_tva=$obj->total_tva; - $facturesupplierstatic->total_ttc=$obj->total_ttc; - $facturesupplierstatic->ref_supplier=$obj->ref_supplier; - $facturesupplierstatic->type=$obj->type; + $facturesupplierstatic->ref = $obj->ref; + $facturesupplierstatic->id = $obj->rowid; + $facturesupplierstatic->total_ht = $obj->total_ht; + $facturesupplierstatic->total_tva = $obj->total_tva; + $facturesupplierstatic->total_ttc = $obj->total_ttc; + $facturesupplierstatic->ref_supplier = $obj->ref_supplier; + $facturesupplierstatic->type = $obj->type; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->email=$obj->email; - $companystatic->country_id=$obj->country_id; - $companystatic->country_code=$obj->country_code; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->email = $obj->email; + $companystatic->country_id = $obj->country_id; + $companystatic->country_code = $obj->country_code; $companystatic->fournisseur = 1; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; @@ -295,7 +295,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print ''; print ''; print ''; - $tot_ttc+=$obj->total_ttc; + $tot_ttc += $obj->total_ttc; $i++; } @@ -321,35 +321,35 @@ print '
    '; // Latest modified customer invoices -if (! empty($conf->facture->enabled) && $user->rights->facture->lire) +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $langs->load("boxes"); - $facstatic=new Facture($db); + $facstatic = new Facture($db); $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; - $sql.= ", f.date_lim_reglement as datelimite"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client, s.code_compta, s.email"; - $sql.= ", cc.rowid as country_id, cc.code as country_code"; - $sql.= ", sum(pf.amount) as am"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays, ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = f.fk_soc"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND f.fk_soc = ".$socid; + $sql .= ", f.date_lim_reglement as datelimite"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client, s.code_compta, s.email"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= ", sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays, ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = f.fk_soc"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerLastModified', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerLastModified', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY f.rowid, f.ref, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; - $sql.= " s.nom, s.rowid, s.code_client, s.code_compta, s.email,"; - $sql.= " cc.rowid, cc.code"; - $sql.= " ORDER BY f.tms DESC "; - $sql.= $db->plimit($max, 0); + $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql .= " s.nom, s.rowid, s.code_client, s.code_compta, s.email,"; + $sql .= " cc.rowid, cc.code"; + $sql .= " ORDER BY f.tms DESC "; + $sql .= $db->plimit($max, 0); $resql = $db->query($sql); if ($resql) @@ -360,7 +360,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print '
    '; print '
    '.$langs->trans("SuppliersDraftInvoices").($num?' '.$num.'':'').'
    '.$langs->trans("SuppliersDraftInvoices").($num ? ' '.$num.'' : '').'
    '.price($obj->total_ttc).'
    '; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -372,22 +372,22 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); - $facturestatic->ref=$obj->ref; - $facturestatic->id=$obj->rowid; - $facturestatic->total_ht=$obj->total_ht; - $facturestatic->total_tva=$obj->total_tva; - $facturestatic->total_ttc=$obj->total_ttc; + $facturestatic->ref = $obj->ref; + $facturestatic->id = $obj->rowid; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_tva; + $facturestatic->total_ttc = $obj->total_ttc; $facturestatic->statut = $obj->fk_statut; $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); - $facturestatic->type=$obj->type; + $facturestatic->type = $obj->type; - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; - $thirdpartystatic->email=$obj->email; - $thirdpartystatic->country_id=$obj->country_id; - $thirdpartystatic->country_code=$obj->country_code; - $thirdpartystatic->email=$obj->email; - $thirdpartystatic->client=1; + $thirdpartystatic->id = $obj->socid; + $thirdpartystatic->name = $obj->name; + $thirdpartystatic->email = $obj->email; + $thirdpartystatic->country_id = $obj->country_id; + $thirdpartystatic->country_code = $obj->country_code; + $thirdpartystatic->email = $obj->email; + $thirdpartystatic->client = 1; $thirdpartystatic->code_client = $obj->code_client; //$thirdpartystatic->code_fournisseur = $obj->code_fournisseur; $thirdpartystatic->code_compta = $obj->code_compta; @@ -406,9 +406,9 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) } print ''; print '
    '.$langs->trans("BoxTitleLastCustomerBills", $max).''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").' '; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?facid='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?facid='.$obj->rowid; print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); print '
    '; @@ -416,23 +416,23 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print '
    '; print $thirdpartystatic->getNomUrl(1, 'customer', 44); print ''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->tms), 'day').''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am).'
    '.$langs->trans("NoInvoice").'

    '; @@ -447,34 +447,34 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) // Last modified supplier invoices -if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { $langs->load("boxes"); - $facstatic=new FactureFournisseur($db); + $facstatic = new FactureFournisseur($db); $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_fournisseur, s.code_compta_fournisseur"; - $sql.= ", SUM(pf.amount) as am"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = ff.fk_soc"; - $sql.= " AND ff.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql.= " AND ff.fk_soc = ".$socid; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", SUM(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = ff.fk_soc"; + $sql .= " AND ff.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND ff.fk_soc = ".$socid; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereSupplierLastModified', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierLastModified', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye,"; - $sql.= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur"; - $sql.= " ORDER BY ff.tms DESC "; - $sql.= $db->plimit($max, 0); + $sql .= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye,"; + $sql .= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= " ORDER BY ff.tms DESC "; + $sql .= $db->plimit($max, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -482,7 +482,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print '
    '; print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -495,15 +495,15 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { $obj = $db->fetch_object($resql); - $facstatic->ref=$obj->ref; + $facstatic->ref = $obj->ref; $facstatic->id = $obj->rowid; $facstatic->total_ht = $obj->total_ht; $facstatic->total_tva = $obj->total_tva; $facstatic->total_ttc = $obj->total_ttc; - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; - $thirdpartystatic->fournisseur=1; + $thirdpartystatic->id = $obj->socid; + $thirdpartystatic->name = $obj->name; + $thirdpartystatic->fournisseur = 1; //$thirdpartystatic->code_client = $obj->code_client; $thirdpartystatic->code_fournisseur = $obj->code_fournisseur; //$thirdpartystatic->code_compta = $obj->code_compta; @@ -515,21 +515,21 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; print ''; $total += $obj->total_ht; - $total_ttc += $obj->total_ttc; - $totalam += $obj->am; + $total_ttc += $obj->total_ttc; + $totalam += $obj->am; $i++; } } else { - $colspan=5; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + $colspan = 5; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''; } print '
    '.$langs->trans("BoxTitleLastSupplierBills", $max).''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").' '; print $thirdpartystatic->getNomUrl(1, 'supplier', 44); print ''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->tms), 'day').''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3).'
    '.$langs->trans("NoInvoice").'

    '; @@ -543,28 +543,28 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- // Last donations -if (! empty($conf->don->enabled) && $user->rights->societe->lire) +if (!empty($conf->don->enabled) && $user->rights->societe->lire) { include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $langs->load("boxes"); - $donationstatic=new Don($db); + $donationstatic = new Don($db); $sql = "SELECT d.rowid, d.lastname, d.firstname, d.societe, d.datedon as date, d.tms as dm, d.amount, d.fk_statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; - $sql.= " WHERE d.entity IN (".getEntity('donation').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."don as d"; + $sql .= " WHERE d.entity IN (".getEntity('donation').")"; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereLastDonations', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereLastDonations', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= $db->order("d.tms", "DESC"); - $sql.= $db->plimit($max, 0); + $sql .= $db->order("d.tms", "DESC"); + $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { - $var=false; + $var = false; $num = $db->num_rows($result); $i = 0; @@ -586,13 +586,13 @@ if (! empty($conf->don->enabled) && $user->rights->societe->lire) { $objp = $db->fetch_object($result); - $donationstatic->id=$objp->rowid; - $donationstatic->ref=$objp->rowid; - $donationstatic->lastname=$objp->lastname; - $donationstatic->firstname=$objp->firstname; + $donationstatic->id = $objp->rowid; + $donationstatic->ref = $objp->rowid; + $donationstatic->lastname = $objp->lastname; + $donationstatic->firstname = $objp->firstname; - $label=$donationstatic->getFullName($langs); - if ($objp->societe) $label.=($label?' - ':'').$objp->societe; + $label = $donationstatic->getFullName($langs); + if ($objp->societe) $label .= ($label ? ' - ' : '').$objp->societe; print '
    '.$donationstatic->getNomUrl(1).'
    '; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -655,15 +655,15 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if ($num) { $i = 0; - $tot_ttc=0; + $tot_ttc = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - $chargestatic->id=$obj->rowid; - $chargestatic->ref=$obj->rowid; - $chargestatic->label=$obj->label; - $chargestatic->paye=$obj->paye; + $chargestatic->id = $obj->rowid; + $chargestatic->ref = $obj->rowid; + $chargestatic->label = $obj->label; + $chargestatic->paye = $obj->paye; print ''; print ''; @@ -673,7 +673,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print ''; print ''; - $tot_ttc+=$obj->amount; + $tot_ttc += $obj->amount; $i++; } @@ -700,37 +700,37 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) /* * Customers orders to be billed */ -if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) +if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { - $commandestatic=new Commande($db); + $commandestatic = new Commande($db); $langs->load("orders"); $sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc"; - $sql.= ", s.nom as name, s.email"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client, s.code_compta"; - $sql.= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc,"; - $sql.= " cc.rowid as country_id, cc.code as country_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON el.fk_target = f.rowid AND el.targettype = 'facture'"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - $sql.= " AND c.fk_statut = 3"; - $sql.= " AND c.facture = 0"; + $sql .= ", s.nom as name, s.email"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc,"; + $sql .= " cc.rowid as country_id, cc.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON el.fk_target = f.rowid AND el.targettype = 'facture'"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_statut = 3"; + $sql .= " AND c.facture = 0"; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code"; + $sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code"; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); @@ -742,31 +742,31 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us print '
    '.$langs->trans("ContributionsToPay").($num?' '.$num.'':'').''.$langs->trans("ContributionsToPay").($num ? ' '.$num.'' : '').''.$langs->trans("DateDue").''.$langs->trans("AmountTTC").''.$langs->trans("Paid").'
    '.$chargestatic->getNomUrl(1).''.$chargestatic->getLibStatut(3).'
    '; print ""; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; print ''; - $tot_ht=$tot_ttc=$tot_tobill=0; + $tot_ht = $tot_ttc = $tot_tobill = 0; $societestatic = new Societe($db); while ($i < $num) { $obj = $db->fetch_object($resql); - $societestatic->id=$obj->socid; - $societestatic->name=$obj->name; - $societestatic->email=$obj->email; - $societestatic->country_id=$obj->country_id; - $societestatic->country_code=$obj->country_code; - $societestatic->client=1; + $societestatic->id = $obj->socid; + $societestatic->name = $obj->name; + $societestatic->email = $obj->email; + $societestatic->country_id = $obj->country_id; + $societestatic->country_code = $obj->country_code; + $societestatic->client = 1; $societestatic->code_client = $obj->code_client; //$societestatic->code_fournisseur = $obj->code_fournisseur; $societestatic->code_compta = $obj->code_compta; //$societestatic->code_fournisseur = $obj->code_fournisseur; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; print ''; print ''; print '
    '.$langs->trans("OrdersDeliveredToBill").' '.$num.''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("ToBill").' 
    '; @@ -779,9 +779,9 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us print ' '; print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print '
    '; @@ -790,20 +790,20 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us print '
    '; print $societestatic->getNomUrl(1, 'customer', 44); print ''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->total_ttc-$obj->tot_fttc).''.price($obj->total_ttc - $obj->tot_fttc).''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).'
    '.$langs->trans("Total").'   ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).') '.price($tot_ht).''.price($tot_ht).''.price($tot_ttc).''.price($tot_tobill).' 
    '; print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -871,21 +871,21 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); - $facturestatic->ref=$obj->ref; - $facturestatic->id=$obj->rowid; - $facturestatic->total_ht=$obj->total_ht; - $facturestatic->total_tva=$obj->total_tva; - $facturestatic->total_ttc=$obj->total_ttc; - $facturestatic->type=$obj->type; + $facturestatic->ref = $obj->ref; + $facturestatic->id = $obj->rowid; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_tva; + $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->type = $obj->type; $facturestatic->statut = $obj->fk_statut; $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); - $societestatic->id=$obj->socid; - $societestatic->name=$obj->name; - $societestatic->email=$obj->email; - $societestatic->country_id=$obj->country_id; - $societestatic->country_code=$obj->country_code; - $societestatic->client=1; + $societestatic->id = $obj->socid; + $societestatic->name = $obj->name; + $societestatic->email = $obj->email; + $societestatic->country_id = $obj->country_id; + $societestatic->country_code = $obj->country_code; + $societestatic->client = 1; $societestatic->code_client = $obj->code_client; $societestatic->code_fournisseur = $obj->code_fournisseur; $societestatic->code_compta = $obj->code_compta; @@ -904,33 +904,33 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) } print ''; print '
    '.$langs->trans("BillsCustomersUnpaid", $num).' '.$num.''.$langs->trans("DateDue").''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("Received").' '; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?facid='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?facid='.$obj->rowid; print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); print '
    '; print '
    ' ; + print ''; print $societestatic->getNomUrl(1, 'customer', 44); print ''.dol_print_date($db->jdate($obj->datelimite), 'day').''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->am).''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am).'
    '.$langs->trans("Total").'   ('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).')
    '.$langs->trans("Total").'   ('.$langs->trans("RemainderToTake").': '.price($total_ttc - $totalam).')  '.price($total).''.price($total).''.price($total_ttc).''.price($totalam).' 
    '.$langs->trans("NoInvoice").'

    '; @@ -954,36 +954,36 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) /* * Unpayed supplier invoices */ -if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { - $facstatic=new FactureFournisseur($db); + $facstatic = new FactureFournisseur($db); $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; - $sql.= ", ff.date_lim_reglement"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid, s.email"; - $sql.= ", s.code_client, s.code_compta"; - $sql.= ", s.code_fournisseur, s.code_compta_fournisseur"; - $sql.= ", sum(pf.amount) as am"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = ff.fk_soc"; - $sql.= " AND ff.entity = ".$conf->entity; - $sql.= " AND ff.paye = 0"; - $sql.= " AND ff.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql.= " AND ff.fk_soc = ".$socid; + $sql .= ", ff.date_lim_reglement"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = ff.fk_soc"; + $sql .= " AND ff.entity = ".$conf->entity; + $sql .= " AND ff.paye = 0"; + $sql .= " AND ff.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND ff.fk_soc = ".$socid; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereSupplierUnpaid', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierUnpaid', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye, ff.date_lim_reglement,"; - $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; - $sql.= " ORDER BY ff.date_lim_reglement ASC"; + $sql .= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye, ff.date_lim_reglement,"; + $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; + $sql .= " ORDER BY ff.date_lim_reglement ASC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -992,7 +992,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print ''; print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -1006,17 +1006,17 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { $obj = $db->fetch_object($resql); - $facstatic->ref=$obj->ref; + $facstatic->ref = $obj->ref; $facstatic->id = $obj->rowid; $facstatic->total_ht = $obj->total_ht; $facstatic->total_tva = $obj->total_tva; $facstatic->total_ttc = $obj->total_ttc; - $societestatic->id=$obj->socid; - $societestatic->name=$obj->name; - $societestatic->email=$obj->email; - $societestatic->client=0; - $societestatic->fournisseur=1; + $societestatic->id = $obj->socid; + $societestatic->name = $obj->name; + $societestatic->email = $obj->email; + $societestatic->client = 0; + $societestatic->fournisseur = 1; $societestatic->code_client = $obj->code_client; $societestatic->code_fournisseur = $obj->code_fournisseur; $societestatic->code_compta = $obj->code_compta; @@ -1027,20 +1027,20 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print ''; print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; print ''; $total += $obj->total_ht; - $total_ttc += $obj->total_ttc; - $totalam += $obj->am; + $total_ttc += $obj->total_ttc; + $totalam += $obj->am; $i++; } - print ''; + print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -1048,8 +1048,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- } else { - $colspan=6; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + $colspan = 6; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''; } print '
    '.$langs->trans("BillsSuppliersUnpaid", $num).' '.$num.''.$langs->trans("DateDue").''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("Paid").' '.$societestatic->getNomUrl(1, 'supplier', 44).''.dol_print_date($db->jdate($obj->date_lim_reglement), 'day').''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->am).''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3).'
    '.$langs->trans("Total").'   ('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).')
    '.$langs->trans("Total").'   ('.$langs->trans("RemainderToPay").': '.price($total_ttc - $totalam).')  '.price($total).''.price($total).''.price($total_ttc).''.price($totalam).' 
    '.$langs->trans("NoInvoice").'

    '; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 6ccb76e95e5..64a116c5ae4 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -37,15 +37,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array('compta', 'bills')); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); -$mode=GETPOST("mode", 'alpha'); -$year=GETPOST("year", 'int'); -$filtre=GETPOST("filtre", 'alpha'); -if (! $year && $mode != 'sconly') { $year=date("Y", time()); } +$mode = GETPOST("mode", 'alpha'); +$year = GETPOST("year", 'int'); +$filtre = GETPOST("filtre", 'alpha'); +if (!$year && $mode != 'sconly') { $year = date("Y", time()); } -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -53,8 +53,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="pc.datep"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "pc.datep"; +if (!$sortorder) $sortorder = "DESC"; /* @@ -62,21 +62,21 @@ if (! $sortorder) $sortorder="DESC"; */ $tva_static = new Tva($db); -$socialcontrib=new ChargeSociales($db); -$payment_sc_static=new PaymentSocialContribution($db); +$socialcontrib = new ChargeSociales($db); +$payment_sc_static = new PaymentSocialContribution($db); $sal_static = new PaymentSalary($db); llxHeader('', $langs->trans("SpecialExpensesArea")); -$title=$langs->trans("SpecialExpensesArea"); -if ($mode == 'sconly') $title=$langs->trans("SocialContributionsPayments"); +$title = $langs->trans("SpecialExpensesArea"); +if ($mode == 'sconly') $title = $langs->trans("SocialContributionsPayments"); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($mode == 'sconly') $param='&mode=sconly'; -if ($sortfield) $param.='&sortfield='.$sortfield; -if ($sortorder) $param.='&sortorder='.$sortorder; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($mode == 'sconly') $param = '&mode=sconly'; +if ($sortfield) $param .= '&sortfield='.$sortfield; +if ($sortorder) $param .= '&sortorder='.$sortorder; print '
    '; @@ -90,7 +90,7 @@ print ''; if ($mode != 'sconly') { - $center=($year?''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."":""); + $center = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); } else @@ -98,7 +98,7 @@ else print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit); } -if ($year) $param.='&year='.$year; +if ($year) $param .= '&year='.$year; if ($mode != 'sconly') { @@ -106,12 +106,12 @@ if ($mode != 'sconly') print "
    "; } -if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { // Social contributions only if ($mode != 'sconly') { - print load_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("SocialContributionsPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); } print ''; @@ -127,15 +127,15 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print "\n"; $sql = "SELECT c.id, c.libelle as type_label,"; - $sql.= " cs.rowid, cs.libelle as label, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; - $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment,"; - $sql.= " pct.code as payment_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; - $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs,"; - $sql.= " ".MAIN_DB_PREFIX."paiementcharge as pc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; - $sql.= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid"; - $sql.= " AND cs.entity = ".$conf->entity; + $sql .= " cs.rowid, cs.libelle as label, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; + $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment,"; + $sql .= " pct.code as payment_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; + $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs,"; + $sql .= " ".MAIN_DB_PREFIX."paiementcharge as pc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; + $sql .= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid"; + $sql .= " AND cs.entity = ".$conf->entity; if ($year > 0) { $sql .= " AND ("; @@ -145,12 +145,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; $sql .= ")"; } - if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); //$sql.= $db->plimit($limit+1,$offset); //print $sql; dol_syslog("compta/sociales/payments.php: select payment", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -163,8 +163,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $obj = $db->fetch_object($resql); - $payment_sc_static->id=$obj->pid; - $payment_sc_static->ref=$obj->pid; + $payment_sc_static->id = $obj->pid; + $payment_sc_static->ref = $obj->pid; print ''; // Ref payment @@ -177,16 +177,16 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print $obj->num_payment.''; // Label print ''; // Type print ''; // Date - $date=$obj->periode; - if (empty($date)) $date=$obj->date_ech; + $date = $obj->periode; + if (empty($date)) $date = $obj->date_ech; print ''; // Expected to pay print ''; @@ -202,7 +202,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $i++; } print ''; - print ''; // A total here has no sense + print ''; // A total here has no sense print ''; print ''; print ''; @@ -217,33 +217,33 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) } // VAT -if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { print "
    "; $tva = new Tva($db); - print load_fiche_titre($langs->trans("VATPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("VATPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm"; - $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv"; - $sql.= " WHERE pv.entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as pv"; + $sql .= " WHERE pv.entity = ".$conf->entity; if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } - if (preg_match('/^pv\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^pv\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print '
    '; - $socialcontrib->id=$obj->rowid; - $socialcontrib->ref=$obj->rowid; - $socialcontrib->label=$obj->label; + $socialcontrib->id = $obj->rowid; + $socialcontrib->ref = $obj->rowid; + $socialcontrib->label = $obj->label; print $socialcontrib->getNomUrl(1, '20'); print ''.$obj->type_label.''.dol_print_date($date, 'day').''.price($obj->total).'
    '.$langs->trans("Total").'   
    '; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder); @@ -268,8 +268,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print '"; // Ref payment - $tva_static->id=$obj->rowid; - $tva_static->ref=$obj->rowid; + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; print '\n"; print '\n"; @@ -296,55 +296,55 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) } // Localtax -if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") +if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { - $j=1; - $numlt=3; + $j = 1; + $numlt = 3; } -elseif($mysoc->localtax1_assuj=="1") +elseif ($mysoc->localtax1_assuj == "1") { - $j=1; - $numlt=2; + $j = 1; + $numlt = 2; } -elseif($mysoc->localtax2_assuj=="1") +elseif ($mysoc->localtax2_assuj == "1") { - $j=2; - $numlt=3; + $j = 2; + $numlt = 3; } else { - $j=0; - $numlt=0; + $j = 0; + $numlt = 0; } -while($j<$numlt) +while ($j < $numlt) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { print "
    "; $tva = new Tva($db); - print load_fiche_titre($langs->transcountry(($j==1?"LT1Payments":"LT2Payments"), $mysoc->country_code).($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->transcountry(($j == 1 ? "LT1Payments" : "LT2Payments"), $mysoc->country_code).($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp"; - $sql.= " FROM ".MAIN_DB_PREFIX."localtax as pv"; - $sql.= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j ; + $sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv"; + $sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j; if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } - if (preg_match('/^pv/', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^pv/', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print '
    '.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm), 'day')."
    '; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="120"', $sortfield, $sortorder); @@ -369,8 +369,8 @@ while($j<$numlt) print '"; // Ref payment - $tva_static->id=$obj->rowid; - $tva_static->ref=$obj->rowid; + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; print '\n"; print '\n"; @@ -399,33 +399,33 @@ while($j<$numlt) // Payment Salary -if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) +if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { $sal = new PaymentSalary($db); print "
    "; - print load_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("SalariesPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE s.entity IN (".getEntity('user').")"; - $sql.= " AND u.rowid = s.fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE s.entity IN (".getEntity('user').")"; + $sql .= " AND u.rowid = s.fk_user"; if ($year > 0) { - $sql.= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')"; + $sql .= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')"; } - if (preg_match('/^s\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^s\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print '
    '.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dp), 'day')."
    '; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "s.dateep", "", $param, 'width="140px"', $sortfield, $sortorder); @@ -448,11 +448,11 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) print "\n"; - print '"; + print '"; // Ref payment - $sal_static->id=$obj->rowid; - $sal_static->ref=$obj->rowid; + $sal_static->id = $obj->rowid; + $sal_static->ref = $obj->rowid; print '\n"; print '\n"; @@ -462,7 +462,7 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) $i++; } print ''; - print ''; // A total here has no sense + print ''; // A total here has no sense print ''; print ''; print '"; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index f72edeb3a34..741d106ab48 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -48,12 +48,12 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'users', 'other', 'commercial')); -$mesg=''; $error=0; $errors=array(); +$mesg = ''; $error = 0; $errors = array(); -$action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); -$confirm = GETPOST('confirm', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); -$id = GETPOST('id', 'int'); +$action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); +$confirm = GETPOST('confirm', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$id = GETPOST('id', 'int'); $socid = GETPOST('socid', 'int'); $object = new Contact($db); @@ -66,9 +66,9 @@ $socialnetworks = getArrayOfSocialNetworks(); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); -$objcanvas=null; -$canvas = (! empty($object->canvas)?$object->canvas:GETPOST("canvas")); -if (! empty($canvas)) +$objcanvas = null; +$canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); @@ -120,30 +120,30 @@ if (empty($reshook)) // Creation user $nuser = new User($db); - $result=$nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha) + $result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha) if ($result > 0) { - $result2=$nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) + $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) if ($result2) { $db->commit(); } else { - $error=$nuser->error; $errors=$nuser->errors; + $error = $nuser->error; $errors = $nuser->errors; $db->rollback(); } } else { - $error=$nuser->error; $errors=$nuser->errors; + $error = $nuser->error; $errors = $nuser->errors; $db->rollback(); } } else { - $error=$object->error; $errors=$object->errors; + $error = $object->error; $errors = $object->errors; } } @@ -152,7 +152,7 @@ if (empty($reshook)) if ($action == 'disable') { $object->fetch($id); - if ($object->setstatus(0)<0) + if ($object->setstatus(0) < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -167,7 +167,7 @@ if (empty($reshook)) if ($action == 'enable') { $object->fetch($id); - if ($object->setstatus(1)<0) + if ($object->setstatus(1) < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -183,41 +183,41 @@ if (empty($reshook)) { $db->begin(); - if ($canvas) $object->canvas=$canvas; + if ($canvas) $object->canvas = $canvas; - $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); + $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); $object->socid = GETPOST("socid", 'int'); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); $object->civility_code = GETPOST("civility_code", 'alpha'); $object->poste = GETPOST("poste", 'alpha'); - $object->address = GETPOST("address", 'alpha'); - $object->zip = GETPOST("zipcode", 'alpha'); - $object->town = GETPOST("town", 'alpha'); - $object->country_id = GETPOST("country_id", 'int'); - $object->state_id = GETPOST("state_id", 'int'); + $object->address = GETPOST("address", 'alpha'); + $object->zip = GETPOST("zipcode", 'alpha'); + $object->town = GETPOST("town", 'alpha'); + $object->country_id = GETPOST("country_id", 'int'); + $object->state_id = GETPOST("state_id", 'int'); //$object->jabberid = GETPOST("jabberid", 'alpha'); //$object->skype = GETPOST("skype", 'alpha'); //$object->twitter = GETPOST("twitter", 'alpha'); //$object->facebook = GETPOST("facebook", 'alpha'); //$object->linkedin = GETPOST("linkedin", 'alpha'); $object->socialnetworks = array(); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } } - $object->email = GETPOST("email", 'alpha'); - $object->no_email = GETPOST("no_email", "int"); - $object->phone_pro = GETPOST("phone_pro", 'alpha'); - $object->phone_perso = GETPOST("phone_perso", 'alpha'); - $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); - $object->fax = GETPOST("fax", 'alpha'); - $object->priv = GETPOST("priv", 'int'); - $object->note_public = GETPOST("note_public", 'none'); - $object->note_private = GETPOST("note_private", 'none'); + $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); + $object->phone_pro = GETPOST("phone_pro", 'alpha'); + $object->phone_perso = GETPOST("phone_perso", 'alpha'); + $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); + $object->fax = GETPOST("fax", 'alpha'); + $object->priv = GETPOST("priv", 'int'); + $object->note_public = GETPOST("note_public", 'none'); + $object->note_private = GETPOST("note_private", 'none'); $object->statut = 1; //Defult status to Actif // Note: Correct date should be completed with location to have exact GM time of birth. @@ -232,18 +232,18 @@ if (empty($reshook)) $action = 'create'; } - if (! GETPOST("lastname")) + if (!GETPOST("lastname")) { - $error++; $errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); + $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); $action = 'create'; } - if (! $error) + if (!$error) { - $id = $object->create($user); + $id = $object->create($user); if ($id <= 0) { - $error++; $errors=array_merge($errors, ($object->error?array($object->error):$object->errors)); + $error++; $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); $action = 'create'; } else { // Categories association @@ -253,26 +253,26 @@ if (empty($reshook)) // Add mass emailing flag into table mailing_unsubscribe if (GETPOST('no_email', 'int') && $object->email) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; - $resql=$db->query($sql); + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); if (empty($obj->nb)) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; - $resql=$db->query($sql); + $resql = $db->query($sql); } } } } } - if (! $error && $id > 0) + if (!$error && $id > 0) { $db->commit(); - if (! empty($backtopage)) $url=$backtopage; - else $url='card.php?id='.$id; + if (!empty($backtopage)) $url = $backtopage; + else $url = 'card.php?id='.$id; header("Location: ".$url); exit; } @@ -284,10 +284,10 @@ if (empty($reshook)) if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) { - $result=$object->fetch($id); + $result = $object->fetch($id); $object->oldcopy = clone $object; - $object->old_lastname = GETPOST("old_lastname"); + $object->old_lastname = GETPOST("old_lastname"); $object->old_firstname = GETPOST("old_firstname"); $result = $object->delete(); @@ -310,17 +310,17 @@ if (empty($reshook)) } } - if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) + if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) { if (empty($_POST["lastname"])) { - $error++; $errors=array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); + $error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); $action = 'edit'; } - if (! $error) + if (!$error) { - $contactid=GETPOST("contactid", 'int'); + $contactid = GETPOST("contactid", 'int'); $object->fetch($contactid); // Photo save @@ -328,8 +328,8 @@ if (empty($reshook)) $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if (GETPOST('deletephoto') && $object->photo) { - $fileimg=$dir.'/'.$object->photo; - $dirthumbs=$dir.'/thumbs'; + $fileimg = $dir.'/'.$object->photo; + $dirthumbs = $dir.'/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); $object->photo = ''; @@ -342,10 +342,10 @@ if (empty($reshook)) if (@is_dir($dir)) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (! $result > 0) + if (!$result > 0) { $errors[] = "ErrorFailedToSaveFile"; } @@ -365,7 +365,7 @@ if (empty($reshook)) } else { - switch($_FILES['photo']['error']) + switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form @@ -379,49 +379,49 @@ if (empty($reshook)) $object->oldcopy = clone $object; - $object->old_lastname = GETPOST("old_lastname", 'alpha'); - $object->old_firstname = GETPOST("old_firstname", 'alpha'); + $object->old_lastname = GETPOST("old_lastname", 'alpha'); + $object->old_firstname = GETPOST("old_firstname", 'alpha'); - $object->socid = GETPOST("socid", 'int'); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->civility_code = GETPOST("civility_code", 'alpha'); - $object->poste = GETPOST("poste", 'alpha'); + $object->socid = GETPOST("socid", 'int'); + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); + $object->civility_code = GETPOST("civility_code", 'alpha'); + $object->poste = GETPOST("poste", 'alpha'); - $object->address = GETPOST("address", 'alpha'); - $object->zip = GETPOST("zipcode", 'alpha'); - $object->town = GETPOST("town", 'alpha'); + $object->address = GETPOST("address", 'alpha'); + $object->zip = GETPOST("zipcode", 'alpha'); + $object->town = GETPOST("town", 'alpha'); $object->state_id = GETPOST("state_id", 'int'); $object->country_id = GETPOST("country_id", 'int'); - $object->email = GETPOST("email", 'alpha'); - $object->no_email = GETPOST("no_email", "int"); + $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); //$object->jabberid = GETPOST("jabberid", 'alpha'); //$object->skype = GETPOST("skype", 'alpha'); //$object->twitter = GETPOST("twitter", 'alpha'); //$object->facebook = GETPOST("facebook", 'alpha'); //$object->linkedin = GETPOST("linkedin", 'alpha'); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } } - $object->phone_pro = GETPOST("phone_pro", 'alpha'); - $object->phone_perso = GETPOST("phone_perso", 'alpha'); - $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); - $object->fax = GETPOST("fax", 'alpha'); - $object->priv = GETPOST("priv", 'int'); - $object->note_public = GETPOST("note_public", 'none'); - $object->note_private = GETPOST("note_private", 'none'); - $object->roles = GETPOST("roles", 'array'); + $object->phone_pro = GETPOST("phone_pro", 'alpha'); + $object->phone_perso = GETPOST("phone_perso", 'alpha'); + $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); + $object->fax = GETPOST("fax", 'alpha'); + $object->priv = GETPOST("priv", 'int'); + $object->note_public = GETPOST("note_public", 'none'); + $object->note_private = GETPOST("note_private", 'none'); + $object->roles = GETPOST("roles", 'array'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (! $error) + if (!$error) { $result = $object->update($contactid, $user); @@ -437,30 +437,30 @@ if (empty($reshook)) { if ($no_email) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; - $resql=$db->query($sql); + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $noemail = $obj->nb; if (empty($noemail)) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; - $resql=$db->query($sql); + $resql = $db->query($sql); } } } else { $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0)); - $resql=$db->query($sql); + $resql = $db->query($sql); } $object->no_email = $no_email; } - $object->old_lastname=''; - $object->old_firstname=''; + $object->old_lastname = ''; + $object->old_firstname = ''; $action = 'view'; } else @@ -471,9 +471,9 @@ if (empty($reshook)) } } - if (! $error && empty($errors)) + if (!$error && empty($errors)) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -482,9 +482,9 @@ if (empty($reshook)) } // Actions to send emails - $trigger_name='CONTACT_SENTBYMAIL'; - $paramname='id'; - $mode='emailfromcontact'; + $trigger_name = 'CONTACT_SENTBYMAIL'; + $paramname = 'id'; + $mode = 'emailfromcontact'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -494,15 +494,15 @@ if (empty($reshook)) */ -$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title=$object->lastname; -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname; +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); $form = new Form($db); $formcompany = new FormCompany($db); -$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($socid > 0) { @@ -518,11 +518,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (empty($object->error) && $id) { $object = new Contact($db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); } - $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + $objcanvas->display_canvas($action); // Show template } else { @@ -535,27 +535,27 @@ else { if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage?'&backtopage='.$backtopage:''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); } } /* * Onglets */ - $head=array(); + $head = array(); if ($id > 0) { // Si edition contact deja existant $object = new Contact($db); - $res=$object->fetch($id, $user); - if ($res<0) { + $res = $object->fetch($id, $user); + if ($res < 0) { setEventMessages($object->error, $object->errors, 'errors'); } // Show tabs $head = contact_prepare_head($object); - $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); } if ($user->rights->societe->contact->creer) @@ -565,25 +565,25 @@ else /* * Fiche en mode creation */ - $object->canvas=$canvas; + $object->canvas = $canvas; $object->state_id = GETPOST("state_id"); // We set country_id, country_code and label for the selected country - $object->country_id=$_POST["country_id"]?GETPOST("country_id"):(empty($objsoc->country_id)?$mysoc->country_id:$objsoc->country_id); + $object->country_id = $_POST["country_id"] ?GETPOST("country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id); if ($object->country_id) { - $tmparray=getCountry($object->country_id, 'all'); + $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; $object->country = $tmparray['label']; } - $title = $addcontact = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); - $linkback=''; + $title = $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $linkback = ''; print load_fiche_titre($title, $linkback, 'address'); // Show errors - dol_htmloutput_errors(is_numeric($error)?'':$error, $errors); + dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); if ($conf->use_javascript_ajax) { @@ -612,7 +612,7 @@ else print ''; print ''; print ''; - if (! empty($objsoc)) { + if (!empty($objsoc)) { print ''; } @@ -622,9 +622,9 @@ else // Name print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) @@ -647,23 +647,23 @@ else // Civility print ''; print ''; - print ''; + print ''; - $colspan=3; - if ($conf->use_javascript_ajax && $socid > 0) $colspan=2; + $colspan = 3; + if ($conf->use_javascript_ajax && $socid > 0) $colspan = 2; // Address - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party print ''; - print ''; + print ''; if ($conf->use_javascript_ajax && $socid > 0) { - $rowspan=3; + $rowspan = 3; if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++; print ''; // Zip / Town - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party print ''; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print ''; } - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->phone; // Predefined with third party - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->phone; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party // Phone / Fax print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party // Email print ''; - print ''; - if (! empty($conf->mailing->enabled)) + print ''; + if (!empty($conf->mailing->enabled)) { $noemail = ''; - if (empty($noemail) && ! empty($object->email)) + if (empty($noemail) && !empty($object->email)) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; //print $sql; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $noemail = $obj->nb; } } print ''; - print ''; + print ''; } else { @@ -752,13 +752,13 @@ else } print ''; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { print ''; print ''; print ''; print ''; } elseif (!empty($object->socialnetworks[$key])) { @@ -802,13 +802,13 @@ else // Visibility print ''; // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { - print '"; @@ -816,7 +816,7 @@ else // Contact by default if (!empty($socid)) { - print ''; + print ''; print '
    ".$obj->label."'.($obj->salary?price($obj->salary):'')."'.($obj->salary ?price($obj->salary) : '')."'.$sal_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day')."
    '.$langs->trans("Total").'  '.price($total)."
    lastname).'" autofocus="autofocus">lastname).'" autofocus="autofocus">firstname).'">
    firstname).'">
    '; - print $formcompany->select_civility(GETPOSTISSET("civility_code")?GETPOST("civility_code", 'alpha'):$object->civility_code, 'civility_code'); + print $formcompany->select_civility(GETPOSTISSET("civility_code") ?GETPOST("civility_code", 'alpha') : $object->civility_code, 'civility_code'); print '
    poste).'">poste).'">
    '; @@ -673,23 +673,23 @@ else print '
    / '; - print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha')?GETPOST("zipcode", 'alpha'):$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6).' '; - print $formcompany->select_ziptown((GETPOST("town", 'alpha')?GETPOST("town", 'alpha'):$object->town), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha') ?GETPOST("zipcode", 'alpha') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; + print $formcompany->select_ziptown((GETPOST("town", 'alpha') ?GETPOST("town", 'alpha') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
    '; - print $form->select_country((GETPOST("country_id", 'alpha')?GETPOST("country_id", 'alpha'):$object->country_id), 'country_id'); + print $form->select_country((GETPOST("country_id", 'alpha') ?GETPOST("country_id", 'alpha') : $object->country_id), 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
    '; } @@ -700,7 +700,7 @@ else if ($object->country_id) { - print $formcompany->select_state(GETPOST("state_id", 'alpha')?GETPOST("state_id", 'alpha'):$object->state_id, $object->country_code, 'state_id'); + print $formcompany->select_state(GETPOST("state_id", 'alpha') ?GETPOST("state_id", 'alpha') : $object->state_id, $object->country_code, 'state_id'); } else { @@ -709,42 +709,42 @@ else print '
    '.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePro', 'phone_pro', '', $object, 0).''.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).'
    '.img_picto('', 'object_phoning_mobile').' '.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', '', $object, 0).'
    '.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '').''.$form->selectyesno('no_email', (GETPOSTISSET("no_email")?GETPOST("no_email", 'alpha'):$noemail), 1).''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'
    '; - print ''; + print ''; print '
    '; - $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha')?GETPOST("priv", 'alpha'):$object->priv), 0); + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha') ?GETPOST("priv", 'alpha') : $object->priv), 0); print '
    ' . $form->editfieldkey('Categories', 'contcats', '', $object, 0) . ''; + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { + print '
    '.$form->editfieldkey('Categories', 'contcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, 'parent', null, null, 1); print $form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, null, null, '90%'); print "
    ' . $langs->trans("ContactByDefaultFor") . '
    '.$langs->trans("ContactByDefaultFor").''; $contactType = $object->listeTypeContacts('external', '', 1); print $form->multiselectarray('roles', $contactType); @@ -824,8 +824,8 @@ else } // Other attributes - $parameters=array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -843,7 +843,7 @@ else // Date To Birth print '
    '; - $form=new Form($db); + $form = new Form($db); if ($object->birthday) { print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0); @@ -871,7 +871,7 @@ else print '
    '; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -879,13 +879,13 @@ else else { print '     '; - print ''; + print ''; } print '
    '; print ""; } - elseif ($action == 'edit' && ! empty($id)) + elseif ($action == 'edit' && !empty($id)) { /* * Fiche en mode edition @@ -894,16 +894,16 @@ else // We set country_id, and country_code label of the chosen country if (isset($_POST["country_id"]) || $object->country_id) { - $tmparray=getCountry($object->country_id, 'all'); - $object->country_code = $tmparray['code']; - $object->country = $tmparray['label']; + $tmparray = getCountry($object->country_id, 'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; } $objsoc = new Societe($db); $objsoc->fetch($object->socid); // Show errors - dol_htmloutput_errors(is_numeric($error)?'':$error, $errors); + dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); if ($conf->use_javascript_ajax) { @@ -935,14 +935,14 @@ else print ''; print ''; print ''; - if (! empty($backtopage)) print ''; + if (!empty($backtopage)) print ''; dol_fiche_head($head, 'card', $title, 0, 'contact'); print ''; // Ref/ID - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; - print ''; + print ''; print ''; print ''; // Firstname print ''; - print ''; + print ''; print ''; // Company @@ -964,24 +964,24 @@ else { print ''; print ''; print ''; } // Civility print ''; print ''; - print ''; + print ''; // Address print ''; print ''; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print ''; } // Phone print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; // EMail - print ''; - print ''; - if (! empty($conf->mailing->enabled)) + print ''; + print ''; + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); print ''; @@ -1043,23 +1043,23 @@ else // Unsubscribe print ''; - if (! empty($conf->mailing->enabled)) + if (!empty($conf->mailing->enabled)) { $noemail = ''; - if (empty($noemail) && ! empty($object->email)) + if (empty($noemail) && !empty($object->email)) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; //print $sql; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $noemail = $obj->nb; } } print ''; - print ''; + print ''; } else { @@ -1067,13 +1067,13 @@ else } print ''; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { print ''; print ''; print ''; print ''; } elseif (!empty($object->socialnetworks[$key])) { @@ -1117,7 +1117,7 @@ else // Visibility print ''; @@ -1141,7 +1141,7 @@ else // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print ''; + print ''; print ''; + print ''; print ''; } // Other attributes - $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('colspan' => ' colspan="3"', 'cols'=>3); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1172,31 +1172,31 @@ else $object->load_ref_elements(); - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { print ''; } - if (! empty($conf->propal->enabled)) + if (!empty($conf->propal->enabled)) { print ''; } - if (! empty($conf->contrat->enabled)) + if (!empty($conf->contrat->enabled)) { print ''; } - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { print ''; } @@ -1204,8 +1204,8 @@ else print ''; // Email - if (! empty($conf->mailing->enabled)) + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); print ''; @@ -1325,14 +1325,14 @@ else { //print 'eee'.$object->email; $noemail = $object->no_email; - if (empty($noemail) && ! empty($object->email)) + if (empty($noemail) && !empty($object->email)) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; //print $sql; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $noemail = $obj->nb; } } @@ -1352,15 +1352,15 @@ else print '
    '.$langs->trans("ID").''; print $object->ref; @@ -951,12 +951,12 @@ else // Lastname print '
    lastname).'" autofocus="autofocus">lastname).'" autofocus="autofocus">
    firstname).'">firstname).'">
    '; - print $form->select_company(GETPOST('socid', 'int')?GETPOST('socid', 'int'):($object->socid?$object->socid:-1), 'socid', '', $langs->trans("SelectThirdParty")); + print $form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : ($object->socid ? $object->socid : -1), 'socid', '', $langs->trans("SelectThirdParty")); print '
    '; - print $formcompany->select_civility(GETPOSTISSET("civility_code")?GETPOST("civility", "aZ09"):$object->civility_code, 'civility_code'); + print $formcompany->select_civility(GETPOSTISSET("civility_code") ?GETPOST("civility", "aZ09") : $object->civility_code, 'civility_code'); print '
    poste).'">
    poste).'">
    '; print '
    '; - print ''; + print ''; print '
    '; if ($conf->use_javascript_ajax) print ''.$langs->trans('CopyAddressFromSoc').'
    '; print '
    '; @@ -989,20 +989,20 @@ else // Zip / Town print '
    / '; - print $formcompany->select_ziptown((isset($_POST["zipcode"])?GETPOST("zipcode"):$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6).' '; - print $formcompany->select_ziptown((isset($_POST["town"])?GETPOST("town"):$object->town), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((isset($_POST["zipcode"]) ?GETPOST("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; + print $formcompany->select_ziptown((isset($_POST["town"]) ?GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
    '; - print $form->select_country(isset($_POST["country_id"])?GETPOST("country_id"):$object->country_id, 'country_id'); + print $form->select_country(isset($_POST["country_id"]) ?GETPOST("country_id") : $object->country_id, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
    '; } @@ -1011,25 +1011,25 @@ else print '
    '; } - print $formcompany->select_state(GETPOSTISSET('state_id')?GETPOST('state_id', 'alpha'):$object->state_id, $object->country_code, 'state_id'); + print $formcompany->select_state(GETPOSTISSET('state_id') ?GETPOST('state_id', 'alpha') : $object->state_id, $object->country_code, 'state_id'); print '
    '.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePro', 'phone_pro', GETPOST('phone_pro', 'alpha'), $object, 0).''.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePerso', 'fax', GETPOST('phone_perso', 'alpha'), $object, 0).'
    '.img_picto('', 'object_phoning_mobile').' '.$form->editfieldkey('PhoneMobile', 'phone_mobile', GETPOST('phone_mobile', 'alpha'), $object, 0, 'string', '').''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).'
    '.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).'
    '.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''.$langs->trans("NbOfEMailingsSend").'
    '.$form->selectyesno('no_email', (GETPOSTISSET("no_email")?GETPOST("no_email", 'alpha'):$noemail), 1).''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'
    '; - print ''; + print ''; print '
    '; - $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); print $form->selectarray('priv', $selectarray, $object->priv, 0); print '
    ' . $form->editfieldkey('Categories', 'contcats', '', $object, 0) . '
    '.$form->editfieldkey('Categories', 'contcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, null, null, null, 1); $c = new Categorie($db); @@ -1155,15 +1155,15 @@ else // Contact by default if (!empty($object->socid)) { - print '
    ' . $langs->trans("ContactByDefaultFor") . '
    '.$langs->trans("ContactByDefaultFor").''; print $formcompany->showRoles("roles", $object, 'edit', $object->roles); print '
    '.$langs->trans("ContactForOrders").''; - print $object->ref_commande?$object->ref_commande:$langs->trans("NoContactForAnyOrder"); + print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder"); print '
    '.$langs->trans("ContactForProposals").''; - print $object->ref_propal?$object->ref_propal:$langs->trans("NoContactForAnyProposal"); + print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); print '
    '.$langs->trans("ContactForContracts").''; - print $object->ref_contrat?$object->ref_contrat:$langs->trans("NoContactForAnyContract"); + print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); print '
    '.$langs->trans("ContactForInvoices").''; - print $object->ref_facturation?$object->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); print '
    '.$langs->trans("DolibarrLogin").''; if ($object->user_id) { - $dolibarr_user=new User($db); - $result=$dolibarr_user->fetch($object->user_id); + $dolibarr_user = new User($db); + $result = $dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); } else print $langs->trans("NoDolibarrAccess"); @@ -1242,14 +1242,14 @@ else } } - if (! empty($id) && $action != 'edit' && $action != 'create') + if (!empty($id) && $action != 'edit' && $action != 'create') { $objsoc = new Societe($db); // View mode // Show errors - dol_htmloutput_errors(is_numeric($error)?'':$error, $errors); + dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); dol_fiche_head($head, 'card', $title, -1, 'contact'); @@ -1257,15 +1257,15 @@ else { // Full firstname and lastname separated with a dot : firstname.lastname include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $login=dol_buildlogin($object->lastname, $object->firstname); + $login = dol_buildlogin($object->lastname, $object->firstname); - $generated_password=''; - if (! $ldap_sid) // TODO ldap_sid ? + $generated_password = ''; + if (!$ldap_sid) // TODO ldap_sid ? { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generated_password=getRandomPassword(false); + $generated_password = getRandomPassword(false); } - $password=$generated_password; + $password = $generated_password; // Create a form array $formquestion = array( @@ -1273,27 +1273,27 @@ else array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password), //array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External'))) ); - $text=$langs->trans("ConfirmCreateContact").'
    '; - if (! empty($conf->societe->enabled)) + $text = $langs->trans("ConfirmCreateContact").'
    '; + if (!empty($conf->societe->enabled)) { - if ($object->socid > 0) $text.=$langs->trans("UserWillBeExternalUser"); - else $text.=$langs->trans("UserWillBeInternalUser"); + if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser"); + else $text .= $langs->trans("UserWillBeInternalUser"); } print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); } $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc->fetch($object->socid); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : '; - if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1, 'contact'); - else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany"); + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); @@ -1313,7 +1313,7 @@ else print '
    '.$langs->trans("PostOrFunction").''.$object->poste.'
    '.$langs->trans("NbOfEMailingsSend").'
    '; // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { - print ''; + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { + print ''; print ''; } if (!empty($object->socid)) { - print ''; + print ''; print ''; @@ -1368,49 +1368,49 @@ else // Other attributes $cols = 3; - $parameters=array('socid'=>$socid); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('socid'=>$socid); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; $object->load_ref_elements(); - if (! empty($conf->propal->enabled)) + if (!empty($conf->propal->enabled)) { print ''; } - if (! empty($conf->commande->enabled) || ! empty($conf->expedition->enabled)) + if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) { print ''; } - if (! empty($conf->contrat->enabled)) + if (!empty($conf->contrat->enabled)) { print ''; } - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { print ''; } print ''; // Ref - print ''; + print ''; // Label print ''; // Date start @@ -856,7 +856,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel */ function show_contacts($conf, $langs, $db, $object, $backtopage = '') { - global $user,$conf,$extrafields,$hookmanager; + global $user, $conf, $extrafields, $hookmanager; global $contextpage; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -869,12 +869,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $page = GETPOST('page', 'int'); $search_status = GETPOST("search_status", 'int'); - if ($search_status=='') $search_status=1; // always display active customer first + if ($search_status == '') $search_status = 1; // always display active customer first $search_name = GETPOST("search_name", 'alpha'); $search_address = GETPOST("search_address", 'alpha'); $search_poste = GETPOST("search_poste", 'alpha'); - $search_roles = GETPOST("search_roles", 'array'); + $search_roles = GETPOST("search_roles", 'array'); $socialnetworks = getArrayOfSocialNetworks(); @@ -902,10 +902,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } } - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="t.lastname"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "t.lastname"; - if (! empty($conf->clicktodial->enabled)) + if (!empty($conf->clicktodial->enabled)) { $user->fetch_clicktodial(); // lecture des infos de clicktodial du user } @@ -915,17 +915,17 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $extrafields->fetch_name_optionals_label($contactstatic->table_element); - $contactstatic->fields=array( - 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), - 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), - 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), - 'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40), - 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), + $contactstatic->fields = array( + 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), + 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), + 'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40), + 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), ); // Definition of fields for list - $arrayfields=array( - 't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'position'=>1), + $arrayfields = array( + 't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'position'=>1), 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), @@ -935,59 +935,59 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') // Extra fields if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) { - foreach($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) { - $arrayfields["ef.".$key]=array( + if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) { + $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key]<0)?0:1), - 'position'=>1000+$extrafields->attributes[$contactstatic->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key])); + 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key] < 0) ? 0 : 1), + 'position'=>1000 + $extrafields->attributes[$contactstatic->table_element]['pos'][$key], + 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key])); } } } // Initialize array of search criterias - $search=array(); - foreach($arrayfields as $key => $val) + $search = array(); + foreach ($arrayfields as $key => $val) { $queryName = 'search_'.substr($key, 2); - if (GETPOST($queryName, 'alpha')){ - $search[substr($key, 2)]=GETPOST($queryName, 'alpha'); + if (GETPOST($queryName, 'alpha')) { + $search[substr($key, 2)] = GETPOST($queryName, 'alpha'); } } - $search_array_options=$extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_'); + $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_'); // 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 + 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_status = ''; + $search_status = ''; $search_name = ''; $search_roles = array(); $search_address = ''; $search_poste = ''; $search = array(); - $search_array_options=array(); + $search_array_options = array(); - foreach($contactstatic->fields as $key => $val) + foreach ($contactstatic->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } } $contactstatic->fields = dol_sort_array($contactstatic->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->societe->contact->creer) { - $addcontact = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); - $newcardbutton.= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); + $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $newcardbutton .= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); } print "\n"; - $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany")); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany")); print load_fiche_titre($title, $newcardbutton, ''); print ''; @@ -998,23 +998,23 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print ''; print ''; - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print "\n".'
    ' . $langs->trans("Categories") . '
    '.$langs->trans("Categories").''; print $form->showCategories($object->id, 'contact', 1); print '
    ' . $langs->trans("ContactByDefaultFor") . '
    '.$langs->trans("ContactByDefaultFor").''; print $formcompany->showRoles("roles", $object, 'view'); print '
    '.$langs->trans("ContactForProposals").''; - print $object->ref_propal?$object->ref_propal:$langs->trans("NoContactForAnyProposal"); + print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); print '
    '; - if (! empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } + if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders"); print ''; - $none=$langs->trans("NoContactForAnyOrder"); - if (! empty($conf->expedition->enabled)) { $none=$langs->trans("NoContactForAnyOrderOrShipments"); } - print $object->ref_commande?$object->ref_commande:$none; + $none = $langs->trans("NoContactForAnyOrder"); + if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); } + print $object->ref_commande ? $object->ref_commande : $none; print '
    '.$langs->trans("ContactForContracts").''; - print $object->ref_contrat?$object->ref_contrat:$langs->trans("NoContactForAnyContract"); + print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); print '
    '.$langs->trans("ContactForInvoices").''; - print $object->ref_facturation?$object->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); print '
    '.$langs->trans("DolibarrLogin").''; if ($object->user_id) { - $dolibarr_user=new User($db); - $result=$dolibarr_user->fetch($object->user_id); + $dolibarr_user = new User($db); + $result = $dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); } else print $langs->trans("NoDolibarrAccess"); @@ -1434,11 +1434,11 @@ else // Barre d'actions print '
    '; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && $action!='presend') + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && $action != 'presend') { - if (! empty($object->email)) + if (!empty($object->email)) { $langs->load("mails"); print ''; @@ -1454,7 +1454,7 @@ else print ''.$langs->trans('Modify').''; } - if (! $object->user_id && $user->rights->user->user->creer) + if (!$object->user_id && $user->rights->user->user->creer) { print ''.$langs->trans("CreateDolibarrLogin").''; } @@ -1473,15 +1473,15 @@ else // Delete if ($user->rights->societe->contact->supprimer) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } } print "
    "; // Presend form - $modelmail='contact'; - $defaulttopic='Information'; + $modelmail = 'contact'; + $defaulttopic = 'Information'; $diroutput = $conf->contact->dir_output; $trackid = 'con'.$object->id; diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 358a823dd12..fb9c607eb72 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -38,42 +38,42 @@ function bank_prepare_head(Account $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/compta/bank/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'bankname'; $h++; - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/bankentries_list.php?id=" . $object->id; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/bankentries_list.php?id=".$object->id; $head[$h][1] = $langs->trans("BankTransactions"); $head[$h][2] = 'journal'; $h++; // if ($conf->global->MAIN_FEATURES_LEVEL >= 1) // { - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/treso.php?account=" . $object->id; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/treso.php?account=".$object->id; $head[$h][1] = $langs->trans("PlannedTransactions"); $head[$h][2] = 'cash'; $h++; // } - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/annuel.php?account=" . $object->id; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/annuel.php?account=".$object->id; $head[$h][1] = $langs->trans("IOMonthlyReporting"); $head[$h][2] = 'annual'; $h++; - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/graph.php?account=" . $object->id; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/graph.php?account=".$object->id; $head[$h][1] = $langs->trans("Graph"); $head[$h][2] = 'graph'; $h++; if ($object->courant != Account::TYPE_CASH) { - $nbReceipts=0; + $nbReceipts = 0; // List of all standing receipts $sql = "SELECT COUNT(DISTINCT(b.num_releve)) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.fk_account = ".$object->id; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.fk_account = ".$object->id; $resql = $db->query($sql); if ($resql) @@ -85,7 +85,7 @@ function bank_prepare_head(Account $object) $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id; $head[$h][1] = $langs->trans("AccountStatements"); - if (($nbReceipts) > 0) $head[$h][1].= ''.($nbReceipts).''; + if (($nbReceipts) > 0) $head[$h][1] .= ''.($nbReceipts).''; $head[$h][2] = 'statement'; $h++; } @@ -93,12 +93,12 @@ function bank_prepare_head(Account $object) // Attached files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/document.php?account=" . $object->id; + $nbLinks = Link::count($db, $object->element, $object->id); + $head[$h][0] = DOL_URL_ROOT."/compta/bank/document.php?account=".$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; @@ -129,12 +129,12 @@ function bank_admin_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/admin/bank.php'; + $head[$h][0] = DOL_URL_ROOT.'/admin/bank.php'; $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'general'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/admin/chequereceipts.php'; + $head[$h][0] = DOL_URL_ROOT.'/admin/chequereceipts.php'; $head[$h][1] = $langs->trans("CheckReceiptShort"); $head[$h][2] = 'checkreceipts'; $h++; @@ -167,11 +167,11 @@ function bank_admin_prepare_head($object) */ function account_statement_prepare_head($object, $num) { - global $langs, $conf, $user,$db; + global $langs, $conf, $user, $db; $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/compta/bank/releve.php?account=' . $object->id.'&num='.$num; + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/releve.php?account='.$object->id.'&num='.$num; $head[$h][1] = $langs->trans("AccountStatements"); $head[$h][2] = 'statement'; $h++; @@ -179,13 +179,13 @@ function account_statement_prepare_head($object, $num) // Attached files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->bank->dir_output . "/" . $object->id.'/'.dol_sanitizeFileName($num); + $upload_dir = $conf->bank->dir_output."/".$object->id.'/'.dol_sanitizeFileName($num); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/account_statement_document.php?account=" . $object->id."&num=".$num; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/account_statement_document.php?account=".$object->id."&num=".$num; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' '.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; @@ -223,12 +223,12 @@ function various_payment_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -293,12 +293,12 @@ function checkBanForAccount($account) if (empty($account->cle)) $account->cle = $account->cle_rib; - dol_syslog("bank.lib::checkBanForAccount account->code_banque=" . $account->code_banque . " account->code_guichet=" . $account->code_guichet . " account->number=" . $account->number . " account->cle=" . $account->cle . " account->iban=" . $account->iban . " country_code=" . $country_code, LOG_DEBUG); + dol_syslog("bank.lib::checkBanForAccount account->code_banque=".$account->code_banque." account->code_guichet=".$account->code_guichet." account->number=".$account->number." account->cle=".$account->cle." account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG); if ($country_code == 'FR') { // France rules $coef = array(62, 34, 3); // Concatenation des differents codes. - $rib = strtolower(trim($account->code_banque) . trim($account->code_guichet) . trim($account->number) . trim($account->cle)); + $rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->number).trim($account->cle)); // On remplace les eventuelles lettres par des chiffres. //$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678912345678"); //Ne marche pas $rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz", "12345678912345678923456789"); @@ -322,7 +322,7 @@ function checkBanForAccount($account) if ($country_code == 'ES') { // Spanish rules $CCC = strtolower(trim($account->number)); - $rib = strtolower(trim($account->code_banque) . trim($account->code_guichet)); + $rib = strtolower(trim($account->code_banque).trim($account->code_guichet)); $cle_rib = strtolower(checkES($rib, $CCC)); if ($cle_rib == strtolower($account->cle)) { return true; @@ -364,7 +364,7 @@ function checkES($IentOfi, $InumCta) return $keycontrol; } - $ccc = $IentOfi . $InumCta; + $ccc = $IentOfi.$InumCta; $numbers = "1234567890"; $i = 0; @@ -396,7 +396,7 @@ function checkES($IentOfi, $InumCta) $sum = 0; for ($i = 0; $i < 11; $i++) { - $sum += $values[$i] * (int) substr($InumCta, $i, 1);//int to cast result of substr to a number + $sum += $values[$i] * (int) substr($InumCta, $i, 1); //int to cast result of substr to a number } $key = 11 - $sum % 11; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2af03656a64..734810eb5e4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -55,7 +55,7 @@ function societe_prepare_head(Societe $object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); - $nbContact = 0; // TODO + $nbContact = 0; // TODO $sql = "SELECT COUNT(p.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; @@ -69,7 +69,7 @@ function societe_prepare_head(Societe $object) $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -79,22 +79,22 @@ function societe_prepare_head(Societe $object) $head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id; $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][1] = $langs->trans("ContactsAddresses"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } - if ($object->client==1 || $object->client==2 || $object->client==3) + if ($object->client == 1 || $object->client == 2 || $object->client == 3) { $head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id; $head[$h][1] = ''; - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client==2 || $object->client==3)) $head[$h][1] .= $langs->trans("Prospect"); - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client==3) $head[$h][1] .= ' | '; - if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client==1 || $object->client==3)) $head[$h][1] .= $langs->trans("Customer"); + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) $head[$h][1] .= $langs->trans("Prospect"); + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client == 3) $head[$h][1] .= ' | '; + if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client == 1 || $object->client == 3)) $head[$h][1] .= $langs->trans("Customer"); $head[$h][2] = 'customer'; $h++; - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $langs->load("products"); // price @@ -104,7 +104,7 @@ function societe_prepare_head(Societe $object) $h++; } } - if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) + if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; $head[$h][1] = $langs->trans("Supplier"); @@ -112,16 +112,16 @@ function societe_prepare_head(Societe $object) $h++; } - if (! empty($conf->projet->enabled) && (!empty($user->rights->projet->lire) )) + if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) { $head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id; $head[$h][1] = $langs->trans("Projects"); $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as n"; - $sql.= " WHERE fk_soc = ".$object->id; - $sql.= " AND entity IN (".getEntity('project').")"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."projet as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $sql .= " AND entity IN (".getEntity('project').")"; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -129,20 +129,20 @@ function societe_prepare_head(Societe $object) while ($i < $num) { $obj = $db->fetch_object($resql); - $nbNote=$obj->nb; + $nbNote = $obj->nb; $i++; } } else { dol_print_error($db); } - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'project'; $h++; } // Tab to link resources - if (! empty($conf->resource->enabled) && ! empty($conf->global->RESOURCE_ON_THIRDPARTIES)) + if (!empty($conf->resource->enabled) && !empty($conf->global->RESOURCE_ON_THIRDPARTIES)) { $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=societe&element_id='.$object->id; $head[$h][1] = $langs->trans("Resources"); @@ -150,10 +150,10 @@ function societe_prepare_head(Societe $object) $h++; } - if (! empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) + if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { // Tab to accountancy - if (! empty($conf->accounting->enabled) && $object->client>0) + if (!empty($conf->accounting->enabled) && $object->client > 0) { $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_customer.php?socid='.$object->id; $head[$h][1] = $langs->trans("TabLetteringCustomer"); @@ -162,7 +162,7 @@ function societe_prepare_head(Societe $object) } // Tab to accountancy - if (! empty($conf->accounting->enabled) && $object->fournisseur>0) + if (!empty($conf->accounting->enabled) && $object->fournisseur > 0) { $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_supplier.php?socid='.$object->id; $head[$h][1] = $langs->trans("TabLetteringSupplier"); @@ -172,7 +172,7 @@ function societe_prepare_head(Societe $object) } // Related items - if ((! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->ficheinter->enabled) || ! empty($conf->fournisseur->enabled)) + if ((!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->fournisseur->enabled)) && empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) { $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; @@ -184,31 +184,31 @@ function societe_prepare_head(Societe $object) // Bank accounts if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) { - $nbBankAccount=0; - $foundonexternalonlinesystem=0; + $nbBankAccount = 0; + $foundonexternalonlinesystem = 0; $langs->load("banks"); //$title = $langs->trans("BankAccounts"); $title = $langs->trans("PaymentInformation"); - if (! empty($conf->stripe->enabled)) + if (!empty($conf->stripe->enabled)) { //$langs->load("stripe"); //$title = $langs->trans("BankAccountsAndGateways"); $servicestatus = 0; - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) $servicestatus = 1; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) $servicestatus = 1; include_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; $societeaccount = new SocieteAccount($db); - $stripecu = $societeaccount->getCustomerAccount($object->id, 'stripe', $servicestatus); // Get thirdparty cu_... + $stripecu = $societeaccount->getCustomerAccount($object->id, 'stripe', $servicestatus); // Get thirdparty cu_... if ($stripecu) $foundonexternalonlinesystem++; } $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; - $sql.= " WHERE fk_soc = ".$object->id; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -216,7 +216,7 @@ function societe_prepare_head(Societe $object) while ($i < $num) { $obj = $db->fetch_object($resql); - $nbBankAccount=$obj->nb; + $nbBankAccount = $obj->nb; $i++; } } @@ -226,23 +226,23 @@ function societe_prepare_head(Societe $object) //if (! empty($conf->stripe->enabled) && $nbBankAccount > 0) $nbBankAccount = '...'; // No way to know exact number - $head[$h][0] = DOL_URL_ROOT .'/societe/paymentmodes.php?socid='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; $head[$h][1] = $title; - if ($foundonexternalonlinesystem) $head[$h][1].= ' ...'; - elseif ($nbBankAccount > 0) $head[$h][1].= ''.$nbBankAccount.''; + if ($foundonexternalonlinesystem) $head[$h][1] .= ' ...'; + elseif ($nbBankAccount > 0) $head[$h][1] .= ''.$nbBankAccount.''; $head[$h][2] = 'rib'; $h++; } - if (! empty($conf->website->enabled) && (! empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) + if (!empty($conf->website->enabled) && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) { $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.$object->id; $head[$h][1] = $langs->trans("WebSiteAccounts"); $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_account as n"; - $sql.= " WHERE fk_soc = ".$object->id.' AND fk_website > 0'; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as n"; + $sql .= " WHERE fk_soc = ".$object->id.' AND fk_website > 0'; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -250,14 +250,14 @@ function societe_prepare_head(Societe $object) while ($i < $num) { $obj = $db->fetch_object($resql); - $nbNote=$obj->nb; + $nbNote = $obj->nb; $i++; } } else { dol_print_error($db); } - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'website'; $h++; } @@ -271,13 +271,13 @@ function societe_prepare_head(Societe $object) if ($user->socid == 0) { // Notifications - if (! empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) { $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n"; - $sql.= " WHERE fk_soc = ".$object->id; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -285,7 +285,7 @@ function societe_prepare_head(Societe $object) while ($i < $num) { $obj = $db->fetch_object($resql); - $nbNote=$obj->nb; + $nbNote = $obj->nb; $i++; } } @@ -295,41 +295,41 @@ function societe_prepare_head(Societe $object) $head[$h][0] = DOL_URL_ROOT.'/societe/notify/card.php?socid='.$object->id; $head[$h][1] = $langs->trans("Notifications"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'notify'; $h++; } // Notes $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/societe/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; // Attached files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id ; + $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id; $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; } $head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; - $head[$h][1].= $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + $head[$h][1] .= $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; @@ -430,46 +430,46 @@ function societe_admin_prepare_head() */ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', $entconv = 1, $searchlabel = '') { - global $db,$langs; + global $db, $langs; - $result=''; + $result = ''; // Check parameters if (empty($searchkey) && empty($searchlabel)) { - if ($withcode === 'all') return array('id'=>'','code'=>'','label'=>''); + if ($withcode === 'all') return array('id'=>'', 'code'=>'', 'label'=>''); else return ''; } - if (! is_object($dbtouse)) $dbtouse=$db; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($dbtouse)) $dbtouse = $db; + if (!is_object($outputlangs)) $outputlangs = $langs; $sql = "SELECT rowid, code, label FROM ".MAIN_DB_PREFIX."c_country"; - if (is_numeric($searchkey)) $sql.= " WHERE rowid=".$searchkey; - elseif (! empty($searchkey)) $sql.= " WHERE code='".$db->escape($searchkey)."'"; - else $sql.= " WHERE label='".$db->escape($searchlabel)."'"; + if (is_numeric($searchkey)) $sql .= " WHERE rowid=".$searchkey; + elseif (!empty($searchkey)) $sql .= " WHERE code='".$db->escape($searchkey)."'"; + else $sql .= " WHERE label='".$db->escape($searchlabel)."'"; - $resql=$dbtouse->query($sql); + $resql = $dbtouse->query($sql); if ($resql) { $obj = $dbtouse->fetch_object($resql); if ($obj) { - $label=((! empty($obj->label) && $obj->label!='-')?$obj->label:''); + $label = ((!empty($obj->label) && $obj->label != '-') ? $obj->label : ''); if (is_object($outputlangs)) { $outputlangs->load("dict"); - if ($entconv) $label=($obj->code && ($outputlangs->trans("Country".$obj->code)!="Country".$obj->code))?$outputlangs->trans("Country".$obj->code):$label; - else $label=($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code))?$outputlangs->transnoentitiesnoconv("Country".$obj->code):$label; + if ($entconv) $label = ($obj->code && ($outputlangs->trans("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->trans("Country".$obj->code) : $label; + else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv("Country".$obj->code) : $label; } - if ($withcode == 1) $result=$label?"$obj->code - $label":"$obj->code"; - elseif ($withcode == 2) $result=$obj->code; - elseif ($withcode == 3) $result=$obj->rowid; - elseif ($withcode === 'all') $result=array('id'=>$obj->rowid,'code'=>$obj->code,'label'=>$label); - else $result=$label; + if ($withcode == 1) $result = $label ? "$obj->code - $label" : "$obj->code"; + elseif ($withcode == 2) $result = $obj->code; + elseif ($withcode == 3) $result = $obj->rowid; + elseif ($withcode === 'all') $result = array('id'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$label); + else $result = $label; } else { - $result='NotDefined'; + $result = 'NotDefined'; } $dbtouse->free($resql); return $result; @@ -495,58 +495,58 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', */ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlangs = '', $entconv = 1) { - global $db,$langs; + global $db, $langs; - if (! is_object($dbtouse)) $dbtouse=$db; + if (!is_object($dbtouse)) $dbtouse = $db; $sql = "SELECT d.rowid as id, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.code_region as region_code, r.nom as region_name FROM"; - $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; + $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and d.rowid=".$id; $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; $sql .= " ORDER BY c.code, d.code_departement"; dol_syslog("Company.lib::getState", LOG_DEBUG); - $resql=$dbtouse->query($sql); + $resql = $dbtouse->query($sql); if ($resql) { $obj = $dbtouse->fetch_object($resql); if ($obj) { - $label=((! empty($obj->name) && $obj->name!='-')?$obj->name:''); + $label = ((!empty($obj->name) && $obj->name != '-') ? $obj->name : ''); if (is_object($outputlangs)) { $outputlangs->load("dict"); - if ($entconv) $label=($obj->code && ($outputlangs->trans("State".$obj->code)!="State".$obj->code))?$outputlangs->trans("State".$obj->code):$label; - else $label=($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code)!="State".$obj->code))?$outputlangs->transnoentitiesnoconv("State".$obj->code):$label; + if ($entconv) $label = ($obj->code && ($outputlangs->trans("State".$obj->code) != "State".$obj->code)) ? $outputlangs->trans("State".$obj->code) : $label; + else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code) != "State".$obj->code)) ? $outputlangs->transnoentitiesnoconv("State".$obj->code) : $label; } if ($withcode == 1) { if ($withregion == 1) { - return $label = $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = $obj->region_name.' - '.$obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } else { - return $label = $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = $obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } } elseif ($withcode == 2) { if ($withregion == 1) { - return $label = $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = $obj->region_name.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } else { - return $label = ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } } elseif ($withcode === 'all') { if ($withregion == 1) { - return array('id'=>$obj->id,'code'=>$obj->code,'label'=>$label,'region_code'=>$obj->region_code,'region'=>$obj->region_name); + return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label, 'region_code'=>$obj->region_code, 'region'=>$obj->region_name); } else { - return array('id'=>$obj->id,'code'=>$obj->code,'label'=>$label); + return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label); } } else { if ($withregion == 1) { - return $label = $obj->region_name . ' - ' . $label; + return $label = $obj->region_name.' - '.$label; } else { return $label; @@ -571,23 +571,23 @@ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlan */ function currency_name($code_iso, $withcode = '', $outputlangs = null) { - global $langs,$db; + global $langs, $db; - if (empty($outputlangs)) $outputlangs=$langs; + if (empty($outputlangs)) $outputlangs = $langs; $outputlangs->load("dict"); // If there is a translation, we can send immediatly the label - if ($outputlangs->trans("Currency".$code_iso)!="Currency".$code_iso) + if ($outputlangs->trans("Currency".$code_iso) != "Currency".$code_iso) { - return ($withcode?$code_iso.' - ':'').$outputlangs->trans("Currency".$code_iso); + return ($withcode ? $code_iso.' - ' : '').$outputlangs->trans("Currency".$code_iso); } // If no translation, we read table to get label by default $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies"; - $sql.= " WHERE code_iso='".$code_iso."'"; + $sql .= " WHERE code_iso='".$code_iso."'"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -595,8 +595,8 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null) if ($num) { $obj = $db->fetch_object($resql); - $label=($obj->label!='-'?$obj->label:''); - if ($withcode) return ($label==$code_iso)?"$code_iso":"$code_iso - $label"; + $label = ($obj->label != '-' ? $obj->label : ''); + if ($withcode) return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label"; else return $label; } else @@ -615,15 +615,15 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null) */ function getFormeJuridiqueLabel($code) { - global $db,$langs; + global $db, $langs; - if (! $code) return ''; + if (!$code) return ''; $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique"; - $sql.= " WHERE code='$code'"; + $sql .= " WHERE code='$code'"; dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -631,7 +631,7 @@ function getFormeJuridiqueLabel($code) if ($num) { $obj = $db->fetch_object($resql); - $label=($obj->libelle!='-' ? $obj->libelle : ''); + $label = ($obj->libelle != '-' ? $obj->libelle : ''); return $label; } else @@ -654,43 +654,43 @@ function getCountriesInEEC() // List of all country codes that are in europe for european vat rules // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9 - $country_code_in_EEC=array( - 'AT', // Austria - 'BE', // Belgium - 'BG', // Bulgaria - 'CY', // Cyprus - 'CZ', // Czech republic - 'DE', // Germany - 'DK', // Danemark - 'EE', // Estonia - 'ES', // Spain - 'FI', // Finland - 'FR', // France - 'GB', // United Kingdom - 'GR', // Greece - 'HR', // Croatia - 'NL', // Holland - 'HU', // Hungary - 'IE', // Ireland - 'IM', // Isle of Man - Included in UK - 'IT', // Italy - 'LT', // Lithuania - 'LU', // Luxembourg - 'LV', // Latvia - 'MC', // Monaco - Included in France - 'MT', // Malta + $country_code_in_EEC = array( + 'AT', // Austria + 'BE', // Belgium + 'BG', // Bulgaria + 'CY', // Cyprus + 'CZ', // Czech republic + 'DE', // Germany + 'DK', // Danemark + 'EE', // Estonia + 'ES', // Spain + 'FI', // Finland + 'FR', // France + 'GB', // United Kingdom + 'GR', // Greece + 'HR', // Croatia + 'NL', // Holland + 'HU', // Hungary + 'IE', // Ireland + 'IM', // Isle of Man - Included in UK + 'IT', // Italy + 'LT', // Lithuania + 'LU', // Luxembourg + 'LV', // Latvia + 'MC', // Monaco - Included in France + 'MT', // Malta //'NO', // Norway - 'PL', // Poland - 'PT', // Portugal - 'RO', // Romania - 'SE', // Sweden - 'SK', // Slovakia - 'SI', // Slovenia - 'UK', // United Kingdom + 'PL', // Poland + 'PT', // Portugal + 'RO', // Romania + 'SE', // Sweden + 'SK', // Slovakia + 'SI', // Slovenia + 'UK', // United Kingdom //'CH', // Switzerland - No. Swizerland in not in EEC ); - if (! empty($conf->global->MAIN_COUNTRIES_IN_EEC)) + if (!empty($conf->global->MAIN_COUNTRIES_IN_EEC)) { // For example MAIN_COUNTRIES_IN_EEC = 'AT,BE,BG,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HR,NL,HU,IE,IM,IT,LT,LU,LV,MC,MT,PL,PT,RO,SE,SK,SI,UK' $country_code_in_EEC = explode(',', $conf->global->MAIN_COUNTRIES_IN_EEC); @@ -732,16 +732,16 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel { global $user; - $i = -1 ; + $i = -1; - if (! empty($conf->projet->enabled) && $user->rights->projet->lire) + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { $langs->load("projects"); - $newcardbutton=''; - if (! empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) + $newcardbutton = ''; + if (!empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) { - $newcardbutton.= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); + $newcardbutton .= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); } print "\n"; @@ -757,7 +757,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel $sql .= " AND p.entity IN (".getEntity('project').")"; $sql .= " ORDER BY p.dateo DESC"; - $result=$db->query($sql); + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); @@ -779,7 +779,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel $projecttmp = new Project($db); - $i=0; + $i = 0; while ($i < $num) { @@ -794,7 +794,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel print '
    '.img_object($langs->trans("ShowProject"), ($obj->public?'projectpub':'project'))." ".$obj->ref.''.img_object($langs->trans("ShowProject"), ($obj->public ? 'projectpub' : 'project'))." ".$obj->ref.''.$obj->title.'
    '."\n"; - $param="socid=".urlencode($object->id); - if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if (count($search_roles)>0) $param.=implode('&search_roles[]=', $search_roles); - if ($search_name != '') $param.='&search_name='.urlencode($search_name); - if ($search_poste != '') $param.='&search_poste='.urlencode($search_poste); - if ($search_address != '') $param.='&search_address='.urlencode($search_address); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = "socid=".urlencode($object->id); + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); + if (count($search_roles) > 0) $param .= implode('&search_roles[]=', $search_roles); + if ($search_name != '') $param .= '&search_name='.urlencode($search_name); + if ($search_poste != '') $param .= '&search_poste='.urlencode($search_poste); + if ($search_address != '') $param .= '&search_address='.urlencode($search_address); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo,"; @@ -1022,41 +1022,41 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; $sql .= " WHERE t.fk_soc = ".$object->id; - if ($search_status!='' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); + if ($search_status != '' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name); if ($search_poste) $sql .= natural_search('t.poste', $search_poste); if ($search_address) { $sql .= natural_search($searchAddressPhoneDBFields, $search_address); } - if (count($search_roles)>0) { + if (count($search_roles) > 0) { $sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } // Add where from extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; - if ($sortfield == "t.name") $sql.=" ORDER BY t.lastname $sortorder, t.firstname $sortorder"; - else $sql.= " ORDER BY $sortfield $sortorder"; + if ($sortfield == "t.name") $sql .= " ORDER BY t.lastname $sortorder, t.firstname $sortorder"; + else $sql .= " ORDER BY $sortfield $sortorder"; dol_syslog('core/lib/company.lib.php :: show_contacts', LOG_DEBUG); $result = $db->query($sql); - if (! $result) dol_print_error($db); + if (!$result) dol_print_error($db); $num = $db->num_rows($result); // Fields title search // -------------------------------------------------------------------- print ''; - foreach($contactstatic->fields as $key => $val) + foreach ($contactstatic->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked']) || ! empty($arrayfields['sc.'.$key]['checked'])) + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked']) || !empty($arrayfields['sc.'.$key]['checked'])) { - print ''; - foreach($contactstatic->fields as $key => $val) + foreach ($contactstatic->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; - if ($key == 'role') $align.=($align?' ':'').'left'; - if (! empty($arrayfields['sc.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'sc.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; + if ($key == 'role') $align .= ($align ? ' ' : '').'left'; + if (!empty($arrayfields['sc.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'sc.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; } } // Extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; print ''."\n"; @@ -1140,14 +1140,14 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $contactstatic->setGenderFromCivility(); $contactstatic->fetch_optionals(); - $resultRole=$contactstatic->fetchRoles(); - if ($resultRole<0) { + $resultRole = $contactstatic->fetchRoles(); + if ($resultRole < 0) { setEventMessages(null, $contactstatic->errors, 'errors'); } if (is_array($contactstatic->array_options)) { - foreach($contactstatic->array_options as $key => $val) + foreach ($contactstatic->array_options as $key => $val) { $obj->$key = $val; } @@ -1156,7 +1156,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print ''; // ID - if (! empty($arrayfields['t.rowid']['checked'])) + if (!empty($arrayfields['t.rowid']['checked'])) { print ''; } // Extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Actions print ''; } print "\n
    '; - if (in_array($key, array('statut'))){ - print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status); + print ''; + if (in_array($key, array('statut'))) { + print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status); } elseif (in_array($key, array('role'))) { print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles); } else { @@ -1066,12 +1066,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } } // Extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; @@ -1083,24 +1083,24 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') // Fields title label // -------------------------------------------------------------------- print '
    '; print $contactstatic->id; @@ -1164,7 +1164,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Photo - Name - if (! empty($arrayfields['t.name']['checked'])) + if (!empty($arrayfields['t.name']['checked'])) { print ''; print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1); @@ -1173,7 +1173,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Job position - if (! empty($arrayfields['t.poste']['checked'])) + if (!empty($arrayfields['t.poste']['checked'])) { print ''; if ($obj->poste) print $obj->poste; @@ -1181,7 +1181,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Address - Phone - Email - if (! empty($arrayfields['t.address']['checked'])) + if (!empty($arrayfields['t.address']['checked'])) { print ''; print $contactstatic->getBannerAddress('contact', $object); @@ -1189,7 +1189,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Role - if (! empty($arrayfields['sc.role']['checked'])) + if (!empty($arrayfields['sc.role']['checked'])) { print ''; print $formcompany->showRoles("roles", $contactstatic, 'view'); @@ -1197,20 +1197,20 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Status - if (! empty($arrayfields['t.statut']['checked'])) + if (!empty($arrayfields['t.statut']['checked'])) { print ''.$contactstatic->getLibStatut(5).''; // Add to agenda - if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { print ''; print img_object($langs->trans("Event"), "action"); @@ -1233,8 +1233,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } else { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '
    '.$langs->trans("None").'
    \n"; @@ -1260,7 +1260,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') */ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '') { - global $user,$conf; + global $user, $conf; $out = show_actions_done($conf, $langs, $db, $filterobj, $objcon, 1, $actioncode, 'todo'); @@ -1295,12 +1295,12 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin dol_include_once('/comm/action/class/actioncomm.class.php'); // Check parameters - if (! is_object($filterobj) && ! is_object($objcon)) dol_print_error('', 'BadParameter'); + if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter'); - $out=''; - $histo=array(); - $numaction = 0 ; - $now=dol_now('tzuser'); + $out = ''; + $histo = array(); + $numaction = 0; + $now = dol_now('tzuser'); // Open DSI -- Fix order by -- Begin $sortfield_list = explode(',', $sortfield); @@ -1311,7 +1311,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } $sortfield_new = implode(',', $sortfield_new_list); - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm if (is_object($objcon) && $objcon->id > 0) { @@ -1321,141 +1321,141 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin { $sql = "SELECT a.id, a.label as label,"; } - $sql.= " a.datep as dp,"; - $sql.= " a.datep2 as dp2,"; - $sql.= " a.percent as percent, 'action' as type,"; - $sql.= " a.fk_element, a.elementtype,"; - $sql.= " a.fk_contact,"; - $sql.= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; - $sql.= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", o.ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; + $sql .= " a.datep as dp,"; + $sql .= " a.datep2 as dp2,"; + $sql .= " a.percent as percent, 'action' as type,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " a.fk_contact,"; + $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; + $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= ", sp.lastname, sp.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; $force_filter_contact = false; if (is_object($objcon) && $objcon->id > 0) { $force_filter_contact = true; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; - $sql.= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . $objcon->id; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; + $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id; } - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; - $sql.= " ON er.resource_type = 'dolresource'"; - $sql.= " AND er.element_id = a.id"; - $sql.= " AND er.resource_id = ".$filterobj->id; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " ON er.resource_type = 'dolresource'"; + $sql .= " AND er.element_id = a.id"; + $sql .= " AND er.resource_id = ".$filterobj->id; } - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", ".MAIN_DB_PREFIX."product as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", ".MAIN_DB_PREFIX."ticket as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", ".MAIN_DB_PREFIX."bom_bom as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", ".MAIN_DB_PREFIX."contrat as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; - $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; if ($force_filter_contact === false) { - if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; - elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; + if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id; + elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id; elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') { - $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } } // Condition on actioncode - if (! empty($actioncode)) + if (!empty($actioncode)) { if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; else { - if ($actioncode == 'AC_OTH') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_OTH_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; } } else { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; - else $sql.= " AND c.code = '".$db->escape($actioncode)."'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else $sql .= " AND c.code = '".$db->escape($actioncode)."'"; } } - if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']); + if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); } // 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) + if (!empty($conf->mailing->enabled) && !empty($objcon->email) && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) { $langs->load("mails"); $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; - $sql2.= ", '' as fk_element, '' as elementtype, '' as contact_id"; - $sql2.= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; - $sql2.= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2.= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2.= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2.= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2.= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2.= ", '' as ref"; - $sql2.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; - $sql2.= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. - $sql2.= " AND mc.statut = 1"; - $sql2.= " AND u.rowid = m.fk_user_valid"; - $sql2.= " AND mc.fk_mailing=m.rowid"; + $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; + $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; + $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. + $sql2 .= " AND mc.statut = 1"; + $sql2 .= " AND u.rowid = m.fk_user_valid"; + $sql2 .= " AND mc.fk_mailing=m.rowid"; } if (!empty($sql) && !empty($sql2)) { - $sql = $sql . " UNION " . $sql2; + $sql = $sql." UNION ".$sql2; } elseif (empty($sql) && !empty($sql2)) { $sql = $sql2; } //TODO Add limit in nb of results - $sql.= $db->order($sortfield_new, $sortorder); + $sql .= $db->order($sortfield_new, $sortorder); dol_syslog("company.lib::show_actions_done", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $i = 0 ; + $i = 0; $num = $db->num_rows($resql); while ($i < $num) @@ -1464,19 +1464,19 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if ($obj->type == 'action') { $contactaction = new ActionComm($db); - $contactaction->id=$obj->id; + $contactaction->id = $obj->id; $result = $contactaction->fetchResources(); - if ($result<0) { + if ($result < 0) { dol_print_error($db); setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); } //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - $tododone=''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone='todo'; + $tododone = ''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>$tododone, 'id'=>$obj->id, @@ -1500,11 +1500,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin // Type of event 'acode'=>$obj->acode, 'alabel'=>$obj->alabel, - 'libelle'=>$obj->alabel, // deprecated + 'libelle'=>$obj->alabel, // deprecated 'apicto'=>$obj->apicto ); } else { - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>'done', 'id'=>$obj->id, @@ -1531,203 +1531,203 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin dol_print_error($db); } - if (! empty($conf->agenda->enabled) || (! empty($conf->mailing->enabled) && ! empty($objcon->email))) + if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) { - $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $formactions=new FormActions($db); + $formactions = new FormActions($db); - $actionstatic=new ActionComm($db); - $userstatic=new User($db); + $actionstatic = new ActionComm($db); + $userstatic = new User($db); $contactstatic = new Contact($db); - $out.=''; + $out .= ''; if ($objcon && get_class($objcon) == 'Contact' && (is_null($filterobj) || get_class($filterobj) == 'Societe')) { - $out.=''; + $out .= ''; } else { - $out.=''; + $out .= ''; } - if ($filterobj && get_class($filterobj) == 'Societe') $out.=''; + if ($filterobj && get_class($filterobj) == 'Societe') $out .= ''; - $out.="\n"; + $out .= "\n"; - $out.='
    '; - $out.=''; + $out .= '
    '; + $out .= '
    '; - $out.=''; + $out .= ''; if ($donetodo) { - $out.=''; + $out .= ''; } - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; // Action column - $out.=''; - $out.=''; + $out .= ''; + $out .= ''; - $out.=''; + $out .= ''; if ($donetodo) { - $tmp=''; - if (get_class($filterobj) == 'Societe') $tmp.=''; - $tmp.=($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); - $tmp.=($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); - $tmp.=($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); + $tmp = ''; + if (get_class($filterobj) == 'Societe') $tmp .= ''; + $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); + $tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); + $tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); //$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort"); - if (get_class($filterobj) == 'Societe') $tmp.=''; - $out.=getTitleFieldOfList($tmp); + if (get_class($filterobj) == 'Societe') $tmp .= ''; + $out .= getTitleFieldOfList($tmp); } - $out.=getTitleFieldOfList($langs->trans("Ref"), 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder); - $out.=getTitleFieldOfList($langs->trans("Owner")); - $out.=getTitleFieldOfList($langs->trans("Type")); - $out.=getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - $out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder); - $out.=getTitleFieldOfList($langs->trans("RelatedObjects"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - $out.=getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - $out.=getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder); - $out.=getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); - $out.=''; + $out .= getTitleFieldOfList($langs->trans("Ref"), 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("Owner")); + $out .= getTitleFieldOfList($langs->trans("Type")); + $out .= getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("RelatedObjects"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder); + $out .= getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); + $out .= ''; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; - $caction=new CActionComm($db); - $arraylist=$caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0), '', 1); + $caction = new CActionComm($db); + $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); foreach ($histo as $key=>$value) { - $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo + $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo - $actionstatic->type_picto=$histo[$key]['apicto']; - $actionstatic->type_code=$histo[$key]['acode']; + $actionstatic->type_picto = $histo[$key]['apicto']; + $actionstatic->type_code = $histo[$key]['acode']; - $out.=''; + $out .= ''; // Done or todo if ($donetodo) { - $out.=''; + $out .= ''; } // Ref - $out.=''; + $out .= ''; // Author of event - $out.=''; + $out .= ''; // Type - $out.=''; + $labeltype = $actionstatic->type_code; + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH'; + if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; + $out .= dol_trunc($labeltype, 28); + $out .= ''; // Title - $out.=''; + $out .= ''; // Date - $out.='\n"; + $late = 0; + if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] == 0 && !$histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && !$histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($late) $out .= img_warning($langs->trans("Late")).' '; + $out .= "\n"; // Title of event //$out.=''; // Objet lie - $out.=''; + else $out .= ' '; + $out .= ''; // Contact pour cette action if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) { - $contactstatic->lastname=$histo[$key]['lastname']; - $contactstatic->firstname=$histo[$key]['firstname']; - $contactstatic->id=$histo[$key]['contact_id']; - $out.=''; + $contactstatic->lastname = $histo[$key]['lastname']; + $contactstatic->firstname = $histo[$key]['firstname']; + $contactstatic->id = $histo[$key]['contact_id']; + $out .= ''; } elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) { $out .= ''; } else { - $out.=''; + $out .= ''; } // Status - $out.=''; + $out .= ''; // Actions - $out.=''; + $out .= ''; - $out.="\n"; + $out .= "\n"; $i++; } - $out.="
    '; - $out.=$formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1, 0, 0, 1); - $out.=''; + $out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, 0, 1); + $out .= ''; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); - $out.=$searchpicto; - $out.='
    '; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + $out .= $searchpicto; + $out .= '
    '; - $out.=''; + $out .= ''; - if (isset($histo[$key]['type']) && $histo[$key]['type']=='mailing') { - $out.=''.img_object($langs->trans("ShowEMailing"), "email").' '; - $out.=$histo[$key]['id']; - $out.=''; + $out .= ''; + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { + $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; + $out .= $histo[$key]['id']; + $out .= ''; } else { - $out.=$actionstatic->getNomUrl(1, -1); + $out .= $actionstatic->getNomUrl(1, -1); } - $out.=''; + $out .= ''; //$userstatic->id=$histo[$key]['userid']; //$userstatic->login=$histo[$key]['login']; //$out.=$userstatic->getLoginUrl(1); if ($histo[$key]['userid'] > 0) { - $userstatic->fetch($histo[$key]['userid']); // TODO Introduce a cache on users fetched - $out.=$userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); + $userstatic->fetch($histo[$key]['userid']); // TODO Introduce a cache on users fetched + $out .= $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); } - $out.=''; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + $out .= ''; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($actionstatic->type_picto) print img_picto('', $actionstatic->type_picto); else { - if ($actionstatic->type_code == 'AC_RDV') $out.= img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_TEL') $out.= img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_FAX') $out.= img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_EMAIL') $out.= img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_INT') $out.= img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; - elseif (! preg_match('/_AUTO/', $actionstatic->type_code)) $out.= img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; + if ($actionstatic->type_code == 'AC_RDV') $out .= img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_TEL') $out .= img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_FAX') $out .= img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_EMAIL') $out .= img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_INT') $out .= img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; + elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) $out .= img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; } } - $labeltype=$actionstatic->type_code; - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype='AC_OTH'; - if (! empty($arraylist[$labeltype])) $labeltype=$arraylist[$labeltype]; - $out.= dol_trunc($labeltype, 28); - $out.=''; - if (isset($histo[$key]['type']) && $histo[$key]['type']=='action') + $out .= ''; + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') { - $transcode=$langs->trans("Action".$histo[$key]['acode']); - $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:$histo[$key]['alabel']); + $transcode = $langs->trans("Action".$histo[$key]['acode']); + $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); //$actionstatic->libelle=$libelle; - $libelle=$histo[$key]['note']; - $actionstatic->id=$histo[$key]['id']; - $out.=dol_trunc($libelle, 120); + $libelle = $histo[$key]['note']; + $actionstatic->id = $histo[$key]['id']; + $out .= dol_trunc($libelle, 120); } - if (isset($histo[$key]['type']) && $histo[$key]['type']=='mailing') + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { - $out.=''.img_object($langs->trans("ShowEMailing"), "email").' '; - $transcode=$langs->trans("Action".$histo[$key]['acode']); - $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:'Send mass mailing'); - $out.=dol_trunc($libelle, 120); + $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; + $transcode = $langs->trans("Action".$histo[$key]['acode']); + $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); + $out .= dol_trunc($libelle, 120); } - $out.=''; - $out.=dol_print_date($histo[$key]['datestart'], 'dayhour'); + $out .= ''; + $out .= dol_print_date($histo[$key]['datestart'], 'dayhour'); if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) { - $tmpa=dol_getdate($histo[$key]['datestart'], true); - $tmpb=dol_getdate($histo[$key]['dateend'], true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out.='-'.dol_print_date($histo[$key]['dateend'], 'hour'); - else $out.='-'.dol_print_date($histo[$key]['dateend'], 'dayhour'); + $tmpa = dol_getdate($histo[$key]['datestart'], true); + $tmpb = dol_getdate($histo[$key]['dateend'], true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour'); + else $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour'); } - $late=0; - if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] == 0 && ! $histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && ! $histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($late) $out.=img_warning($langs->trans("Late")).' '; - $out.="'.dol_trunc($histo[$key]['note'], 40).''; + $out .= ''; if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) { - $out.=dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1); + $out .= dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1); } - else $out.=' '; - $out.=''.$contactstatic->getNomUrl(1, '', 10).''.$contactstatic->getNomUrl(1, '', 10).''; foreach ($histo[$key]['socpeopleassigned'] as $cid => $Tab) { @@ -1740,8 +1740,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if ($result > 0) { $out .= $contact->getNomUrl(1); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { - if (! empty($contact->phone_pro)) - $out .= '(' . dol_print_phone($contact->phone_pro) . ')'; + if (!empty($contact->phone_pro)) + $out .= '('.dol_print_phone($contact->phone_pro).')'; } $out .= '
    '; } @@ -1749,23 +1749,23 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= '
      '.$actionstatic->LibStatut($histo[$key]['percent'], 3, 0, $histo[$key]['datestart']).''.$actionstatic->LibStatut($histo[$key]['percent'], 3, 0, $histo[$key]['datestart']).'
    \n"; - $out.="
    \n"; + $out .= "
    \n"; + $out .= "\n"; } - $out.=''; + $out .= ''; if ($noprint) return $out; else print $out; @@ -1784,13 +1784,13 @@ function show_subsidiaries($conf, $langs, $db, $object) { global $user; - $i=-1; + $i = -1; $sql = "SELECT s.rowid, s.client, s.fournisseur, s.nom as name, s.name_alias, s.email, s.address, s.zip, s.town, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.canvas"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.parent = ".$object->id; - $sql.= " AND s.entity IN (".getEntity('societe').")"; - $sql.= " ORDER BY s.nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.parent = ".$object->id; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + $sql .= " ORDER BY s.nom"; $result = $db->query($sql); $num = $db->num_rows($result); @@ -1808,7 +1808,7 @@ function show_subsidiaries($conf, $langs, $db, $object) print "
     
    '; - $var=false; + $var = false; // Title print ''; print ''; print ''; print ''; print ''; @@ -486,20 +486,20 @@ if ($action == 'create') print $langs->trans('Piece'); print ''; if ($action != 'editdocref') - print ''; + print ''; print '
    '.$langs->trans("DefaultSkin").''; - $url='http://ckeditor.com/addons/skins/all'; + $url = 'http://ckeditor.com/addons/skins/all'; /*print ''; print $langs->trans('DownloadMoreSkins'); print '';*/ @@ -74,7 +74,7 @@ function show_skin($fuser, $edit = 0) print '
    '.$langs->trans("ThemeDir").''; - foreach($dirskins as $dirskin) + foreach ($dirskins as $dirskin) { echo '"'.$dirskin.'" '; } @@ -86,22 +86,22 @@ function show_skin($fuser, $edit = 0) print ''."\n"; - $projectstatic->id=$lines[$i]->fk_project; - $projectstatic->ref=$lines[$i]->projectref; - $projectstatic->public=$lines[$i]->public; - $projectstatic->title=$lines[$i]->projectlabel; - $projectstatic->usage_bill_time=$lines[$i]->usage_bill_time; + $projectstatic->id = $lines[$i]->fk_project; + $projectstatic->ref = $lines[$i]->projectref; + $projectstatic->public = $lines[$i]->public; + $projectstatic->title = $lines[$i]->projectlabel; + $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time; - $taskstatic->id=$lines[$i]->id; - $taskstatic->ref=$lines[$i]->ref; - $taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:''); + $taskstatic->id = $lines[$i]->id; + $taskstatic->ref = $lines[$i]->ref; + $taskstatic->label = ($taskrole[$lines[$i]->id] ? $langs->trans("YourRole").': '.$taskrole[$lines[$i]->id] : ''); $taskstatic->projectstatus = $lines[$i]->projectstatus; $taskstatic->progress = $lines[$i]->progress; $taskstatic->fk_statut = $lines[$i]->status; $taskstatic->datee = $lines[$i]->date_end; - $taskstatic->planned_workload= $lines[$i]->planned_workload; - $taskstatic->duration_effective= $lines[$i]->duration; + $taskstatic->planned_workload = $lines[$i]->planned_workload; + $taskstatic->duration_effective = $lines[$i]->duration; if ($showproject) @@ -466,14 +466,14 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Project ref print ""; // Project status print '"; } @@ -494,12 +494,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print "'; - $plannedworkloadoutputformat='allhourmin'; - $timespentoutputformat='allhourmin'; - if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; - if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; + $plannedworkloadoutputformat = 'allhourmin'; + $timespentoutputformat = 'allhourmin'; + if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; + if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; // Planned Workload (in working hours) print '\n"; - if (! $showlineingray) $inc++; + if (!$showlineingray) $inc++; if ($level >= 0) // Call sublevels { @@ -662,7 +662,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); print ''; print ''; @@ -680,13 +680,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($totalCalculatedProgress > $totalAverageDeclaredProgress) { $progressBarClass = 'progress-bar-danger'; - $badgeClass.= 'badge-danger'; + $badgeClass .= 'badge-danger'; } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) { // warning if close at 1% $progressBarClass = 'progress-bar-warning'; - $badgeClass.= 'badge-warning'; + $badgeClass .= 'badge-warning'; } else { $progressBarClass = 'progress-bar-success'; - $badgeClass.= 'badge-success'; + $badgeClass .= 'badge-success'; } } @@ -719,7 +719,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; } // Contacts of task - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { print ''; } @@ -753,43 +753,43 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec global $conf, $db, $user, $bc, $langs; global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; - $lastprojectid=0; - $totalforeachline=array(); - $workloadforid=array(); - $lineswithoutlevel0=array(); + $lastprojectid = 0; + $totalforeachline = array(); + $workloadforid = array(); + $lineswithoutlevel0 = array(); - $numlines=count($lines); + $numlines = count($lines); // Create a smaller array with sublevels only to be used later. This increase dramatically performances. if ($parent == 0) // Always and only if at first level { - for ($i = 0 ; $i < $numlines ; $i++) + for ($i = 0; $i < $numlines; $i++) { - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; } } if (empty($oldprojectforbreak)) { - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break } //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); - for ($i = 0 ; $i < $numlines ; $i++) + for ($i = 0; $i < $numlines; $i++) { if ($parent == 0) $level = 0; //if ($lines[$i]->fk_task_parent == $parent) //{ // If we want all or we have a role on task, we show it - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) { //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); // Break on a new project if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { - $lastprojectid=$lines[$i]->fk_project; + $lastprojectid = $lines[$i]->fk_project; if ($preselectedday) { $projectstatic->id = $lines[$i]->fk_project; @@ -800,25 +800,25 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec { if ($preselectedday) { - $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week - $workloadforid[$projectstatic->id]=1; + $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week + $workloadforid[$projectstatic->id] = 1; } } - $projectstatic->id=$lines[$i]->fk_project; - $projectstatic->ref=$lines[$i]->project_ref; - $projectstatic->title=$lines[$i]->project_label; - $projectstatic->public=$lines[$i]->public; + $projectstatic->id = $lines[$i]->fk_project; + $projectstatic->ref = $lines[$i]->project_ref; + $projectstatic->title = $lines[$i]->project_label; + $projectstatic->public = $lines[$i]->public; - $taskstatic->id=$lines[$i]->task_id; - $taskstatic->ref=($lines[$i]->task_ref?$lines[$i]->task_ref:$lines[$i]->task_id); - $taskstatic->label=$lines[$i]->task_label; - $taskstatic->date_start=$lines[$i]->date_start; - $taskstatic->date_end=$lines[$i]->date_end; + $taskstatic->id = $lines[$i]->task_id; + $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id); + $taskstatic->label = $lines[$i]->task_label; + $taskstatic->date_start = $lines[$i]->date_start; + $taskstatic->date_end = $lines[$i]->date_end; - $thirdpartystatic->id=$lines[$i]->socid; - $thirdpartystatic->name=$lines[$i]->thirdparty_name; - $thirdpartystatic->email=$lines[$i]->thirdparty_email; + $thirdpartystatic->id = $lines[$i]->socid; + $thirdpartystatic->name = $lines[$i]->thirdparty_name; + $thirdpartystatic->email = $lines[$i]->thirdparty_email; if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) { @@ -862,11 +862,11 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec // Ref print ''; - $disabledproject=1;$disabledtask=1; + $disabledproject = 1; $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { - $disabledproject=0; - $disabledtask=0; + $disabledproject = 0; + $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { - $disabledtask=1; + $disabledtask = 1; } // Hour @@ -899,23 +899,23 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec print dol_print_date($lines[$i]->timespent_datehour, 'hour'); print ''; - $cssonholiday=''; - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; // Duration - print ''; if ($action != 'editjournal') - print ''; + print ''; print '
    '; - $i=0; - foreach($dirskins as $dir) + $i = 0; + foreach ($dirskins as $dir) { //print $dirroot.$dir;exit; - $dirskin=dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root - $urltheme=dol_buildpath($dir, 1); + $dirskin = dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root + $urltheme = dol_buildpath($dir, 1); if (is_dir($dirskin)) { - $handle=opendir($dirskin); + $handle = opendir($dirskin); if (is_resource($handle)) { - while (($subdir = readdir($handle))!==false) + while (($subdir = readdir($handle)) !== false) { if (is_dir($dirskin."/".$subdir) && substr($subdir, 0, 1) <> '.' - && substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i', $subdir)) + && substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir)) { // Disable not stable themes (dir ends with _exp or _dev) if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue; @@ -110,11 +110,11 @@ function show_skin($fuser, $edit = 0) print '
    '; if ($subdir == $selected_theme) { - print ' '.$subdir.''; + print ' '.$subdir.''; } else { - print ' '.$subdir; + print ' '.$subdir; } print '
    '; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index cac2208eb2f..da7d15806f9 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -44,37 +44,37 @@ function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup') { global $conf, $db, $langs; - dol_syslog("pdf_getFormat Get paper format with mode=".$mode." MAIN_PDF_FORMAT=".(empty($conf->global->MAIN_PDF_FORMAT)?'null':$conf->global->MAIN_PDF_FORMAT)." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')." and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang : 'null')); + dol_syslog("pdf_getFormat Get paper format with mode=".$mode." MAIN_PDF_FORMAT=".(empty($conf->global->MAIN_PDF_FORMAT) ? 'null' : $conf->global->MAIN_PDF_FORMAT)." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')." and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang : 'null')); // Default value if setup was not done and/or entry into c_paper_format not defined - $width=210; $height=297; $unit='mm'; + $width = 210; $height = 297; $unit = 'mm'; if ($mode == 'auto' || empty($conf->global->MAIN_PDF_FORMAT) || $conf->global->MAIN_PDF_FORMAT == 'auto') { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $pdfformat=dol_getDefaultFormat($outputlangs); + $pdfformat = dol_getDefaultFormat($outputlangs); } else { - $pdfformat=$conf->global->MAIN_PDF_FORMAT; + $pdfformat = $conf->global->MAIN_PDF_FORMAT; } - $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format"; - $sql.=" WHERE code = '".$db->escape($pdfformat)."'"; - $resql=$db->query($sql); + $sql = "SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format"; + $sql .= " WHERE code = '".$db->escape($pdfformat)."'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); if ($obj) { - $width=(int) $obj->width; - $height=(int) $obj->height; - $unit=$obj->unit; + $width = (int) $obj->width; + $height = (int) $obj->height; + $unit = $obj->unit; } } //print "pdfformat=".$pdfformat." width=".$width." height=".$height." unit=".$unit; - return array('width'=>$width,'height'=>$height,'unit'=>$unit); + return array('width'=>$width, 'height'=>$height, 'unit'=>$unit); } /** @@ -90,9 +90,9 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') global $conf; // Define constant for TCPDF - if (! defined('K_TCPDF_EXTERNAL_CONFIG')) + if (!defined('K_TCPDF_EXTERNAL_CONFIG')) { - define('K_TCPDF_EXTERNAL_CONFIG', 1); // this avoid using tcpdf_config file + define('K_TCPDF_EXTERNAL_CONFIG', 1); // this avoid using tcpdf_config file define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/'); define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/'); dol_mkdir(K_PATH_CACHE); @@ -119,7 +119,7 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') define('HEAD_MAGNIFICATION', 1.1); define('K_CELL_HEIGHT_RATIO', 1.25); define('K_TITLE_MAGNIFICATION', 1.3); - define('K_SMALL_RATIO', 2/3); + define('K_SMALL_RATIO', 2 / 3); define('K_THAI_TOPCHARS', true); define('K_TCPDF_CALLS_IN_HTML', true); define('K_TCPDF_THROW_EXCEPTION_ERROR', false); @@ -135,14 +135,14 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') //$format=array($arrayformat['width'],$arrayformat['height']); //$metric=$arrayformat['unit']; - $pdfa=false; // PDF-1.3 - if (! empty($conf->global->PDF_USE_1A)) $pdfa=true; // PDF1/A + $pdfa = false; // PDF-1.3 + if (!empty($conf->global->PDF_USE_1A)) $pdfa = true; // PDF1/A if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); else $pdf = new TCPDF($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); // Protection and encryption of pdf - if (! empty($conf->global->PDF_SECURITY_ENCRYPTION)) + if (!empty($conf->global->PDF_SECURITY_ENCRYPTION)) { /* Permission supported by TCPDF - print : Print the document; @@ -157,20 +157,20 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') */ // For TCPDF, we specify permission we want to block - $pdfrights = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS)?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS, true):array('modify','copy')); // Json format in llx_const + $pdfrights = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS, true) : array('modify', 'copy')); // Json format in llx_const // Password for the end user - $pdfuserpass = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_USERPASS)?$conf->global->PDF_SECURITY_ENCRYPTION_USERPASS:''); + $pdfuserpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_USERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_USERPASS : ''); // Password of the owner, created randomly if not defined - $pdfownerpass = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS)?$conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS:null); + $pdfownerpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS : null); // For encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit - $encstrength = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH)?$conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH:0); + $encstrength = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH) ? $conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH : 0); // Array of recipients containing public-key certificates ('c') and permissions ('p'). // For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print'))) - $pubkeys = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS)?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS, true):null); // Json format in llx_const + $pubkeys = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS, true) : null); // Json format in llx_const $pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass, $encstrength, $pubkeys); } @@ -199,11 +199,11 @@ function pdf_getEncryption($pathoffile) //ob_end_clean(); if (isset($xref['trailer']['encrypt'])) { - $isencrypted = true; // Secured pdf file are currently not supported + $isencrypted = true; // Secured pdf file are currently not supported } if (empty($data)) { - $isencrypted = true; // Object list not found. Possible secured file + $isencrypted = true; // Object list not found. Possible secured file } return $isencrypted; @@ -219,14 +219,14 @@ function pdf_getPDFFont($outputlangs) { global $conf; - if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT; + if (!empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT; - $font='Helvetica'; // By default, for FPDI, or ISO language on TCPDF + $font = 'Helvetica'; // By default, for FPDI, or ISO language on TCPDF if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) { - if ($outputlangs->trans('FONTFORPDF')!='FONTFORPDF') + if ($outputlangs->trans('FONTFORPDF') != 'FONTFORPDF') { - $font=$outputlangs->trans('FONTFORPDF'); + $font = $outputlangs->trans('FONTFORPDF'); } } return $font; @@ -242,7 +242,7 @@ function pdf_getPDFFontSize($outputlangs) { global $conf; - $size=10; // By default, for FPDI or ISO language on TCPDF + $size = 10; // By default, for FPDI or ISO language on TCPDF if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 font like DejaVuSans if required (slower) { if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF') @@ -250,7 +250,7 @@ function pdf_getPDFFontSize($outputlangs) $size = (int) $outputlangs->trans('FONTSIZEFORPDF'); } } - if (! empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE; + if (!empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE; return $size; } @@ -266,14 +266,14 @@ function pdf_getPDFFontSize($outputlangs) function pdf_getHeightForLogo($logo, $url = false) { global $conf; - $height=(empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT)?22:$conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT); - $maxwidth=130; + $height = (empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT) ? 22 : $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT); + $maxwidth = 130; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $tmp=dol_getImageSize($logo, $url); + $tmp = dol_getImageSize($logo, $url); if ($tmp['height']) { - $width=round($height*$tmp['width']/$tmp['height']); - if ($width > $maxwidth) $height=$height*$maxwidth/$width; + $width = round($height * $tmp['width'] / $tmp['height']); + if ($width > $maxwidth) $height = $height * $maxwidth / $width; } //print $tmp['width'].' '.$tmp['height'].' '.$width; exit; return $height; @@ -307,9 +307,9 @@ function pdfGetHeightForHtmlContent(&$pdf, $htmlcontent) } else { - for ($page=$start_page; $page <= $end_page; ++$page) { + for ($page = $start_page; $page <= $end_page; ++$page) { $pdf->setPage($page); - $tmpm=$pdf->getMargins(); + $tmpm = $pdf->getMargins(); $tMargin = $tmpm['top']; if ($page == $start_page) { // first page @@ -346,7 +346,7 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali if ($thirdparty instanceof Societe) { $socname .= $thirdparty->name; - if (($includealias || ! empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) { + if (($includealias || !empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) { $socname .= "\n".$thirdparty->name_alias; } } elseif ($thirdparty instanceof Contact) { @@ -375,20 +375,20 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t { global $conf, $hookmanager; - if ($mode == 'source' && ! is_object($sourcecompany)) return -1; - if ($mode == 'target' && ! is_object($targetcompany)) return -1; + if ($mode == 'source' && !is_object($sourcecompany)) return -1; + if ($mode == 'target' && !is_object($targetcompany)) return -1; - if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state=getState($sourcecompany->state_id); - if (! empty($targetcompany->state_id) && empty($targetcompany->state)) $targetcompany->state=getState($targetcompany->state_id); + if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state = getState($sourcecompany->state_id); + if (!empty($targetcompany->state_id) && empty($targetcompany->state)) $targetcompany->state = getState($targetcompany->state_id); - $reshook=0; + $reshook = 0; $stringaddress = ''; if (is_object($hookmanager)) { $parameters = array('sourcecompany'=>&$sourcecompany, 'targetcompany'=>&$targetcompany, 'targetcontact'=>&$targetcontact, 'outputlangs'=>$outputlangs, 'mode'=>$mode, 'usecontact'=>$usecontact); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_build_address', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $stringaddress.=$hookmanager->resPrint; + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_build_address', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $stringaddress .= $hookmanager->resPrint; } if (empty($reshook)) { @@ -397,64 +397,64 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t $withCountry = 0; if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1; - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n"; + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n"; if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) { // Phone - if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); + if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); // Fax - if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); + if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); // EMail - if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); + if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); // Web - if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); + if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); } // Intra VAT - if (! empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) + if (!empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) { - if ($sourcecompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); + if ($sourcecompany->tva_intra) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); } // Professionnal Ids $reg = array(); - if (! empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof1)) + if (!empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof1)) { - $tmp=$outputlangs->transcountrynoentities("ProfId1", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1); + $tmp = $outputlangs->transcountrynoentities("ProfId1", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1); } - if (! empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof2)) + if (!empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof2)) { - $tmp=$outputlangs->transcountrynoentities("ProfId2", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2); + $tmp = $outputlangs->transcountrynoentities("ProfId2", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2); } - if (! empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof3)) + if (!empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof3)) { - $tmp=$outputlangs->transcountrynoentities("ProfId3", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3); + $tmp = $outputlangs->transcountrynoentities("ProfId3", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3); } - if (! empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof4)) + if (!empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof4)) { - $tmp=$outputlangs->transcountrynoentities("ProfId4", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4); + $tmp = $outputlangs->transcountrynoentities("ProfId4", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4); } - if (! empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof5)) + if (!empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof5)) { - $tmp=$outputlangs->transcountrynoentities("ProfId5", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5); + $tmp = $outputlangs->transcountrynoentities("ProfId5", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5); } - if (! empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof6)) + if (!empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof6)) { - $tmp=$outputlangs->transcountrynoentities("ProfId6", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6); + $tmp = $outputlangs->transcountrynoentities("ProfId6", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6); } - if (! empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) { - $stringaddress.=($stringaddress ? "\n" : '' ).$conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS; + if (!empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) { + $stringaddress .= ($stringaddress ? "\n" : '').$conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS; } } @@ -462,10 +462,10 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t { if ($usecontact) { - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1)); if (!empty($targetcontact->address)) { - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcontact)); } else { $companytouseforaddress = $targetcompany; @@ -476,73 +476,73 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t $companytouseforaddress = $targetcontact->thirdparty; } - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress)); } // Country if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) { - $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code)); } elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { - $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); } - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) { // Phone - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) { - if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; - if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); - if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / "; - if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); + if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": "; + if (!empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); + if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) $stringaddress .= " / "; + if (!empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); } // Fax - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) { - if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); + if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); } // EMail - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) { - if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); + if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); } // Web - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) { - if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); + if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); } } } else { - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany)); // Country - if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); + if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) { // Phone - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) { - if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; - if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); - if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / "; - if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); + if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": "; + if (!empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); + if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) $stringaddress .= " / "; + if (!empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); } // Fax - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) { - if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); + if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); } // EMail - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) { - if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); + if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); } // Web - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) { - if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); + if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); } } } @@ -550,57 +550,57 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t // Intra VAT if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) { - if ($targetcompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); + if ($targetcompany->tva_intra) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); } // Professionnal Ids - if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1)) + if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1)) { - $tmp=$outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); + $tmp = $outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); } - if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2)) + if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2)) { - $tmp=$outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); + $tmp = $outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); } - if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3)) + if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3)) { - $tmp=$outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); + $tmp = $outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); } - if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4)) + if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4)) { - $tmp=$outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); + $tmp = $outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); } - if (! empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && ! empty($targetcompany->idprof5)) + if (!empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && !empty($targetcompany->idprof5)) { - $tmp=$outputlangs->transcountrynoentities("ProfId5", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); + $tmp = $outputlangs->transcountrynoentities("ProfId5", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); } - if (! empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && ! empty($targetcompany->idprof6)) + if (!empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && !empty($targetcompany->idprof6)) { - $tmp=$outputlangs->transcountrynoentities("ProfId6", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); + $tmp = $outputlangs->transcountrynoentities("ProfId6", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); } // Public note - if (! empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) + if (!empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) { - if ($mode == 'source' && ! empty($sourcecompany->note_public)) + if ($mode == 'source' && !empty($sourcecompany->note_public)) { - $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($sourcecompany->note_public); + $stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($sourcecompany->note_public); } - if (($mode == 'target' || preg_match('/targetwithdetails/', $mode)) && ! empty($targetcompany->note_public)) + if (($mode == 'target' || preg_match('/targetwithdetails/', $mode)) && !empty($targetcompany->note_public)) { - $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($targetcompany->note_public); + $stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($targetcompany->note_public); } } } @@ -623,11 +623,11 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) global $conf; // Add a background image on document - if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image + if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image { - $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image - $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height); - $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak + $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image + $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); + $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak } } @@ -644,8 +644,8 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) function pdf_getSubstitutionArray($outputlangs, $exclude = null, $object = null, $onlykey = 0) { $substitutionarray = getCommonSubstitutionArray($outputlangs, $onlykey, $exclude, $object); - $substitutionarray['__FROM_NAME__']='__FROM_NAME__'; - $substitutionarray['__FROM_EMAIL__']='__FROM_EMAIL__'; + $substitutionarray['__FROM_NAME__'] = '__FROM_NAME__'; + $substitutionarray['__FROM_EMAIL__'] = '__FROM_EMAIL__'; return $substitutionarray; } @@ -666,31 +666,31 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) global $langs, $mysoc, $user; // Print Draft Watermark - if ($unit=='pt') $k=1; - elseif ($unit=='mm') $k=72/25.4; - elseif ($unit=='cm') $k=72/2.54; - elseif ($unit=='in') $k=72; + if ($unit == 'pt') $k = 1; + elseif ($unit == 'mm') $k = 72 / 25.4; + elseif ($unit == 'cm') $k = 72 / 2.54; + elseif ($unit == 'in') $k = 72; // Make substitution - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, null); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, null); complete_substitutions_array($substitutionarray, $outputlangs, null); - $text=make_substitutions($text, $substitutionarray, $outputlangs); - $text=$outputlangs->convToOutputCharset($text); + $text = make_substitutions($text, $substitutionarray, $outputlangs); + $text = $outputlangs->convToOutputCharset($text); - $savx=$pdf->getX(); $savy=$pdf->getY(); + $savx = $pdf->getX(); $savy = $pdf->getY(); - $watermark_angle=atan($h/$w)/2; - $watermark_x_pos=0; - $watermark_y_pos=$h/3; - $watermark_x=$w/2; - $watermark_y=$h/3; + $watermark_angle = atan($h / $w) / 2; + $watermark_x_pos = 0; + $watermark_y_pos = $h / 3; + $watermark_x = $w / 2; + $watermark_y = $h / 3; $pdf->SetFont('', 'B', 40); $pdf->SetTextColor(255, 192, 203); //rotate - $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x*$k, ($h-$watermark_y)*$k, -$watermark_x*$k, -($h-$watermark_y)*$k)); + $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x * $k, ($h - $watermark_y) * $k, -$watermark_x * $k, -($h - $watermark_y) * $k)); //print watermark $pdf->SetXY($watermark_x_pos, $watermark_y_pos); - $pdf->Cell($w-20, 25, $outputlangs->convToOutputCharset($text), "", 2, "C", 0); + $pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text), "", 2, "C", 0); //antirotate $pdf->_out('Q'); @@ -716,37 +716,37 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); - $diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + $diffsizecontent = (empty($conf->global->PDF_DIFFSIZE_CONTENT) ? 4 : $conf->global->PDF_DIFFSIZE_CONTENT); $pdf->SetXY($curx, $cury); if (empty($onlynumber)) { $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); - $cury+=4; + $cury += 4; } $outputlangs->load("banks"); // Use correct name of bank id according to country - $bickey="BICNumber"; - if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($account->getCountryCode() == 'IN') $bickey = "SWIFT"; // Get format of bank account according to its country - $usedetailedbban=$account->useDetailedBBAN(); + $usedetailedbban = $account->useDetailedBBAN(); //$onlynumber=0; $usedetailedbban=1; // For tests if ($usedetailedbban) { - $savcurx=$curx; + $savcurx = $curx; if (empty($onlynumber)) { $pdf->SetFont('', '', $default_font_size - $diffsizecontent); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); + $cury += 3; } if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enougth for them @@ -756,12 +756,12 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, // desk = code guichet (FR), used only when $usedetailedbban = 1 // number = account number // key = check control key used only when $usedetailedbban = 1 - if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+6); + if (empty($onlynumber)) $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6); foreach ($account->getFieldsToShow() as $val) { - $pdf->SetXY($curx, $cury+4); + $pdf->SetXY($curx, $cury + 4); $pdf->SetFont('', '', $default_font_size - 3); if ($val == 'BankCode') { @@ -799,54 +799,54 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, } } - $curx=$savcurx; - $cury+=8; + $curx = $savcurx; + $cury += 8; } } else { $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); + $cury += 3; $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': '.$outputlangs->convToOutputCharset($account->number), 0, 'L', 0); + $cury += 3; - if ($diffsizecontent <= 2) $cury+=1; + if ($diffsizecontent <= 2) $cury += 1; } $pdf->SetFont('', '', $default_font_size - $diffsizecontent); - if (empty($onlynumber) && ! empty($account->domiciliation)) + if (empty($onlynumber) && !empty($account->domiciliation)) { $pdf->SetXY($curx, $cury); - $val=$outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation); + $val = $outputlangs->transnoentities("Residence").': '.$outputlangs->convToOutputCharset($account->domiciliation); $pdf->MultiCell(100, 3, $val, 0, 'L', 0); //$nboflines=dol_nboflines_bis($val,120); //$cury+=($nboflines*3)+2; - $tmpy=$pdf->getStringHeight(100, $val); - $cury+=$tmpy; + $tmpy = $pdf->getStringHeight(100, $val); + $cury += $tmpy; } - if (! empty($account->proprio)) + if (!empty($account->proprio)) { $pdf->SetXY($curx, $cury); - $val=$outputlangs->transnoentities("BankAccountOwner").': ' . $outputlangs->convToOutputCharset($account->proprio); + $val = $outputlangs->transnoentities("BankAccountOwner").': '.$outputlangs->convToOutputCharset($account->proprio); $pdf->MultiCell(100, 3, $val, 0, 'L', 0); - $tmpy=$pdf->getStringHeight(100, $val); - $cury+=$tmpy; - $cur+=1; + $tmpy = $pdf->getStringHeight(100, $val); + $cury += $tmpy; + $cur += 1; } - elseif (! $usedetailedbban) $cury+=1; + elseif (!$usedetailedbban) $cury += 1; // Use correct name of bank id according to country $ibankey = FormBank::getIBANLabel($account); - if (! empty($account->iban)) + if (!empty($account->iban)) { //Remove whitespaces to ensure we are dealing with the format we expect $ibanDisplay_temp = str_replace(' ', '', $outputlangs->convToOutputCharset($account->iban)); @@ -856,20 +856,20 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, for ($i = 0; $i < $nbIbanDisplay_temp; $i++) { $ibanDisplay .= $ibanDisplay_temp[$i]; - if($i%4 == 3 && $i > 0) $ibanDisplay .= " "; + if ($i % 4 == 3 && $i > 0) $ibanDisplay .= " "; } $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': ' . $ibanDisplay, 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': '.$ibanDisplay, 0, 'L', 0); + $cury += 3; } - if (! empty($account->bic)) + if (!empty($account->bic)) { $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': '.$outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); } return $pdf->getY(); @@ -892,82 +892,82 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, */ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0) { - global $conf,$user,$mysoc; + global $conf, $user, $mysoc; $outputlangs->load("dict"); - $line=''; + $line = ''; - $dims=$pdf->getPageDimensions(); + $dims = $pdf->getPageDimensions(); // Line of free text - if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext)) + if (empty($hidefreetext) && !empty($conf->global->$paramfreetext)) { - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); // More substitution keys - $substitutionarray['__FROM_NAME__']=$fromcompany->name; - $substitutionarray['__FROM_EMAIL__']=$fromcompany->email; + $substitutionarray['__FROM_NAME__'] = $fromcompany->name; + $substitutionarray['__FROM_EMAIL__'] = $fromcompany->email; complete_substitutions_array($substitutionarray, $outputlangs, $object); - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs); // Make a change into HTML code to allow to include images from medias directory. // // become // - $newfreetext=preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); + $newfreetext = preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); - $line.=$outputlangs->convToOutputCharset($newfreetext); + $line .= $outputlangs->convToOutputCharset($newfreetext); } // First line of company infos - $line1=""; $line2=""; $line3=""; $line4=""; + $line1 = ""; $line2 = ""; $line3 = ""; $line4 = ""; if ($showdetails == 1 || $showdetails == 3) { // Company name if ($fromcompany->name) { - $line1.=($line1?" - ":"").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name; + $line1 .= ($line1 ? " - " : "").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name; } // Address if ($fromcompany->address) { - $line1.=($line1?" - ":"").str_replace("\n", ", ", $fromcompany->address); + $line1 .= ($line1 ? " - " : "").str_replace("\n", ", ", $fromcompany->address); } // Zip code if ($fromcompany->zip) { - $line1.=($line1?" - ":"").$fromcompany->zip; + $line1 .= ($line1 ? " - " : "").$fromcompany->zip; } // Town if ($fromcompany->town) { - $line1.=($line1?" ":"").$fromcompany->town; + $line1 .= ($line1 ? " " : "").$fromcompany->town; } // Country if ($fromcompany->country) { - $line1.=($line1?", ":"").$fromcompany->country; + $line1 .= ($line1 ? ", " : "").$fromcompany->country; } // Phone if ($fromcompany->phone) { - $line2.=($line2?" - ":"").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone; + $line2 .= ($line2 ? " - " : "").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone; } // Fax if ($fromcompany->fax) { - $line2.=($line2?" - ":"").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax; + $line2 .= ($line2 ? " - " : "").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax; } // URL if ($fromcompany->url) { - $line2.=($line2?" - ":"").$fromcompany->url; + $line2 .= ($line2 ? " - " : "").$fromcompany->url; } // Email if ($fromcompany->email) { - $line2.=($line2?" - ":"").$fromcompany->email; + $line2 .= ($line2 ? " - " : "").$fromcompany->email; } } if ($showdetails == 2 || $showdetails == 3 || ($fromcompany->country_code == 'DE')) @@ -975,7 +975,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Managers if ($fromcompany->managers) { - $line2.=($line2?" - ":"").$fromcompany->managers; + $line2 .= ($line2 ? " - " : "").$fromcompany->managers; } } @@ -983,90 +983,90 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Juridical status if ($fromcompany->forme_juridique_code) { - $line3.=($line3?" - ":"").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); + $line3 .= ($line3 ? " - " : "").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); } // Capital if ($fromcompany->capital) { $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string - if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); - else $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs); + if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); + else $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs); } // Prof Id 1 - if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) { - $field=$outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); + $field = $outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); } // Prof Id 2 if ($fromcompany->idprof2) { - $field=$outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2); + $field = $outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2); } // Line 4 of company infos // Prof Id 3 if ($fromcompany->idprof3) { - $field=$outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); + $field = $outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); } // Prof Id 4 if ($fromcompany->idprof4) { - $field=$outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); + $field = $outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); } // Prof Id 5 if ($fromcompany->idprof5) { - $field=$outputlangs->transcountrynoentities("ProfId5", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5); + $field = $outputlangs->transcountrynoentities("ProfId5", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5); } // Prof Id 6 if ($fromcompany->idprof6) { - $field=$outputlangs->transcountrynoentities("ProfId6", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6); + $field = $outputlangs->transcountrynoentities("ProfId6", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6); } // IntraCommunautary VAT if ($fromcompany->tva_intra != '') { - $line4.=($line4?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra); + $line4 .= ($line4 ? " - " : "").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra); } $pdf->SetFont('', '', 7); $pdf->SetDrawColor(224, 224, 224); // The start of the bottom of this page footer is positioned according to # of lines - $freetextheight=0; + $freetextheight = 0; if ($line) // Free text { //$line="sample text
    \nfdsfsdf
    \nghfghg
    "; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. - if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { - $width=200; $align='C'; + $width = 20000; $align = 'L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. + if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { + $width = 200; $align = 'C'; } - $freetextheight=$pdf->getStringHeight($width, $line); + $freetextheight = $pdf->getStringHeight($width, $line); } else { - $freetextheight=pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); // New method (works for HTML content) + $freetextheight = pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); // New method (works for HTML content) //print '
    '.$freetextheight;exit; } } - $marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0); - $posy=$marginwithfooter+0; + $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0); + $posy = $marginwithfooter + 0; if ($line) // Free text { @@ -1077,50 +1077,50 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } else { - $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk']-$marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); + $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); } - $posy-=$freetextheight; + $posy -= $freetextheight; } $pdf->SetY(-$posy); - $pdf->line($dims['lm'], $dims['hk']-$posy, $dims['wk']-$dims['rm'], $dims['hk']-$posy); + $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); $posy--; - if (! empty($line1)) + if (!empty($line1)) { $pdf->SetFont('', 'B', 7); $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line1, 0, 'C', 0); - $posy-=3; + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line1, 0, 'C', 0); + $posy -= 3; $pdf->SetFont('', '', 7); } - if (! empty($line2)) + if (!empty($line2)) { $pdf->SetFont('', 'B', 7); $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line2, 0, 'C', 0); - $posy-=3; + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line2, 0, 'C', 0); + $posy -= 3; $pdf->SetFont('', '', 7); } - if (! empty($line3)) + if (!empty($line3)) { $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line3, 0, 'C', 0); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line3, 0, 'C', 0); } - if (! empty($line4)) + if (!empty($line4)) { - $posy-=3; + $posy -= 3; $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line4, 0, 'C', 0); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line4, 0, 'C', 0); } // Show page nb only on iso languages (so default Helvetica font) if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { - $pdf->SetXY($dims['wk']-$dims['rm']-15, -$posy); + $pdf->SetXY($dims['wk'] - $dims['rm'] - 15, -$posy); //print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; $pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); } @@ -1145,17 +1145,17 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ function pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size) { $linkedobjects = pdf_getLinkedObjects($object, $outputlangs); - if (! empty($linkedobjects)) + if (!empty($linkedobjects)) { - foreach($linkedobjects as $linkedobject) + foreach ($linkedobjects as $linkedobject) { $reftoshow = $linkedobject["ref_title"].' : '.$linkedobject["ref_value"]; - if (! empty($linkedobject["date_value"])) + if (!empty($linkedobject["date_value"])) { $reftoshow .= ' / '.$linkedobject["date_value"]; } - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetFont('', '', $default_font_size - 2); $pdf->MultiCell($w, $h, $reftoshow, '', $align); @@ -1185,22 +1185,22 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos { global $db, $conf, $langs, $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code); - $action=''; - $reshook=$hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('pdf'=>$pdf, 'i'=>$i, 'outputlangs'=>$outputlangs, 'w'=>$w, 'h'=>$h, 'posx'=>$posx, 'posy'=>$posy, 'hideref'=>$hideref, 'hidedesc'=>$hidedesc, 'issupplierline'=>$issupplierline, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $labelproductservice=pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline); + $labelproductservice = pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline); //var_dump($labelproductservice);exit; @@ -1212,7 +1212,7 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos // Description $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, 'J', true); - $result.=$labelproductservice; + $result .= $labelproductservice; } return $result; } @@ -1232,12 +1232,12 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { global $db, $conf, $langs; - $idprod=(! empty($object->lines[$i]->fk_product)?$object->lines[$i]->fk_product:false); - $label=(! empty($object->lines[$i]->label)?$object->lines[$i]->label:(! empty($object->lines[$i]->product_label)?$object->lines[$i]->product_label:'')); - $desc=(! empty($object->lines[$i]->desc)?$object->lines[$i]->desc:(! empty($object->lines[$i]->description)?$object->lines[$i]->description:'')); - $ref_supplier=(! empty($object->lines[$i]->ref_supplier)?$object->lines[$i]->ref_supplier:(! empty($object->lines[$i]->ref_fourn)?$object->lines[$i]->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders - $note=(! empty($object->lines[$i]->note)?$object->lines[$i]->note:''); - $dbatch=(! empty($object->lines[$i]->detail_batch)?$object->lines[$i]->detail_batch:false); + $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); + $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); + $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); + $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders + $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); + $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); if ($issupplierline) { @@ -1254,9 +1254,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated - if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) + if (!empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) { - $translatealsoifmodified=(! empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) + $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation // ($textwasmodified is replaced with $textwasmodifiedorcompleted and we add completion). @@ -1264,63 +1264,63 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Set label // If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation. //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit; - $textwasmodified=($label == $prodser->label); - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; + $textwasmodified = ($label == $prodser->label); + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label = $prodser->multilangs[$outputlangs->defaultlang]["label"]; // Set desc // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no - $textwasmodified=false; + $textwasmodified = false; if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) { - $textwasmodified=(strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401))!==false); + $textwasmodified = (strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401)) !== false); } else { - $textwasmodified=($desc == $prodser->description); + $textwasmodified = ($desc == $prodser->description); } - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"]; // Set note - $textwasmodified=($note == $prodser->note); - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; + $textwasmodified = ($note == $prodser->note); + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; } } // Description short of product line - $libelleproduitservice=$label; + $libelleproduitservice = $label; // Description long of product line - if (! empty($desc) && ($desc != $label)) + if (!empty($desc) && ($desc != $label)) { if ($libelleproduitservice && empty($hidedesc)) { - $libelleproduitservice.='__N__'; + $libelleproduitservice .= '__N__'; } if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); // Add date of deposit - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; } if ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); } elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { @@ -1330,17 +1330,17 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) { - $libelleproduitservice=$desc."\n".$libelleproduitservice; + $libelleproduitservice = $desc."\n".$libelleproduitservice; } else { - $libelleproduitservice.=$desc; + $libelleproduitservice .= $desc; } } } else { - $libelleproduitservice.=$desc; + $libelleproduitservice .= $desc; } } } @@ -1348,7 +1348,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // We add ref of product (and supplier ref if defined) $prefix_prodserv = ""; $ref_prodserv = ""; - if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this + if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this { if ($prodser->isService()) { @@ -1367,11 +1367,11 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) $ref_prodserv = $ref_supplier; elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) - $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; + $ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; else // Common case { $ref_prodserv = $prodser->ref; // Show local ref - if ($ref_supplier) $ref_prodserv.= ($prodser->ref?' (':'').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref?')':''); + if ($ref_supplier) $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : ''); } } else @@ -1379,72 +1379,72 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $ref_prodserv = $prodser->ref; // Show local ref only } - if (! empty($libelleproduitservice) && ! empty($ref_prodserv)) $ref_prodserv .= " - "; + if (!empty($libelleproduitservice) && !empty($ref_prodserv)) $ref_prodserv .= " - "; } - if(!empty($ref_prodserv) && !empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)){ $ref_prodserv = ''.$ref_prodserv.''; } - $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; + if (!empty($ref_prodserv) && !empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)) { $ref_prodserv = ''.$ref_prodserv.''; } + $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; // Add an additional description for the category products - if (! empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && ! empty($conf->categorie->enabled)) + if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $categstatic=new Categorie($db); + $categstatic = new Categorie($db); // recovering the list of all the categories linked to product - $tblcateg=$categstatic->containing($idprod, Categorie::TYPE_PRODUCT); + $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT); foreach ($tblcateg as $cate) { // Adding the descriptions if they are filled - $desccateg=$cate->add_description; + $desccateg = $cate->add_description; if ($desccateg) - $libelleproduitservice.='__N__'.$desccateg; + $libelleproduitservice .= '__N__'.$desccateg; } } - if (! empty($object->lines[$i]->date_start) || ! empty($object->lines[$i]->date_end)) + if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) { - $format='day'; + $format = 'day'; $period = ''; // Show duration if exists if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; } - if ($object->lines[$i]->date_start && ! $object->lines[$i]->date_end) + if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')'; } - if (! $object->lines[$i]->date_start && $object->lines[$i]->date_end) + if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; } //print '>'.$outputlangs->charset_output.','.$period; - if(!empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)){ - $libelleproduitservice.= ''."__N__ ".$period.''; + if (!empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)) { + $libelleproduitservice .= ''."__N__ ".$period.''; } else { - $libelleproduitservice.="__N__".$period; + $libelleproduitservice .= "__N__".$period; } //print $libelleproduitservice; } if ($dbatch) { - $format='day'; + $format = 'day'; foreach ($dbatch as $detail) { - $dte=array(); - if ($detail->eatby) $dte[]=$outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs)); - if ($detail->sellby) $dte[]=$outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs)); - if ($detail->batch) $dte[]=$outputlangs->transnoentitiesnoconv('printBatch', $detail->batch); - $dte[]=$outputlangs->transnoentitiesnoconv('printQty', $detail->qty); - $libelleproduitservice.= "__N__ ".implode(" - ", $dte); + $dte = array(); + if ($detail->eatby) $dte[] = $outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs)); + if ($detail->sellby) $dte[] = $outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs)); + if ($detail->batch) $dte[] = $outputlangs->transnoentitiesnoconv('printBatch', $detail->batch); + $dte[] = $outputlangs->transnoentitiesnoconv('printQty', $detail->qty); + $libelleproduitservice .= "__N__ ".implode(" - ", $dte); } } // Now we convert \n into br - if (dol_textishtml($libelleproduitservice)) $libelleproduitservice=preg_replace('/__N__/', '
    ', $libelleproduitservice); - else $libelleproduitservice=preg_replace('/__N__/', "\n", $libelleproduitservice); - $libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice, 1); + if (dol_textishtml($libelleproduitservice)) $libelleproduitservice = preg_replace('/__N__/', '
    ', $libelleproduitservice); + else $libelleproduitservice = preg_replace('/__N__/', "\n", $libelleproduitservice); + $libelleproduitservice = dol_htmlentitiesbr($libelleproduitservice, 1); return $libelleproduitservice; } @@ -1462,21 +1462,21 @@ function pdf_getlinenum($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinenum', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $result.=$hookmanager->resPrint; + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinenum', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $result.=dol_htmlentitiesbr($object->lines[$i]->num); + $result .= dol_htmlentitiesbr($object->lines[$i]->num); } return $result; } @@ -1495,21 +1495,21 @@ function pdf_getlineref($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineref', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $result.=$hookmanager->resPrint; + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineref', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $result.=dol_htmlentitiesbr($object->lines[$i]->product_ref); + $result .= dol_htmlentitiesbr($object->lines[$i]->product_ref); } return $result; } @@ -1527,21 +1527,21 @@ function pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $result.=$hookmanager->resPrint; + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $result.=dol_htmlentitiesbr($object->lines[$i]->ref_supplier); + $result .= dol_htmlentitiesbr($object->lines[$i]->ref_supplier); } return $result; } @@ -1559,47 +1559,47 @@ function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager, $mysoc; - $result=''; - $reshook=0; + $result = ''; + $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if (empty($hidedetails) || $hidedetails > 1) { - $tmpresult=''; + $tmpresult = ''; - $tmpresult.=vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); + $tmpresult .= vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) { if ($object->lines[$i]->total_localtax1 != 0) { - if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult.='/'; - else $tmpresult=''; - $tmpresult.=vatrate(abs($object->lines[$i]->localtax1_tx), 0); + if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult .= '/'; + else $tmpresult = ''; + $tmpresult .= vatrate(abs($object->lines[$i]->localtax1_tx), 0); } } if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) { if ($object->lines[$i]->total_localtax2 != 0) { - if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult.='/'; - else $tmpresult=''; - $tmpresult.=vatrate(abs($object->lines[$i]->localtax2_tx), 0); + if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult .= '/'; + else $tmpresult = ''; + $tmpresult .= vatrate(abs($object->lines[$i]->localtax2_tx), 0); } } - $tmpresult.= '%'; + $tmpresult .= '%'; - $result.=$tmpresult; + $result .= $tmpresult; } } return $result; @@ -1618,28 +1618,28 @@ function pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $result=''; - $reshook=0; + $result = ''; + $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if (empty($hidedetails) || $hidedetails > 1) { $subprice = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice); - $result.=price($sign * $subprice, 0, $outputlangs); + $result .= price($sign * $subprice, 0, $outputlangs); } } return $result; @@ -1656,27 +1656,27 @@ function pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails = 0) */ function pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails = 0) { - global $hookmanager,$conf; + global $hookmanager, $conf; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $result=''; - $reshook=0; + $result = ''; + $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { - if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs); + if (empty($hidedetails) || $hidedetails > 1) $result .= price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs); } return $result; } @@ -1694,23 +1694,23 @@ function pdf_getlineqty($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $result=''; - $reshook=0; + $result = ''; + $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineqty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineqty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result = $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty; + if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty; } return $result; } @@ -1728,23 +1728,23 @@ function pdf_getlineqty_asked($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty_asked; + if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_asked; } return $result; } @@ -1762,23 +1762,23 @@ function pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty_shipped; + if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_shipped; } return $result; } @@ -1796,23 +1796,23 @@ function pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); + if (empty($hidedetails) || $hidedetails > 1) $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); } return $result; } @@ -1831,8 +1831,8 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag { global $langs; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { @@ -1847,14 +1847,14 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag 'special_code' => $special_code ); $action = ''; - $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); + if (empty($hidedetails) || $hidedetails > 1) $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); } return $result; } @@ -1875,23 +1875,23 @@ function pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails = 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs); + if (empty($hidedetails) || $hidedetails > 1) $result .= dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs); } return $result; } @@ -1911,8 +1911,8 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm if (empty($hookmanager)) global $hookmanager; global $conf; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { @@ -1920,9 +1920,9 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code); $action = ''; - $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint; } if (empty($reshook)) { @@ -1936,10 +1936,10 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm { $prev_progress = $object->lines[$i]->get_prev_progress($object->id); } - $result = ($object->lines[$i]->situation_percent - $prev_progress) . '%'; + $result = ($object->lines[$i]->situation_percent - $prev_progress).'%'; } else - $result = $object->lines[$i]->situation_percent . '%'; + $result = $object->lines[$i]->situation_percent.'%'; } } return $result; @@ -1958,21 +1958,21 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code, 'sign'=>$sign); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code, 'sign'=>$sign); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { @@ -1993,11 +1993,11 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) $prev_progress = $object->lines[$i]->get_prev_progress($object->id); $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100; } - $result.=price($sign * ($total_ht/($object->lines[$i]->situation_percent/100)) * $progress, 0, $outputlangs); + $result .= price($sign * ($total_ht / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs); } else { - $result.=price($sign * $total_ht, 0, $outputlangs); + $result .= price($sign * $total_ht, 0, $outputlangs); } } } @@ -2015,31 +2015,31 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) */ function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0) { - global $hookmanager,$conf; + global $hookmanager, $conf; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) { - $result.=$outputlangs->transnoentities("Option"); + $result .= $outputlangs->transnoentities("Option"); } - elseif (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); + elseif (empty($hidedetails) || $hidedetails > 1) $result .= price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht) * ($object->lines[$i]->tva_tx) / 100, 0, $outputlangs); } return $result; } @@ -2057,32 +2057,32 @@ function pdf_getTotalQty($object, $type, $outputlangs) { global $hookmanager; - $total=0; - $nblines=count($object->lines); + $total = 0; + $nblines = count($object->lines); // Loop on each lines - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if ($object->lines[$i]->special_code != 3) { - if ($type=='all') + if ($type == 'all') { $total += $object->lines[$i]->qty; } - elseif ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) + elseif ($type == 9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getTotalQty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getTotalQty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks return $hookmanager->resPrint; } - elseif ($type==0 && $object->lines[$i]->product_type == 0) + elseif ($type == 0 && $object->lines[$i]->product_type == 0) { $total += $object->lines[$i]->qty; } - elseif ($type==1 && $object->lines[$i]->product_type == 1) + elseif ($type == 1 && $object->lines[$i]->product_type == 1) { $total += $object->lines[$i]->qty; } @@ -2104,11 +2104,11 @@ function pdf_getLinkedObjects($object, $outputlangs) { global $hookmanager; - $linkedobjects=array(); + $linkedobjects = array(); $object->fetchObjectLinked(); - foreach($object->linkedObjects as $objecttype => $objects) + foreach ($object->linkedObjects as $objecttype => $objects) { if ($objecttype == 'facture') { @@ -2118,7 +2118,7 @@ function pdf_getLinkedObjects($object, $outputlangs) { $outputlangs->load('propal'); - foreach($objects as $elementobject) + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); @@ -2129,10 +2129,10 @@ function pdf_getLinkedObjects($object, $outputlangs) elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') { $outputlangs->load('orders'); - foreach($objects as $elementobject) + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder"); - $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref) . ($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '') . ($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : ''); + $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : ''); $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate"); $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs); } @@ -2140,7 +2140,7 @@ function pdf_getLinkedObjects($object, $outputlangs) elseif ($objecttype == 'contrat') { $outputlangs->load('contracts'); - foreach($objects as $elementobject) + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); @@ -2152,29 +2152,29 @@ function pdf_getLinkedObjects($object, $outputlangs) { $outputlangs->loadLangs(array("orders", "sendings")); - foreach($objects as $x => $elementobject) + foreach ($objects as $x => $elementobject) { - $order=null; + $order = null; // We concat this record info into fields xxx_value. title is overwrote. if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order { $elementobject->fetchObjectLinked(); - if (! empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); + if (!empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); } - if (! is_object($order)) + if (!is_object($order)) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending"); - if (! empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'].=' / '; - $linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref); + if (!empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] .= ' / '; + $linkedobjects[$objecttype]['ref_value'] .= $outputlangs->transnoentities($elementobject->ref); //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateShipment"); //if (! empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'].=' / '; //$linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs); } else { - $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending"); - if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : ''); - $linkedobjects[$objecttype]['ref_value'].= ' / ' . $outputlangs->transnoentities($elementobject->ref); + $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending"); + if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : ''); + $linkedobjects[$objecttype]['ref_value'] .= ' / '.$outputlangs->transnoentities($elementobject->ref); //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ($elementobject->date_delivery ? ' / ' . $outputlangs->transnoentities("DateShipment") : ''); //if (empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date,'day','',$outputlangs); //$linkedobjects[$objecttype]['date_value'].= ($elementobject->date_delivery ? ' / ' . dol_print_date($elementobject->date_delivery,'day','',$outputlangs) : ''); @@ -2187,9 +2187,9 @@ function pdf_getLinkedObjects($object, $outputlangs) if (is_object($hookmanager)) { $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); - $action=''; - $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; + $action = ''; + $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; } return $linkedobjects; @@ -2206,24 +2206,24 @@ function pdf_getSizeForImage($realpath) { global $conf; - $maxwidth=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); - $maxheight=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT)?32:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT); + $maxwidth = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); + $maxheight = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT) ? 32 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT); include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $tmp=dol_getImageSize($realpath); + $tmp = dol_getImageSize($realpath); if ($tmp['height']) { - $width=(int) round($maxheight*$tmp['width']/$tmp['height']); // I try to use maxheight + $width = (int) round($maxheight * $tmp['width'] / $tmp['height']); // I try to use maxheight if ($width > $maxwidth) // Pb with maxheight, so i use maxwidth { - $width=$maxwidth; - $height=(int) round($maxwidth*$tmp['height']/$tmp['width']); + $width = $maxwidth; + $height = (int) round($maxwidth * $tmp['height'] / $tmp['width']); } else // No pb with maxheight { - $height=$maxheight; + $height = $maxheight; } } - return array('width'=>$width,'height'=>$height); + return array('width'=>$width, 'height'=>$height); } /** @@ -2238,8 +2238,8 @@ function pdf_getSizeForImage($realpath) function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; if ($object->lines[$i]->special_code == 3) { return $outputlangs->transnoentities("Option"); @@ -2249,7 +2249,7 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = if (is_object($hookmanager)) { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); $parameters = array( 'i'=>$i, @@ -2258,15 +2258,15 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = 'special_code'=>$special_code ); - $action=''; + $action = ''; - if( $hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action)>0) + if ($hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action) > 0) { - return $hookmanager->resPrint; // Note that $action and $object may have been modified by some hooks + return $hookmanager->resPrint; // Note that $action and $object may have been modified by some hooks } } - if (empty($hidedetails) || $hidedetails > 1) return $sign * ( ($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht ); + if (empty($hidedetails) || $hidedetails > 1) return $sign * (($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht); } return ''; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 21df0301d49..875705cd8c3 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -48,7 +48,7 @@ function project_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id; $head[$h][1] = $langs->trans("ProjectContact"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; @@ -59,13 +59,13 @@ function project_prepare_head($object) $head[$h][1] = $langs->trans("Tasks"); require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; - $taskstatic=new Task($db); - $nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); - if ($nbTasks > 0) $head[$h][1].= ''.($nbTasks).''; + $taskstatic = new Task($db); + $nbTasks = count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); + if ($nbTasks > 0) $head[$h][1] .= ''.($nbTasks).''; $head[$h][2] = 'tasks'; $h++; - $nbTimeSpent=0; + $nbTimeSpent = 0; $sql = "SELECT t.rowid"; //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; @@ -76,20 +76,20 @@ function project_prepare_head($object) if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $nbTimeSpent=1; + if ($obj) $nbTimeSpent = 1; } else dol_print_error($db); $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; $head[$h][1] = $langs->trans("TimeSpent"); - if ($nbTimeSpent > 0) $head[$h][1].= '...'; + if ($nbTimeSpent > 0) $head[$h][1] .= '...'; $head[$h][2] = 'timespent'; $h++; } - if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) - || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled) - || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled)) + if (!empty($conf->fournisseur->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) + || !empty($conf->facture->enabled) || !empty($conf->contrat->enabled) + || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled)) { $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id; $head[$h][1] = $langs->trans("ProjectOverview"); @@ -107,23 +107,23 @@ function project_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ' '.$nbNote.''; $head[$h][2] = 'notes'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; @@ -133,17 +133,17 @@ function project_prepare_head($object) $nbComments = $object->getNbComments(); $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id; $head[$h][1] = $langs->trans("CommentLink"); - if ($nbComments > 0) $head[$h][1].= ''.$nbComments.''; + if ($nbComments > 0) $head[$h][1] .= ''.$nbComments.''; $head[$h][2] = 'project_comment'; $h++; } $head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id; - $head[$h][1].= $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + $head[$h][1] .= $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; @@ -166,20 +166,20 @@ function task_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'task_task'; $h++; $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans("TaskRessourceLinks"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'task_contact'; $h++; // Is there timespent ? - $nbTimeSpent=0; + $nbTimeSpent = 0; $sql = "SELECT t.rowid"; //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; @@ -189,13 +189,13 @@ function task_prepare_head($object) if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $nbTimeSpent=1; + if ($obj) $nbTimeSpent = 1; } else dol_print_error($db); - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans("TimeSpent"); - if ($nbTimeSpent > 0) $head[$h][1].= '...'; + if ($nbTimeSpent > 0) $head[$h][1] .= '...'; $head[$h][2] = 'task_time'; $h++; @@ -208,23 +208,23 @@ function task_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'task_notes'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); - $filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); + $filesdir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->project->ref).'/'.dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $nbFiles = count(dol_dir_list($filesdir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'task_document'; $h++; @@ -232,9 +232,9 @@ function task_prepare_head($object) if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) { $nbComments = $object->getNbComments(); - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans("CommentLink"); - if ($nbComments > 0) $head[$h][1].= ''.$nbComments.''; + if ($nbComments > 0) $head[$h][1] .= ''.$nbComments.''; $head[$h][2] = 'task_comment'; $h++; } @@ -259,13 +259,13 @@ function project_timesheet_prepare_head($mode, $fuser = null) $h = 0; - $param=''; - $param.=($mode?'&mode='.$mode:''); - if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id; + $param = ''; + $param .= ($mode ? '&mode='.$mode : ''); + if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id; if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) { - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerWeek"); $head[$h][2] = 'inputperweek'; $h++; @@ -273,7 +273,7 @@ function project_timesheet_prepare_head($mode, $fuser = null) if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) { - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerDay"); $head[$h][2] = 'inputperday'; $h++; @@ -353,10 +353,10 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t global $user, $bc, $langs, $conf, $db; global $projectstatic, $taskstatic; - $lastprojectid=0; + $lastprojectid = 0; - $projectsArrayId=explode(',', $projectsListId); - if ($filterprogresscalc!=='') { + $projectsArrayId = explode(',', $projectsListId); + if ($filterprogresscalc !== '') { foreach ($lines as $key=>$line) { if (!empty($line->planned_workload) && !empty($line->duration)) { $filterprogresscalc = str_replace(' = ', ' == ', $filterprogresscalc); @@ -365,27 +365,27 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } } - $lines=array_values($lines); + $lines = array_values($lines); } - $numlines=count($lines); + $numlines = count($lines); // We declare counter as global because we want to edit them into recursive call global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned, $total_projectlinesa_declared_if_planned, $total_projectlinesa_tobill, $total_projectlinesa_billed; if ($level == 0) { - $total_projectlinesa_spent=0; - $total_projectlinesa_planned=0; - $total_projectlinesa_spent_if_planned=0; - $total_projectlinesa_declared_if_planned=0; - $total_projectlinesa_tobill=0; - $total_projectlinesa_billed=0; + $total_projectlinesa_spent = 0; + $total_projectlinesa_planned = 0; + $total_projectlinesa_spent_if_planned = 0; + $total_projectlinesa_declared_if_planned = 0; + $total_projectlinesa_tobill = 0; + $total_projectlinesa_billed = 0; } - for ($i = 0 ; $i < $numlines ; $i++) + for ($i = 0; $i < $numlines; $i++) { - if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines + if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines // Process line // print "i:".$i."-".$lines[$i]->fk_project.'
    '; @@ -393,26 +393,26 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines { // Show task line. - $showline=1; - $showlineingray=0; + $showline = 1; + $showlineingray = 0; // If there is filters to use if (is_array($taskrole)) { // If task not legitimate to show, search if a legitimate task exists later in tree - if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) + if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) { // So search if task has a subtask legitimate to show - $foundtaskforuserdeeper=0; + $foundtaskforuserdeeper = 0; searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole); //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'
    '; if ($foundtaskforuserdeeper > 0) { - $showlineingray=1; // We will show line but in gray + $showlineingray = 1; // We will show line but in gray } else { - $showline=0; // No reason to show line + $showline = 0; // No reason to show line } } } @@ -423,12 +423,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (empty($user->rights->projet->all->lire)) { // User is not allowed on this project and project is not public, so we hide line - if (! in_array($lines[$i]->fk_project, $projectsArrayId)) + if (!in_array($lines[$i]->fk_project, $projectsArrayId)) { // Note that having a user assigned to a task into a project user has no permission on, should not be possible // because assignement on task can be done only on contact of project. // If assignement was done and after, was removed from contact of project, then we can hide the line. - $showline=0; + $showline = 0; } } } @@ -439,26 +439,26 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { $var = !$var; - $lastprojectid=$lines[$i]->fk_project; + $lastprojectid = $lines[$i]->fk_project; } print '
    "; //if ($showlineingray) print ''; - if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); + if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); else print $projectstatic->getNomUrl(1, 'nolink'); //if ($showlineingray) print ''; print "'; - $projectstatic->statut=$lines[$i]->projectstatus; + $projectstatic->statut = $lines[$i]->projectstatus; print $projectstatic->getLibStatut(2); print ""; if ($showlineingray) print ''; //else print ''; - for ($k = 0 ; $k < $level ; $k++) + for ($k = 0; $k < $level; $k++) { print '
    '; } print $lines[$i]->label; - for ($k = 0 ; $k < $level ; $k++) + for ($k = 0; $k < $level; $k++) { print '
    '; } @@ -518,15 +518,15 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); print '
    '; - $fullhour=convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); - $workingdelay=convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks + $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); + $workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks if ($lines[$i]->planned_workload != '') { print $fullhour; @@ -539,7 +539,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Time spent print ''; if ($showlineingray) print ''; - else print ''; + else print ''; if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); else print '--:--'; if ($showlineingray) print ''; @@ -600,20 +600,20 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Contacts of task - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { print ''; - foreach(array('internal','external') as $source) + foreach (array('internal', 'external') as $source) { $tab = $lines[$i]->liste_contact(-1, $source); - $num=count($tab); - if (!empty($num)){ - foreach ($tab as $contacttask){ + $num = count($tab); + if (!empty($num)) { + foreach ($tab as $contacttask) { //var_dump($contacttask); if ($source == 'internal') $c = new User($db); else $c = new Contact($db); $c->fetch($contacttask['id']); - print $c->getNomUrl(1) . ' (' . $contacttask['libelle'] . ')' . '
    '; + print $c->getNomUrl(1).' ('.$contacttask['libelle'].')'.'
    '; } } } @@ -628,7 +628,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print "
    '; - if ($projectidfortotallink > 0) print ''; + if ($projectidfortotallink > 0) print ''; print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); if ($projectidfortotallink > 0) print ''; print ''; print ''; - for ($k = 0 ; $k < $level ; $k++) print "   "; + for ($k = 0; $k < $level; $k++) print "   "; print $taskstatic->getNomUrl(1, 'withproject', 'time'); // Label task print '
    '; - for ($k = 0 ; $k < $level ; $k++) print "   "; + for ($k = 0; $k < $level; $k++) print "   "; print $taskstatic->label; //print "
    "; //for ($k = 0 ; $k < $level ; $k++) print "   "; @@ -878,20 +878,20 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec print dol_print_date($lines[$i]->timespent_datehour, 'day'); print '
    '; + print ''; $dayWorkLoad = $lines[$i]->timespent_duration; - $totalforeachline[$preselectedday]+=$lines[$i]->timespent_duration; + $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration; - $alreadyspent=''; - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); + $alreadyspent = ''; + if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); - $modeinput='hours'; + $modeinput = 'hours'; print ' '; diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php index e696be779d0..5c5274aba16 100644 --- a/htdocs/modulebuilder/admin/setup.php +++ b/htdocs/modulebuilder/admin/setup.php @@ -21,9 +21,9 @@ * \brief Page setup for modulebuilder module */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -global $conf,$langs,$user, $db; +global $conf, $langs, $user, $db; $langs->loadLangs(array("admin", "other", "modulebuilder")); if (!$user->admin || empty($conf->modulebuilder->enabled)) @@ -35,16 +35,16 @@ $backtopage = GETPOST('backtopage', 'alpha'); /* * Actions */ -if ($action=="update") +if ($action == "update") { - $res1=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'none'), 'chaine', 0, '', $conf->entity); - $res2=dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res3=dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res4=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_NAME', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_NAME', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res5=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_URL', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_URL', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res6=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_FAMILY', GETPOST('MODULEBUILDER_SPECIFIC_FAMILY', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res7=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_AUTHOR', GETPOST('MODULEBUILDER_SPECIFIC_AUTHOR', 'html'), 'chaine', 0, '', $conf->entity); - $res8=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_VERSION', GETPOST('MODULEBUILDER_SPECIFIC_VERSION', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res1 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'none'), 'chaine', 0, '', $conf->entity); + $res2 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res3 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res4 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_NAME', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_NAME', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res5 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_URL', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_URL', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res6 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_FAMILY', GETPOST('MODULEBUILDER_SPECIFIC_FAMILY', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res7 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_AUTHOR', GETPOST('MODULEBUILDER_SPECIFIC_AUTHOR', 'html'), 'chaine', 0, '', $conf->entity); + $res8 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_VERSION', GETPOST('MODULEBUILDER_SPECIFIC_VERSION', 'nohtml'), 'chaine', 0, '', $conf->entity); if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0 || $res7 < 0 || $res8 < 0) { setEventMessages('ErrorFailedToSaveDate', null, 'errors'); $db->rollback(); @@ -63,7 +63,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) { $values = implode(',', $values); if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); @@ -73,7 +73,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) { if (preg_match('/del_(.*)/', $action, $reg)) { $code = $reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { - Header("Location: " . $_SERVER["PHP_SELF"]); + Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); @@ -89,27 +89,27 @@ $form = new Form($db); llxHeader('', $langs->trans("ModulebuilderSetup")); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print '
    '; print ''; print ''; -print load_fiche_titre($langs->trans("ModuleSetup") . ' ' . $langs->trans('Modulebuilder'), $linkback); +print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('Modulebuilder'), $linkback); if (GETPOST('withtab', 'alpha')) { dol_fiche_head($head, 'modulebuilder', '', -1); } -print '' . $langs->trans("ModuleBuilderDesc") . "
    \n"; +print ''.$langs->trans("ModuleBuilderDesc")."
    \n"; print '
    '; print ''; print ''; -print ''; -print ''; +print ''; +print ''; print "\n"; @@ -118,49 +118,49 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is use cas of this 2 options ? 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 ''; @@ -168,14 +168,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) } print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; // Categories - if($conf->categorie->enabled) { + if ($conf->categorie->enabled) { print '"; @@ -1095,11 +1095,11 @@ elseif ($object->id > 0) print ''; // Change probability from status - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Default value to close or not when we set opp to 'WON'. - $defaultcheckedwhenoppclose=1; - if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0; + $defaultcheckedwhenoppclose = 1; + if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose = 0; print ''; print ''; $stringtoshow .= '
    '; // hideobject is to start hidden -$stringtoshow .= '
    '; -$stringtoshow .= ''; +$stringtoshow .= ''; +$stringtoshow .= ''; $stringtoshow .= ''; -$stringtoshow .= $langs->trans("Year") . ' '; -$stringtoshow .= ''; +$stringtoshow .= $langs->trans("Year").' '; +$stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= '
    '; print '
    '; print '
    ' . $langs->trans("Key") . '' . $langs->trans("Value") . ''.$langs->trans("Key").''.$langs->trans("Value").'
    ' . $langs->trans("UseAboutPage") . ''.$langs->trans("UseAboutPage").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('MODULEBUILDER_USE_ABOUT'); } else { if (empty($conf->global->MODULEBUILDER_USE_ABOUT)) { - print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { - print '' . img_picto($langs->trans("Enabled"), 'on') . ''; + print ''.img_picto($langs->trans("Enabled"), 'on').''; } } print '
    ' . $langs->trans("UseSpecificEditorName") . ''.$langs->trans("UseSpecificEditorName").''; print ''; print '
    ' . $langs->trans("UseSpecificEditorURL") . ''.$langs->trans("UseSpecificEditorURL").''; print ''; print '
    ' . $langs->trans("UseSpecificFamily") . ''.$langs->trans("UseSpecificFamily").''; print ''; print '
    ' . $langs->trans("UseSpecificAuthor") . ''.$langs->trans("UseSpecificAuthor").''; print ''; print '
    ' . $langs->trans("UseSpecificVersion") . ''.$langs->trans("UseSpecificVersion").''; print ''; print '
    ' . $langs->trans("UseSpecificReadme") . ''.$langs->trans("UseSpecificReadme").''; print ''; print '
    ' . $langs->trans("AsciiToHtmlConverter") . ''.$langs->trans("AsciiToHtmlConverter").''; print ''; print ' '.$langs->trans("Example").': asciidoc, asciidoctor'; @@ -183,7 +183,7 @@ print '
    ' . $langs->trans("AsciiToPdfConverter") . ''.$langs->trans("AsciiToPdfConverter").''; print ''; print ' '.$langs->trans("Example").': asciidoctor-pdf'; diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 6c5f44fc732..56e7865a346 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -23,23 +23,23 @@ */ // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); global $langs, $user; // Libraries -require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/mymodule.lib.php'; //require_once "../class/myclass.class.php"; @@ -47,15 +47,15 @@ require_once '../lib/mymodule.lib.php'; $langs->loadLangs(array("admin", "mymodule@mymodule")); // Access control -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$arrayofparameters=array( - 'MYMODULE_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1), - 'MYMODULE_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1) +$arrayofparameters = array( + 'MYMODULE_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), + 'MYMODULE_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) ); @@ -79,7 +79,7 @@ $page_name = "MyModuleSetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mymodule@mymodule'); @@ -100,12 +100,12 @@ if ($action == 'edit') print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print '
    '; @@ -118,17 +118,17 @@ if ($action == 'edit') } else { - if (! empty($arrayofparameters)) + if (!empty($arrayofparameters)) { print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print '' . $conf->global->$key . '
    '.$conf->global->$key.'
    '; diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index f8161cb2917..0f71b0ceabf 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -99,19 +99,19 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre")) } } - if (! $testdate) { + if (!$testdate) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("ExpireDate")), null, 'errors'); } if ($titre && $testdate) { - if (! empty($creation_sondage_date)) + if (!empty($creation_sondage_date)) { header("Location: choix_date.php"); exit(); } - if (! empty($creation_sondage_autre)) + if (!empty($creation_sondage_autre)) { header("Location: choix_autre.php"); exit(); @@ -128,8 +128,8 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre")) $form = new Form($db); -$arrayofjs=array(); -$arrayofcss=array('/opensurvey/css/style.css'); +$arrayofjs = array(); +$arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $langs->trans("OpenSurvey"), '', "", 0, 0, $arrayofjs, $arrayofcss); print load_fiche_titre($langs->trans("CreatePoll").' (1 / 2)'); @@ -142,22 +142,22 @@ dol_fiche_head(); // Affichage des différents champs textes a remplir print ''."\n"; -print ''."\n"; -if (! $_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) +print ''."\n"; +if (!$_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PollTitle")), null, 'errors'); } print ''."\n"; -print ''."\n"; print ''."\n"; -print ''."\n"; print '
    '. $langs->trans("PollTitle") .'
    '.$langs->trans("PollTitle").'
    '. $langs->trans("Description") .''; -$doleditor=new DolEditor('commentaires', $_SESSION["commentaires"], '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); +print '
    '.$langs->trans("Description").''; +$doleditor = new DolEditor('commentaires', $_SESSION["commentaires"], '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); $doleditor->Create(0, ''); print '
    '. $langs->trans("ExpireDate") .''; +print '
    '.$langs->trans("ExpireDate").''; -print $form->selectDate($champdatefin?$champdatefin:-1, 'champdatefin', '', '', '', "add", 1, 0); +print $form->selectDate($champdatefin ? $champdatefin : -1, 'champdatefin', '', '', '', "add", 1, 0); print '
    '."\n"; @@ -173,16 +173,16 @@ print '
    '."\n"; // Check or not -if ($_SESSION["mailsonde"]) $cochemail="checked"; +if ($_SESSION["mailsonde"]) $cochemail = "checked"; -print ' '. $langs->trans("ToReceiveEMailForEachVote") .'
    '."\n"; +print ' '.$langs->trans("ToReceiveEMailForEachVote").'
    '."\n"; if ($_SESSION['allow_comments']) $allow_comments = 'checked'; -if (isset($_POST['allow_comments'])) $allow_comments=GETPOST('allow_comments')?'checked':''; +if (isset($_POST['allow_comments'])) $allow_comments = GETPOST('allow_comments') ? 'checked' : ''; print ' '.$langs->trans('CanComment').'
    '."\n"; if ($_SESSION['allow_spy']) $allow_spy = 'checked'; -if (isset($_POST['allow_spy'])) $allow_spy=GETPOST('allow_spy')?'checked':''; +if (isset($_POST['allow_spy'])) $allow_spy = GETPOST('allow_spy') ? 'checked' : ''; print ' '.$langs->trans('CanSeeOthersVote').'
    '."\n"; if (GETPOST('choix_sondage')) @@ -190,15 +190,15 @@ if (GETPOST('choix_sondage')) if (GETPOST('choix_sondage') == 'date') print ''; else print ''; print ''; - print '
    trans("TypeDate"):$langs->trans("TypeClassic")).')">'; + print '
    trans("TypeDate") : $langs->trans("TypeClassic")).')">'; } else { // Show image to selecte between date survey or other survey print '
    '."\n"; - print ' '."\n"; + print ' '."\n"; print ''."\n"; - print ' '."\n"; + print ' '."\n"; print ''."\n"; print '
    '. $langs->trans("CreateSurveyDate") .'
    '.$langs->trans("CreateSurveyDate").'
    '. $langs->trans("CreateSurveyStandard") .'
    '.$langs->trans("CreateSurveyStandard").'
    '."\n"; } diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index cea14170602..11c2e91b233 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -31,12 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $search_project_user = GETPOST('search_project_user', 'int'); -$mine = GETPOST('mode', 'aZ09')=='mine' ? 1 : 0; +$mine = GETPOST('mode', 'aZ09') == 'mine' ? 1 : 0; if ($search_project_user == $user->id) $mine = 1; // Security check -$socid=0; -if ($user->socid > 0) $socid=$user->socid; +$socid = 0; +if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'projet', $projectid); if (!$user->rights->projet->lire) accessforbidden(); @@ -54,36 +54,36 @@ $langs->load("projects"); */ $now = dol_now(); -$tmp=dol_getdate($now); -$day=$tmp['mday']; -$month=$tmp['mon']; -$year=$tmp['year']; +$tmp = dol_getdate($now); +$day = $tmp['mday']; +$month = $tmp['mon']; +$year = $tmp['year']; -$projectstatic=new Project($db); -$taskstatic=new Task($db); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project -$taskstatic=new Task($db); -$tasktmp=new Task($db); +$projectstatic = new Project($db); +$taskstatic = new Task($db); +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project +$taskstatic = new Task($db); +$tasktmp = new Task($db); -$title=$langs->trans("Activities"); +$title = $langs->trans("Activities"); //if ($mine) $title=$langs->trans("MyActivities"); llxHeader("", $title); // Title for combo list see all projects -$titleall=$langs->trans("AllAllowedProjects"); -if (! empty($user->rights->projet->all->lire) && ! $socid) $titleall=$langs->trans("AllProjects"); -else $titleall=$langs->trans("AllAllowedProjects").'

    '; +$titleall = $langs->trans("AllAllowedProjects"); +if (!empty($user->rights->projet->all->lire) && !$socid) $titleall = $langs->trans("AllProjects"); +else $titleall = $langs->trans("AllAllowedProjects").'

    '; -$morehtml=''; -$morehtml.=''; -$morehtml.=''; -$morehtml.=''; +$morehtml = ''; +$morehtml .= ''; +$morehtml .= ''; +$morehtml .= ''; print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'project', 0, $morehtml); //print load_fiche_titre($title, '', 'project'); @@ -91,7 +91,7 @@ print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'proje if ($mine) print $langs->trans("MyTasksDesc").'

    '; else { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("TasksDesc").'

    '; + if ($user->rights->projet->all->lire && !$socid) print $langs->trans("TasksDesc").'

    '; else print $langs->trans("TasksPublicDesc").'

    '; } @@ -99,12 +99,12 @@ else print '
    '; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search project - if (! empty($conf->projet->enabled) && $user->rights->projet->lire) + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { - $listofsearchfields['search_task']=array('text'=>'Task'); + $listofsearchfields['search_task'] = array('text'=>'Task'); } if (count($listofsearchfields)) @@ -113,8 +113,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; print '
    '; print ''; - $i=0; - foreach($listofsearchfields as $key => $value) + $i = 0; + foreach ($listofsearchfields as $key => $value) { if ($i == 0) print ''; print ''; @@ -140,30 +140,30 @@ print ''; print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; -$sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; -$sql.= " WHERE t.fk_projet = p.rowid"; -$sql.= " AND p.entity = ".$conf->entity; -$sql.= " AND tt.fk_task = t.rowid"; -$sql.= " AND tt.fk_user = ".$user->id; -$sql.= " AND task_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; -$sql.= " AND p.rowid in (".$projectsListId.")"; -$sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; +$sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; +$sql .= " WHERE t.fk_projet = p.rowid"; +$sql .= " AND p.entity = ".$conf->entity; +$sql .= " AND tt.fk_task = t.rowid"; +$sql .= " AND tt.fk_user = ".$user->id; +$sql .= " AND task_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; +$sql .= " AND p.rowid in (".$projectsListId.")"; +$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); -if ( $resql ) +if ($resql) { - $total=0; + $total = 0; while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -197,30 +197,30 @@ print ''; print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; -$sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; -$sql.= " WHERE t.fk_projet = p.rowid"; -$sql.= " AND p.entity = ".$conf->entity; -$sql.= " AND tt.fk_task = t.rowid"; -$sql.= " AND tt.fk_user = ".$user->id; -$sql.= " AND task_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'"; -$sql.= " AND p.rowid in (".$projectsListId.")"; -$sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; +$sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; +$sql .= " WHERE t.fk_projet = p.rowid"; +$sql .= " AND p.entity = ".$conf->entity; +$sql .= " AND tt.fk_task = t.rowid"; +$sql .= " AND tt.fk_user = ".$user->id; +$sql .= " AND task_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'"; +$sql .= " AND p.rowid in (".$projectsListId.")"; +$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); -if ( $resql ) +if ($resql) { - $total=0; + $total = 0; while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -304,7 +304,7 @@ if ($db->type != 'pgsql') */ /* Affichage de la liste des projets du mois */ -if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) +if (!empty($conf->global->PROJECT_TASK_TIME_MONTH)) { print '
    '; print '
    '.$langs->trans("Search").'
    '.$langs->trans("Time").'
    '; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - $projectstatic->public=$row->public; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; + $projectstatic->public = $row->public; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').''.$langs->trans("Time").'
    '; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - $projectstatic->public=$row->public; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; + $projectstatic->public = $row->public; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').'
    '; @@ -314,27 +314,27 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; - $sql.= " WHERE t.fk_projet = p.rowid"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND tt.fk_task = t.rowid"; - $sql.= " AND tt.fk_user = ".$user->id; - $sql.= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'"; - $sql.= " AND p.rowid in (".$projectsListId.")"; - $sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; + $sql .= " WHERE t.fk_projet = p.rowid"; + $sql .= " AND p.entity = ".$conf->entity; + $sql .= " AND tt.fk_task = t.rowid"; + $sql .= " AND tt.fk_user = ".$user->id; + $sql .= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'"; + $sql .= " AND p.rowid in (".$projectsListId.")"; + $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -355,7 +355,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) } /* Affichage de la liste des projets de l'annee */ -if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) +if (!empty($conf->global->PROJECT_TASK_TIME_YEAR)) { print '
    '; print '
    '; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').'
    '; @@ -365,28 +365,28 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; - $sql.= " WHERE t.fk_projet = p.rowid"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND tt.fk_task = t.rowid"; - $sql.= " AND tt.fk_user = ".$user->id; - $sql.= " AND YEAR(task_date) = '".strftime("%Y", $now)."'"; - $sql.= " AND p.rowid in (".$projectsListId.")"; - $sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; + $sql .= " WHERE t.fk_projet = p.rowid"; + $sql .= " AND p.entity = ".$conf->entity; + $sql .= " AND tt.fk_task = t.rowid"; + $sql .= " AND tt.fk_user = ".$user->id; + $sql .= " AND YEAR(task_date) = '".strftime("%Y", $now)."'"; + $sql .= " AND p.rowid in (".$projectsListId.")"; + $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -406,72 +406,72 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) print ''; } -if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA)) +if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA)) { // Get id of types of contacts for projects (This list never contains a lot of elements) - $listofprojectcontacttype=array(); + $listofprojectcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sql.= " WHERE ctc.element = '" . $projectstatic->element . "'"; - $sql.= " AND ctc.source = 'internal'"; + $sql .= " WHERE ctc.element = '".$projectstatic->element."'"; + $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listofprojectcontacttype[$obj->rowid]=$obj->code; + $listofprojectcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); - if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found + if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found // Get id of types of contacts for tasks (This list never contains a lot of elements) - $listoftaskcontacttype=array(); + $listoftaskcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sql.= " WHERE ctc.element = '" . $taskstatic->element . "'"; - $sql.= " AND ctc.source = 'internal'"; + $sql .= " WHERE ctc.element = '".$taskstatic->element."'"; + $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listoftaskcontacttype[$obj->rowid]=$obj->code; + $listoftaskcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); - if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found + if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found // Tasks for all resources of all opened projects and time spent for each task/resource // This list can be very long, so we don't show it by default on task area. We prefer to use the list page. // Add constant PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA to show this list - $max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA); + $max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA) ? 1000 : $conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA); $sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdateo, p.datee as projdatee,"; - $sql.= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid"; + $sql .= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid"; if ($mine) { - $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ect"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect"; } - $sql.= " WHERE p.entity IN (".getEntity('project').")"; - if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; // project i have permission on + $sql .= " WHERE p.entity IN (".getEntity('project').")"; + if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; // project i have permission on if ($mine) // this may duplicate record if we are contact twice { - $sql.= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id; + $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id; } - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - $sql.= " AND p.fk_statut=1"; - $sql.= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee"; - $sql.= " ORDER BY t.dateo desc, t.rowid desc, t.datee"; - $sql.= $db->plimit($max+1); // We want more to know if we have more than limit + if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + $sql .= " AND p.fk_statut=1"; + $sql .= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee"; + $sql .= " ORDER BY t.dateo desc, t.rowid desc, t.datee"; + $sql .= $db->plimit($max + 1); // We want more to know if we have more than limit dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG); $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -483,7 +483,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print ''; //print ''; print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print ''; print ''; print ''; print ''; @@ -511,11 +511,11 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S $taskstatic->dateo = $db->jdate($obj->dateo); $taskstatic->datee = $db->jdate($obj->datee); - $username=''; + $username = ''; if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user { - $result=$userstatic->fetch($obj->userid); - if (! $result) $userstatic->id=0; + $result = $userstatic->fetch($obj->userid); + if (!$result) $userstatic->id = 0; } if ($userstatic->id) $username = $userstatic->getNomUrl(0, 0); @@ -524,7 +524,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print ''; } print ''; print ''; print ''; print "\n"; @@ -572,8 +572,8 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S if ($num > $max) { - $colspan=6; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++; + $colspan = 6; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++; print ''; } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 51af2f2b14d..493978f738e 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -36,57 +36,57 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('projects', 'companies')); -$id=GETPOST('id', 'int'); -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$backtopage=GETPOST('backtopage', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); -$confirm=GETPOST('confirm', 'aZ09'); -$status=GETPOST('status', 'int'); -$opp_status=GETPOST('opp_status', 'int'); -$opp_percent=price2num(GETPOST('opp_percent', 'alpha')); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'aZ09'); +$status = GETPOST('status', 'int'); +$opp_status = GETPOST('opp_status', 'int'); +$opp_percent = price2num(GETPOST('opp_percent', 'alpha')); -if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && ! $_POST["cancel"])) accessforbidden(); +if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && !$_POST["cancel"])) accessforbidden(); -$mine = GETPOST('mode')=='mine' ? 1 : 0; +$mine = GETPOST('mode') == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('projectcard','globalcard')); +$hookmanager->initHooks(array('projectcard', 'globalcard')); $object = new Project($db); $extrafields = new ExtraFields($db); // Load object //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Can't use generic include because when creating a project, ref is defined and we dont want error if fetch fails from ref. -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { - $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database + $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database if ($ret > 0) { $object->fetch_thirdparty(); - if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); - $id=$object->id; + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + $id = $object->id; } } // Security check -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $object->id, 'projet&project'); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$date_start=dol_mktime(0, 0, 0, GETPOST('projectstartmonth', 'int'), GETPOST('projectstartday', 'int'), GETPOST('projectstartyear', 'int')); -$date_end=dol_mktime(0, 0, 0, GETPOST('projectendmonth', 'int'), GETPOST('projectendday', 'int'), GETPOST('projectendyear', 'int')); +$date_start = dol_mktime(0, 0, 0, GETPOST('projectstartmonth', 'int'), GETPOST('projectstartday', 'int'), GETPOST('projectstartyear', 'int')); +$date_end = dol_mktime(0, 0, 0, GETPOST('projectendmonth', 'int'), GETPOST('projectendday', 'int'), GETPOST('projectendyear', 'int')); /* * Actions */ -$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas); +$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)) @@ -94,9 +94,9 @@ if (empty($reshook)) // Cancel if ($cancel) { - if (GETPOST("comefromclone")==1) + if (GETPOST("comefromclone") == 1) { - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { header("Location: index.php"); @@ -119,7 +119,7 @@ if (empty($reshook)) if ($action == 'add' && $user->rights->projet->creer) { - $error=0; + $error = 0; if (empty($_POST["ref"])) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); @@ -131,21 +131,21 @@ if (empty($reshook)) $error++; } - if (GETPOST('opp_amount') != '' && ! (GETPOST('opp_status') > 0)) + if (GETPOST('opp_amount') != '' && !(GETPOST('opp_status') > 0)) { $error++; setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } // Create with status validated immediatly - if (! empty($conf->global->PROJECT_CREATE_NO_DRAFT)) + if (!empty($conf->global->PROJECT_CREATE_NO_DRAFT)) { - $status=Project::STATUS_VALIDATED; + $status = Project::STATUS_VALIDATED; } - if (! $error) + if (!$error) { - $error=0; + $error = 0; $db->begin(); @@ -156,23 +156,23 @@ if (empty($reshook)) $object->public = GETPOST('public', 'alpha'); $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha')); $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha')); - $object->date_c = dol_now(); + $object->date_c = dol_now(); $object->date_start = $date_start; $object->date_end = $date_end; $object->statut = $status; $object->opp_status = $opp_status; $object->opp_percent = $opp_percent; - $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha')=='on'?1:0); - $object->usage_task = (GETPOST('usage_task', 'alpha')=='on'?1:0); - $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha')=='on'?1:0); - $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha')=='on'?1:0); + $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0); + $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0); + $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0); + $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; $result = $object->create($user); - if (! $error && $result > 0) + if (!$error && $result > 0) { // Add myself as project leader $result = $object->add_contact($user->id, 'PROJECTLEADER', 'internal'); @@ -189,26 +189,26 @@ if (empty($reshook)) setEventMessages($langs->trans($object->error), null, 'errors'); $error++; } - if (! $error && !empty($object->id) > 0) + if (!$error && !empty($object->id) > 0) { // Category association $categories = GETPOST('categories', 'array'); - $result=$object->setCategories($categories); - if ($result<0) { + $result = $object->setCategories($categories); + if ($result < 0) { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $error++; } } - if (! $error) + if (!$error) { $db->commit(); - if (! empty($backtopage)) + if (!empty($backtopage)) { - $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation - $backtopage = $backtopage.'&projectid='.$object->id; // Old method + $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation + $backtopage = $backtopage.'&projectid='.$object->id; // Old method header("Location: ".$backtopage); exit; } @@ -231,9 +231,9 @@ if (empty($reshook)) } } - if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) + if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) { - $error=0; + $error = 0; if (empty($ref)) { @@ -250,7 +250,7 @@ if (empty($reshook)) $db->begin(); - if (! $error) + if (!$error) { $object->oldcopy = clone $object; @@ -260,18 +260,18 @@ if (empty($reshook)) $object->title = GETPOST('title', 'none'); // Do not use 'alpha' here, we want field as it is $object->statut = GETPOST('status', 'int'); $object->socid = GETPOST('socid', 'int'); - $object->description = GETPOST('description', 'none'); // Do not use 'alpha' here, we want field as it is + $object->description = GETPOST('description', 'none'); // Do not use 'alpha' here, we want field as it is $object->public = GETPOST('public', 'alpha'); - $object->date_start = empty($_POST["projectstart"])?'':$date_start; - $object->date_end = empty($_POST["projectend"])?'':$date_end; + $object->date_start = empty($_POST["projectstart"]) ? '' : $date_start; + $object->date_end = empty($_POST["projectend"]) ? '' : $date_end; if (isset($_POST['opp_amount'])) $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha')); - if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount', 'alpha')); + if (isset($_POST['budget_amount'])) $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha')); if (isset($_POST['opp_status'])) $object->opp_status = $opp_status; if (isset($_POST['opp_percent'])) $object->opp_percent = $opp_percent; - $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha')=='on'?1:0); - $object->usage_task = (GETPOST('usage_task', 'alpha')=='on'?1:0); - $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha')=='on'?1:0); - $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha')=='on'?1:0); + $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0); + $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0); + $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0); + $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -284,18 +284,18 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } - if (! $error) + if (!$error) { - $result=$object->update($user); + $result = $object->update($user); if ($result < 0) { $error++; if ($result == -4) setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); else setEventMessages($object->error, $object->errors, 'errors'); - }else { + } else { // Category association $categories = GETPOST('categories', 'array'); - $result=$object->setCategories($categories); + $result = $object->setCategories($categories); if ($result < 0) { $error++; @@ -304,11 +304,11 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { - if (GETPOST("reportdate") && ($object->date_start!=$old_start_date)) + if (GETPOST("reportdate") && ($object->date_start != $old_start_date)) { - $result=$object->shiftTaskDate($old_start_date); + $result = $object->shiftTaskDate($old_start_date); if ($result < 0) { $error++; @@ -332,7 +332,7 @@ if (empty($reshook)) if ($error) { $db->rollback(); - $action='edit'; + $action = 'edit'; } else { @@ -355,11 +355,11 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); } - $result= $object->generateDocument($object->modelpdf, $outputlangs); + $result = $object->generateDocument($object->modelpdf, $outputlangs); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } @@ -368,11 +368,11 @@ if (empty($reshook)) { if ($object->id > 0) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("other"); $upload_dir = $conf->projet->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); + $file = $upload_dir.'/'.GETPOST('file'); $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); @@ -413,7 +413,7 @@ if (empty($reshook)) if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) { $object->fetch($id); - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); @@ -429,15 +429,15 @@ if (empty($reshook)) if ($action == 'confirm_clone' && $user->rights->projet->creer && $confirm == 'yes') { - $clone_contacts=GETPOST('clone_contacts')?1:0; - $clone_tasks=GETPOST('clone_tasks')?1:0; + $clone_contacts = GETPOST('clone_contacts') ? 1 : 0; + $clone_tasks = GETPOST('clone_tasks') ? 1 : 0; $clone_project_files = GETPOST('clone_project_files') ? 1 : 0; $clone_task_files = GETPOST('clone_task_files') ? 1 : 0; - $clone_notes=GETPOST('clone_notes')?1:0; - $move_date=GETPOST('move_date')?1:0; - $clone_thirdparty=GETPOST('socid', 'int')?GETPOST('socid', 'int'):0; + $clone_notes = GETPOST('clone_notes') ? 1 : 0; + $move_date = GETPOST('move_date') ? 1 : 0; + $clone_thirdparty = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : 0; - $result=$object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty); + $result = $object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -445,21 +445,21 @@ if (empty($reshook)) else { // Load new object - $newobject=new Project($db); + $newobject = new Project($db); $newobject->fetch($result); $newobject->fetch_optionals(); - $newobject->fetch_thirdparty(); // Load new object - $object=$newobject; - $action='edit'; - $comefromclone=true; + $newobject->fetch_thirdparty(); // Load new object + $object = $newobject; + $action = 'edit'; + $comefromclone = true; } } // Actions to send emails - $trigger_name='PROJECT_SENTBYMAIL'; - $paramname='id'; - $autocopy='MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add - $trackid='proj'.$object->id; + $trigger_name = 'PROJECT_SENTBYMAIL'; + $paramname = 'id'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add + $trackid = 'proj'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -473,21 +473,21 @@ $formfile = new FormFile($db); $formproject = new FormProjets($db); $userstatic = new User($db); -$title=$langs->trans("Project").' - '.$object->ref.($object->thirdparty->name?' - '.$object->thirdparty->name:'').($object->title?' - '.$object->title:''); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) $title=$object->ref.($object->thirdparty->name?' - '.$object->thirdparty->name:'').($object->title?' - '.$object->title:''); -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$title = $langs->trans("Project").' - '.$object->ref.($object->thirdparty->name ? ' - '.$object->thirdparty->name : '').($object->title ? ' - '.$object->title : ''); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) $title = $object->ref.($object->thirdparty->name ? ' - '.$object->thirdparty->name : '').($object->title ? ' - '.$object->title : ''); +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); -$titleboth=$langs->trans("LeadsOrProjects"); -$titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default +$titleboth = $langs->trans("LeadsOrProjects"); +$titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0) { - $titleboth=$langs->trans("Projects"); + $titleboth = $langs->trans("Projects"); $titlenew = $langs->trans("NewProject"); } if ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only - $titleboth=$langs->trans("Leads"); + $titleboth = $langs->trans("Leads"); $titlenew = $langs->trans("NewLead"); } @@ -497,7 +497,7 @@ if ($action == 'create' && $user->rights->projet->creer) * Create */ - $thirdparty=new Societe($db); + $thirdparty = new Societe($db); if ($socid > 0) $thirdparty->fetch($socid); print load_fiche_titre($titlenew, '', 'project'); @@ -511,18 +511,18 @@ if ($action == 'create' && $user->rights->projet->creer) print '
    '; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - $projectstatic->public=$row->public; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; + $projectstatic->public = $row->public; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').'
    '.$langs->trans('TaskRessourceLinks').''.$langs->trans('OpenedProjects').''.$langs->trans('OpportunityStatus').''.$langs->trans('OpportunityStatus').''.$langs->trans('Task').''.$langs->trans('DateStart').''.$langs->trans('DateEnd').''; print $projectstatic->getNomUrl(1, '', 0, '', '
    '); print '
    '; $code = dol_getIdFromCode($db, $obj->opp_status, 'c_lead_status', 'rowid', 'code'); @@ -532,7 +532,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print ''; - if (! empty($obj->taskid)) + if (!empty($obj->taskid)) { $tasktmp->id = $obj->taskid; $tasktmp->ref = $obj->ref; @@ -552,18 +552,18 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print convertSecondToTime($obj->timespent, 'allhourmin'); print ''; - if (! empty($obj->taskid)) + if (!empty($obj->taskid)) { if (empty($obj->planned_workload) > 0) { $percentcompletion = $langs->trans("WorkloadNotDefined"); } else { - $percentcompletion = intval($obj->duration_effective*100/$obj->planned_workload).'%'; + $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).'%'; } } print $percentcompletion; print ''; - print ($obj->taskid>0)?$obj->progress.'%':''; + print ($obj->taskid > 0) ? $obj->progress.'%' : ''; print '
    '.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").'
    '; - $defaultref=''; - $modele = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; + $defaultref = ''; + $modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON; // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); + $file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = $modele; break; } @@ -530,16 +530,16 @@ if ($action == 'create' && $user->rights->projet->creer) if ($filefound) { - $result=dol_include_once($reldir."core/modules/project/".$modele.'.php'); + $result = dol_include_once($reldir."core/modules/project/".$modele.'.php'); $modProject = new $classname; $defaultref = $modProject->getNextValue($thirdparty, $object); } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; // Ref - $suggestedref=($_POST["ref"]?$_POST["ref"]:$defaultref); + $suggestedref = ($_POST["ref"] ? $_POST["ref"] : $defaultref); print ''; @@ -552,23 +552,23 @@ if ($action == 'create' && $user->rights->projet->creer) print $langs->trans("Usage"); print ''; print ''; } @@ -612,46 +612,46 @@ if ($action == 'create' && $user->rights->projet->creer) // Visibility print ''; // Date start print ''; // Date end print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity status print ''; print ''; // Opportunity probability print ''; - print ''; print ''; // Opportunity amount print ''; - print ''; + print ''; print ''; } // Budget print ''; - print ''; + print ''; print ''; // Description @@ -664,14 +664,14 @@ if ($action == 'create' && $user->rights->projet->creer) // Categories print '"; } // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -684,7 +684,7 @@ if ($action == 'create' && $user->rights->projet->creer) print '
    '; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -692,7 +692,7 @@ if ($action == 'create' && $user->rights->projet->creer) else { print '     '; - print ''; + print ''; } print '
    '; @@ -721,7 +721,7 @@ elseif ($object->id > 0) * Show or edit */ - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); // To verify role of users $userAccess = $object->restrictedProjectArea($user, 'read'); @@ -748,26 +748,26 @@ elseif ($object->id > 0) // Confirmation delete if ($action == 'delete') { - $text=$langs->trans("ConfirmDeleteAProject"); - $task=new Task($db); - $taskarray=$task->getTasksArray(0, 0, $object->id, 0, 0); - $nboftask=count($taskarray); - if ($nboftask) $text.='
    '.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask); + $text = $langs->trans("ConfirmDeleteAProject"); + $task = new Task($db); + $taskarray = $task->getTasksArray(0, 0, $object->id, 0, 0); + $nboftask = count($taskarray); + if ($nboftask) $text .= '
    '.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAProject"), $text, "confirm_delete", '', '', 1); } // Clone confirmation if ($action == 'clone') { - $formquestion=array( + $formquestion = array( 'text' => $langs->trans("ConfirmClone"), - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int')>0?GETPOST('socid', 'int'):$object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')), - array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true), - array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_project_files','label' => $langs->trans("CloneProjectFiles"), 'value' => false), - array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')), + array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true), + array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_project_files', 'label' => $langs->trans("CloneProjectFiles"), 'value' => false), + array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) ); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300, 590); @@ -780,16 +780,16 @@ elseif ($object->id > 0) print ''; print ''; - $head=project_prepare_head($object); + $head = project_prepare_head($object); if ($action == 'edit' && $userWrite > 0) { - dol_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public?'projectpub':'project')); + dol_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public ? 'projectpub' : 'project')); print '
    '.$langs->trans("Ref").''; print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref)); print '
    '; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
    '; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
    '; } - if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
    '; @@ -584,20 +584,20 @@ if ($action == 'create' && $user->rights->projet->creer) if ($conf->societe->enabled) { print '
    '; - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print $langs->trans("ThirdParty"); - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print ''; - $filteronlist=''; - if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; - $text=$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300'); + $filteronlist = ''; + if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + $text = $form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300'); if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { - $texthelp=$langs->trans("IfNeedToUseOtherObjectKeepEmpty"); + $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1); } else print $text; - if (! GETPOSTISSET('backtopage')) print ' '.$langs->trans("AddThirdParty").''; + if (!GETPOSTISSET('backtopage')) print ' '.$langs->trans("AddThirdParty").''; print '
    '.$langs->trans("Visibility").''; - $array=array(); + $array = array(); if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); - print $form->selectarray('public', $array, GETPOST('public')?GETPOST('public'):$object->public); + print $form->selectarray('public', $array, GETPOST('public') ?GETPOST('public') : $object->public); print '
    '.$langs->trans("DateStart").''; - print $form->selectDate(($date_start?$date_start:''), 'projectstart', 0, 0, 0, '', 1, 0); + print $form->selectDate(($date_start ? $date_start : ''), 'projectstart', 0, 0, 0, '', 1, 0); print '
    '.$langs->trans("DateEnd").''; - print $form->selectDate(($date_end?$date_end:-1), 'projectend', 0, 0, 0, '', 1, 0); + print $form->selectDate(($date_end ? $date_end : -1), 'projectend', 0, 0, 0, '', 1, 0); print '
    '.$langs->trans("OpportunityStatus").''; - print $formproject->selectOpportunityStatus('opp_status', GETPOST('opp_status')?GETPOST('opp_status'):$object->opp_status); + print $formproject->selectOpportunityStatus('opp_status', GETPOST('opp_status') ?GETPOST('opp_status') : $object->opp_status); print '
    '.$langs->trans("OpportunityProbability").' %'; - print ''; + print ' %'; + print ''; print '
    '.$langs->trans("OpportunityAmount").'
    '.$langs->trans("Budget").'
    '.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1); - $arrayselected=GETPOST('categories', 'array'); + $arrayselected = GETPOST('categories', 'array'); print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); print "
    '; // Ref - $suggestedref=$object->ref; + $suggestedref = $object->ref; print ''; print ''; @@ -815,23 +815,23 @@ elseif ($object->id > 0) print $langs->trans("Usage"); print ''; print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity status print ''; @@ -881,33 +881,33 @@ elseif ($object->id > 0) // Opportunity probability print ''; - print ''; print ''; // Opportunity amount print ''; - print ''; + print ''; print ''; } // Date start print ''; // Date end print ''; // Budget print ''; - print ''; + print ''; print ''; // Description @@ -923,7 +923,7 @@ elseif ($object->id > 0) $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_PROJECT); - foreach($cats as $cat) { + foreach ($cats as $cat) { $arrayselected[] = $cat->id; } print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); @@ -931,8 +931,8 @@ elseif ($object->id > 0) } // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -943,28 +943,28 @@ elseif ($object->id > 0) } else { - dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); + dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); // Project card $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Title - $morehtmlref.=$object->title; + $morehtmlref .= $object->title; // Thirdparty - $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : '; + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '; if ($object->thirdparty->id > 0) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project'); } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; // Define a complementary filter for search of next/prev ref. - if (! $user->rights->projet->all->lire) + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")"; + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -981,23 +981,23 @@ elseif ($object->id > 0) print $langs->trans("Usage"); print ''; print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES) && ! empty($object->usage_opportunity)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) { // Opportunity status print ''; @@ -1050,7 +1050,7 @@ elseif ($object->id > 0) // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '.$langs->trans("Ref").''; print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref)); @@ -803,9 +803,9 @@ elseif ($object->id > 0) // Status print '
    '.$langs->trans("Status").''; print ''; print '
    '; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
    '; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; + print 'usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
    '; } - if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
    '; @@ -842,16 +842,16 @@ elseif ($object->id > 0) if ($conf->societe->enabled) { print '
    '; - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print $langs->trans("ThirdParty"); - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print ''; - $filteronlist=''; - if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; - $text=$form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300'); + $filteronlist = ''; + if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + $text = $form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300'); if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { - $texthelp=$langs->trans("IfNeedToUseOtherObjectKeepEmpty"); + $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2); } else print $text; @@ -860,13 +860,13 @@ elseif ($object->id > 0) // Visibility print '
    '.$langs->trans("Visibility").''; - $array=array(); + $array = array(); if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); print $form->selectarray('public', $array, $object->public); print '
    '.$langs->trans("OpportunityStatus").'
    '.$langs->trans("OpportunityProbability").' %'; + print ' %'; print ''; print '
    '.$langs->trans("OpportunityAmount").'
    '.$langs->trans("DateStart").''; - print $form->selectDate($object->date_start?$object->date_start:-1, 'projectstart', 0, 0, 0, '', 1, 0); + print $form->selectDate($object->date_start ? $object->date_start : -1, 'projectstart', 0, 0, 0, '', 1, 0); print '     '. $langs->trans("ProjectReportDate"); + if ($comefromclone) {print ' checked '; } + print '/> '.$langs->trans("ProjectReportDate"); print '
    '.$langs->trans("DateEnd").''; - print $form->selectDate($object->date_end?$object->date_end:-1, 'projectend', 0, 0, 0, '', 1, 0); + print $form->selectDate($object->date_end ? $object->date_end : -1, 'projectend', 0, 0, 0, '', 1, 0); print '
    '.$langs->trans("Budget").'
    '; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
    '; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; + print 'usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
    '; } - if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
    '; @@ -1010,7 +1010,7 @@ elseif ($object->id > 0) else print $langs->trans('PrivateProject'); print '
    '.$langs->trans("OpportunityStatus").''; @@ -1036,10 +1036,10 @@ elseif ($object->id > 0) // Date start - end print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start, 'day'); - print ($start?$start:'?'); + print ($start ? $start : '?'); $end = dol_print_date($object->date_end, 'day'); print ' - '; - print ($end?$end:'?'); + print ($end ? $end : '?'); if ($object->hasDelay()) print img_warning("Late"); print '
    '; @@ -1067,7 +1067,7 @@ elseif ($object->id > 0) print '
    '.$langs->trans("Categories").''; print $form->showCategories($object->id, 'project', 1); print "
    '; -print ''; +print ''; print ''; @@ -274,26 +274,26 @@ $max = 10; $sql = "SELECT t.rowid, t.ref, t.track_id, t.datec, t.subject, t.type_code, t.category_code, t.severity_code, t.fk_statut, t.progress,"; $sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label"; -$sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_type as type ON type.code=t.type_code"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_category as category ON category.code=t.category_code"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_severity as severity ON severity.code=t.severity_code"; +$sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -$sql .= ' WHERE t.entity IN (' . getEntity('ticket') . ')'; +$sql .= ' WHERE t.entity IN ('.getEntity('ticket').')'; $sql .= " AND t.fk_statut=0"; if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; + $sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($user->socid > 0) { - $sql .= " AND t.fk_soc='" . $user->socid . "'"; + $sql .= " AND t.fk_soc='".$user->socid."'"; } else { // Restricted to assigned user only if ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && !$user->rights->ticket->manage) { - $sql .= " AND t.fk_user_assign=" . $user->id; + $sql .= " AND t.fk_user_assign=".$user->id; } } $sql .= $db->order("t.datec", "DESC"); @@ -310,7 +310,7 @@ if ($result) { print '
    '; print '
    ' . $langs->trans("Statistics") . ' ' . img_picto('', 'filter.png', 'id="idsubimgDOLUSERCOOKIE_ticket_by_status" class="linkobject"') . '
    '.$langs->trans("Statistics").' '.img_picto('', 'filter.png', 'id="idsubimgDOLUSERCOOKIE_ticket_by_status" class="linkobject"').'
    '; print $stringtoshow; // don't display graph if no series -if (! empty($dataseries) && count($dataseries) > 1) { - $totalnb=0; +if (!empty($dataseries) && count($dataseries) > 1) { + $totalnb = 0; foreach ($dataseries as $key => $value) { $totalnb += $value['data']; } @@ -252,7 +252,7 @@ if (! empty($dataseries) && count($dataseries) > 1) { //$px1->SetTitle($langs->trans("TicketStatByStatus")); $px1->draw($filenamenb, $fileurlnb); - print $px1->show($totalnb?0:1); + print $px1->show($totalnb ? 0 : 1); } } print '
    '; - print ''; + print ''; print ''; print ''; if ($num > 0) { @@ -338,7 +338,7 @@ if ($result) { // Subject print '\n"; // Type @@ -366,7 +366,7 @@ if ($result) { $db->free(); } else { - print ''; + print ''; } print "
    ' . $transRecordedType . '
    '.$transRecordedType.''.$langs->trans("FullList").'
    '; - print '' . dol_trunc($objp->subject, 30) . ''; + print ''.dol_trunc($objp->subject, 30).''; print "
    ' . $langs->trans('NoUnreadTicketsFound') . '
    '.$langs->trans('NoUnreadTicketsFound').'
    "; diff --git a/htdocs/zapier/admin/setup.php b/htdocs/zapier/admin/setup.php index 0754f75bb3c..167da89cfe9 100644 --- a/htdocs/zapier/admin/setup.php +++ b/htdocs/zapier/admin/setup.php @@ -26,22 +26,22 @@ require '../../main.inc.php'; // Libraries -require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/zapier.lib.php'; // Translations $langs->loadLangs(array("admin", "zapier@zapier")); // Access control -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$arrayofparameters=array( - 'ZAPIERFORDOLIBARR_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1), - 'ZAPIERFORDOLIBARR_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1) +$arrayofparameters = array( + 'ZAPIERFORDOLIBARR_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), + 'ZAPIERFORDOLIBARR_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) ); @@ -61,7 +61,7 @@ $page_name = "ZapierSetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_zapier@zapier'); @@ -81,10 +81,10 @@ if ($action == 'edit') { print ''; print ''; - foreach($arrayofparameters as $key => $val) { + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '
    '; @@ -95,14 +95,14 @@ if ($action == 'edit') { print ''; print '
    '; } else { - if (! empty($arrayofparameters)) { + if (!empty($arrayofparameters)) { print ''; print ''; - foreach($arrayofparameters as $key => $val) { + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '' . $conf->global->$key . '
    '.$conf->global->$key.'
    '; From ac40dd8bbe76ebf3e48d19f0ded9592a7ad6dde0 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Wed, 13 Nov 2019 18:35:39 +0000 Subject: [PATCH 233/299] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/accountancy/admin/account.php | 162 +- htdocs/accountancy/admin/index.php | 88 +- htdocs/accountancy/bookkeeping/balance.php | 94 +- htdocs/accountancy/bookkeeping/card.php | 180 +- .../class/accountingjournal.class.php | 92 +- .../accountancy/class/bookkeeping.class.php | 648 ++--- htdocs/accountancy/index.php | 66 +- htdocs/adherents/admin/website.php | 64 +- htdocs/adherents/subscription.php | 430 ++-- htdocs/adherents/subscription/list.php | 354 +-- htdocs/adherents/type.php | 96 +- htdocs/admin/agenda_xcal.php | 70 +- htdocs/admin/boxes.php | 160 +- htdocs/admin/dav.php | 36 +- htdocs/admin/security.php | 78 +- htdocs/admin/ticket_public.php | 46 +- htdocs/api/admin/explorer.php | 46 +- htdocs/api/admin/index.php | 30 +- htdocs/asset/document.php | 46 +- htdocs/asset/note.php | 32 +- htdocs/asset/type.php | 122 +- htdocs/bom/bom_agenda.php | 64 +- htdocs/bom/bom_document.php | 44 +- htdocs/bom/bom_note.php | 32 +- htdocs/bom/tpl/objectline_create.tpl.php | 8 +- htdocs/bom/tpl/objectline_edit.tpl.php | 10 +- htdocs/bom/tpl/objectline_view.tpl.php | 14 +- htdocs/categories/card.php | 36 +- htdocs/categories/edit.php | 36 +- htdocs/categories/viewcat.php | 166 +- htdocs/comm/action/card.php | 568 ++--- htdocs/comm/card.php | 470 ++-- htdocs/comm/mailing/card.php | 448 ++-- .../mailing/class/advtargetemailing.class.php | 270 +- htdocs/comm/mailing/list.php | 94 +- htdocs/comm/propal/contact.php | 12 +- htdocs/comm/propal/document.php | 10 +- htdocs/comm/propal/note.php | 8 +- htdocs/commande/contact.php | 14 +- htdocs/commande/document.php | 18 +- htdocs/commande/info.php | 4 +- htdocs/commande/note.php | 4 +- htdocs/commande/orderstoinvoice.php | 212 +- htdocs/compta/bank/card.php | 210 +- htdocs/compta/bank/list.php | 176 +- htdocs/compta/bank/various_payment/card.php | 118 +- .../compta/bank/various_payment/document.php | 20 +- .../compta/cashcontrol/cashcontrol_card.php | 230 +- htdocs/compta/facture/contact.php | 16 +- htdocs/compta/facture/document.php | 68 +- htdocs/compta/facture/info.php | 52 +- .../compta/facture/invoicetemplate_list.php | 146 +- htdocs/compta/facture/note.php | 50 +- htdocs/compta/facture/prelevement.php | 130 +- htdocs/compta/paiement.php | 254 +- htdocs/contact/agenda.php | 98 +- htdocs/contact/card.php | 302 +-- htdocs/contrat/agenda.php | 56 +- htdocs/contrat/card.php | 494 ++-- htdocs/contrat/contact.php | 64 +- htdocs/contrat/document.php | 80 +- htdocs/contrat/note.php | 58 +- htdocs/contrat/services_list.php | 332 +-- .../box_accountancy_last_manual_entries.php | 10 +- .../box_accountancy_suspense_account.php | 8 +- htdocs/core/boxes/box_bookmarks.php | 38 +- .../core/class/commondocgenerator.class.php | 148 +- htdocs/core/class/commonobject.class.php | 2230 ++++++++--------- htdocs/core/class/cunits.class.php | 146 +- htdocs/core/class/discount.class.php | 234 +- htdocs/core/class/dolgraph.class.php | 302 +-- htdocs/core/class/extrafields.class.php | 866 +++---- htdocs/core/class/html.formactions.class.php | 138 +- htdocs/core/class/html.formcompany.class.php | 324 +-- htdocs/core/class/html.formticket.class.php | 242 +- htdocs/core/class/infobox.class.php | 124 +- htdocs/core/lib/company.lib.php | 534 ++-- htdocs/core/lib/cron.lib.php | 18 +- htdocs/core/lib/payments.lib.php | 62 +- htdocs/core/lib/product.lib.php | 72 +- htdocs/core/lib/project.lib.php | 234 +- htdocs/core/lib/signature.lib.php | 32 +- htdocs/core/lib/ticket.lib.php | 374 +-- .../modules/import/import_csv.modules.php | 378 +-- .../modules/import/import_xlsx.modules.php | 350 +-- htdocs/core/modules/modProduct.class.php | 224 +- htdocs/core/modules/modService.class.php | 224 +- .../doc/doc_generic_project_odt.modules.php | 504 ++-- .../generate/modGeneratePassPerso.class.php | 28 +- .../stock/doc/pdf_stdmovement.modules.php | 336 +-- htdocs/core/tpl/extrafields_add.tpl.php | 6 +- htdocs/core/tpl/extrafields_view.tpl.php | 22 +- htdocs/core/tpl/objectline_create.tpl.php | 26 +- htdocs/core/tpl/objectline_edit.tpl.php | 58 +- htdocs/core/tpl/objectline_view.tpl.php | 18 +- htdocs/core/tpl/onlinepaymentlinks.tpl.php | 34 +- htdocs/don/card.php | 164 +- htdocs/don/document.php | 22 +- htdocs/don/info.php | 6 +- htdocs/don/note.php | 6 +- htdocs/ecm/file_card.php | 130 +- htdocs/expedition/card.php | 644 ++--- htdocs/expedition/contact.php | 62 +- htdocs/expedition/document.php | 68 +- htdocs/expedition/note.php | 18 +- htdocs/expedition/shipment.php | 146 +- htdocs/fichinter/card-rec.php | 162 +- htdocs/fichinter/card.php | 386 +-- htdocs/fichinter/class/fichinterrec.class.php | 314 +-- htdocs/fichinter/contact.php | 20 +- htdocs/fichinter/document.php | 16 +- htdocs/fichinter/info.php | 38 +- htdocs/fichinter/note.php | 6 +- htdocs/fourn/card.php | 250 +- .../class/fournisseur.commande.class.php | 1420 +++++------ htdocs/fourn/commande/contact.php | 10 +- htdocs/fourn/commande/dispatch.php | 374 +-- htdocs/fourn/commande/document.php | 20 +- htdocs/fourn/commande/info.php | 40 +- htdocs/fourn/commande/note.php | 6 +- htdocs/fourn/facture/contact.php | 78 +- htdocs/fourn/facture/document.php | 86 +- htdocs/fourn/facture/info.php | 52 +- htdocs/fourn/facture/note.php | 28 +- htdocs/fourn/facture/paiement.php | 310 +-- htdocs/holiday/card.php | 320 +-- htdocs/holiday/document.php | 38 +- htdocs/livraison/card.php | 146 +- htdocs/loan/card.php | 212 +- htdocs/loan/document.php | 52 +- htdocs/loan/info.php | 30 +- htdocs/loan/note.php | 42 +- htdocs/opensurvey/card.php | 102 +- htdocs/opensurvey/results.php | 348 +-- htdocs/paypal/lib/paypal.lib.php | 324 +-- htdocs/product/class/api_products.class.php | 16 +- .../product/class/html.formproduct.class.php | 88 +- htdocs/product/inventory/card.php | 70 +- htdocs/product/stock/card.php | 186 +- htdocs/product/stock/movement_list.php | 400 +-- htdocs/projet/activity/perday.php | 330 +-- htdocs/projet/activity/perweek.php | 396 +-- htdocs/projet/card.php | 348 +-- htdocs/projet/class/project.class.php | 646 ++--- htdocs/projet/comment.php | 32 +- htdocs/projet/tasks/comment.php | 100 +- htdocs/projet/tasks/task.php | 166 +- htdocs/projet/tasks/time.php | 508 ++-- htdocs/public/members/new.php | 232 +- htdocs/public/members/public_card.php | 22 +- htdocs/public/ticket/list.php | 124 +- htdocs/public/ticket/view.php | 82 +- htdocs/reception/contact.php | 60 +- htdocs/reception/note.php | 18 +- htdocs/resource/class/dolresource.class.php | 540 ++-- htdocs/resource/list.php | 64 +- htdocs/salaries/card.php | 106 +- htdocs/societe/contact.php | 32 +- htdocs/stripe/admin/stripe.php | 120 +- htdocs/stripe/charge.php | 28 +- htdocs/stripe/class/actions_stripe.class.php | 136 +- htdocs/stripe/lib/stripe.lib.php | 88 +- htdocs/stripe/payout.php | 30 +- htdocs/stripe/transaction.php | 32 +- htdocs/supplier_proposal/contact.php | 10 +- htdocs/supplier_proposal/document.php | 14 +- htdocs/supplier_proposal/note.php | 6 +- htdocs/theme/eldy/global.inc.php | 156 +- htdocs/ticket/agenda.php | 48 +- htdocs/ticket/card.php | 236 +- htdocs/ticket/class/ticket.class.php | 561 +++-- htdocs/ticket/contact.php | 20 +- htdocs/ticket/document.php | 28 +- htdocs/ticket/messaging.php | 70 +- htdocs/user/class/user.class.php | 1020 ++++---- htdocs/user/clicktodial.php | 24 +- htdocs/user/group/perms.php | 82 +- htdocs/user/list.php | 218 +- htdocs/webservices/admin/index.php | 24 +- htdocs/webservices/server_actioncomm.php | 252 +- htdocs/webservices/server_contact.php | 316 +-- htdocs/webservices/server_order.php | 346 +-- .../webservices/server_productorservice.php | 386 +-- htdocs/webservices/server_project.php | 182 +- htdocs/webservices/server_thirdparty.php | 358 +-- htdocs/webservices/server_user.php | 412 +-- htdocs/zapier/hook_agenda.php | 84 +- htdocs/zapier/hook_card.php | 112 +- htdocs/zapier/hook_document.php | 58 +- htdocs/zapier/hook_note.php | 52 +- 190 files changed, 16675 insertions(+), 16676 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 10a65cab2fe..56d60281078 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -24,12 +24,12 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","admin","accountancy","salaries")); +$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries")); $mesg = ''; $action = GETPOST('action', 'aZ09'); @@ -37,7 +37,7 @@ $cancel = GETPOST('cancel', 'alpha'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); $massaction = GETPOST('massaction', 'aZ09'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'accountingaccountlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingaccountlist'; // To manage different context of search $search_account = GETPOST('search_account', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -58,10 +58,10 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield = "aa.account_number"; -if (! $sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "aa.account_number"; +if (!$sortorder) $sortorder = "ASC"; -$arrayfields=array( +$arrayfields = array( 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), @@ -78,27 +78,27 @@ $accounting = new AccountingAccount($db); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha')) { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; } -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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)) { - if (! empty($cancel)) $action = ''; + if (!empty($cancel)) $action = ''; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { $search_account = ""; $search_label = ""; $search_accountparent = ""; $search_pcgtype = ""; $search_pcgsubtype = ""; - $search_array_options=array(); + $search_array_options = array(); } if (GETPOST('change_chart', 'alpha') && (GETPOST('valid_change_chart', 'int') || empty($conf->use_javascript_ajax))) @@ -108,8 +108,8 @@ if (empty($reshook)) if ($chartofaccounts > 0) { // Get language code for this $chartofaccounts - $sql ='SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; - $sql.=' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; + $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; + $sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; $resql = $db->query($sql); if ($resql) { @@ -132,7 +132,7 @@ if (empty($reshook)) { $offsetforchartofaccount += $reg[1]; } - $offsetforchartofaccount+=($conf->entity * 100000000); + $offsetforchartofaccount += ($conf->entity * 100000000); $result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount); @@ -146,7 +146,7 @@ if (empty($reshook)) } } - if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { + if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { $error++; } } else { @@ -179,12 +179,12 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); llxHeader('', $langs->trans("ListAccounts")); if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); + $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); print $formconfirm; } @@ -192,11 +192,11 @@ $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, "; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = " . $conf->entity; -if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = " . $conf->entity; -else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = " . $conf->entity; -$sql .= " WHERE asy.rowid = " . $pcgver; +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity; +if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; +else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; +$sql .= " WHERE asy.rowid = ".$pcgver; //print $sql; if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account); if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); @@ -220,24 +220,24 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); -dol_syslog('accountancy/admin/account.php:: $sql=' . $sql); +dol_syslog('accountancy/admin/account.php:: $sql='.$sql); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_account) $param.= '&search_account='.urlencode($search_account); - if ($search_label) $param.= '&search_label='.urlencode($search_label); - if ($search_accountparent) $param.= '&search_accountparent='.urlencode($search_accountparent); - if ($search_pcgtype) $param.= '&search_pcgtype='.urlencode($search_pcgtype); - if ($search_pcgsubtype) $param.= '&search_pcgsubtype='.urlencode($search_pcgsubtype); - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($search_account) $param .= '&search_account='.urlencode($search_account); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_accountparent) $param .= '&search_accountparent='.urlencode($search_accountparent); + if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); + if ($search_pcgsubtype) $param .= '&search_pcgsubtype='.urlencode($search_pcgsubtype); + if ($optioncss != '') $param .= '&optioncss='.$optioncss; - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print ' '; } - print '
    '; + print ''; if ($optioncss != '') print ''; print ''; print ''; @@ -266,17 +266,17 @@ if ($resql) print ''; print ''; - $newcardbutton.= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); // Box to select active chart of account - print $langs->trans("Selectchartofaccounts") . " : "; + print $langs->trans("Selectchartofaccounts")." : "; print ''."\n"; + print '
    '."\n"; // Line for search fields print ''; - if (! empty($arrayfields['aa.account_number']['checked'])) print ''; - if (! empty($arrayfields['aa.label']['checked'])) print ''; - if (! empty($arrayfields['aa.account_parent']['checked'])) print ''; - if (! empty($arrayfields['aa.pcg_type']['checked'])) print ''; - if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print ''; - if (! empty($arrayfields['aa.active']['checked'])) print ''; + if (!empty($arrayfields['aa.account_number']['checked'])) print ''; + if (!empty($arrayfields['aa.label']['checked'])) print ''; + if (!empty($arrayfields['aa.account_parent']['checked'])) print ''; + if (!empty($arrayfields['aa.pcg_type']['checked'])) print ''; + if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print ''; + if (!empty($arrayfields['aa.active']['checked'])) print ''; print ''; print ''; print ''; - if (! empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); - if (! empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); - if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']); - if (! empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); + if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); + if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']); + if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; $accountstatic = new AccountingAccount($db); $accountparent = new AccountingAccount($db); - $i=0; + $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -351,27 +351,27 @@ if ($resql) print ''; // Account number - if (! empty($arrayfields['aa.account_number']['checked'])) + if (!empty($arrayfields['aa.account_number']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account label - if (! empty($arrayfields['aa.label']['checked'])) + if (!empty($arrayfields['aa.label']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account parent - if (! empty($arrayfields['aa.account_parent']['checked'])) + if (!empty($arrayfields['aa.account_parent']['checked'])) { - if (! empty($obj->account_parent)) + if (!empty($obj->account_parent)) { $accountparent->id = $obj->rowid2; $accountparent->label = $obj->label2; @@ -380,63 +380,63 @@ if ($resql) print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } else { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } } // Chart of accounts type - if (! empty($arrayfields['aa.pcg_type']['checked'])) + if (!empty($arrayfields['aa.pcg_type']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Chart of accounts subtype - if (! empty($arrayfields['aa.pcg_subtype']['checked'])) + if (!empty($arrayfields['aa.pcg_subtype']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Activated or not - if (! empty($arrayfields['aa.active']['checked'])) + if (!empty($arrayfields['aa.active']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action print '' . "\n"; - if (! $i) $totalarray['nbfield']++; + print ''."\n"; + if (!$i) $totalarray['nbfield']++; print "\n"; $i++; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index dcc2e608f0b..58a7d9a9d5e 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -29,11 +29,11 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","admin","accountancy")); +$langs->loadLangs(array("compta", "bills", "admin", "accountancy")); // Security access if (empty($user->rights->accounting->chartofaccount)) @@ -44,9 +44,9 @@ if (empty($user->rights->accounting->chartofaccount)) $action = GETPOST('action', 'aZ09'); // Parameters ACCOUNTING_* and others -$list = array ( +$list = array( 'ACCOUNTING_LENGTH_GACCOUNT', - 'ACCOUNTING_LENGTH_AACCOUNT' , + 'ACCOUNTING_LENGTH_AACCOUNT', // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc ); @@ -62,13 +62,13 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : if ($action == 'update') { $error = 0; - if (! $error) + if (!$error) { foreach ($list as $constname) { $constvalue = GETPOST($constname, 'alpha'); - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { $error++; } } @@ -77,7 +77,7 @@ if ($action == 'update') { } } - if (! $error) { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } } @@ -146,9 +146,9 @@ if ($action == 'setenabledraftexport') { if ($action == 'setenablesubsidiarylist') { $setenablesubsidiarylist = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); - if (! $res > 0) - $error ++; - if (! $error) { + if (!$res > 0) + $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'mesgs'); @@ -159,15 +159,15 @@ if ($action == 'setenablesubsidiarylist') { * View */ -$title= $langs->trans('ConfigAccountingExpert'); +$title = $langs->trans('ConfigAccountingExpert'); llxHeader('', $title); -$linkback=''; +$linkback = ''; //$linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy'); -print ''; -print ''; +print ''; +print ''; print ''; // Default mode for calculating turnover (parameter ACCOUNTING_MODE) @@ -204,85 +204,85 @@ print '
    '; print '
      '; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print '
    "; print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1); print ""; print $obj->label; print ""; print $accountparent->getNomUrl(1); print " "; print $obj->pcg_type; print ""; print $obj->pcg_subtype; print "'; if (empty($obj->active)) { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } print ''; if ($user->rights->accounting->chartofaccount) { - print ''; + print ''; print img_edit(); print ''; print ' '; - print ''; + print ''; print img_delete(); print ''; } - print '
    '; print ''; -print ''; +print ''; print "\n"; -if (! empty($user->admin)) +if (!empty($user->admin)) { // TO DO Mutualize code for yes/no constants print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { - print ''; + if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { - print ''; + if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { - print ''; + if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - print ''; + if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print ''; + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { - print ''; + if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { + print ''; } else { - print ''; } @@ -295,14 +295,14 @@ foreach ($list as $key) { print ''; - if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; + if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; // Param $label = $langs->trans($key); print ''; // Value print ''; print ''; @@ -311,7 +311,7 @@ foreach ($list as $key) print '
    ' . $langs->trans('OtherOptions') . ''.$langs->trans('OtherOptions').'
    ' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . ''; + print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    ' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . ''; + print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    ' . $langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL") . ''; + print ''.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    ' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . ''; + print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    ' . $langs->trans("ACCOUNTANCY_COMBO_FOR_AUX") . ''; + print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    ' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . ''; + print ''.$langs->trans("ACCOUNTING_MANAGE_ZERO").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
    '.$label.''; - print ''; + print ''; print '
    '; -print '
    '; +print '
    '; print '
    '; print '
    '; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 7d48790348d..02174ea2524 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -28,12 +28,12 @@ require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy")); @@ -45,7 +45,7 @@ $action = GETPOST('action', 'aZ09'); if (GETPOST("exportcsv", 'alpha')) $action = 'export_csv'; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -75,18 +75,18 @@ $formaccounting = new FormAccounting($db); $formother = new FormOther($db); $form = new Form($db); -if (empty($search_date_start) && ! GETPOSTISSET('formfilteraction')) +if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { - $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; - $sql.= $db->plimit(1); + $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; + $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; + $sql .= $db->plimit(1); $res = $db->query($sql); if ($res->num_rows > 0) { $fiscalYear = $db->fetch_object($res); $search_date_start = strtotime($fiscalYear->date_start); $search_date_end = strtotime($fiscalYear->date_end); } else { - $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); + $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $year_start = dol_print_date(dol_now(), '%Y'); $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -105,26 +105,26 @@ if ($sortfield == "") $sortfield = "t.numero_compte"; -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -$filter = array (); -if (! empty($search_date_start)) { +$filter = array(); +if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; - $param .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); + $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int').'&date_startday='.GETPOST('date_startday', 'int').'&date_startyear='.GETPOST('date_startyear', 'int'); } -if (! empty($search_date_end)) { +if (!empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; - $param .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); + $param .= '&date_endmonth='.GETPOST('date_endmonth', 'int').'&date_endday='.GETPOST('date_endday', 'int').'&date_endyear='.GETPOST('date_endyear', 'int'); } -if (! empty($search_accountancy_code_start)) { +if (!empty($search_accountancy_code_start)) { $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start=' . $search_accountancy_code_start; + $param .= '&search_accountancy_code_start='.$search_accountancy_code_start; } -if (! empty($search_accountancy_code_end)) { +if (!empty($search_accountancy_code_end)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end=' . $search_accountancy_code_end; + $param .= '&search_accountancy_code_end='.$search_accountancy_code_end; } /* @@ -151,7 +151,7 @@ if ($action == 'export_csv') $filename = 'balance'; $type_export = 'balance'; - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter); if ($result < 0) { @@ -160,11 +160,11 @@ if ($action == 'export_csv') foreach ($object->lines as $line) { - print length_accountg($line->numero_compte) . $sep; - print $object->get_compte_desc($line->numero_compte) . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep; - print price($line->debit - $line->credit) . $sep; + print length_accountg($line->numero_compte).$sep; + print $object->get_compte_desc($line->numero_compte).$sep; + print price($line->debit).$sep; + print price($line->credit).$sep; + print price($line->debit - $line->credit).$sep; print "\n"; } @@ -203,20 +203,20 @@ if ($action != 'export_csv') print ''; print ''; - $button = 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; + $button = 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); $moreforfilter = ''; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('DateStart') . ': '; - $moreforfilter .= $form->selectDate($search_date_start?$search_date_start:-1, 'date_start', 0, 0, 1, '', 1, 0); - $moreforfilter .= $langs->trans('DateEnd') . ': '; - $moreforfilter .= $form->selectDate($search_date_end?$search_date_end:-1, 'date_end', 0, 0, 1, '', 1, 0); + $moreforfilter .= $langs->trans('DateStart').': '; + $moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0); + $moreforfilter .= $langs->trans('DateEnd').': '; + $moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0); $moreforfilter .= '
    '; - if (! empty($moreforfilter)) { + if (!empty($moreforfilter)) { print '
    '; print $moreforfilter; $parameters = array(); @@ -225,7 +225,7 @@ if ($action != 'export_csv') print '
    '; } - print ''; + print '
    '; print ''; print ''; print ''; @@ -265,7 +265,7 @@ if ($action != 'export_csv') $description = $object->get_compte_desc($line->numero_compte); // Search description of the account $root_account_description = $object->get_compte_racine($line->numero_compte); if (empty($description)) { - $link = '' . img_edit_add() . ''; + $link = ''.img_edit_add().''; } print ''; @@ -291,12 +291,12 @@ if ($action != 'export_csv') // $object->get_compte_racine($line->numero_compte); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print "\n"; @@ -305,11 +305,11 @@ if ($action != 'export_csv') $sous_total_credit += $line->credit; } - print ''; + print ''; print "\n"; print ''; - print ''; + print ''; print "\n"; print ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 7a8a6612d4b..c1513a93a23 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -26,23 +26,23 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy", "bills", "compta")); $action = GETPOST('action', 'aZ09'); -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$id = GETPOST('id', 'int'); // id of record -$mode = GETPOST('mode', 'aZ09'); // '' or 'tmp' -$piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id) +$id = GETPOST('id', 'int'); // id of record +$mode = GETPOST('mode', 'aZ09'); // '' or 'tmp' +$piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id) // Security check if ($user->socid > 0) { @@ -66,14 +66,14 @@ $subledger_account = GETPOST('subledger_account', 'alphanohtml'); if ($subledger_account == - 1) { $subledger_account = null; } -$label_operation= GETPOST('label_operation', 'alphanohtml'); +$label_operation = GETPOST('label_operation', 'alphanohtml'); $debit = price2num(GETPOST('debit', 'alpha')); $credit = price2num(GETPOST('credit', 'alpha')); $save = GETPOST('save', 'alpha'); -if (! empty($save)) $action = 'add'; +if (!empty($save)) $action = 'add'; $update = GETPOST('update', 'alpha'); -if (! empty($update)) $action = 'confirm_update'; +if (!empty($update)) $action = 'confirm_update'; $object = new BookKeeping($db); @@ -88,16 +88,16 @@ if ($action == "confirm_update") { if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { $error++; setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $action='update'; + $action = 'update'; } if (empty($accountingaccount_number) || $accountingaccount_number == '-1') { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); - $action='update'; + $action = 'update'; } - if (! $error) + if (!$error) { $object = new BookKeeping($db); @@ -109,7 +109,7 @@ if ($action == "confirm_update") { $object->numero_compte = $accountingaccount_number; $object->subledger_account = $subledger_account; $object->label_compte = $accountingaccount_label; - $object->label_operation= $label_operation; + $object->label_operation = $label_operation; $object->debit = $debit; $object->credit = $credit; @@ -147,22 +147,22 @@ elseif ($action == "add") { { $error++; setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $action=''; + $action = ''; } if (empty($accountingaccount_number) || $accountingaccount_number == '-1') { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); - $action=''; + $action = ''; } - if (! $error) { + if (!$error) { $object = new BookKeeping($db); $object->numero_compte = $accountingaccount_number; $object->subledger_account = $subledger_account; $object->label_compte = $accountingaccount_label; - $object->label_operation= $label_operation; + $object->label_operation = $label_operation; $object->debit = $debit; $object->credit = $credit; $object->doc_date = GETPOST('doc_date', 'alpha'); @@ -223,18 +223,18 @@ elseif ($action == "confirm_create") { $object = new BookKeeping($db); - if (! $journal_code || $journal_code == '-1') { + if (!$journal_code || $journal_code == '-1') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } - if (! GETPOST('next_num_mvt', 'alpha')) + if (!GETPOST('next_num_mvt', 'alpha')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $object->label_compte = ''; $object->debit = 0; @@ -258,7 +258,7 @@ elseif ($action == "confirm_create") { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $action = 'update'; - $id=$object->id; + $id = $object->id; $piece_num = $object->piece_num; } } @@ -329,7 +329,7 @@ llxHeader('', $langs->trans("CreateMvts")); // Confirmation to delete the command if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id.'&mode='. $mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); + $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); print $formconfirm; } @@ -345,12 +345,12 @@ if ($action == 'create') dol_print_error('', 'Failed to get next piece number'); } - print ''; + print ''; if ($optioncss != '') print ''; print ''; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; dol_fiche_head(); @@ -362,19 +362,19 @@ if ($action == 'create') print '';*/ print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -390,9 +390,9 @@ if ($action == 'create') dol_fiche_end(); print '
    '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
    '; print ''; @@ -403,15 +403,15 @@ if ($action == 'create') setEventMessages($object->error, $object->errors, 'errors'); } - if (! empty($object->piece_num)) + if (!empty($object->piece_num)) { - $backlink = '' . $langs->trans('BackToList') . ''; + $backlink = ''.$langs->trans('BackToList').''; print load_fiche_titre($langs->trans("UpdateMvts"), $backlink); - $head=array(); - $h=0; - $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode?'&mode='.$mode:''); + $head = array(); + $h = 0; + $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : ''); $head[$h][1] = $langs->trans("Transaction"); $head[$h][2] = 'transaction'; $h++; @@ -428,8 +428,8 @@ if ($action == 'create') // Account movement print ''; - print ''; - print ''; + print ''; + print ''; print ''; // Date @@ -438,17 +438,17 @@ if ($action == 'create') print $langs->trans('Docdate'); print ''; if ($action != 'editdate') - print ''; + print ''; print '
    '; @@ -236,7 +236,7 @@ if ($action != 'export_csv') print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, ''); print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
    ' . length_accountg($line->numero_compte) . '' . $description . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->debit - $line->credit) . '' . $link; + print ''.length_accountg($line->numero_compte).''.$description.''.price($line->debit).''.price($line->credit).''.price($line->debit - $line->credit).''.$link; print '
    ' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price(price2num($sous_total_debit - $sous_total_credit)) . '
    '.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit - $sous_total_credit)).' 
    ' . $langs->trans("AccountBalance") . ':' . price($total_debit) . '' . price($total_credit) . '' . price(price2num($total_debit - $total_credit)) . '
    '.$langs->trans("AccountBalance").':'.price($total_debit).''.price($total_credit).''.price(price2num($total_debit - $total_credit)).' 
    ' . $langs->trans("Docdate") . ''.$langs->trans("Docdate").''; print $html->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1); print '
    ' . $langs->trans("Codejournal") . '' . $formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1) . ''.$langs->trans("Codejournal").''.$formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1).'
    ' . $langs->trans("Piece") . ''.$langs->trans("Piece").'
    ' . $langs->trans("NumMvts") . '' . $object->piece_num . ''.$langs->trans("NumMvts").''.$object->piece_num.'
    piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'
    '; print '
    '; if ($action == 'editdate') { - print '
    '; + print ''; if ($optioncss != '') print ''; print ''; print ''; print ''; print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); - print ''; + print ''; print '
    '; } else { print $object->doc_date ? dol_print_date($object->doc_date, 'day') : ' '; @@ -462,20 +462,20 @@ if ($action == 'create') print $langs->trans('Codejournal'); print '
    piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'
    '; print '
    '; if ($action == 'editjournal') { - print '
    '; + print ''; if ($optioncss != '') print ''; print ''; print ''; print ''; print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1); - print ''; + print ''; print '
    '; } else { - print $object->code_journal ; + print $object->code_journal; } print '
    piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'
    '; print '
    '; if ($action == 'editdocref') { - print '
    '; + print ''; if ($optioncss != '') print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print '
    '; } else { - print $object->doc_ref ; + print $object->doc_ref; } print '
    '; // Doc type - if(! empty($object->doc_type)) + if (!empty($object->doc_type)) { print ''; - print ''; - print ''; + print ''; + print ''; print ''; } // Date document creation print ''; - print ''; + print ''; print ''; @@ -586,16 +586,16 @@ if ($action == 'create') } else { print load_fiche_titre($langs->trans("ListeMvts"), '', ''); - print ''; + print ''; if ($optioncss != '') print ''; print ''; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; print "
    ' . $langs->trans("Doctype") . '' . $object->doc_type . ''.$langs->trans("Doctype").''.$object->doc_type.'
    ' . $langs->trans("DateCreation") . ''.$langs->trans("DateCreation").''; print $object->date_creation ? dol_print_date($object->date_creation, 'day') : ' '; print '
    "; if (count($object->linesmvt) > 0) { @@ -620,12 +620,12 @@ if ($action == 'create') if ($action == 'update' && $line->id == $id) { print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; } else { $accountingaccount->fetch(null, $line->numero_compte, true); - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; } print '
    '; - print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array (), 1, 1, ''); + print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, ''); print ''; // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. - if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1); } @@ -634,30 +634,30 @@ if ($action == 'create') print 'subledger_account).'">'; } print 'label_operation). '">debit)) . '">credit)) . '">label_operation).'">debit)).'">credit)).'">'; - print '' . "\n"; - print ''; + print ''."\n"; + print ''; print '' . $accountingaccount->getNomUrl(0, 1, 1, '', 0) . '' . length_accounta($line->subledger_account) . '' . $line->label_operation. '' . price($line->debit) . '' . price($line->credit) . ''.$accountingaccount->getNomUrl(0, 1, 1, '', 0).''.length_accounta($line->subledger_account).''.$line->label_operation.''.price($line->debit).''.price($line->credit).''; - print 'id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">'; + print 'id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">'; print img_edit(); print '  '; - $actiontodelete='delete'; - if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete='confirm_delete'; + $actiontodelete = 'delete'; + if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete = 'confirm_delete'; - print ''; + print ''; print img_delete(); print ''; @@ -677,12 +677,12 @@ if ($action == 'create') if ($action == "" || $action == 'add') { print '
    '; - print $formaccounting->select_account('', 'accountingaccount_number', 1, array (), 1, 1, ''); + print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); print ''; // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. - if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount('', 'subledger_account', 1); } @@ -694,19 +694,19 @@ if ($action == 'create') print '
    '; - if ($mode=='_tmp' && $action=='') + if ($mode == '_tmp' && $action == '') { print '
    '; print '
    '; if ($total_debit == $total_credit) { - print ''.$langs->trans("ValidTransaction").''; + print ''.$langs->trans("ValidTransaction").''; } else { @@ -714,7 +714,7 @@ if ($action == 'create') } print '   '; - print ''.$langs->trans("Cancel").''; + print ''.$langs->trans("Cancel").''; print "
    "; } diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index f922ac06655..886b2ade2d4 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -29,12 +29,12 @@ class AccountingJournal extends CommonObject /** * @var string ID to identify managed object */ - public $element='accounting_journal'; + public $element = 'accounting_journal'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='accounting_journal'; + public $table_element = 'accounting_journal'; /** * @var int Field with ID of parent key if this field has a parent @@ -64,7 +64,7 @@ class AccountingJournal extends CommonObject */ public $label; - public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new + public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new public $active; public $lines; @@ -93,29 +93,29 @@ class AccountingJournal extends CommonObject if ($rowid || $journal_code) { $sql = "SELECT rowid, code, label, nature, active"; - $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal"; $sql .= " WHERE"; if ($rowid) { - $sql .= " rowid = " . (int) $rowid; + $sql .= " rowid = ".(int) $rowid; } elseif ($journal_code) { - $sql .= " code = '" . $this->db->escape($journal_code) . "'"; - $sql .= " AND entity = " . $conf->entity; + $sql .= " code = '".$this->db->escape($journal_code)."'"; + $sql .= " AND entity = ".$conf->entity; } - dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); if ($obj) { - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->rowid = $obj->rowid; $this->code = $obj->code; - $this->ref = $obj->code; + $this->ref = $obj->code; $this->label = $obj->label; $this->nature = $obj->nature; $this->active = $obj->active; @@ -127,8 +127,8 @@ class AccountingJournal extends CommonObject } else { - $this->error = "Error " . $this->db->lasterror(); - $this->errors[] = "Error " . $this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); } } return -1; @@ -149,38 +149,38 @@ class AccountingJournal extends CommonObject public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { $sql = "SELECT rowid, code, label, nature, active"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.code' || $key == 't.label' || $key == 't.nature') { - $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->escape($value).'\''; } elseif ($key == 't.rowid' || $key == 't.active') { - $sqlwhere[] = $key . '=' . $value; + $sqlwhere[] = $key.'='.$value; } } } $sql .= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " AND entity IN (".getEntity('accountancy').")"; if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } - if (! empty($sortfield)) { + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } - if (! empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit + 1, $offset); } $this->lines = array(); - dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $line = new self($this->db); $line->id = $obj->rowid; @@ -196,10 +196,10 @@ class AccountingJournal extends CommonObject return $num; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -217,34 +217,34 @@ class AccountingJournal extends CommonObject { global $langs, $conf, $user; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $url = DOL_URL_ROOT . '/accountancy/admin/journals_list.php?id=35'; + $url = DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35'; - $label = '' . $langs->trans("ShowAccountingJournal") . ''; - if (! empty($this->code)) - $label .= '
    '.$langs->trans('Code') . ': ' . $this->code; - if (! empty($this->label)) - $label .= '
    '.$langs->trans('Label') . ': ' . $langs->transnoentities($this->label); - if ($moretitle) $label.=' - '.$moretitle; + $label = ''.$langs->trans("ShowAccountingJournal").''; + if (!empty($this->code)) + $label .= '
    '.$langs->trans('Code').': '.$this->code; + if (!empty($this->label)) + $label .= '
    '.$langs->trans('Label').': '.$langs->transnoentities($this->label); + if ($moretitle) $label .= ' - '.$moretitle; - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowAccountingJournal"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowAccountingJournal"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } - $linkstart=''; - $linkend=''; + $linkstart = ''; + $linkend = ''; if ($nourl) { @@ -254,11 +254,11 @@ class AccountingJournal extends CommonObject } $label_link = $this->code; - if ($withlabel) $label_link .= ' - ' . $langs->transnoentities($this->label); + if ($withlabel) $label_link .= ' - '.$langs->transnoentities($this->label); $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $label_link; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $label_link; $result .= $linkend; return $result; @@ -292,7 +292,7 @@ class AccountingJournal extends CommonObject if ($mode == 0) { - $prefix=''; + $prefix = ''; if ($nature == 9) return $langs->trans('AccountingJournalType9'); elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); elseif ($nature == 4) return $langs->trans('AccountingJournalType4'); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 193ca34e2f3..69c17f3484e 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -25,7 +25,7 @@ */ // Class -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** * Class to manage Ledger (General Ledger and Subledger) @@ -60,7 +60,7 @@ class BookKeeping extends CommonObject /** * @var BookKeepingLine[] Lines */ - public $lines = array (); + public $lines = array(); /** * @var int ID @@ -230,17 +230,17 @@ class BookKeeping extends CommonObject $langs->loadLangs(array("errors")); if (in_array($this->doc_type, array('bank', 'expense_report'))) { - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type); + $this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type); } else { //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte); - $mesg=$this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte; + $mesg = $this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte; if ($this->subledger_account && $this->subledger_account != $this->numero_compte) { - $mesg.=', '.$langs->trans("SubledgerAccount").': '.$this->subledger_account; + $mesg .= ', '.$langs->trans("SubledgerAccount").': '.$this->subledger_account; } - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $mesg); + $this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForLine', $mesg); } return -1; @@ -256,13 +256,13 @@ class BookKeeping extends CommonObject // WARNING: This is not reliable, label may have been modified. This is just a small protection. // The page to make journalization make the test on couple doc_type - fk_doc only. $sql = "SELECT count(*) as nb"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; - $sql .= " AND fk_doc = " . $this->fk_doc; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE doc_type = '".$this->db->escape($this->doc_type)."'"; + $sql .= " AND fk_doc = ".$this->fk_doc; //$sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 if record is for several lines - $sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'"; - $sql .= " AND label_operation = '" . $this->db->escape($this->label_operation) . "'"; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " AND numero_compte = '".$this->db->escape($this->numero_compte)."'"; + $sql .= " AND label_operation = '".$this->db->escape($this->label_operation)."'"; + $sql .= " AND entity IN (".getEntity('accountancy').")"; $resql = $this->db->query($sql); @@ -272,39 +272,39 @@ class BookKeeping extends CommonObject { // Determine piece_num $sqlnum = "SELECT piece_num"; - $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank' - $sqlnum .= " AND fk_docdet = " . $this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... - $sqlnum .= " AND doc_ref = '" . $this->db->escape($this->doc_ref) . "'"; // ref of source object - $sqlnum .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sqlnum .= " WHERE doc_type = '".$this->db->escape($this->doc_type)."'"; // For example doc_type = 'bank' + $sqlnum .= " AND fk_docdet = ".$this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... + $sqlnum .= " AND doc_ref = '".$this->db->escape($this->doc_ref)."'"; // ref of source object + $sqlnum .= " AND entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); + dol_syslog(get_class($this).":: create sqlnum=".$sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { $objnum = $this->db->fetch_object($resqlnum); $this->piece_num = $objnum->piece_num; } - dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG); + dol_syslog(get_class($this).":: create this->piece_num=".$this->piece_num, LOG_DEBUG); if (empty($this->piece_num)) { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; - $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sqlnum .= " WHERE entity IN (" . getEntity('accountancy') . ")"; + $sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sqlnum .= " WHERE entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); + dol_syslog(get_class($this).":: create sqlnum=".$sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { $objnum = $this->db->fetch_object($resqlnum); $this->piece_num = $objnum->maxpiecenum; } } - dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG); + dol_syslog(get_class($this).":: create this->piece_num=".$this->piece_num, LOG_DEBUG); if (empty($this->piece_num)) { $this->piece_num = 1; } $now = dol_now(); - $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." ("; $sql .= "doc_date"; $sql .= ", date_lim_reglement"; $sql .= ", doc_type"; @@ -329,60 +329,60 @@ class BookKeeping extends CommonObject $sql .= ', entity'; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($this->doc_date)."'"; - $sql .= ", ".(! isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'"); - $sql .= ",'" . $this->db->escape($this->doc_type) . "'"; - $sql .= ",'" . $this->db->escape($this->doc_ref) . "'"; - $sql .= "," . $this->fk_doc; - $sql .= "," . $this->fk_docdet; - $sql .= ",'" . $this->db->escape($this->thirdparty_code) . "'"; - $sql .= ",'" . $this->db->escape($this->subledger_account) . "'"; - $sql .= ",'" . $this->db->escape($this->subledger_label) . "'"; - $sql .= ",'" . $this->db->escape($this->numero_compte) . "'"; - $sql .= ",'" . $this->db->escape($this->label_compte) . "'"; - $sql .= ",'" . $this->db->escape($this->label_operation) . "'"; - $sql .= "," . $this->debit; - $sql .= "," . $this->credit; - $sql .= "," . $this->montant; - $sql .= ",'" . $this->db->escape($this->sens) . "'"; - $sql .= ",'" . $this->db->escape($this->fk_user_author) . "'"; + $sql .= ", ".(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'"); + $sql .= ",'".$this->db->escape($this->doc_type)."'"; + $sql .= ",'".$this->db->escape($this->doc_ref)."'"; + $sql .= ",".$this->fk_doc; + $sql .= ",".$this->fk_docdet; + $sql .= ",'".$this->db->escape($this->thirdparty_code)."'"; + $sql .= ",'".$this->db->escape($this->subledger_account)."'"; + $sql .= ",'".$this->db->escape($this->subledger_label)."'"; + $sql .= ",'".$this->db->escape($this->numero_compte)."'"; + $sql .= ",'".$this->db->escape($this->label_compte)."'"; + $sql .= ",'".$this->db->escape($this->label_operation)."'"; + $sql .= ",".$this->debit; + $sql .= ",".$this->credit; + $sql .= ",".$this->montant; + $sql .= ",'".$this->db->escape($this->sens)."'"; + $sql .= ",'".$this->db->escape($this->fk_user_author)."'"; $sql .= ",'".$this->db->idate($now)."'"; - $sql .= ",'" . $this->db->escape($this->code_journal) . "'"; - $sql .= ",'" . $this->db->escape($this->journal_label) . "'"; - $sql .= "," . $this->db->escape($this->piece_num); - $sql .= ", " . (! isset($this->entity) ? $conf->entity : $this->entity); + $sql .= ",'".$this->db->escape($this->code_journal)."'"; + $sql .= ",'".$this->db->escape($this->journal_label)."'"; + $sql .= ",".$this->db->escape($this->piece_num); + $sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity); $sql .= ")"; - dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this).":: create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); if ($id > 0) { $this->id = $id; $result = 0; } else { $result = -2; - $error ++; - $this->errors[] = 'Error Create Error ' . $result . ' lecture ID'; - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error Create Error '.$result.' lecture ID'; + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } } else { $result = -1; - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } } else { // Already exists $result = -3; $error++; - $this->error='BookkeepingRecordAlreadyExists'; - dol_syslog(__METHOD__ . ' ' . $this->error, LOG_WARNING); + $this->error = 'BookkeepingRecordAlreadyExists'; + dol_syslog(__METHOD__.' '.$this->error, LOG_WARNING); } } else { $result = -5; - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } // Uncomment this and change MYOBJECT to your own tag if you @@ -421,45 +421,45 @@ class BookKeeping extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; $companylink = ''; - $label = '' . $langs->trans("Transaction") . ''; - $label.= '
    '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->piece_num; + $label = ''.$langs->trans("Transaction").''; + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->piece_num; $url = DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$this->piece_num; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowTransaction"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowTransaction"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->piece_num; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->piece_num; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -551,7 +551,7 @@ class BookKeeping extends CommonObject $this->journal_label = $langs->trans($this->journal_label); // Insert request - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . $mode.' ('; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.$mode.' ('; $sql .= 'doc_date,'; $sql .= 'date_lim_reglement,'; $sql .= 'doc_type,'; @@ -575,41 +575,41 @@ class BookKeeping extends CommonObject $sql .= 'piece_num,'; $sql .= 'entity'; $sql .= ') VALUES ('; - $sql .= ' ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : "'".$this->db->idate($this->doc_date)."'") . ','; - $sql .= ' ' . (! isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'" . $this->db->idate($this->date_lim_reglement) . "'") . ','; - $sql .= ' ' . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ','; - $sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ','; - $sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ','; - $sql .= ' ' . (empty($this->fk_docdet) ? '0' : $this->fk_docdet) . ','; - $sql .= ' ' . (! isset($this->thirdparty_code) ? 'NULL' : "'" . $this->db->escape($this->thirdparty_code) . "'") . ','; - $sql .= ' ' . (! isset($this->subledger_account) ? 'NULL' : "'" . $this->db->escape($this->subledger_account) . "'") . ','; - $sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ','; - $sql .= ' ' . (! isset($this->numero_compte) ? 'NULL' : "'" . $this->db->escape($this->numero_compte) . "'") . ','; - $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; - $sql .= ' ' . (! isset($this->label_operation) ? 'NULL' : "'" . $this->db->escape($this->label_operation) . "'") . ','; - $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; - $sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ','; - $sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ','; - $sql .= ' ' . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ','; - $sql .= ' ' . $user->id . ','; - $sql .= ' ' . "'".$this->db->idate($now)."',"; - $sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ','; - $sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ','; - $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).','; - $sql .= ' ' . (! isset($this->entity) ? $conf->entity : $this->entity); + $sql .= ' '.(!isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : "'".$this->db->idate($this->doc_date)."'").','; + $sql .= ' '.(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'").','; + $sql .= ' '.(!isset($this->doc_type) ? 'NULL' : "'".$this->db->escape($this->doc_type)."'").','; + $sql .= ' '.(!isset($this->doc_ref) ? 'NULL' : "'".$this->db->escape($this->doc_ref)."'").','; + $sql .= ' '.(empty($this->fk_doc) ? '0' : $this->fk_doc).','; + $sql .= ' '.(empty($this->fk_docdet) ? '0' : $this->fk_docdet).','; + $sql .= ' '.(!isset($this->thirdparty_code) ? 'NULL' : "'".$this->db->escape($this->thirdparty_code)."'").','; + $sql .= ' '.(!isset($this->subledger_account) ? 'NULL' : "'".$this->db->escape($this->subledger_account)."'").','; + $sql .= ' '.(!isset($this->subledger_label) ? 'NULL' : "'".$this->db->escape($this->subledger_label)."'").','; + $sql .= ' '.(!isset($this->numero_compte) ? 'NULL' : "'".$this->db->escape($this->numero_compte)."'").','; + $sql .= ' '.(!isset($this->label_compte) ? 'NULL' : "'".$this->db->escape($this->label_compte)."'").','; + $sql .= ' '.(!isset($this->label_operation) ? 'NULL' : "'".$this->db->escape($this->label_operation)."'").','; + $sql .= ' '.(!isset($this->debit) ? 'NULL' : $this->debit).','; + $sql .= ' '.(!isset($this->credit) ? 'NULL' : $this->credit).','; + $sql .= ' '.(!isset($this->montant) ? 'NULL' : $this->montant).','; + $sql .= ' '.(!isset($this->sens) ? 'NULL' : "'".$this->db->escape($this->sens)."'").','; + $sql .= ' '.$user->id.','; + $sql .= ' '."'".$this->db->idate($now)."',"; + $sql .= ' '.(empty($this->code_journal) ? 'NULL' : "'".$this->db->escape($this->code_journal)."'").','; + $sql .= ' '.(empty($this->journal_label) ? 'NULL' : "'".$this->db->escape($this->journal_label)."'").','; + $sql .= ' '.(empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).','; + $sql .= ' '.(!isset($this->entity) ? $conf->entity : $this->entity); $sql .= ')'; $this->db->begin(); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } - if (! $error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element . $mode); + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element.$mode); // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. @@ -626,7 +626,7 @@ class BookKeeping extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -673,13 +673,13 @@ class BookKeeping extends CommonObject $sql .= " t.journal_label,"; $sql .= " t.piece_num,"; $sql .= " t.date_creation"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element.$mode. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.$mode.' as t'; $sql .= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " AND entity IN (".getEntity('accountancy').")"; if (null !== $ref) { - $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; + $sql .= ' AND t.ref = '.'\''.$ref.'\''; } else { - $sql .= ' AND t.rowid = ' . $id; + $sql .= ' AND t.rowid = '.$id; } $resql = $this->db->query($sql); @@ -721,10 +721,10 @@ class BookKeeping extends CommonObject return 0; } } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -777,21 +777,21 @@ class BookKeeping extends CommonObject $sql .= " t.piece_num,"; $sql .= " t.date_creation"; // Manage filter - $sqlwhere = array (); + $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.doc_date') { - $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'=\''.$this->db->idate($value).'\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->escape($value).'\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key . '=' . $value; + $sqlwhere[] = $key.'='.$value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } else { @@ -799,19 +799,19 @@ class BookKeeping extends CommonObject } } } - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " AND entity IN (".getEntity('accountancy').")"; if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } // Affichage par compte comptable $sql .= ' ORDER BY t.numero_compte ASC'; - if (! empty($sortfield)) { - $sql .= ', ' . $sortfield . ' ' .$sortorder; + if (!empty($sortfield)) { + $sql .= ', '.$sortfield.' '.$sortorder; } - if (! empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit + 1, $offset); } $resql = $this->db->query($sql); @@ -858,8 +858,8 @@ class BookKeeping extends CommonObject return $num; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } @@ -909,27 +909,27 @@ class BookKeeping extends CommonObject $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification,"; $sql .= " t.date_export"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter - $sqlwhere = array (); + $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.doc_date') { - $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'=\''.$this->db->idate($value).'\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->escape($value).'\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key . '=' . $value; + $sqlwhere[] = $key.'='.$value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.tms>=' || $key == 't.tms<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } else { @@ -937,18 +937,18 @@ class BookKeeping extends CommonObject } } } - $sql.= ' WHERE t.entity IN (' . getEntity('accountancy') . ')'; + $sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')'; if ($showAlreadyExportMovements == 0) { $sql .= " AND t.date_export IS NULL"; } if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } - if (! empty($sortfield)) { + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } - if (! empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit + 1, $offset); } $this->lines = array(); @@ -996,8 +996,8 @@ class BookKeeping extends CommonObject return $num; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } } @@ -1026,40 +1026,40 @@ class BookKeeping extends CommonObject $sql .= " t.numero_compte,"; $sql .= " SUM(t.debit) as debit,"; $sql .= " SUM(t.credit) as credit"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter - $sqlwhere = array (); + $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.doc_date') { - $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'=\''.$this->db->idate($value).'\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->escape($value).'\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key . '=' . $value; + $sqlwhere[] = $key.'='.$value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } elseif ($key == 't.subledger_label') { - $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } - $sql.= ' WHERE entity IN (' . getEntity('accountancy') . ')'; + $sql .= ' WHERE entity IN ('.getEntity('accountancy').')'; if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } $sql .= ' GROUP BY t.numero_compte'; - if (! empty($sortfield)) { + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } - if (! empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit + 1, $offset); } $resql = $this->db->query($sql); @@ -1084,10 +1084,10 @@ class BookKeeping extends CommonObject return $num; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -1168,36 +1168,36 @@ class BookKeeping extends CommonObject // Put here code to add a control on parameters values // Update request - $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . $mode.' SET'; - $sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'".$this->db->idate($this->doc_date)."'" : 'null') . ','; - $sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ','; - $sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ','; - $sql .= ' fk_doc = ' . (isset($this->fk_doc) ? $this->fk_doc : "null") . ','; - $sql .= ' fk_docdet = ' . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ','; - $sql .= ' thirdparty_code = ' . (isset($this->thirdparty_code) ? "'" . $this->db->escape($this->thirdparty_code) . "'" : "null") . ','; - $sql .= ' subledger_account = ' . (isset($this->subledger_account) ? "'" . $this->db->escape($this->subledger_account) . "'" : "null") . ','; - $sql .= ' subledger_label = ' . (isset($this->subledger_label) ? "'" . $this->db->escape($this->subledger_label) . "'" : "null") . ','; - $sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ','; - $sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ','; - $sql .= ' label_operation = ' . (isset($this->label_operation) ? "'" . $this->db->escape($this->label_operation) . "'" : "null") . ','; - $sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ','; - $sql .= ' credit = ' . (isset($this->credit) ? $this->credit : "null") . ','; - $sql .= ' montant = ' . (isset($this->montant) ? $this->montant : "null") . ','; - $sql .= ' sens = ' . (isset($this->sens) ? "'" . $this->db->escape($this->sens) . "'" : "null") . ','; - $sql .= ' fk_user_author = ' . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ','; - $sql .= ' import_key = ' . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ','; - $sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ','; - $sql .= ' journal_label = ' . (isset($this->journal_label) ? "'" . $this->db->escape($this->journal_label) . "'" : "null") . ','; - $sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null"); - $sql .= ' WHERE rowid=' . $this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.$mode.' SET'; + $sql .= ' doc_date = '.(!isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'".$this->db->idate($this->doc_date)."'" : 'null').','; + $sql .= ' doc_type = '.(isset($this->doc_type) ? "'".$this->db->escape($this->doc_type)."'" : "null").','; + $sql .= ' doc_ref = '.(isset($this->doc_ref) ? "'".$this->db->escape($this->doc_ref)."'" : "null").','; + $sql .= ' fk_doc = '.(isset($this->fk_doc) ? $this->fk_doc : "null").','; + $sql .= ' fk_docdet = '.(isset($this->fk_docdet) ? $this->fk_docdet : "null").','; + $sql .= ' thirdparty_code = '.(isset($this->thirdparty_code) ? "'".$this->db->escape($this->thirdparty_code)."'" : "null").','; + $sql .= ' subledger_account = '.(isset($this->subledger_account) ? "'".$this->db->escape($this->subledger_account)."'" : "null").','; + $sql .= ' subledger_label = '.(isset($this->subledger_label) ? "'".$this->db->escape($this->subledger_label)."'" : "null").','; + $sql .= ' numero_compte = '.(isset($this->numero_compte) ? "'".$this->db->escape($this->numero_compte)."'" : "null").','; + $sql .= ' label_compte = '.(isset($this->label_compte) ? "'".$this->db->escape($this->label_compte)."'" : "null").','; + $sql .= ' label_operation = '.(isset($this->label_operation) ? "'".$this->db->escape($this->label_operation)."'" : "null").','; + $sql .= ' debit = '.(isset($this->debit) ? $this->debit : "null").','; + $sql .= ' credit = '.(isset($this->credit) ? $this->credit : "null").','; + $sql .= ' montant = '.(isset($this->montant) ? $this->montant : "null").','; + $sql .= ' sens = '.(isset($this->sens) ? "'".$this->db->escape($this->sens)."'" : "null").','; + $sql .= ' fk_user_author = '.(isset($this->fk_user_author) ? $this->fk_user_author : "null").','; + $sql .= ' import_key = '.(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").','; + $sql .= ' code_journal = '.(isset($this->code_journal) ? "'".$this->db->escape($this->code_journal)."'" : "null").','; + $sql .= ' journal_label = '.(isset($this->journal_label) ? "'".$this->db->escape($this->journal_label)."'" : "null").','; + $sql .= ' piece_num = '.(isset($this->piece_num) ? $this->piece_num : "null"); + $sql .= ' WHERE rowid='.$this->id; $this->db->begin(); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } // Uncomment this and change MYOBJECT to your own tag if you @@ -1214,7 +1214,7 @@ class BookKeeping extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -1233,19 +1233,19 @@ class BookKeeping extends CommonObject */ public function updateByMvt($piece_num = '', $field = '', $value = '', $mode = '') { - $error=0; + $error = 0; $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab"; - $sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$this->db->escape($value)."'"); - $sql .= ' WHERE ab.piece_num=' . $piece_num ; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element.$mode." as ab"; + $sql .= ' SET ab.'.$field.'='.(is_numeric($value) ? $value : "'".$this->db->escape($value)."'"); + $sql .= ' WHERE ab.piece_num='.$piece_num; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } if ($error) { $this->db->rollback(); @@ -1284,15 +1284,15 @@ class BookKeeping extends CommonObject // // End call triggers //} - if (! $error) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element.$mode; - $sql .= ' WHERE rowid=' . $this->id; + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.$mode; + $sql .= ' WHERE rowid='.$this->id; $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } } @@ -1300,7 +1300,7 @@ class BookKeeping extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -1320,16 +1320,16 @@ class BookKeeping extends CommonObject // first check if line not yet in bookkeeping $sql = "DELETE"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE import_key = '" . $this->db->escape($importkey) . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE import_key = '".$this->db->escape($importkey)."'"; $resql = $this->db->query($sql); - if (! $resql) { - $this->errors[] = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this)."::delete Error " . $this->db->lasterror(), LOG_ERR); + if (!$resql) { + $this->errors[] = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::delete Error ".$this->db->lasterror(), LOG_ERR); $this->db->rollback(); - return - 1; + return -1; } $this->db->commit(); @@ -1357,18 +1357,18 @@ class BookKeeping extends CommonObject // first check if line not yet in bookkeeping $sql = "DELETE"; - $sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode; - $sql.= " WHERE 1 = 1"; - if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between - if (! empty($journal)) $sql.= " AND code_journal = '".$this->db->escape($journal)."'"; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; + $sql .= " WHERE 1 = 1"; + if (!empty($delyear)) $sql .= " AND YEAR(doc_date) = ".$delyear; // FIXME Must use between + if (!empty($journal)) $sql .= " AND code_journal = '".$this->db->escape($journal)."'"; + $sql .= " AND entity IN (".getEntity('accountancy').")"; $resql = $this->db->query($sql); - if (! $resql) { - $this->errors[] = "Error " . $this->db->lasterror(); + if (!$resql) { + $this->errors[] = "Error ".$this->db->lasterror(); foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1; @@ -1392,20 +1392,20 @@ class BookKeeping extends CommonObject // first check if line not yet in bookkeeping $sql = "DELETE"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE piece_num = " . (int) $piecenum; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE piece_num = ".(int) $piecenum; + $sql .= " AND entity IN (".getEntity('accountancy').")"; $resql = $this->db->query($sql); - if (! $resql) { - $this->errors[] = "Error " . $this->db->lasterror(); + if (!$resql) { + $this->errors[] = "Error ".$this->db->lasterror(); foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1; + return -1; } $this->db->commit(); @@ -1442,15 +1442,15 @@ class BookKeeping extends CommonObject // Other options if ($result < 0) { - $error ++; + $error++; $this->errors = $object->errors; - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } unset($object->context['createfromclone']); // End - if (! $error) { + if (!$error) { $this->db->commit(); return $object->id; @@ -1471,7 +1471,7 @@ class BookKeeping extends CommonObject { global $user; - $now=dol_now(); + $now = dol_now(); $this->id = 0; $this->doc_date = $now; @@ -1509,11 +1509,11 @@ class BookKeeping extends CommonObject global $conf; $sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type,date_creation"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode; - $sql .= " WHERE piece_num = " . $piecenum; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; + $sql .= " WHERE piece_num = ".$piecenum; + $sql .= " AND entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -1526,9 +1526,9 @@ class BookKeeping extends CommonObject $this->doc_type = $obj->doc_type; $this->date_creation = $obj->date_creation; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR); + return -1; } return 1; @@ -1544,10 +1544,10 @@ class BookKeeping extends CommonObject { global $conf; - $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element.$mode; - $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; + $sql = "SELECT MAX(piece_num)+1 as max FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; + $sql .= " WHERE entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."getNextNumMvt sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -1556,9 +1556,9 @@ class BookKeeping extends CommonObject if (empty($result)) $result = 1; return $result; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::getNextNumMvt " . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::getNextNumMvt ".$this->error, LOG_ERR); + return -1; } } @@ -1577,11 +1577,11 @@ class BookKeeping extends CommonObject $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode; - $sql .= " WHERE piece_num = " . $piecenum; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; + $sql .= " WHERE piece_num = ".$piecenum; + $sql .= " AND entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { while ($obj = $this->db->fetch_object($result)) { @@ -1612,9 +1612,9 @@ class BookKeeping extends CommonObject $this->linesmvt[] = $line; } } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR); + return -1; } return 1; @@ -1636,15 +1636,15 @@ class BookKeeping extends CommonObject $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "::export_bookkeeping", LOG_DEBUG); + dol_syslog(get_class($this)."::export_bookkeeping", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->linesexport = array (); + $this->linesexport = array(); $num = $this->db->num_rows($resql); while ($obj = $this->db->fetch_object($resql)) { @@ -1676,9 +1676,9 @@ class BookKeeping extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::export_bookkeeping " . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::export_bookkeeping ".$this->error, LOG_ERR); + return -1; } } @@ -1695,45 +1695,45 @@ class BookKeeping extends CommonObject $this->db->begin(); - if ($direction==0) + if ($direction == 0) { - $next_piecenum=$this->getNextNumMvt(); + $next_piecenum = $this->getNextNumMvt(); $now = dol_now(); if ($next_piecenum < 0) { $error++; } - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . ' (doc_date, doc_type,'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' (doc_date, doc_type,'; $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation)'; $sql .= ' SELECT doc_date, doc_type,'; $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; - $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, ' . $next_piecenum . ", '".$this->db->idate($now)."'"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . '_tmp WHERE piece_num = ' . $this->db->escape($piece_num); + $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.$next_piecenum.", '".$this->db->idate($now)."'"; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$this->db->escape($piece_num); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element . '_tmp WHERE piece_num = ' . $this->db->escape($piece_num); + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$this->db->escape($piece_num); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } - } elseif ($direction==1) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element . '_tmp WHERE piece_num = ' . $piece_num; + } elseif ($direction == 1) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$piece_num; $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '_tmp (doc_date, doc_type,'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'_tmp (doc_date, doc_type,'; $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)'; @@ -1741,27 +1741,27 @@ class BookKeeping extends CommonObject $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element.' WHERE piece_num = ' . $piece_num; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.$piece_num; $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element . '_tmp WHERE piece_num = ' . $piece_num; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$piece_num; $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } } - if (! $error) { + if (!$error) { $this->db->commit(); return 1; } else { $this->db->rollback(); - return - 1; + return -1; } /* $sql = "DELETE FROM "; @@ -1793,26 +1793,26 @@ class BookKeeping extends CommonObject // phpcs:enable global $conf; - require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.account_number = ab.numero_compte"; $sql .= " AND aa.active = 1"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = " . $pcgver; - $sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " AND asy.rowid = ".$pcgver; + $sql .= " AND ab.entity IN (".getEntity('accountancy').")"; $sql .= " ORDER BY account_number ASC"; - dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); + dol_syslog(get_class($this)."::select_account", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); - return - 1; + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_account ".$this->error, LOG_ERR); + return -1; } $out = ajax_combobox($htmlname, $event); @@ -1821,7 +1821,7 @@ class BookKeeping extends CommonObject $selected = null; while ($obj = $this->db->fetch_object($resql)) { - $label = length_accountg($obj->account_number) . ' - ' . $obj->label; + $label = length_accountg($obj->account_number).' - '.$obj->label; $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; @@ -1861,17 +1861,17 @@ class BookKeeping extends CommonObject $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT root.account_number, root.label as label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = " . $pcgver; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as parent ON aa.account_parent = parent.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as root ON parent.account_parent = root.rowid"; - $sql .= " WHERE aa.account_number = '" . $account . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " AND asy.rowid = ".$pcgver; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as parent ON aa.account_parent = parent.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as root ON parent.account_parent = root.rowid"; + $sql .= " WHERE aa.account_number = '".$account."'"; $sql .= " AND parent.active = 1"; $sql .= " AND root.active = 1"; - $sql .= " AND aa.entity IN (" . getEntity('accountancy') . ")"; + $sql .= " AND aa.entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::select_account sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = ''; @@ -1881,8 +1881,8 @@ class BookKeeping extends CommonObject return $obj->label; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(__METHOD__." ".$this->error, LOG_ERR); return -1; } @@ -1902,29 +1902,29 @@ class BookKeeping extends CommonObject $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa "; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND aa.account_number = '" . $account . "'"; - $sql .= " AND asy.rowid = " . $pcgver; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " AND aa.account_number = '".$account."'"; + $sql .= " AND asy.rowid = ".$pcgver; $sql .= " AND aa.active = 1"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; - $sql .= " WHERE aa.entity IN (" . getEntity('accountancy') . ")"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; + $sql .= " WHERE aa.entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::select_account sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = ''; if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); } - if(empty($obj->category)){ + if (empty($obj->category)) { return $obj->label; - }else{ + } else { return $obj->label.' ('.$obj->category.')'; } } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(__METHOD__." ".$this->error, LOG_ERR); return -1; } } diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 8dde1d0df22..71fce0be43a 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -24,12 +24,12 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","accountancy","loans","banks","admin","dict")); +$langs->loadLangs(array("compta", "bills", "other", "accountancy", "loans", "banks", "admin", "dict")); // Security check if ($user->socid > 0) @@ -45,12 +45,12 @@ $hookmanager->initHooks(array('accountancyindex')); if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) { require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - $zone=GETPOST('areacode', 'aZ09'); - $userid=GETPOST('userid', 'int'); - $boxorder=GETPOST('boxorder', 'aZ09'); - $boxorder.=GETPOST('boxcombo', 'aZ09'); + $zone = GETPOST('areacode', 'aZ09'); + $userid = GETPOST('userid', 'int'); + $boxorder = GETPOST('boxorder', 'aZ09'); + $boxorder .= GETPOST('boxcombo', 'aZ09'); - $result=InfoBox::saveboxorder($db, $zone, $boxorder, $userid); + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); } @@ -64,16 +64,16 @@ if ($conf->accounting->enabled) { $step = 0; - $resultboxes=FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) + $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) - $helpisexpanded = empty($resultboxes['boxactivated']); // If there is no widget, the tooltip help is expanded by default. + $helpisexpanded = empty($resultboxes['boxactivated']); // If there is no widget, the tooltip help is expanded by default. $showtutorial = ''; - if (! $helpisexpanded) + if (!$helpisexpanded) { $showtutorial = ''; $showtutorial .= ''."\n"; - $formproject->selectTasks((! empty($societe->id)?$societe->id:-1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); + $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); print ''; print '
    '.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note', $object->note, '', 200, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor('note', $object->note, '', 200, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); print '
    '; // Type - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''; } @@ -1630,12 +1630,12 @@ if ($id > 0) // Full day event print ''; - $rowspan=4; + $rowspan = 4; if (empty($conf->global->AGENDA_DISABLE_LOCATION)) $rowspan++; // Date start print ''; @@ -1643,9 +1643,9 @@ if ($id > 0) // Date end print ''; // Location @@ -1656,41 +1656,41 @@ if ($id > 0) // Assigned to print ''; // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table // for such objects because there is already a dedicated field into table llx_actioncomm. - if (! empty($object->fk_element) && ! empty($object->elementtype) && ! in_array($object->elementtype, array('societe','contact','project'))) + if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe', 'contact', 'project'))) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print ''; - $link=dolGetElementUrl($object->fk_element, $object->elementtype, 1); + $link = dolGetElementUrl($object->fk_element, $object->elementtype, 1); print ''; // Other attributes - $cols=3; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $cols = 3; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '.$langs->trans("Type").''.$langs->trans($object->type).'
    '.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).'
    '.$langs->trans("DateActionStart").''; - if (! $object->fulldayevent) print dol_print_date($object->datep, 'dayhour'); + if (!$object->fulldayevent) print dol_print_date($object->datep, 'dayhour'); else print dol_print_date($object->datep, 'day'); if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print '
    '.$langs->trans("DateActionEnd").''; - if (! $object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); + if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); else print dol_print_date($object->datef, 'day'); - if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); + if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print '
    '.$langs->trans("ActionAssignedTo").''; - $listofuserid=array(); + $listofuserid = array(); if (empty($donotclearsession)) { if ($object->userownerid > 0) { - $listofuserid[$object->userownerid]=array( + $listofuserid[$object->userownerid] = array( 'id'=>$object->userownerid, - 'transparency'=>$object->transparency, // Force transparency on onwer from preoperty of event + 'transparency'=>$object->transparency, // Force transparency on onwer from preoperty of event 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] ); } - if (! empty($object->userassigned)) // Now concat assigned users + if (!empty($object->userassigned)) // Now concat assigned users { // Restore array with key with same value than param 'id' - $tmplist1=$object->userassigned; - foreach($tmplist1 as $key => $val) + $tmplist1 = $object->userassigned; + foreach ($tmplist1 as $key => $val) { - if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val; + if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']] = $val; } } - $_SESSION['assignedtouser']=json_encode($listofuserid); + $_SESSION['assignedtouser'] = json_encode($listofuserid); } else { if (!empty($_SESSION['assignedtouser'])) { - $listofuserid=json_decode($_SESSION['assignedtouser'], true); + $listofuserid = json_decode($_SESSION['assignedtouser'], true); } } - $listofcontactid=array(); // not used yet - $listofotherid=array(); // not used yet + $listofcontactid = array(); // not used yet + $listofotherid = array(); // not used yet print '
    '; - print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef)?1:0, $listofuserid, $listofcontactid, $listofotherid); + print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid); print '
    '; /* if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid))) @@ -1710,7 +1710,7 @@ if ($id > 0) print '
    '.$langs->trans("ActionDoneBy").''; if ($object->userdoneid > 0) { - $tmpuser=new User($db); + $tmpuser = new User($db); $tmpuser->fetch($object->userdoneid); print $tmpuser->getNomUrl(1); } @@ -1727,7 +1727,7 @@ if ($id > 0) if ($conf->societe->enabled) { // Related company - print '
    '.$langs->trans("ActionOnCompany").''.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):(''.$langs->trans("None").'')); + print '
    '.$langs->trans("ActionOnCompany").''.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (''.$langs->trans("None").'')); if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') { if ($object->thirdparty->fetch($object->thirdparty->id)) @@ -1770,16 +1770,16 @@ if ($id > 0) // Priority print '
    '.$langs->trans("Priority").''; - print ($object->priority?$object->priority:''); + print ($object->priority ? $object->priority : ''); print '
    '.$langs->trans("LinkedObject").''; if (empty($link)) print ''.$langs->trans("ObjectDeleted").''; else print $link; @@ -1792,8 +1792,8 @@ if ($id > 0) print '
    '; @@ -1809,8 +1809,8 @@ if ($id > 0) print '
    '; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if ($action != 'edit') @@ -1860,11 +1860,11 @@ if ($id > 0) * Documents generes */ - $filedir=$conf->agenda->multidir_output[$conf->entity].'/'.$object->id; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; + $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$user->rights->agenda->myactions->read; - $delallowed=$user->rights->agenda->myactions->create; + $genallowed = $user->rights->agenda->myactions->read; + $delallowed = $user->rights->agenda->myactions->create; print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index a0263065dee..00ad6c9aa00 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -72,8 +72,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="nom"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "nom"; $cancelbutton = GETPOST('cancel', 'alpha'); $object = new Client($db); @@ -83,7 +83,7 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('thirdpartycomm','globalcard')); +$hookmanager->initHooks(array('thirdpartycomm', 'globalcard')); @@ -99,15 +99,15 @@ if (empty($reshook)) { if ($cancelbutton) { - $action=""; + $action = ""; } // set accountancy code if ($action == 'setcustomeraccountancycode') { - $result=$object->fetch($id); - $object->code_compta=$_POST["customeraccountancycode"]; - $result=$object->update($object->id, $user, 1, 1, 0); + $result = $object->fetch($id); + $object->code_compta = $_POST["customeraccountancycode"]; + $result = $object->update($object->id, $user, 1, 1, 0); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -115,7 +115,7 @@ if (empty($reshook)) if ($action == 'setconditions' && $user->rights->societe->creer) { $object->fetch($id); - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -123,7 +123,7 @@ if (empty($reshook)) if ($action == 'setmode' && $user->rights->societe->creer) { $object->fetch($id); - $result=$object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -131,7 +131,7 @@ if (empty($reshook)) if ($action == 'setbankaccount' && $user->rights->societe->creer) { $object->fetch($id); - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -147,8 +147,8 @@ if (empty($reshook)) if ($action == 'setassujtva' && $user->rights->societe->creer) { $object->fetch($id); - $object->tva_assuj=$_POST['assujtva_value']; - $result=$object->update($object->id); + $object->tva_assuj = $_POST['assujtva_value']; + $result = $object->update($object->id); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -156,8 +156,8 @@ if (empty($reshook)) if ($action == 'setprospectlevel' && $user->rights->societe->creer) { $object->fetch($id); - $object->fk_prospectlevel=GETPOST('prospect_level_id', 'alpha'); - $result=$object->update($object->id, $user); + $object->fk_prospectlevel = GETPOST('prospect_level_id', 'alpha'); + $result = $object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -165,8 +165,8 @@ if (empty($reshook)) if ($action == 'setstcomm') { $object->fetch($id); - $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); - $result=$object->update($object->id, $user); + $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); + $result = $object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -174,8 +174,8 @@ if (empty($reshook)) if ($action == 'setoutstanding_limit') { $object->fetch($id); - $object->outstanding_limit=GETPOST('outstanding_limit'); - $result=$object->update($object->id, $user); + $object->outstanding_limit = GETPOST('outstanding_limit'); + $result = $object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -183,8 +183,8 @@ if (empty($reshook)) if ($action == 'setorder_min_amount') { $object->fetch($id); - $object->order_min_amount=price2num(GETPOST('order_min_amount', 'alpha')); - $result=$object->update($object->id, $user); + $object->order_min_amount = price2num(GETPOST('order_min_amount', 'alpha')); + $result = $object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -196,7 +196,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { $result = $object->insertExtraFields('COMPANY_MODIFY'); if ($result < 0) @@ -215,20 +215,20 @@ if (empty($reshook)) */ $contactstatic = new Contact($db); -$userstatic=new User($db); +$userstatic = new User($db); $form = new Form($db); -$formcompany=new FormCompany($db); +$formcompany = new FormCompany($db); if ($id > 0 && empty($object->id)) { // Load data of third party - $res=$object->fetch($id); + $res = $object->fetch($id); if ($object->id < 0) dol_print_error($db, $object->error, $object->errors); } -$title=$langs->trans("CustomerCard"); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name; -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = $langs->trans("CustomerCard"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name; +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); @@ -253,10 +253,10 @@ if ($object->id > 0) print ''; // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''.$langs->trans("Prefix").''; - print ($object->prefix_comm?$object->prefix_comm:' '); + print ($object->prefix_comm ? $object->prefix_comm : ' '); print ''; } @@ -298,13 +298,13 @@ if ($object->id > 0) if ($mysoc->country_code == 'ES') { // Local Taxes - if ($mysoc->localtax1_assuj=="1") + if ($mysoc->localtax1_assuj == "1") { print ''.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; print yn($object->localtax1_assuj); print ''; } - if ($mysoc->localtax1_assuj=="1") + if ($mysoc->localtax1_assuj == "1") { print ''.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; print yn($object->localtax2_assuj); @@ -356,7 +356,7 @@ if ($object->id > 0) print ""; print ''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // Compte bancaire par défaut print ''; @@ -392,7 +392,7 @@ if ($object->id > 0) print ''.img_edit($langs->trans("Modify")).''; } print ''; - print ''.($object->remise_percent?''.$object->remise_percent.'%':'').''; + print ''.($object->remise_percent ? ''.$object->remise_percent.'%' : '').''; print ''; // Absolute discounts (Discounts-Drawbacks-Rebates) @@ -408,7 +408,7 @@ if ($object->id > 0) print ''; print ''; print ''; - $amount_discount=$object->getAvailableDiscounts(); + $amount_discount = $object->getAvailableDiscounts(); if ($amount_discount < 0) dol_print_error($db, $object->error); if ($amount_discount > 0) print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; //else print $langs->trans("DiscountNone"); @@ -423,7 +423,7 @@ if ($object->id > 0) print ''; print $form->editfieldkey("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer); print ''; - $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; + $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; print $form->editfieldval("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer, $limit_field_type, ($object->outstanding_limit != '' ? price($object->outstanding_limit) : '')); print ''; print ''; @@ -431,7 +431,7 @@ if ($object->id > 0) if ($object->client) { - if (! empty($conf->commande->enabled) && ! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) + if (!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) { print ''."\n"; print ''; @@ -446,7 +446,7 @@ if ($object->id > 0) // Multiprice level - if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { print ''; print '
    '; @@ -459,14 +459,14 @@ if ($object->id > 0) print '
    '; print ''; print $object->price_level; - $keyforlabel='PRODUIT_MULTIPRICES_LABEL'.$object->price_level; - if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); + $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$object->price_level; + if (!empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); print ""; print ''; } // Preferred shipping Method - if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) { + if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) { print ''; print ''; + print ''; print '"; } // Other attributes - $parameters=array('socid'=>$object->id); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('socid'=>$object->id); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Sales representative include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; // Module Adherent - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { $langs->load("members"); $langs->load("users"); print ''; print ''; @@ -574,65 +574,65 @@ if ($object->id > 0) $boxstat = ''; // Nbre max d'elements des petites listes - $MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT; + $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; // Lien recap - $boxstat.='
    '; - $boxstat.='
    '; print $langs->trans('SendingMethod'); @@ -489,32 +489,32 @@ if ($object->id > 0) // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { $langs->load("categories"); - print '
    ' . $langs->trans("CustomersCategoriesShort") . '
    '.$langs->trans("CustomersCategoriesShort").''; print $form->showCategories($object->id, 'customer', 1); print "
    '.$langs->trans("LinkedToDolibarrMember").''; - $adh=new Adherent($db); - $result=$adh->fetch('', '', $object->id); + $adh = new Adherent($db); + $result = $adh->fetch('', '', $object->id); if ($result > 0) { - $adh->ref=$adh->getFullName($langs); + $adh->ref = $adh->getFullName($langs); print $adh->getNomUrl(1); } else @@ -558,10 +558,10 @@ if ($object->id > 0) print '
    '.$langs->trans("StatusProsp").''.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']); print '     '; print '
    '; - foreach($object->cacheprospectstatus as $key => $val) + foreach ($object->cacheprospectstatus as $key => $val) { - $titlealt='default'; - if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label']; + $titlealt = 'default'; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; if ($object->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code']).''; } print '
    '; - $boxstat.=''; + $boxstat .= '
    '; + $boxstat .= '
    '; + $boxstat .= ''; + $boxstat .= ''; - $boxstat.='
    '; - if (! empty($conf->propal->enabled)) + if (!empty($conf->propal->enabled)) { // Box proposals $tmp = $object->getOutstandingProposals(); - $outstandingOpened=$tmp['opened']; - $outstandingTotal=$tmp['total_ht']; - $outstandingTotalIncTax=$tmp['total_ttc']; - $text=$langs->trans("OverAllProposals"); - $link=DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
    '; - $boxstat.=''.img_object("", $icon).' '.$text.'
    '; - $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat.='
    '; - if ($link) $boxstat.='
    '; + $outstandingOpened = $tmp['opened']; + $outstandingTotal = $tmp['total_ht']; + $outstandingTotalIncTax = $tmp['total_ttc']; + $text = $langs->trans("OverAllProposals"); + $link = DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
    '; + $boxstat .= ''.img_object("", $icon).' '.$text.'
    '; + $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat .= '
    '; + if ($link) $boxstat .= '
    '; } - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { // Box commandes $tmp = $object->getOutstandingOrders(); - $outstandingOpened=$tmp['opened']; - $outstandingTotal=$tmp['total_ht']; - $outstandingTotalIncTax=$tmp['total_ttc']; - $text=$langs->trans("OverAllOrders"); - $link=DOL_URL_ROOT.'/commande/list.php?socid='.$object->id; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
    '; - $boxstat.=''.img_object("", $icon).' '.$text.'
    '; - $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat.='
    '; - if ($link) $boxstat.='
    '; + $outstandingOpened = $tmp['opened']; + $outstandingTotal = $tmp['total_ht']; + $outstandingTotalIncTax = $tmp['total_ttc']; + $text = $langs->trans("OverAllOrders"); + $link = DOL_URL_ROOT.'/commande/list.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
    '; + $boxstat .= ''.img_object("", $icon).' '.$text.'
    '; + $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat .= '
    '; + if ($link) $boxstat .= '
    '; } - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { // Box factures $tmp = $object->getOutstandingBills(); - $outstandingOpened=$tmp['opened']; - $outstandingTotal=$tmp['total_ht']; - $outstandingTotalIncTax=$tmp['total_ttc']; - $text=$langs->trans("OverAllInvoices"); - $link=DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
    '; - $boxstat.=''.img_object("", $icon).' '.$text.'
    '; - $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat.='
    '; - if ($link) $boxstat.='
    '; + $outstandingOpened = $tmp['opened']; + $outstandingTotal = $tmp['total_ht']; + $outstandingTotalIncTax = $tmp['total_ttc']; + $text = $langs->trans("OverAllInvoices"); + $link = DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
    '; + $boxstat .= ''.img_object("", $icon).' '.$text.'
    '; + $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat .= '
    '; + if ($link) $boxstat .= '
    '; // Box outstanding bill $warn = ''; @@ -640,50 +640,50 @@ if ($object->id > 0) { $warn = ' '.img_warning($langs->trans("OutstandingBillReached")); } - $text=$langs->trans("CurrentOutstandingBill"); - $link=DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
    '; - $boxstat.=''.img_object("", $icon).' '.$text.'
    '; - $boxstat.=''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; - $boxstat.='
    '; - if ($link) $boxstat.='
    '; + $text = $langs->trans("CurrentOutstandingBill"); + $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
    '; + $boxstat .= ''.img_object("", $icon).' '.$text.'
    '; + $boxstat .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; + $boxstat .= '
    '; + if ($link) $boxstat .= '
    '; } $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action); - if(empty($reshook)){ - $boxstat.= $hookmanager->resPrint; + if (empty($reshook)) { + $boxstat .= $hookmanager->resPrint; } - $boxstat.='
    '; - $boxstat.='
    '; + $boxstat .= '
    '; + $boxstat .= '
    '; print $boxstat; - $now=dol_now(); + $now = dol_now(); /* * Last proposals */ - if (! empty($conf->propal->enabled) && $user->rights->propal->lire) + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht"; - $sql.= ", p.tva as total_tva"; - $sql.= ", p.total as total_ttc"; - $sql.= ", p.ref, p.ref_client, p.remise"; - $sql.= ", p.datep as dp, p.fin_validite as datelimite"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; - $sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; - $sql.= " AND s.rowid = ".$object->id; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - $sql.= " ORDER BY p.datep DESC"; + $sql .= ", p.tva as total_tva"; + $sql .= ", p.total as total_ttc"; + $sql .= ", p.ref, p.ref_client, p.remise"; + $sql .= ", p.datep as dp, p.fin_validite as datelimite"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; + $sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; + $sql .= " AND s.rowid = ".$object->id; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " ORDER BY p.datep DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $propal_static = new Propal($db); @@ -695,7 +695,7 @@ if ($object->id > 0) print ''; print ''; - print '
    '; + print ''; print ''; @@ -715,7 +715,7 @@ if ($object->id > 0) $propal_static->total_tva = $objp->total_tva; $propal_static->total_ttc = $objp->total_ttc; print $propal_static->getNomUrl(1); - if ( ($db->jdate($objp->datelimite) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1 ) { + if (($db->jdate($objp->datelimite) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1) { print " ".img_warning(); } print '\n"; @@ -740,39 +740,39 @@ if ($object->id > 0) /* * Last orders */ - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $sql = "SELECT s.nom, s.rowid"; - $sql.= ", c.rowid as cid, c.total_ht"; - $sql.= ", c.tva as total_tva"; - $sql.= ", c.total_ttc"; - $sql.= ", c.ref, c.ref_client, c.fk_statut, c.facture"; - $sql.= ", c.date_commande as dc"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - $sql.= " WHERE c.fk_soc = s.rowid "; - $sql.= " AND s.rowid = ".$object->id; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " ORDER BY c.date_commande DESC"; + $sql .= ", c.rowid as cid, c.total_ht"; + $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_ttc"; + $sql .= ", c.ref, c.ref_client, c.fk_statut, c.facture"; + $sql .= ", c.date_commande as dc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; + $sql .= " WHERE c.fk_soc = s.rowid "; + $sql .= " AND s.rowid = ".$object->id; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.date_commande DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $commande_static=new Commande($db); + $commande_static = new Commande($db); $num = $db->num_rows($resql); if ($num > 0) { // Check if there are orders billable $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,'; - $sql2.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed'; - $sql2.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; - $sql2.= ', '.MAIN_DB_PREFIX.'commande as c'; - $sql2.= ' WHERE c.fk_soc = s.rowid'; - $sql2.= ' AND s.rowid = '.$object->id; + $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed'; + $sql2 .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; + $sql2 .= ', '.MAIN_DB_PREFIX.'commande as c'; + $sql2 .= ' WHERE c.fk_soc = s.rowid'; + $sql2 .= ' AND s.rowid = '.$object->id; // Show orders with status validated, shipping started and delivered (well any order we can bill) - $sql2.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; + $sql2 .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; - $resql2=$db->query($sql2); + $resql2 = $db->query($sql2); $orders2invoice = $db->num_rows($resql2); $db->free($resql2); @@ -780,7 +780,7 @@ if ($object->id > 0) print '
    '.$langs->trans("LastPropals", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPropals").' '.$num.''; print ''; print '
    '.$langs->trans("LastPropals", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllPropals").' '.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
    '.dol_print_date($db->jdate($objp->dp), 'day')."
    '; print ''; - print ''; } else { - $out.=''; + $out .= ''; } // Status - $out.=''; + $out .= ''; // Actions - $out.=''; + $out .= ''; - $out.="\n"; + $out .= "\n"; $i++; } - $out.="
    '; + print ''; + print ''; $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); @@ -545,10 +545,10 @@ if ($object->id > 0) $remaintopaylesspendingdebit = $resteapayer - $pending; print ''; - print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; } @@ -596,14 +596,14 @@ if ($object->id > 0) print ''; $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande"; - $sql.= " , pfd.date_traite as date_traite, pfd.amount,"; - $sql.= " u.rowid as user_id, u.lastname, u.firstname, u.login"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; - $sql.= " WHERE fk_facture = ".$object->id; - $sql.= " AND pfd.traite = 0"; - $sql.= " ORDER BY pfd.date_demande DESC"; + $sql .= " , pfd.date_traite as date_traite, pfd.amount,"; + $sql .= " u.rowid as user_id, u.lastname, u.firstname, u.login"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; + $sql .= " WHERE fk_facture = ".$object->id; + $sql .= " AND pfd.traite = 0"; + $sql .= " ORDER BY pfd.date_demande DESC"; $result_sql = $db->query($sql); @@ -646,14 +646,14 @@ if ($object->id > 0) // Past requests $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,"; - $sql.= " pb.ref,"; - $sql.= " u.rowid as user_id, u.lastname, u.firstname, u.login"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; - $sql.= " WHERE fk_facture = ".$object->id; - $sql.= " AND pfd.traite = 1"; - $sql.= " ORDER BY pfd.date_demande DESC"; + $sql .= " pb.ref,"; + $sql .= " u.rowid as user_id, u.lastname, u.firstname, u.login"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; + $sql .= " WHERE fk_facture = ".$object->id; + $sql .= " AND pfd.traite = 1"; + $sql .= " ORDER BY pfd.date_demande DESC"; $result = $db->query($sql); if ($result) @@ -677,9 +677,9 @@ if ($object->id > 0) print '\n"; @@ -694,7 +694,7 @@ if ($object->id > 0) $i++; } - if (! $numopen && ! $numclosed) + if (!$numopen && !$numclosed) print ''; $db->free($result); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 3f1e4aef717..609181dec96 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -42,21 +42,21 @@ $langs->loadLangs(array('companies', 'bills', 'banks', 'multicurrency')); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$facid = GETPOST('facid', 'int'); -$accountid = GETPOST('accountid', 'int'); +$facid = GETPOST('facid', 'int'); +$accountid = GETPOST('accountid', 'int'); $paymentnum = GETPOST('num_paiement', 'alpha'); $socid = GETPOST('socid', 'int'); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOST('page', 'int'); -$amounts=array(); -$amountsresttopay=array(); -$addwarning=0; +$amounts = array(); +$amountsresttopay = array(); +$addwarning = 0; -$multicurrency_amounts=array(); -$multicurrency_amountsresttopay=array(); +$multicurrency_amounts = array(); +$multicurrency_amountsresttopay = array(); // Security check if ($user->socid > 0) @@ -64,24 +64,24 @@ if ($user->socid > 0) $socid = $user->socid; } -$object=new Facture($db); +$object = new Facture($db); // Load object if ($facid > 0) { - $ret=$object->fetch($facid); + $ret = $object->fetch($facid); } // Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('paiementcard','globalcard')); +$hookmanager->initHooks(array('paiementcard', 'globalcard')); /* * Actions */ -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) @@ -97,7 +97,7 @@ if (empty($reshook)) $atleastonepaymentnotnull = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new Facture($db); + $tmpinvoice = new Facture($db); foreach ($_POST as $key => $value) { if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') @@ -105,16 +105,16 @@ if (empty($reshook)) $cursorfacid = substr($key, 7); $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); if ($amounts[$cursorfacid]) { // Check amount if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date @@ -126,23 +126,23 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; - if (! empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $multicurrency_amountsresttopay[$cursorfacid]=price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); + $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); if ($multicurrency_amounts[$cursorfacid]) { // Check amount if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date @@ -154,18 +154,18 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => GETPOST($key, 'int')); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int')); } } // Check parameters - if (! GETPOST('paiementcode')) + if (!GETPOST('paiementcode')) { setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors'); $error++; } - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // If bank module is on, account is required to enter a payment if (GETPOST('accountid') <= 0) @@ -212,7 +212,7 @@ if (empty($reshook)) */ if ($action == 'confirm_paiement' && $confirm == 'yes') { - $error=0; + $error = 0; $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); @@ -244,7 +244,7 @@ if (empty($reshook)) } } - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement if (GETPOST('accountid', 'int') <= 0) @@ -257,17 +257,17 @@ if (empty($reshook)) // Creation of payment line $paiement = new Paiement($db); $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); $paiement->num_paiement = GETPOST('num_paiement', 'alpha'); $paiement->note = GETPOST('comment', 'alpha'); - if (! $error) + if (!$error) { // Create payment and update this->multicurrency_amounts if this->amounts filled or // this->amounts if this->multicurrency_amounts filled. - $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0), $thirdparty); // This include closing invoices and regenerating documents + $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -275,11 +275,11 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { - $label='(CustomerInvoicePayment)'; - if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) $label='(CustomerInvoicePaymentBack)'; // Refund of a credit note - $result=$paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank')); + $label = '(CustomerInvoicePayment)'; + if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank')); if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -287,19 +287,19 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $db->commit(); // If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card - $invoiceid=0; + $invoiceid = 0; foreach ($paiement->amounts as $key => $amount) { $facid = $key; if (is_numeric($amount) && $amount <> 0) { - if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment - else $invoiceid=$facid; + if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment + else $invoiceid = $facid; } } if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; @@ -319,7 +319,7 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); llxHeader('', $langs->trans("Payment")); @@ -335,31 +335,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { $facture->fetch_thirdparty(); - $title=''; - if ($facture->type != Facture::TYPE_CREDIT_NOTE) $title.=$langs->trans("EnterPaymentReceivedFromCustomer"); - if ($facture->type == Facture::TYPE_CREDIT_NOTE) $title.=$langs->trans("EnterPaymentDueToCustomer"); + $title = ''; + if ($facture->type != Facture::TYPE_CREDIT_NOTE) $title .= $langs->trans("EnterPaymentReceivedFromCustomer"); + if ($facture->type == Facture::TYPE_CREDIT_NOTE) $title .= $langs->trans("EnterPaymentDueToCustomer"); print load_fiche_titre($title); // Initialize data for confirmation (this is used because data can be change during confirmation) if ($action == 'add_paiement') { - $i=0; + $i = 0; - $formquestion[$i++]=array('type' => 'hidden','name' => 'facid', 'value' => $facture->id); - $formquestion[$i++]=array('type' => 'hidden','name' => 'socid', 'value' => $facture->socid); - $formquestion[$i++]=array('type' => 'hidden','name' => 'type', 'value' => $facture->type); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'socid', 'value' => $facture->socid); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'type', 'value' => $facture->type); } // Invoice with Paypal transaction // TODO add hook possibility (regis) - if (! empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && ! empty($facture->ref_int)) + if (!empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_int)) { - if (! empty($conf->global->PAYPAL_BANK_ACCOUNT)) $accountid=$conf->global->PAYPAL_BANK_ACCOUNT; - $paymentnum=$facture->ref_int; + if (!empty($conf->global->PAYPAL_BANK_ACCOUNT)) $accountid = $conf->global->PAYPAL_BANK_ACCOUNT; + $paymentnum = $facture->ref_int; } // Add realtime total information - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print "\n".''."\n"; + $this->stringtoshow .= 'plotWithOptions_'.$tag.'();'."\n"; + $this->stringtoshow .= '});'."\n"; + $this->stringtoshow .= ''."\n"; } @@ -1138,8 +1138,8 @@ class DolGraph if ($shownographyet) { - $s= '
    '; - $s.='
    '.$langs->trans("NotEnoughDataYet").'
    '; + $s = '
    '; + $s .= '
    '.$langs->trans("NotEnoughDataYet").'
    '; return $s; } @@ -1161,11 +1161,11 @@ class DolGraph if ($direction == 'width') { if (empty($conf->dol_optimize_smallscreen)) return ($defaultsize ? $defaultsize : '500'); - else return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width']-40)); + else return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width'] - 40)); } if ($direction == 'height') { - return (empty($conf->dol_optimize_smallscreen)?($defaultsize?$defaultsize:'200'):'160'); + return (empty($conf->dol_optimize_smallscreen) ? ($defaultsize ? $defaultsize : '200') : '160'); } return 0; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 8567ef595a0..81dffc51b67 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -140,7 +140,7 @@ class ExtraFields /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Array of Error code (or message) @@ -153,7 +153,7 @@ class ExtraFields public $errno; - public static $type2label=array( + public static $type2label = array( 'varchar'=>'String', 'text'=>'TextLong', 'html'=>'HtmlText', @@ -280,67 +280,67 @@ class ExtraFields */ private function create($attrname, $type = 'varchar', $length = 255, $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = '', $perms = '', $list = '0', $computed = '', $help = '') { - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - $table=$elementtype.'_extrafields'; - if ($elementtype == 'categorie') $table='categories_extrafields'; + $table = $elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table = 'categories_extrafields'; - if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/", $attrname) && ! is_numeric($attrname)) + if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/", $attrname) && !is_numeric($attrname)) { - if ($type=='boolean') { - $typedb='int'; - $lengthdb='1'; - } elseif($type=='price') { - $typedb='double'; - $lengthdb='24,8'; - } elseif($type=='phone') { - $typedb='varchar'; - $lengthdb='20'; - } elseif($type=='mail') { - $typedb='varchar'; - $lengthdb='128'; - } elseif($type=='url') { - $typedb='varchar'; - $lengthdb='255'; - } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox') ||($type=='chkbxlst')){ - $typedb='varchar'; - $lengthdb='255'; - } elseif ($type=='link') { - $typedb='int'; - $lengthdb='11'; - } elseif ($type=='html') { - $typedb='text'; - $lengthdb=$length; - } elseif($type=='password') { - $typedb='varchar'; - $lengthdb='128'; + if ($type == 'boolean') { + $typedb = 'int'; + $lengthdb = '1'; + } elseif ($type == 'price') { + $typedb = 'double'; + $lengthdb = '24,8'; + } elseif ($type == 'phone') { + $typedb = 'varchar'; + $lengthdb = '20'; + } elseif ($type == 'mail') { + $typedb = 'varchar'; + $lengthdb = '128'; + } elseif ($type == 'url') { + $typedb = 'varchar'; + $lengthdb = '255'; + } elseif (($type == 'select') || ($type == 'sellist') || ($type == 'radio') || ($type == 'checkbox') || ($type == 'chkbxlst')) { + $typedb = 'varchar'; + $lengthdb = '255'; + } elseif ($type == 'link') { + $typedb = 'int'; + $lengthdb = '11'; + } elseif ($type == 'html') { + $typedb = 'text'; + $lengthdb = $length; + } elseif ($type == 'password') { + $typedb = 'varchar'; + $lengthdb = '128'; } else { - $typedb=$type; - $lengthdb=$length; - if ($type == 'varchar' && empty($lengthdb)) $lengthdb='255'; + $typedb = $type; + $lengthdb = $length; + if ($type == 'varchar' && empty($lengthdb)) $lengthdb = '255'; } $field_desc = array( 'type'=>$typedb, 'value'=>$lengthdb, - 'null'=>($required?'NOT NULL':'NULL'), + 'null'=>($required ? 'NOT NULL' : 'NULL'), 'default' => $default_value ); - $result=$this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); + $result = $this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); if ($result > 0) { if ($unique) { - $sql="ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; - $resql=$this->db->query($sql, 1, 'dml'); + $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; + $resql = $this->db->query($sql, 1, 'dml'); } return 1; } else { - $this->error=$this->db->lasterror(); - $this->errno=$this->db->lasterrno(); + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); return -1; } } @@ -378,19 +378,19 @@ class ExtraFields private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = 0, $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0) { // phpcs:enable - global $conf,$user; + global $conf, $user; - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; // Clean parameters - if (empty($pos)) $pos=0; - if (empty($list)) $list='0'; - if (empty($required)) $required=0; - if (empty($unique)) $unique=0; - if (empty($alwayseditable)) $alwayseditable=0; + if (empty($pos)) $pos = 0; + if (empty($list)) $list = '0'; + if (empty($required)) $required = 0; + if (empty($unique)) $unique = 0; + if (empty($alwayseditable)) $alwayseditable = 0; - if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname) && ! is_numeric($attrname)) + if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname) && !is_numeric($attrname)) { if (is_array($param) && count($param) > 0) { @@ -460,8 +460,8 @@ class ExtraFields } else { - $this->error=$this->db->lasterror(); - $this->errno=$this->db->lasterrno(); + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); return -1; } } @@ -476,30 +476,30 @@ class ExtraFields */ public function delete($attrname, $elementtype = 'member') { - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - $table=$elementtype.'_extrafields'; - if ($elementtype == 'categorie') $table='categories_extrafields'; + $table = $elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table = 'categories_extrafields'; - $error=0; + $error = 0; - if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) + if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { - $result=$this->delete_label($attrname, $elementtype); + $result = $this->delete_label($attrname, $elementtype); if ($result < 0) { - $this->error=$this->db->lasterror(); - $this->errors[]=$this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } - if (! $error) + if (!$error) { $sql = "SELECT COUNT(rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; - $sql.= " WHERE elementtype = '".$elementtype."'"; - $sql.= " AND name = '".$attrname."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."extrafields"; + $sql .= " WHERE elementtype = '".$elementtype."'"; + $sql .= " AND name = '".$attrname."'"; //$sql.= " AND entity IN (0,".$conf->entity.")"; Do not test on entity here. We want to see if there is still on field remaning in other entities before deleting field in table $resql = $this->db->query($sql); if ($resql) @@ -507,11 +507,11 @@ class ExtraFields $obj = $this->db->fetch_object($resql); if ($obj->nb <= 0) { - $result=$this->db->DDLDropField(MAIN_DB_PREFIX.$table, $attrname); // This also drop the unique key + $result = $this->db->DDLDropField(MAIN_DB_PREFIX.$table, $attrname); // This also drop the unique key if ($result < 0) { - $this->error=$this->db->lasterror(); - $this->errors[]=$this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } } @@ -539,18 +539,18 @@ class ExtraFields // phpcs:enable global $conf; - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; - $sql.= " WHERE name = '".$attrname."'"; - $sql.= " AND entity IN (0,".$conf->entity.')'; - $sql.= " AND elementtype = '".$elementtype."'"; + $sql .= " WHERE name = '".$attrname."'"; + $sql .= " AND entity IN (0,".$conf->entity.')'; + $sql .= " AND elementtype = '".$elementtype."'"; dol_syslog(get_class($this)."::delete_label", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { return 1; @@ -593,80 +593,80 @@ class ExtraFields */ public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0) { - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - $table=$elementtype.'_extrafields'; - if ($elementtype == 'categorie') $table='categories_extrafields'; + $table = $elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table = 'categories_extrafields'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { - if ($type=='boolean') { - $typedb='int'; - $lengthdb='1'; - } elseif($type=='price') { - $typedb='double'; - $lengthdb='24,8'; - } elseif($type=='phone') { - $typedb='varchar'; - $lengthdb='20'; - } elseif($type=='mail') { - $typedb='varchar'; - $lengthdb='128'; - } elseif($type=='url') { - $typedb='varchar'; - $lengthdb='255'; - } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') || ($type=='checkbox') || ($type=='chkbxlst')) { - $typedb='varchar'; - $lengthdb='255'; + if ($type == 'boolean') { + $typedb = 'int'; + $lengthdb = '1'; + } elseif ($type == 'price') { + $typedb = 'double'; + $lengthdb = '24,8'; + } elseif ($type == 'phone') { + $typedb = 'varchar'; + $lengthdb = '20'; + } elseif ($type == 'mail') { + $typedb = 'varchar'; + $lengthdb = '128'; + } elseif ($type == 'url') { + $typedb = 'varchar'; + $lengthdb = '255'; + } elseif (($type == 'select') || ($type == 'sellist') || ($type == 'radio') || ($type == 'checkbox') || ($type == 'chkbxlst')) { + $typedb = 'varchar'; + $lengthdb = '255'; } elseif ($type == 'html') { - $typedb='text'; - } elseif ($type=='link') { - $typedb='int'; - $lengthdb='11'; - } elseif($type=='password') { - $typedb='varchar'; - $lengthdb='50'; + $typedb = 'text'; + } elseif ($type == 'link') { + $typedb = 'int'; + $lengthdb = '11'; + } elseif ($type == 'password') { + $typedb = 'varchar'; + $lengthdb = '50'; } else { - $typedb=$type; - $lengthdb=$length; + $typedb = $type; + $lengthdb = $length; } - $field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required?'NOT NULL':'NULL'), 'default'=>$default); + $field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required ? 'NOT NULL' : 'NULL'), 'default'=>$default); if ($type != 'separate') // No table update when separate type { - $result=$this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); + $result = $this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); } if ($result > 0 || $type == 'separate') { if ($label) { - $result=$this->update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable); + $result = $this->update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable); } if ($result > 0) { - $sql=''; + $sql = ''; if ($unique) { - $sql="ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; + $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; } else { - $sql="ALTER TABLE ".MAIN_DB_PREFIX.$table." DROP INDEX uk_".$table."_".$attrname; + $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." DROP INDEX uk_".$table."_".$attrname; } dol_syslog(get_class($this).'::update', LOG_DEBUG); - $resql=$this->db->query($sql, 1, 'dml'); + $resql = $this->db->query($sql, 1, 'dml'); return 1; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -708,17 +708,17 @@ class ExtraFields dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled.", ".$totalizable); // Clean parameters - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - if (empty($pos)) $pos=0; - if (empty($list)) $list='0'; + if (empty($pos)) $pos = 0; + if (empty($list)) $list = '0'; if (empty($totalizable)) { $totalizable = 0; } - if (empty($required)) $required=0; - if (empty($unique)) $unique=0; - if (empty($alwayseditable)) $alwayseditable=0; + if (empty($required)) $required = 0; + if (empty($unique)) $unique = 0; + if (empty($alwayseditable)) $alwayseditable = 0; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { @@ -734,76 +734,76 @@ class ExtraFields } else { - $params=''; + $params = ''; } if ($entity === '' || $entity != '0') { // We dont want on all entities, we delete all and current $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; - $sql_del.= " WHERE name = '".$attrname."'"; - $sql_del.= " AND entity IN (0, ".($entity===''?$conf->entity:$entity).")"; - $sql_del.= " AND elementtype = '".$elementtype."'"; + $sql_del .= " WHERE name = '".$attrname."'"; + $sql_del .= " AND entity IN (0, ".($entity === '' ? $conf->entity : $entity).")"; + $sql_del .= " AND elementtype = '".$elementtype."'"; } else { // We want on all entities ($entities = '0'), we delete on all only (we keep setup specific to each entity) $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; - $sql_del.= " WHERE name = '".$attrname."'"; - $sql_del.= " AND entity = 0"; - $sql_del.= " AND elementtype = '".$elementtype."'"; + $sql_del .= " WHERE name = '".$attrname."'"; + $sql_del .= " AND entity = 0"; + $sql_del .= " AND elementtype = '".$elementtype."'"; } - $resql1=$this->db->query($sql_del); + $resql1 = $this->db->query($sql_del); $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields("; - $sql.= " name,"; // This is code - $sql.= " entity,"; - $sql.= " label,"; - $sql.= " type,"; - $sql.= " size,"; - $sql.= " elementtype,"; - $sql.= " fieldunique,"; - $sql.= " fieldrequired,"; - $sql.= " perms,"; - $sql.= " langs,"; - $sql.= " pos,"; - $sql.= " alwayseditable,"; - $sql.= " param,"; - $sql.= " list,"; - $sql.= " totalizable,"; - $sql.= " fielddefault,"; - $sql.= " fieldcomputed,"; - $sql.= " fk_user_author,"; - $sql.= " fk_user_modif,"; - $sql.= " datec,"; - $sql.= " enabled,"; - $sql.= " help"; - $sql.= ") VALUES ("; - $sql.= "'".$attrname."',"; - $sql.= " ".($entity===''?$conf->entity:$entity).","; - $sql.= " '".$this->db->escape($label)."',"; - $sql.= " '".$this->db->escape($type)."',"; - $sql.= " '".$this->db->escape($size)."',"; - $sql.= " '".$this->db->escape($elementtype)."',"; - $sql.= " ".$unique.","; - $sql.= " ".$required.","; - $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; - $sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").","; - $sql.= " ".$pos.","; - $sql.= " '".$this->db->escape($alwayseditable)."',"; - $sql.= " '".$this->db->escape($params)."',"; - $sql.= " '".$this->db->escape($list)."', "; - $sql.= " ".$totalizable.","; - $sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").","; - $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; - $sql .= " " . $user->id . ","; - $sql .= " " . $user->id . ","; - $sql .= "'" . $this->db->idate(dol_now()) . "',"; - $sql .= "'" . $this->db->escape($enabled). "',"; - $sql.= " ".($help?"'".$this->db->escape($help)."'":"null"); - $sql.= ")"; + $sql .= " name,"; // This is code + $sql .= " entity,"; + $sql .= " label,"; + $sql .= " type,"; + $sql .= " size,"; + $sql .= " elementtype,"; + $sql .= " fieldunique,"; + $sql .= " fieldrequired,"; + $sql .= " perms,"; + $sql .= " langs,"; + $sql .= " pos,"; + $sql .= " alwayseditable,"; + $sql .= " param,"; + $sql .= " list,"; + $sql .= " totalizable,"; + $sql .= " fielddefault,"; + $sql .= " fieldcomputed,"; + $sql .= " fk_user_author,"; + $sql .= " fk_user_modif,"; + $sql .= " datec,"; + $sql .= " enabled,"; + $sql .= " help"; + $sql .= ") VALUES ("; + $sql .= "'".$attrname."',"; + $sql .= " ".($entity === '' ? $conf->entity : $entity).","; + $sql .= " '".$this->db->escape($label)."',"; + $sql .= " '".$this->db->escape($type)."',"; + $sql .= " '".$this->db->escape($size)."',"; + $sql .= " '".$this->db->escape($elementtype)."',"; + $sql .= " ".$unique.","; + $sql .= " ".$required.","; + $sql .= " ".($perms ? "'".$this->db->escape($perms)."'" : "null").","; + $sql .= " ".($langfile ? "'".$this->db->escape($langfile)."'" : "null").","; + $sql .= " ".$pos.","; + $sql .= " '".$this->db->escape($alwayseditable)."',"; + $sql .= " '".$this->db->escape($params)."',"; + $sql .= " '".$this->db->escape($list)."', "; + $sql .= " ".$totalizable.","; + $sql .= " ".(($default != '') ? "'".$this->db->escape($default)."'" : "null").","; + $sql .= " ".($computed ? "'".$this->db->escape($computed)."'" : "null").","; + $sql .= " ".$user->id.","; + $sql .= " ".$user->id.","; + $sql .= "'".$this->db->idate(dol_now())."',"; + $sql .= "'".$this->db->escape($enabled)."',"; + $sql .= " ".($help ? "'".$this->db->escape($help)."'" : "null"); + $sql .= ")"; - $resql2=$this->db->query($sql); + $resql2 = $this->db->query($sql); if ($resql1 && $resql2) { @@ -839,11 +839,11 @@ class ExtraFields if (empty($elementtype)) return array(); - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; - if ($elementtype == 'order_supplier') $elementtype='commande_fournisseur'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; + if ($elementtype == 'order_supplier') $elementtype = 'commande_fournisseur'; - $array_name_label=array(); + $array_name_label = array(); // To avoid conflicts with external modules. TODO Remove this. if (empty($forceload) && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; @@ -871,12 +871,12 @@ class ExtraFields // We should not have several time this request. If we have, there is some optimization to do by calling a simple $extrafields->fetch_optionals() in top of code and not into subcode $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,totalizable,fielddefault,fieldcomputed,entity,enabled,help"; - $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; + $sql .= " FROM ".MAIN_DB_PREFIX."extrafields"; //$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later - if ($elementtype) $sql.= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element - $sql.= " ORDER BY pos"; + if ($elementtype) $sql .= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element + $sql .= " ORDER BY pos"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -888,7 +888,7 @@ class ExtraFields // This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field without default value if ($tab->fieldrequired && is_null($tab->fielddefault)) { - $this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name]=$tab->type; + $this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name] = $tab->type; } continue; } @@ -969,58 +969,58 @@ class ExtraFields */ public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $extrafieldsobjectkey = '', $mode = 0) { - global $conf,$langs,$form; + global $conf, $langs, $form; - if (! is_object($form)) + if (!is_object($form)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $form=new Form($this->db); + $form = new Form($this->db); } - $out=''; + $out = ''; - if (! preg_match('/options_$/', $keyprefix)) // Because we work on extrafields, we add 'options_' to prefix if not already added + if (!preg_match('/options_$/', $keyprefix)) // Because we work on extrafields, we add 'options_' to prefix if not already added { $keyprefix = $keyprefix.'options_'; } - if (! empty($extrafieldsobjectkey)) + if (!empty($extrafieldsobjectkey)) { - $label=$this->attributes[$extrafieldsobjectkey]['label'][$key]; - $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; - $size=$this->attributes[$extrafieldsobjectkey]['size'][$key]; - $default=$this->attributes[$extrafieldsobjectkey]['default'][$key]; - $computed=$this->attributes[$extrafieldsobjectkey]['computed'][$key]; - $unique=$this->attributes[$extrafieldsobjectkey]['unique'][$key]; - $required=$this->attributes[$extrafieldsobjectkey]['required'][$key]; - $param=$this->attributes[$extrafieldsobjectkey]['param'][$key]; - $perms=dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); - $langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key]; - $list=dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); - $totalizable=$this->attributes[$extrafieldsobjectkey]['totalizable'][$key]; - $help=$this->attributes[$extrafieldsobjectkey]['help'][$key]; - $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + $label = $this->attributes[$extrafieldsobjectkey]['label'][$key]; + $type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; + $size = $this->attributes[$extrafieldsobjectkey]['size'][$key]; + $default = $this->attributes[$extrafieldsobjectkey]['default'][$key]; + $computed = $this->attributes[$extrafieldsobjectkey]['computed'][$key]; + $unique = $this->attributes[$extrafieldsobjectkey]['unique'][$key]; + $required = $this->attributes[$extrafieldsobjectkey]['required'][$key]; + $param = $this->attributes[$extrafieldsobjectkey]['param'][$key]; + $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); + $langfile = $this->attributes[$extrafieldsobjectkey]['langfile'][$key]; + $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); + $totalizable = $this->attributes[$extrafieldsobjectkey]['totalizable'][$key]; + $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; + $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } else // Old usage { - $label=$this->attribute_label[$key]; - $type =$this->attribute_type[$key]; - $size =$this->attribute_size[$key]; - $elementtype=$this->attribute_elementtype[$key]; // Seems not used - $default=$this->attribute_default[$key]; - $computed=$this->attribute_computed[$key]; - $unique=$this->attribute_unique[$key]; - $required=$this->attribute_required[$key]; - $param=$this->attribute_param[$key]; - $langfile=$this->attribute_langfile[$key]; - $list=$this->attribute_list[$key]; - $totalizable=$this->attribute_totalizable[$key]; - $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + $label = $this->attribute_label[$key]; + $type = $this->attribute_type[$key]; + $size = $this->attribute_size[$key]; + $elementtype = $this->attribute_elementtype[$key]; // Seems not used + $default = $this->attribute_default[$key]; + $computed = $this->attribute_computed[$key]; + $unique = $this->attribute_unique[$key]; + $required = $this->attribute_required[$key]; + $param = $this->attribute_param[$key]; + $langfile = $this->attribute_langfile[$key]; + $list = $this->attribute_list[$key]; + $totalizable = $this->attribute_totalizable[$key]; + $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } if ($computed) { - if (! preg_match('/^search_/', $keyprefix)) return ''.$langs->trans("AutomaticallyCalculated").''; + if (!preg_match('/^search_/', $keyprefix)) return ''.$langs->trans("AutomaticallyCalculated").''; else return ''; } @@ -1034,21 +1034,21 @@ class ExtraFields { $morecss = 'minwidth200imp'; } - elseif (in_array($type, array('int','integer','double','price'))) + elseif (in_array($type, array('int', 'integer', 'double', 'price'))) { $morecss = 'maxwidth75'; } elseif ($type == 'password') { - $morecss='maxwidth100'; + $morecss = 'maxwidth100'; } elseif ($type == 'url') { - $morecss='minwidth400'; + $morecss = 'minwidth400'; } elseif ($type == 'boolean') { - $morecss=''; + $morecss = ''; } else { @@ -1067,10 +1067,10 @@ class ExtraFields } } - if (in_array($type, array('date','datetime'))) + if (in_array($type, array('date', 'datetime'))) { - $tmp=explode(',', $size); - $newsize=$tmp[0]; + $tmp = explode(',', $size); + $newsize = $tmp[0]; $showtime = in_array($type, array('datetime')) ? 1 : 0; @@ -1080,118 +1080,118 @@ class ExtraFields // TODO Must also support $moreparam $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); } - elseif (in_array($type, array('int','integer'))) + elseif (in_array($type, array('int', 'integer'))) { - $tmp=explode(',', $size); - $newsize=$tmp[0]; - $out=''; + $tmp = explode(',', $size); + $newsize = $tmp[0]; + $out = ''; } elseif (preg_match('/varchar/', $type)) { - $out=''; + $out = ''; } elseif (in_array($type, array('mail', 'phone', 'url'))) { - $out=''; + $out = ''; } elseif ($type == 'text') { - if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field + if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); - $out=$doleditor->Create(1); + $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); + $out = $doleditor->Create(1); } else { - $out=''; + $out = ''; } } elseif ($type == 'html') { - if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field + if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, ! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); - $out=$doleditor->Create(1); + $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); + $out = $doleditor->Create(1); } else { - $out=''; + $out = ''; } } elseif ($type == 'boolean') { if (empty($mode)) { - $checked=''; + $checked = ''; if (!empty($value)) { - $checked=' checked value="1" '; + $checked = ' checked value="1" '; } else { - $checked=' value="1" '; + $checked = ' value="1" '; } - $out=''; + $out = ''; } else { - $out.=$form->selectyesno($keyprefix.$key.$keysuffix, $value, 1, false, 1); + $out .= $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1, false, 1); } } elseif ($type == 'price') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. - $value=price($value); + $value = price($value); } - $out=' '.$langs->getCurrencySymbol($conf->currency); + $out = ' '.$langs->getCurrencySymbol($conf->currency); } elseif ($type == 'double') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. - $value=price($value); + $value = price($value); } - $out=' '; + $out = ' '; } elseif ($type == 'select') { $out = ''; - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); } - $out.=''; + $out .= ''; foreach ($param['options'] as $key => $val) { if ((string) $key == '') continue; list($val, $parent) = explode('|', $val); - $out.=''; + $out .= ''; } - $out.=''; + $out .= ''; } elseif ($type == 'sellist') { $out = ''; - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); } - $out.=''; if (is_array($param['options'])) { - $param_list=array_keys($param['options']); + $param_list = array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); - $parentName=''; - $parentField=''; + $parentName = ''; + $parentField = ''; // 0 : tableName // 1 : label field name // 2 : key fields name (if differ of rowid) @@ -1199,22 +1199,22 @@ class ExtraFields // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value // 5 : id category type // 6 : ids categories list separated by comma for category root - $keyList=(empty($InfoFieldList[2])?'rowid':$InfoFieldList[2].' as rowid'); + $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid'); - if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4])) + if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) { if (strpos($InfoFieldList[4], 'extra.') !== false) { - $keyList='main.'.$InfoFieldList[2].' as rowid'; + $keyList = 'main.'.$InfoFieldList[2].' as rowid'; } else { - $keyList=$InfoFieldList[2].' as rowid'; + $keyList = $InfoFieldList[2].' as rowid'; } } - if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) + if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) { list($parentName, $parentField) = explode('|', $InfoFieldList[3]); - $keyList.= ', '.$parentField; + $keyList .= ', '.$parentField; } $filter_categorie = false; @@ -1232,8 +1232,8 @@ class ExtraFields } $sqlwhere = ''; - $sql = 'SELECT ' . $keyList; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; + $sql = 'SELECT '.$keyList; + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { // can use curent entity filter if (strpos($InfoFieldList[4], '$ENTITY$') !== false) { @@ -1252,24 +1252,24 @@ class ExtraFields } //We have to join on extrafield table if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; - $sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4]; + $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; + $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; } else { - $sqlwhere .= ' WHERE ' . $InfoFieldList[4]; + $sqlwhere .= ' WHERE '.$InfoFieldList[4]; } } else { $sqlwhere .= ' WHERE 1=1'; } // Some tables may have field, some other not. For the moment we disable it. if (in_array($InfoFieldList[0], array('tablewithentity'))) { - $sqlwhere .= ' AND entity = ' . $conf->entity; + $sqlwhere .= ' AND entity = '.$conf->entity; } $sql .= $sqlwhere; //print $sql; - $sql .= ' ORDER BY ' . implode(', ', $fields_label); + $sql .= ' ORDER BY '.implode(', ', $fields_label); - dol_syslog(get_class($this) . '::showInputField type=sellist', LOG_DEBUG); + dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $out .= ''; @@ -1285,7 +1285,7 @@ class ExtraFields if (is_array($fields_label) && count($fields_label) > 1) { $notrans = true; foreach ($fields_label as $field_toshow) { - $labeltoshow .= $obj->$field_toshow . ' '; + $labeltoshow .= $obj->$field_toshow.' '; } } else { $labeltoshow = $obj->{$InfoFieldList[1]}; @@ -1296,10 +1296,10 @@ class ExtraFields if (!$notrans) { foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); - $labeltoshow = dol_trunc($translabel, 18) . ' '; + $labeltoshow = dol_trunc($translabel, 18).' '; } } - $out .= ''; + $out .= ''; } else { if (!$notrans) { $translabel = $langs->trans($obj->{$InfoFieldList[1]}); @@ -1308,48 +1308,48 @@ class ExtraFields if (empty($labeltoshow)) $labeltoshow = '(not defined)'; if (!empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName . ':' . $obj->{$parentField}; + $parent = $parentName.':'.$obj->{$parentField}; } - $out .= ''; + $out .= (!empty($parent) ? ' parent="'.$parent.'"' : ''); + $out .= '>'.$labeltoshow.''; } $i++; } $this->db->free($resql); } else { - print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
    '; + print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.
    '; } } else { $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1); $out .= ''; foreach ($data as $data_key => $data_value) { - $out .= ''; } } } - $out.=''; + $out .= ''; } elseif ($type == 'checkbox') { - $value_arr=explode(',', $value); - $out=$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); + $value_arr = explode(',', $value); + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); } elseif ($type == 'radio') { - $out=''; + $out = ''; foreach ($param['options'] as $keyopt => $val) { - $out.=''.$val.'
    '; + $out .= ''.$val.'
    '; } } elseif ($type == 'chkbxlst') @@ -1364,8 +1364,8 @@ class ExtraFields if (is_array($param['options'])) { $param_list = array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); - $parentName=''; - $parentField=''; + $parentName = ''; + $parentField = ''; // 0 : tableName // 1 : label field name // 2 : key fields name (if differ of rowid) @@ -1373,17 +1373,17 @@ class ExtraFields // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value // 5 : id category type // 6 : ids categories list separated by comma for category root - $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid'); + $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid'); - if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) { - list ( $parentName, $parentField ) = explode('|', $InfoFieldList[3]); - $keyList .= ', ' . $parentField; + if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) { + list ($parentName, $parentField) = explode('|', $InfoFieldList[3]); + $keyList .= ', '.$parentField; } - if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4])) { + if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) { if (strpos($InfoFieldList[4], 'extra.') !== false) { - $keyList = 'main.' . $InfoFieldList[2] . ' as rowid'; + $keyList = 'main.'.$InfoFieldList[2].' as rowid'; } else { - $keyList = $InfoFieldList[2] . ' as rowid'; + $keyList = $InfoFieldList[2].' as rowid'; } } @@ -1402,8 +1402,8 @@ class ExtraFields } $sqlwhere = ''; - $sql = 'SELECT ' . $keyList; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; + $sql = 'SELECT '.$keyList; + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$') !== false) { @@ -1426,11 +1426,11 @@ class ExtraFields // Init des compteurs $nbPregRepl = $nbPregSel = 0; // On retire toutes les parenthèses sans = avant - $InfoFieldList[4] = preg_replace('#([^=])(\([^)^(]*(' . $word . ')[^)^(]*\))#', '$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl); + $InfoFieldList[4] = preg_replace('#([^=])(\([^)^(]*('.$word.')[^)^(]*\))#', '$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl); // On retire les espaces autour des = et parenthèses $InfoFieldList[4] = preg_replace('# *(=|\(|\)) *#', '$1', $InfoFieldList[4]); // On retire toutes les parenthèses avec = avant - $InfoFieldList[4] = preg_replace('#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*(' . $word . ')[^)^(]*\)#', '$1 ', $InfoFieldList[4], -1, $nbPregSel); + $InfoFieldList[4] = preg_replace('#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.')[^)^(]*\)#', '$1 ', $InfoFieldList[4], -1, $nbPregSel); // On retire les espaces autour des = et parenthèses $InfoFieldList[4] = preg_replace('# *(=|\(|\)) *#', '$1', $InfoFieldList[4]); @@ -1439,7 +1439,7 @@ class ExtraFields } // Si l'on a un AND ou un OR, avant ou après - preg_match('#(AND|OR|) *(' . $word . ') *(AND|OR|)#', $InfoFieldList[4], $matchCondition); + preg_match('#(AND|OR|) *('.$word.') *(AND|OR|)#', $InfoFieldList[4], $matchCondition); while (!empty($matchCondition[0])) { // If the two sides differ but are not empty if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) { @@ -1448,7 +1448,7 @@ class ExtraFields } else { if (!empty($matchCondition[1])) { $boolCond = (($matchCondition[1] == "AND") ? ' AND TRUE ' : ' OR FALSE '); - $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond . $matchCondition[3], $InfoFieldList[4]); + $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]); } elseif (!empty($matchCondition[3])) { $boolCond = (($matchCondition[3] == "AND") ? ' TRUE AND ' : ' FALSE OR'); $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]); @@ -1458,7 +1458,7 @@ class ExtraFields } // Si l'on a un AND ou un OR, avant ou après - preg_match('#(AND|OR|) *(' . $word . ') *(AND|OR|)#', $InfoFieldList[4], $matchCondition); + preg_match('#(AND|OR|) *('.$word.') *(AND|OR|)#', $InfoFieldList[4], $matchCondition); } } else { $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); @@ -1466,23 +1466,23 @@ class ExtraFields // We have to join on extrafield table if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; - $sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4]; + $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; + $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; } else { - $sqlwhere .= ' WHERE ' . $InfoFieldList[4]; + $sqlwhere .= ' WHERE '.$InfoFieldList[4]; } } else { $sqlwhere .= ' WHERE 1=1'; } // Some tables may have field, some other not. For the moment we disable it. if (in_array($InfoFieldList[0], array('tablewithentity'))) { - $sqlwhere .= ' AND entity = ' . $conf->entity; + $sqlwhere .= ' AND entity = '.$conf->entity; } // $sql.=preg_replace('/^ AND /','',$sqlwhere); // print $sql; $sql .= $sqlwhere; - dol_syslog(get_class($this) . '::showInputField type=chkbxlst', LOG_DEBUG); + dol_syslog(get_class($this).'::showInputField type=chkbxlst', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -1500,7 +1500,7 @@ class ExtraFields if (is_array($fields_label)) { $notrans = true; foreach ($fields_label as $field_toshow) { - $labeltoshow .= $obj->$field_toshow . ' '; + $labeltoshow .= $obj->$field_toshow.' '; } } else { $labeltoshow = $obj->{$InfoFieldList[1]}; @@ -1511,9 +1511,9 @@ class ExtraFields foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); if ($translabel != $obj->$field_toshow) { - $labeltoshow = dol_trunc($translabel, 18) . ' '; + $labeltoshow = dol_trunc($translabel, 18).' '; } else { - $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' '; + $labeltoshow = dol_trunc($obj->$field_toshow, 18).' '; } } @@ -1535,7 +1535,7 @@ class ExtraFields } if (!empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName . ':' . $obj->{$parentField}; + $parent = $parentName.':'.$obj->{$parentField}; } $data[$obj->rowid] = $labeltoshow; @@ -1653,70 +1653,70 @@ class ExtraFields //$value=price($value); $sizeparts = explode(",", $size); $number_decimals = $sizeparts[1]; - $value=price($value, 0, $langs, 0, 0, $number_decimals, ''); + $value = price($value, 0, $langs, 0, 0, $number_decimals, ''); } } elseif ($type == 'boolean') { - $checked=''; + $checked = ''; if (!empty($value)) { - $checked=' checked '; + $checked = ' checked '; } - $value=''; + $value = ''; } elseif ($type == 'mail') { - $value=dol_print_email($value, 0, 0, 0, 64, 1, 1); + $value = dol_print_email($value, 0, 0, 0, 64, 1, 1); } elseif ($type == 'url') { - $value=dol_print_url($value, '_blank', 32, 1); + $value = dol_print_url($value, '_blank', 32, 1); } elseif ($type == 'phone') { - $value=dol_print_phone($value, '', 0, 0, '', ' ', 'phone'); + $value = dol_print_phone($value, '', 0, 0, '', ' ', 'phone'); } elseif ($type == 'price') { - $value=price($value, 0, $langs, 0, 0, -1, $conf->currency); + $value = price($value, 0, $langs, 0, 0, -1, $conf->currency); } elseif ($type == 'select') { - if ($langfile && $param['options'][$value]) $value=$langs->trans($param['options'][$value]); - else $value=$param['options'][$value]; + if ($langfile && $param['options'][$value]) $value = $langs->trans($param['options'][$value]); + else $value = $param['options'][$value]; } elseif ($type == 'sellist') { - $param_list=array_keys($param['options']); + $param_list = array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); - $selectkey="rowid"; - $keyList='rowid'; + $selectkey = "rowid"; + $keyList = 'rowid'; - if (count($InfoFieldList)>=3) + if (count($InfoFieldList) >= 3) { $selectkey = $InfoFieldList[2]; - $keyList=$InfoFieldList[2].' as rowid'; + $keyList = $InfoFieldList[2].' as rowid'; } $fields_label = explode('|', $InfoFieldList[1]); - if(is_array($fields_label)) { - $keyList .=', '; + if (is_array($fields_label)) { + $keyList .= ', '; $keyList .= implode(', ', $fields_label); } $sql = 'SELECT '.$keyList; - $sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0]; - if (strpos($InfoFieldList[4], 'extra')!==false) + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; + if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql.= ' as main'; + $sql .= ' as main'; } - if ($selectkey=='rowid' && empty($value)) { - $sql.= " WHERE ".$selectkey."=0"; - } elseif ($selectkey=='rowid') { - $sql.= " WHERE ".$selectkey."=".$this->db->escape($value); - }else { - $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; + if ($selectkey == 'rowid' && empty($value)) { + $sql .= " WHERE ".$selectkey."=0"; + } elseif ($selectkey == 'rowid') { + $sql .= " WHERE ".$selectkey."=".$this->db->escape($value); + } else { + $sql .= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; } //$sql.= ' AND entity = '.$conf->entity; @@ -1725,38 +1725,38 @@ class ExtraFields $resql = $this->db->query($sql); if ($resql) { - $value=''; // value was used, so now we reste it to use it to build final output + $value = ''; // value was used, so now we reste it to use it to build final output $obj = $this->db->fetch_object($resql); // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); - if(is_array($fields_label) && count($fields_label)>1) + if (is_array($fields_label) && count($fields_label) > 1) { foreach ($fields_label as $field_toshow) { - $translabel=''; + $translabel = ''; if (!empty($obj->$field_toshow)) { - $translabel=$langs->trans($obj->$field_toshow); + $translabel = $langs->trans($obj->$field_toshow); } - if ($translabel!=$field_toshow) { - $value.=dol_trunc($translabel, 18).' '; - }else { - $value.=$obj->$field_toshow.' '; + if ($translabel != $field_toshow) { + $value .= dol_trunc($translabel, 18).' '; + } else { + $value .= $obj->$field_toshow.' '; } } } else { - $translabel=''; + $translabel = ''; if (!empty($obj->{$InfoFieldList[1]})) { - $translabel=$langs->trans($obj->{$InfoFieldList[1]}); + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); } - if ($translabel!=$obj->{$InfoFieldList[1]}) { - $value=dol_trunc($translabel, 18); - }else { - $value=$obj->{$InfoFieldList[1]}; + if ($translabel != $obj->{$InfoFieldList[1]}) { + $value = dol_trunc($translabel, 18); + } else { + $value = $obj->{$InfoFieldList[1]}; } } } @@ -1764,20 +1764,20 @@ class ExtraFields } elseif ($type == 'radio') { - $value=$param['options'][$value]; + $value = $param['options'][$value]; } elseif ($type == 'checkbox') { - $value_arr=explode(',', $value); - $value=''; - $toprint=array(); + $value_arr = explode(',', $value); + $value = ''; + $toprint = array(); if (is_array($value_arr)) { foreach ($value_arr as $keyval=>$valueval) { - $toprint[]='
  • '.$param['options'][$valueval].'
  • '; + $toprint[] = '
  • '.$param['options'][$valueval].'
  • '; } } - $value='
      '.implode(' ', $toprint).'
    '; + $value = '
      '.implode(' ', $toprint).'
    '; } elseif ($type == 'chkbxlst') { @@ -1791,7 +1791,7 @@ class ExtraFields if (count($InfoFieldList) >= 3) { $selectkey = $InfoFieldList[2]; - $keyList = $InfoFieldList[2] . ' as rowid'; + $keyList = $InfoFieldList[2].' as rowid'; } $fields_label = explode('|', $InfoFieldList[1]); @@ -1820,53 +1820,53 @@ class ExtraFields if (is_array($fields_label) && count($fields_label) > 1) { foreach ($fields_label as $field_toshow) { $translabel = ''; - if (! empty($obj->$field_toshow)) { + if (!empty($obj->$field_toshow)) { $translabel = $langs->trans($obj->$field_toshow); } if ($translabel != $field_toshow) { - $toprint[]='
  • '.dol_trunc($translabel, 18).'
  • '; + $toprint[] = '
  • '.dol_trunc($translabel, 18).'
  • '; } else { - $toprint[]='
  • '.$obj->$field_toshow.'
  • '; + $toprint[] = '
  • '.$obj->$field_toshow.'
  • '; } } } else { $translabel = ''; - if (! empty($obj->{$InfoFieldList[1]})) { + if (!empty($obj->{$InfoFieldList[1]})) { $translabel = $langs->trans($obj->{$InfoFieldList[1]}); } if ($translabel != $obj->{$InfoFieldList[1]}) { - $toprint[]='
  • '.dol_trunc($translabel, 18).'
  • '; + $toprint[] = '
  • '.dol_trunc($translabel, 18).'
  • '; } else { - $toprint[]='
  • '.$obj->{$InfoFieldList[1]}.'
  • '; + $toprint[] = '
  • '.$obj->{$InfoFieldList[1]}.'
  • '; } } } } - $value='
      '.implode(' ', $toprint).'
    '; + $value = '
      '.implode(' ', $toprint).'
    '; } else { - dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); + dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); } } elseif ($type == 'link') { - $out=''; + $out = ''; // Only if something to display (perf) if ($value) // If we have -1 here, pb is into insert, not into ouptut (fix insert instead of changing code here to compensate) { - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' $InfoFieldList = explode(":", $param_list[0]); - $classname=$InfoFieldList[0]; - $classpath=$InfoFieldList[1]; - if (! empty($classpath)) + $classname = $InfoFieldList[0]; + $classpath = $InfoFieldList[1]; + if (!empty($classpath)) { dol_include_once($InfoFieldList[1]); if ($classname && class_exists($classname)) { $object = new $classname($this->db); $object->fetch($value); - $value=$object->getNomUrl(3); + $value = $object->getNomUrl(3); } } else @@ -1878,24 +1878,24 @@ class ExtraFields } elseif ($type == 'text') { - $value=dol_htmlentitiesbr($value); + $value = dol_htmlentitiesbr($value); } elseif ($type == 'html') { - $value=dol_htmlentitiesbr($value); + $value = dol_htmlentitiesbr($value); } elseif ($type == 'password') { - $value=dol_trunc(preg_replace('/./i', '*', $value), 8, 'right', 'UTF-8', 1); + $value = dol_trunc(preg_replace('/./i', '*', $value), 8, 'right', 'UTF-8', 1); } else { - $showsize=round($size); - if ($showsize > 48) $showsize=48; + $showsize = round($size); + if ($showsize > 48) $showsize = 48; } //print $type.'-'.$size; - $out=$value; + $out = $value; return $out; } @@ -1909,44 +1909,44 @@ class ExtraFields */ public function getAlignFlag($key, $extrafieldsobjectkey = '') { - global $conf,$langs; + global $conf, $langs; - if (! empty($extrafieldsobjectkey)) $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; - else $type=$this->attribute_type[$key]; + if (!empty($extrafieldsobjectkey)) $type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; + else $type = $this->attribute_type[$key]; - $align=''; + $align = ''; if ($type == 'date') { - $align="center"; + $align = "center"; } elseif ($type == 'datetime') { - $align="center"; + $align = "center"; } elseif ($type == 'int') { - $align="right"; + $align = "right"; } elseif ($type == 'double') { - $align="right"; + $align = "right"; } elseif ($type == 'boolean') { - $align="center"; + $align = "center"; } elseif ($type == 'radio') { - $align="center"; + $align = "center"; } elseif ($type == 'checkbox') { - $align="center"; + $align = "center"; } elseif ($type == 'price') { - $align="right"; + $align = "right"; } return $align; @@ -1964,8 +1964,8 @@ class ExtraFields global $langs; $out = ''; + $out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]); + $out .= ''; $extrafield_param = $this->attributes[$object->table_element]['param'][$key]; if (!empty($extrafield_param) && is_array($extrafield_param)) { @@ -1982,19 +1982,19 @@ class ExtraFields $out .= '\n"; } - if (! empty($conf->use_javascript_ajax) || $onlyselect) + if (!empty($conf->use_javascript_ajax) || $onlyselect) { //var_dump($selected); - if ($selected == 'done') $selected='100'; - print ''; + if ($showempty) print ''; + foreach ($listofstatus as $key => $val) { print ''; if ($key == '50' && $onlyselect == 2) @@ -140,17 +140,17 @@ class FormActions } } print ''; - if ($selected == 0 || $selected == 100) $canedit=0; + if ($selected == 0 || $selected == 100) $canedit = 0; if (empty($onlyselect)) { - print ' =0)?'':' disabled').'>'; + print ' = 0) ? '' : ' disabled').'>'; print '%'; } } else { - print ' %'; + print ' %'; } } @@ -170,79 +170,79 @@ class FormActions */ public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlright = '') { - global $langs,$conf,$user; + global $langs, $conf, $user; global $bc; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $sortfield='a.datep,a.id'; - $sortorder='DESC,DESC'; + $sortfield = 'a.datep,a.id'; + $sortorder = 'DESC,DESC'; - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); - if (! is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); + $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0)); + if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); $num = count($listofactions); if ($num || $forceshowtitle) { - if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); - elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); - elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); - elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); - elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); - elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); - elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); - elseif ($typeelement == 'member') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); - else $title=$langs->trans("LatestLinkedEvents", $max?$max:''); + if ($typeelement == 'invoice') $title = $langs->trans('ActionsOnBill'); + elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill'); + elseif ($typeelement == 'propal') $title = $langs->trans('ActionsOnPropal'); + elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal'); + elseif ($typeelement == 'order') $title = $langs->trans('ActionsOnOrder'); + elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title = $langs->trans('ActionsOnOrder'); + elseif ($typeelement == 'shipping') $title = $langs->trans('ActionsOnShipping'); + elseif ($typeelement == 'fichinter') $title = $langs->trans('ActionsOnFicheInter'); + elseif ($typeelement == 'project') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); + elseif ($typeelement == 'task') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); + elseif ($typeelement == 'member') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); + else $title = $langs->trans("LatestLinkedEvents", $max ? $max : ''); - $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); + $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : ''); $projectid = $object->fk_project; if ($typeelement == 'project') $projectid = $object->id; - $newcardbutton=''; - if (! empty($conf->agenda->enabled)) + $newcardbutton = ''; + if (!empty($conf->agenda->enabled)) { - $newcardbutton.= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid>0?'&socid='.$object->socid:($socid>0?'&socid='.$socid:'')).($projectid>0?'&projectid='.$projectid:'').'&backtopage='.urlencode($urlbacktopage)); + $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage)); } print ''."\n"; print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlright); - $page=0; $param=''; + $page = 0; $param = ''; print '
    '; - print '
    '.$langs->trans("LastCustomerOrders", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllOrders").' '.$num.''; print ''; //if($num2 > 0) print ''; //else print ''; @@ -795,7 +795,7 @@ if ($object->id > 0) $commande_static->id = $objp->cid; $commande_static->ref = $objp->ref; - $commande_static->ref_client=$objp->ref_client; + $commande_static->ref_client = $objp->ref_client; $commande_static->total_ht = $objp->total_ht; $commande_static->total_tva = $objp->total_tva; $commande_static->total_ttc = $objp->total_ttc; @@ -811,7 +811,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num >0) + if ($num > 0) { print "
    '.$langs->trans("LastCustomerOrders", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllOrders").' '.$num.''.img_picto($langs->trans("Statistics"), 'stats').''.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').''.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'
    "; print ''; @@ -826,24 +826,24 @@ if ($object->id > 0) /* * Last shipments */ - if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) + if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) { $sql = 'SELECT e.rowid as id'; - $sql.= ', e.ref'; - $sql.= ', e.date_creation'; - $sql.= ', e.fk_statut as statut'; - $sql.= ', s.nom'; - $sql.= ', s.rowid as socid'; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e"; - $sql.= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql.= " AND e.entity IN (".getEntity('expedition').")"; - $sql.= ' GROUP BY e.rowid'; - $sql.= ', e.ref'; - $sql.= ', e.date_creation'; - $sql.= ', e.fk_statut'; - $sql.= ', s.nom'; - $sql.= ', s.rowid'; - $sql.= " ORDER BY e.date_creation DESC"; + $sql .= ', e.ref'; + $sql .= ', e.date_creation'; + $sql .= ', e.fk_statut as statut'; + $sql .= ', s.nom'; + $sql .= ', s.rowid as socid'; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id; + $sql .= " AND e.entity IN (".getEntity('expedition').")"; + $sql .= ' GROUP BY e.rowid'; + $sql .= ', e.ref'; + $sql .= ', e.date_creation'; + $sql .= ', e.fk_statut'; + $sql .= ', s.nom'; + $sql .= ', s.rowid'; + $sql .= " ORDER BY e.date_creation DESC"; $resql = $db->query($sql); if ($resql) @@ -856,7 +856,7 @@ if ($object->id > 0) print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; // Multicurrency Amount VAT - print ''; - print ''; + print ''; + print ''; print ''; // Multicurrency Amount TTC - print ''; - print ''; + print ''; + print ''; print ''; } // Amount - print ''; - print ''; + print ''; + print ''; // Vat - print ''; + print ''; print ''; // Amount Local Taxes if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 { - print ''; - print ''; + print ''; + print ''; } if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 { - print ''; - print ''; + print ''; + print ''; } // Revenue stamp @@ -456,9 +456,9 @@ if ($object->id > 0) print '
    '; + print ''; print ''; @@ -880,7 +880,7 @@ if ($object->id > 0) print ''; } - print ''; + print ''; print "\n"; $i++; } @@ -899,28 +899,28 @@ if ($object->id > 0) /* * Last linked contracts */ - if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " WHERE c.fk_soc = s.rowid "; - $sql.= " AND s.rowid = ".$object->id; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " ORDER BY c.datec DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " WHERE c.fk_soc = s.rowid "; + $sql .= " AND s.rowid = ".$object->id; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $contrat=new Contrat($db); + $contrat = new Contrat($db); $num = $db->num_rows($resql); - if ($num >0) + if ($num > 0) { print '
    '; print '
    '.$langs->trans("LastSendings", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllSendings").' '.$num.''; print ''; print '
    '.$langs->trans("LastSendings", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllSendings").' '.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
    !!!' . $sendingstatic->LibStatut($objp->statut, 5) . ''.$sendingstatic->LibStatut($objp->statut, 5).'
    '; print ''; - print ''; print ''; print ''; - print ''; + print ''; // Label print ''; - print ''; + print ''; // Type print ''; print ''; // Currency @@ -854,9 +854,9 @@ else print ''; print ''; print ''; @@ -864,15 +864,15 @@ else // Status print ''; print ''; // Country - $object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; - $selectedcode=$object->country_code; - if (isset($_POST["account_country_id"])) $selectedcode=$_POST["account_country_id"]; - elseif (empty($selectedcode)) $selectedcode=$mysoc->country_code; - $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules + $object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id; + $selectedcode = $object->country_code; + if (isset($_POST["account_country_id"])) $selectedcode = $_POST["account_country_id"]; + elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; + $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules print ''; print ''; print ''; // Balance print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Web print ''; - print ''; // Tags-Categories @@ -935,13 +935,13 @@ else print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -973,7 +973,7 @@ else print ''; // Accountancy journal - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print ''; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 2244a73b02a..3a9db058c91 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -64,8 +64,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='b.label'; -if (! $sortorder) $sortorder='ASC'; +if (!$sortfield) $sortfield = 'b.label'; +if (!$sortorder) $sortorder = 'ASC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Account($db); @@ -82,14 +82,14 @@ $fieldstosearchall = array( 'b.label'=>'Label', ); -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1), 'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1), 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1), - 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(! empty($conf->accounting->enabled) || ! empty($conf->accounting->enabled))), - 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(! empty($conf->accounting->enabled) || ! empty($conf->accounting->enabled))), + 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), + 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1), 'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0), 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), @@ -114,11 +114,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -126,10 +126,10 @@ 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_ref=''; - $search_label=''; - $search_number=''; - $search_status=''; + $search_ref = ''; + $search_label = ''; + $search_number = ''; + $search_status = ''; } @@ -179,7 +179,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -198,41 +198,41 @@ else dol_print_error($db); -$help_url='EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas'; +$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas'; llxHeader('', $title, $help_url); -$link=''; +$link = ''; $num_rows = count($accounts); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($search_ref != '') $param.='&search_ref='.$search_ref; -if ($search_label != '') $param.='&search_label='.$search_label; -if ($search_number != '') $param.='&search_number='.$search_number; -if ($search_status != '') $param.='&search_status='.$search_status; -if ($show_files) $param.='&show_files=' .$show_files; -if ($optioncss != '') $param.='&optioncss='.$optioncss; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($search_ref != '') $param .= '&search_ref='.$search_ref; +if ($search_label != '') $param .= '&search_label='.$search_label; +if ($search_number != '') $param .= '&search_number='.$search_number; +if ($search_status != '') $param .= '&search_status='.$search_status; +if ($show_files) $param .= '&show_files='.$show_files; +if ($optioncss != '') $param .= '&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( // 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->banque->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->banque->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->banque->configurer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create'); } @@ -249,89 +249,89 @@ print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bank', 0, $newcardbutton, '', $limit, 1); -$topicmail="Information"; +$topicmail = "Information"; //$modelmail="subscription"; -$objecttmp=new Account($db); +$objecttmp = new Account($db); //$trackid='sub'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
    '.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
    '; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
    '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
    '; } -$moreforfilter=''; +$moreforfilter = ''; // Bank accounts -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
    '; print $moreforfilter; print '
    '; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '
    '; -print '
    '; + print ''; @@ -932,10 +932,10 @@ if ($object->id > 0) { $objp = $db->fetch_object($resql); - $contrat->id=$objp->id; - $contrat->ref=$objp->ref?$objp->ref:$objp->id; - $contrat->ref_customer=$objp->refcus; - $contrat->ref_supplier=$objp->refsup; + $contrat->id = $objp->id; + $contrat->ref = $objp->ref ? $objp->ref : $objp->id; + $contrat->ref_customer = $objp->refcus; + $contrat->ref_supplier = $objp->refsup; $contrat->fetch_lines(); print ''; @@ -969,19 +969,19 @@ if ($object->id > 0) /* * Last interventions */ - if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND s.rowid = ".$object->id; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " ORDER BY f.tms DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND s.rowid = ".$object->id; + $sql .= " AND f.entity = ".$conf->entity; + $sql .= " ORDER BY f.tms DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $fichinter_static=new Fichinter($db); + $fichinter_static = new Fichinter($db); $num = $db->num_rows($resql); if ($num > 0) @@ -990,7 +990,7 @@ if ($object->id > 0) print '
    '.$langs->trans("LastContracts", ($num<=$MAXLIST?"":$MAXLIST)).''; print ''; //print ''; print '
    '.$langs->trans("LastContracts", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllContracts").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
    '; print ''; - print ''; - print ''; + print ''; print ''; // Show fields of bank account @@ -500,32 +500,32 @@ if ($action == 'create') } print ''; - print ''; + print ''; print ''; } $ibankey = FormBank::getIBANLabel($object); - $bickey="BICNumber"; - if ($object->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($object->getCountryCode() == 'IN') $bickey = "SWIFT"; // IBAN print ''; - print ''; + print ''; print ''; - print ''; + print ''; print '"; print ''; - print ''; print '"; print '
    '; + print ''; print ''; @@ -1001,8 +1001,8 @@ if ($object->id > 0) { $objp = $db->fetch_object($resql); - $fichinter_static->id=$objp->id; - $fichinter_static->statut=$objp->fk_statut; + $fichinter_static->id = $objp->id; + $fichinter_static->statut = $objp->fk_statut; print ''; print ''."\n"; @@ -1030,28 +1030,28 @@ if ($object->id > 0) /* * Last invoices templates */ - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $sql = 'SELECT f.rowid as id, f.titre as ref, f.amount'; - $sql.= ', f.total as total_ht'; - $sql.= ', f.tva as total_tva'; - $sql.= ', f.total_ttc'; - $sql.= ', f.datec as dc'; - $sql.= ', f.date_last_gen, f.date_when'; - $sql.= ', f.frequency'; - $sql.= ', f.unit_frequency'; - $sql.= ', f.suspended as suspended'; - $sql.= ', s.nom, s.rowid as socid'; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; - $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= ' GROUP BY f.rowid, f.titre, f.amount, f.total, f.tva, f.total_ttc,'; - $sql.= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,'; - $sql.= ' f.suspended,'; - $sql.= ' s.nom, s.rowid'; - $sql.= " ORDER BY f.date_last_gen, f.datec DESC"; + $sql .= ', f.total as total_ht'; + $sql .= ', f.tva as total_tva'; + $sql .= ', f.total_ttc'; + $sql .= ', f.datec as dc'; + $sql .= ', f.date_last_gen, f.date_when'; + $sql .= ', f.frequency'; + $sql .= ', f.unit_frequency'; + $sql .= ', f.suspended as suspended'; + $sql .= ', s.nom, s.rowid as socid'; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; + $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; + $sql .= " AND f.entity = ".$conf->entity; + $sql .= ' GROUP BY f.rowid, f.titre, f.amount, f.total, f.tva, f.total_ttc,'; + $sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,'; + $sql .= ' f.suspended,'; + $sql .= ' s.nom, s.rowid'; + $sql .= " ORDER BY f.date_last_gen, f.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $invoicetemplate = new FactureRec($db); @@ -1063,7 +1063,7 @@ if ($object->id > 0) print '
    '.$langs->trans("LastInterventions", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllInterventions").' '.$num.''; print ''; print '
    '.$langs->trans("LastInterventions", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllInterventions").' '.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
    '.img_object($langs->trans("ShowPropal"), "propal").' '.$objp->ref.'
    '; print ''; - print ''; @@ -707,7 +707,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) // Checkbox print '' ; + print ''; print ''; @@ -719,7 +719,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; // Buttons actions - print '
    global->INVOICE_CLOSE_ORDERS_OFF_BY_DEFAULT_FORMASSINVOICE)?' checked="checked"':'').' name="autocloseorders"> '.$langs->trans("CloseProcessedOrdersAutomatically"); + print '
    global->INVOICE_CLOSE_ORDERS_OFF_BY_DEFAULT_FORMASSINVOICE) ? ' checked="checked"' : '').' name="autocloseorders"> '.$langs->trans("CloseProcessedOrdersAutomatically"); print '
    '; print ''; print ''; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 980cf6bd8f2..23f92c773f4 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -29,19 +29,19 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","bills","categories","companies","compta")); +$langs->loadLangs(array("banks", "bills", "categories", "companies", "compta")); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); @@ -59,17 +59,17 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('bankcard','globalcard')); +$hookmanager->initHooks(array('bankcard', 'globalcard')); /* * Actions */ -if ($cancel) $action=''; +if ($cancel) $action = ''; if ($action == 'add') { - $error=0; + $error = 0; $db->begin(); @@ -124,26 +124,26 @@ if ($action == 'add') if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation $error++; } if (empty($object->ref)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation $error++; } if (empty($object->label)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation $error++; } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if (! $error) + if (!$error) { $id = $object->create($user); if ($id > 0) @@ -152,19 +152,19 @@ if ($action == 'add') $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - $_GET["id"]=$id; // Force chargement page en mode visu + $_GET["id"] = $id; // Force chargement page en mode visu - $action=''; + $action = ''; } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation } } - if (! $error) + if (!$error) { $db->commit(); } @@ -176,7 +176,7 @@ if ($action == 'add') if ($action == 'update') { - $error=0; + $error = 0; // Update account $object = new Account($db); @@ -225,31 +225,31 @@ if ($action == 'update') if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); - $action='edit'; // Force chargement page en mode creation + $action = 'edit'; // Force chargement page en mode creation $error++; } if (empty($object->ref)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); - $action='edit'; // Force chargement page en mode creation + $action = 'edit'; // Force chargement page en mode creation $error++; } if (empty($object->label)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors'); - $action='edit'; // Force chargement page en mode creation + $action = 'edit'; // Force chargement page en mode creation $error++; } $db->begin(); - if (! $error) + if (!$error) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); } - if (! $error) + if (!$error) { $result = $object->update($user); if ($result >= 0) @@ -258,17 +258,17 @@ if ($action == 'update') $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu + $_GET["id"] = $_POST["id"]; // Force chargement page en mode visu } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); - $action='edit'; // Force chargement page edition + $action = 'edit'; // Force chargement page edition } } - if (! $error) + if (!$error) { $db->commit(); } @@ -306,11 +306,11 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights-> $form = new Form($db); $formbank = new FormBank($db); $formcompany = new FormCompany($db); -if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); -$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; -$title = $langs->trans("FinancialAccount") . " - " . $langs->trans("Card"); +$title = $langs->trans("FinancialAccount")." - ".$langs->trans("Card"); $helpurl = ""; llxHeader("", $title, $helpurl); @@ -319,7 +319,7 @@ llxHeader("", $title, $helpurl); if ($action == 'create') { - $object=new Account($db); + $object = new Account($db); print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'title_bank.png'); @@ -350,7 +350,7 @@ if ($action == 'create') // Ref print '
    '; - print ''; + print ''; // Label print ''; @@ -359,15 +359,15 @@ if ($action == 'create') // Type print ''; print ''; // Currency print ''; print ''; @@ -375,17 +375,17 @@ if ($action == 'create') // Status print ''; print ''; // Country - $selectedcode=''; + $selectedcode = ''; if (isset($_POST["account_country_id"])) { - $selectedcode=$_POST["account_country_id"]?$_POST["account_country_id"]:$object->country_code; + $selectedcode = $_POST["account_country_id"] ? $_POST["account_country_id"] : $object->country_code; } - elseif (empty($selectedcode)) $selectedcode=$mysoc->country_code; - $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules + elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; + $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules print ''; print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -454,7 +454,7 @@ if ($action == 'create') // Sold print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print '
    '; + print ''; print ''; } @@ -1107,7 +1107,7 @@ if ($object->id > 0) print price($objp->total_ht); print ''; - if (! empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) + if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) { print ''; // Payment term print ''; // Payment mode print ''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { - $formproject=new FormProjets($db); + $formproject = new FormProjets($db); $langs->load('projects'); print ''; print '"; @@ -550,36 +550,36 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ' WHERE c.entity IN ('.getEntity('commande').')'; - $sql.= ' AND c.fk_soc = s.rowid'; + $sql .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; + $sql .= ', '.MAIN_DB_PREFIX.'commande as c'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ' WHERE c.entity IN ('.getEntity('commande').')'; + $sql .= ' AND c.fk_soc = s.rowid'; // Show orders with status validated, shipping started and delivered (well any order we can bill) - $sql.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; + $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; - if ($socid) $sql.= ' AND s.rowid = '.$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql .= ' AND s.rowid = '.$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($sref) { - $sql.= " AND c.ref LIKE '%".$db->escape($sref)."%'"; + $sql .= " AND c.ref LIKE '%".$db->escape($sref)."%'"; } if ($sall) { - $sql.= " AND (c.ref LIKE '%".$db->escape($sall)."%' OR c.note LIKE '%".$db->escape($sall)."%')"; + $sql .= " AND (c.ref LIKE '%".$db->escape($sall)."%' OR c.note LIKE '%".$db->escape($sall)."%')"; } //Date filter - if ($date_start && $date_end) $sql.= " AND c.date_commande >= '".$db->idate($date_start)."' AND c.date_commande <= '".$db->idate($date_end)."'"; - if ($date_starty && $date_endy) $sql.= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'"; + if ($date_start && $date_end) $sql .= " AND c.date_commande >= '".$db->idate($date_start)."' AND c.date_commande <= '".$db->idate($date_end)."'"; + if ($date_starty && $date_endy) $sql .= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'"; if (!empty($sref_client)) { - $sql.= ' AND c.ref_client LIKE \'%'.$db->escape($sref_client).'%\''; + $sql .= ' AND c.ref_client LIKE \'%'.$db->escape($sref_client).'%\''; } - $sql.= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); $resql = $db->query($sql); if ($resql) @@ -590,18 +590,18 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) $soc->fetch($socid); } $title = $langs->trans('ListOfOrders'); - $title.=' - '.$langs->trans('StatusOrderValidated').', '.$langs->trans("StatusOrderSent").', '.$langs->trans('StatusOrderToBill'); + $title .= ' - '.$langs->trans('StatusOrderValidated').', '.$langs->trans("StatusOrderSent").', '.$langs->trans('StatusOrderToBill'); $num = $db->num_rows($resql); print load_fiche_titre($title); $i = 0; - $period=$html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); - $periodely=$html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); + $period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); + $periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); - if (! empty($socid)) + if (!empty($socid)) { // Company - $companystatic->id=$socid; - $companystatic->name=$soc->name; + $companystatic->id = $socid; + $companystatic->name = $soc->name; print '

    '.$companystatic->getNomUrl(1, 'customer').'

    '; } @@ -664,8 +664,8 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; print ''; print '
    '.$langs->trans("LatestCustomerTemplateInvoices", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllCustomerTemplateInvoices").' '.$num.''; print '
    '.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllCustomerTemplateInvoices").' '.$num.'
    '; print price($objp->total_ttc); @@ -1138,25 +1138,25 @@ if ($object->id > 0) /* * Last invoices */ - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $sql = 'SELECT f.rowid as facid, f.ref, f.type, f.amount'; - $sql.= ', f.total as total_ht'; - $sql.= ', f.tva as total_tva'; - $sql.= ', f.total_ttc'; - $sql.= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut'; - $sql.= ', s.nom, s.rowid as socid'; - $sql.= ', SUM(pf.amount) as am'; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture'; - $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= ' GROUP BY f.rowid, f.ref, f.type, f.amount, f.total, f.tva, f.total_ttc,'; - $sql.= ' f.datef, f.datec, f.paye, f.fk_statut,'; - $sql.= ' s.nom, s.rowid'; - $sql.= " ORDER BY f.datef DESC, f.datec DESC"; + $sql .= ', f.total as total_ht'; + $sql .= ', f.tva as total_tva'; + $sql .= ', f.total_ttc'; + $sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut'; + $sql .= ', s.nom, s.rowid as socid'; + $sql .= ', SUM(pf.amount) as am'; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture'; + $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.amount, f.total, f.tva, f.total_ttc,'; + $sql .= ' f.datef, f.datec, f.paye, f.fk_statut,'; + $sql .= ' s.nom, s.rowid'; + $sql .= " ORDER BY f.datef DESC, f.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $facturestatic = new Facture($db); @@ -1168,7 +1168,7 @@ if ($object->id > 0) print ''; print ''; - print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1260,11 +1260,11 @@ else print ''; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
    '; - foreach($object->substitutionarray as $key => $val) + foreach ($object->substitutionarray as $key => $val) { - $htmltext.=$key.' = '.$langs->trans($val).'
    '; + $htmltext .= $key.' = '.$langs->trans($val).'
    '; } - $htmltext.='
    '; + $htmltext .= ''; // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'generic'); @@ -1276,43 +1276,43 @@ else // Subject print ''; - $trackid=''; // TODO To avoid conflicts with 2 mass emailing, we should set a trackid here, even if we use another one into email header. + $trackid = ''; // TODO To avoid conflicts with 2 mass emailing, we should set a trackid here, even if we use another one into email header. dol_init_file_process($upload_dir, $trackid); // Joined files - $addfileaction='addfile'; + $addfileaction = 'addfile'; print ''; print ''; @@ -1330,14 +1330,14 @@ else { // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); $doleditor->Create(); } if ($action == 'edithtml') { // Editor HTML source require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, 'ace', 20, '90%'); + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, 'ace', 20, '90%'); $doleditor->Create(0, '', false, 'HTML Source', 'php'); } diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 465bf7dcc50..0b47d8c4aa5 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -36,7 +36,7 @@ class AdvanceTargetingMailing extends CommonObject /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -46,12 +46,12 @@ class AdvanceTargetingMailing extends CommonObject /** * @var string ID to identify managed object */ - public $element='advtargetemailing'; + public $element = 'advtargetemailing'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='advtargetemailing'; + public $table_element = 'advtargetemailing'; /** * @var int ID @@ -64,12 +64,12 @@ class AdvanceTargetingMailing extends CommonObject public $type_element; public $filtervalue; public $fk_user_author; - public $datec=''; + public $datec = ''; public $fk_user_mod; - public $tms=''; + public $tms = ''; public $select_target_type = array(); - public $type_statuscommprospect=array(); + public $type_statuscommprospect = array(); public $thirdparty_lines; public $contact_lines; @@ -88,12 +88,12 @@ class AdvanceTargetingMailing extends CommonObject $this->select_target_type = array( '2' => $langs->trans('Contacts'), - '1' => $langs->trans('Contacts') . '+' . $langs->trans('ThirdParty'), + '1' => $langs->trans('Contacts').'+'.$langs->trans('ThirdParty'), '3' => $langs->trans('ThirdParty'), '4' => $langs->trans('ContactsWithThirdpartyFilter') ); $this->type_statuscommprospect = array( - - 1 => $langs->trans("StatusProspect-1"), + -1 => $langs->trans("StatusProspect-1"), 0 => $langs->trans("StatusProspect0"), 1 => $langs->trans("StatusProspect1"), 2 => $langs->trans("StatusProspect2"), @@ -111,50 +111,50 @@ class AdvanceTargetingMailing extends CommonObject public function create($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->fk_element)) $this->fk_element=(int) $this->fk_element; - if (isset($this->type_element)) $this->type_element=trim($this->type_element); + if (isset($this->fk_element)) $this->fk_element = (int) $this->fk_element; + if (isset($this->type_element)) $this->type_element = trim($this->type_element); - if (isset($this->name)) $this->name=trim($this->name); - if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); + if (isset($this->name)) $this->name = trim($this->name); + if (isset($this->filtervalue)) $this->filtervalue = trim($this->filtervalue); // Check parameters // Put here code to add control on parameters values // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."advtargetemailing("; - $sql.= "name,"; - $sql.= "entity,"; - $sql.= "fk_element,"; - $sql.= "type_element,"; - $sql.= "filtervalue,"; - $sql.= "fk_user_author,"; - $sql.= "datec,"; - $sql.= "fk_user_mod"; - $sql.= ") VALUES ("; - $sql.= " ".(! isset($this->name)?'NULL':"'".$this->db->escape($this->name)."'").","; - $sql.= " ".$conf->entity.","; - $sql.= " ".(! isset($this->fk_element)?'NULL':"'".$this->db->escape($this->fk_element)."'").","; - $sql.= " ".(! isset($this->type_element)?'NULL':"'".$this->db->escape($this->type_element)."'").","; - $sql.= " ".(! isset($this->filtervalue)?'NULL':"'".$this->db->escape($this->filtervalue)."'").","; - $sql.= " ".$user->id.","; - $sql.= " '".$this->db->idate(dol_now())."',"; - $sql.= " null"; - $sql.= ")"; + $sql .= "name,"; + $sql .= "entity,"; + $sql .= "fk_element,"; + $sql .= "type_element,"; + $sql .= "filtervalue,"; + $sql .= "fk_user_author,"; + $sql .= "datec,"; + $sql .= "fk_user_mod"; + $sql .= ") VALUES ("; + $sql .= " ".(!isset($this->name) ? 'NULL' : "'".$this->db->escape($this->name)."'").","; + $sql .= " ".$conf->entity.","; + $sql .= " ".(!isset($this->fk_element) ? 'NULL' : "'".$this->db->escape($this->fk_element)."'").","; + $sql .= " ".(!isset($this->type_element) ? 'NULL' : "'".$this->db->escape($this->type_element)."'").","; + $sql .= " ".(!isset($this->filtervalue) ? 'NULL' : "'".$this->db->escape($this->filtervalue)."'").","; + $sql .= " ".$user->id.","; + $sql .= " '".$this->db->idate(dol_now())."',"; + $sql .= " null"; + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."advtargetemailing"); - if (! $notrigger) + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -171,13 +171,13 @@ class AdvanceTargetingMailing extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -196,30 +196,30 @@ class AdvanceTargetingMailing extends CommonObject { global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; + $sql .= " t.rowid,"; - $sql.= " t.name,"; - $sql.= " t.entity,"; - $sql.= " t.fk_element,"; - $sql.= " t.type_element,"; - $sql.= " t.filtervalue,"; - $sql.= " t.fk_user_author,"; - $sql.= " t.datec,"; - $sql.= " t.fk_user_mod,"; - $sql.= " t.tms"; + $sql .= " t.name,"; + $sql .= " t.entity,"; + $sql .= " t.fk_element,"; + $sql .= " t.type_element,"; + $sql .= " t.filtervalue,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.datec,"; + $sql .= " t.fk_user_mod,"; + $sql .= " t.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->name = $obj->name; $this->entity = $obj->entity; @@ -237,7 +237,7 @@ class AdvanceTargetingMailing extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; } @@ -255,34 +255,34 @@ class AdvanceTargetingMailing extends CommonObject // phpcs:enable global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; + $sql .= " t.rowid,"; - $sql.= " t.name,"; - $sql.= " t.entity,"; - $sql.= " t.fk_element,"; - $sql.= " t.type_element,"; - $sql.= " t.filtervalue,"; - $sql.= " t.fk_user_author,"; - $sql.= " t.datec,"; - $sql.= " t.fk_user_mod,"; - $sql.= " t.tms"; + $sql .= " t.name,"; + $sql .= " t.entity,"; + $sql .= " t.fk_element,"; + $sql .= " t.type_element,"; + $sql .= " t.filtervalue,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.datec,"; + $sql .= " t.fk_user_mod,"; + $sql .= " t.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; if (!empty($id)) { - $sql.= " WHERE t.fk_element = ".$id." AND type_element='mailing'"; - }else { - $sql.= " WHERE t.fk_element = ".$this->fk_element." AND type_element='mailing'"; + $sql .= " WHERE t.fk_element = ".$id." AND type_element='mailing'"; + } else { + $sql .= " WHERE t.fk_element = ".$this->fk_element." AND type_element='mailing'"; } dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->name = $obj->name; $this->entity = $obj->entity; @@ -300,7 +300,7 @@ class AdvanceTargetingMailing extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; } @@ -322,34 +322,34 @@ class AdvanceTargetingMailing extends CommonObject // phpcs:enable global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; + $sql .= " t.rowid,"; - $sql.= " t.name,"; - $sql.= " t.entity,"; - $sql.= " t.fk_element,"; - $sql.= " t.type_element,"; - $sql.= " t.filtervalue,"; - $sql.= " t.fk_user_author,"; - $sql.= " t.datec,"; - $sql.= " t.fk_user_mod,"; - $sql.= " t.tms"; + $sql .= " t.name,"; + $sql .= " t.entity,"; + $sql .= " t.fk_element,"; + $sql .= " t.type_element,"; + $sql .= " t.filtervalue,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.datec,"; + $sql .= " t.fk_user_mod,"; + $sql .= " t.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; if (!empty($id)) { - $sql.= " WHERE t.fk_element = ".$id." AND type_element='$type_element'"; - }else { - $sql.= " WHERE t.fk_element = ".$this->fk_element." AND type_element='$type_element'"; + $sql .= " WHERE t.fk_element = ".$id." AND type_element='$type_element'"; + } else { + $sql .= " WHERE t.fk_element = ".$this->fk_element." AND type_element='$type_element'"; } dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->name = $obj->name; $this->entity = $obj->entity; @@ -367,7 +367,7 @@ class AdvanceTargetingMailing extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; } @@ -383,13 +383,13 @@ class AdvanceTargetingMailing extends CommonObject public function update($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->fk_element)) $this->fk_element=(int) $this->fk_element; - if (isset($this->type_element)) $this->type_element=trim($this->type_element); - if (isset($this->name)) $this->name=trim($this->name); - if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); + if (isset($this->fk_element)) $this->fk_element = (int) $this->fk_element; + if (isset($this->type_element)) $this->type_element = trim($this->type_element); + if (isset($this->name)) $this->name = trim($this->name); + if (isset($this->filtervalue)) $this->filtervalue = trim($this->filtervalue); // Check parameters // Put here code to add a control on parameters values @@ -397,21 +397,21 @@ class AdvanceTargetingMailing extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."advtargetemailing SET"; - $sql.= " name=".(isset($this->name)?"'".$this->db->escape($this->name)."'":"''").","; - $sql.= " entity=".$conf->entity.","; - $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; - $sql.= " type_element=".(isset($this->type_element)?"'".$this->db->escape($this->type_element)."'":"null").","; - $sql.= " filtervalue=".(isset($this->filtervalue)?"'".$this->db->escape($this->filtervalue)."'":"null").","; - $sql.= " fk_user_mod=".$user->id; + $sql .= " name=".(isset($this->name) ? "'".$this->db->escape($this->name)."'" : "''").","; + $sql .= " entity=".$conf->entity.","; + $sql .= " fk_element=".(isset($this->fk_element) ? $this->fk_element : "null").","; + $sql .= " type_element=".(isset($this->type_element) ? "'".$this->db->escape($this->type_element)."'" : "null").","; + $sql .= " filtervalue=".(isset($this->filtervalue) ? "'".$this->db->escape($this->filtervalue)."'" : "null").","; + $sql .= " fk_user_mod=".$user->id; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; - $this->errors[]="Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); } //if (! $error) @@ -433,13 +433,13 @@ class AdvanceTargetingMailing extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -458,13 +458,13 @@ class AdvanceTargetingMailing extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; $this->db->begin(); - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -478,26 +478,26 @@ class AdvanceTargetingMailing extends CommonObject } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."advtargetemailing"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete sql=".$sql); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -516,17 +516,17 @@ class AdvanceTargetingMailing extends CommonObject */ public function savequery($user, $arrayquery) { - global $langs,$conf; + global $langs, $conf; if (!empty($arrayquery)) { - $result=$this->fetch_by_mailing($this->fk_element); - $this->filtervalue=json_encode($arrayquery); - if ($result<0) { + $result = $this->fetch_by_mailing($this->fk_element); + $this->filtervalue = json_encode($arrayquery); + if ($result < 0) { return -1; } if (!empty($this->id)) { $this->update($user); - }else { + } else { $this->create($user); } } @@ -662,7 +662,7 @@ class AdvanceTargetingMailing extends CommonObject if ($num) { - while( $i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -675,8 +675,8 @@ class AdvanceTargetingMailing extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::query_thirdparty " . $this->error, LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::query_thirdparty ".$this->error, LOG_ERR); return -1; } } @@ -905,7 +905,7 @@ class AdvanceTargetingMailing extends CommonObject if ($num) { - while( $i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -918,8 +918,8 @@ class AdvanceTargetingMailing extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::query_contact " . $this->error, LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::query_contact ".$this->error, LOG_ERR); return -1; } } @@ -940,26 +940,26 @@ class AdvanceTargetingMailing extends CommonObject //This is a multiple value test if (preg_match('/;/', $criteria)) { - $return_sql_not_like=array(); - $return_sql_like=array(); + $return_sql_not_like = array(); + $return_sql_like = array(); - $criteria_array=explode(';', $criteria); - foreach($criteria_array as $inter_criteria) { + $criteria_array = explode(';', $criteria); + foreach ($criteria_array as $inter_criteria) { if (preg_match('/!/', $inter_criteria)) { - $return_sql_not_like[]= '('.$column_to_test.' NOT LIKE \''.str_replace('!', '', $inter_criteria).'\')'; + $return_sql_not_like[] = '('.$column_to_test.' NOT LIKE \''.str_replace('!', '', $inter_criteria).'\')'; } else { - $return_sql_like[]= '('.$column_to_test.' LIKE \''.$inter_criteria.'\')'; + $return_sql_like[] = '('.$column_to_test.' LIKE \''.$inter_criteria.'\')'; } } - if (count($return_sql_like)>0) { - $return_sql_criteria .= '(' . implode(' OR ', $return_sql_like) .')'; + if (count($return_sql_like) > 0) { + $return_sql_criteria .= '('.implode(' OR ', $return_sql_like).')'; } - if (count($return_sql_not_like)>0) { - $return_sql_criteria .= ' AND (' . implode(' AND ', $return_sql_not_like).')'; + if (count($return_sql_not_like) > 0) { + $return_sql_criteria .= ' AND ('.implode(' AND ', $return_sql_not_like).')'; } } else { - $return_sql_criteria .= $column_to_test . ' LIKE \''.$this->db->escape($criteria).'\''; + $return_sql_criteria .= $column_to_test.' LIKE \''.$this->db->escape($criteria).'\''; } $return_sql_criteria .= ')'; diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 0e3d7a7725e..b38a796d3c7 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -29,22 +29,22 @@ require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; $langs->load("mails"); // Security check -$result=restrictedArea($user, 'mailing'); +$result = restrictedArea($user, 'mailing'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $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 (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="m.date_creat"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "m.date_creat"; -$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref=GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha"); -$filteremail=GETPOST('filteremail', 'alpha'); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha"); +$filteremail = GETPOST('filteremail', 'alpha'); $object = new Mailing($db); @@ -55,7 +55,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -69,11 +69,11 @@ $fieldstosearchall = array( * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -82,7 +82,7 @@ if (empty($reshook)) 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 + 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 { /*foreach($object->fields as $key => $val) { @@ -90,13 +90,13 @@ if (empty($reshook)) }*/ $search_ref = ''; $search_all = ''; - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions @@ -121,28 +121,28 @@ $form = new Form($db); if ($filteremail) { $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,"; - $sql.= " mc.statut as sendstatut"; - $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql.= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity; - $sql.= " AND mc.email = '".$db->escape($filteremail)."'"; - if ($search_ref) $sql.= " AND m.rowid = '".$db->escape($search_ref)."'"; - if ($search_all) $sql.= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="m.rowid"; - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($conf->liste_limit +1, $offset); + $sql .= " mc.statut as sendstatut"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity; + $sql .= " AND mc.email = '".$db->escape($filteremail)."'"; + if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; + if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "m.rowid"; + $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($conf->liste_limit + 1, $offset); } else { $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi"; - $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; - $sql.= " WHERE m.entity = ".$conf->entity; - if ($search_ref) $sql.= " AND m.rowid = '".$db->escape($search_ref)."'"; - if ($search_all) $sql.= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="m.rowid"; - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($conf->liste_limit +1, $offset); + $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; + $sql .= " WHERE m.entity = ".$conf->entity; + if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; + if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "m.rowid"; + $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($conf->liste_limit + 1, $offset); } //print $sql; @@ -151,19 +151,19 @@ if ($result) { $num = $db->num_rows($result); - $title=$langs->trans("ListOfEMailings"); - if ($filteremail) $title.=' ('.$langs->trans("SentTo", $filteremail).')'; + $title = $langs->trans("ListOfEMailings"); + if ($filteremail) $title .= ' ('.$langs->trans("SentTo", $filteremail).')'; - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->mailing->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); } $i = 0; $param = "&search_all=".urlencode($search_all); - if ($filteremail) $param.='&filteremail='.urlencode($filteremail); + if ($filteremail) $param .= '&filteremail='.urlencode($filteremail); print ''; if ($optioncss != '') print ''; @@ -178,7 +178,7 @@ if ($result) $moreforfilter = ''; print '
    '; - print '
    '; + print ''; print ''; @@ -1202,7 +1202,7 @@ if ($object->id > 0) print price($objp->total_ht); print ''; - if (! empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) + if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) { print '
    '.$langs->trans("LastCustomersBills", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllBills").' '.$num.''; print ''; print '
    '.$langs->trans("LastCustomersBills", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllBills").' '.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
    '; print price($objp->total_ttc); @@ -1249,25 +1249,25 @@ if ($object->id > 0) print ''; } - if (! empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status==1) + if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1) { $langs->load("propal"); print ''; } - if (! empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status==1) + if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1) { $langs->load("orders"); print ''; } - if ($user->rights->contrat->creer && $object->status==1) + if ($user->rights->contrat->creer && $object->status == 1) { $langs->load("contracts"); print ''; } - if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status==1) + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1) { $langs->load("fichinter"); print ''; @@ -1276,13 +1276,13 @@ if ($object->id > 0) // Add invoice if ($user->socid == 0) { - if (! empty($conf->deplacement->enabled) && $object->status==1) + if (!empty($conf->deplacement->enabled) && $object->status == 1) { $langs->load("trips"); print ''; } - if (! empty($conf->facture->enabled) && $object->status==1) + if (!empty($conf->facture->enabled) && $object->status == 1) { if (empty($user->rights->facture->creer)) { @@ -1310,7 +1310,7 @@ if ($object->id > 0) } // Add action - if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status==1) + if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) { if ($user->rights->agenda->myactions->create) { @@ -1325,13 +1325,13 @@ if ($object->id > 0) print ''; - if (! empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) + if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) { // List of contacts show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); } - if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) + if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) { print load_fiche_titre($langs->trans("ActionsOnCompany"), '', ''); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index f4a0e61095f..a2d8c0a373b 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -23,7 +23,7 @@ * \brief Fiche mailing, onglet general */ -if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); +if (!defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php'; @@ -54,26 +54,26 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('mailingcard','globalcard')); +$hookmanager->initHooks(array('mailingcard', 'globalcard')); // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) -$object->substitutionarray=FormMail::getAvailableSubstitKey('emailing'); +$object->substitutionarray = FormMail::getAvailableSubstitKey('emailing'); // Set $object->substitutionarrayfortest -$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); +$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); -$targetobject = null; // Not defined with mass emailing +$targetobject = null; // Not defined with mass emailing -$parameters=array('mode'=>'emailing'); -$substitutionarray=FormMail::getAvailableSubstitKey('emailing', $targetobject); +$parameters = array('mode'=>'emailing'); +$substitutionarray = FormMail::getAvailableSubstitKey('emailing', $targetobject); $object->substitutionarrayfortest = $substitutionarray; // List of sending methods -$listofmethods=array(); -$listofmethods['mail']='PHP mail function'; -$listofmethods['smtps']='SMTP/SMTPS socket library'; +$listofmethods = array(); +$listofmethods['mail'] = 'PHP mail function'; +$listofmethods['smtps'] = 'SMTP/SMTPS socket library'; @@ -81,8 +81,8 @@ $listofmethods['smtps']='SMTP/SMTPS socket library'; * Actions */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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)) @@ -96,7 +96,7 @@ if (empty($reshook)) } else { - $result=$object->createFromClone($user, $object->id, $_REQUEST["clone_content"], $_REQUEST["clone_receivers"]); + $result = $object->createFromClone($user, $object->id, $_REQUEST["clone_content"], $_REQUEST["clone_receivers"]); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -107,7 +107,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - $action=''; + $action = ''; } // Action send emailing for everybody @@ -119,16 +119,16 @@ if (empty($reshook)) setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); setEventMessages('', null, 'warnings'); setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); - $action=''; + $action = ''; } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings'); - $action=''; + $action = ''; } else { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); if ($object->statut == 0) { @@ -143,37 +143,37 @@ if (empty($reshook)) $replyto = $object->email_replyto; $errorsto = $object->email_errorsto; // Le message est-il en html - $msgishtml=-1; // Unknown by default - if (preg_match('/[\s\t]*/i', $message)) $msgishtml=1; + $msgishtml = -1; // Unknown by default + if (preg_match('/[\s\t]*/i', $message)) $msgishtml = 1; // Warning, we must not use begin-commit transaction here // because we want to save update for each mail sent. - $nbok=0; $nbko=0; + $nbok = 0; $nbko = 0; // On choisit les mails non deja envoyes pour ce mailing (statut=0) // ou envoyes en erreur (statut=-1) $sql = "SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id; - $sql .= " ORDER BY mc.statut DESC"; // first status 0, then status -1 + $sql .= " ORDER BY mc.statut DESC"; // first status 0, then status -1 dol_syslog("card.php: select targets", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); // nb of possible recipients + $num = $db->num_rows($resql); // nb of possible recipients if ($num) { dol_syslog("comm/mailing/card.php: nb of targets = ".$num, LOG_DEBUG); - $now=dol_now(); + $now = dol_now(); // Positionne date debut envoi - $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$object->id; - $resql2=$db->query($sql); - if (! $resql2) + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$object->id; + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -184,8 +184,8 @@ if (empty($reshook)) while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) { // Here code is common with same loop ino mailing-send.php - $res=1; - $now=dol_now(); + $res = 1; + $now = dol_now(); $obj = $db->fetch_object($resql); @@ -193,18 +193,18 @@ if (empty($reshook)) $sendto = str_replace(',', ' ', dolGetFirstLastname($obj->firstname, $obj->lastname))." <".$obj->email.">"; // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... - $other=explode(';', $obj->other); - $tmpfield=explode('=', $other[0], 2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=', $other[1], 2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=', $other[2], 2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=', $other[3], 2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=', $other[4], 2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $other = explode(';', $obj->other); + $tmpfield = explode('=', $other[0], 2); $other1 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); - $targetobject = null; // Not defined with mass emailing - $parameters=array('mode'=>'emailing'); - $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object + $targetobject = null; // Not defined with mass emailing + $parameters = array('mode'=>'emailing'); + $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; @@ -217,79 +217,79 @@ if (empty($reshook)) $substitutionarray['__OTHER3__'] = $other3; $substitutionarray['__OTHER4__'] = $other4; $substitutionarray['__OTHER5__'] = $other5; - $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) - $substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility + $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) + $substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility $substitutionarray['__CHECK_READ__'] = ''; $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; $onlinepaymentenabled = 0; - if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; - if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++; - if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++; - if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++; + if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++; + if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++; + if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - $substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); } else { - $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); - $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2); - $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2); - $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'order'.$obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'invoice'.$obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'contractline'.$obj->source_id, 2); } } /* For backward compatibility, deprecated */ - if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2); - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'order' . $obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'order'.$obj->source_id, 2); - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'invoice'.$obj->source_id, 2); - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'contractline'.$obj->source_id, 2); } //$substitutionisok=true; complete_substitutions_array($substitutionarray, $langs); - $newsubject=make_substitutions($subject, $substitutionarray); - $newmessage=make_substitutions($message, $substitutionarray); + $newsubject = make_substitutions($subject, $substitutionarray); + $newmessage = make_substitutions($message, $substitutionarray); $arr_file = array(); $arr_mime = array(); $arr_name = array(); $arr_css = array(); - $listofpaths=dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); + $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); if (count($listofpaths)) { - foreach($listofpaths as $key => $val) + foreach ($listofpaths as $key => $val) { - $arr_file[]=$listofpaths[$key]['fullname']; - $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); - $arr_name[]=$listofpaths[$key]['name']; + $arr_file[] = $listofpaths[$key]['fullname']; + $arr_mime[] = dol_mimetype($listofpaths[$key]['name']); + $arr_name[] = $listofpaths[$key]['name']; } } // Fabrication du mail - $trackid='emailing-'.$obj->fk_mailing.'-'.$obj->rowid; + $trackid = 'emailing-'.$obj->fk_mailing.'-'.$obj->rowid; $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, '', 'emailing'); if ($mail->error) { - $res=0; + $res = 0; } /*if (! $substitutionisok) { @@ -300,7 +300,7 @@ if (empty($reshook)) // Send mail if ($res) { - $res=$mail->sendfile(); + $res = $mail->sendfile(); } if ($res) @@ -308,12 +308,12 @@ if (empty($reshook)) // Mail successful $nbok++; - dol_syslog("comm/mailing/card.php: ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); + dol_syslog("comm/mailing/card.php: ok for #".$i.($mail->error ? ' - '.$mail->error : ''), LOG_DEBUG); - $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql.=" SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; - $resql2=$db->query($sql); - if (! $resql2) + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql .= " SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -325,8 +325,8 @@ if (empty($reshook)) //Update status communication of thirdparty prospect $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")"; dol_syslog("card.php: set prospect thirdparty status", LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -335,8 +335,8 @@ if (empty($reshook)) $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("card.php: set prospect contact status", LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -355,12 +355,12 @@ if (empty($reshook)) // Mail failed $nbko++; - dol_syslog("comm/mailing/card.php: error for #".$i.($mail->error?' - '.$mail->error:''), LOG_WARNING); + dol_syslog("comm/mailing/card.php: error for #".$i.($mail->error ? ' - '.$mail->error : ''), LOG_WARNING); - $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql.=" SET statut=-1, error_text='".$db->escape($mail->error)."', date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; - $resql2=$db->query($sql); - if (! $resql2) + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql .= " SET statut=-1, error_text='".$db->escape($mail->error)."', date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -377,7 +377,7 @@ if (empty($reshook)) // Loop finished, set global statut of mail if ($nbko > 0) { - $statut=2; // Status 'sent partially' (because at least one error) + $statut = 2; // Status 'sent partially' (because at least one error) if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } @@ -385,20 +385,20 @@ if (empty($reshook)) { if ($nbok >= $num) { - $statut=3; // Send to everybody + $statut = 3; // Send to everybody setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } else { - $statut=2; // Status 'sent partially' (because not send to everybody) + $statut = 2; // Status 'sent partially' (because not send to everybody) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } } - $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id; dol_syslog("comm/mailing/card.php: update global status", LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -416,22 +416,22 @@ if (empty($reshook)) // Action send test emailing if ($action == 'send' && empty($_POST["cancel"])) { - $error=0; + $error = 0; - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $object->sendto = $_POST["sendto"]; - if (! $object->sendto) + if (!$object->sendto) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTo")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { // Le message est-il en html - $msgishtml=-1; // Inconnu par defaut - if (preg_match('/[\s\t]*/i', $object->body)) $msgishtml=1; + $msgishtml = -1; // Inconnu par defaut + if (preg_match('/[\s\t]*/i', $object->body)) $msgishtml = 1; // other are set at begin of page $object->substitutionarrayfortest['__EMAIL__'] = $object->sendto; @@ -439,8 +439,8 @@ if (empty($reshook)) // Pratique les substitutions sur le sujet et message complete_substitutions_array($object->substitutionarrayfortest, $langs); - $tmpsujet=make_substitutions($object->sujet, $object->substitutionarrayfortest); - $tmpbody=make_substitutions($object->body, $object->substitutionarrayfortest); + $tmpsujet = make_substitutions($object->sujet, $object->substitutionarrayfortest); + $tmpbody = make_substitutions($object->body, $object->substitutionarrayfortest); $arr_file = array(); $arr_mime = array(); @@ -448,25 +448,25 @@ if (empty($reshook)) $arr_css = array(); // Ajout CSS - if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor)?'':'#').$object->bgcolor; + if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; // Attached files - $listofpaths=dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); + $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); if (count($listofpaths)) { - foreach($listofpaths as $key => $val) + foreach ($listofpaths as $key => $val) { - $arr_file[]=$listofpaths[$key]['fullname']; - $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); - $arr_name[]=$listofpaths[$key]['name']; + $arr_file[] = $listofpaths[$key]['fullname']; + $arr_mime[] = dol_mimetype($listofpaths[$key]['name']); + $arr_name[] = $listofpaths[$key]['name']; } } - $trackid='emailingtest'; + $trackid = 'emailingtest'; $mailfile = new CMailFile($tmpsujet, $object->sendto, $object->email_from, $tmpbody, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $object->email_errorsto, $arr_css, $trackid, '', 'emailing'); - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { setEventMessages($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null, 'mesgs'); @@ -494,13 +494,13 @@ if (empty($reshook)) $object->bgcolor = trim($_POST["bgcolor"]); $object->bgimage = trim($_POST["bgimage"]); - if (! $object->titre) { + if (!$object->titre) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); } - if (! $object->sujet) { + if (!$object->sujet) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic")); } - if (! $object->body) { + if (!$object->body) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage")); } @@ -515,17 +515,17 @@ if (empty($reshook)) } setEventMessages($mesg, $mesgs, 'errors'); - $action="create"; + $action = "create"; } // Action update description of emailing if ($action == 'settitre' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); if ($action == 'settitre') $object->titre = trim(GETPOST('titre', 'alpha')); elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'alpha')); - elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'alpha')); + elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'alpha')); elseif ($action == 'setemail_errorsto') { $object->email_errorsto = trim(GETPOST('email_errorsto', 'alpha')); } elseif ($action == 'settitre' && empty($object->titre)) { @@ -534,7 +534,7 @@ if (empty($reshook)) $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); } - if (! $mesg) + if (!$mesg) { if ($object->update($user) >= 0) { @@ -545,34 +545,34 @@ if (empty($reshook)) } setEventMessages($mesg, $mesgs, 'errors'); - $action=""; + $action = ""; } /* * Add file in email form */ - if (! empty($_POST['addfile'])) + if (!empty($_POST['addfile'])) { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Set tmp user directory dol_add_file_process($upload_dir, 0, 0); - $action="edit"; + $action = "edit"; } // Action remove file - if (! empty($_POST["removedfile"])) + if (!empty($_POST["removedfile"])) { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing + dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing - $action="edit"; + $action = "edit"; } // Action update emailing @@ -580,9 +580,9 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $isupload=0; + $isupload = 0; - if (! $isupload) + if (!$isupload) { $mesgs = array(); @@ -591,10 +591,10 @@ if (empty($reshook)) $object->bgcolor = trim($_POST["bgcolor"]); $object->bgimage = trim($_POST["bgimage"]); - if (! $object->sujet) { + if (!$object->sujet) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic")); } - if (! $object->body) { + if (!$object->body) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage")); } @@ -605,15 +605,15 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } - $mesgs[] =$object->error; + $mesgs[] = $object->error; } setEventMessages($mesg, $mesgs, 'errors'); - $action="edit"; + $action = "edit"; } else { - $action="edit"; + $action = "edit"; } } @@ -663,10 +663,10 @@ if (empty($reshook)) { $db->begin(); - $result=$object->valid($user); + $result = $object->valid($user); if ($result > 0) { - $result=$object->reset_targets_status($user); + $result = $object->reset_targets_status($user); } if ($result > 0) @@ -692,13 +692,13 @@ if (empty($reshook)) { if ($object->delete($object->id)) { - $url= (! empty($urlfrom) ? $urlfrom : 'list.php'); + $url = (!empty($urlfrom) ? $urlfrom : 'list.php'); header("Location: ".$url); exit; } } - if (! empty($_POST["cancel"])) + if (!empty($_POST["cancel"])) { $action = ''; } @@ -712,7 +712,7 @@ if (empty($reshook)) $form = new Form($db); $htmlother = new FormOther($db); -$help_url='EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'; +$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'; llxHeader('', $langs->trans("Mailing"), $help_url, '', 0, 0, array( '/includes/ace/src/ace.js', @@ -729,14 +729,14 @@ if ($action == 'create') print ''; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
    '; - foreach($object->substitutionarray as $key => $val) + foreach ($object->substitutionarray as $key => $val) { - $htmltext.=$key.' = '.$langs->trans($val).'
    '; + $htmltext .= $key.' = '.$langs->trans($val).'
    '; } - $htmltext.='
    '; + $htmltext .= ''; - $availablelink=$form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'availvar'); + $availablelink = $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'availvar'); //print ''.img_picto($langs->trans("ClickToShowDescription"), $imginfo).''; @@ -748,11 +748,11 @@ if ($action == 'create') print ''; print ''; print ''; - print ''; + print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -773,7 +773,7 @@ if ($action == 'create') print '
    '; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('bodyemail', GETPOST('bodyemail', 'none'), '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); + $doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'none'), '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); $doleditor->Create(); print '
    '; @@ -787,7 +787,7 @@ else { if ($object->id > 0) { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $head = emailing_prepare_head($object); @@ -809,7 +809,7 @@ else // Confirm delete elseif ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(! empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); } @@ -919,22 +919,22 @@ else print ''; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '.$langs->trans("MailTitle").'
    '.$langs->trans("MailFrom").'
    '.$langs->trans("MailErrorsTo").'
    '.$langs->trans("MailErrorsTo").'
    '; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; - $nbemail = ($object->nbemail?$object->nbemail:0); + $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { - $text=''; - if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) + $text = ''; + if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) { if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { - $text.=$langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); + $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); } else { - $text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed'); + $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } - if (empty($nbemail)) $nbemail.=' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); @@ -947,7 +947,7 @@ else print '
    '; @@ -960,9 +960,9 @@ else if ($action == 'clone') { // Create an array for form - $formquestion=array( + $formquestion = array( 'text' => $langs->trans("ConfirmClone"), - array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContent"), 'value' => 1), + array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContent"), 'value' => 1), array('type' => 'checkbox', 'name' => 'clone_receivers', 'label' => $langs->trans("CloneReceivers"), 'value' => 0) ); // Paiement incomplet. On demande si motif = escompte ou autre @@ -973,7 +973,7 @@ else * Boutons d'action */ - if (GETPOST('cancel', 'alpha') || $confirm=='no' || $action == '' || in_array($action, array('settodraft','valid','delete','sendall','clone','test'))) + if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) { print "\n\n
    \n"; @@ -984,7 +984,7 @@ else if (($object->statut == 0 || $object->statut == 1) && $user->rights->mailing->creer) { - if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_MAILING)) + if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) { print ''.$langs->trans("EditWithEditor").''; } @@ -993,12 +993,12 @@ else print ''.$langs->trans("EditWithTextEditor").''; } - if (! empty($conf->use_javascript_ajax)) print ''.$langs->trans("EditHTMLSource").''; + if (!empty($conf->use_javascript_ajax)) print ''.$langs->trans("EditHTMLSource").''; } //print ''.$langs->trans("PreviewMailing").''; - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->send) + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("TestMailing").''; } @@ -1029,7 +1029,7 @@ else { print ''.$langs->trans("SendMailing").''; } - elseif (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->send) + elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("SendMailing").''; } @@ -1046,7 +1046,7 @@ else if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider) { - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->send) + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("ResetMailing").''; } @@ -1058,13 +1058,13 @@ else if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer) { - if ($object->statut > 0 && (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->delete)) + if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete)) { print ''.$langs->trans("DeleteMailing").''; } else { - print ''.$langs->trans("DeleteMailing").''; + print ''.$langs->trans("DeleteMailing").''; } } @@ -1084,25 +1084,25 @@ else $formmail = new FormMail($db); $formmail->fromname = $object->email_from; $formmail->frommail = $object->email_from; - $formmail->withsubstit=1; - $formmail->withfrom=0; - $formmail->withto=$user->email?$user->email:1; - $formmail->withtocc=0; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=0; - $formmail->withtopicreadonly=1; - $formmail->withfile=0; - $formmail->withbody=0; - $formmail->withbodyreadonly=1; - $formmail->withcancel=1; - $formmail->withdeliveryreceipt=0; + $formmail->withsubstit = 1; + $formmail->withfrom = 0; + $formmail->withto = $user->email ? $user->email : 1; + $formmail->withtocc = 0; + $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; + $formmail->withtopic = 0; + $formmail->withtopicreadonly = 1; + $formmail->withfile = 0; + $formmail->withbody = 0; + $formmail->withbodyreadonly = 1; + $formmail->withcancel = 1; + $formmail->withdeliveryreceipt = 0; // Tableau des substitutions - $formmail->substit=$object->substitutionarrayfortest; + $formmail->substit = $object->substitutionarrayfortest; // Tableau des parametres complementaires du post - $formmail->param["action"]="send"; - $formmail->param["models"]='none'; - $formmail->param["mailid"]=$object->id; - $formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id; + $formmail->param["action"] = "send"; + $formmail->param["models"] = 'none'; + $formmail->param["mailid"] = $object->id; + $formmail->param["returnurl"] = $_SERVER['PHP_SELF']."?id=".$object->id; print $formmail->get_form(); @@ -1115,11 +1115,11 @@ else $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
    '; - foreach($object->substitutionarray as $key => $val) + foreach ($object->substitutionarray as $key => $val) { - $htmltext.=$key.' = '.$langs->trans($val).'
    '; + $htmltext .= $key.' = '.$langs->trans($val).'
    '; } - $htmltext.='
    '; + $htmltext .= ''; // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto(''.$langs->trans("AvailableVariables").'', $htmltext, 1, 'helpclickable', '', 0, 2, 'emailsubstitionhelp'), 'generic'); @@ -1134,10 +1134,10 @@ else // Joined files print '
    '.$langs->trans("MailFile").''; // List of files - $listofpaths=dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); + $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); if (count($listofpaths)) { - foreach($listofpaths as $key => $val) + foreach ($listofpaths as $key => $val) { print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; print '
    '; @@ -1157,13 +1157,13 @@ else print '
    '; // Message - print '
    '; + print '
    '; if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') // CKEditor does not apply the color of the div into its content area { - $readonly=1; + $readonly = 1; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, true, empty($conf->global->FCKEDITOR_ENABLE_MAILING)?0:1, 20, '90%', $readonly); + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20, '90%', $readonly); $doleditor->Create(); } else print dol_htmlentitiesbr($object->body); @@ -1181,8 +1181,8 @@ else $linkback = ''.$langs->trans("BackToList").''; - $morehtmlright=''; - if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; + $morehtmlright = ''; + if ($object->statut == 2) $morehtmlright .= ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); @@ -1209,22 +1209,22 @@ else print '
    '; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; - $nbemail = ($object->nbemail?$object->nbemail:0); + $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { - $text=''; - if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) + $text = ''; + if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) { if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { - $text.=$langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); + $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); } else { - $text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed'); + $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } - if (empty($nbemail)) $nbemail.=' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); @@ -1237,8 +1237,8 @@ else print '
    '.$langs->trans("MailTopic").'
    '.$langs->trans("MailFile").''; // List of files - $listofpaths=dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); + $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out.= ''."\n"; - $out.= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; if (count($listofpaths)) { - foreach($listofpaths as $key => $val) + foreach ($listofpaths as $key => $val) { - $out.= '
    '; - $out.= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; - $out.= ' '; - $out.= '
    '; + $out .= '
    '; + $out .= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; + $out .= ' '; + $out .= '
    '; } } else { - $out.= $langs->trans("NoAttachedFiles").'
    '; + $out .= $langs->trans("NoAttachedFiles").'
    '; } // Add link to add file - $out.= ''; - $out.= ' '; - $out.= ''; + $out .= ''; + $out .= ' '; + $out .= ''; print $out; print '
    '."\n"; + print '
    '."\n"; print ''; print ''; print ''; - if (! $filteremail) print ''; + if (!$filteremail) print ''; print ''; print ''; print ''; print "\n"; @@ -202,15 +202,15 @@ if ($result) print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "m.rowid", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "m.titre", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", $param, "", 'align="center"', $sortfield, $sortorder); - 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); + 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, "", 'class="right"', $sortfield, $sortorder); + 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"; - $email=new Mailing($db); + $email = new Mailing($db); while ($i < min($num, $limit)) { @@ -233,7 +233,7 @@ if ($result) print ''; // Nb of email - if (! $filteremail) + if (!$filteremail) { print ''."\n"; print '
    '; @@ -189,11 +189,11 @@ if ($result) print ''; print '     '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
    '; $nbemail = $obj->nbemail; diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 14f5913c4ce..248ad8f47a0 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -62,7 +62,7 @@ if ($id > 0 || ! empty($ref)) $error++; } } -if (! $error) +if (!$error) { $object->fetch_thirdparty(); } @@ -109,7 +109,7 @@ elseif ($action == 'swapstatut' && $user->rights->propale->creer) { if ($object->id > 0) { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } } @@ -143,7 +143,7 @@ elseif ($action == 'setaddress' && $user->rights->propale->creer) llxHeader('', $langs->trans('Proposal'), 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); $form = new Form($db); -$formcompany= new FormCompany($db); +$formcompany = new FormCompany($db); $formother = new FormOther($db); if ($object->id > 0) @@ -205,10 +205,10 @@ if ($object->id > 0) // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach($dirtpls as $reldir) + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach ($dirtpls as $reldir) { - $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); if ($res) break; } } diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 55a21445be2..af2e866966a 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -32,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page @@ -79,7 +79,7 @@ if ($object->id > 0) { $object->fetch_thirdparty(); $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; + include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; } @@ -176,8 +176,8 @@ if ($object->id > 0) $modulepart = 'propal'; $permission = $user->rights->propal->creer; $permtoedit = $user->rights->propal->creer; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index ee9d9bd9c4f..1abbeb6370c 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -51,9 +51,9 @@ $object = new Propal($db); * Actions */ -$permissionnote=$user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once @@ -65,11 +65,11 @@ llxHeader('', $langs->trans('Proposal'), 'EN:Commercial_Proposals|FR:Proposition $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { if ($mesg) print $mesg; - $now=dol_now(); + $now = dol_now(); if ($object->fetch($id, $ref) > 0) { diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 97890c9d2ef..10aaf0fd2ac 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -83,7 +83,7 @@ elseif ($action == 'swapstatut' && $user->rights->commande->creer) { if ($object->fetch($id)) { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { @@ -124,8 +124,8 @@ llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients| $form = new Form($db); $formcompany = new FormCompany($db); $formother = new FormOther($db); -$contactstatic=new Contact($db); -$userstatic=new User($db); +$contactstatic = new Contact($db); +$userstatic = new User($db); /* *************************************************************************** */ @@ -134,7 +134,7 @@ $userstatic=new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $langs->trans("OrderCard"); @@ -200,10 +200,10 @@ if ($id > 0 || ! empty($ref)) print '
    '; // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach($dirtpls as $reldir) + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach ($dirtpls as $reldir) { - $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); if ($res) break; } } diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 565583e1fae..8d5afb985a3 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -31,9 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT .'/commande/class/commande.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page @@ -49,7 +49,7 @@ if ($user->socid) { $socid = $user->socid; } -$result=restrictedArea($user, 'commande', $id, ''); +$result = restrictedArea($user, 'commande', $id, ''); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); @@ -76,10 +76,10 @@ $object = new Commande($db); if ($object->fetch($id)) { $object->fetch_thirdparty(); - $upload_dir = $conf->commande->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->commande->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); } -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -90,7 +90,7 @@ llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients| $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref)) { @@ -179,8 +179,8 @@ if ($id > 0 || ! empty($ref)) $modulepart = 'commande'; $permission = $user->rights->commande->creer; $permtoedit = $user->rights->commande->creer; - $param = '&id=' . $object->id.'&entity=' . (! empty($object->entity)?$object->entity:$conf->entity); - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity); + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 4ca81f77771..d509d3711b2 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -27,8 +27,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } if (!$user->rights->commande->lire) accessforbidden(); diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 5b8fe052b06..3c6b1c37de3 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -71,7 +71,7 @@ llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients| $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); @@ -134,7 +134,7 @@ if ($id > 0 || ! empty($ref)) print '
    '; - $cssclass="titlefield"; + $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; print ''; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 4cc5ce532e4..20014e58767 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -36,50 +36,50 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; -if (! empty($conf->projet->enabled)) { +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page $langs->loadLangs(array("orders", "deliveries", "companies")); -if (! $user->rights->facture->creer) +if (!$user->rights->facture->creer) accessforbidden(); -$id = (GETPOST('id')?GETPOST('id', 'int'):GETPOST("facid", "int")); // For backward compatibility +$id = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST("facid", "int")); // For backward compatibility $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $sref = GETPOST('sref', 'alpha'); -$sref_client = GETPOST('sref_client', 'alpha'); -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$socid = GETPOST('socid', 'int'); -$selected = GETPOST('orders_to_invoice'); +$sref_client = GETPOST('sref_client', 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$socid = GETPOST('socid', 'int'); +$selected = GETPOST('orders_to_invoice'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$viewstatut = GETPOST('viewstatut', 'alpha'); +$viewstatut = GETPOST('viewstatut', 'alpha'); $error = 0; -if (! $sortfield) $sortfield='c.rowid'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'c.rowid'; +if (!$sortorder) $sortorder = 'DESC'; $now = dol_now(); -$date_start = dol_mktime(0, 0, 0, $_REQUEST["date_startmonth"], $_REQUEST["date_startday"], $_REQUEST["date_startyear"]); // Date for local PHP server +$date_start = dol_mktime(0, 0, 0, $_REQUEST["date_startmonth"], $_REQUEST["date_startday"], $_REQUEST["date_startyear"]); // Date for local PHP server $date_end = dol_mktime(23, 59, 59, $_REQUEST["date_endmonth"], $_REQUEST["date_endday"], $_REQUEST["date_endyear"]); -$date_starty = dol_mktime(0, 0, 0, $_REQUEST["date_start_delymonth"], $_REQUEST["date_start_delyday"], $_REQUEST["date_start_delyyear"]); // Date for local PHP server +$date_starty = dol_mktime(0, 0, 0, $_REQUEST["date_start_delymonth"], $_REQUEST["date_start_delyday"], $_REQUEST["date_start_delyyear"]); // Date for local PHP server $date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST["date_end_delyday"], $_REQUEST["date_end_delyyear"]); $extrafields = new ExtraFields($db); -$object=new Facture($db); +$object = new Facture($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); if ($action == 'create') { - if (! is_array($selected)) + if (!is_array($selected)) { $error++; setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); @@ -93,7 +93,7 @@ if ($action == 'create') // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); +$hookmanager = new HookManager($db); $hookmanager->initHooks(array('orderstoinvoice')); @@ -107,7 +107,7 @@ if (($action == 'create' || $action == 'add') && !$error) require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; - if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->load('bills'); $langs->load('products'); @@ -118,8 +118,8 @@ if (($action == 'create' || $action == 'add') && !$error) $n = count($orders_id); $i = 0; - $originid=$orders_id[0]; - $_GET['originid']=$orders_id[0]; + $originid = $orders_id[0]; + $_GET['originid'] = $orders_id[0]; } if (isset($_POST['orders_to_invoice'])) { @@ -189,23 +189,23 @@ if (($action == 'create' || $action == 'add') && !$error) $id = $object->create($user); $object->fetch_thirdparty(); - if ($id>0) + if ($id > 0) { - foreach($orders_id as $origin => $origin_id) + foreach ($orders_id as $origin => $origin_id) { - $origin_id = (! empty($origin_id) ? $origin_id : $object->origin_id); + $origin_id = (!empty($origin_id) ? $origin_id : $object->origin_id); $db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sql.= "fk_source"; - $sql.= ", sourcetype"; - $sql.= ", fk_target"; - $sql.= ", targettype"; - $sql.= ") VALUES ("; - $sql.= $origin_id; - $sql.= ", '".$object->origin."'"; - $sql.= ", ".$id; - $sql.= ", '".$object->element."'"; - $sql.= ")"; + $sql .= "fk_source"; + $sql .= ", sourcetype"; + $sql .= ", fk_target"; + $sql .= ", targettype"; + $sql .= ") VALUES ("; + $sql .= $origin_id; + $sql .= ", '".$object->origin."'"; + $sql .= ", ".$id; + $sql .= ", '".$object->element."'"; + $sql .= ")"; if ($db->query($sql)) { @@ -222,7 +222,7 @@ if (($action == 'create' || $action == 'add') && !$error) include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $objectsrc = new Commande($db); dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); - $result=$objectsrc->fetch($orders_id[$ii]); + $result = $objectsrc->fetch($orders_id[$ii]); if ($result > 0) { if ($closeOrders) @@ -236,26 +236,26 @@ if (($action == 'create' || $action == 'add') && !$error) $objectsrc->fetch_lines(); $lines = $objectsrc->lines; } - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) + $fk_parent_line = 0; + $num = count($lines); + for ($i = 0; $i < $num; $i++) { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); - $discount->fk_soc=$object->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); + $discount->fk_soc = $object->socid; + $discount->amount_ht = abs($lines[$i]->total_ht); + $discount->amount_tva = abs($lines[$i]->total_tva); + $discount->amount_ttc = abs($lines[$i]->total_ttc); + $discount->tva_tx = $lines[$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); if ($discountid > 0) { - $result=$object->insert_discount($discountid); + $result = $object->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else @@ -268,17 +268,17 @@ if (($action == 'create' || $action == 'add') && !$error) else { // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_start = false; + if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + $date_end = false; + if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { @@ -320,11 +320,11 @@ if (($action == 'create' || $action == 'add') && !$error) ); if ($result > 0) { - $lineid=$result; + $lineid = $result; } else { - $lineid=0; + $lineid = 0; $error++; break; } @@ -354,7 +354,7 @@ if (($action == 'create' || $action == 'add') && !$error) } // End of object creation, we show it - if ($id > 0 && ! $error) + if ($id > 0 && !$error) { $db->commit(); header('Location: '.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$id); @@ -363,9 +363,9 @@ if (($action == 'create' || $action == 'add') && !$error) else { $db->rollback(); - $action='create'; - $_GET["origin"]=$_POST["origin"]; - $_GET["originid"]=$_POST["originid"]; + $action = 'create'; + $_GET["origin"] = $_POST["origin"]; + $_GET["originid"] = $_POST["originid"]; setEventMessages($object->error, $object->errors, 'errors'); $error++; } @@ -385,27 +385,27 @@ $companystatic = new Societe($db); // Mode creation if ($action == 'create' && !$error) { - $facturestatic=new Facture($db); + $facturestatic = new Facture($db); llxHeader(); print load_fiche_titre($langs->trans('NewBill')); $soc = new Societe($db); - if ($socid) $res=$soc->fetch($socid); + if ($socid) $res = $soc->fetch($socid); if ($res) { $cond_reglement_id = $soc->cond_reglement_id; $mode_reglement_id = $soc->mode_reglement_id; - $remise_percent = $soc->remise_percent; + $remise_percent = $soc->remise_percent; } - $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; + $remise_absolue = 0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; - $absolute_discount=$soc->getAvailableDiscounts(); + $absolute_discount = $soc->getAvailableDiscounts(); print ''; print ''; print ''; - print '' ."\n"; + print ''."\n"; print ''; print ''; print ''; @@ -433,9 +433,9 @@ if ($action == 'create' && !$error) // Standard invoice print '
    '; - print ''; + print ''; print ''; - $desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1); + $desc = $html->textwithpicto($langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1); print $desc; print '
    '; @@ -446,16 +446,16 @@ if ($action == 'create' && !$error) print '
    '.$langs->trans('PaymentConditionsShort').''; - $html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id, 'cond_reglement_id'); + $html->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); print '
    '.$langs->trans('PaymentMode').''; - $html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id, 'mode_reglement_id'); + $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); print '
    '.$langs->trans('Project').''; @@ -468,7 +468,7 @@ if ($action == 'create' && !$error) $listoforders = array(); foreach ($selected as $sel) { - $result=$objectsrc->fetch($sel); + $result = $objectsrc->fetch($sel); if ($result > 0) { $listoforders[] = $objectsrc->ref; @@ -476,12 +476,12 @@ if ($action == 'create' && !$error) } // Other attributes - $parameters=array('objectsrc' => $objectsrc, 'idsrc' => $listoforders); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('objectsrc' => $objectsrc, 'idsrc' => $listoforders); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - $object=new Facture($db); + $object = new Facture($db); print $object->showOptionals($extrafields, 'edit'); } @@ -489,7 +489,7 @@ if ($action == 'create' && !$error) print '
    '.$langs->trans('Model').''; include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $liste=ModelePDFFactures::liste_modeles($db); + $liste = ModelePDFFactures::liste_modeles($db); print $html->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF); print "
    '; - $generic_commande->id=$objp->rowid; - $generic_commande->ref=$objp->ref; + $generic_commande->id = $objp->rowid; + $generic_commande->ref = $objp->ref; $generic_commande->statut = $objp->fk_statut; $generic_commande->date_commande = $db->jdate($objp->date_commande); $generic_commande->date_livraison = $db->jdate($objp->date_livraison); @@ -682,9 +682,9 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; - $filename=dol_sanitizeFileName($objp->ref); - $filedir=$conf->commande->multidir_output[$objp->entity] . '/' . dol_sanitizeFileName($objp->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid; + $filename = dol_sanitizeFileName($objp->ref); + $filedir = $conf->commande->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objp->rowid; print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print '
    '; print '
    '; print ''; - print '
    '.$langs->trans("Ref").'ref).'" maxlength="12" autofocus>
    ref).'" maxlength="12" autofocus>
    '.$langs->trans("LabelBankCashAccount").'
    '.$langs->trans("AccountType").''; - $formbank->selectTypeOfBankAccount(isset($_POST["type"])?$_POST["type"]: Account::TYPE_CURRENT, "type"); + $formbank->selectTypeOfBankAccount(isset($_POST["type"]) ? $_POST["type"] : Account::TYPE_CURRENT, "type"); print '
    '.$langs->trans("Currency").''; - $selectedcode=$object->currency_code; - if (! $selectedcode) $selectedcode=$conf->currency; - print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); + $selectedcode = $object->currency_code; + if (!$selectedcode) $selectedcode = $conf->currency; + print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
    '.$langs->trans("Status").''; - print $form->selectarray("clos", $object->status, (GETPOST("clos", 'int')!=''?GETPOST("clos", 'int'):$object->clos)); + print $form->selectarray("clos", $object->status, (GETPOST("clos", 'int') != '' ?GETPOST("clos", 'int') : $object->clos)); print '
    '.$langs->trans("BankAccountCountry").''; @@ -397,7 +397,7 @@ if ($action == 'create') print '
    '.$langs->trans('State').''; if ($selectedcode) { - $formcompany->select_departement(isset($_POST["account_state_id"])?$_POST["account_state_id"]:'', $selectedcode, 'account_state_id'); + $formcompany->select_departement(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : '', $selectedcode, 'account_state_id'); } else { @@ -433,13 +433,13 @@ if ($action == 'create') print ''; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('account_comment', (GETPOST("account_comment")?GETPOST("account_comment"):$object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '90%'); + $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '90%'); $doleditor->Create(); print '
    '.$langs->trans("InitialBankBalance").'solde)).'">
    solde)).'">
    '.$langs->trans("Date").''; @@ -462,10 +462,10 @@ if ($action == 'create') print '
    '.$langs->trans("BalanceMinimalAllowed").'min_allowed).'">
    min_allowed).'">
    '.$langs->trans("BalanceMinimalDesired").'min_desired).'">
    min_desired).'">
    '; print '
    '; @@ -476,7 +476,7 @@ if ($action == 'create') // If bank account print '
    '.$langs->trans("BankName").'
    '.$langs->trans($val).'
    '.$langs->trans($ibankey).'
    '.$langs->trans($bickey).'
    '.$langs->trans("BankAccountDomiciliation").''; print "
    '.$langs->trans("BankAccountOwner").''; + print ''; print '
    '.$langs->trans("BankAccountOwnerAddress").''; print "
    '; @@ -534,10 +534,10 @@ if ($action == 'create') print ''; // Accountancy code - $fieldrequired=''; - if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired '; + $fieldrequired = ''; + if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired = 'fieldrequired '; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print ''; - print ''; + print ''; } // Accountancy journal - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print ''; print ''; // Accountancy journal - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print '
    '.$langs->trans("AccountancyCode").''; @@ -547,11 +547,11 @@ if ($action == 'create') else { print '
    '.$langs->trans("AccountancyCode").'account_number).'">
    account_number).'">
    '.$langs->trans("AccountancyJournal").''; @@ -564,9 +564,9 @@ if ($action == 'create') dol_fiche_end(); print '
    '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
    '; print ''; @@ -588,11 +588,11 @@ else if ($_GET["ref"]) { $object->fetch(0, $_GET["ref"]); - $_GET["id"]=$object->id; + $_GET["id"] = $object->id; } // Show tabs - $head=bank_prepare_head($object); + $head = bank_prepare_head($object); dol_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account'); $formconfirm = ''; @@ -608,7 +608,7 @@ else $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref=''; + $morehtmlref = ''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -648,7 +648,7 @@ else // Accountancy code print '
    '.$langs->trans("AccountancyCode").''; - if (! empty($conf->accounting->enabled)) { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_number, 1); @@ -659,7 +659,7 @@ else print '
    '.$langs->trans("AccountancyJournal").''; @@ -675,7 +675,7 @@ else // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '; @@ -725,13 +725,13 @@ else } $ibankey = FormBank::getIBANLabel($object); - $bickey="BICNumber"; - if ($object->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($object->getCountryCode() == 'IN') $bickey = "SWIFT"; print '
    '.$langs->trans($ibankey).''.$object->iban.' '; - if (! empty($object->iban)) { - if (! checkIbanForAccount($object)) { + if (!empty($object->iban)) { + if (!checkIbanForAccount($object)) { print img_picto($langs->trans("IbanNotValid"), 'warning'); } else { print img_picto($langs->trans("IbanValid"), 'info'); @@ -741,8 +741,8 @@ else print '
    '.$langs->trans($bickey).''.$object->bic.' '; - if (! empty($object->bic)) { - if (! checkSwiftForAccount($object)) { + if (!empty($object->bic)) { + if (!checkSwiftForAccount($object)) { print img_picto($langs->trans("SwiftNotValid"), 'warning'); } else { print img_picto($langs->trans("SwiftValid"), 'info'); @@ -783,7 +783,7 @@ else print 'id.'">'.$langs->trans("Modify").''; } - $canbedeleted=$object->can_be_deleted(); // Renvoi vrai si compte sans mouvements + $canbedeleted = $object->can_be_deleted(); // Renvoi vrai si compte sans mouvements if ($user->rights->banque->configurer && $canbedeleted) { print 'id.'">'.$langs->trans("Delete").''; @@ -837,16 +837,16 @@ else // Ref print '
    '.$langs->trans("Ref").'ref).'">
    ref).'">
    '.$langs->trans("Label").'label).'">
    label).'">
    '.$langs->trans("AccountType").''; - $formbank->selectTypeOfBankAccount((isset($_POST["type"])?$_POST["type"]:$object->type), "type"); + $formbank->selectTypeOfBankAccount((isset($_POST["type"]) ? $_POST["type"] : $object->type), "type"); print '
    '; - $selectedcode=$object->currency_code; - if (! $selectedcode) $selectedcode=$conf->currency; - print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); + $selectedcode = $object->currency_code; + if (!$selectedcode) $selectedcode = $conf->currency; + print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
    '.$langs->trans("Status").''; - print $form->selectarray("clos", $object->status, (isset($_POST["clos"])?$_POST["clos"]:$object->clos)); + print $form->selectarray("clos", $object->status, (isset($_POST["clos"]) ? $_POST["clos"] : $object->clos)); print '
    '.$langs->trans("Country").''; @@ -884,7 +884,7 @@ else print '
    '.$langs->trans('State').''; if ($selectedcode) { - print $formcompany->select_state(isset($_POST["account_state_id"])?$_POST["account_state_id"]:$object->state_id, $selectedcode, 'account_state_id'); + print $formcompany->select_state(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : $object->state_id, $selectedcode, 'account_state_id'); } else { @@ -895,22 +895,22 @@ else // Conciliable print '
    '.$langs->trans("Conciliable").''; - $conciliate=$object->canBeConciliated(); + $conciliate = $object->canBeConciliated(); if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; elseif ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')'; - else print ' 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation"); + else print ' 0) ? '' : ' checked="checked"').'"> '.$langs->trans("DisableConciliation"); print '
    '.$langs->trans("BalanceMinimalAllowed").'min_allowed).'">
    min_allowed).'">
    '.$langs->trans("BalanceMinimalDesired").'min_desired).'">
    min_desired).'">
    '.$langs->trans("Web").'url).'">'; + print 'url).'">'; print '
    '; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('account_comment', (GETPOST("account_comment")?GETPOST("account_comment"):$object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '95%'); + $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '95%'); $doleditor->Create(); print '
    '.$langs->trans("AccountancyJournal").''; @@ -1022,8 +1022,8 @@ else } $ibankey = FormBank::getIBANLabel($object); - $bickey="BICNumber"; - if ($object->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($object->getCountryCode() == 'IN') $bickey = "SWIFT"; // IBAN print '
    '.$langs->trans($ibankey).'
    '."\n"; +print '
    '."\n"; print ''; // Ref -if (! empty($arrayfields['b.ref']['checked'])) +if (!empty($arrayfields['b.ref']['checked'])) { print ''; } // Label -if (! empty($arrayfields['b.label']['checked'])) +if (!empty($arrayfields['b.label']['checked'])) { print ''; } // Account type -if (! empty($arrayfields['accountype']['checked'])) +if (!empty($arrayfields['accountype']['checked'])) { print ''; } // Bank number -if (! empty($arrayfields['b.number']['checked'])) +if (!empty($arrayfields['b.number']['checked'])) { print ''; } // Account number -if (! empty($arrayfields['b.account_number']['checked'])) +if (!empty($arrayfields['b.account_number']['checked'])) { print ''; } // Accountancy journal -if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) +if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { print ''; } // Transactions to reconcile -if (! empty($arrayfields['toreconcile']['checked'])) +if (!empty($arrayfields['toreconcile']['checked'])) { print ''; } // Currency -if (! empty($arrayfields['b.currency_code']['checked'])) +if (!empty($arrayfields['b.currency_code']['checked'])) { print ''; @@ -340,26 +340,26 @@ if (! empty($arrayfields['b.currency_code']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (! empty($arrayfields['b.datec']['checked'])) +if (!empty($arrayfields['b.datec']['checked'])) { print ''; } // Date modification -if (! empty($arrayfields['b.tms']['checked'])) +if (!empty($arrayfields['b.tms']['checked'])) { print ''; } // Status -if (! empty($arrayfields['b.clos']['checked'])) +if (!empty($arrayfields['b.clos']['checked'])) { print ''; } // Balance -if (! empty($arrayfields['balance']['checked'])) +if (!empty($arrayfields['balance']['checked'])) { print ''; } // Action column print ''; print ''; // Fields title print ''; -if (! empty($arrayfields['b.ref']['checked'])) print_liste_field_titre($arrayfields['b.ref']['label'], $_SERVER["PHP_SELF"], 'b.ref', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER["PHP_SELF"], 'b.label', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['accountype']['checked'])) print_liste_field_titre($arrayfields['accountype']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'], $_SERVER["PHP_SELF"], 'b.number', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'], $_SERVER["PHP_SELF"], 'b.account_number', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'], $_SERVER["PHP_SELF"], 'b.fk_accountancy_journal', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.currency_code']['checked'])) print_liste_field_titre($arrayfields['b.currency_code']['label'], $_SERVER["PHP_SELF"], 'b.currency_code', '', $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['b.ref']['checked'])) print_liste_field_titre($arrayfields['b.ref']['label'], $_SERVER["PHP_SELF"], 'b.ref', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER["PHP_SELF"], 'b.label', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['accountype']['checked'])) print_liste_field_titre($arrayfields['accountype']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'], $_SERVER["PHP_SELF"], 'b.number', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'], $_SERVER["PHP_SELF"], 'b.account_number', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'], $_SERVER["PHP_SELF"], 'b.fk_accountancy_journal', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.currency_code']['checked'])) print_liste_field_titre($arrayfields['b.currency_code']['label'], $_SERVER["PHP_SELF"], 'b.currency_code', '', $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$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 +$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; -if (! empty($arrayfields['b.datec']['checked'])) print_liste_field_titre($arrayfields['b.datec']['label'], $_SERVER["PHP_SELF"], "b.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['b.tms']['checked'])) print_liste_field_titre($arrayfields['b.tms']['label'], $_SERVER["PHP_SELF"], "b.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['b.clos']['checked'])) print_liste_field_titre($arrayfields['b.clos']['label'], $_SERVER["PHP_SELF"], 'b.clos', '', $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['b.datec']['checked'])) print_liste_field_titre($arrayfields['b.datec']['label'], $_SERVER["PHP_SELF"], "b.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['b.tms']['checked'])) print_liste_field_titre($arrayfields['b.tms']['label'], $_SERVER["PHP_SELF"], "b.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['b.clos']['checked'])) print_liste_field_titre($arrayfields['b.clos']['label'], $_SERVER["PHP_SELF"], 'b.clos', '', $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; -$total = array(); $found = 0; $i=0; $lastcurrencycode=''; +$total = array(); $found = 0; $i = 0; $lastcurrencycode = ''; foreach ($accounts as $key=>$type) { @@ -488,26 +488,26 @@ foreach ($accounts as $key=>$type) print ''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Currency - if (! empty($arrayfields['b.currency_code']['checked'])) + if (!empty($arrayfields['b.currency_code']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Transactions to reconcile - if (! empty($arrayfields['toreconcile']['checked'])) + if (!empty($arrayfields['toreconcile']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; @@ -586,10 +586,10 @@ foreach ($accounts as $key=>$type) } // If no record found -if (! $found) +if (!$found) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 5e7904ad7d6..c80a0cd0ab8 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -85,39 +85,39 @@ if (empty($reshook)) { if ($action != 'addlink') { - $urltogo=$backtopage?$backtopage:dol_buildpath('/compta/bank/various_payment/list.php', 1); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/compta/bank/various_payment/list.php', 1); header("Location: ".$urltogo); exit; } - if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id, $ref); - $action=''; + if ($id > 0 || !empty($ref)) $ret = $object->fetch($id, $ref); + $action = ''; } if ($action == 'add') { - $error=0; + $error = 0; - $datep=dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int')); - $datev=dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int')); - if (empty($datev)) $datev=$datep; + $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int')); + $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int')); + if (empty($datev)) $datev = $datep; - $object->ref=''; // TODO - $object->accountid=GETPOST("accountid", 'int') > 0 ? GETPOST("accountid", "int") : 0; - $object->datev=$datev; - $object->datep=$datep; - $object->amount=price2num(GETPOST("amount", 'alpha')); - $object->label=GETPOST("label", 'none'); - $object->note=GETPOST("note", 'none'); - $object->type_payment=GETPOST("paymenttype", 'int') > 0 ? GETPOST("paymenttype", "int") : 0; - $object->num_payment=GETPOST("num_payment", 'alpha'); - $object->fk_user_author=$user->id; - $object->category_transaction=GETPOST("category_transaction", 'alpha'); + $object->ref = ''; // TODO + $object->accountid = GETPOST("accountid", 'int') > 0 ? GETPOST("accountid", "int") : 0; + $object->datev = $datev; + $object->datep = $datep; + $object->amount = price2num(GETPOST("amount", 'alpha')); + $object->label = GETPOST("label", 'none'); + $object->note = GETPOST("note", 'none'); + $object->type_payment = GETPOST("paymenttype", 'int') > 0 ? GETPOST("paymenttype", "int") : 0; + $object->num_payment = GETPOST("num_payment", 'alpha'); + $object->fk_user_author = $user->id; + $object->category_transaction = GETPOST("category_transaction", 'alpha'); - $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : ""; - $object->subledger_account=GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""; + $object->accountancy_code = GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : ""; + $object->subledger_account = GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""; - $object->sens=GETPOST('sens'); - $object->fk_project= GETPOST('fk_project', 'int'); + $object->sens = GETPOST('sens'); + $object->fk_project = GETPOST('fk_project', 'int'); if (empty($datep) || empty($datev)) { @@ -137,29 +137,29 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); $error++; } - if (! empty($conf->banque->enabled) && ! $object->accountid > 0) + if (!empty($conf->banque->enabled) && !$object->accountid > 0) { $langs->load('errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); $error++; } // TODO Remove this and allow instead to edit a various payment to enter accounting code - if (! empty($conf->accounting->enabled) && ! $object->accountancy_code) + if (!empty($conf->accounting->enabled) && !$object->accountancy_code) { $langs->load('errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->begin(); - $ret=$object->create($user); + $ret = $object->create($user); if ($ret > 0) { $db->commit(); - $urltogo=($backtopage ? $backtopage : DOL_URL_ROOT.'/compta/bank/various_payment/list.php'); + $urltogo = ($backtopage ? $backtopage : DOL_URL_ROOT.'/compta/bank/various_payment/list.php'); header("Location: ".$urltogo); exit; } @@ -167,29 +167,29 @@ if (empty($reshook)) { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); - $action="create"; + $action = "create"; } } - $action='create'; + $action = 'create'; } if ($action == 'delete') { - $result=$object->fetch($id); + $result = $object->fetch($id); if ($object->rappro == 0) { $db->begin(); - $ret=$object->delete($user); + $ret = $object->delete($user); if ($ret > 0) { if ($object->fk_bank) { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); - if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + $accountline = new AccountLine($db); + $result = $accountline->fetch($object->fk_bank); + if ($result > 0) $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) } if ($result >= 0) @@ -200,7 +200,7 @@ if (empty($reshook)) } else { - $object->error=$accountline->error; + $object->error = $accountline->error; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } @@ -226,8 +226,8 @@ if (empty($reshook)) llxHeader("", $langs->trans("VariousPayment")); $form = new Form($db); -if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); -if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db); +if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); if ($id) { @@ -271,25 +271,25 @@ if ($action == 'create') // Date payment print ''; // Date value for bank print ''; // Label print ''; // Sens print ''; @@ -300,11 +300,11 @@ if ($action == 'create') print ''; // Bank - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''; } @@ -315,7 +315,7 @@ if ($action == 'create') print ''; // Number - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // Number print ''; } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''; @@ -355,7 +355,7 @@ if ($action == 'create') } // Accountancy account - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code print ''; @@ -371,11 +371,11 @@ if ($action == 'create') } // Subledger account - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print ''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { if ($object->fk_account > 0) { - $bankline=new AccountLine($db); + $bankline = new AccountLine($db); $bankline->fetch($object->fk_bank); print ''; @@ -519,8 +519,8 @@ if ($id) } // Other attributes - $parameters=array('socid'=>$object->id); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('socid'=>$object->id); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; - $array=array( + $array = array( 'opened'=>$langs->trans("Opened"), 'closed'=>$langs->trans("Closed") ); @@ -367,42 +367,42 @@ if (! empty($arrayfields['b.clos']['checked'])) print ''; -$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); +$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print '
    '; print $objecttmp->currency_code; print ''; if ($objecttmp->rappro) { - $result=$objecttmp->load_board($user, $objecttmp->id); - if ($result<0) { + $result = $objecttmp->load_board($user, $objecttmp->id); + if ($result < 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); } else { print ''.$result->nbtodo.''; @@ -571,12 +571,12 @@ foreach ($accounts as $key=>$type) print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($objecttmp->id, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($objecttmp->id, $arrayofselected)) $selected = 1; + print ''; } print '
    '.$langs->trans("NoRecordFound").'
    '; print $form->editfieldkey('DatePayment', 'datep', '', $object, 0, 'string', '', 1).''; - print $form->selectDate((empty($datep)?-1:$datep), "datep", '', '', '', 'add', 1, 1); + print $form->selectDate((empty($datep) ?-1 : $datep), "datep", '', '', '', 'add', 1, 1); print '
    '; print $form->editfieldkey('DateValue', 'datev', '', $object, 0).''; - print $form->selectDate((empty($datev)?-1:$datev), "datev", '', '', '', 'add', 1, 1); + print $form->selectDate((empty($datev) ?-1 : $datev), "datev", '', '', '', 'add', 1, 1); print '
    '; print $form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).''; - print ''; + print ''; print '
    '; print $form->editfieldkey('Sens', 'sens', '', $object, 0, 'string', '', 1).''; - $sensarray=array( '0' => $langs->trans("Debit"), '1' => $langs->trans("Credit")); + $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit")); print $form->selectarray('sens', $sensarray, $sens); print '
    '; print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).''; - $form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant + $form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant print '
    '.$langs->trans("Project").''; - $numproject=$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); + $numproject = $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); print '
    '.$langs->trans("AccountAccounting").'
    '.$langs->trans("SubledgerAccount").''; - if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, ''); } @@ -484,7 +484,7 @@ if ($id) print '
    '; print $langs->trans("AccountAccounting"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->accountancy_code, 1); @@ -502,11 +502,11 @@ if ($id) print $object->subledger_account; print '
    '; @@ -542,7 +542,7 @@ if ($id) // Delete if (empty($object->rappro)) { - if (! empty($user->rights->banque->modifier)) + if (!empty($user->rights->banque->modifier)) { print ''; } diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 7070946e2c7..6e8fb2a65ea 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -50,22 +50,22 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; $object = new PaymentVarious($db); $object->fetch($id, $ref); $upload_dir = $conf->bank->dir_output.'/'.dol_sanitizeFileName($object->id); -$modulepart='banque'; +$modulepart = 'banque'; /* * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -125,11 +125,11 @@ if ($object->id) print '
    '; // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } print ''; @@ -146,8 +146,8 @@ if ($object->id) $modulepart = 'banque'; $permission = $user->rights->banque->modifier; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 602cd9142cf..ef88c586ede 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -31,20 +31,20 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; -$langs->loadLangs(array("install","cashdesk","admin","banks")); +$langs->loadLangs(array("install", "cashdesk", "admin", "banks")); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); $categid = GETPOST('categid'); $label = GETPOST("label"); -$now=dol_now(); -$syear = (GETPOSTISSET('closeyear')?GETPOST('closeyear', 'int'):dol_print_date($now, "%Y")); -$smonth = (GETPOSTISSET('closemonth')?GETPOST('closemonth', 'int'):dol_print_date($now, "%m")); -$sday = (GETPOSTISSET('closeday')?GETPOST('closeday', 'int'):dol_print_date($now, "%d")); +$now = dol_now(); +$syear = (GETPOSTISSET('closeyear') ?GETPOST('closeyear', 'int') : dol_print_date($now, "%Y")); +$smonth = (GETPOSTISSET('closemonth') ?GETPOST('closemonth', 'int') : dol_print_date($now, "%m")); +$sday = (GETPOSTISSET('closeday') ?GETPOST('closeday', 'int') : dol_print_date($now, "%d")); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -52,30 +52,30 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='rowid'; -if (! $sortorder) $sortorder='ASC'; +if (!$sortfield) $sortfield = 'rowid'; +if (!$sortorder) $sortorder = 'ASC'; // Security check -if (! $user->rights->cashdesk->use && ! $user->rights->takepos->use) +if (!$user->rights->cashdesk->use && !$user->rights->takepos->use) { accessforbidden(); } -$arrayofpaymentmode=array('cash'=>'Cash', 'cheque'=>'Cheque', 'card'=>'CreditCard'); +$arrayofpaymentmode = array('cash'=>'Cash', 'cheque'=>'Cheque', 'card'=>'CreditCard'); -$arrayofposavailable=array(); -if (! empty($conf->cashdesk->enabled)) $arrayofposavailable['cashdesk']=$langs->trans('CashDesk').' (cashdesk)'; -if (! empty($conf->takepos->enabled)) $arrayofposavailable['takepos']=$langs->trans('TakePOS').' (takepos)'; +$arrayofposavailable = array(); +if (!empty($conf->cashdesk->enabled)) $arrayofposavailable['cashdesk'] = $langs->trans('CashDesk').' (cashdesk)'; +if (!empty($conf->takepos->enabled)) $arrayofposavailable['takepos'] = $langs->trans('TakePOS').' (takepos)'; // TODO Add hook here to allow other POS to add themself -$object= new CashControl($db); +$object = new CashControl($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('cashcontrolcard','globalcard')); +$hookmanager->initHooks(array('cashcontrolcard', 'globalcard')); /* @@ -86,7 +86,7 @@ $permissiontoadd = ($user->rights->cashdesk->use || $user->rights->takepos->use) $permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use) || ($permissiontoadd && $object->status == 0); if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcontrol_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); $backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php', 1); -$triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record +$triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH1)) { @@ -99,70 +99,70 @@ if (GETPOST('cancel', 'alpha')) $action = 'create'; } -if ($action=="start") +if ($action == "start") { - $error=0; - if (! GETPOST('posmodule', 'alpha') || GETPOST('posmodule', 'alpha') == '-1') + $error = 0; + if (!GETPOST('posmodule', 'alpha') || GETPOST('posmodule', 'alpha') == '-1') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Module")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } if (GETPOST('posnumber', 'alpha') == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CashDesk")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } - if (! GETPOST('closeyear', 'alpha') || GETPOST('closeyear', 'alpha') == '-1') + if (!GETPOST('closeyear', 'alpha') || GETPOST('closeyear', 'alpha') == '-1') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Year")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } } -elseif ($action=="add") +elseif ($action == "add") { if (GETPOST('opening', 'alpha') == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InitialBankBalance")), null, 'errors'); - $action='start'; + $action = 'start'; $error++; } - $error=0; - foreach($arrayofpaymentmode as $key=>$val) + $error = 0; + foreach ($arrayofpaymentmode as $key=>$val) { $object->$key = price2num(GETPOST($key.'_amount', 'alpha')); } - if (! $error) + if (!$error) { $object->day_close = GETPOST('closeday', 'int'); $object->month_close = GETPOST('closemonth', 'int'); $object->year_close = GETPOST('closeyear', 'int'); - $object->opening=price2num(GETPOST('opening', 'alpha')); - $object->posmodule=GETPOST('posmodule', 'alpha'); - $object->posnumber=GETPOST('posnumber', 'alpha'); + $object->opening = price2num(GETPOST('opening', 'alpha')); + $object->posmodule = GETPOST('posmodule', 'alpha'); + $object->posnumber = GETPOST('posnumber', 'alpha'); $db->begin(); - $id=$object->create($user); + $id = $object->create($user); if ($id > 0) { $db->commit(); - $action="view"; + $action = "view"; } else { $db->rollback; - $action="view"; + $action = "view"; } } } -if ($action=="close") +if ($action == "close") { $object->fetch($id); @@ -176,21 +176,21 @@ if ($action=="close") setEventMessages($langs->trans("CashFenceDone"), null); } - $action="view"; + $action = "view"; } // Action to delete -if ($action == 'confirm_delete' && ! empty($permissiontodelete)) +if ($action == 'confirm_delete' && !empty($permissiontodelete)) { $object->fetch($id); - if (! ($object->id > 0)) + if (!($object->id > 0)) { dol_print_error('', 'Error, object must be fetched before being deleted'); exit; } - $result=$object->delete($user); + $result = $object->delete($user); //var_dump($result); if ($result > 0) { @@ -201,7 +201,7 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete)) } else { - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); else setEventMessages($object->error, null, 'errors'); } } @@ -211,15 +211,15 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete)) * View */ -$form=new Form($db); +$form = new Form($db); -if ($action=="create" || $action=="start") +if ($action == "create" || $action == "start") { llxHeader(); - $initialbalanceforterminal=array(); - $theoricalamountforterminal=array(); - $theoricalnbofinvoiceforterminal=array(); + $initialbalanceforterminal = array(); + $theoricalamountforterminal = array(); + $theoricalnbofinvoiceforterminal = array(); if (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1') { @@ -227,16 +227,16 @@ if ($action=="create" || $action=="start") $terminalid = GETPOST('posnumber', 'alpha'); $terminaltouse = $terminalid; - if ($terminaltouse == '1' && $posmodule=='cashdesk') $terminaltouse = ''; + if ($terminaltouse == '1' && $posmodule == 'cashdesk') $terminaltouse = ''; - if ($posmodule=='cashdesk' && $terminaltouse != '' && $terminaltouse != '1') { + if ($posmodule == 'cashdesk' && $terminaltouse != '' && $terminaltouse != '1') { $terminaltouse = ''; setEventMessages($langs->trans("OnlyTerminal1IsAvailableForCashDeskModule"), null, 'errors'); $error++; } // Calculate $initialbalanceforterminal for terminal 0 - foreach($arrayofpaymentmode as $key => $val) + foreach ($arrayofpaymentmode as $key => $val) { if ($key != 'cash') { @@ -245,18 +245,18 @@ if ($action=="create" || $action=="start") } // Get the bank account dedicated to this point of sale module/terminal - $vartouse='CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse; - $bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) + $vartouse = 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse; + $bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) // Hook to get the good bank id according to posmodule and posnumber. // @TODO add hook here if ($bankid > 0) { $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account = ".$bankid; - if ($syear && ! $smonth) $sql.= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; - elseif ($syear && $smonth && ! $sday) $sql.= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; - elseif ($syear && $smonth && $sday) $sql.= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; + $sql .= " WHERE fk_account = ".$bankid; + if ($syear && !$smonth) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; + elseif ($syear && $smonth && !$sday) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; + elseif ($syear && $smonth && $sday) $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; else dol_print_error('', 'Year not defined'); $resql = $db->query($sql); @@ -275,28 +275,28 @@ if ($action=="create" || $action=="start") } // Calculate $theoricalamountforterminal for terminal 0 - foreach($arrayofpaymentmode as $key => $val) + foreach ($arrayofpaymentmode as $key => $val) { /*$sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; $sql.= " WHERE fk_account = ".$bankid;*/ $sql = "SELECT SUM(pf.amount) as total, COUNT(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp"; - $sql.= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement"; - $sql.= " AND f.module_source = '".$db->escape($posmodule)."'"; - $sql.= " AND f.pos_source = '".$db->escape($terminalid)."'"; - $sql.= " AND f.paye = 1"; - $sql.= " AND p.entity IN (".getEntity('facture').")"; - if ($key == 'cash') $sql.=" AND cp.code = 'LIQ'"; - elseif ($key == 'cheque') $sql.=" AND cp.code = 'CHQ'"; - elseif ($key == 'card') $sql.=" AND cp.code = 'CB'"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp"; + $sql .= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement"; + $sql .= " AND f.module_source = '".$db->escape($posmodule)."'"; + $sql .= " AND f.pos_source = '".$db->escape($terminalid)."'"; + $sql .= " AND f.paye = 1"; + $sql .= " AND p.entity IN (".getEntity('facture').")"; + if ($key == 'cash') $sql .= " AND cp.code = 'LIQ'"; + elseif ($key == 'cheque') $sql .= " AND cp.code = 'CHQ'"; + elseif ($key == 'card') $sql .= " AND cp.code = 'CB'"; else { dol_print_error('Value for key = '.$key.' not supported'); exit; } - if ($syear && ! $smonth) $sql.= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; - elseif ($syear && $smonth && ! $sday) $sql.= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; - elseif ($syear && $smonth && $sday) $sql.= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; + if ($syear && !$smonth) $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; + elseif ($syear && $smonth && !$sday) $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; + elseif ($syear && $smonth && $sday) $sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; else dol_print_error('', 'Year not defined'); $resql = $db->query($sql); @@ -337,53 +337,53 @@ if ($action=="create" || $action=="start") print ''; print "\n"; - $disabled=0; - $prefix='close'; + $disabled = 0; + $prefix = 'close'; print ''; - print ''; + print ''; print ''; // Year print ''; // Month print ''; // Day print ''; // Button Start @@ -425,10 +425,10 @@ if ($action=="create" || $action=="start") print ''; - $i=0; - foreach($arrayofpaymentmode as $key => $val) + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) { - print ''; $i++; @@ -442,10 +442,10 @@ if ($action=="create" || $action=="start") print ''; // Amount per payment type - $i=0; - foreach($arrayofpaymentmode as $key => $val) + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) { - print ''; $i++; @@ -461,10 +461,10 @@ if ($action=="create" || $action=="start") print price($initialbalanceforterminal[$terminalid]['cash']).'
    '; print ''; // Amount per payment type - $i=0; - foreach($arrayofpaymentmode as $key => $val) + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) { - print ''; $i++; @@ -477,14 +477,14 @@ if ($action=="create" || $action=="start") print ''; // Initial amount print ''; // Amount per payment type - $i=0; - foreach($arrayofpaymentmode as $key => $val) + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) { - print ''; $i++; } @@ -500,23 +500,23 @@ if ($action=="create" || $action=="start") print ''; } -if (empty($action) || $action=="view") +if (empty($action) || $action == "view") { $object->fetch($id); llxHeader('', $langs->trans("CashControl")); - $head=array(); + $head = array(); $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; $head[0][1] = $langs->trans("Card"); $head[0][2] = 'cashcontrol'; dol_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'cashcontrol'); - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; - $morehtmlref.='
    '; + $morehtmlref = '
    '; + $morehtmlref .= '
    '; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); @@ -563,7 +563,7 @@ if (empty($action) || $action=="view") print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); print ""; - foreach($arrayofpaymentmode as $key => $val) + foreach ($arrayofpaymentmode as $key => $val) { print '"; print "\n"; @@ -671,8 +671,8 @@ if ($resql) } else { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index ff71b1ff9af..d211c04d375 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -64,13 +64,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, * View */ -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Notes'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Notes'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $object = new Facture($db); $object->fetch($id, $ref); @@ -85,50 +85,50 @@ if ($id > 0 || ! empty($ref)) // Invoice content - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'customer'); + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
    '.$langs->trans('Project') . ' '; + $morehtmlref .= '
    '.$langs->trans('Project').' '; if ($user->rights->facture->creer) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); @@ -136,7 +136,7 @@ if ($id > 0 || ! empty($ref)) print '
    '; - $cssclass="titlefield"; + $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; dol_fiche_end(); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index e0569878b57..f1cbb613b18 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -32,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } if (!$user->rights->facture->lire) accessforbidden(); @@ -95,7 +95,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - $action=''; + $action = ''; } if ($action == "delete") @@ -117,9 +117,9 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('StandingOrders'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('StandingOrders'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); @@ -135,7 +135,7 @@ if ($object->id > 0) { $selleruserevenustamp = $mysoc->useRevenueStamp(); - $totalpaye = $object->getSommePaiement(); + $totalpaye = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; @@ -146,10 +146,10 @@ if ($object->id > 0) //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - if ($object->paye) $resteapayer=0; - $resteapayeraffiche=$resteapayer; + if ($object->paye) $resteapayer = 0; + $resteapayeraffiche = $resteapayer; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -157,10 +157,10 @@ if ($object->id > 0) $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } - $absolute_discount=$object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount); - $absolute_creditnote=$object->thirdparty->getAvailableDiscounts('', $filtercreditnote); - $absolute_discount=price2num($absolute_discount, 'MT'); - $absolute_creditnote=price2num($absolute_creditnote, 'MT'); + $absolute_discount = $object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount); + $absolute_creditnote = $object->thirdparty->getAvailableDiscounts('', $filtercreditnote); + $absolute_discount = price2num($absolute_discount, 'MT'); + $absolute_creditnote = price2num($absolute_creditnote, 'MT'); $author = new User($db); if ($object->user_author) @@ -233,27 +233,27 @@ if ($object->id > 0) print $object->getLibType(); if ($object->type == Facture::TYPE_REPLACEMENT) { - $facreplaced=new Facture($db); + $facreplaced = new Facture($db); $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; } if ($object->type == Facture::TYPE_CREDIT_NOTE) { - $facusing=new Facture($db); + $facusing = new Facture($db); $facusing->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } - $facidavoir=$object->getListIdAvoirFromInvoice(); + $facidavoir = $object->getListIdAvoirFromInvoice(); if (count($facidavoir) > 0) { print ' ('.$langs->transnoentities("InvoiceHasAvoir"); - $i=0; - foreach($facidavoir as $id) + $i = 0; + foreach ($facidavoir as $id) { - if ($i==0) print ' '; + if ($i == 0) print ' '; else print ','; - $facavoir=new Facture($db); + $facavoir = new Facture($db); $facavoir->fetch($id); print $facavoir->getNomUrl(1); } @@ -274,7 +274,7 @@ if ($object->id > 0) $thirdparty = $object->thirdparty; $discount_type = 0; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?facid=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id); $cannotApplyDiscount = 1; include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; @@ -285,7 +285,7 @@ if ($object->id > 0) print '
    '.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable)>1?1:0)).''.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; - $array=array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6", 7=>"7", 8=>"8", 9=>"9"); - $selectedposnumber=0; $showempty=1; + $array = array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6", 7=>"7", 8=>"8", 9=>"9"); + $selectedposnumber = 0; $showempty = 1; if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') { - $selectedposnumber=1; $showempty=0; + $selectedposnumber = 1; $showempty = 0; } - print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber')?GETPOST('posnumber', 'int'):$selectedposnumber, $showempty); + print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); //print ''; print ''; - $retstring=''; - for ($year = $syear - 10; $year < $syear + 10 ; $year++) + $retstring = ''; + for ($year = $syear - 10; $year < $syear + 10; $year++) { - $retstring.=''; + $retstring .= ''; } - $retstring.="\n"; + $retstring .= "\n"; print $retstring; print ''; - $retstring=''; - $retstring.=''; - for ($month = 1 ; $month <= 12 ; $month++) + $retstring = ''; + $retstring .= ''; + for ($month = 1; $month <= 12; $month++) { - $retstring.='"; + $retstring .= '"; } - $retstring.=""; + $retstring .= ""; print $retstring; print ''; - $retstring=''; - $retstring.=''; - for ($day = 1 ; $day <= 31; $day++) + $retstring = ''; + $retstring .= ''; + for ($day = 1; $day <= 31; $day++) { - $retstring.=''; + $retstring .= ''; } - $retstring.=""; + $retstring .= ""; print $retstring; print ''.$langs->trans("Cash"); //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); print '
    '.$langs->trans($val); + print ''.$langs->trans($val); //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); print '
    '; print ''; + print ''; print $theoricalnbofinvoiceforterminal[$terminalid][$key]; print ''; + print ''; print price($theoricalamountforterminal[$terminalid][$key]).'
    '; print '
    '.$langs->trans("RealAmount").''; - print ''; + print ''; print ''; - print ''; + print ''; + print ''; print '
    '.$langs->trans($val).''; print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); @@ -578,12 +578,12 @@ if (empty($action) || $action=="view") dol_fiche_end(); print '
    '; - print ''; + print ''; if ($object->status == CashControl::STATUS_DRAFT) { - print ''; + print ''; - print ''; + print ''; } print '
    '; diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 72bb79545e5..0c0e3d1a99c 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -89,7 +89,7 @@ elseif ($action == 'swapstatut' && $user->rights->facture->creer) { if ($object->fetch($id)) { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { @@ -118,14 +118,14 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer) * View */ -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('ContactsAddresses'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); $form = new Form($db); $formcompany = new FormCompany($db); -$contactstatic=new Contact($db); -$userstatic=new User($db); +$contactstatic = new Contact($db); +$userstatic = new User($db); /* *************************************************************************** */ @@ -134,7 +134,7 @@ $userstatic=new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref) > 0) { @@ -201,10 +201,10 @@ if ($id > 0 || ! empty($ref)) print '
    '; // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach($dirtpls as $reldir) + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach ($dirtpls as $reldir) { - $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); if ($res) break; } } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 36f768991f8..91e6ab46c5a 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -63,14 +63,14 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; $object = new Facture($db); if ($object->fetch($id)) { $object->fetch_thirdparty(); - $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->facture->dir_output."/".dol_sanitizeFileName($object->ref); } @@ -78,20 +78,20 @@ if ($object->fetch($id)) * Actions */ -require_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* * View */ -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Documents'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Documents'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref) > 0) { @@ -105,60 +105,60 @@ if ($id > 0 || ! empty($ref)) $totalpaye = $object->getSommePaiement(); // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } // Invoice content - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'customer'); + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
    '.$langs->trans('Project') . ' '; + $morehtmlref .= '
    '.$langs->trans('Project').' '; if ($user->rights->facture->creer) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
    '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); @@ -178,8 +178,8 @@ if ($id > 0 || ! empty($ref)) $modulepart = 'facture'; $permission = $user->rights->facture->creer; $permtoedit = $user->rights->facture->creer; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 6769b184e40..36a2496bdcf 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -28,15 +28,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; -if (! empty($conf->projet->enabled)) { - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page $langs->loadLangs(array('companies', 'bills')); $id = GETPOST("facid", "int"); -$ref=GETPOST("ref", 'alpha'); +$ref = GETPOST("ref", 'alpha'); /* @@ -45,7 +45,7 @@ $ref=GETPOST("ref", 'alpha'); $form = new Form($db); -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Info'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); @@ -62,50 +62,50 @@ $totalpaye = $object->getSommePaiement(); // Invoice content -$linkback = '' . $langs->trans("BackToList") . ''; +$linkback = ''.$langs->trans("BackToList").''; -$morehtmlref='
    '; +$morehtmlref = '
    '; // Ref customer -$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); -$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); +$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); +$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty -$morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'customer'); +$morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // Project -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
    '.$langs->trans('Project') . ' '; + $morehtmlref .= '
    '.$langs->trans('Project').' '; if ($user->rights->facture->creer) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
    '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } -$morehtmlref.='
    '; +$morehtmlref .= '
    '; -$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status +$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 12e437e6110..3e8ea324fda 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -33,15 +33,15 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; //require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; } -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page $langs->loadLangs(array('bills', 'compta', 'admin', 'other')); @@ -104,19 +104,19 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add') } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('invoicereccard','globalcard')); +$hookmanager->initHooks(array('invoicereccard', 'globalcard')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('facture_rec'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $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 +$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 -$arrayfields=array( +$arrayfields = array( 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), 'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), @@ -137,10 +137,10 @@ $arrayfields=array( // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -151,8 +151,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -160,7 +160,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if (GETPOST('cancel', 'alpha')) $action=''; + if (GETPOST('cancel', 'alpha')) $action = ''; // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -168,24 +168,24 @@ if (empty($reshook)) // Do we click on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_ref=''; - $search_societe=''; - $search_montant_ht=''; - $search_montant_vat=''; - $search_montant_ttc=''; - $search_payment_mode=''; - $search_payment_term=''; - $search_day=''; - $search_year=''; - $search_month=''; - $search_day_date_when=''; - $search_year_date_when=''; - $search_month_date_when=''; - $search_recurring=''; - $search_frequency=''; - $search_unit_frequency=''; - $search_status=''; - $search_array_options=array(); + $search_ref = ''; + $search_societe = ''; + $search_montant_ht = ''; + $search_montant_vat = ''; + $search_montant_ttc = ''; + $search_payment_mode = ''; + $search_payment_term = ''; + $search_day = ''; + $search_year = ''; + $search_month = ''; + $search_day_date_when = ''; + $search_year_date_when = ''; + $search_month_date_when = ''; + $search_recurring = ''; + $search_frequency = ''; + $search_unit_frequency = ''; + $search_status = ''; + $search_array_options = array(); } // Mass actions @@ -247,22 +247,22 @@ if ($search_societe) $sql .= natural_search('s.nom', $search_societ if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); -if (! empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1); -if (! empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1); +if (!empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1); +if (!empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1); if ($search_recurring == '1') $sql .= ' AND f.frequency > 0'; if ($search_recurring == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; if ($search_frequency != '') $sql .= natural_search('f.frequency', $search_frequency, 1); if ($search_unit_frequency != '') $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency); if ($search_status != '' && $search_status >= -1) { - if ($search_status == 0) $sql.= ' AND frequency = 0 AND suspended = 0'; - if ($search_status == 1) $sql.= ' AND frequency != 0 AND suspended = 0'; - if ($search_status == -1) $sql.= ' AND suspended = 1'; + if ($search_status == 0) $sql .= ' AND frequency = 0 AND suspended = 0'; + if ($search_status == 1) $sql .= ' AND frequency != 0 AND suspended = 0'; + if ($search_status == -1) $sql .= ' AND suspended = 1'; } -$sql.=dolSqlDateFilter('f.date_last_gen', $search_day, $search_month, $search_year); -$sql.=dolSqlDateFilter('f.date_last_gen', $search_day_date_when, $search_month_date_when, $search_year_date_when); +$sql .= dolSqlDateFilter('f.date_last_gen', $search_day, $search_month, $search_year); +$sql .= dolSqlDateFilter('f.date_last_gen', $search_day_date_when, $search_month_date_when, $search_year_date_when); -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -276,43 +276,43 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($socid) $param.='&socid='.urlencode($socid); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year=' .urlencode($search_year); - if ($search_day_date_when) $param.='&search_day_date_when='.urlencode($search_day_date_when); - if ($search_month_date_when) $param.='&search_month_date_when='.urlencode($search_month_date_when); - if ($search_year_date_when) $param.='&search_year_date_when=' .urlencode($search_year_date_when); - if ($search_ref) $param.='&search_ref=' .urlencode($search_ref); - if ($search_societe) $param.='&search_societe=' .urlencode($search_societe); - if ($search_montant_ht != '') $param.='&search_montant_ht=' .urlencode($search_montant_ht); - if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); - if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode); - if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type); - if ($search_recurring != '' && $search_recurrning != '-1') $param.='&search_recurring=' .urlencode($search_recurring); - if ($search_frequency > 0) $param.='&search_frequency=' .urlencode($search_frequency); - if ($search_unit_frequency != '') $param.='&search_unit_frequency='.urlencode($search_unit_frequency); - if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if ($option) $param.="&option=".urlencode($option); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($socid) $param .= '&socid='.urlencode($socid); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_day_date_when) $param .= '&search_day_date_when='.urlencode($search_day_date_when); + if ($search_month_date_when) $param .= '&search_month_date_when='.urlencode($search_month_date_when); + if ($search_year_date_when) $param .= '&search_year_date_when='.urlencode($search_year_date_when); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); + if ($search_montant_ht != '') $param .= '&search_montant_ht='.urlencode($search_montant_ht); + if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); + if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); + if ($search_payment_mode != '') $param .= '&search_payment_mode='.urlencode($search_payment_mode); + if ($search_payment_type != '') $param .= '&search_payment_type='.urlencode($search_payment_type); + if ($search_recurring != '' && $search_recurrning != '-1') $param .= '&search_recurring='.urlencode($search_recurring); + if ($search_frequency > 0) $param .= '&search_frequency='.urlencode($search_frequency); + if ($search_unit_frequency != '') $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); + if ($option) $param .= "&option=".urlencode($option); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); + $massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
    '; @@ -661,7 +661,7 @@ if ($resql) { print " "; } - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "
    '.$langs->trans("NoRecordFound").'
    '; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
    '; print $langs->trans('DateInvoice'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'id.'">'.img_edit($langs->trans('SetDate'), 1).'
    '; print '
    '; @@ -312,7 +312,7 @@ if ($object->id > 0) print ''; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
    '; print $langs->trans('PaymentConditionsShort'); print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
    '; print '
    '; if ($object->type != Facture::TYPE_CREDIT_NOTE) @@ -337,7 +337,7 @@ if ($object->id > 0) print ''; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
    '; print $langs->trans('DateMaxPayment'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'id.'">'.img_edit($langs->trans('SetDate'), 1).'
    '; print '
    '; if ($object->type != Facture::TYPE_CREDIT_NOTE) @@ -365,7 +365,7 @@ if ($object->id > 0) print ''; - if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($action != 'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
    '; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'id.'">'.img_edit($langs->trans('SetMode'), 1).'
    '; print '
    '; if ($action == 'editmode') @@ -383,7 +383,7 @@ if ($object->id > 0) print ''; print '
    '; print $langs->trans('BankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon)) + if (($action != 'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon)) print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
    '; print '
    '; @@ -414,39 +414,39 @@ if ($object->id > 0) if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print '
    ' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    '.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    ' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    '.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    ' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    '.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    ' . $langs->trans('AmountHT') . '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->trans('AmountHT').''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
    ' . $langs->trans('AmountVAT') . '' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->trans('AmountVAT').''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'
    ' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
    ' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
    '; - if ($action != 'editrevenuestamp' && ! empty($object->brouillon) && $user->rights->facture->creer) + if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer) { - print ''; + print ''; } print '
    '; print $langs->trans('RevenueStamp'); print 'id . '">' . img_edit($langs->trans('SetRevenuStamp'), 1) . 'id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'
    '; print '
    '; @@ -467,7 +467,7 @@ if ($object->id > 0) } // Total with tax - print '
    ' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->trans('AmountTTC').''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'
    '; if ($obj->fk_prelevement_bons > 0) { - $withdrawreceipt=new BonPrelevement($db); - $withdrawreceipt->id=$obj->fk_prelevement_bons; - $withdrawreceipt->ref=$obj->ref; + $withdrawreceipt = new BonPrelevement($db); + $withdrawreceipt->id = $obj->fk_prelevement_bons; + $withdrawreceipt->ref = $obj->ref; print $withdrawreceipt->getNomUrl(1); } print "
    '.$langs->trans("None").'
    '; - $out.= $langs->trans($this->attributes[$object->table_element]['label'][$key]); - $out.= '
    '; + print '
    '; print ''; - print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1); - print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1); + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1); + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1); print ''; print "\n"; if (is_array($listofactions) && count($listofactions)) { - $cacheusers=array(); + $cacheusers = array(); $cursorevent = 0; - foreach($listofactions as $action) + foreach ($listofactions as $action) { if ($max && $cursorevent >= $max) break; - $ref=$action->getNomUrl(1, -1); - $label=$action->getNomUrl(0, 38); + $ref = $action->getNomUrl(1, -1); + $label = $action->getNomUrl(0, 38); print ''; // Ref print ''; // Onwer print ''; // Type print ''; // Ref - print ''; + print ''; // Label print ''; // Date start @@ -856,7 +856,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel */ function show_contacts($conf, $langs, $db, $object, $backtopage = '') { - global $user,$conf,$extrafields,$hookmanager; + global $user, $conf, $extrafields, $hookmanager; global $contextpage; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -869,12 +869,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $page = GETPOST('page', 'int'); $search_status = GETPOST("search_status", 'int'); - if ($search_status=='') $search_status=1; // always display active customer first + if ($search_status == '') $search_status = 1; // always display active customer first $search_name = GETPOST("search_name", 'alpha'); $search_address = GETPOST("search_address", 'alpha'); $search_poste = GETPOST("search_poste", 'alpha'); - $search_roles = GETPOST("search_roles", 'array'); + $search_roles = GETPOST("search_roles", 'array'); $socialnetworks = getArrayOfSocialNetworks(); @@ -902,10 +902,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } } - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="t.lastname"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "t.lastname"; - if (! empty($conf->clicktodial->enabled)) + if (!empty($conf->clicktodial->enabled)) { $user->fetch_clicktodial(); // lecture des infos de clicktodial du user } @@ -935,59 +935,59 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') // Extra fields if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) { - foreach($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) { - $arrayfields["ef.".$key]=array( + if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) { + $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key]<0)?0:1), - 'position'=>1000+$extrafields->attributes[$contactstatic->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key])); + 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key] < 0) ? 0 : 1), + 'position'=>1000 + $extrafields->attributes[$contactstatic->table_element]['pos'][$key], + 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key])); } } } // Initialize array of search criterias - $search=array(); - foreach($arrayfields as $key => $val) + $search = array(); + foreach ($arrayfields as $key => $val) { $queryName = 'search_'.substr($key, 2); - if (GETPOST($queryName, 'alpha')){ - $search[substr($key, 2)]=GETPOST($queryName, 'alpha'); + if (GETPOST($queryName, 'alpha')) { + $search[substr($key, 2)] = GETPOST($queryName, 'alpha'); } } - $search_array_options=$extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_'); + $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_'); // 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 + 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_status = ''; + $search_status = ''; $search_name = ''; $search_roles = array(); $search_address = ''; $search_poste = ''; $search = array(); - $search_array_options=array(); + $search_array_options = array(); - foreach($contactstatic->fields as $key => $val) + foreach ($contactstatic->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } } $contactstatic->fields = dol_sort_array($contactstatic->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->societe->contact->creer) { - $addcontact = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); - $newcardbutton.= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); + $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $newcardbutton .= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); } print "\n"; - $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany")); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany")); print load_fiche_titre($title, $newcardbutton, ''); print ''; @@ -998,23 +998,23 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print ''; print ''; - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print "\n".'
    '.$ref.''; - if (! empty($action->userownerid)) + if (!empty($action->userownerid)) { if (is_object($cacheusers[$action->userownerid])) { @@ -262,17 +262,17 @@ class FormActions print ''; - $imgpicto=''; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + $imgpicto = ''; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); + if ($action->type_picto) $imgpicto = img_picto('', $action->type_picto); else { - if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; - elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; - elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; - elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; - elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; - elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; + if ($action->type_code == 'AC_RDV') $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; + elseif ($action->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; + elseif ($action->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; + elseif ($action->type_code == 'AC_EMAIL') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; + elseif ($action->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; + elseif (!preg_match('/_AUTO/', $action->type_code)) $imgpicto = img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; } } print $imgpicto; @@ -284,8 +284,8 @@ class FormActions print ''.dol_print_date($action->datep, 'dayhour', 'tzuserrel'); if ($action->datef) { - $tmpa=dol_getdate($action->datep); - $tmpb=dol_getdate($action->datef); + $tmpa = dol_getdate($action->datep); + $tmpb = dol_getdate($action->datef); if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); @@ -335,39 +335,39 @@ class FormActions public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0) { // phpcs:enable - global $langs,$user,$form,$conf; + global $langs, $user, $form, $conf; - if (! is_object($form)) $form=new Form($this->db); + if (!is_object($form)) $form = new Form($this->db); require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $caction=new CActionComm($this->db); + $caction = new CActionComm($this->db); // Suggest a list with manual events or all auto events - $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); - array_unshift($arraylist, ' '); // Add empty line at start + $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot); + array_unshift($arraylist, ' '); // Add empty line at start //asort($arraylist); - if ($selected == 'manual') $selected='AC_OTH'; - if ($selected == 'auto') $selected='AC_OTH_AUTO'; + if ($selected == 'manual') $selected = 'AC_OTH'; + if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); - $out=''; + $out = ''; - if (! empty($multiselect)) + if (!empty($multiselect)) { if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); - $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); + $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); } else { - $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); + $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); } if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) { - $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); } if ($nooutput) return $out; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 76b9d07a2c4..759b7cc4c0d 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -46,17 +46,17 @@ class FormCompany extends Form public function typent_array($mode = 0, $filter = '') { // phpcs:enable - global $langs,$mysoc; + global $langs, $mysoc; $effs = array(); $sql = "SELECT id, code, libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; - $sql.= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id)?'0':$mysoc->country_id).")"; - if ($filter) $sql.=" ".$filter; - $sql.= " ORDER by position, id"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_typent"; + $sql .= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id) ? '0' : $mysoc->country_id).")"; + if ($filter) $sql .= " ".$filter; + $sql .= " ORDER by position, id"; dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -65,11 +65,11 @@ class FormCompany extends Form while ($i < $num) { $objp = $this->db->fetch_object($resql); - if (! $mode) $key=$objp->id; - else $key=$objp->code; + if (!$mode) $key = $objp->id; + else $key = $objp->code; if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); else $effs[$key] = $objp->libelle; - if ($effs[$key]=='-') $effs[$key]=''; + if ($effs[$key] == '-') $effs[$key] = ''; $i++; } $this->db->free($resql); @@ -93,11 +93,11 @@ class FormCompany extends Form $sql = "SELECT id, code, libelle"; $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; - $sql.= " WHERE active = 1"; - if ($filter) $sql.=" ".$filter; + $sql .= " WHERE active = 1"; + if ($filter) $sql .= " ".$filter; $sql .= " ORDER BY id ASC"; dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -106,10 +106,10 @@ class FormCompany extends Form while ($i < $num) { $objp = $this->db->fetch_object($resql); - if (! $mode) $key=$objp->id; - else $key=$objp->code; + if (!$mode) $key = $objp->id; + else $key = $objp->code; - $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; + $effs[$key] = $objp->libelle != '-' ? $objp->libelle : ''; $i++; } $this->db->free($resql); @@ -139,9 +139,9 @@ class FormCompany extends Form dol_syslog(get_class($this).'::form_prospect_level', LOG_DEBUG); $sql = "SELECT code, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; - $sql.= " WHERE active > 0"; - $sql.= " ORDER BY sortorder"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; + $sql .= " WHERE active > 0"; + $sql .= " ORDER BY sortorder"; $resql = $this->db->query($sql); if ($resql) { @@ -164,7 +164,7 @@ class FormCompany extends Form print Form::selectarray($htmlname, $options, $selected); } else dol_print_error($this->db); - if (! empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if (!empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; print ''; } @@ -203,88 +203,88 @@ class FormCompany extends Form public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id') { // phpcs:enable - global $conf,$langs,$user; + global $conf, $langs, $user; dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG); $langs->load("dict"); - $out=''; + $out = ''; // Serch departements/cantons/province active d'une region et pays actif $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM"; - $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; + $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; - if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; + if ($country_codeid && !is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; $sql .= " ORDER BY c.code, d.code_departement"; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { - if (!empty($htmlname)) $out.= ''; + if ($country_codeid) $out .= ''; $num = $this->db->num_rows($result); $i = 0; dol_syslog(get_class($this)."::select_departement num=".$num, LOG_DEBUG); if ($num) { - $country=''; + $country = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); if ($obj->code == '0') // Le code peut etre une chaine { - $out.= ''; + $out .= ''; } else { - if (! $country || $country != $obj->country) + if (!$country || $country != $obj->country) { // Affiche la rupture si on est en mode liste multipays - if (! $country_codeid && $obj->country_code) + if (!$country_codeid && $obj->country_code) { - $out.= '\n"; - $country=$obj->country; + $out .= '\n"; + $country = $obj->country; } } - if ((! empty($selected) && $selected == $obj->rowid) - || (empty($selected) && ! empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) + if ((!empty($selected) && $selected == $obj->rowid) + || (empty($selected) && !empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) { - $out.= ''; + $out .= ''; } $i++; } } - if (! empty($htmlname)) $out.= ''; - if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if (!empty($htmlname)) $out .= ''; + if (!empty($htmlname) && $user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } else { @@ -292,9 +292,9 @@ class FormCompany extends Form } // Make select dynamic - if (! empty($htmlname)) + if (!empty($htmlname)) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); } @@ -316,16 +316,16 @@ class FormCompany extends Form public function select_region($selected = '', $htmlname = 'region_id') { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $langs->load("dict"); $sql = "SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; - $sql.= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; - $sql.= " ORDER BY c.code, c.label ASC"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; + $sql .= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; + $sql .= " ORDER BY c.code, c.label ASC"; dol_syslog(get_class($this)."::select_region", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { print ''; - $out.= ''; + $out .= ''; - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= ''; + if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } else { @@ -460,10 +460,10 @@ class FormCompany extends Form public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code') { // phpcs:enable - global $conf,$langs,$user; + global $conf, $langs, $user; $langs->load("dict"); - $out=''; + $out = ''; // On recherche les formes juridiques actives des pays actifs $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code"; @@ -475,70 +475,70 @@ class FormCompany extends Form $sql .= " ORDER BY c.code"; dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $out.= '
    '; - $out.= ''; + if ($country_codeid) $out .= ''; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. $num = $this->db->num_rows($resql); if ($num) { $i = 0; - $country=''; $arraydata=array(); + $country = ''; $arraydata = array(); while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj->code) // We exclude empty line, we will add it later { - $labelcountry=(($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); - $labeljs=(($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label!='-'?$obj->label:'')); // $obj->label is already in output charset (converted by database driver) - $arraydata[$obj->code]=array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); + $labelcountry = (($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); + $labeljs = (($langs->trans("JuridicalStatus".$obj->code) != "JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label != '-' ? $obj->label : '')); // $obj->label is already in output charset (converted by database driver) + $arraydata[$obj->code] = array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); } $i++; } - $arraydata=dol_sort_array($arraydata, 'label_sort', 'ASC'); + $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC'); if (empty($country_codeid)) // Introduce empty value (if $country_codeid not empty, empty value was already added) { - $arraydata[0]=array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); + $arraydata[0] = array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); } - foreach($arraydata as $key => $val) + foreach ($arraydata as $key => $val) { - if (! $country || $country != $val['country']) + if (!$country || $country != $val['country']) { // Show break when we are in multi country mode if (empty($country_codeid) && $val['country_code']) { - $out.= '\n"; - $country=$val['country']; + $out .= '\n"; + $country = $val['country']; } } if ($selected > 0 && $selected == $val['code']) { - $out.= ''; + $out .= $val['label']; + $out .= ''; } } - $out.= ''; - if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= ''; + if ($user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); // Make select dynamic - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); - $out.= '
    '; + $out .= ''; } else { @@ -566,15 +566,15 @@ class FormCompany extends Form { global $conf, $langs; - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) { // Use Ajax search - $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); + $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2); - $socid=0; $name=''; + $socid = 0; $name = ''; if ($selected > 0) { - $tmpthirdparty=new Societe($this->db); + $tmpthirdparty = new Societe($this->db); $result = $tmpthirdparty->fetch($selected); if ($result > 0) { @@ -584,13 +584,13 @@ class FormCompany extends Form } - $events=array(); + $events = array(); // Add an entry 'method' to say 'yes, we must execute url with param action = method'; // Add an entry 'url' to say which url to execute // Add an entry htmlname to say which element we must change once url is called // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines // To refresh contacts list on thirdparty list change - $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); + $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events { @@ -646,29 +646,29 @@ class FormCompany extends Form print "\n".''."\n"; print ''; - print ajax_autocompleter(($socid?$socid:-1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); + print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); return $socid; } else { // Search to list thirdparties $sql = "SELECT s.rowid, s.nom as name FROM"; - $sql.= " ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.entity IN (".getEntity('societe').")"; + $sql .= " ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; // For ajax search we limit here. For combo list, we limit later if (is_array($limitto) && count($limitto)) { - $sql.= " AND s.rowid IN (".join(',', $limitto).")"; + $sql .= " AND s.rowid IN (".join(',', $limitto).")"; } - $sql.= " ORDER BY s.nom ASC"; + $sql .= " ORDER BY s.nom ASC"; $resql = $this->db->query($sql); if ($resql) { - print '\n"; @@ -729,9 +729,9 @@ class FormCompany extends Form if (is_object($object) && method_exists($object, 'liste_type_contact')) { $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); - print ''; if ($showempty) print ''; - foreach($lesTypes as $key=>$value) + foreach ($lesTypes as $key=>$value) { print ''; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } - $out .= ''; - } elseif ($typeinput=='list') { - $out .= ''; + $out .= ''; + } elseif ($typeinput == 'list') { + $out .= ''; if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - $out .= ''; + $out .= ''; } - $out .= ''; - $out .= ''; - } elseif ($typeinput=='admin') { + $out .= ''; + $out .= ''; + } elseif ($typeinput == 'admin') { if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } } $out .= ''; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 2ad3a190cfc..a21f06dacfe 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -22,12 +22,12 @@ * \ingroup ticket * \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire */ -require_once DOL_DOCUMENT_ROOT . "/core/class/html.form.class.php"; -require_once DOL_DOCUMENT_ROOT . "/core/class/html.formmail.class.php"; -require_once DOL_DOCUMENT_ROOT . "/core/class/html.formprojet.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.formmail.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.formprojet.class.php"; if (!class_exists('FormCompany')) { - include DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; + include DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; } /** @@ -117,7 +117,7 @@ class FormTicket $this->withcreatereadonly = 1; $this->withemail = 0; $this->withref = 0; - $this->withextrafields = 0; // Show extrafields or not + $this->withextrafields = 0; // Show extrafields or not //$this->withtopicreadonly=0; } @@ -152,26 +152,26 @@ class FormTicket if ($withdolfichehead) dol_fiche_head(null, 'card', '', 0, ''); - print '
    '; - print ''; - print ''; + print ''; + print ''; + print ''; foreach ($this->param as $key => $value) { - print ''; + print ''; } - print ''; + print ''; print ''; if ($this->withref) { // Ref $defaultref = $ticketstat->getDefaultRef(); - print ''; + print ''; } // TITLE if ($this->withemail) { - print ''; } @@ -184,7 +184,7 @@ class FormTicket $subelement = $regs[2]; } - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($this->db); $objectsrc->fetch(GETPOST('originid', 'int')); @@ -195,53 +195,53 @@ class FormTicket $objectsrc->fetch_thirdparty(); $newclassname = $classname; - print ''; + print ''; } // Type - print ''; // Severity - print ''; // Group - print ''; // Subject if ($this->withtitletopic) { - print ''; } else { if ($this->withthreadid > 0) { - $subject = $langs->trans('SubjectAnswerToTicket') . ' ' . $this->withthreadid . ' : ' . $this->topic_title . ''; + $subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withthreadid.' : '.$this->topic_title.''; } - print ''; + print ''; print ''; } } // MESSAGE $msg = GETPOSTISSET('message') ? GETPOST('message', 'none') : ''; - print ''; - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) { + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) { $htmlname = 'socid'; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; foreach ($this->param as $key => $value) { - print ''; + print ''; } // Get message template - $model_id=0; + $model_id = 0; if (array_key_exists('models_id', $this->param)) { - $model_id=$this->param["models_id"]; - $arraydefaultmessage=$formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); + $model_id = $this->param["models_id"]; + $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); } $result = $formmail->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); - if ($result<0) { + if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); } - $modelmail_array=array(); + $modelmail_array = array(); foreach ($formmail->lines_model as $line) { - $modelmail_array[$line->id]=$line->label; + $modelmail_array[$line->id] = $line->label; } - print '
    ' . $langs->trans("Ref") . '
    '.$langs->trans("Ref").'
    '; - print ''; + print '
    '; + print ''; print '
    ' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
    '.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
    '; + print '
    '; $this->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $this->type_code), 'type_code', '', '2'); print '
    '; + print '
    '; $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2'); print '
    '; + print '
    '; $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', '2'); print '
    '; + print '
    '; // Réponse à un ticket : affichage du titre du thread en readonly if ($this->withtopicreadonly) { - print $langs->trans('SubjectAnswerToTicket') . ' ' . $this->topic_title; + print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title; print '
    '; + print '
    '; // If public form, display more information $toolbarname = 'dolibarr_notes'; if ($this->ispublic) { $toolbarname = 'dolibarr_details'; - print '
    ' . ($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')) . '
    '; + print '
    '.($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')).'
    '; } - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $uselocalbrowser = true; $doleditor = new DolEditor('message', $msg, '100%', 230, $toolbarname, 'In', true, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_TICKET, ROWS_8, '90%'); $doleditor->Create(); @@ -249,7 +249,7 @@ class FormTicket // FK_USER_CREATE if ($this->withusercreate > 0 && $this->fk_user_create) { - print '
    ' . $langs->trans("CreatedBy") . ''; + print '
    '.$langs->trans("CreatedBy").''; $langs->load("users"); $fuser = new User($this->db); @@ -267,12 +267,12 @@ class FormTicket // altairis: force company and contact id for external user if (empty($user->socid)) { // Company - print '
    ' . $langs->trans("ThirdParty") . ''; + print '
    '.$langs->trans("ThirdParty").''; $events = array(); $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events, 0, 'minwidth200'); print '
    '; + print '
    '; // External users can't send message email if ($user->rights->ticket->write && !$user->socid) @@ -891,11 +891,11 @@ class FormTicket print ''; // Zone to select its email template - if (count($modelmail_array)>0) { + if (count($modelmail_array) > 0) { print ''; } - print ''; + print ''; $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE; - print ''; // Destinataires - print ''; @@ -972,10 +972,10 @@ class FormTicket // External users can't send message email if ($user->rights->ticket->write && !$user->socid) { $mail_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO; - print ''; - $out .= ''; + $out .= ''; $out .= '\n"; @@ -1075,10 +1075,10 @@ class FormTicket print '
    '; $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : ''); print ' '; - print ''; + print ''; print '
    '; $checkbox_selected = (GETPOST('private_message', 'alpha') == "1" ? ' checked' : ''); print ' '; - print ''; + print ''; print ''; print $form->textwithpicto('', $langs->trans("TicketMessagePrivateHelp"), 1, 'help'); print '
    '; + print '
    '; //$toolbarname = 'dolibarr_details'; $toolbarname = 'dolibarr_notes'; - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('message', $defaultmessage, '100%', 200, $toolbarname, '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, 70); $doleditor->Create(); print ''; @@ -1025,10 +1025,10 @@ class FormTicket // External users can't send message email if ($user->rights->ticket->write && !$user->socid) { $mail_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; - print '
    ' . $langs->trans("MailFile") . ''.$langs->trans("MailFile").''; // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out .= '' . "\n"; + $out .= ''."\n"; $out .= '' . "\n"; + $out .= ''."\n"; if (count($listofpaths)) { foreach ($listofpaths as $key => $val) { - $out .= '
    '; - $out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key]; + $out .= '
    '; + $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; if (!$this->withfilereadonly) { - $out .= ' '; + $out .= ' '; } $out .= '
    '; } } else { - $out .= $langs->trans("NoAttachedFiles") . '
    '; + $out .= $langs->trans("NoAttachedFiles").'
    '; } if ($this->withfile == 2) { // Can add other files - $out .= ''; + $out .= ''; $out .= ' '; - $out .= ''; + $out .= ''; } $out .= "
    '; print '

    '; - print ''; + print ''; if ($this->withcancel) { print "     "; - print "trans("Cancel") . "\">"; + print "trans("Cancel")."\">"; } print "
    \n"; diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 4ff061933e9..de00ea85e6f 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -94,29 +94,29 @@ class InfoBox { global $conf; - $boxes=array(); + $boxes = array(); - $confuserzone='MAIN_BOXES_'.$zone; + $confuserzone = 'MAIN_BOXES_'.$zone; if ($mode == 'activated') // activated { $sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,"; - $sql.= " d.rowid as box_id, d.file, d.note, d.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; - $sql.= " WHERE b.box_id = d.rowid"; - $sql.= " AND b.entity IN (0,".$conf->entity.")"; - if ($zone >= 0) $sql.= " AND b.position = ".$zone; - if (is_object($user)) $sql.= " AND b.fk_user IN (0,".$user->id.")"; - else $sql.= " AND b.fk_user = 0"; - $sql.= " ORDER BY b.box_order"; + $sql .= " d.rowid as box_id, d.file, d.note, d.tms"; + $sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; + $sql .= " WHERE b.box_id = d.rowid"; + $sql .= " AND b.entity IN (0,".$conf->entity.")"; + if ($zone >= 0) $sql .= " AND b.position = ".$zone; + if (is_object($user)) $sql .= " AND b.fk_user IN (0,".$user->id.")"; + else $sql .= " AND b.fk_user = 0"; + $sql .= " ORDER BY b.box_order"; } else // available { $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; - $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; + $sql .= " WHERE d.entity IN (0,".$conf->entity.")"; } - dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); + dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user) ? $user->id : '')."", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -126,7 +126,7 @@ class InfoBox { $obj = $db->fetch_object($resql); - if (! in_array($obj->box_id, $excludelist)) + if (!in_array($obj->box_id, $excludelist)) { if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) { @@ -136,7 +136,7 @@ class InfoBox } else { - $boxname=preg_replace('/\.php$/i', '', $obj->file); + $boxname = preg_replace('/\.php$/i', '', $obj->file); $relsourcefile = "/core/boxes/".$boxname.".php"; } @@ -148,48 +148,48 @@ class InfoBox dol_include_once($relsourcefile); if (class_exists($boxname)) { - $box=new $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. + $box = new $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. //$box=new stdClass(); // box properties - $box->rowid = (empty($obj->rowid) ? '' : $obj->rowid); - $box->id = (empty($obj->box_id) ? '' : $obj->box_id); - $box->position = ($obj->position == '' ? '' : $obj->position); // '0' must stay '0' + $box->rowid = (empty($obj->rowid) ? '' : $obj->rowid); + $box->id = (empty($obj->box_id) ? '' : $obj->box_id); + $box->position = ($obj->position == '' ? '' : $obj->position); // '0' must stay '0' $box->box_order = (empty($obj->box_order) ? '' : $obj->box_order); - $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); - $box->sourcefile= $relsourcefile; + $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); + $box->sourcefile = $relsourcefile; $box->class = $boxname; - if ($mode == 'activated' && ! is_object($user)) // List of activated box was not yet personalized into database + if ($mode == 'activated' && !is_object($user)) // List of activated box was not yet personalized into database { if (is_numeric($box->box_order)) { - if ($box->box_order % 2 == 1) $box->box_order='A'.$box->box_order; - elseif ($box->box_order % 2 == 0) $box->box_order='B'.$box->box_order; + if ($box->box_order % 2 == 1) $box->box_order = 'A'.$box->box_order; + elseif ($box->box_order % 2 == 0) $box->box_order = 'B'.$box->box_order; } } // box_def properties - $box->box_id = (empty($obj->box_id) ? '' : $obj->box_id); - $box->note = (empty($obj->note) ? '' : $obj->note); + $box->box_id = (empty($obj->box_id) ? '' : $obj->box_id); + $box->note = (empty($obj->note) ? '' : $obj->note); // Filter on box->enabled (used for example by box_comptes) // Filter also on box->depends. Example: array("product|service") or array("contrat", "service") - $enabled=$box->enabled; + $enabled = $box->enabled; if (isset($box->depends) && count($box->depends) > 0) { - foreach($box->depends as $moduleelem) + foreach ($box->depends as $moduleelem) { - $arrayelem=explode('|', $moduleelem); - $tmpenabled=0; // $tmpenabled is used for the '|' test (OR) - foreach($arrayelem as $module) + $arrayelem = explode('|', $moduleelem); + $tmpenabled = 0; // $tmpenabled is used for the '|' test (OR) + foreach ($arrayelem as $module) { - $tmpmodule=preg_replace('/@[^@]+/', '', $module); - if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; + $tmpmodule = preg_replace('/@[^@]+/', '', $module); + if (!empty($conf->$tmpmodule->enabled)) $tmpenabled = 1; //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'
    '; } if (empty($tmpenabled)) // We found at least one module required that is disabled { - $enabled=0; + $enabled = 0; break; } } @@ -197,7 +197,7 @@ class InfoBox //print '=>'.$boxname.'-enabled='.$enabled.'
    '; //print 'xx module='.$module.' enabled='.$enabled; - if ($enabled && ($includehidden || empty($box->hidden))) $boxes[]=$box; + if ($enabled && ($includehidden || empty($box->hidden))) $boxes[] = $box; else unset($box); } else @@ -231,66 +231,66 @@ class InfoBox { global $conf; - $error=0; + $error = 0; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; dol_syslog(get_class()."::saveboxorder zone=".$zone." userid=".$userid); - if (! $userid || $userid == 0) return 0; + if (!$userid || $userid == 0) return 0; $user = new User($db); - $user->id=$userid; + $user->id = $userid; $db->begin(); // Save parameters to say user has a dedicated setup - $tab=array(); - $confuserzone='MAIN_BOXES_'.$zone; - $tab[$confuserzone]=1; + $tab = array(); + $confuserzone = 'MAIN_BOXES_'.$zone; + $tab[$confuserzone] = 1; if (dol_set_user_param($db, $conf, $user, $tab) < 0) { - $error=$db->lasterror(); + $error = $db->lasterror(); $db->rollback(); return -3; } // Delete all lines $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " AND fk_user = ".$userid; - $sql.= " AND position = ".$zone; + $sql .= " WHERE entity = ".$conf->entity; + $sql .= " AND fk_user = ".$userid; + $sql .= " AND position = ".$zone; dol_syslog(get_class()."::saveboxorder", LOG_DEBUG); $result = $db->query($sql); if ($result) { - $colonnes=explode('-', $boxorder); + $colonnes = explode('-', $boxorder); foreach ($colonnes as $collist) { - $part=explode(':', $collist); - $colonne=$part[0]; - $list=$part[1]; + $part = explode(':', $collist); + $colonne = $part[0]; + $list = $part[1]; dol_syslog(get_class()."::saveboxorder column=".$colonne.' list='.$list); - $i=0; - $listarray=explode(',', $list); + $i = 0; + $listarray = explode(',', $list); foreach ($listarray as $id) { if (is_numeric($id)) { //dol_syslog("aaaaa".count($listarray)); $i++; - $ii=sprintf('%02d', $i); + $ii = sprintf('%02d', $i); $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes"; - $sql.= "(box_id, position, box_order, fk_user, entity)"; - $sql.= " values ("; - $sql.= " ".$id.","; - $sql.= " ".$zone.","; - $sql.= " '".$colonne.$ii."',"; - $sql.= " ".$userid.","; - $sql.= " ".$conf->entity; - $sql.= ")"; + $sql .= "(box_id, position, box_order, fk_user, entity)"; + $sql .= " values ("; + $sql .= " ".$id.","; + $sql .= " ".$zone.","; + $sql .= " '".$colonne.$ii."',"; + $sql .= " ".$userid.","; + $sql .= " ".$conf->entity; + $sql .= ")"; dol_syslog(get_class()."::saveboxorder", LOG_DEBUG); $result = $db->query($sql); @@ -304,7 +304,7 @@ class InfoBox } if ($error) { - $error=$db->error(); + $error = $db->error(); $db->rollback(); return -2; } @@ -316,7 +316,7 @@ class InfoBox } else { - $error=$db->lasterror(); + $error = $db->lasterror(); $db->rollback(); dol_syslog(get_class()."::saveboxorder ".$error); return -1; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2af03656a64..3a9efd14c61 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -55,7 +55,7 @@ function societe_prepare_head(Societe $object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); - $nbContact = 0; // TODO + $nbContact = 0; // TODO $sql = "SELECT COUNT(p.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; @@ -104,7 +104,7 @@ function societe_prepare_head(Societe $object) $h++; } } - if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) + if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; $head[$h][1] = $langs->trans("Supplier"); @@ -112,16 +112,16 @@ function societe_prepare_head(Societe $object) $h++; } - if (! empty($conf->projet->enabled) && (!empty($user->rights->projet->lire) )) + if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) { $head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id; $head[$h][1] = $langs->trans("Projects"); $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as n"; - $sql.= " WHERE fk_soc = ".$object->id; - $sql.= " AND entity IN (".getEntity('project').")"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."projet as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $sql .= " AND entity IN (".getEntity('project').")"; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -150,10 +150,10 @@ function societe_prepare_head(Societe $object) $h++; } - if (! empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) + if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { // Tab to accountancy - if (! empty($conf->accounting->enabled) && $object->client>0) + if (!empty($conf->accounting->enabled) && $object->client > 0) { $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_customer.php?socid='.$object->id; $head[$h][1] = $langs->trans("TabLetteringCustomer"); @@ -162,7 +162,7 @@ function societe_prepare_head(Societe $object) } // Tab to accountancy - if (! empty($conf->accounting->enabled) && $object->fournisseur>0) + if (!empty($conf->accounting->enabled) && $object->fournisseur > 0) { $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_supplier.php?socid='.$object->id; $head[$h][1] = $langs->trans("TabLetteringSupplier"); @@ -172,7 +172,7 @@ function societe_prepare_head(Societe $object) } // Related items - if ((! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->ficheinter->enabled) || ! empty($conf->fournisseur->enabled)) + if ((!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->fournisseur->enabled)) && empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) { $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; @@ -184,31 +184,31 @@ function societe_prepare_head(Societe $object) // Bank accounts if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) { - $nbBankAccount=0; - $foundonexternalonlinesystem=0; + $nbBankAccount = 0; + $foundonexternalonlinesystem = 0; $langs->load("banks"); //$title = $langs->trans("BankAccounts"); $title = $langs->trans("PaymentInformation"); - if (! empty($conf->stripe->enabled)) + if (!empty($conf->stripe->enabled)) { //$langs->load("stripe"); //$title = $langs->trans("BankAccountsAndGateways"); $servicestatus = 0; - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) $servicestatus = 1; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) $servicestatus = 1; include_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; $societeaccount = new SocieteAccount($db); - $stripecu = $societeaccount->getCustomerAccount($object->id, 'stripe', $servicestatus); // Get thirdparty cu_... + $stripecu = $societeaccount->getCustomerAccount($object->id, 'stripe', $servicestatus); // Get thirdparty cu_... if ($stripecu) $foundonexternalonlinesystem++; } $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; - $sql.= " WHERE fk_soc = ".$object->id; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -216,7 +216,7 @@ function societe_prepare_head(Societe $object) while ($i < $num) { $obj = $db->fetch_object($resql); - $nbBankAccount=$obj->nb; + $nbBankAccount = $obj->nb; $i++; } } @@ -271,13 +271,13 @@ function societe_prepare_head(Societe $object) if ($user->socid == 0) { // Notifications - if (! empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) { $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n"; - $sql.= " WHERE fk_soc = ".$object->id; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -285,7 +285,7 @@ function societe_prepare_head(Societe $object) while ($i < $num) { $obj = $db->fetch_object($resql); - $nbNote=$obj->nb; + $nbNote = $obj->nb; $i++; } } @@ -430,46 +430,46 @@ function societe_admin_prepare_head() */ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', $entconv = 1, $searchlabel = '') { - global $db,$langs; + global $db, $langs; - $result=''; + $result = ''; // Check parameters if (empty($searchkey) && empty($searchlabel)) { - if ($withcode === 'all') return array('id'=>'','code'=>'','label'=>''); + if ($withcode === 'all') return array('id'=>'', 'code'=>'', 'label'=>''); else return ''; } - if (! is_object($dbtouse)) $dbtouse=$db; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($dbtouse)) $dbtouse = $db; + if (!is_object($outputlangs)) $outputlangs = $langs; $sql = "SELECT rowid, code, label FROM ".MAIN_DB_PREFIX."c_country"; - if (is_numeric($searchkey)) $sql.= " WHERE rowid=".$searchkey; - elseif (! empty($searchkey)) $sql.= " WHERE code='".$db->escape($searchkey)."'"; - else $sql.= " WHERE label='".$db->escape($searchlabel)."'"; + if (is_numeric($searchkey)) $sql .= " WHERE rowid=".$searchkey; + elseif (!empty($searchkey)) $sql .= " WHERE code='".$db->escape($searchkey)."'"; + else $sql .= " WHERE label='".$db->escape($searchlabel)."'"; - $resql=$dbtouse->query($sql); + $resql = $dbtouse->query($sql); if ($resql) { $obj = $dbtouse->fetch_object($resql); if ($obj) { - $label=((! empty($obj->label) && $obj->label!='-')?$obj->label:''); + $label = ((!empty($obj->label) && $obj->label != '-') ? $obj->label : ''); if (is_object($outputlangs)) { $outputlangs->load("dict"); - if ($entconv) $label=($obj->code && ($outputlangs->trans("Country".$obj->code)!="Country".$obj->code))?$outputlangs->trans("Country".$obj->code):$label; - else $label=($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code))?$outputlangs->transnoentitiesnoconv("Country".$obj->code):$label; + if ($entconv) $label = ($obj->code && ($outputlangs->trans("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->trans("Country".$obj->code) : $label; + else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv("Country".$obj->code) : $label; } - if ($withcode == 1) $result=$label?"$obj->code - $label":"$obj->code"; - elseif ($withcode == 2) $result=$obj->code; - elseif ($withcode == 3) $result=$obj->rowid; - elseif ($withcode === 'all') $result=array('id'=>$obj->rowid,'code'=>$obj->code,'label'=>$label); - else $result=$label; + if ($withcode == 1) $result = $label ? "$obj->code - $label" : "$obj->code"; + elseif ($withcode == 2) $result = $obj->code; + elseif ($withcode == 3) $result = $obj->rowid; + elseif ($withcode === 'all') $result = array('id'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$label); + else $result = $label; } else { - $result='NotDefined'; + $result = 'NotDefined'; } $dbtouse->free($resql); return $result; @@ -495,58 +495,58 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', */ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlangs = '', $entconv = 1) { - global $db,$langs; + global $db, $langs; - if (! is_object($dbtouse)) $dbtouse=$db; + if (!is_object($dbtouse)) $dbtouse = $db; $sql = "SELECT d.rowid as id, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.code_region as region_code, r.nom as region_name FROM"; - $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; + $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and d.rowid=".$id; $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; $sql .= " ORDER BY c.code, d.code_departement"; dol_syslog("Company.lib::getState", LOG_DEBUG); - $resql=$dbtouse->query($sql); + $resql = $dbtouse->query($sql); if ($resql) { $obj = $dbtouse->fetch_object($resql); if ($obj) { - $label=((! empty($obj->name) && $obj->name!='-')?$obj->name:''); + $label = ((!empty($obj->name) && $obj->name != '-') ? $obj->name : ''); if (is_object($outputlangs)) { $outputlangs->load("dict"); - if ($entconv) $label=($obj->code && ($outputlangs->trans("State".$obj->code)!="State".$obj->code))?$outputlangs->trans("State".$obj->code):$label; - else $label=($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code)!="State".$obj->code))?$outputlangs->transnoentitiesnoconv("State".$obj->code):$label; + if ($entconv) $label = ($obj->code && ($outputlangs->trans("State".$obj->code) != "State".$obj->code)) ? $outputlangs->trans("State".$obj->code) : $label; + else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code) != "State".$obj->code)) ? $outputlangs->transnoentitiesnoconv("State".$obj->code) : $label; } if ($withcode == 1) { if ($withregion == 1) { - return $label = $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = $obj->region_name.' - '.$obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } else { - return $label = $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = $obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } } elseif ($withcode == 2) { if ($withregion == 1) { - return $label = $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = $obj->region_name.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } else { - return $label = ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } } elseif ($withcode === 'all') { if ($withregion == 1) { - return array('id'=>$obj->id,'code'=>$obj->code,'label'=>$label,'region_code'=>$obj->region_code,'region'=>$obj->region_name); + return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label, 'region_code'=>$obj->region_code, 'region'=>$obj->region_name); } else { - return array('id'=>$obj->id,'code'=>$obj->code,'label'=>$label); + return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label); } } else { if ($withregion == 1) { - return $label = $obj->region_name . ' - ' . $label; + return $label = $obj->region_name.' - '.$label; } else { return $label; @@ -571,23 +571,23 @@ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlan */ function currency_name($code_iso, $withcode = '', $outputlangs = null) { - global $langs,$db; + global $langs, $db; - if (empty($outputlangs)) $outputlangs=$langs; + if (empty($outputlangs)) $outputlangs = $langs; $outputlangs->load("dict"); // If there is a translation, we can send immediatly the label - if ($outputlangs->trans("Currency".$code_iso)!="Currency".$code_iso) + if ($outputlangs->trans("Currency".$code_iso) != "Currency".$code_iso) { - return ($withcode?$code_iso.' - ':'').$outputlangs->trans("Currency".$code_iso); + return ($withcode ? $code_iso.' - ' : '').$outputlangs->trans("Currency".$code_iso); } // If no translation, we read table to get label by default $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies"; - $sql.= " WHERE code_iso='".$code_iso."'"; + $sql .= " WHERE code_iso='".$code_iso."'"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -595,8 +595,8 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null) if ($num) { $obj = $db->fetch_object($resql); - $label=($obj->label!='-'?$obj->label:''); - if ($withcode) return ($label==$code_iso)?"$code_iso":"$code_iso - $label"; + $label = ($obj->label != '-' ? $obj->label : ''); + if ($withcode) return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label"; else return $label; } else @@ -615,15 +615,15 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null) */ function getFormeJuridiqueLabel($code) { - global $db,$langs; + global $db, $langs; - if (! $code) return ''; + if (!$code) return ''; $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique"; - $sql.= " WHERE code='$code'"; + $sql .= " WHERE code='$code'"; dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -631,7 +631,7 @@ function getFormeJuridiqueLabel($code) if ($num) { $obj = $db->fetch_object($resql); - $label=($obj->libelle!='-' ? $obj->libelle : ''); + $label = ($obj->libelle != '-' ? $obj->libelle : ''); return $label; } else @@ -654,43 +654,43 @@ function getCountriesInEEC() // List of all country codes that are in europe for european vat rules // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9 - $country_code_in_EEC=array( - 'AT', // Austria - 'BE', // Belgium - 'BG', // Bulgaria - 'CY', // Cyprus - 'CZ', // Czech republic - 'DE', // Germany - 'DK', // Danemark - 'EE', // Estonia - 'ES', // Spain - 'FI', // Finland - 'FR', // France - 'GB', // United Kingdom - 'GR', // Greece - 'HR', // Croatia - 'NL', // Holland - 'HU', // Hungary - 'IE', // Ireland - 'IM', // Isle of Man - Included in UK - 'IT', // Italy - 'LT', // Lithuania - 'LU', // Luxembourg - 'LV', // Latvia - 'MC', // Monaco - Included in France - 'MT', // Malta + $country_code_in_EEC = array( + 'AT', // Austria + 'BE', // Belgium + 'BG', // Bulgaria + 'CY', // Cyprus + 'CZ', // Czech republic + 'DE', // Germany + 'DK', // Danemark + 'EE', // Estonia + 'ES', // Spain + 'FI', // Finland + 'FR', // France + 'GB', // United Kingdom + 'GR', // Greece + 'HR', // Croatia + 'NL', // Holland + 'HU', // Hungary + 'IE', // Ireland + 'IM', // Isle of Man - Included in UK + 'IT', // Italy + 'LT', // Lithuania + 'LU', // Luxembourg + 'LV', // Latvia + 'MC', // Monaco - Included in France + 'MT', // Malta //'NO', // Norway - 'PL', // Poland - 'PT', // Portugal - 'RO', // Romania - 'SE', // Sweden - 'SK', // Slovakia - 'SI', // Slovenia - 'UK', // United Kingdom + 'PL', // Poland + 'PT', // Portugal + 'RO', // Romania + 'SE', // Sweden + 'SK', // Slovakia + 'SI', // Slovenia + 'UK', // United Kingdom //'CH', // Switzerland - No. Swizerland in not in EEC ); - if (! empty($conf->global->MAIN_COUNTRIES_IN_EEC)) + if (!empty($conf->global->MAIN_COUNTRIES_IN_EEC)) { // For example MAIN_COUNTRIES_IN_EEC = 'AT,BE,BG,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HR,NL,HU,IE,IM,IT,LT,LU,LV,MC,MT,PL,PT,RO,SE,SK,SI,UK' $country_code_in_EEC = explode(',', $conf->global->MAIN_COUNTRIES_IN_EEC); @@ -732,16 +732,16 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel { global $user; - $i = -1 ; + $i = -1; - if (! empty($conf->projet->enabled) && $user->rights->projet->lire) + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { $langs->load("projects"); - $newcardbutton=''; - if (! empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) + $newcardbutton = ''; + if (!empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) { - $newcardbutton.= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); + $newcardbutton .= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); } print "\n"; @@ -757,7 +757,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel $sql .= " AND p.entity IN (".getEntity('project').")"; $sql .= " ORDER BY p.dateo DESC"; - $result=$db->query($sql); + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); @@ -779,7 +779,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel $projecttmp = new Project($db); - $i=0; + $i = 0; while ($i < $num) { @@ -794,7 +794,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel print '
    '.img_object($langs->trans("ShowProject"), ($obj->public?'projectpub':'project'))." ".$obj->ref.''.img_object($langs->trans("ShowProject"), ($obj->public ? 'projectpub' : 'project'))." ".$obj->ref.''.$obj->title.'
    '."\n"; - $param="socid=".urlencode($object->id); - if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if (count($search_roles)>0) $param.=implode('&search_roles[]=', $search_roles); - if ($search_name != '') $param.='&search_name='.urlencode($search_name); - if ($search_poste != '') $param.='&search_poste='.urlencode($search_poste); - if ($search_address != '') $param.='&search_address='.urlencode($search_address); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = "socid=".urlencode($object->id); + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); + if (count($search_roles) > 0) $param .= implode('&search_roles[]=', $search_roles); + if ($search_name != '') $param .= '&search_name='.urlencode($search_name); + if ($search_poste != '') $param .= '&search_poste='.urlencode($search_poste); + if ($search_address != '') $param .= '&search_address='.urlencode($search_address); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo,"; @@ -1066,12 +1066,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } } // Extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; // ID - if (! empty($arrayfields['t.rowid']['checked'])) + if (!empty($arrayfields['t.rowid']['checked'])) { print ''; } // Extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Actions print ''; } print "\n
    '; @@ -1140,14 +1140,14 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $contactstatic->setGenderFromCivility(); $contactstatic->fetch_optionals(); - $resultRole=$contactstatic->fetchRoles(); - if ($resultRole<0) { + $resultRole = $contactstatic->fetchRoles(); + if ($resultRole < 0) { setEventMessages(null, $contactstatic->errors, 'errors'); } if (is_array($contactstatic->array_options)) { - foreach($contactstatic->array_options as $key => $val) + foreach ($contactstatic->array_options as $key => $val) { $obj->$key = $val; } @@ -1156,7 +1156,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print '
    '; print $contactstatic->id; @@ -1164,7 +1164,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Photo - Name - if (! empty($arrayfields['t.name']['checked'])) + if (!empty($arrayfields['t.name']['checked'])) { print ''; print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1); @@ -1173,7 +1173,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Job position - if (! empty($arrayfields['t.poste']['checked'])) + if (!empty($arrayfields['t.poste']['checked'])) { print ''; if ($obj->poste) print $obj->poste; @@ -1181,7 +1181,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Address - Phone - Email - if (! empty($arrayfields['t.address']['checked'])) + if (!empty($arrayfields['t.address']['checked'])) { print ''; print $contactstatic->getBannerAddress('contact', $object); @@ -1189,7 +1189,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Role - if (! empty($arrayfields['sc.role']['checked'])) + if (!empty($arrayfields['sc.role']['checked'])) { print ''; print $formcompany->showRoles("roles", $contactstatic, 'view'); @@ -1197,20 +1197,20 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Status - if (! empty($arrayfields['t.statut']['checked'])) + if (!empty($arrayfields['t.statut']['checked'])) { print ''.$contactstatic->getLibStatut(5).''; // Add to agenda - if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { print ''; print img_object($langs->trans("Event"), "action"); @@ -1233,8 +1233,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } else { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '
    '.$langs->trans("None").'
    \n"; @@ -1260,7 +1260,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') */ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '') { - global $user,$conf; + global $user, $conf; $out = show_actions_done($conf, $langs, $db, $filterobj, $objcon, 1, $actioncode, 'todo'); @@ -1295,12 +1295,12 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin dol_include_once('/comm/action/class/actioncomm.class.php'); // Check parameters - if (! is_object($filterobj) && ! is_object($objcon)) dol_print_error('', 'BadParameter'); + if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter'); - $out=''; - $histo=array(); - $numaction = 0 ; - $now=dol_now('tzuser'); + $out = ''; + $histo = array(); + $numaction = 0; + $now = dol_now('tzuser'); // Open DSI -- Fix order by -- Begin $sortfield_list = explode(',', $sortfield); @@ -1311,7 +1311,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } $sortfield_new = implode(',', $sortfield_new_list); - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm if (is_object($objcon) && $objcon->id > 0) { @@ -1321,141 +1321,141 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin { $sql = "SELECT a.id, a.label as label,"; } - $sql.= " a.datep as dp,"; - $sql.= " a.datep2 as dp2,"; - $sql.= " a.percent as percent, 'action' as type,"; - $sql.= " a.fk_element, a.elementtype,"; - $sql.= " a.fk_contact,"; - $sql.= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; - $sql.= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", o.ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; + $sql .= " a.datep as dp,"; + $sql .= " a.datep2 as dp2,"; + $sql .= " a.percent as percent, 'action' as type,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " a.fk_contact,"; + $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; + $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= ", sp.lastname, sp.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; $force_filter_contact = false; if (is_object($objcon) && $objcon->id > 0) { $force_filter_contact = true; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; - $sql.= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . $objcon->id; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; + $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id; } - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; - $sql.= " ON er.resource_type = 'dolresource'"; - $sql.= " AND er.element_id = a.id"; - $sql.= " AND er.resource_id = ".$filterobj->id; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " ON er.resource_type = 'dolresource'"; + $sql .= " AND er.element_id = a.id"; + $sql .= " AND er.resource_id = ".$filterobj->id; } - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", ".MAIN_DB_PREFIX."product as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", ".MAIN_DB_PREFIX."ticket as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", ".MAIN_DB_PREFIX."bom_bom as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", ".MAIN_DB_PREFIX."contrat as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; - $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; if ($force_filter_contact === false) { - if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; - elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; + if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id; + elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id; elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') { - $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } } // Condition on actioncode - if (! empty($actioncode)) + if (!empty($actioncode)) { if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; else { - if ($actioncode == 'AC_OTH') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_OTH_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; } } else { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; - else $sql.= " AND c.code = '".$db->escape($actioncode)."'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else $sql .= " AND c.code = '".$db->escape($actioncode)."'"; } } - if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']); + if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); } // 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) + if (!empty($conf->mailing->enabled) && !empty($objcon->email) && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) { $langs->load("mails"); $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; - $sql2.= ", '' as fk_element, '' as elementtype, '' as contact_id"; - $sql2.= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; - $sql2.= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2.= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2.= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2.= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2.= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2.= ", '' as ref"; - $sql2.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; - $sql2.= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. - $sql2.= " AND mc.statut = 1"; - $sql2.= " AND u.rowid = m.fk_user_valid"; - $sql2.= " AND mc.fk_mailing=m.rowid"; + $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; + $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; + $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. + $sql2 .= " AND mc.statut = 1"; + $sql2 .= " AND u.rowid = m.fk_user_valid"; + $sql2 .= " AND mc.fk_mailing=m.rowid"; } if (!empty($sql) && !empty($sql2)) { - $sql = $sql . " UNION " . $sql2; + $sql = $sql." UNION ".$sql2; } elseif (empty($sql) && !empty($sql2)) { $sql = $sql2; } //TODO Add limit in nb of results - $sql.= $db->order($sortfield_new, $sortorder); + $sql .= $db->order($sortfield_new, $sortorder); dol_syslog("company.lib::show_actions_done", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $i = 0 ; + $i = 0; $num = $db->num_rows($resql); while ($i < $num) @@ -1464,19 +1464,19 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if ($obj->type == 'action') { $contactaction = new ActionComm($db); - $contactaction->id=$obj->id; + $contactaction->id = $obj->id; $result = $contactaction->fetchResources(); - if ($result<0) { + if ($result < 0) { dol_print_error($db); setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); } //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - $tododone=''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone='todo'; + $tododone = ''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>$tododone, 'id'=>$obj->id, @@ -1500,11 +1500,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin // Type of event 'acode'=>$obj->acode, 'alabel'=>$obj->alabel, - 'libelle'=>$obj->alabel, // deprecated + 'libelle'=>$obj->alabel, // deprecated 'apicto'=>$obj->apicto ); } else { - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>'done', 'id'=>$obj->id, @@ -1740,8 +1740,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if ($result > 0) { $out .= $contact->getNomUrl(1); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { - if (! empty($contact->phone_pro)) - $out .= '(' . dol_print_phone($contact->phone_pro) . ')'; + if (!empty($contact->phone_pro)) + $out .= '('.dol_print_phone($contact->phone_pro).')'; } $out .= '
    '; } @@ -1749,23 +1749,23 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= '
      '.$actionstatic->LibStatut($histo[$key]['percent'], 3, 0, $histo[$key]['datestart']).''.$actionstatic->LibStatut($histo[$key]['percent'], 3, 0, $histo[$key]['datestart']).'
    \n"; - $out.="\n"; + $out .= "
    \n"; + $out .= "
    \n"; } - $out.=''; + $out .= ''; if ($noprint) return $out; else print $out; @@ -1784,13 +1784,13 @@ function show_subsidiaries($conf, $langs, $db, $object) { global $user; - $i=-1; + $i = -1; $sql = "SELECT s.rowid, s.client, s.fournisseur, s.nom as name, s.name_alias, s.email, s.address, s.zip, s.town, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.canvas"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.parent = ".$object->id; - $sql.= " AND s.entity IN (".getEntity('societe').")"; - $sql.= " ORDER BY s.nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.parent = ".$object->id; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + $sql .= " ORDER BY s.nom"; $result = $db->query($sql); $num = $db->num_rows($result); @@ -1808,7 +1808,7 @@ function show_subsidiaries($conf, $langs, $db, $object) print " "; print ""; - $i=0; + $i = 0; while ($i < $num) { diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php index 4088b00c151..8128a449cfd 100644 --- a/htdocs/core/lib/cron.lib.php +++ b/htdocs/core/lib/cron.lib.php @@ -87,17 +87,17 @@ function dol_print_cron_urls() global $dolibarr_main_url_root; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current // Cron launch print '
    '; print $langs->trans("URLToLaunchCronJobs").':
    '; - $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; + $url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; print img_picto('', 'globe').' '.$url."
    \n"; print ' '.$langs->trans("OrToLaunchASpecificJob").'
    '; - $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; + $url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; print img_picto('', 'globe').' '.$url."
    \n"; print '
    '; print '
    '; @@ -107,22 +107,22 @@ function dol_print_cron_urls() print ''.$langs->trans("FileToLaunchCronJobs").':
    '; - $file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]'; + $file = '/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY) ? 'securitykey' : ''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]'; print '
    \n"; print '
    '; // Add note if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON)) { - $linuxlike=1; - if (preg_match('/^win/i', PHP_OS)) $linuxlike=0; - if (preg_match('/^mac/i', PHP_OS)) $linuxlike=0; + $linuxlike = 1; + if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; + if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; print $langs->trans("Note").': '; if ($linuxlike) { print $langs->trans("CronExplainHowToRunUnix"); print '
    '; - print '
    '; + print '
    '; } else { diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 568da82368f..66b39809b29 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -136,12 +136,12 @@ function showOnlinePaymentUrl($type, $ref) // Load translation files required by the page $langs->loadLangs(array('payment', 'paybox')); - $servicename=$langs->transnoentitiesnoconv('Online'); + $servicename = $langs->transnoentitiesnoconv('Online'); $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
    '; $url = getOnlinePaymentUrl(0, $type, $ref); - $out.= ''; - $out.= ajax_autoselect("onlinepaymenturl", 0); + $out .= ''; + $out .= ajax_autoselect("onlinepaymenturl", 0); return $out; } @@ -160,12 +160,12 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag { global $conf, $dolibarr_main_url_root; - $ref=str_replace(' ', '', $ref); - $out=''; + $ref = str_replace(' ', '', $ref); + $out = ''; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current $urltouse = DOL_MAIN_URL_ROOT; @@ -295,51 +295,51 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, global $conf; // Juridical status - $line1=""; + $line1 = ""; if ($fromcompany->forme_juridique_code) { - $line1.=($line1?" - ":"").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); + $line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); } // Capital if ($fromcompany->capital) { - $line1.=($line1?" - ":"").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); + $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); } // Prof Id 1 - if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) { - $field=$langs->transcountrynoentities("ProfId1", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof1; + $field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1; } // Prof Id 2 if ($fromcompany->idprof2) { - $field=$langs->transcountrynoentities("ProfId2", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof2; + $field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2; } // Second line of company infos - $line2=""; + $line2 = ""; // Prof Id 3 if ($fromcompany->idprof3) { - $field=$langs->transcountrynoentities("ProfId3", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof3; + $field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3; } // Prof Id 4 if ($fromcompany->idprof4) { - $field=$langs->transcountrynoentities("ProfId4", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof4; + $field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4; } // IntraCommunautary VAT if ($fromcompany->tva_intra != '') { - $line2.=($line2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; + $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; } print '
    '; @@ -350,16 +350,16 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, print ''; print '
    '; - $parammessageform='ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); - elseif (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); + $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; + if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); + elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); // Add other message if VAT exists if ($object->total_vat != 0 || $object->total_tva != 0) { - $parammessageform='ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); - elseif (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); + $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; + if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); + elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); } } diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index bdeb9181d3b..095a65c3584 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -45,7 +45,7 @@ function product_prepare_head($object) $head[$h][2] = 'card'; $h++; - if (! empty($object->status)) + if (!empty($object->status)) { $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id; $head[$h][1] = $langs->trans("SellingPrices"); @@ -53,10 +53,10 @@ function product_prepare_head($object) $h++; } - if (! empty($object->status_buy) || (! empty($conf->margin->enabled) && ! empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase + if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase { - if ((! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) - || (! empty($conf->margin->enabled) && $user->rights->margin->liretous) + if ((!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) + || (!empty($conf->margin->enabled) && $user->rights->margin->liretous) ) { $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id; @@ -67,7 +67,7 @@ function product_prepare_head($object) } // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { $head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$object->id; $head[$h][1] = $langs->trans("Translation"); @@ -130,16 +130,16 @@ function product_prepare_head($object) // Tab to link resources if (!empty($conf->resource->enabled)) { - if ($object->isProduct() && ! empty($conf->global->RESOURCE_ON_PRODUCTS)) + if ($object->isProduct() && !empty($conf->global->RESOURCE_ON_PRODUCTS)) { - $head[$h][0] = DOL_URL_ROOT . '/resource/element_resource.php?element=product&ref=' . $object->ref; + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=product&ref='.$object->ref; $head[$h][1] = $langs->trans("Resources"); $head[$h][2] = 'resources'; $h++; } - if ($object->isService() && ! empty($conf->global->RESOURCE_ON_SERVICES)) + if ($object->isService() && !empty($conf->global->RESOURCE_ON_SERVICES)) { - $head[$h][0] = DOL_URL_ROOT . '/resource/element_resource.php?element=service&ref=' . $object->ref; + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=service&ref='.$object->ref; $head[$h][1] = $langs->trans("Resources"); $head[$h][2] = 'resources'; $h++; @@ -188,10 +188,10 @@ function product_prepare_head($object) // Log $head[$h][0] = DOL_URL_ROOT.'/product/agenda.php?id='.$object->id; $head[$h][1] = $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; @@ -210,7 +210,7 @@ function productlot_prepare_head($object) global $db, $langs, $conf, $user; // Load translation files required by the page - $langs->loadLangs(array("products","productbatch")); + $langs->loadLangs(array("products", "productbatch")); $h = 0; $head = array(); @@ -270,7 +270,7 @@ function product_admin_prepare_head() $head[$h][2] = 'general'; $h++; - if (!empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { $head[$h] = array( 0 => DOL_URL_ROOT."/product/admin/price_rules.php", @@ -342,7 +342,7 @@ function product_lot_admin_prepare_head() */ function show_stats_for_company($product, $socid) { - global $conf,$langs,$user,$db; + global $conf, $langs, $user, $db; $nblines = 0; @@ -354,10 +354,10 @@ function show_stats_for_company($product, $socid) print ''; // Customer proposals - if (! empty($conf->propal->enabled) && $user->rights->propale->lire) + if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $nblines++; - $ret=$product->load_stats_propale($socid); + $ret = $product->load_stats_propale($socid); if ($ret < 0) dol_print_error($db); $langs->load("propal"); print ''; @@ -372,10 +372,10 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier proposals - if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) + if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { $nblines++; - $ret=$product->load_stats_proposal_supplier($socid); + $ret = $product->load_stats_proposal_supplier($socid); if ($ret < 0) dol_print_error($db); $langs->load("propal"); print ''; @@ -390,10 +390,10 @@ function show_stats_for_company($product, $socid) print ''; } // Customer orders - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $nblines++; - $ret=$product->load_stats_commande($socid); + $ret = $product->load_stats_commande($socid); if ($ret < 0) dol_print_error($db); $langs->load("orders"); print ''; @@ -408,10 +408,10 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier orders - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { $nblines++; - $ret=$product->load_stats_commande_fournisseur($socid); + $ret = $product->load_stats_commande_fournisseur($socid); if ($ret < 0) dol_print_error($db); $langs->load("orders"); print ''; @@ -426,10 +426,10 @@ function show_stats_for_company($product, $socid) print ''; } // Customer invoices - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $nblines++; - $ret=$product->load_stats_facture($socid); + $ret = $product->load_stats_facture($socid); if ($ret < 0) dol_print_error($db); $langs->load("bills"); print ''; @@ -444,10 +444,10 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier invoices - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { $nblines++; - $ret=$product->load_stats_facture_fournisseur($socid); + $ret = $product->load_stats_facture_fournisseur($socid); if ($ret < 0) dol_print_error($db); $langs->load("bills"); print ''; @@ -463,10 +463,10 @@ function show_stats_for_company($product, $socid) } // Contracts - if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $nblines++; - $ret=$product->load_stats_contrat($socid); + $ret = $product->load_stats_contrat($socid); if ($ret < 0) dol_print_error($db); $langs->load("contracts"); print ''; @@ -514,7 +514,7 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho { global $langs, $db; require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; - $measuringUnits= new CUnits($db); + $measuringUnits = new CUnits($db); if ($scale !== '') { @@ -534,10 +534,10 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho } $result = $measuringUnits->fetchAll('', '', 0, 0, $arrayforfilter); - if ($result<0) { + if ($result < 0) { return -1; } else { - if (is_array($measuringUnits->records) && count($measuringUnits->records)>0) { + if (is_array($measuringUnits->records) && count($measuringUnits->records) > 0) { if ($use_short_label) return $measuringUnits->records[key($measuringUnits->records)]->short_label; else return $langs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label); } else { @@ -555,8 +555,8 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho */ function measuring_units_squared($unit) { - $measuring_units=array(); - $measuring_units[0] = 0; // m -> m3 + $measuring_units = array(); + $measuring_units[0] = 0; // m -> m3 $measuring_units[-1] = -2; // dm-> dm2 $measuring_units[-2] = -4; // cm -> cm2 $measuring_units[-3] = -6; // mm -> mm2 @@ -575,8 +575,8 @@ function measuring_units_squared($unit) */ function measuring_units_cubed($unit) { - $measuring_units=array(); - $measuring_units[0] = 0; // m -> m2 + $measuring_units = array(); + $measuring_units[0] = 0; // m -> m2 $measuring_units[-1] = -3; // dm-> dm3 $measuring_units[-2] = -6; // cm -> cm3 $measuring_units[-3] = -9; // mm -> mm3 diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 21df0301d49..b7609ab82ae 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -259,13 +259,13 @@ function project_timesheet_prepare_head($mode, $fuser = null) $h = 0; - $param=''; - $param.=($mode?'&mode='.$mode:''); - if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id; + $param = ''; + $param .= ($mode ? '&mode='.$mode : ''); + if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id; if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) { - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerWeek"); $head[$h][2] = 'inputperweek'; $h++; @@ -273,7 +273,7 @@ function project_timesheet_prepare_head($mode, $fuser = null) if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) { - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerDay"); $head[$h][2] = 'inputperday'; $h++; @@ -353,10 +353,10 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t global $user, $bc, $langs, $conf, $db; global $projectstatic, $taskstatic; - $lastprojectid=0; + $lastprojectid = 0; - $projectsArrayId=explode(',', $projectsListId); - if ($filterprogresscalc!=='') { + $projectsArrayId = explode(',', $projectsListId); + if ($filterprogresscalc !== '') { foreach ($lines as $key=>$line) { if (!empty($line->planned_workload) && !empty($line->duration)) { $filterprogresscalc = str_replace(' = ', ' == ', $filterprogresscalc); @@ -365,27 +365,27 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } } - $lines=array_values($lines); + $lines = array_values($lines); } - $numlines=count($lines); + $numlines = count($lines); // We declare counter as global because we want to edit them into recursive call global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned, $total_projectlinesa_declared_if_planned, $total_projectlinesa_tobill, $total_projectlinesa_billed; if ($level == 0) { - $total_projectlinesa_spent=0; - $total_projectlinesa_planned=0; - $total_projectlinesa_spent_if_planned=0; - $total_projectlinesa_declared_if_planned=0; - $total_projectlinesa_tobill=0; - $total_projectlinesa_billed=0; + $total_projectlinesa_spent = 0; + $total_projectlinesa_planned = 0; + $total_projectlinesa_spent_if_planned = 0; + $total_projectlinesa_declared_if_planned = 0; + $total_projectlinesa_tobill = 0; + $total_projectlinesa_billed = 0; } - for ($i = 0 ; $i < $numlines ; $i++) + for ($i = 0; $i < $numlines; $i++) { - if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines + if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines // Process line // print "i:".$i."-".$lines[$i]->fk_project.'
    '; @@ -393,26 +393,26 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines { // Show task line. - $showline=1; - $showlineingray=0; + $showline = 1; + $showlineingray = 0; // If there is filters to use if (is_array($taskrole)) { // If task not legitimate to show, search if a legitimate task exists later in tree - if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) + if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) { // So search if task has a subtask legitimate to show - $foundtaskforuserdeeper=0; + $foundtaskforuserdeeper = 0; searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole); //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'
    '; if ($foundtaskforuserdeeper > 0) { - $showlineingray=1; // We will show line but in gray + $showlineingray = 1; // We will show line but in gray } else { - $showline=0; // No reason to show line + $showline = 0; // No reason to show line } } } @@ -423,12 +423,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (empty($user->rights->projet->all->lire)) { // User is not allowed on this project and project is not public, so we hide line - if (! in_array($lines[$i]->fk_project, $projectsArrayId)) + if (!in_array($lines[$i]->fk_project, $projectsArrayId)) { // Note that having a user assigned to a task into a project user has no permission on, should not be possible // because assignement on task can be done only on contact of project. // If assignement was done and after, was removed from contact of project, then we can hide the line. - $showline=0; + $showline = 0; } } } @@ -439,26 +439,26 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { $var = !$var; - $lastprojectid=$lines[$i]->fk_project; + $lastprojectid = $lines[$i]->fk_project; } print ''."\n"; - $projectstatic->id=$lines[$i]->fk_project; - $projectstatic->ref=$lines[$i]->projectref; - $projectstatic->public=$lines[$i]->public; - $projectstatic->title=$lines[$i]->projectlabel; - $projectstatic->usage_bill_time=$lines[$i]->usage_bill_time; + $projectstatic->id = $lines[$i]->fk_project; + $projectstatic->ref = $lines[$i]->projectref; + $projectstatic->public = $lines[$i]->public; + $projectstatic->title = $lines[$i]->projectlabel; + $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time; - $taskstatic->id=$lines[$i]->id; - $taskstatic->ref=$lines[$i]->ref; - $taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:''); + $taskstatic->id = $lines[$i]->id; + $taskstatic->ref = $lines[$i]->ref; + $taskstatic->label = ($taskrole[$lines[$i]->id] ? $langs->trans("YourRole").': '.$taskrole[$lines[$i]->id] : ''); $taskstatic->projectstatus = $lines[$i]->projectstatus; $taskstatic->progress = $lines[$i]->progress; $taskstatic->fk_statut = $lines[$i]->status; $taskstatic->datee = $lines[$i]->date_end; - $taskstatic->planned_workload= $lines[$i]->planned_workload; - $taskstatic->duration_effective= $lines[$i]->duration; + $taskstatic->planned_workload = $lines[$i]->planned_workload; + $taskstatic->duration_effective = $lines[$i]->duration; if ($showproject) @@ -466,14 +466,14 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Project ref print ""; //if ($showlineingray) print ''; - if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); + if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); else print $projectstatic->getNomUrl(1, 'nolink'); //if ($showlineingray) print ''; print ""; // Project status print ''; - $projectstatic->statut=$lines[$i]->projectstatus; + $projectstatic->statut = $lines[$i]->projectstatus; print $projectstatic->getLibStatut(2); print ""; } @@ -494,12 +494,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ""; if ($showlineingray) print ''; //else print ''; - for ($k = 0 ; $k < $level ; $k++) + for ($k = 0; $k < $level; $k++) { print '
    '; } print $lines[$i]->label; - for ($k = 0 ; $k < $level ; $k++) + for ($k = 0; $k < $level; $k++) { print '
    '; } @@ -518,15 +518,15 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); print ''; - $plannedworkloadoutputformat='allhourmin'; - $timespentoutputformat='allhourmin'; - if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; - if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; + $plannedworkloadoutputformat = 'allhourmin'; + $timespentoutputformat = 'allhourmin'; + if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; + if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; // Planned Workload (in working hours) print ''; - $fullhour=convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); - $workingdelay=convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks + $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); + $workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks if ($lines[$i]->planned_workload != '') { print $fullhour; @@ -539,7 +539,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Time spent print ''; if ($showlineingray) print ''; - else print '
    '; + else print ''; if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); else print '--:--'; if ($showlineingray) print ''; @@ -600,20 +600,20 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Contacts of task - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { print ''; - foreach(array('internal','external') as $source) + foreach (array('internal', 'external') as $source) { $tab = $lines[$i]->liste_contact(-1, $source); - $num=count($tab); - if (!empty($num)){ - foreach ($tab as $contacttask){ + $num = count($tab); + if (!empty($num)) { + foreach ($tab as $contacttask) { //var_dump($contacttask); if ($source == 'internal') $c = new User($db); else $c = new Contact($db); $c->fetch($contacttask['id']); - print $c->getNomUrl(1) . ' (' . $contacttask['libelle'] . ')' . '
    '; + print $c->getNomUrl(1).' ('.$contacttask['libelle'].')'.'
    '; } } } @@ -628,7 +628,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print "\n"; - if (! $showlineingray) $inc++; + if (!$showlineingray) $inc++; if ($level >= 0) // Call sublevels { @@ -662,7 +662,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); print ''; print ''; - if ($projectidfortotallink > 0) print '
    '; + if ($projectidfortotallink > 0) print ''; print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); if ($projectidfortotallink > 0) print ''; print ''; @@ -680,13 +680,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($totalCalculatedProgress > $totalAverageDeclaredProgress) { $progressBarClass = 'progress-bar-danger'; - $badgeClass.= 'badge-danger'; + $badgeClass .= 'badge-danger'; } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) { // warning if close at 1% $progressBarClass = 'progress-bar-warning'; - $badgeClass.= 'badge-warning'; + $badgeClass .= 'badge-warning'; } else { $progressBarClass = 'progress-bar-success'; - $badgeClass.= 'badge-success'; + $badgeClass .= 'badge-success'; } } @@ -719,7 +719,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; } // Contacts of task - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { print ''; } @@ -1169,11 +1169,11 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr // Ref print ''; print ''; - for ($k = 0 ; $k < $level ; $k++) print "   "; + for ($k = 0; $k < $level; $k++) print "   "; print $taskstatic->getNomUrl(1, 'withproject', 'time'); // Label task print '
    '; - for ($k = 0 ; $k < $level ; $k++) print "   "; + for ($k = 0; $k < $level; $k++) print "   "; print $taskstatic->label; //print "
    "; //for ($k = 0 ; $k < $level ; $k++) print "   "; @@ -1221,20 +1221,20 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr else print '--:--'; print "\n"; - $disabledproject=1;$disabledtask=1; + $disabledproject = 1; $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { - $disabledproject=0; - $disabledtask=0; + $disabledproject = 0; + $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { - $disabledtask=1; + $disabledtask = 1; } // Form to add new time @@ -1392,7 +1392,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $obj = &$lines[$i]; // To display extrafields // If we want all or we have a role on task, we show it - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) { //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); @@ -1530,7 +1530,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ */ // Project - if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) + if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { print ''; if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); @@ -1538,7 +1538,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ } // Thirdparty - if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) + if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { print ''; if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project'); @@ -1596,25 +1596,25 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ // Time spent by user print ''; - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); else print '--:--'; print "\n"; - $disabledproject=1;$disabledtask=1; + $disabledproject = 1; $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { - $disabledproject=0; - $disabledtask=0; + $disabledproject = 0; + $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { - $disabledtask=1; + $disabledtask = 1; } //var_dump($projectstatic->weekWorkLoadPerTask); @@ -1686,9 +1686,9 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields); //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); //var_dump($ret); - foreach($ret as $key => $val) + foreach ($ret as $key => $val) { - $totalforeachday[$key]+=$val; + $totalforeachday[$key] += $val; } //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); //var_dump($totalforeachday); @@ -1717,8 +1717,8 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) { //print 'Search in line with parent id = '.$parent.'
    '; - $numlines=count($lines); - for ($i = 0 ; $i < $numlines ; $i++) + $numlines = count($lines); + for ($i = 0; $i < $numlines; $i++) { // Process line $lines[$i] if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) @@ -1811,40 +1811,40 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks { $project_year_filter = date("Y"); } - $sql.= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")"; - $sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")"; + $sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")"; + $sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")"; } } // Get id of project we must show tasks - $arrayidofprojects=array(); + $arrayidofprojects = array(); $sql1 = "SELECT p.rowid as projectid"; - $sql1.= $sql; + $sql1 .= $sql; $resql = $db->query($sql1); if ($resql) { - $i=0; + $i = 0; $num = $db->num_rows($resql); while ($i < $num) { $objp = $db->fetch_object($resql); - $arrayidofprojects[$objp->projectid]=$objp->projectid; + $arrayidofprojects[$objp->projectid] = $objp->projectid; $i++; } } else dol_print_error($db); - if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1; + if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1; // Get list of project with calculation on tasks $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,"; - $sql2.= " p.dateo, p.datee,"; - $sql2.= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; - $sql2.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; - $sql2.= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")"; - $sql2.= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee"; - $sql2.= " ORDER BY p.title, p.ref"; + $sql2 .= " p.dateo, p.datee,"; + $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; + $sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")"; + $sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee"; + $sql2 .= " ORDER BY p.title, p.ref"; $resql = $db->query($sql2); if ($resql) @@ -1859,7 +1859,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print_liste_field_titre($title.''.$num.'', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre("OpportunityStatus", "", "", "", "", 'align="right"', $sortfield, $sortorder); @@ -1867,14 +1867,14 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks if (empty($conf->global->PROJECT_HIDE_TASKS)) { print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder); - if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder); - if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder); + if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder); + if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder); } print_liste_field_titre("Status", "", "", "", "", 'align="right"', $sortfield, $sortorder); print "\n"; - $total_plannedworkload=0; - $total_declaredprogressworkload=0; + $total_plannedworkload = 0; + $total_declaredprogressworkload = 0; while ($i < $num) { $objp = $db->fetch_object($resql); @@ -1887,7 +1887,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $userAccess = $projectstatic->restrictedProjectArea($user); if ($userAccess >= 0) { - $projectstatic->ref=$objp->ref; + $projectstatic->ref = $objp->ref; $projectstatic->statut = $objp->status; $projectstatic->title = $objp->title; $projectstatic->datee = $db->jdate($objp->datee); @@ -1897,18 +1897,18 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print ''; print $projectstatic->getNomUrl(1); - if (! in_array('projectlabel', $hiddenfields)) print '
    '.dol_trunc($objp->title, 24); + if (!in_array('projectlabel', $hiddenfields)) print '
    '.dol_trunc($objp->title, 24); print ''; print ''; if ($objp->fk_soc > 0) { - $thirdpartystatic->id=$objp->fk_soc; - $thirdpartystatic->ref=$objp->socname; - $thirdpartystatic->name=$objp->socname; + $thirdpartystatic->id = $objp->fk_soc; + $thirdpartystatic->ref = $objp->socname; + $thirdpartystatic->name = $objp->socname; print $thirdpartystatic->getNomUrl(1); } print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print ''; if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); @@ -1922,19 +1922,19 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks { print ''.$objp->nb.''; - $plannedworkload=$objp->planned_workload; - $total_plannedworkload+=$plannedworkload; - if (! in_array('plannedworkload', $hiddenfields)) + $plannedworkload = $objp->planned_workload; + $total_plannedworkload += $plannedworkload; + if (!in_array('plannedworkload', $hiddenfields)) { - print ''.($plannedworkload?convertSecondToTime($plannedworkload):'').''; + print ''.($plannedworkload ?convertSecondToTime($plannedworkload) : '').''; } - if (! in_array('declaredprogress', $hiddenfields)) + if (!in_array('declaredprogress', $hiddenfields)) { - $declaredprogressworkload=$objp->declared_progess_workload; - $total_declaredprogressworkload+=$declaredprogressworkload; + $declaredprogressworkload = $objp->declared_progess_workload; + $total_declaredprogressworkload += $declaredprogressworkload; print ''; //print $objp->planned_workload.'-'.$objp->declared_progess_workload."
    "; - print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload, 0).'%':''); + print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : ''); print ''; } } @@ -1952,7 +1952,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print ''.$langs->trans("Total").""; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print ''.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).''; print ''.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).''; @@ -1960,8 +1960,8 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks if (empty($conf->global->PROJECT_HIDE_TASKS)) { print ''.$total_task.''; - if (! in_array('plannedworkload', $hiddenfields)) print ''.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').''; - if (! in_array('declaredprogress', $hiddenfields)) print ''.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload, 0).'%':'').''; + if (!in_array('plannedworkload', $hiddenfields)) print ''.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').''; + if (!in_array('declaredprogress', $hiddenfields)) print ''.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').''; } print ''; print ''; diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index c9527c54840..837f505c132 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -29,14 +29,14 @@ function showOnlineSignatureUrl($type, $ref) global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("payment","paybox")); + $langs->loadLangs(array("payment", "paybox")); - $servicename='Online'; + $servicename = 'Online'; $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'
    '; $url = getOnlineSignatureUrl(0, $type, $ref); - $out.= ''; - $out.= ajax_autoselect("onlinesignatureurl", 0); + $out .= ''; + $out .= ajax_autoselect("onlinesignatureurl", 0); return $out; } @@ -53,29 +53,29 @@ function getOnlineSignatureUrl($mode, $type, $ref = '') { global $conf, $db, $langs; - $ref=str_replace(' ', '', $ref); - $out=''; + $ref = str_replace(' ', '', $ref); + $out = ''; if ($type == 'proposal') { - $out=DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode?'':''); - if ($mode == 1) $out.='proposal_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if ($mode == 1) $out.='&hashp=hash_of_file'; + $out = DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'proposal_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if ($mode == 1) $out .= '&hashp=hash_of_file'; else { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $propaltmp=new Propal($db); + $propaltmp = new Propal($db); $res = $propaltmp->fetch(0, $ref); if ($res <= 0) return 'FailedToGetProposal'; include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($db); + $ecmfile = new EcmFiles($db); $ecmfile->fetch(0, '', $propaltmp->last_main_doc); - $hashp=$ecmfile->share; + $hashp = $ecmfile->share; if (empty($hashp)) { $out = $langs->trans("FeatureOnlineSignDisabled"); @@ -83,13 +83,13 @@ function getOnlineSignatureUrl($mode, $type, $ref = '') } else { - $out.='&hashp='.$hashp; + $out .= '&hashp='.$hashp; } } } // For multicompany - if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + if (!empty($out)) $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities return $out; } diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 609dbd9926d..fd2d56c946b 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -77,7 +77,7 @@ function ticket_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id=' . $object->track_id; + $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id='.$object->track_id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'tabTicket'; $h++; @@ -110,25 +110,25 @@ function ticket_prepare_head($object) // History $ticketViewType = "messaging"; - if(empty($_SESSION['ticket-view-type'])){ + if (empty($_SESSION['ticket-view-type'])) { $_SESSION['ticket-view-type'] = $ticketViewType; } - else{ + else { $ticketViewType = $_SESSION['ticket-view-type']; } - if($ticketViewType == "messaging"){ - $head[$h][0] = DOL_URL_ROOT.'/ticket/messaging.php?track_id=' . $object->track_id; + if ($ticketViewType == "messaging") { + $head[$h][0] = DOL_URL_ROOT.'/ticket/messaging.php?track_id='.$object->track_id; } - else{ + else { // $ticketViewType == "list" - $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id; + $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id; } $head[$h][1] = $langs->trans('Events'); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'tabTicketLogs'; $h++; @@ -158,22 +158,22 @@ function showDirectPublicLink($object) $url = dol_buildpath('/public/ticket/view.php', 3).'?track_id='.$object->track_id.'&email='.$email; } - $out=''; + $out = ''; if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { - $out.= ''.$langs->trans("PublicInterfaceNotEnabled").''; + $out .= ''.$langs->trans("PublicInterfaceNotEnabled").''; } else { - $out.= img_picto('', 'object_globe.png').' '.$langs->trans("TicketPublicAccess").':
    '; + $out .= img_picto('', 'object_globe.png').' '.$langs->trans("TicketPublicAccess").':
    '; if ($url) { - $out.= ''; - $out.= ajax_autoselect("directpubliclink", 0); + $out .= ''; + $out .= ajax_autoselect("directpubliclink", 0); } else { - $out.= ''.$langs->trans("TicketNotCreatedFromPublicInterface").''; + $out .= ''.$langs->trans("TicketNotCreatedFromPublicInterface").''; } } @@ -272,12 +272,12 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no dol_include_once('/comm/action/class/actioncomm.class.php'); // Check parameters - if (! is_object($filterobj) && ! is_object($objcon)) dol_print_error('', 'BadParameter'); + if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter'); - $out=''; - $histo=array(); - $numaction = 0 ; - $now=dol_now('tzuser'); + $out = ''; + $histo = array(); + $numaction = 0; + $now = dol_now('tzuser'); // Open DSI -- Fix order by -- Begin $sortfield_list = explode(',', $sortfield); @@ -288,7 +288,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no } $sortfield_new = implode(',', $sortfield_new_list); - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm if (is_object($objcon) && $objcon->id > 0) { @@ -298,142 +298,142 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no { $sql = "SELECT a.id, a.label as label,"; } - $sql.= " a.datep as dp,"; - $sql.= " a.note as message,"; - $sql.= " a.datep2 as dp2,"; - $sql.= " a.percent as percent, 'action' as type,"; - $sql.= " a.fk_element, a.elementtype,"; - $sql.= " a.fk_contact,"; - $sql.= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; - $sql.= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", o.ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; + $sql .= " a.datep as dp,"; + $sql .= " a.note as message,"; + $sql .= " a.datep2 as dp2,"; + $sql .= " a.percent as percent, 'action' as type,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " a.fk_contact,"; + $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; + $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= ", sp.lastname, sp.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; $force_filter_contact = false; if (is_object($objcon) && $objcon->id > 0) { $force_filter_contact = true; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; - $sql.= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . $objcon->id; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; + $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id; } - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; - $sql.= " ON er.resource_type = 'dolresource'"; - $sql.= " AND er.element_id = a.id"; - $sql.= " AND er.resource_id = ".$filterobj->id; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " ON er.resource_type = 'dolresource'"; + $sql .= " AND er.element_id = a.id"; + $sql .= " AND er.resource_id = ".$filterobj->id; } - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", ".MAIN_DB_PREFIX."product as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", ".MAIN_DB_PREFIX."ticket as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", ".MAIN_DB_PREFIX."bom_bom as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", ".MAIN_DB_PREFIX."contrat as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; - $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; if ($force_filter_contact === false) { - if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; - elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; + if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id; + elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id; elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') { - $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } } // Condition on actioncode - if (! empty($actioncode)) + if (!empty($actioncode)) { if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; else { - if ($actioncode == 'AC_OTH') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_OTH_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; } } else { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; - else $sql.= " AND c.code = '".$db->escape($actioncode)."'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else $sql .= " AND c.code = '".$db->escape($actioncode)."'"; } } - if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']); + if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); } // 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) + if (!empty($conf->mailing->enabled) && !empty($objcon->email) && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) { $langs->load("mails"); $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; - $sql2.= ", '' as fk_element, '' as elementtype, '' as contact_id"; - $sql2.= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; - $sql2.= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2.= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2.= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2.= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2.= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2.= ", '' as ref"; - $sql2.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; - $sql2.= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. - $sql2.= " AND mc.statut = 1"; - $sql2.= " AND u.rowid = m.fk_user_valid"; - $sql2.= " AND mc.fk_mailing=m.rowid"; + $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; + $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; + $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. + $sql2 .= " AND mc.statut = 1"; + $sql2 .= " AND u.rowid = m.fk_user_valid"; + $sql2 .= " AND mc.fk_mailing=m.rowid"; } if (!empty($sql) && !empty($sql2)) { - $sql = $sql . " UNION " . $sql2; + $sql = $sql." UNION ".$sql2; } elseif (empty($sql) && !empty($sql2)) { $sql = $sql2; } //TODO Add limit in nb of results - $sql.= $db->order($sortfield_new, $sortorder); + $sql .= $db->order($sortfield_new, $sortorder); dol_syslog("company.lib::show_actions_done", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $i = 0 ; + $i = 0; $num = $db->num_rows($resql); while ($i < $num) @@ -442,19 +442,19 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no if ($obj->type == 'action') { $contactaction = new ActionComm($db); - $contactaction->id=$obj->id; + $contactaction->id = $obj->id; $result = $contactaction->fetchResources(); - if ($result<0) { + if ($result < 0) { dol_print_error($db); setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); } //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - $tododone=''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone='todo'; + $tododone = ''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>$tododone, 'id'=>$obj->id, @@ -479,11 +479,11 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no // Type of event 'acode'=>$obj->acode, 'alabel'=>$obj->alabel, - 'libelle'=>$obj->alabel, // deprecated + 'libelle'=>$obj->alabel, // deprecated 'apicto'=>$obj->apicto ); } else { - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>'done', 'id'=>$obj->id, @@ -511,85 +511,85 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no dol_print_error($db); } - if (! empty($conf->agenda->enabled) || (! empty($conf->mailing->enabled) && ! empty($objcon->email))) + if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) { - $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $formactions=new FormActions($db); + $formactions = new FormActions($db); - $actionstatic=new ActionComm($db); - $userstatic=new User($db); + $actionstatic = new ActionComm($db); + $userstatic = new User($db); $contactstatic = new Contact($db); $userGetNomUrlCache = array(); - $out.='
    '; - $out.='
    '; + $out .= '
    '; + $out .= ''; if ($objcon && get_class($objcon) == 'Contact' && (is_null($filterobj) || get_class($filterobj) == 'Societe')) { - $out.=''; + $out .= ''; } else { - $out.=''; + $out .= ''; } - if ($filterobj && get_class($filterobj) == 'Societe') $out.=''; + if ($filterobj && get_class($filterobj) == 'Societe') $out .= ''; - $out.="\n"; + $out .= "\n"; - $out.='
    '; - $out.=''; + $out .= '
    '; + $out .= '
    '; - $out.=''; + $out .= ''; //$out.=''; - $out.=''; + $out .= ''; if ($donetodo) { - $out.=''; + $out .= ''; } - $out.=''; - $out.=''; + $out .= ''; + $out .= ''; - $out.=''; - $out.=''; + $out .= ''; + $out .= ''; - $out.='
    '; $out .= getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', '', $param, '', $sortfield, $sortorder, '')."\n"; //$out.=''.$langs->trans("Search").' : '.$langs->trans("Search").' : '.$langs->trans("Type").' '; - $out.=$formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1, 0, 0, 1); - $out.=''; - $out.=$langs->trans("Label").' '; - $out.=''; - $out.=''.$langs->trans("Type").' '; + $out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, 0, 1); + $out .= ''; + $out .= $langs->trans("Label").' '; + $out .= ''; + $out .= ''; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); - $out.=$searchpicto; - $out.='
    '; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + $out .= $searchpicto; + $out .= '
    '; + $out .= ''; - $out.=''; - $out.='
    '; + $out .= ''; + $out .= '
    '; - $out.="\n"; + $out .= "\n"; - $out.='
      '; + $out .= '
        '; if ($donetodo) { - $tmp=''; - if (get_class($filterobj) == 'Societe') $tmp.=''; - $tmp.=($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); - $tmp.=($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); - $tmp.=($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); + $tmp = ''; + if (get_class($filterobj) == 'Societe') $tmp .= ''; + $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); + $tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); + $tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); //$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort"); - if (get_class($filterobj) == 'Societe') $tmp.=''; - $out.=getTitleFieldOfList($tmp); + if (get_class($filterobj) == 'Societe') $tmp .= ''; + $out .= getTitleFieldOfList($tmp); } @@ -601,69 +601,69 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no foreach ($histo as $key=>$value) { - $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo + $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo - $actionstatic->type_picto=$histo[$key]['apicto']; - $actionstatic->type_code=$histo[$key]['acode']; + $actionstatic->type_picto = $histo[$key]['apicto']; + $actionstatic->type_code = $histo[$key]['acode']; $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$histo[$key]['id']; - $tmpa=dol_getdate($histo[$key]['datestart'], false); - if($actualCycleDate !== $tmpa['year'].'-'.$tmpa['yday']){ + $tmpa = dol_getdate($histo[$key]['datestart'], false); + if ($actualCycleDate !== $tmpa['year'].'-'.$tmpa['yday']) { $actualCycleDate = $tmpa['year'].'-'.$tmpa['yday']; - $out.=''; - $out.='
      • '; - $out.=''; - $out.= dol_print_date($histo[$key]['datestart'], 'daytext', 'tzserver', $langs); - $out.=''; - $out.='
      • '; - $out.=''; + $out .= ''; + $out .= '
      • '; + $out .= ''; + $out .= dol_print_date($histo[$key]['datestart'], 'daytext', 'tzserver', $langs); + $out .= ''; + $out .= '
      • '; + $out .= ''; } - $out.=''."\n"; - $out.='
      • '; + $out .= ''."\n"; + $out .= '
      • '; - $out.=''."\n"; + $out .= ''."\n"; $iconClass = 'fa fa-comments'; $img_picto = ''; $colorClass = ''; $pictoTitle = ''; - if ($histo[$key]['percent']==-1) { + if ($histo[$key]['percent'] == -1) { $colorClass = 'timeline-icon-not-applicble'; $pictoTitle = $langs->trans('StatusNotApplicable'); } - elseif ($histo[$key]['percent']==0) { + elseif ($histo[$key]['percent'] == 0) { $colorClass = 'timeline-icon-todo'; - $pictoTitle = $langs->trans('StatusActionToDo') . ' (0%)'; + $pictoTitle = $langs->trans('StatusActionToDo').' (0%)'; } - elseif ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100){ + elseif ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100) { $colorClass = 'timeline-icon-in-progress'; $pictoTitle = $langs->trans('StatusActionInProcess').' ('.$histo[$key]['percent'].'%)'; } - elseif ($histo[$key]['percent'] >= 100){ + elseif ($histo[$key]['percent'] >= 100) { $colorClass = 'timeline-icon-done'; - $pictoTitle = $langs->trans('StatusActionDone').' (100%)'; + $pictoTitle = $langs->trans('StatusActionDone').' (100%)'; } - if($actionstatic->code == 'AC_TICKET_CREATE'){ + if ($actionstatic->code == 'AC_TICKET_CREATE') { $iconClass = 'fa fa-ticket'; } - elseif($actionstatic->code == 'AC_TICKET_MODIFY'){ + elseif ($actionstatic->code == 'AC_TICKET_MODIFY') { $iconClass = 'fa fa-pencil'; } - elseif($actionstatic->code == 'TICKET_MSG'){ + elseif ($actionstatic->code == 'TICKET_MSG') { $iconClass = 'fa fa-comments'; } - elseif($actionstatic->code == 'TICKET_MSG_PRIVATE'){ + elseif ($actionstatic->code == 'TICKET_MSG_PRIVATE') { $iconClass = 'fa fa-mask'; } elseif (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actionstatic->type_picto) $img_picto = img_picto('', $actionstatic->type_picto); + if ($actionstatic->type_picto) $img_picto = img_picto('', $actionstatic->type_picto); else { if ($actionstatic->type_code == 'AC_RDV') $iconClass = 'fa fa-handshake'; elseif ($actionstatic->type_code == 'AC_TEL') $iconClass = 'fa fa-phone'; @@ -671,24 +671,24 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no elseif ($actionstatic->type_code == 'AC_EMAIL') $iconClass = 'fa fa-envelope'; elseif ($actionstatic->type_code == 'AC_INT') $iconClass = 'fa fa-shipping-fast'; elseif ($actionstatic->type_code == 'AC_OTH_AUTO') $iconClass = 'fa fa-robot'; - elseif (! preg_match('/_AUTO/', $actionstatic->type_code)) $iconClass = 'fa fa-robot'; + elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) $iconClass = 'fa fa-robot'; } } - $out.=''.$img_picto.''."\n"; + $out .= ''.$img_picto.''."\n"; - $out.='
        '."\n"; + $out .= '
        '."\n"; - $out.=''; + $out .= ''; - if (isset($histo[$key]['type']) && $histo[$key]['type']=='mailing') { - $out.=''.img_object($langs->trans("ShowEMailing"), "email").' '; - $out.=$histo[$key]['id']; - $out.=' '; + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { + $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; + $out .= $histo[$key]['id']; + $out .= ' '; } else { - $out.=$actionstatic->getNomUrl(1, -1).' '; + $out .= $actionstatic->getNomUrl(1, -1).' '; } //if ($user->rights->agenda->allactions->read || $actionstatic->authorid == $user->id) @@ -765,16 +765,16 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out .= ''; - $out.=''; + $out .= ''; - if (! empty($histo[$key]['message']) + if (!empty($histo[$key]['message']) && $actionstatic->code != 'AC_TICKET_CREATE' && $actionstatic->code != 'AC_TICKET_MODIFY' ) { - $out.='
        '; - $out.=$histo[$key]['message']; - $out.='
        '; + $out .= '
        '; + $out .= $histo[$key]['message']; + $out .= '
        '; } @@ -792,11 +792,11 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no dol_print_error($db, $contact->error); if ($result > 0) { - $contactList.= !empty($contactList)?', ':''; + $contactList .= !empty($contactList) ? ', ' : ''; $contactList .= $contact->getNomUrl(1); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { - if (! empty($contact->phone_pro)) - $contactList .= '(' . dol_print_phone($contact->phone_pro) . ')'; + if (!empty($contact->phone_pro)) + $contactList .= '('.dol_print_phone($contact->phone_pro).')'; } } } diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 08ac267445d..d6c43edd5c3 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -25,7 +25,7 @@ * \brief File to load import files with CSV format */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/import/modules_import.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php'; /** @@ -43,7 +43,7 @@ class ImportCsv extends ModeleImports /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -60,7 +60,7 @@ class ImportCsv extends ModeleImports */ public $label; - public $extension; // Extension of files imported by driver + public $extension; // Extension of files imported by driver /** * Dolibarr version of driver @@ -68,19 +68,19 @@ class ImportCsv extends ModeleImports */ public $version = 'dolibarr'; - public $label_lib; // Label of external lib used by driver + public $label_lib; // Label of external lib used by driver - public $version_lib; // Version of external lib used by driver + public $version_lib; // Version of external lib used by driver public $separator; - public $file; // Path of file + public $file; // Path of file - public $handle; // Handle fichier + public $handle; // Handle fichier - public $cacheconvert=array(); // Array to cache list of value found after a convertion + public $cacheconvert = array(); // Array to cache list of value found after a convertion - public $cachefieldtable=array(); // Array to cache list of value found into fields@tables + public $cachefieldtable = array(); // Array to cache list of value found into fields@tables public $nbinsert = 0; // # of insert done during the import @@ -98,23 +98,23 @@ class ImportCsv extends ModeleImports global $conf, $langs; $this->db = $db; - $this->separator=(GETPOST('separator')?GETPOST('separator'):(empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE)?',':$conf->global->IMPORT_CSV_SEPARATOR_TO_USE)); - $this->enclosure='"'; - $this->escape='"'; + $this->separator = (GETPOST('separator') ?GETPOST('separator') : (empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? ',' : $conf->global->IMPORT_CSV_SEPARATOR_TO_USE)); + $this->enclosure = '"'; + $this->escape = '"'; - $this->id='csv'; // Same value then xxx in file name export_xxx.modules.php - $this->label='Csv'; // Label of driver - $this->desc=$langs->trans("CSVFormatDesc", $this->separator, $this->enclosure, $this->escape); - $this->extension='csv'; // Extension for generated file by this driver - $this->picto='mime/other'; // Picto - $this->version='1.34'; // Driver version + $this->id = 'csv'; // Same value then xxx in file name export_xxx.modules.php + $this->label = 'Csv'; // Label of driver + $this->desc = $langs->trans("CSVFormatDesc", $this->separator, $this->enclosure, $this->escape); + $this->extension = 'csv'; // Extension for generated file by this driver + $this->picto = 'mime/other'; // Picto + $this->version = '1.34'; // Driver version // If driver use an external library, put its name here - $this->label_lib='Dolibarr'; - $this->version_lib=DOL_VERSION; + $this->label_lib = 'Dolibarr'; + $this->version_lib = DOL_VERSION; - $this->datatoimport=$datatoimport; - if (preg_match('/^societe_/', $datatoimport)) $this->thirpartyobject=new Societe($this->db); + $this->datatoimport = $datatoimport; + if (preg_match('/^societe_/', $datatoimport)) $this->thirpartyobject = new Societe($this->db); } @@ -142,7 +142,7 @@ class ImportCsv extends ModeleImports public function write_title_example($outputlangs, $headerlinefields) { // phpcs:enable - $s=join($this->separator, array_map('cleansep', $headerlinefields)); + $s = join($this->separator, array_map('cleansep', $headerlinefields)); return $s."\n"; } @@ -157,7 +157,7 @@ class ImportCsv extends ModeleImports public function write_record_example($outputlangs, $contentlinevalues) { // phpcs:enable - $s=join($this->separator, array_map('cleansep', $contentlinevalues)); + $s = join($this->separator, array_map('cleansep', $contentlinevalues)); return $s."\n"; } @@ -187,22 +187,22 @@ class ImportCsv extends ModeleImports { // phpcs:enable global $langs; - $ret=1; + $ret = 1; dol_syslog(get_class($this)."::open_file file=".$file); - ini_set('auto_detect_line_endings', 1); // For MAC compatibility + ini_set('auto_detect_line_endings', 1); // For MAC compatibility $this->handle = fopen(dol_osencode($file), "r"); - if (! $this->handle) + if (!$this->handle) { $langs->load("errors"); - $this->error=$langs->trans("ErrorFailToOpenFile", $file); - $ret=-1; + $this->error = $langs->trans("ErrorFailToOpenFile", $file); + $ret = -1; } else { - $this->file=$file; + $this->file = $file; } return $ret; @@ -247,47 +247,47 @@ class ImportCsv extends ModeleImports // phpcs:enable global $conf; - $arrayres=fgetcsv($this->handle, 100000, $this->separator, $this->enclosure, $this->escape); + $arrayres = fgetcsv($this->handle, 100000, $this->separator, $this->enclosure, $this->escape); // End of file if ($arrayres === false) return false; //var_dump($this->handle); //var_dump($arrayres);exit; - $newarrayres=array(); + $newarrayres = array(); if ($arrayres && is_array($arrayres)) { - foreach($arrayres as $key => $val) + foreach ($arrayres as $key => $val) { - if (! empty($conf->global->IMPORT_CSV_FORCE_CHARSET)) // Forced charset + if (!empty($conf->global->IMPORT_CSV_FORCE_CHARSET)) // Forced charset { if (strtolower($conf->global->IMPORT_CSV_FORCE_CHARSET) == 'utf8') { - $newarrayres[$key]['val']=$val; - $newarrayres[$key]['type']=(dol_strlen($val)?1:-1); // If empty we considere it's null + $newarrayres[$key]['val'] = $val; + $newarrayres[$key]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we considere it's null } else { - $newarrayres[$key]['val']=utf8_encode($val); - $newarrayres[$key]['type']=(dol_strlen($val)?1:-1); // If empty we considere it's null + $newarrayres[$key]['val'] = utf8_encode($val); + $newarrayres[$key]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we considere it's null } } else // Autodetect format (UTF8 or ISO) { if (utf8_check($val)) { - $newarrayres[$key]['val']=$val; - $newarrayres[$key]['type']=(dol_strlen($val)?1:-1); // If empty we considere it's null + $newarrayres[$key]['val'] = $val; + $newarrayres[$key]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we considere it's null } else { - $newarrayres[$key]['val']=utf8_encode($val); - $newarrayres[$key]['type']=(dol_strlen($val)?1:-1); // If empty we considere it's null + $newarrayres[$key]['val'] = utf8_encode($val); + $newarrayres[$key]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we considere it's null } } } - $this->col=count($newarrayres); + $this->col = count($newarrayres); } return $newarrayres; @@ -322,21 +322,21 @@ class ImportCsv extends ModeleImports public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) { // phpcs:enable - global $langs,$conf,$user; - global $thirdparty_static; // Specific to thirdparty import - global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables + global $langs, $conf, $user; + global $thirdparty_static; // Specific to thirdparty import + global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables - $error=0; - $warning=0; - $this->errors=array(); - $this->warnings=array(); + $error = 0; + $warning = 0; + $this->errors = array(); + $this->warnings = array(); //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); //var_dump($array_match_file_to_database); //var_dump($arrayrecord); - $array_match_database_to_file=array_flip($array_match_file_to_database); - $sort_array_match_file_to_database=$array_match_file_to_database; + $array_match_database_to_file = array_flip($array_match_file_to_database); + $sort_array_match_file_to_database = $array_match_file_to_database; ksort($sort_array_match_file_to_database); //var_dump($sort_array_match_file_to_database); @@ -344,8 +344,8 @@ class ImportCsv extends ModeleImports if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[0]['val']))) { //print 'W'; - $this->warnings[$warning]['lib']=$langs->trans('EmptyLine'); - $this->warnings[$warning]['type']='EMPTY'; + $this->warnings[$warning]['lib'] = $langs->trans('EmptyLine'); + $this->warnings[$warning]['type'] = 'EMPTY'; $warning++; } else @@ -354,25 +354,25 @@ class ImportCsv extends ModeleImports $updatedone = false; $insertdone = false; // For each table to insert, me make a separate insert - foreach($objimport->array_import_tables[0] as $alias => $tablename) + foreach ($objimport->array_import_tables[0] as $alias => $tablename) { // Build sql request - $sql=''; - $listfields=array(); - $listvalues=array(); - $i=0; - $errorforthistable=0; + $sql = ''; + $listfields = array(); + $listvalues = array(); + $i = 0; + $errorforthistable = 0; // Define $tablewithentity_cache[$tablename] if not already defined - if (! isset($tablewithentity_cache[$tablename])) // keep this test with "isset" + if (!isset($tablewithentity_cache[$tablename])) // keep this test with "isset" { dol_syslog("Check if table ".$tablename." has an entity field"); - $resql=$this->db->DDLDescTable($tablename, 'entity'); + $resql = $this->db->DDLDescTable($tablename, 'entity'); if ($resql) { - $obj=$this->db->fetch_object($resql); - if ($obj) $tablewithentity_cache[$tablename]=1; // table contains entity field - else $tablewithentity_cache[$tablename]=0; // table does not contains entity field + $obj = $this->db->fetch_object($resql); + if ($obj) $tablewithentity_cache[$tablename] = 1; // table contains entity field + else $tablewithentity_cache[$tablename] = 0; // table does not contains entity field } else dol_print_error($this->db); } @@ -388,26 +388,26 @@ class ImportCsv extends ModeleImports } // Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom) - foreach($sort_array_match_file_to_database as $key => $val) + foreach ($sort_array_match_file_to_database as $key => $val) { - $fieldalias=preg_replace('/\..*$/i', '', $val); - $fieldname=preg_replace('/^.*\./i', '', $val); + $fieldalias = preg_replace('/\..*$/i', '', $val); + $fieldname = preg_replace('/^.*\./i', '', $val); - if ($alias != $fieldalias) continue; // Not a field of current table + if ($alias != $fieldalias) continue; // Not a field of current table if ($key <= $maxfields) { // Set $newval with value to insert and set $listvalues with sql request part for insert - $newval=''; - if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value + $newval = ''; + if ($arrayrecord[($key - 1)]['type'] > 0) $newval = $arrayrecord[($key - 1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value // Make some tests on $newval // Is it a required field ? - if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval=='')) + if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval == '')) { - $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue', $key); - $this->errors[$error]['type']='NOTNULL'; + $this->errors[$error]['lib'] = $langs->trans('ErrorMissingMandatoryValue', $key); + $this->errors[$error]['type'] = 'NOTNULL'; $errorforthistable++; $error++; } @@ -415,28 +415,28 @@ class ImportCsv extends ModeleImports else { // We convert field if required - if (! empty($objimport->array_import_convertvalue[0][$val])) + if (!empty($objimport->array_import_convertvalue[0][$val])) { //print 'Must convert '.$newval.' with rule '.join(',',$objimport->array_import_convertvalue[0][$val]).'. '; - if ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeid' - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromref' - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' + if ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeid' + || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromref' + || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeorlabel' ) { // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. - $isidorref='id'; - if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i', $newval)) $isidorref='ref'; - $newval=preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref + $isidorref = 'id'; + if (!is_numeric($newval) && $newval != '' && !preg_match('/^id:/i', $newval)) $isidorref = 'ref'; + $newval = preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref //print 'Val is now '.$newval.' and is type '.$isidorref."
        \n"; if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor { - $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); - $class=$objimport->array_import_convertvalue[0][$val]['class']; - $method=$objimport->array_import_convertvalue[0][$val]['method']; + $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); + $class = $objimport->array_import_convertvalue[0][$val]['class']; + $method = $objimport->array_import_convertvalue[0][$val]['method']; if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '') { - $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; + $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; } else { @@ -446,7 +446,7 @@ class ImportCsv extends ModeleImports dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); // Try the fetch from code or ref $param_array = array('', $newval); if ($class == 'AccountingAccount') @@ -550,11 +550,11 @@ class ImportCsv extends ModeleImports dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', units='.$units); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); // Try the fetch from code or ref call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); - $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$scaleorid; + $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] = $scaleorid; //print 'We have made a '.$class.'->'.$method." to get a value from key '".$newval."' and we got '".$scaleorid."'.";exit; if ($classinstance->id > 0) // we found record { @@ -562,91 +562,91 @@ class ImportCsv extends ModeleImports } else { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; - $this->errors[$error]['type']='FOREIGNKEY'; + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codeclient(0, 0); - $newval=$this->thirpartyobject->code_client; + $newval = $this->thirpartyobject->code_client; //print 'code_client='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsuppliercodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') { if (strtolower($newval) == 'auto') { - $newval=$this->thirpartyobject->get_codefournisseur(0, 1); - $newval=$this->thirpartyobject->code_fournisseur; + $newval = $this->thirpartyobject->get_codefournisseur(0, 1); + $newval = $this->thirpartyobject->code_fournisseur; //print 'code_fournisseur='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomeraccountancycodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('customer'); - $newval=$this->thirpartyobject->code_compta; + $newval = $this->thirpartyobject->code_compta; //print 'code_compta='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsupplieraccountancycodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('supplier'); - $newval=$this->thirpartyobject->code_compta_fournisseur; - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + $newval = $this->thirpartyobject->code_compta_fournisseur; + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" //print 'code_compta_fournisseur='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getrefifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getrefifauto') { - $defaultref=''; + $defaultref = ''; // TODO provide the $modTask (module of generation of ref) as parameter of import_insert function - $obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON; - if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) { - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; + require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; $modTask = new $obj; $defaultref = $modTask->getNextValue(null, null); } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; - $newval=$defaultref; + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; + $newval = $defaultref; } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='compute') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'compute') { - $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); - $class=$objimport->array_import_convertvalue[0][$val]['class']; - $method=$objimport->array_import_convertvalue[0][$val]['method']; + $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); + $class = $objimport->array_import_convertvalue[0][$val]['class']; + $method = $objimport->array_import_convertvalue[0][$val]['method']; $resultload = dol_include_once($file); if (empty($resultload)) { dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord)); - if ($res<0) { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; - $this->errors[$error]['type']='FOREIGNKEY'; + if ($res < 0) { + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { $newval = price2num($newval); } @@ -655,36 +655,36 @@ class ImportCsv extends ModeleImports } // Test regexp - if (! empty($objimport->array_import_regex[0][$val]) && ($newval != '')) + if (!empty($objimport->array_import_regex[0][$val]) && ($newval != '')) { // If test is "Must exist in a field@table or field@table:..." if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) { - $field=$reg[1]; - $table=$reg[2]; - $filter=!empty($reg[3])?substr($reg[3], 1):''; + $field = $reg[1]; + $table = $reg[2]; + $filter = !empty($reg[3]) ?substr($reg[3], 1) : ''; $cachekey = $field.'@'.$table; - if(! empty($filter)) $cachekey.= ':'.$filter; + if (!empty($filter)) $cachekey .= ':'.$filter; // Load content of field@table into cache array - if (! is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache + if (!is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache { - $sql="SELECT ".$field." as aliasfield FROM ".$table; - if(! empty($filter)) + $sql = "SELECT ".$field." as aliasfield FROM ".$table; + if (!empty($filter)) { - $sql.= ' WHERE ' . $filter; + $sql .= ' WHERE '.$filter; } - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { - $obj=$this->db->fetch_object($resql); - if ($obj) $this->cachefieldtable[$cachekey][]=$obj->aliasfield; + $obj = $this->db->fetch_object($resql); + if ($obj) $this->cachefieldtable[$cachekey][] = $obj->aliasfield; $i++; } } @@ -695,21 +695,21 @@ class ImportCsv extends ModeleImports } // Now we check cache is not empty (should not) and key is into cache - if (! is_array($this->cachefieldtable[$cachekey]) || ! in_array($newval, $this->cachefieldtable[$cachekey])) + if (!is_array($this->cachefieldtable[$cachekey]) || !in_array($newval, $this->cachefieldtable[$cachekey])) { $tableforerror = $table; - if(! empty($filter)) $tableforerror.= ':'.$filter; - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); - $this->errors[$error]['type']='FOREIGNKEY'; + if (!empty($filter)) $tableforerror .= ':'.$filter; + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } // If test is just a static regex - elseif (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { + elseif (!preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."
        "; - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); - $this->errors[$error]['type']='REGEX'; + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); + $this->errors[$error]['type'] = 'REGEX'; $errorforthistable++; $error++; } @@ -723,9 +723,9 @@ class ImportCsv extends ModeleImports $listfields[] = $fieldname; // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) { - $listvalues[] = ($newval=='0'?$newval:"null"); - } elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) { + if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) { + $listvalues[] = ($newval == '0' ? $newval : "null"); + } elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) { $listvalues[] = "''"; } else { $listvalues[] = "'".$this->db->escape($newval)."'"; @@ -738,9 +738,9 @@ class ImportCsv extends ModeleImports if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) { // Loop on each hidden fields to add them into listfields/listvalues - foreach($objimport->array_import_fieldshidden[0] as $key => $val) + foreach ($objimport->array_import_fieldshidden[0] as $key => $val) { - if (! preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table + if (!preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table if ($val == 'user->id') { $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); @@ -748,8 +748,8 @@ class ImportCsv extends ModeleImports } elseif (preg_match('/^lastrowid-/', $val)) { - $tmp=explode('-', $val); - $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; + $tmp = explode('-', $val); + $lastinsertid = (isset($last_insert_id_array[$tmp[1]])) ? $last_insert_id_array[$tmp[1]] : 0; $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listfields[] = $keyfield; $listvalues[] = $lastinsertid; @@ -757,14 +757,14 @@ class ImportCsv extends ModeleImports } elseif (preg_match('/^const-/', $val)) { - $tmp=explode('-', $val, 2); + $tmp = explode('-', $val, 2); $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listvalues[] = "'".$tmp[1]."'"; } else { - $this->errors[$error]['lib']='Bad value of profile setup '.$val.' for array_import_fieldshidden'; - $this->errors[$error]['type']='Import profile setup'; + $this->errors[$error]['lib'] = 'Bad value of profile setup '.$val.' for array_import_fieldshidden'; + $this->errors[$error]['type'] = 'Import profile setup'; $error++; } } @@ -773,7 +773,7 @@ class ImportCsv extends ModeleImports // If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined // so we can try to make the insert or update now. - if (! $errorforthistable) + if (!$errorforthistable) { //print "$alias/$tablename/$listfields/$listvalues
        "; if (!empty($listfields)) @@ -792,21 +792,21 @@ class ImportCsv extends ModeleImports $filters = array(); foreach ($updatekeys as $key) { $col = $objimport->array_import_updatekeys[0][$key]; - $key=preg_replace('/^.*\./i', '', $key); + $key = preg_replace('/^.*\./i', '', $key); $where[] = $key.' = '.$data[$key]; $filters[] = $col.' = '.$data[$key]; } - $sqlSelect.= ' WHERE '.implode(' AND ', $where); + $sqlSelect .= ' WHERE '.implode(' AND ', $where); - $resql=$this->db->query($sqlSelect); - if($resql) { + $resql = $this->db->query($sqlSelect); + if ($resql) { $res = $this->db->fetch_object($resql); - if($resql->num_rows == 1) { + if ($resql->num_rows == 1) { $lastinsertid = $res->rowid; $last_insert_id_array[$tablename] = $lastinsertid; - } elseif($resql->num_rows > 1) { - $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); - $this->errors[$error]['type']='SQL'; + } elseif ($resql->num_rows > 1) { + $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); + $this->errors[$error]['type'] = 'SQL'; $error++; } else { // No record found with filters, insert will be tried below @@ -815,8 +815,8 @@ class ImportCsv extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } else { @@ -827,13 +827,13 @@ class ImportCsv extends ModeleImports // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' $sqlSelect = 'SELECT rowid FROM '.$tablename; - if(empty($keyfield)) $keyfield = 'rowid'; + if (empty($keyfield)) $keyfield = 'rowid'; $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; - $resql=$this->db->query($sqlSelect); - if($resql) { + $resql = $this->db->query($sqlSelect); + if ($resql) { $res = $this->db->fetch_object($resql); - if($resql->num_rows == 1) { + if ($resql->num_rows == 1) { // We have a row referencing this last foreign key, continue with UPDATE. } else { // No record found referencing this last foreign key, @@ -844,8 +844,8 @@ class ImportCsv extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -859,24 +859,24 @@ class ImportCsv extends ModeleImports foreach ($data as $key => $val) { $set[] = $key.' = '.$val; } - $sqlstart.= ' SET '.implode(', ', $set); + $sqlstart .= ' SET '.implode(', ', $set); - if(empty($keyfield)) $keyfield = 'rowid'; + if (empty($keyfield)) $keyfield = 'rowid'; $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; $sql = $sqlstart.$sqlend; // Run update request - $resql=$this->db->query($sql); - if($resql) { + $resql = $this->db->query($sql); + if ($resql) { // No error, update has been done. $this->db->db->affected_rows can be 0 if data hasn't changed $updatedone = true; } else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -887,13 +887,13 @@ class ImportCsv extends ModeleImports // Build SQL INSERT request $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'"; - if (! empty($tablewithentity_cache[$tablename])) { - $sqlstart.= ', entity'; - $sqlend.= ', '.$conf->entity; + if (!empty($tablewithentity_cache[$tablename])) { + $sqlstart .= ', entity'; + $sqlend .= ', '.$conf->entity; } - if (! empty($objimport->array_import_tables_creator[0][$alias])) { - $sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias]; - $sqlend.=', '.$user->id; + if (!empty($objimport->array_import_tables_creator[0][$alias])) { + $sqlstart .= ', '.$objimport->array_import_tables_creator[0][$alias]; + $sqlend .= ', '.$user->id; } $sql = $sqlstart.$sqlend.')'; dol_syslog("import_csv.modules", LOG_DEBUG); @@ -901,7 +901,7 @@ class ImportCsv extends ModeleImports // Run insert request if ($sql) { - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). @@ -910,8 +910,8 @@ class ImportCsv extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -926,8 +926,8 @@ class ImportCsv extends ModeleImports if ($error) break; } - if($updatedone) $this->nbupdate++; - if($insertdone) $this->nbinsert++; + if ($updatedone) $this->nbupdate++; + if ($insertdone) $this->nbinsert++; } return 1; @@ -942,5 +942,5 @@ class ImportCsv extends ModeleImports */ function cleansep($value) { - return str_replace(array(',',';'), '/', $value); + return str_replace(array(',', ';'), '/', $value); }; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index c5fcc1441e3..03b3f941a1d 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -25,7 +25,7 @@ * \brief File to load import files with Excel format */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/import/modules_import.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php'; /** @@ -43,7 +43,7 @@ class ImportXlsx extends ModeleImports /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -60,7 +60,7 @@ class ImportXlsx extends ModeleImports */ public $label; - public $extension; // Extension of files imported by driver + public $extension; // Extension of files imported by driver /** * Dolibarr version of driver @@ -68,19 +68,19 @@ class ImportXlsx extends ModeleImports */ public $version = 'dolibarr'; - public $label_lib; // Label of external lib used by driver + public $label_lib; // Label of external lib used by driver - public $version_lib; // Version of external lib used by driver + public $version_lib; // Version of external lib used by driver public $separator; - public $file; // Path of file + public $file; // Path of file - public $handle; // Handle fichier + public $handle; // Handle fichier - public $cacheconvert=array(); // Array to cache list of value found after a convertion + public $cacheconvert = array(); // Array to cache list of value found after a convertion - public $cachefieldtable=array(); // Array to cache list of value found into fields@tables + public $cachefieldtable = array(); // Array to cache list of value found into fields@tables public $workbook; // temporary import file @@ -97,31 +97,31 @@ class ImportXlsx extends ModeleImports */ public function __construct($db, $datatoimport) { - global $conf,$langs; + global $conf, $langs; $this->db = $db; // this is used as an extension from the example file code, so we have to put xlsx here !!! - $this->id='xlsx'; // Same value as xxx in file name export_xxx.modules.php - $this->label='Excel 2007'; // Label of driver - $this->desc=$langs->trans("Excel2007FormatDesc"); - $this->extension='xlsx'; // Extension for generated file by this driver - $this->picto='mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) - $this->version='1.0'; // Driver version + $this->id = 'xlsx'; // Same value as xxx in file name export_xxx.modules.php + $this->label = 'Excel 2007'; // Label of driver + $this->desc = $langs->trans("Excel2007FormatDesc"); + $this->extension = 'xlsx'; // Extension for generated file by this driver + $this->picto = 'mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) + $this->version = '1.0'; // Driver version // If driver use an external library, put its name here require_once PHPEXCEL_PATH.'PHPExcel.php'; require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; - if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive + if (!class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive { $langs->load("errors"); - $this->error=$langs->trans('ErrorPHPNeedModule', 'zip'); + $this->error = $langs->trans('ErrorPHPNeedModule', 'zip'); return -1; } - $this->label_lib='PhpExcel'; - $this->version_lib='1.8.0'; + $this->label_lib = 'PhpExcel'; + $this->version_lib = '1.8.0'; - $this->datatoimport=$datatoimport; - if (preg_match('/^societe_/', $datatoimport)) $this->thirpartyobject=new Societe($this->db); + $this->datatoimport = $datatoimport; + if (preg_match('/^societe_/', $datatoimport)) $this->thirpartyobject = new Societe($this->db); } @@ -135,11 +135,11 @@ class ImportXlsx extends ModeleImports public function write_header_example($outputlangs) { // phpcs:enable - global $user,$conf,$langs; + global $user, $conf, $langs; // create a temporary object, the final output will be generated in footer if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) { $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM; - $cacheSettings = array ( + $cacheSettings = array( 'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR ); PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); @@ -174,7 +174,7 @@ class ImportXlsx extends ModeleImports $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); $col = 0; - foreach($headerlinefields as $field) { + foreach ($headerlinefields as $field) { $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, 1, $outputlangs->transnoentities($field)); // set autowidth //$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($col + 1))->setAutoSize(true); @@ -197,7 +197,7 @@ class ImportXlsx extends ModeleImports // phpcs:enable $col = 0; $row = 2; - foreach($contentlinevalues as $cell) { + foreach ($contentlinevalues as $cell) { $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, $row, $cell); $col++; } @@ -240,7 +240,7 @@ class ImportXlsx extends ModeleImports { // phpcs:enable global $langs; - $ret=1; + $ret = 1; dol_syslog(get_class($this)."::open_file file=".$file); @@ -287,7 +287,7 @@ class ImportXlsx extends ModeleImports // This is not called by the import code !!! $this->headers = array(); $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn()); - for($col=0;$col<$colcount;$col++) { + for ($col = 0; $col < $colcount; $col++) { $this->headers[$col] = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, 1)->getValue(); } return 0; @@ -306,14 +306,14 @@ class ImportXlsx extends ModeleImports global $conf; $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); - if($this->record > $rowcount) + if ($this->record > $rowcount) return false; $array = array(); $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn(0)); - for($col=0;$col<$colcount;$col++) { + for ($col = 0; $col < $colcount; $col++) { $val = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, $this->record)->getValue(); $array[$col]['val'] = $val; - $array[$col]['type'] = (dol_strlen($val)?1:-1); // If empty we consider it null + $array[$col]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we consider it null } $this->record++; return $array; @@ -349,21 +349,21 @@ class ImportXlsx extends ModeleImports public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) { // phpcs:enable - global $langs,$conf,$user; - global $thirdparty_static; // Specific to thirdparty import - global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables + global $langs, $conf, $user; + global $thirdparty_static; // Specific to thirdparty import + global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables - $error=0; - $warning=0; - $this->errors=array(); - $this->warnings=array(); + $error = 0; + $warning = 0; + $this->errors = array(); + $this->warnings = array(); //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); //var_dump($array_match_file_to_database); //var_dump($arrayrecord); - $array_match_database_to_file=array_flip($array_match_file_to_database); - $sort_array_match_file_to_database=$array_match_file_to_database; + $array_match_database_to_file = array_flip($array_match_file_to_database); + $sort_array_match_file_to_database = $array_match_file_to_database; ksort($sort_array_match_file_to_database); //var_dump($sort_array_match_file_to_database); @@ -371,8 +371,8 @@ class ImportXlsx extends ModeleImports if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[0]['val']))) { //print 'W'; - $this->warnings[$warning]['lib']=$langs->trans('EmptyLine'); - $this->warnings[$warning]['type']='EMPTY'; + $this->warnings[$warning]['lib'] = $langs->trans('EmptyLine'); + $this->warnings[$warning]['type'] = 'EMPTY'; $warning++; } else @@ -381,25 +381,25 @@ class ImportXlsx extends ModeleImports $updatedone = false; $insertdone = false; // For each table to insert, me make a separate insert - foreach($objimport->array_import_tables[0] as $alias => $tablename) + foreach ($objimport->array_import_tables[0] as $alias => $tablename) { // Build sql request - $sql=''; - $listfields=array(); - $listvalues=array(); - $i=0; - $errorforthistable=0; + $sql = ''; + $listfields = array(); + $listvalues = array(); + $i = 0; + $errorforthistable = 0; // Define $tablewithentity_cache[$tablename] if not already defined - if (! isset($tablewithentity_cache[$tablename])) // keep this test with "isset" + if (!isset($tablewithentity_cache[$tablename])) // keep this test with "isset" { dol_syslog("Check if table ".$tablename." has an entity field"); - $resql=$this->db->DDLDescTable($tablename, 'entity'); + $resql = $this->db->DDLDescTable($tablename, 'entity'); if ($resql) { - $obj=$this->db->fetch_object($resql); - if ($obj) $tablewithentity_cache[$tablename]=1; // table contains entity field - else $tablewithentity_cache[$tablename]=0; // table does not contains entity field + $obj = $this->db->fetch_object($resql); + if ($obj) $tablewithentity_cache[$tablename] = 1; // table contains entity field + else $tablewithentity_cache[$tablename] = 0; // table does not contains entity field } else dol_print_error($this->db); } @@ -415,26 +415,26 @@ class ImportXlsx extends ModeleImports } // Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom) - foreach($sort_array_match_file_to_database as $key => $val) + foreach ($sort_array_match_file_to_database as $key => $val) { - $fieldalias=preg_replace('/\..*$/i', '', $val); - $fieldname=preg_replace('/^.*\./i', '', $val); + $fieldalias = preg_replace('/\..*$/i', '', $val); + $fieldname = preg_replace('/^.*\./i', '', $val); - if ($alias != $fieldalias) continue; // Not a field of current table + if ($alias != $fieldalias) continue; // Not a field of current table if ($key <= $maxfields) { // Set $newval with value to insert and set $listvalues with sql request part for insert - $newval=''; - if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value + $newval = ''; + if ($arrayrecord[($key - 1)]['type'] > 0) $newval = $arrayrecord[($key - 1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value // Make some tests on $newval // Is it a required field ? - if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval=='')) + if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval == '')) { - $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue', $key); - $this->errors[$error]['type']='NOTNULL'; + $this->errors[$error]['lib'] = $langs->trans('ErrorMissingMandatoryValue', $key); + $this->errors[$error]['type'] = 'NOTNULL'; $errorforthistable++; $error++; } @@ -442,28 +442,28 @@ class ImportXlsx extends ModeleImports else { // We convert field if required - if (! empty($objimport->array_import_convertvalue[0][$val])) + if (!empty($objimport->array_import_convertvalue[0][$val])) { //print 'Must convert '.$newval.' with rule '.join(',',$objimport->array_import_convertvalue[0][$val]).'. '; - if ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeid' - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromref' - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' + if ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeid' + || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromref' + || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeorlabel' ) { // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. - $isidorref='id'; - if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i', $newval)) $isidorref='ref'; - $newval=preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref + $isidorref = 'id'; + if (!is_numeric($newval) && $newval != '' && !preg_match('/^id:/i', $newval)) $isidorref = 'ref'; + $newval = preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref //print 'Val is now '.$newval.' and is type '.$isidorref."
        \n"; if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor { - $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); - $class=$objimport->array_import_convertvalue[0][$val]['class']; - $method=$objimport->array_import_convertvalue[0][$val]['method']; + $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); + $class = $objimport->array_import_convertvalue[0][$val]['class']; + $method = $objimport->array_import_convertvalue[0][$val]['method']; if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '') { - $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; + $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; } else { @@ -473,7 +473,7 @@ class ImportXlsx extends ModeleImports dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); // Try the fetch from code or ref $param_array = array('', $newval); if ($class == 'AccountingAccount') @@ -577,11 +577,11 @@ class ImportXlsx extends ModeleImports dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', units='.$units); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); // Try the fetch from code or ref call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); - $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$scaleorid; + $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] = $scaleorid; //print 'We have made a '.$class.'->'.$method." to get a value from key '".$newval."' and we got '".$scaleorid."'.";exit; if ($classinstance->id > 0) // we found record { @@ -589,91 +589,91 @@ class ImportXlsx extends ModeleImports } else { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; - $this->errors[$error]['type']='FOREIGNKEY'; + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codeclient(0, 0); - $newval=$this->thirpartyobject->code_client; + $newval = $this->thirpartyobject->code_client; //print 'code_client='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsuppliercodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') { if (strtolower($newval) == 'auto') { - $newval=$this->thirpartyobject->get_codefournisseur(0, 1); - $newval=$this->thirpartyobject->code_fournisseur; + $newval = $this->thirpartyobject->get_codefournisseur(0, 1); + $newval = $this->thirpartyobject->code_fournisseur; //print 'code_fournisseur='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomeraccountancycodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('customer'); - $newval=$this->thirpartyobject->code_compta; + $newval = $this->thirpartyobject->code_compta; //print 'code_compta='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsupplieraccountancycodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('supplier'); - $newval=$this->thirpartyobject->code_compta_fournisseur; - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + $newval = $this->thirpartyobject->code_compta_fournisseur; + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" //print 'code_compta_fournisseur='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getrefifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getrefifauto') { - $defaultref=''; + $defaultref = ''; // TODO provide the $modTask (module of generation of ref) as parameter of import_insert function - $obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON; - if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) { - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; + require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; $modTask = new $obj; $defaultref = $modTask->getNextValue(null, null); } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; - $newval=$defaultref; + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; + $newval = $defaultref; } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='compute') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'compute') { - $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); - $class=$objimport->array_import_convertvalue[0][$val]['class']; - $method=$objimport->array_import_convertvalue[0][$val]['method']; + $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); + $class = $objimport->array_import_convertvalue[0][$val]['class']; + $method = $objimport->array_import_convertvalue[0][$val]['method']; $resultload = dol_include_once($file); if (empty($resultload)) { dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord)); - if ($res<0) { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; - $this->errors[$error]['type']='FOREIGNKEY'; + if ($res < 0) { + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { $newval = price2num($newval); } @@ -682,36 +682,36 @@ class ImportXlsx extends ModeleImports } // Test regexp - if (! empty($objimport->array_import_regex[0][$val]) && ($newval != '')) + if (!empty($objimport->array_import_regex[0][$val]) && ($newval != '')) { // If test is "Must exist in a field@table or field@table:..." if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) { - $field=$reg[1]; - $table=$reg[2]; - $filter=!empty($reg[3])?substr($reg[3], 1):''; + $field = $reg[1]; + $table = $reg[2]; + $filter = !empty($reg[3]) ?substr($reg[3], 1) : ''; $cachekey = $field.'@'.$table; - if(! empty($filter)) $cachekey.= ':'.$filter; + if (!empty($filter)) $cachekey .= ':'.$filter; // Load content of field@table into cache array - if (! is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache + if (!is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache { - $sql="SELECT ".$field." as aliasfield FROM ".$table; - if(! empty($filter)) + $sql = "SELECT ".$field." as aliasfield FROM ".$table; + if (!empty($filter)) { - $sql.= ' WHERE ' . $filter; + $sql .= ' WHERE '.$filter; } - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { - $obj=$this->db->fetch_object($resql); - if ($obj) $this->cachefieldtable[$cachekey][]=$obj->aliasfield; + $obj = $this->db->fetch_object($resql); + if ($obj) $this->cachefieldtable[$cachekey][] = $obj->aliasfield; $i++; } } @@ -722,21 +722,21 @@ class ImportXlsx extends ModeleImports } // Now we check cache is not empty (should not) and key is into cache - if (! is_array($this->cachefieldtable[$cachekey]) || ! in_array($newval, $this->cachefieldtable[$cachekey])) + if (!is_array($this->cachefieldtable[$cachekey]) || !in_array($newval, $this->cachefieldtable[$cachekey])) { $tableforerror = $table; - if(! empty($filter)) $tableforerror.= ':'.$filter; - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); - $this->errors[$error]['type']='FOREIGNKEY'; + if (!empty($filter)) $tableforerror .= ':'.$filter; + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } // If test is just a static regex - elseif (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { + elseif (!preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."
        "; - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); - $this->errors[$error]['type']='REGEX'; + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); + $this->errors[$error]['type'] = 'REGEX'; $errorforthistable++; $error++; } @@ -750,8 +750,8 @@ class ImportXlsx extends ModeleImports $listfields[] = $fieldname; // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues[] = ($newval=='0'?$newval:"null"); - elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues[] = "''"; + if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) $listvalues[] = ($newval == '0' ? $newval : "null"); + elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) $listvalues[] = "''"; else $listvalues[] = "'".$this->db->escape($newval)."'"; } $i++; @@ -761,9 +761,9 @@ class ImportXlsx extends ModeleImports if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) { // Loop on each hidden fields to add them into listfields/listvalues - foreach($objimport->array_import_fieldshidden[0] as $key => $val) + foreach ($objimport->array_import_fieldshidden[0] as $key => $val) { - if (! preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table + if (!preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table if ($val == 'user->id') { $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); @@ -771,8 +771,8 @@ class ImportXlsx extends ModeleImports } elseif (preg_match('/^lastrowid-/', $val)) { - $tmp=explode('-', $val); - $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; + $tmp = explode('-', $val); + $lastinsertid = (isset($last_insert_id_array[$tmp[1]])) ? $last_insert_id_array[$tmp[1]] : 0; $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listfields[] = $keyfield; $listvalues[] = $lastinsertid; @@ -780,14 +780,14 @@ class ImportXlsx extends ModeleImports } elseif (preg_match('/^const-/', $val)) { - $tmp=explode('-', $val, 2); + $tmp = explode('-', $val, 2); $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listvalues[] = "'".$tmp[1]."'"; } else { - $this->errors[$error]['lib']='Bad value of profile setup '.$val.' for array_import_fieldshidden'; - $this->errors[$error]['type']='Import profile setup'; + $this->errors[$error]['lib'] = 'Bad value of profile setup '.$val.' for array_import_fieldshidden'; + $this->errors[$error]['type'] = 'Import profile setup'; $error++; } } @@ -796,7 +796,7 @@ class ImportXlsx extends ModeleImports // If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined // so we can try to make the insert or update now. - if (! $errorforthistable) + if (!$errorforthistable) { //print "$alias/$tablename/$listfields/$listvalues
        "; if (!empty($listfields)) @@ -814,21 +814,21 @@ class ImportXlsx extends ModeleImports $filters = array(); foreach ($updatekeys as $key) { $col = $objimport->array_import_updatekeys[0][$key]; - $key=preg_replace('/^.*\./i', '', $key); + $key = preg_replace('/^.*\./i', '', $key); $where[] = $key.' = '.$data[$key]; $filters[] = $col.' = '.$data[$key]; } - $sqlSelect.= ' WHERE '.implode(' AND ', $where); + $sqlSelect .= ' WHERE '.implode(' AND ', $where); - $resql=$this->db->query($sqlSelect); - if($resql) { + $resql = $this->db->query($sqlSelect); + if ($resql) { $res = $this->db->fetch_object($resql); - if($resql->num_rows == 1) { + if ($resql->num_rows == 1) { $lastinsertid = $res->rowid; $last_insert_id_array[$tablename] = $lastinsertid; - } elseif($resql->num_rows > 1) { - $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); - $this->errors[$error]['type']='SQL'; + } elseif ($resql->num_rows > 1) { + $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); + $this->errors[$error]['type'] = 'SQL'; $error++; } else { // No record found with filters, insert will be tried below @@ -837,8 +837,8 @@ class ImportXlsx extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } else { @@ -849,13 +849,13 @@ class ImportXlsx extends ModeleImports // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' $sqlSelect = 'SELECT rowid FROM '.$tablename; - if(empty($keyfield)) $keyfield = 'rowid'; + if (empty($keyfield)) $keyfield = 'rowid'; $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; - $resql=$this->db->query($sqlSelect); - if($resql) { + $resql = $this->db->query($sqlSelect); + if ($resql) { $res = $this->db->fetch_object($resql); - if($resql->num_rows == 1) { + if ($resql->num_rows == 1) { // We have a row referencing this last foreign key, continue with UPDATE. } else { // No record found referencing this last foreign key, @@ -866,8 +866,8 @@ class ImportXlsx extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -881,24 +881,24 @@ class ImportXlsx extends ModeleImports foreach ($data as $key => $val) { $set[] = $key.' = '.$val; } - $sqlstart.= ' SET '.implode(', ', $set); + $sqlstart .= ' SET '.implode(', ', $set); - if(empty($keyfield)) $keyfield = 'rowid'; + if (empty($keyfield)) $keyfield = 'rowid'; $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; $sql = $sqlstart.$sqlend; // Run update request - $resql=$this->db->query($sql); - if($resql) { + $resql = $this->db->query($sql); + if ($resql) { // No error, update has been done. $this->db->db->affected_rows can be 0 if data hasn't changed $updatedone = true; } else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -909,13 +909,13 @@ class ImportXlsx extends ModeleImports // Build SQL INSERT request $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'"; - if (! empty($tablewithentity_cache[$tablename])) { - $sqlstart.= ', entity'; - $sqlend.= ', '.$conf->entity; + if (!empty($tablewithentity_cache[$tablename])) { + $sqlstart .= ', entity'; + $sqlend .= ', '.$conf->entity; } - if (! empty($objimport->array_import_tables_creator[0][$alias])) { - $sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias]; - $sqlend.=', '.$user->id; + if (!empty($objimport->array_import_tables_creator[0][$alias])) { + $sqlstart .= ', '.$objimport->array_import_tables_creator[0][$alias]; + $sqlend .= ', '.$user->id; } $sql = $sqlstart.$sqlend.')'; dol_syslog("import_xlsx.modules", LOG_DEBUG); @@ -923,7 +923,7 @@ class ImportXlsx extends ModeleImports // Run insert request if ($sql) { - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). @@ -932,8 +932,8 @@ class ImportXlsx extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -948,8 +948,8 @@ class ImportXlsx extends ModeleImports if ($error) break; } - if($updatedone) $this->nbupdate++; - if($insertdone) $this->nbinsert++; + if ($updatedone) $this->nbupdate++; + if ($insertdone) $this->nbinsert++; } return 1; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index b6a9f968a02..b15bd41f9bb 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -29,7 +29,7 @@ * \ingroup produit * \brief File to describe module to manage catalog of predefined products */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -59,25 +59,25 @@ class modProduct extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto='product'; + $this->picto = 'product'; // Data directories to create when module is enabled $this->dirs = array("/product/temp"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array("modStock","modBarcode","modProductBatch","modVariants"); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with - $this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants"); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5, 4); // Minimum version of PHP required by module // Config pages $this->config_page_url = array("product.php@product"); - $this->langfiles = array("products","companies","stocks","bills"); + $this->langfiles = array("products", "companies", "stocks", "bills"); // Constants $this->const = array(); - $r=0; + $r = 0; $this->const[$r][0] = "PRODUCT_CODEPRODUCT_ADDON"; $this->const[$r][1] = "chaine"; @@ -102,15 +102,15 @@ class modProduct extends DolibarrModules // Boxes $this->boxes = array( - 0=>array('file'=>'box_produits.php','enabledbydefaulton'=>'Home'), - 1=>array('file'=>'box_produits_alerte_stock.php','enabledbydefaulton'=>''), - 2=>array('file'=>'box_graph_product_distribution.php','enabledbydefaulton'=>'Home') + 0=>array('file'=>'box_produits.php', 'enabledbydefaulton'=>'Home'), + 1=>array('file'=>'box_produits_alerte_stock.php', 'enabledbydefaulton'=>''), + 2=>array('file'=>'box_graph_product_distribution.php', 'enabledbydefaulton'=>'Home') ); // Permissions $this->rights = array(); $this->rights_class = 'produit'; - $r=0; + $r = 0; $this->rights[$r][0] = 31; // id de la permission $this->rights[$r][1] = 'Read products'; // libelle de la permission @@ -133,7 +133,7 @@ class modProduct extends DolibarrModules $this->rights[$r][4] = 'supprimer'; $r++; - $this->rights[$r][0] = 38; // Must be same permission than in service module + $this->rights[$r][0] = 38; // Must be same permission than in service module $this->rights[$r][1] = 'Export products'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; @@ -150,7 +150,7 @@ class modProduct extends DolibarrModules // Menus //------- - $this->menu = 1; // This module adds menu entries. They are coded into menu manager. + $this->menu = 1; // This module adds menu entries. They are coded into menu manager. /* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts $r=0; $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode @@ -398,28 +398,28 @@ class modProduct extends DolibarrModules 'p.surface_units' => "SurfaceUnit", 'p.volume' => "Volume", 'p.volume_units' => "VolumeUnits", - 'p.duration' => "Duration",//duration of service + 'p.duration' => "Duration", //duration of service 'p.finished' => 'Nature', - 'p.price' => "SellingPriceHT",//without + 'p.price' => "SellingPriceHT", //without 'p.price_min' => "MinPrice", - 'p.price_ttc' => "SellingPriceTTC",//with tax + 'p.price_ttc' => "SellingPriceTTC", //with tax 'p.price_min_ttc' => "SellingMinPriceTTC", - 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card + 'p.price_base_type' => "PriceBaseType", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card 'p.tva_tx' => 'VATRate', 'p.datec' => 'DateCreation', 'p.cost_price' => "CostPrice", ); if (!empty($conf->stock->enabled)) {//if Stock module enabled $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( - 'p.seuil_stock_alerte' => 'StockLimit',//lower limit for warning - 'p.pmp' => 'PMPValue',//weighted average price + 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning + 'p.pmp' => 'PMPValue', //weighted average price 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature )); } $this->import_convertvalue_array[$r] = array( 'p.weight_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -427,7 +427,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.length_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -435,7 +435,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.width_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -443,7 +443,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.height_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -451,7 +451,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.surface_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -459,7 +459,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.volume_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -475,29 +475,29 @@ class modProduct extends DolibarrModules ) ); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); - if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); + if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields - $import_extrafield_sample=array(); - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; - $resql=$this->db->query($sql); + $import_extrafield_sample = array(); + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; + $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); - $import_extrafield_sample[$fieldname]=$fieldlabel; + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + $import_extrafield_sample[$fieldname] = $fieldlabel; } } // End add extra fields - $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r]=array( + $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_regex_array[$r] = array( 'p.ref' => '[^ ]', 'p.price_base_type' => '\AHT\z|\ATTC\z', 'p.tosell' => '^[0|1]$', @@ -523,7 +523,7 @@ class modProduct extends DolibarrModules 'p.price_ttc' => "110", 'p.price_min_ttc' => "110", 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", - 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' + 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", 'p.fk_product_type' => "0 (product) / 1 (service)", @@ -534,17 +534,17 @@ class modProduct extends DolibarrModules 'p.accountancy_code_sell_export' => "", 'p.accountancy_code_buy' => "", 'p.weight' => "", - 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.length' => "", - 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.width' => "", - 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.height' => "", - 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.surface' => "", - 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.volume' => "", - 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.finished' => '0 (raw material) / 1 (finished goods)' ); //clauses copied from import_fields_array @@ -553,16 +553,16 @@ class modProduct extends DolibarrModules 'p.pmp' => '0', 'p.desiredstock' => '' )); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'90')); - if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); - if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>'')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) { + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); + if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); + if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>'')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $import_sample = array_merge( $import_sample, array( - 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "' . MAIN_DB_PREFIX . 'c_units"' + 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"' ) ); @@ -577,21 +577,21 @@ class modProduct extends DolibarrModules ) )); } - $this->import_examplevalues_array[$r]=array_merge($import_sample, $import_extrafield_sample); + $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); - if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled + if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled - if (! empty($conf->fournisseur->enabled)) + if (!empty($conf->fournisseur->enabled)) { // Import suppliers prices (note: this code is duplicated in module Service) $r++; - $this->import_code[$r]=$this->rights_class.'_supplierprices'; - $this->import_label[$r]="SuppliersPricesOfProductsOrServices"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); - $this->import_tables_creator_array[$r]=array('sp'=>'fk_user'); - $this->import_fields_array[$r]=array(//field order as per structure of table llx_product_fournisseur_price, without optional fields + $this->import_code[$r] = $this->rights_class.'_supplierprices'; + $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); + $this->import_tables_creator_array[$r] = array('sp'=>'fk_user'); + $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields 'sp.fk_product'=>"ProductOrService*", 'sp.fk_soc' => "Supplier*", 'sp.ref_fourn' => 'SupplierRef', @@ -601,19 +601,19 @@ class modProduct extends DolibarrModules 'sp.delivery_time_days' => 'DeliveryDelay', 'sp.supplier_reputation' => 'SupplierReputation' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( 'sp.price'=>"PriceQtyMinHT*", - 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty + 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.remise_percent'=>'DiscountQtyMin' )); if ($conf->multicurrency->enabled) { - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( - 'sp.fk_multicurrency'=>'CurrencyCodeId',//ideally this should be automatically obtained from the CurrencyCode on the next line + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line 'sp.multicurrency_code'=>'CurrencyCode', 'sp.multicurrency_tx'=>'CurrencyRate', 'sp.multicurrency_unitprice'=>'CurrencyUnitPrice', @@ -621,12 +621,12 @@ class modProduct extends DolibarrModules )); } - $this->import_convertvalue_array[$r]=array( - 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), - 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + $this->import_convertvalue_array[$r] = array( + 'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'), + 'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array( + $this->import_examplevalues_array[$r] = array( 'sp.fk_product' => "PRODUCT_REF or id:123456", 'sp.fk_soc' => "My Supplier", 'sp.ref_fourn' => "XYZ-F123456", @@ -639,9 +639,9 @@ class modProduct extends DolibarrModules 'sp.delivery_time_days' => '5', 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( 'sp.price' => "50.00", 'sp.unitprice' => '10', @@ -650,7 +650,7 @@ class modProduct extends DolibarrModules )); if ($conf->multicurrency->enabled) { - $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array( + $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', 'sp.multicurrency_code'=>'GBP', 'sp.multicurrency_tx'=>'1.12345', @@ -660,32 +660,32 @@ class modProduct extends DolibarrModules )); } - $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier'); + $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier'); } - if (! empty($conf->global->PRODUIT_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { // Import products multiprices $r++; - $this->import_code[$r]=$this->rights_class.'_multiprice'; - $this->import_label[$r]="ProductsOrServiceMultiPrice"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price'); - $this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array('pr.fk_product'=>"ProductOrService*", - 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", + $this->import_code[$r] = $this->rights_class.'_multiprice'; + $this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('pr'=>MAIN_DB_PREFIX.'product_price'); + $this->import_tables_creator_array[$r] = array('pr'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r] = array('pr.fk_product'=>"ProductOrService*", + 'pr.price_base_type'=>"PriceBase", 'pr.price_level'=>"PriceLevel", + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.date_price'=>'DateCreation*'); - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx']='VATRate'; - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); - $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','pr.recuperableonly'=>'^[0|1]$'); - $this->import_convertvalue_array[$r]=array( - 'pr.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); + $this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly'=>'^[0|1]$'); + $this->import_convertvalue_array[$r] = array( + 'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"PRODUCT_REF or id:123456", - 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)",'pr.price_level'=>"1", + $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"PRODUCT_REF or id:123456", + 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1", 'pr.price'=>"100", 'pr.price_ttc'=>"110", 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", 'pr.tva_tx'=>'20', @@ -693,23 +693,23 @@ class modProduct extends DolibarrModules 'pr.date_price'=>'2013-04-10'); } - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { // Import translations of product names and descriptions $r++; - $this->import_code[$r]=$this->rights_class.'_languages'; - $this->import_label[$r]="ProductsOrServicesTranslations"; - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang'); + $this->import_code[$r] = $this->rights_class.'_languages'; + $this->import_label[$r] = "ProductsOrServicesTranslations"; + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang'); // multiline translation, one line per translation - $this->import_fields_array[$r]=array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); + $this->import_fields_array[$r] = array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); //$this->import_fields_array[$r]['l.note']='TranslatedNote'; - $this->import_convertvalue_array[$r]=array( - 'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + $this->import_convertvalue_array[$r] = array( + 'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array('l.fk_product'=>'PRODUCT_REF or id:123456','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US'); - $this->import_updatekeys_array[$r]=array('l.fk_product'=>'ProductOrService','l.lang'=>'Language'); + $this->import_examplevalues_array[$r] = array('l.fk_product'=>'PRODUCT_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); + $this->import_updatekeys_array[$r] = array('l.fk_product'=>'ProductOrService', 'l.lang'=>'Language'); } } diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 780a9078f2b..379799a0ac6 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -26,7 +26,7 @@ * \ingroup service * \brief Fichier de description et activation du module Service */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -57,35 +57,35 @@ class modService extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto='service'; + $this->picto = 'service'; // Data directories to create when module is enabled $this->dirs = array("/product/temp"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with - $this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5, 4); // Minimum version of PHP required by module // Config pages $this->config_page_url = array("product.php@product"); - $this->langfiles = array("products","companies","stocks","bills"); + $this->langfiles = array("products", "companies", "stocks", "bills"); // Constants $this->const = array(); // Boxes $this->boxes = array( - 0=>array('file'=>'box_services_contracts.php','enabledbydefaulton'=>'Home'), - 1=>array('file'=>'box_graph_product_distribution.php','enabledbydefaulton'=>'Home') + 0=>array('file'=>'box_services_contracts.php', 'enabledbydefaulton'=>'Home'), + 1=>array('file'=>'box_graph_product_distribution.php', 'enabledbydefaulton'=>'Home') ); // Permissions $this->rights = array(); $this->rights_class = 'service'; - $r=0; + $r = 0; $this->rights[$r][0] = 531; // id de la permission $this->rights[$r][1] = 'Read services'; // libelle de la permission @@ -108,7 +108,7 @@ class modService extends DolibarrModules $this->rights[$r][4] = 'supprimer'; $r++; - $this->rights[$r][0] = 538; // Must be same permission than in product module + $this->rights[$r][0] = 538; // Must be same permission than in product module $this->rights[$r][1] = 'Export services'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; @@ -117,7 +117,7 @@ class modService extends DolibarrModules // Menus //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + $this->menu = 1; // This module add menu entries. They are coded into menu manager. /* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts $r=0; $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode @@ -367,28 +367,28 @@ class modService extends DolibarrModules 'p.surface_units' => "SurfaceUnit", 'p.volume' => "Volume", 'p.volume_units' => "VolumeUnits", - 'p.duration' => "Duration",//duration of service + 'p.duration' => "Duration", //duration of service 'p.finished' => 'Nature', - 'p.price' => "SellingPriceHT",//without + 'p.price' => "SellingPriceHT", //without 'p.price_min' => "MinPrice", - 'p.price_ttc' => "SellingPriceTTC",//with tax + 'p.price_ttc' => "SellingPriceTTC", //with tax 'p.price_min_ttc' => "SellingMinPriceTTC", - 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card + 'p.price_base_type' => "PriceBaseType", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card 'p.tva_tx' => 'VATRate', 'p.datec' => 'DateCreation', 'p.cost_price' => "CostPrice", ); if (!empty($conf->stock->enabled)) {//if Stock module enabled $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( - 'p.seuil_stock_alerte' => 'StockLimit',//lower limit for warning - 'p.pmp' => 'PMPValue',//weighted average price + 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning + 'p.pmp' => 'PMPValue', //weighted average price 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature )); } $this->import_convertvalue_array[$r] = array( 'p.weight_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -396,7 +396,7 @@ class modService extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.length_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -404,7 +404,7 @@ class modService extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.width_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -412,7 +412,7 @@ class modService extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.height_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -420,7 +420,7 @@ class modService extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.surface_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -428,7 +428,7 @@ class modService extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.volume_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -443,29 +443,29 @@ class modService extends DolibarrModules 'dict' => 'DictionaryCountry' ) ); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); - if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); + if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields - $import_extrafield_sample=array(); - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")"; - $resql=$this->db->query($sql); + $import_extrafield_sample = array(); + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")"; + $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); - $import_extrafield_sample[$fieldname]=$fieldlabel; + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + $import_extrafield_sample[$fieldname] = $fieldlabel; } } // End add extra fields - $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r]=array( + $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_regex_array[$r] = array( 'p.ref'=>'[^ ]', 'p.price_base_type' => '\AHT\z|\ATTC\z', 'p.tosell'=>'^[0|1]$', @@ -490,7 +490,7 @@ class modService extends DolibarrModules 'p.price_ttc' => "110", 'p.price_min_ttc' => "110", 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", - 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' + 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", 'p.fk_product_type' => "0 (product) / 1 (service)", @@ -501,17 +501,17 @@ class modService extends DolibarrModules 'p.accountancy_code_sell_export' => "", 'p.accountancy_code_buy' => "", 'p.weight' => "", - 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.length' => "", - 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.width' => "", - 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.height' => "", - 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.surface' => "", - 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.volume' => "", - 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.finished' => '0 (raw material) / 1 (finished goods)' ); //clauses copied from import_fields_array @@ -520,16 +520,16 @@ class modService extends DolibarrModules 'p.pmp' => '0', 'p.desiredstock' => '' )); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'90')); - if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); - if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>'')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) { + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); + if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); + if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>'')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $import_sample = array_merge( $import_sample, array( - 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "' . MAIN_DB_PREFIX . 'c_units"' + 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"' ) ); @@ -544,23 +544,23 @@ class modService extends DolibarrModules ) )); } - $this->import_examplevalues_array[$r]=array_merge($import_sample, $import_extrafield_sample); + $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); - if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled + if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries) { - if (! empty($conf->fournisseur->enabled)) + if (!empty($conf->fournisseur->enabled)) { // Import suppliers prices (note: this code is duplicated in module Service) $r++; - $this->import_code[$r]=$this->rights_class.'_supplierprices'; - $this->import_label[$r]="SuppliersPricesOfProductsOrServices"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); - $this->import_tables_creator_array[$r]=array('sp'=>'fk_user'); - $this->import_fields_array[$r]=array(//field order as per structure of table llx_product_fournisseur_price, without optional fields + $this->import_code[$r] = $this->rights_class.'_supplierprices'; + $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); + $this->import_tables_creator_array[$r] = array('sp'=>'fk_user'); + $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields 'sp.fk_product'=>"ProductOrService*", 'sp.fk_soc' => "Supplier*", 'sp.ref_fourn' => 'SupplierRef', @@ -570,19 +570,19 @@ class modService extends DolibarrModules 'sp.delivery_time_days' => 'DeliveryDelay', 'sp.supplier_reputation' => 'SupplierReputation' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( 'sp.price'=>"PriceQtyMinHT*", - 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty + 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.remise_percent'=>'DiscountQtyMin' )); if ($conf->multicurrency->enabled) { - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( - 'sp.fk_multicurrency'=>'CurrencyCodeId',//ideally this should be automatically obtained from the CurrencyCode on the next line + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line 'sp.multicurrency_code'=>'CurrencyCode', 'sp.multicurrency_tx'=>'CurrencyRate', 'sp.multicurrency_unitprice'=>'CurrencyUnitPrice', @@ -590,11 +590,11 @@ class modService extends DolibarrModules )); } - $this->import_convertvalue_array[$r]=array( - 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), - 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + $this->import_convertvalue_array[$r] = array( + 'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'), + 'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array( + $this->import_examplevalues_array[$r] = array( 'sp.fk_product' => "PRODUCT_REF or id:123456", 'sp.fk_soc' => "My Supplier", 'sp.ref_fourn' => "XYZ-F123456", @@ -607,9 +607,9 @@ class modService extends DolibarrModules 'sp.delivery_time_days' => '5', 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( 'sp.price' => "50.00", 'sp.unitprice' => '10', @@ -618,7 +618,7 @@ class modService extends DolibarrModules )); if ($conf->multicurrency->enabled) { - $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array( + $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', 'sp.multicurrency_code'=>'GBP', 'sp.multicurrency_tx'=>'1.12345', @@ -628,56 +628,56 @@ class modService extends DolibarrModules )); } - $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier'); + $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier'); } - if (! empty($conf->global->PRODUIT_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { // Import products multiprices $r++; - $this->import_code[$r]=$this->rights_class.'_multiprice'; - $this->import_label[$r]="ProductsOrServiceMultiPrice"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price'); - $this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array('pr.fk_product'=>"ProductOrService*", - 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", + $this->import_code[$r] = $this->rights_class.'_multiprice'; + $this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('pr'=>MAIN_DB_PREFIX.'product_price'); + $this->import_tables_creator_array[$r] = array('pr'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r] = array('pr.fk_product'=>"ProductOrService*", + 'pr.price_base_type'=>"PriceBase", 'pr.price_level'=>"PriceLevel", + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.date_price'=>'DateCreation*'); - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx']='VATRate'; - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); - $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','pr.recuperableonly'=>'^[0|1]$'); - $this->import_convertvalue_array[$r]=array( - 'pr.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); + $this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly'=>'^[0|1]$'); + $this->import_convertvalue_array[$r] = array( + 'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"SERVICE_REF or id:123456", - 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)",'pr.price_level'=>"1", - 'pr.price'=>"100",'pr.price_ttc'=>"110", - 'pr.price_min'=>"100",'pr.price_min_ttc'=>"110", + $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"SERVICE_REF or id:123456", + 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1", + 'pr.price'=>"100", 'pr.price_ttc'=>"110", + 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", 'pr.tva_tx'=>'20', 'pr.recuperableonly'=>'0', 'pr.date_price'=>'2013-04-10'); } - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { // Import translations of product names and descriptions $r++; - $this->import_code[$r]=$this->rights_class.'_languages'; - $this->import_label[$r]="ProductsOrServicesTranslations"; - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang'); + $this->import_code[$r] = $this->rights_class.'_languages'; + $this->import_label[$r] = "ProductsOrServicesTranslations"; + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang'); // multiline translation, one line per translation - $this->import_fields_array[$r]=array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); + $this->import_fields_array[$r] = array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); //$this->import_fields_array[$r]['l.note']='TranslatedNote'; - $this->import_convertvalue_array[$r]=array( - 'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + $this->import_convertvalue_array[$r] = array( + 'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array('l.fk_product'=>'SERVICE_REF or id:123456','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US'); - $this->import_updatekeys_array[$r]=array('l.fk_product'=>'ProductOrService','l.lang'=>'Language'); + $this->import_examplevalues_array[$r] = array('l.fk_product'=>'SERVICE_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); + $this->import_updatekeys_array[$r] = array('l.fk_product'=>'ProductOrService', 'l.lang'=>'Language'); } } } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 6883a089bda..9029fc82dfc 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -37,16 +37,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if (!empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; /** @@ -88,32 +88,32 @@ class doc_generic_project_odt extends ModelePDFProjects $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini + $this->emetteur = $mysoc; + if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini } @@ -131,7 +131,7 @@ class doc_generic_project_odt extends ModelePDFProjects // phpcs:enable global $conf; - $resarray=array( + $resarray = array( $array_key.'_id'=>$object->id, $array_key.'_ref'=>$object->ref, $array_key.'_title'=>$object->title, @@ -209,7 +209,7 @@ class doc_generic_project_odt extends ModelePDFProjects { // phpcs:enable global $conf; - $pc='projcontacts_'; // prefix to avoid typos + $pc = 'projcontacts_'; // prefix to avoid typos $ret = array( $pc.'id'=>$contact['id'], @@ -223,7 +223,7 @@ class doc_generic_project_odt extends ModelePDFProjects $pc.'email'=>$contact['email'] ); - if ($contact['source']=='external') { + if ($contact['source'] == 'external') { $ret[$pc.'isInternal'] = ''; // not internal $ct = new Contact($this->db); @@ -234,15 +234,15 @@ class doc_generic_project_odt extends ModelePDFProjects // fetch external user extrafields require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); + $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($ct->table_element, true); $extrafields_num = $ct->fetch_optionals(); //dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG); - foreach($ct->array_options as $efkey => $efval) { + foreach ($ct->array_options as $efkey => $efval) { dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG); $ret[$pc.$efkey] = $efval; // add nothing else because it already comes as 'options_XX' } - } elseif ($contact['source']=='internal') { + } elseif ($contact['source'] == 'internal') { $ret[$pc.'isInternal'] = '1'; // this is an internal user $ct = new User($this->db); @@ -381,83 +381,83 @@ class doc_generic_project_odt extends ModelePDFProjects */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("companies","errors")); + $langs->loadLangs(array("companies", "errors")); $form = new Form($this->db); $texte = $this->description.".
        \n"; - $texte.= '
        '; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
        '; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
        '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
        '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
        '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
        '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
        '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
        '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
        '; - $texte.= ''; - $texte.= '
        '; - $texte.= ''; - $texte.= '
        '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
        '; + $texte .= ''; + $texte .= '
        '; + $texte .= ''; + $texte .= '
        '; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=$nbofiles; + $texte .= $nbofiles; //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
        '; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
        '; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
        '; - $texte.= '
        '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -474,7 +474,7 @@ class doc_generic_project_odt extends ModelePDFProjects public function write_file($object, $outputlangs, $srctemplatepath) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -483,17 +483,17 @@ class doc_generic_project_odt extends ModelePDFProjects } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); @@ -501,11 +501,11 @@ class doc_generic_project_odt extends ModelePDFProjects if ($conf->projet->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Project($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -515,14 +515,14 @@ class doc_generic_project_odt extends ModelePDFProjects $dir = $conf->projet->dir_output; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -530,25 +530,25 @@ class doc_generic_project_odt extends ModelePDFProjects if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -557,33 +557,33 @@ class doc_generic_project_odt extends ModelePDFProjects dol_mkdir($conf->projet->dir_temp); // If PROJECTLEADER contact defined on project, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'PROJECTLEADER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'PROJECTLEADER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; } - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Open and load template require_once ODTPHP_PATH.'odf.php'; @@ -592,13 +592,13 @@ class doc_generic_project_odt extends ModelePDFProjects $srctemplatepath, array( 'PATH_TO_TMP' => $conf->projet->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -612,23 +612,23 @@ class doc_generic_project_odt extends ModelePDFProjects // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_project_contact = array(); - if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_project_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_project_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -655,43 +655,43 @@ class doc_generic_project_odt extends ModelePDFProjects $taskstatic = new Task($this->db); // Security check - $socid=0; + $socid = 0; if (!empty($object->fk_soc)) $socid = $object->fk_soc; - $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0); + $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0); foreach ($tasksarray as $task) { - $tmparray=$this->get_substitutionarray_tasks($task, $outputlangs); + $tmparray = $this->get_substitutionarray_tasks($task, $outputlangs); //complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines"); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } - $taskobj=new Task($this->db); + $taskobj = new Task($this->db); $taskobj->fetch($task->id); // Replace tags of lines for contacts task - $sourcearray=array('internal','external'); - $contact_arrray=array(); + $sourcearray = array('internal', 'external'); + $contact_arrray = array(); foreach ($sourcearray as $source) { - $contact_temp=$taskobj->liste_contact(-1, $source); + $contact_temp = $taskobj->liste_contact(-1, $source); if ((is_array($contact_temp) && count($contact_temp) > 0)) { - $contact_arrray=array_merge($contact_arrray, $contact_temp); + $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if ((is_array($contact_arrray) && count($contact_arrray) > 0)) @@ -700,33 +700,33 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($contact_arrray as $contact) { - if ($contact['source']=='internal') { - $objectdetail=new User($this->db); + if ($contact['source'] == 'internal') { + $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); - $contact['socname']=$mysoc->name; - } elseif ($contact['source']=='external') { - $objectdetail=new Contact($this->db); + $contact['socname'] = $mysoc->name; + } elseif ($contact['source'] == 'external') { + $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); - $soc=new Societe($this->db); + $soc = new Societe($this->db); $soc->fetch($contact['socid']); - $contact['socname']=$soc->name; + $contact['socname'] = $soc->name; } - $contact['fullname']=$objectdetail->getFullName($outputlangs, 1); + $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); - $tmparray=$this->get_substitutionarray_tasksressource($contact, $outputlangs); + $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlinestaskres->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -737,7 +737,7 @@ class doc_generic_project_odt extends ModelePDFProjects //Time ressources $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; - $sql.= ", u.lastname, u.firstname, t.thm"; + $sql .= ", u.lastname, u.firstname, t.thm"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_task =".$task->id; @@ -750,33 +750,33 @@ class doc_generic_project_odt extends ModelePDFProjects $num = $this->db->num_rows($resql); $i = 0; $tasks = array(); - $row=array(); + $row = array(); $listlinestasktime = $listlines->__get('taskstimes'); if (empty($num)) { - $row['rowid']=''; - $row['task_date']=''; - $row['task_duration']=''; - $row['$tasktime']=''; - $row['note']=''; - $row['fk_user']=''; - $row['name']=''; - $row['firstname']=''; - $row['fullcivname']=''; - $row['amountht']=''; - $row['amountttc']=''; - $row['thm']=''; - $tmparray=$this->get_substitutionarray_taskstime($row, $outputlangs); - foreach($tmparray as $key => $val) + $row['rowid'] = ''; + $row['task_date'] = ''; + $row['task_duration'] = ''; + $row['$tasktime'] = ''; + $row['note'] = ''; + $row['fk_user'] = ''; + $row['name'] = ''; + $row['firstname'] = ''; + $row['fullcivname'] = ''; + $row['amountht'] = ''; + $row['amountttc'] = ''; + $row['thm'] = ''; + $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs); + foreach ($tmparray as $key => $val) { try { $listlinestasktime->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -787,36 +787,36 @@ class doc_generic_project_odt extends ModelePDFProjects { $row = $this->db->fetch_array($resql); if (!empty($row['fk_user'])) { - $objectdetail=new User($this->db); + $objectdetail = new User($this->db); $objectdetail->fetch($row['fk_user']); - $row['fullcivname']=$objectdetail->getFullName($outputlangs, 1); + $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1); } else { - $row['fullcivname']=''; + $row['fullcivname'] = ''; } if (!empty($row['thm'])) { - $row['amountht']=($row['task_duration'] / 3600) * $row['thm']; + $row['amountht'] = ($row['task_duration'] / 3600) * $row['thm']; $defaultvat = get_default_tva($mysoc, $mysoc); - $row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)), 'MT'); + $row['amountttc'] = price2num($row['amountht'] * (1 + ($defaultvat / 100)), 'MT'); } else { - $row['amountht']=0; - $row['amountttc']=0; - $row['thm']=0; + $row['amountht'] = 0; + $row['amountttc'] = 0; + $row['thm'] = 0; } - $tmparray=$this->get_substitutionarray_taskstime($row, $outputlangs); + $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlinestasktime->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -832,14 +832,14 @@ class doc_generic_project_odt extends ModelePDFProjects $listtasksfiles = $listlines->__get('tasksfiles'); $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref); - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { - $tmparray=$this->get_substitutionarray_task_file($filedetail, $outputlangs); + $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs); //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true)); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { @@ -860,13 +860,13 @@ class doc_generic_project_odt extends ModelePDFProjects } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $ExceptionTrace=$e->getTrace(); + $ExceptionTrace = $e->getTrace(); // no segment defined on ODT is not an error - if($ExceptionTrace[0]['function'] != 'setSegment') + if ($ExceptionTrace[0]['function'] != 'setSegment') { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } @@ -878,24 +878,24 @@ class doc_generic_project_odt extends ModelePDFProjects $listlines = $odfHandler->setSegment('projectfiles'); $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref); - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true)); - $tmparray=$this->get_substitutionarray_project_file($filedetail, $outputlangs); + $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -904,21 +904,21 @@ class doc_generic_project_odt extends ModelePDFProjects } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace tags of lines for contacts - $sourcearray=array('internal','external'); - $contact_arrray=array(); + $sourcearray = array('internal', 'external'); + $contact_arrray = array(); foreach ($sourcearray as $source) { - $contact_temp=$object->liste_contact(-1, $source); + $contact_temp = $object->liste_contact(-1, $source); if ((is_array($contact_temp) && count($contact_temp) > 0)) { - $contact_arrray=array_merge($contact_arrray, $contact_temp); + $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if ((is_array($contact_arrray) && count($contact_arrray) > 0)) @@ -929,32 +929,32 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($contact_arrray as $contact) { - if ($contact['source']=='internal') { - $objectdetail=new User($this->db); + if ($contact['source'] == 'internal') { + $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); - $contact['socname']=$mysoc->name; - } elseif ($contact['source']=='external') { - $objectdetail=new Contact($this->db); + $contact['socname'] = $mysoc->name; + } elseif ($contact['source'] == 'external') { + $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); - $soc=new Societe($this->db); + $soc = new Societe($this->db); $soc->fetch($contact['socid']); - $contact['socname']=$soc->name; + $contact['socname'] = $soc->name; } - $contact['fullname']=$objectdetail->getFullName($outputlangs, 1); + $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); - $tmparray=$this->get_substitutionarray_project_contacts($contact, $outputlangs); - foreach($tmparray as $key => $val) + $tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs); + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -963,9 +963,9 @@ class doc_generic_project_odt extends ModelePDFProjects } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } @@ -1065,14 +1065,14 @@ class doc_generic_project_odt extends ModelePDFProjects 'title' => "ListSocialContributionAssociatedProject", 'class' => 'ChargeSociales', 'table' => 'chargesociales', - 'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $object->id, + 'urlnew' => DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$object->id, 'test' => $conf->tax->enabled && $user->rights->tax->charges->lire ), 'stock_mouvement' => array( 'title' => "ListMouvementStockProject", 'class' => 'MouvementStock', 'table' => 'stock_mouvement', - 'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)) + 'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)) ), 'agenda' => array( 'title' => "ListActionsAssociatedProject", @@ -1090,72 +1090,72 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($listofreferent as $keyref => $valueref) { - $title=$valueref['title']; - $tablename=$valueref['table']; - $classname=$valueref['class']; - $qualified=$valueref['test']; + $title = $valueref['title']; + $tablename = $valueref['table']; + $classname = $valueref['class']; + $qualified = $valueref['test']; if ($qualified) { $elementarray = $object->get_element_list($keyref, $tablename); - if (count($elementarray)>0 && is_array($elementarray)) + if (count($elementarray) > 0 && is_array($elementarray)) { $total_ht = 0; $total_ttc = 0; - $num=count($elementarray); + $num = count($elementarray); for ($i = 0; $i < $num; $i++) { - $ref_array=array(); - $ref_array['type']=$langs->trans($classname); + $ref_array = array(); + $ref_array['type'] = $langs->trans($classname); $element = new $classname($this->db); $element->fetch($elementarray[$i]); $element->fetch_thirdparty(); //Ref object - $ref_array['ref']=$element->ref; + $ref_array['ref'] = $element->ref; //Date object - $dateref=$element->date; - if (empty($dateref)) $dateref=$element->datep; - if (empty($dateref)) $dateref=$element->date_contrat; - $ref_array['date']=$dateref; + $dateref = $element->date; + if (empty($dateref)) $dateref = $element->datep; + if (empty($dateref)) $dateref = $element->date_contrat; + $ref_array['date'] = $dateref; //Soc object if (is_object($element->thirdparty)) { - $ref_array['socname']=$element->thirdparty->name; + $ref_array['socname'] = $element->thirdparty->name; } else { - $ref_array['socname']=''; + $ref_array['socname'] = ''; } //Amount object if (empty($valueref['disableamount'])) { if (!empty($element->total_ht)) { - $ref_array['amountht']=$element->total_ht; - $ref_array['amountttc']=$element->total_ttc; + $ref_array['amountht'] = $element->total_ht; + $ref_array['amountttc'] = $element->total_ttc; } else { - $ref_array['amountht']=0; - $ref_array['amountttc']=0; + $ref_array['amountht'] = 0; + $ref_array['amountttc'] = 0; } } else { - $ref_array['amountht']=''; - $ref_array['amountttc']=''; + $ref_array['amountht'] = ''; + $ref_array['amountttc'] = ''; } - $ref_array['status']=$element->getLibStatut(0); + $ref_array['status'] = $element->getLibStatut(0); - $tmparray=$this->get_substitutionarray_project_reference($ref_array, $outputlangs); + $tmparray = $this->get_substitutionarray_project_reference($ref_array, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -1166,15 +1166,15 @@ class doc_generic_project_odt extends ModelePDFProjects } $odfHandler->mergeSegment($listlines); } - } catch(OdfException $e) { - $this->error=$e->getMessage(); + } catch (OdfException $e) { + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); @@ -1184,8 +1184,8 @@ class doc_generic_project_odt extends ModelePDFProjects } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file @@ -1193,33 +1193,33 @@ class doc_generic_project_odt extends ModelePDFProjects try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); return -1; } } else { try { $odfHandler->saveToDisk($file); - } catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php index 8abcc41c263..6251f02a0de 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php @@ -24,7 +24,7 @@ * \brief File to manage no password generation. */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/security/generate/modules_genpassword.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php'; /** @@ -75,10 +75,10 @@ class modGeneratePassPerso extends ModeleGenPassword $this->id = "Perso"; $this->length = $langs->trans("SetupPerso"); - $this->db=$db; - $this->conf=$conf; - $this->langs=$langs; - $this->user=$user; + $this->db = $db; + $this->conf = $conf; + $this->langs = $langs; + $this->user = $user; if (empty($conf->global->USER_PASSWORD_PATTERN)) { // default value (8carac, 1maj, 1digit, 1spe, 3 repeat, no ambi at auto generation. @@ -89,7 +89,7 @@ class modGeneratePassPerso extends ModeleGenPassword $this->Min = strtolower($this->Maj); $this->Nb = "0123456789"; $this->Spe = "!@#$%&*()_-+={}[]\\|:;'/"; - $this->Ambi = array("1","I","l","|","O","0"); + $this->Ambi = array("1", "I", "l", "|", "O", "0"); $tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN); $this->length2 = $tabConf[0]; @@ -107,7 +107,7 @@ class modGeneratePassPerso extends ModeleGenPassword $this->Spe = str_replace($this->Ambi, "", $this->Spe); } - $pattern = $this->Min . (! empty($this->NbMaj)?$this->Maj:'') . (! empty($this->NbNum)?$this->Nb:'') . (! empty($this->NbSpe)?$this->Spe:''); + $pattern = $this->Min.(!empty($this->NbMaj) ? $this->Maj : '').(!empty($this->NbNum) ? $this->Nb : '').(!empty($this->NbSpe) ? $this->Spe : ''); $this->All = str_shuffle($pattern); //$this->All = str_shuffle($this->Maj. $this->Min. $this->Nb. $this->Spe); @@ -144,24 +144,24 @@ class modGeneratePassPerso extends ModeleGenPassword public function getNewGeneratedPassword() { $pass = ""; - for ($i=0; $i<$this->NbMaj; $i++) { + for ($i = 0; $i < $this->NbMaj; $i++) { // Y $pass .= $this->Maj[mt_rand(0, strlen($this->Maj) - 1)]; } - for ($i=0; $i<$this->NbNum; $i++) { + for ($i = 0; $i < $this->NbNum; $i++) { // X $pass .= $this->Nb[mt_rand(0, strlen($this->Nb) - 1)]; } - for ($i=0; $i<$this->NbSpe; $i++) { + for ($i = 0; $i < $this->NbSpe; $i++) { // @ $pass .= $this->Spe[mt_rand(0, strlen($this->Spe) - 1)]; } - for ($i=strlen($pass);$i<$this->length2; $i++) { + for ($i = strlen($pass); $i < $this->length2; $i++) { // y - $pass .= $this->All[mt_rand(0, strlen($this->All) -1)]; + $pass .= $this->All[mt_rand(0, strlen($this->All) - 1)]; } $pass = str_shuffle($pass); @@ -220,8 +220,8 @@ class modGeneratePassPerso extends ModeleGenPassword $count = 0; $char = str_split($password); - foreach($char as $c) { - if($c != $last) { + foreach ($char as $c) { + if ($c != $last) { $last = $c; $count = 0; diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 9adc6afad9d..4f59c2510b4 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -117,7 +117,7 @@ class pdf_stdmovement extends ModelePDFMovement */ public function __construct($db) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Load traductions files required by page $langs->loadLangs(array("main", "companies")); @@ -128,54 +128,54 @@ class pdf_stdmovement extends ModelePDFMovement // Page size for A4 format $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Affiche logo - $this->option_codestockservice = 0; // Affiche code stock-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_freetext = 0; // Support add of a personalised text + $this->option_logo = 1; // Affiche logo + $this->option_codestockservice = 0; // Affiche code stock-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_freetext = 0; // Support add of a personalised text // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined // Define position of columns $this->wref = 15; $this->posxidref = $this->marge_gauche; - $this->posxdatemouv = $this->marge_gauche+8; - $this->posxdesc=37; - $this->posxlabel=50; - $this->posxtva=80; - $this->posxqty=105; - $this->posxup=119; - $this->posxunit=136; - $this->posxdiscount=167; - $this->postotalht=180; + $this->posxdatemouv = $this->marge_gauche + 8; + $this->posxdesc = 37; + $this->posxlabel = 50; + $this->posxtva = 80; + $this->posxqty = 105; + $this->posxup = 119; + $this->posxunit = 136; + $this->posxdiscount = 167; + $this->postotalht = 180; - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup; + $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { - $this->posxpicture-=20; - $this->posxtva-=20; - $this->posxup-=20; - $this->posxqty-=20; - $this->posxunit-=20; - $this->posxdiscount-=20; - $this->postotalht-=20; + $this->posxpicture -= 20; + $this->posxtva -= 20; + $this->posxup -= 20; + $this->posxqty -= 20; + $this->posxunit -= 20; + $this->posxdiscount -= 20; + $this->postotalht -= 20; } - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } @@ -194,11 +194,11 @@ class pdf_stdmovement extends ModelePDFMovement public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$db,$hookmanager; + global $user, $langs, $conf, $mysoc, $db, $hookmanager; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries")); @@ -207,13 +207,13 @@ class pdf_stdmovement extends ModelePDFMovement * TODO: get from object */ - $id=GETPOST('id', 'int'); + $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); - $msid=GETPOST('msid', 'int'); - $product_id=GETPOST("product_id"); - $action=GETPOST('action', 'aZ09'); - $cancel=GETPOST('cancel', 'alpha'); - $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'movementlist'; + $msid = GETPOST('msid', 'int'); + $product_id = GETPOST("product_id"); + $action = GETPOST('action', 'aZ09'); + $cancel = GETPOST('cancel', 'alpha'); + $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; $idproduct = GETPOST('idproduct', 'int'); $year = GETPOST("year"); @@ -227,18 +227,18 @@ class pdf_stdmovement extends ModelePDFMovement $search_user = trim(GETPOST("search_user")); $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); - $search_type_mouvement=GETPOST('search_type_mouvement', 'int'); + $search_type_mouvement = GETPOST('search_type_mouvement', 'int'); - $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; - if (! $sortfield) $sortfield="m.datem"; - if (! $sortorder) $sortorder="DESC"; + if (!$sortfield) $sortfield = "m.datem"; + if (!$sortorder) $sortorder = "DESC"; - $pdluoid=GETPOST('pdluoid', 'int'); + $pdluoid = GETPOST('pdluoid', 'int'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('movementlist')); @@ -324,7 +324,7 @@ class pdf_stdmovement extends ModelePDFMovement } } - if(empty($search_inventorycode)) $sql.= $db->plimit($limit+1, $offset); + if (empty($search_inventorycode)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); @@ -358,44 +358,44 @@ class pdf_stdmovement extends ModelePDFMovement $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); $i = 0; - $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; if ($msid) $texte = $langs->trans('StockMovementForId', $msid); else { $texte = $langs->trans("ListOfStockMovements"); - if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')'; + if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; } } // Definition of $dir and $file if ($object->specimen) { - $dir = $conf->stock->dir_output . "/movement"; - $file = $dir . "/SPECIMEN.pdf"; + $dir = $conf->stock->dir_output."/movement"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode; - if($search_type_mouvement) $objectref.="_".$search_type_mouvement; - $dir = $conf->stock->dir_output . "/movement/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + if (!empty($search_inventorycode)) $objectref .= "_".$id."_".$search_inventorycode; + if ($search_type_mouvement) $objectref .= "_".$search_type_mouvement; + $dir = $conf->stock->dir_output."/movement/".$objectref; + $file = $dir."/".$objectref.".pdf"; } $stockFournisseur = new ProductFournisseur($this->db); $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id); $object->supplierprices = $supplierprices; - $productstatic=new Product($db); + $productstatic = new Product($db); - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -403,24 +403,24 @@ class pdf_stdmovement extends ModelePDFMovement if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Create pdf instance - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1, 0); - $heightforinfotot = 40; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + $heightforinfotot = 40; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) if (class_exists('TCPDF')) { @@ -429,14 +429,14 @@ class pdf_stdmovement extends ModelePDFMovement } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -469,12 +469,12 @@ class pdf_stdmovement extends ModelePDFMovement /* */ /* ************************************************************************** */ - $nexY+=5; + $nexY += 5; $nexY = $pdf->GetY(); - $nexY+=10; + $nexY += 10; - $totalunit=0; - $totalvalue=$totalvaluesell=0; + $totalunit = 0; + $totalvalue = $totalvaluesell = 0; $arrayofuniqueproduct = array(); //dol_syslog('List products', LOG_DEBUG); @@ -484,18 +484,18 @@ class pdf_stdmovement extends ModelePDFMovement $num = $db->num_rows($resql); $i = 0; $nblines = $num; - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { $objp = $db->fetch_object($resql); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$objp->rowid; - $sql.= " AND lang='". $langs->getDefaultLang() ."'"; - $sql.= " LIMIT 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$objp->rowid; + $sql .= " AND lang='".$langs->getDefaultLang()."'"; + $sql .= " LIMIT 1"; $result = $db->query($sql); if ($result) @@ -599,60 +599,60 @@ class pdf_stdmovement extends ModelePDFMovement // Id movement. $pdf->SetXY($this->posxidref, $curY); - $pdf->MultiCell($this->posxdesc-$this->posxidref-0.8, 3, $objp->mid, 0, 'L'); + $pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0, 'L'); // Date. $pdf->SetXY($this->posxdatemouv, $curY); - $pdf->MultiCell($this->posxdesc-$this->posxdatemouv-0.8, 6, dol_print_date($db->jdate($objp->datem), 'dayhour'), 0, 'L'); + $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6, dol_print_date($db->jdate($objp->datem), 'dayhour'), 0, 'L'); // Ref. $pdf->SetXY($this->posxdesc, $curY); - $pdf->MultiCell($this->posxlabel-$this->posxdesc-0.8, 3, $productstatic->ref, 0, 'L'); + $pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0, 'L'); // Label - $pdf->SetXY($this->posxlabel+0.8, $curY); - $pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 6, $productstatic->label, 0, 'L'); + $pdf->SetXY($this->posxlabel + 0.8, $curY); + $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0, 'L'); // Lot/serie $pdf->SetXY($this->posxqty, $curY); - $pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $productlot->batch, 0, 'R'); + $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0, 'R'); // Inv. code $pdf->SetXY($this->posxup, $curY); - $pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, $objp->inventorycode, 0, 'R'); + $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0, 'R'); // Label mouvement $pdf->SetXY($this->posxunit, $curY); - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, $objp->label, 0, 'R'); - $totalvalue+=price2num($objp->ppmp*$objp->value, 'MT'); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0, 'R'); + $totalvalue += price2num($objp->ppmp * $objp->value, 'MT'); // Origin - $pricemin=$objp->price; + $pricemin = $objp->price; $pdf->SetXY($this->posxdiscount, $curY); - $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8, 3, $origin, 0, 'R', 0); + $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0, 'R', 0); // Qty - $valtoshow=price2num($objp->qty, 'MS'); - $towrite = (empty($valtoshow)?'0':$valtoshow); - $totalunit+=$objp->qty; + $valtoshow = price2num($objp->qty, 'MS'); + $towrite = (empty($valtoshow) ? '0' : $valtoshow); + $totalunit += $objp->qty; $pdf->SetXY($this->postotalht, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $objp->qty, 0, 'R', 0); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0, 'R', 0); - $totalvaluesell+=price2num($pricemin*$objp->value, 'MT'); + $totalvaluesell += price2num($pricemin * $objp->value, 'MT'); - $nexY+=3.5; // Add space between lines + $nexY += 3.5; // Add space between lines // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -669,10 +669,10 @@ class pdf_stdmovement extends ModelePDFMovement $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -685,7 +685,7 @@ class pdf_stdmovement extends ModelePDFMovement $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -697,23 +697,23 @@ class pdf_stdmovement extends ModelePDFMovement * footer table */ $nexY = $pdf->GetY(); - $nexY+=5; + $nexY += 5; $curY = $nexY; - $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); - $pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1); + $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26))); + $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1); $pdf->SetLineStyle(array('dash'=>0)); - $pdf->SetFont('', 'B', $default_font_size-1); + $pdf->SetFont('', 'B', $default_font_size - 1); $pdf->SetTextColor(0, 0, 120); // Total $pdf->SetXY($this->posxidref, $curY); - $pdf->MultiCell($this->posxdesc-$this->posxidref, 3, $langs->trans("Total"), 0, 'L'); + $pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans("Total"), 0, 'L'); // Total Qty $pdf->SetXY($this->postotalht, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $totalunit, 0, 'R', 0); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $totalunit, 0, 'R', 0); } else { @@ -722,7 +722,7 @@ class pdf_stdmovement extends ModelePDFMovement if ($notetoshow) { - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); @@ -730,41 +730,41 @@ class pdf_stdmovement extends ModelePDFMovement $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } else { - $height_note=0; + $height_note = 0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - $tab_top = $tab_top_newpage+21; + $tab_top = $tab_top_newpage + 21; // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; // Affiche zone infos //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); @@ -782,31 +782,31 @@ class pdf_stdmovement extends ModelePDFMovement // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR"); + $this->error = $langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR"); return 0; } } @@ -830,8 +830,8 @@ class pdf_stdmovement extends ModelePDFMovement global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -843,11 +843,11 @@ class pdf_stdmovement extends ModelePDFMovement if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } $pdf->SetDrawColor(128, 128, 128); @@ -856,9 +856,9 @@ class pdf_stdmovement extends ModelePDFMovement // Output Rect //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter - $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26))); $pdf->SetDrawColor(220, 26, 26); - $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top); + $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top); $pdf->SetLineStyle(array('dash'=>0)); $pdf->SetDrawColor(128, 128, 128); $pdf->SetTextColor(0, 0, 120); @@ -867,32 +867,32 @@ class pdf_stdmovement extends ModelePDFMovement if (empty($hidetop)) { //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter - $pdf->SetXY($this->posxidref, $tab_top+1); - $pdf->MultiCell($this->posxdatemouv-$this->posxdatemouv-0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L'); + $pdf->SetXY($this->posxidref, $tab_top + 1); + $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L'); } //Date mouv //$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxdatemouv, $tab_top+1); - $pdf->MultiCell($this->posxdesc-$this->posxdatemouv, 2, $outputlangs->transnoentities("Date"), '', 'C'); + $pdf->SetXY($this->posxdatemouv, $tab_top + 1); + $pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities("Date"), '', 'C'); } //Ref Product //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxdesc-1, $tab_top+1); - $pdf->MultiCell($this->posxlabel-$this->posxdesc, 2, $outputlangs->transnoentities("Ref. Product"), '', 'C'); + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); + $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities("Ref. Product"), '', 'C'); } //Label Product //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxlabel-1, $tab_top+1); - $pdf->MultiCell($this->posxqty-$this->posxlabel, 2, $outputlangs->transnoentities("Label"), '', 'C'); + $pdf->SetXY($this->posxlabel - 1, $tab_top + 1); + $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities("Label"), '', 'C'); } //Lot/serie Product @@ -907,37 +907,37 @@ class pdf_stdmovement extends ModelePDFMovement //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxup-1, $tab_top+1); - $pdf->MultiCell($this->posxunit-$this->posxup, 2, $outputlangs->transnoentities("Inventory Code"), '', 'C'); + $pdf->SetXY($this->posxup - 1, $tab_top + 1); + $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities("Inventory Code"), '', 'C'); } //Label mouvement //$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxunit, $tab_top+1); - $pdf->MultiCell($this->posxdiscount-$this->posxunit, 2, $outputlangs->transnoentities("Label Mouvement"), '', 'C'); + $pdf->SetXY($this->posxunit, $tab_top + 1); + $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities("Label Mouvement"), '', 'C'); } //Origin //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxdiscount+2, $tab_top+1); - $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8, 2, $outputlangs->transnoentities("Origin"), '', 'C'); + $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1); + $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities("Origin"), '', 'C'); } //Qty //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->postotalht+2, $tab_top+1); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 2, $outputlangs->transnoentities("Qty"), '', 'C'); + $pdf->SetXY($this->postotalht + 2, $tab_top + 1); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } $pdf->SetDrawColor(220, 26, 26); - $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); - $pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11); + $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26))); + $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11); $pdf->SetLineStyle(array('dash'=>0)); } @@ -954,20 +954,20 @@ class pdf_stdmovement extends ModelePDFMovement */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") { - global $conf,$langs,$db,$hookmanager; + global $conf, $langs, $db, $hookmanager; // Load traductions files required by page $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks")); $default_font_size = pdf_getPDFFontSize($outputlangs); - if ($object->type == 1) $titlekey='ServiceSheet'; - else $titlekey='StockSheet'; + if ($object->type == 1) $titlekey = 'ServiceSheet'; + else $titlekey = 'StockSheet'; pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK); } @@ -1048,25 +1048,25 @@ class pdf_stdmovement extends ModelePDFMovement // Description $nexY = $pdf->GetY(); - $nexY+=5; + $nexY += 5; $pdf->SetXY($posx, $posy); $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("Description").' : '.nl2br($object->description), 0, 1); $nexY = $pdf->GetY(); - $calcproductsunique=$object->nb_different_products(); - $calcproducts=$object->nb_products(); + $calcproductsunique = $object->nb_different_products(); + $calcproducts = $object->nb_products(); // Total nb of different products - $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfDifferentProducts").' : '.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfDifferentProducts").' : '.(empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']), 0, 1); $nexY = $pdf->GetY(); // Nb of products - $valtoshow=price2num($calcproducts['nb'], 'MS'); - $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfProducts").' : '.(empty($valtoshow)?'0':$valtoshow), 0, 1); + $valtoshow = price2num($calcproducts['nb'], 'MS'); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfProducts").' : '.(empty($valtoshow) ? '0' : $valtoshow), 0, 1); $nexY = $pdf->GetY(); // Value - $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("EstimatedStockValueShort").' : '. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("EstimatedStockValueShort").' : '.price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1); $nexY = $pdf->GetY(); @@ -1078,7 +1078,7 @@ class pdf_stdmovement extends ModelePDFMovement if ($resqlbis) { $obj = $db->fetch_object($resqlbis); - $lastmovementdate=$db->jdate($obj->datem); + $lastmovementdate = $db->jdate($obj->datem); } else { @@ -1128,7 +1128,7 @@ class pdf_stdmovement extends ModelePDFMovement } }*/ - $posy+=2; + $posy += 2; // Show list of linked objects //$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); @@ -1184,7 +1184,7 @@ class pdf_stdmovement extends ModelePDFMovement protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php index 29652f09b88..0579c464d30 100644 --- a/htdocs/core/tpl/extrafields_add.tpl.php +++ b/htdocs/core/tpl/extrafields_add.tpl.php @@ -26,7 +26,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -41,8 +41,8 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - $params = isset($tpl_context) ? array('tpl_context' => $tpl_context) : array(); // BUG #11554 : Add tpl_context in params - print $object->showOptionals($extrafields, 'edit', $params); // BUG #11554 : Add context in params + $params = isset($tpl_context) ? array('tpl_context' => $tpl_context) : array(); // BUG #11554 : Add tpl_context in params + print $object->showOptionals($extrafields, 'edit', $params); // BUG #11554 : Add context in params } ?> diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 6a61686e5cc..32fff114739 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -26,22 +26,22 @@ */ // Protection to avoid direct call of template -if (empty($object) || ! is_object($object)) +if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; } -if (! is_object($form)) $form=new Form($db); +if (!is_object($form)) $form = new Form($db); ?> fk_soc)) $parameters['socid'] = $object->fk_soc; +if (!is_array($parameters)) $parameters = array(); +if (!empty($cols)) $parameters['colspan'] = ' colspan="'.$cols.'"'; +if (!empty($cols)) $parameters['cols'] = $cols; +if (!empty($object->fk_soc)) $parameters['socid'] = $object->fk_soc; $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -94,10 +94,10 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] if (!empty($extrafield_param) && is_array($extrafield_param)) { $extrafield_param_list = array_keys($extrafield_param['options']); - if (count($extrafield_param_list)>0) { + if (count($extrafield_param_list) > 0) { $extrafield_collapse_display_value = intval($extrafield_param_list[0]); - if ($extrafield_collapse_display_value==1 || $extrafield_collapse_display_value==2) { + if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) { $extrafields_collapse_num = $extrafields->attributes[$object->table_element]['pos'][$key]; } } @@ -105,7 +105,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] print $extrafields->showSeparator($key, $object); - $lastseparatorkeyfound=$key; + $lastseparatorkeyfound = $key; } else { @@ -184,14 +184,14 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] } print ''; - print '' . "\n"; + print ''."\n"; } } // Add code to manage list depending on others // TODO Test/enhance this with a more generic solution - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print "\n"; print ' diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f58b6725f81..b2ab12041af 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -115,12 +115,12 @@ if ($nolinesbefore) { multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> trans('PriceUHTCurrency'); ?> - + trans('PriceUTTC'); ?> trans('Qty'); ?> global->PRODUCT_USE_UNITS) + if ($conf->global->PRODUCT_USE_UNITS) { print ''; print ''; @@ -466,20 +466,20 @@ $coldisplay+=$colspan; showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $objectline->showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); } -if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required +if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { ?> > - global->MAIN_VIEW_LINE_NUMBER)) { print ''; } ?> - + global->MAIN_VIEW_LINE_NUMBER)) { print ''; } ?> + element) && $object->element == 'contrat') + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + if (!empty($object->element) && $object->element == 'contrat') { print $langs->trans("DateStartPlanned").' '; print $form->selectDate($date_start, "date_start", $usehm, $usehm, 1, "addproduct"); @@ -489,9 +489,9 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da else { echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, 1, "addproduct", 1, 0); + print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); echo ' '.$langs->trans('to').' '; - print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, 1, "addproduct", 1, 0); + print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); }; print ''; // Loan card - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
        '; + $morehtmlref = '
        '; // Ref loan - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->loadLangs(array("projects")); - $morehtmlref.='
        '.$langs->trans('Project') . ' '; + $morehtmlref .= '
        '.$langs->trans('Project').' '; if ($user->rights->loan->write) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
        '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
        '; + $morehtmlref .= '
        '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
        '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; - $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -493,7 +493,7 @@ if ($id > 0) if ($action == 'edit') { print ''.$langs->trans("LoanCapital").''; - print ''; + print ''; print ''; } else @@ -505,7 +505,7 @@ if ($id > 0) if ($action == 'edit') { print ''.$langs->trans("Insurance").''; - print ''; + print ''; print ''; } else @@ -544,7 +544,7 @@ if ($id > 0) print ''; if ($action == 'edit') { - print ''; + print ''; } else { @@ -557,11 +557,11 @@ if ($id > 0) print ''; if ($action == 'edit') { - print '%'; + print '%'; } else { - print $object->rate . '%'; + print $object->rate.'%'; } print ''; @@ -573,7 +573,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyCapitalCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 1, 1); } @@ -589,7 +589,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyCapitalCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_capital, 1); @@ -611,7 +611,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyInsuranceCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 1, 1); } @@ -627,7 +627,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyCapitalCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_insurance, 1); @@ -649,7 +649,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyInterestCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 1, 1); } @@ -665,7 +665,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyInterestCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_interest, 1); @@ -689,15 +689,15 @@ if ($id > 0) * Payments */ $sql = "SELECT p.rowid, p.num_payment, datep as dp,"; - $sql.= " p.amount_capital, p.amount_insurance, p.amount_interest,"; - $sql.= " c.libelle as paiement_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; - $sql.= ", ".MAIN_DB_PREFIX."loan as l"; - $sql.= " WHERE p.fk_loan = ".$id; - $sql.= " AND p.fk_loan = l.rowid"; - $sql.= " AND l.entity IN ( ".getEntity('loan').")"; - $sql.= " ORDER BY dp DESC"; + $sql .= " p.amount_capital, p.amount_insurance, p.amount_interest,"; + $sql .= " c.libelle as paiement_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; + $sql .= ", ".MAIN_DB_PREFIX."loan as l"; + $sql .= " WHERE p.fk_loan = ".$id; + $sql .= " AND p.fk_loan = l.rowid"; + $sql .= " AND l.entity IN ( ".getEntity('loan').")"; + $sql .= " ORDER BY dp DESC"; //print $sql; $resql = $db->query($sql); @@ -709,7 +709,7 @@ if ($id > 0) $total_interest = 0; $total_capital = 0; - print '
        '; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
        '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; @@ -746,7 +746,7 @@ if ($id > 0) $staytopay = $object->capital - $totalpaid; print ''; - print ''; } @@ -804,7 +804,7 @@ if ($id > 0) } // Classify 'paid' - if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) + if ($object->paid == 0 && round($staytopay) <= 0 && $user->rights->loan->write) { print ''; } diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index a4bed07949e..a4328bec863 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -53,21 +53,21 @@ if (empty($page) || $page == -1) { $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; $object = new Loan($db); if ($id > 0) $object->fetch($id); $upload_dir = $conf->loan->dir_output.'/'.dol_sanitizeFileName($object->ref); -$modulepart='loan'; +$modulepart = 'loan'; /* * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -76,45 +76,45 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title = $langs->trans("Loan") . ' - ' . $langs->trans("Documents"); +$title = $langs->trans("Loan").' - '.$langs->trans("Documents"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $title, $help_url); if ($object->id) { - $totalpaid=$object->getSumPayment(); + $totalpaid = $object->getSumPayment(); $head = loan_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("Loan"), -1, 'bill'); - $morehtmlref='
        '; + $morehtmlref = '
        '; // Ref loan - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project - if (! empty($conf->projet->enabled)) { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref .= '
        ' . $langs->trans('Project') . ' : '; + $morehtmlref .= '
        '.$langs->trans('Project').' : '; if ($user->rights->loan->write) { //if ($action != 'classify') // $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
        '; + $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $proj->ref; $morehtmlref .= ''; } else { @@ -122,11 +122,11 @@ if ($object->id) } } } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -135,11 +135,11 @@ if ($object->id) // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } @@ -155,8 +155,8 @@ if ($object->id) $modulepart = 'loan'; $permission = $user->rights->loan->write; $permtoedit = $user->rights->loan->write; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/loan/info.php b/htdocs/loan/info.php index 618345518ed..1a26a8a12da 100644 --- a/htdocs/loan/info.php +++ b/htdocs/loan/info.php @@ -48,7 +48,7 @@ $result = restrictedArea($user, 'loan', $id, '', ''); $form = new Form($db); -$title = $langs->trans("Loan") . ' - ' . $langs->trans("Info"); +$title = $langs->trans("Loan").' - '.$langs->trans("Info"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $title, $help_url); @@ -60,33 +60,33 @@ $head = loan_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("Loan"), -1, 'bill'); -$morehtmlref='
        '; +$morehtmlref = '
        '; // Ref loan -$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); -$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); +$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); +$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project -if (! empty($conf->projet->enabled)) { +if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref .= '
        ' . $langs->trans('Project') . ' : '; + $morehtmlref .= '
        '.$langs->trans('Project').' : '; if ($user->rights->loan->write) { //if ($action != 'classify') // $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
        '; + $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $proj->ref; $morehtmlref .= ''; } else { @@ -94,11 +94,11 @@ if (! empty($conf->projet->enabled)) { } } } -$morehtmlref.='
        '; +$morehtmlref .= '
        '; -$linkback = '' . $langs->trans("BackToList") . ''; +$linkback = ''.$langs->trans("BackToList").''; -$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status +$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php index 4ddd7bdccee..ebe0b9d876c 100644 --- a/htdocs/loan/note.php +++ b/htdocs/loan/note.php @@ -30,8 +30,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } $action = GETPOST('action', 'aZ09'); @@ -46,7 +46,7 @@ $result = restrictedArea($user, 'loan', $id, '&loan'); $object = new Loan($db); if ($id > 0) $object->fetch($id); -$permissionnote=$user->rights->loan->write; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->loan->write; // Used by the include of actions_setnotes.inc.php /* @@ -62,7 +62,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, $form = new Form($db); -$title = $langs->trans("Loan") . ' - ' . $langs->trans("Notes"); +$title = $langs->trans("Loan").' - '.$langs->trans("Notes"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $title, $help_url); @@ -71,39 +71,39 @@ if ($id > 0) /* * Affichage onglets */ - $totalpaid=$object->getSumPayment(); + $totalpaid = $object->getSumPayment(); $head = loan_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans("Loan"), -1, 'bill'); - $morehtmlref='
        '; + $morehtmlref = '
        '; // Ref loan - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project - if (! empty($conf->projet->enabled)) { + if (!empty($conf->projet->enabled)) { $langs->loadLangs(array("projects")); - $morehtmlref .= '
        ' . $langs->trans('Project') . ' : '; + $morehtmlref .= '
        '.$langs->trans('Project').' : '; if ($user->rights->loan->write) { //if ($action != 'classify') // $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
        '; + $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $proj->ref; $morehtmlref .= ''; } else { @@ -111,19 +111,19 @@ if ($id > 0) } } } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
        '; print '
        '; - $cssclass='titlefield'; - $permission = $user->rights->loan->write; // Used by the include of notes.tpl.php + $cssclass = 'titlefield'; + $permission = $user->rights->loan->write; // Used by the include of notes.tpl.php include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; dol_fiche_end(); diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index cdd8db1a0bd..302ecf5f1ff 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; if (!$user->rights->opensurvey->read) accessforbidden(); // Initialisation des variables -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); $numsondage = ''; @@ -44,16 +44,16 @@ if (GETPOST('id')) { $numsondage = GETPOST('id', 'alpha'); } -$object=new Opensurveysondage($db); +$object = new Opensurveysondage($db); -$result=$object->fetch(0, $numsondage); +$result = $object->fetch(0, $numsondage); if ($result <= 0) { dol_print_error($db, $object->error); exit; } -$expiredate=dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear')); +$expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear')); @@ -67,7 +67,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) $action=''; + if ($cancel) $action = ''; // Delete if ($action == 'delete_confirm') @@ -75,7 +75,7 @@ if (empty($reshook)) // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - $result=$object->delete($user, '', $numsondage); + $result = $object->delete($user, '', $numsondage); header('Location: '.dol_buildpath('/opensurvey/list.php', 1)); exit(); @@ -101,16 +101,16 @@ if (empty($reshook)) // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - $error=0; + $error = 0; - if (! GETPOST('nouveautitre')) + if (!GETPOST('nouveautitre')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); $error++; $action = 'edit'; } - if (! $error) + if (!$error) { $object->titre = GETPOST('nouveautitre', 'nohtml'); $object->commentaires = GETPOST('nouveauxcommentaires', 'nohtml'); @@ -121,11 +121,11 @@ if (empty($reshook)) $object->allow_spy = GETPOST('canseeothersvote', 'alpha') == 'on' ? true : false; $object->mailsonde = GETPOST('mailsonde', 'alpha') == 'on' ? true : false; - $res=$object->update($user); + $res = $object->update($user); if ($res < 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action='edit'; + $action = 'edit'; } } } @@ -133,27 +133,27 @@ if (empty($reshook)) // Add comment if (GETPOST('ajoutcomment')) { - $error=0; + $error = 0; - if (! GETPOST('comment')) + if (!GETPOST('comment')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); } - if (! GETPOST('commentuser')) + if (!GETPOST('commentuser')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); } - if (! $error) + if (!$error) { $comment = GETPOST("comment"); $comment_user = GETPOST('commentuser'); $resql = $object->addComment($comment, $comment_user); - if (! $resql) + if (!$resql) { setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); } @@ -161,7 +161,7 @@ if (empty($reshook)) } // Delete comment - $idcomment=GETPOST('deletecomment', 'int'); + $idcomment = GETPOST('deletecomment', 'int'); if ($idcomment) { // Security check @@ -181,7 +181,7 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); if ($object->fk_user_creat) { @@ -191,21 +191,21 @@ if ($object->fk_user_creat) $title = $object->titre." - ".$langs->trans('Card'); $helpurl = ''; -$arrayofjs=array(); -$arrayofcss=array('/opensurvey/css/style.css'); +$arrayofjs = array(); +$arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices -$toutsujet=explode(",", $object->sujet); -$listofanswers=array(); +$toutsujet = explode(",", $object->sujet); +$listofanswers = array(); foreach ($toutsujet as $value) { - $tmp=explode('@', $value); - $listofanswers[]=array('label'=>$tmp[0],'format'=>($tmp[1]?$tmp[1]:'checkbox')); + $tmp = explode('@', $value); + $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } -$toutsujet=str_replace("@", "
        ", $toutsujet); -$toutsujet=str_replace("°", "'", $toutsujet); +$toutsujet = str_replace("@", "
        ", $toutsujet); +$toutsujet = str_replace("°", "'", $toutsujet); print '
        '."\n"; print ''; @@ -228,15 +228,15 @@ print '
        '; print '
        '.$langs->trans("RefPayment").'
        '.$langs->trans("RemainderToPay").' :'; + print ''; print price($staytopay, 0, $langs, 0, 0, -1, $conf->currency); print '
        '; // Type -$type=($object->format=="A")?'classic':'date'; +$type = ($object->format == "A") ? 'classic' : 'date'; print ''; +print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1); +print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate").''; // Title print ''; // Description -print ''; // EMail //If linked user, then emails are going to be sent to users' email if (!$object->fk_user_creat) { - print ''; print ''; @@ -300,14 +300,14 @@ print ''; print ''; // Expire date print ''; // Author print ''; print ''; - print ''; + print ''; // Parent entrepot print ''; print ''; // Zip / Town print ''; print ''; // Country print ''; // Status @@ -310,7 +310,7 @@ if ($action == 'create') print ''; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; if ($conf->categorie->enabled) { // Categories @@ -324,16 +324,16 @@ if ($action == 'create') dol_fiche_end(); print '
        '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
        '; print ''; } else { - $id=GETPOST("id", 'int'); + $id = GETPOST("id", 'int'); if ($id > 0 || $ref) { $object = new Entrepot($db); @@ -364,8 +364,8 @@ else // Call Hook formConfirm $parameters = array(); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -399,18 +399,18 @@ else // Description print ''; - $calcproductsunique=$object->nb_different_products(); - $calcproducts=$object->nb_products(); + $calcproductsunique = $object->nb_different_products(); + $calcproducts = $object->nb_products(); // Total nb of different products print '"; // Nb of products print '"; print '
        '.$langs->trans("Type").''; -print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'), 1), 'width="16"', 1); -print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate").'
        '; -$adresseadmin=$object->mail_admin; -print $langs->trans("Title") .''; +$adresseadmin = $object->mail_admin; +print $langs->trans("Title").''; if ($action == 'edit') { print ''; @@ -245,22 +245,22 @@ else print dol_htmlentities($object->titre); print '
        '.$langs->trans("Description") .''; +print '
        '.$langs->trans("Description").''; if ($action == 'edit') { - $doleditor=new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires), '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); + $doleditor = new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires), '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); $doleditor->Create(0, ''); } else { - print (dol_textishtml($object->commentaires)?$object->commentaires:dol_nl2br($object->commentaires, 1, true)); + print (dol_textishtml($object->commentaires) ? $object->commentaires : dol_nl2br($object->commentaires, 1, true)); } print '
        '.$langs->trans("EMail") .''; + print '
        '.$langs->trans("EMail").''; if ($action == 'edit') { print ''; @@ -273,7 +273,7 @@ if (!$object->fk_user_creat) { print '
        '.$langs->trans('ToReceiveEMailForEachVote').''; if ($action == 'edit') { - print 'mailsonde?'checked="checked"':'').'">'; + print 'mailsonde ? 'checked="checked"' : '').'">'; } else { print yn($object->mailsonde); @@ -291,7 +291,7 @@ print '
        '.$langs->trans('CanComment').''; if ($action == 'edit') { - print 'allow_comments?'checked="checked"':'').'">'; + print 'allow_comments ? 'checked="checked"' : '').'">'; } else print yn($object->allow_comments); print '
        '.$langs->trans('CanSeeOthersVote').''; if ($action == 'edit') { - print 'allow_spy?'checked="checked"':'').'">'; + print 'allow_spy ? 'checked="checked"' : '').'">'; } else print yn($object->allow_spy); print '
        '.$langs->trans('ExpireDate').''; -if ($action == 'edit') print $form->selectDate($expiredate?$expiredate:$object->date_fin, 'expire', 0, 0, 0, '', 1, 0); +if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); else { print dol_print_date($object->date_fin, 'day'); @@ -317,7 +317,7 @@ print '
        '; -print $langs->trans("Author") .''; +print $langs->trans("Author").''; if ($object->fk_user_creat) { print $userstatic->getLoginUrl(1); } else { @@ -329,11 +329,11 @@ print '
        '.img_picto('', 'globe').' '.$langs->trans("UrlForSurvey", '').''; // Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current -$url=$urlwithroot.'/public/opensurvey/studs.php?sondage='.$object->id_sondage; +$url = $urlwithroot.'/public/opensurvey/studs.php?sondage='.$object->id_sondage; print ''; if ($action != 'edit') print ajax_autoselect("opensurveyurl", $url); @@ -365,17 +365,17 @@ print '
        '; if ($action != 'edit' && $user->rights->opensurvey->write) { //Modify button - print ''.$langs->trans("Modify") . ''; + print ''.$langs->trans("Modify").''; if ($object->status == Opensurveysondage::STATUS_VALIDATED) { //Close button - print ''.$langs->trans("Close") . ''; + print ''.$langs->trans("Close").''; } if ($object->status == Opensurveysondage::STATUS_CLOSED) { //Opened button - print ''.$langs->trans("ReOpen") . ''; + print ''.$langs->trans("ReOpen").''; } //Delete button @@ -419,12 +419,12 @@ print '
        '; // Add comment if ($object->allow_comments) { - print $langs->trans("AddACommentForPoll") . '
        '; + print $langs->trans("AddACommentForPoll").'
        '; print '
        '."\n"; - print $langs->trans("Name") .':
        '."\n"; + print $langs->trans("Name").':
        '."\n"; print '
        '."\n"; - if (isset($erreur_commentaire_vide) && $erreur_commentaire_vide=="yes") { - print "" . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")) . ""; + if (isset($erreur_commentaire_vide) && $erreur_commentaire_vide == "yes") { + print "".$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")).""; } } diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 017779b74f7..7bb775e790e 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -35,14 +35,14 @@ if (!$user->rights->opensurvey->read) accessforbidden(); // Init vars -$action=GETPOST('action', 'aZ09'); -$numsondage= GETPOST("id"); +$action = GETPOST('action', 'aZ09'); +$numsondage = GETPOST("id"); -$object=new Opensurveysondage($db); -$result=$object->fetch(0, $numsondage); +$object = new Opensurveysondage($db); +$result = $object->fetch(0, $numsondage); if ($result <= 0) dol_print_error('', 'Failed to get survey id '.$numsondage); -$nblines=$object->fetch_lines(); +$nblines = $object->fetch_lines(); /* @@ -65,28 +65,28 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $erreur_prenom = false; $nouveauchoix = ''; - for ($i=0;$i<$nbcolonnes;$i++) + for ($i = 0; $i < $nbcolonnes; $i++) { if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { - $nouveauchoix.="1"; + $nouveauchoix .= "1"; } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { - $nouveauchoix.="2"; + $nouveauchoix .= "2"; } else { // sinon c'est 0 - $nouveauchoix.="0"; + $nouveauchoix .= "0"; } } - $nom=substr(GETPOST("nom", 'nohtml'), 0, 64); + $nom = substr(GETPOST("nom", 'nohtml'), 0, 64); // Check if vote already exists $sql = 'SELECT id_users, nom as name'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql.= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."'"; - $sql.= ' ORDER BY id_users'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; + $sql .= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."'"; + $sql .= ' ORDER BY id_users'; $resql = $db->query($sql); $num_rows = $db->num_rows($resql); if ($num_rows > 0) @@ -97,9 +97,9 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout else { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)'; - $sql.= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); + $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); } } } @@ -108,19 +108,19 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $testmodifier = false; $testligneamodifier = false; $ligneamodifier = -1; -for ($i=0; $i<$nblines; $i++) +for ($i = 0; $i < $nblines; $i++) { if (isset($_POST['modifierligne'.$i])) { - $ligneamodifier=$i; - $testligneamodifier=true; + $ligneamodifier = $i; + $testligneamodifier = true; } //test pour voir si une ligne est a modifier if (isset($_POST['validermodifier'.$i])) { - $modifier=$i; - $testmodifier=true; + $modifier = $i; + $testmodifier = true; } } if ($testmodifier) @@ -134,24 +134,24 @@ if ($testmodifier) //var_dump($_POST["choix$i"]); if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { - $nouveauchoix.="1"; + $nouveauchoix .= "1"; } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { - $nouveauchoix.="2"; + $nouveauchoix .= "2"; } else { // sinon c'est 0 - $nouveauchoix.="0"; + $nouveauchoix .= "0"; } } - $idtomodify=$_POST["idtomodify".$modifier]; + $idtomodify = $_POST["idtomodify".$modifier]; $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.= " SET reponses = '".$db->escape($nouveauchoix)."'"; - $sql.= " WHERE id_users = '".$db->escape($idtomodify)."'"; + $sql .= " SET reponses = '".$db->escape($nouveauchoix)."'"; + $sql .= " WHERE id_users = '".$db->escape($idtomodify)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } // Add column (not for date) @@ -160,18 +160,18 @@ if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format = // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - $nouveauxsujets=$object->sujet; + $nouveauxsujets = $object->sujet; //on rajoute la valeur a la fin de tous les sujets deja entrés - $nouveauxsujets.=','; - $nouveauxsujets.=str_replace(array(",","@"), " ", $_POST["nouvellecolonne"]).(empty($_POST["typecolonne"])?'':'@'.$_POST["typecolonne"]); + $nouveauxsujets .= ','; + $nouveauxsujets .= str_replace(array(",", "@"), " ", $_POST["nouvellecolonne"]).(empty($_POST["typecolonne"]) ? '' : '@'.$_POST["typecolonne"]); //mise a jour avec les nouveaux sujets dans la base $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " SET sujet = '".$db->escape($nouveauxsujets)."'"; - $sql.= " WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."'"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); else { header('Location: results.php?id='.$object->id_sondage); } @@ -223,10 +223,10 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") //recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau if ($nouvelledate < $datesbase[0]) { $cleinsertion = 0; - } elseif ($nouvelledate > $datesbase[$taillebase-1]) { + } elseif ($nouvelledate > $datesbase[$taillebase - 1]) { $cleinsertion = count($datesbase); } else { - $nbdatesbase=count($datesbase); + $nbdatesbase = count($datesbase); for ($i = 0; $i < $nbdatesbase; $i++) { $j = $i + 1; @@ -239,10 +239,10 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") array_splice($datesbase, $cleinsertion, 0, $nouvelledate); $cle = array_search($nouvelledate, $datesbase); $dateinsertion = ''; - $nbofdates=count($datesbase); + $nbofdates = count($datesbase); for ($i = 0; $i < $nbofdates; $i++) { - $dateinsertion.=","; - $dateinsertion.=$datesbase[$i]; + $dateinsertion .= ","; + $dateinsertion .= $datesbase[$i]; } $dateinsertion = substr("$dateinsertion", 1); @@ -251,10 +251,10 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) { $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " SET sujet = '".$db->escape($dateinsertion)."'"; - $sql.= " WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql .= " SET sujet = '".$db->escape($dateinsertion)."'"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); else { header('Location: results.php?id='.$object->id_sondage); } @@ -264,7 +264,7 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") } else { - $erreur_ajout_date="yes"; + $erreur_ajout_date = "yes"; } } @@ -276,24 +276,24 @@ for ($i = 0; $i < $nblines; $i++) // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - $compteur=0; + $compteur = 0; // Loop on each answer $compteur = 0; - $sql ="SELECT id_users, nom as name, id_sondage, reponses"; - $sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'"; - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); - $num=$db->num_rows($resql); + $sql = "SELECT id_users, nom as name, id_sondage, reponses"; + $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); + $num = $db->num_rows($resql); while ($compteur < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); - if ($compteur==$i) + if ($compteur == $i) { $sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql2.= ' WHERE id_users = '.$db->escape($obj->id_users); + $sql2 .= ' WHERE id_users = '.$db->escape($obj->id_users); $resql2 = $db->query($sql2); } @@ -323,7 +323,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) //si le sujet n'est pas celui qui a été effacé alors on concatene if ($i != $j) { - if (! empty($nouveauxsujets)) $nouveauxsujets .= ','; + if (!empty($nouveauxsujets)) $nouveauxsujets .= ','; $nouveauxsujets .= $toutsujet[$j]; } @@ -332,26 +332,26 @@ for ($i = 0; $i < $nbcolonnes; $i++) // Mise a jour des sujets dans la base $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); // Clean current answer to remove deleted columns $compteur = 0; - $sql ="SELECT id_users, nom as name, id_sondage, reponses"; - $sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql = "SELECT id_users, nom as name, id_sondage, reponses"; + $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; dol_syslog('sql='.$sql); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; } - $num=$db->num_rows($resql); + $num = $db->num_rows($resql); while ($compteur < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $newcar = ''; $ensemblereponses = $obj->reponses; @@ -359,7 +359,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) // parcours de toutes les réponses actuelles for ($j = 0; $j < $nbcolonnes; $j++) { - $car=substr($ensemblereponses, $j, 1); + $car = substr($ensemblereponses, $j, 1); //si les reponses ne concerne pas la colonne effacée, on concatene if ($i != $j) { $newcar .= $car; @@ -368,8 +368,8 @@ for ($i = 0; $i < $nbcolonnes; $i++) // mise a jour des reponses utilisateurs dans la base $sql2 = 'UPDATE '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql2.= " SET reponses = '".$db->escape($newcar)."'"; - $sql2.= " WHERE id_users = '".$db->escape($obj->id_users)."'"; + $sql2 .= " SET reponses = '".$db->escape($newcar)."'"; + $sql2 .= " WHERE id_users = '".$db->escape($obj->id_users)."'"; //print $sql2; dol_syslog('sql='.$sql2); $resql2 = $db->query($sql2); @@ -387,14 +387,14 @@ for ($i = 0; $i < $nbcolonnes; $i++) * View */ -$form=new Form($db); +$form = new Form($db); if ($object->fk_user_creat) { $userstatic = new User($db); $userstatic->fetch($object->fk_user_creat); } -$result=$object->fetch(0, $numsondage); +$result = $object->fetch(0, $numsondage); if ($result <= 0) { dol_print_error($db, $object->error); @@ -403,21 +403,21 @@ if ($result <= 0) $title = $object->titre." - ".$langs->trans('Card'); $helpurl = ''; -$arrayofjs=array(); -$arrayofcss=array('/opensurvey/css/style.css'); +$arrayofjs = array(); +$arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices -$toutsujet=explode(",", $object->sujet); -$listofanswers=array(); +$toutsujet = explode(",", $object->sujet); +$listofanswers = array(); foreach ($toutsujet as $value) { - $tmp=explode('@', $value); - $listofanswers[]=array('label'=>$tmp[0],'format'=>($tmp[1]?$tmp[1]:'checkbox')); + $tmp = explode('@', $value); + $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } -$toutsujet=str_replace("@", "
        ", $toutsujet); -$toutsujet=str_replace("°", "'", $toutsujet); +$toutsujet = str_replace("@", "
        ", $toutsujet); +$toutsujet = str_replace("°", "'", $toutsujet); print ''."\n"; @@ -439,15 +439,15 @@ print '
        '; print ''; // Type -$type=($object->format=="A")?'classic':'date'; +$type = ($object->format == "A") ? 'classic' : 'date'; print ''; +print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1); +print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate").''; // Title print ''; // Expire date print ''; // Author print ''; print '
        '.$langs->trans("Type").''; -print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'), 1), 'width="16"', 1); -print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate").'
        '; -$adresseadmin=$object->mail_admin; -print $langs->trans("Title") .''; +$adresseadmin = $object->mail_admin; +print $langs->trans("Title").''; if ($action == 'edit') { print ''; @@ -457,13 +457,13 @@ print '
        '.$langs->trans('ExpireDate').''; -if ($action == 'edit') print $form->selectDate($expiredate?$expiredate:$object->date_fin, 'expire', 0, 0, 0, '', 1, 0); +if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); else print dol_print_date($object->date_fin, 'day'); print '
        '; -print $langs->trans("Author") .''; +print $langs->trans("Author").''; if ($object->fk_user_creat) { print $userstatic->getLoginUrl(1); } else { @@ -475,12 +475,12 @@ print '
        '.img_picto('', 'globe').' '.$langs->trans("UrlForSurvey", '').''; // Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current -$url=$urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage; -$urllink=''; +$url = $urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage; +$urllink = ''; print $urllink; if ($action != 'edit') { @@ -505,7 +505,7 @@ print ''."\n"; print ''; @@ -523,11 +523,11 @@ if (GETPOST('ajoutsujet')) print "

        "."\n"; // Add new column - if ($object->format=="A") + if ($object->format == "A") { - print $langs->trans("AddNewColumn") .':

        '; + print $langs->trans("AddNewColumn").':

        '; print $langs->trans("Title").'
        '; - $tmparray=array('checkbox'=>$langs->trans("CheckBox"),'yesno'=>$langs->trans("YesNoList"),'foragainst'=>$langs->trans("PourContreList")); + $tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList")); print $langs->trans("Type").' '.$form->selectarray("typecolonne", $tmparray, GETPOST('typecolonne')).'

        '; print ''; print '     '; @@ -538,12 +538,12 @@ if (GETPOST('ajoutsujet')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - $formother=new FormOther($db); + $formother = new FormOther($db); //ajout d'une date avec creneau horaire - print $langs->trans("AddADate") .':

        '."\n"; + print $langs->trans("AddADate").':

        '."\n"; print ''."\n"; @@ -554,7 +554,7 @@ if (GETPOST('ajoutsujet')) print $formother->select_year('', 'nouvelleannee', 1, 0, 5, 0, 1); - print '

        '. $langs->trans("AddStartHour") .':

        '."\n"; + print '

        '.$langs->trans("AddStartHour").':

        '."\n"; print ''."\n"; - print '

        '. $langs->trans("AddEndHour") .':

        '."\n"; + print '

        '.$langs->trans("AddEndHour").':

        '."\n"; print ''."\n"; //reformatage des données des sujets du sondage -$toutsujet=explode(",", $object->sujet); -$toutsujet=str_replace("°", "'", $toutsujet); +$toutsujet = explode(",", $object->sujet); +$toutsujet = str_replace("°", "'", $toutsujet); print ''."\n"; print ''."\n"; @@ -628,7 +628,7 @@ print ''."\n"; // Show choice titles -if ($object->format=="D") +if ($object->format == "D") { //affichage des sujets du sondage print ''."\n"; @@ -636,9 +636,9 @@ if ($object->format=="D") print ''."\n"; //affichage des années - $colspan=1; - $nbofsujet=count($toutsujet); - for ($i=0;$i<$nbofsujet;$i++) + $colspan = 1; + $nbofsujet = count($toutsujet); + for ($i = 0; $i < $nbofsujet; $i++) { $current = $toutsujet[$i]; @@ -646,24 +646,24 @@ if ($object->format=="D") $current = substr($toutsujet[$i], 0, strpos($toutsujet[$i], '@')); } - if (isset($toutsujet[$i+1]) && strpos($toutsujet[$i+1], '@') !== false) { - $next = substr($toutsujet[$i+1], 0, strpos($toutsujet[$i+1], '@')); - } elseif (isset($toutsujet[$i+1])) { - $next = $toutsujet[$i+1]; + if (isset($toutsujet[$i + 1]) && strpos($toutsujet[$i + 1], '@') !== false) { + $next = substr($toutsujet[$i + 1], 0, strpos($toutsujet[$i + 1], '@')); + } elseif (isset($toutsujet[$i + 1])) { + $next = $toutsujet[$i + 1]; } $currenty = 0; - if ($current) $currenty=strftime("%Y", $current); + if ($current) $currenty = strftime("%Y", $current); $next = 0; - if ($next) $nexty=strftime("%Y", $next); - if (isset($toutsujet[$i+1]) && ($currenty == $nexty)) + if ($next) $nexty = strftime("%Y", $next); + if (isset($toutsujet[$i + 1]) && ($currenty == $nexty)) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -680,20 +680,20 @@ if ($object->format=="D") //affichage des mois $colspan = 1; for ($i = 0; $i < $nbofsujet; $i++) { - $cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime() + $cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime() - if (isset($toutsujet[$i+1]) === false) { + if (isset($toutsujet[$i + 1]) === false) { $next = false; } else { - $next = intval($toutsujet[$i+1]); + $next = intval($toutsujet[$i + 1]); } - if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")){ + if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -710,17 +710,17 @@ if ($object->format=="D") $colspan = 1; for ($i = 0; $i < $nbofsujet; $i++) { $cur = intval($toutsujet[$i]); - if (isset($toutsujet[$i+1]) === false) { + if (isset($toutsujet[$i + 1]) === false) { $next = false; } else { - $next = intval($toutsujet[$i+1]); + $next = intval($toutsujet[$i + 1]); } if ($next && dol_print_date($cur, "%a %e") == dol_print_date($next, "%a %e") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -736,7 +736,7 @@ if ($object->format=="D") print ''."\n"; for ($i = 0; isset($toutsujet[$i]); $i++) { - $heures=explode('@', $toutsujet[$i]); + $heures = explode('@', $toutsujet[$i]); if (isset($heures[1])) { print ''."\n"; } else { @@ -760,7 +760,7 @@ else for ($i = 0; isset($toutsujet[$i]); $i++) { - $tmp=explode('@', $toutsujet[$i]); + $tmp = explode('@', $toutsujet[$i]); print ''."\n"; } @@ -773,20 +773,20 @@ else $sumfor = array(); $sumagainst = array(); $compteur = 0; -$sql ="SELECT id_users, nom as name, id_sondage, reponses"; -$sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; -$sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'"; +$sql = "SELECT id_users, nom as name, id_sondage, reponses"; +$sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; +$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; dol_syslog('sql='.$sql); -$resql=$db->query($sql); -if (! $resql) +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); exit; } -$num=$db->num_rows($resql); +$num = $db->num_rows($resql); while ($compteur < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $ensemblereponses = $obj->reponses; @@ -800,40 +800,40 @@ while ($compteur < $num) print ''."\n"; // si la ligne n'est pas a changer, on affiche les données - if (! $testligneamodifier) + if (!$testligneamodifier) { for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); //print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz'; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { if (((string) $car) == "1") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } @@ -848,20 +848,20 @@ while ($compteur < $num) { $car = substr($ensemblereponses, $i, 1); print ''."\n"; @@ -872,33 +872,33 @@ while ($compteur < $num) for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { if (((string) $car) == "1") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } @@ -913,7 +913,7 @@ while ($compteur < $num) } //demande de confirmation pour modification de ligne - for ($i=0; $i<$nblines; $i++) + for ($i = 0; $i < $nblines; $i++) { if (isset($_POST["modifierligne".$i])) { @@ -943,23 +943,23 @@ if (empty($testligneamodifier)) for ($i = 0; $i < $nbcolonnes; $i++) { print ''."\n"; @@ -971,10 +971,10 @@ if (empty($testligneamodifier)) } // Select value of best choice (for checkbox columns only) -$nbofcheckbox=0; -for ($i=0; $i < $nbcolonnes + 1; $i++) +$nbofcheckbox = 0; +for ($i = 0; $i < $nbcolonnes + 1; $i++) { - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) $nbofcheckbox++; if (isset($sumfor[$i])) { @@ -993,18 +993,18 @@ for ($i=0; $i < $nbcolonnes + 1; $i++) // Show line total print ''."\n"; print ''."\n"; -print ''."\n"; +print ''."\n"; for ($i = 0; $i < $nbcolonnes; $i++) { - $showsumfor = isset($sumfor[$i])?$sumfor[$i]:''; - $showsumagainst = isset($sumagainst[$i])?$sumagainst[$i]:''; + $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] : ''; + $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] : ''; if (empty($showsumfor)) $showsumfor = 0; if (empty($showsumagainst)) $showsumagainst = 0; print ''."\n"; } print ''; @@ -1015,7 +1015,7 @@ if ($nbofcheckbox >= 2) print ''."\n"; print ''."\n"; for ($i = 0; $i < $nbcolonnes; $i++) { - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) { print ''."\n"; } else { @@ -1043,7 +1043,7 @@ print '
        '; if ($current) print strftime("%Y", $current); print ''.dol_print_date($cur, "%B").''.dol_print_date($cur, "%a %e").''.dol_htmlentities($heures[1]).''.dol_htmlentities($tmp[0]).''.dol_htmlentities($obj->name).'OKKO'.$langs->trans("Yes").''.$langs->trans("No").' '.$langs->trans("For").''.$langs->trans("Against").' '; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print ''; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice, $car); } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("Against"),'1'=>$langs->trans("For")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice, $car); } print 'OKKO'.$langs->trans("For").''.$langs->trans("Against").' '.$langs->trans("For").''.$langs->trans("Against").' '; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print ''; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice); } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("Against"),'1'=>$langs->trans("For")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice); } print '
        '. $langs->trans("Total") .''.$langs->trans("Total").''; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) print $showsumfor; - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'
        '.$langs->trans("No").': '.$showsumagainst; - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'
        '.$langs->trans("Against").': '.$showsumagainst; + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) print $showsumfor; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'
        '.$langs->trans("No").': '.$showsumagainst; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'
        '.$langs->trans("Against").': '.$showsumagainst; print '
        '."\n"; print ''."\n"; -$toutsujet = explode(",", $object->sujet); // With old versions, this field was not set +$toutsujet = explode(",", $object->sujet); // With old versions, this field was not set $compteursujet = 0; $meilleursujet = ''; @@ -1051,21 +1051,21 @@ for ($i = 0; $i < $nbcolonnes; $i++) { if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) { - $meilleursujet.=", "; + $meilleursujet .= ", "; if ($object->format == "D") { $meilleursujetexport = $toutsujet[$i]; //var_dump($toutsujet); if (strpos($toutsujet[$i], '@') !== false) { $toutsujetdate = explode("@", $toutsujet[$i]); - $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext'). ($toutsujetdate[0] ? ' ('.dol_print_date($toutsujetdate[0], '%A').')' : '') . ' - ' . $toutsujetdate[1]; + $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext').($toutsujetdate[0] ? ' ('.dol_print_date($toutsujetdate[0], '%A').')' : '').' - '.$toutsujetdate[1]; } else { - $meilleursujet .= dol_print_date($toutsujet[$i], 'daytext'). ($toutsujet[$i] ? ' ('.dol_print_date($toutsujet[$i], '%A').')' : ''); + $meilleursujet .= dol_print_date($toutsujet[$i], 'daytext').($toutsujet[$i] ? ' ('.dol_print_date($toutsujet[$i], '%A').')' : ''); } } else { - $tmps=explode('@', $toutsujet[$i]); + $tmps = explode('@', $toutsujet[$i]); $meilleursujet .= dol_htmlentities($tmps[0]); } @@ -1082,9 +1082,9 @@ if ($nbofcheckbox >= 2) print '

        '."\n"; if (isset($meilleurecolonne) && $compteursujet == "1") { - print " " . $langs->trans('TheBestChoice') . ": ".$meilleursujet." " . $langs->trans("with") . " ".$meilleurecolonne." " . $vote_str . ".\n"; + print " ".$langs->trans('TheBestChoice').": ".$meilleursujet." ".$langs->trans("with")." ".$meilleurecolonne." ".$vote_str.".\n"; } elseif (isset($meilleurecolonne)) { - print " " . $langs->trans('TheBestChoices') . ": ".$meilleursujet." " . $langs->trans("with") . " ".$meilleurecolonne." " . $vote_str . ".\n"; + print " ".$langs->trans('TheBestChoices').": ".$meilleursujet." ".$langs->trans("with")." ".$meilleurecolonne." ".$vote_str.".\n"; } print '


        '."\n"; } diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 22356994008..ab9ba921e16 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -40,7 +40,7 @@ function paypaladmin_prepare_head() $head[$h][2] = 'paypalaccount'; $h++; - $object=new stdClass(); + $object = new stdClass(); // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -68,12 +68,12 @@ function showPaypalPaymentUrl($type, $ref) $langs->load("paypal"); $langs->load("paybox"); - $servicename='PayPal'; - $out='

        '; - $out.=img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
        '; - $url=getPaypalPaymentUrl(0, $type, $ref); - $out.=''; - $out.=ajax_autoselect("paypalurl", 0); + $servicename = 'PayPal'; + $out = '

        '; + $out .= img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
        '; + $url = getPaypalPaymentUrl(0, $type, $ref); + $out .= ''; + $out .= ajax_autoselect("paypalurl", 0); return $out; } @@ -92,92 +92,92 @@ function getPaypalPaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag { global $conf; - $ref=str_replace(' ', '', $ref); + $ref = str_replace(' ', '', $ref); if ($type == 'free') { - $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?amount='.($mode ? '' : '').$amount.($mode ? '' : '').'&tag='.($mode ? '' : '').$freetag.($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else $out.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else $out .= '&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); } } if ($type == 'order') { - $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=order&ref='.($mode?'':''); - if ($mode == 1) $out.='order_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=order&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'order_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } if ($type == 'invoice') { - $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=invoice&ref='.($mode?'':''); - if ($mode == 1) $out.='invoice_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=invoice&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'invoice_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } if ($type == 'contractline') { - $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=contractline&ref='.($mode?'':''); - if ($mode == 1) $out.='contractline_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=contractline&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'contractline_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } if ($type == 'membersubscription') { - $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref='.($mode?'':''); - if ($mode == 1) $out.='member_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'member_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } // For multicompany - $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities return $out; } @@ -209,27 +209,27 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, //' //'------------------------------------------------- - if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; + if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral'; - $solutionType='Sole'; - $landingPage='Billing'; + $solutionType = 'Sole'; + $landingPage = 'Billing'; // For payment with Paypal only if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') { - $solutionType='Mark'; - $landingPage='Login'; + $solutionType = 'Mark'; + $landingPage = 'Login'; } // For payment with Credit card or Paypal if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') { - $solutionType='Sole'; - $landingPage='Billing'; + $solutionType = 'Sole'; + $landingPage = 'Billing'; } // For payment with Credit card if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'cconly') { - $solutionType='Sole'; - $landingPage='Billing'; + $solutionType = 'Sole'; + $landingPage = 'Billing'; } dol_syslog("expresscheckout redirect with callSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum"); @@ -255,12 +255,12 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, ); $ack = strtoupper($resArray["ACK"]); - if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { - $token=$resArray["TOKEN"]; + $token = $resArray["TOKEN"]; // Redirect to paypal.com here - $payPalURL = $API_Url . $token; + $payPalURL = $API_Url.$token; header("Location: ".$payPalURL); exit; } @@ -274,15 +274,15 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, if ($ErrorCode == 10729) { - $mesg.= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
        Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
        \n"; + $mesg .= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
        Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
        \n"; } else { - $mesg = $langs->trans('SetExpressCheckoutAPICallFailed') . "
        \n"; - $mesg.= $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
        \n"; - $mesg.= $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
        \n"; - $mesg.= $langs->trans('ErrorCode') . ": " . $ErrorCode."
        \n"; - $mesg.= $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
        \n"; + $mesg = $langs->trans('SetExpressCheckoutAPICallFailed')."
        \n"; + $mesg .= $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."
        \n"; + $mesg .= $langs->trans('ShortErrorMessage').": ".$ErrorShortMsg."
        \n"; + $mesg .= $langs->trans('ErrorCode').": ".$ErrorCode."
        \n"; + $mesg .= $langs->trans('ErrorSeverityCode').": ".$ErrorSeverityCode."
        \n"; } return $mesg; @@ -342,92 +342,92 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $nvpstr = ''; //$nvpstr = $nvpstr . "&VERSION=".$API_version; // Already added by hash_call - $nvpstr = $nvpstr . "&RETURNURL=" . urlencode($returnURL); - $nvpstr = $nvpstr . "&CANCELURL=" . urlencode($cancelURL); - if (! empty($conf->global->PAYPAL_ALLOW_NOTES)) + $nvpstr = $nvpstr."&RETURNURL=".urlencode($returnURL); + $nvpstr = $nvpstr."&CANCELURL=".urlencode($cancelURL); + if (!empty($conf->global->PAYPAL_ALLOW_NOTES)) { - $nvpstr = $nvpstr . "&ALLOWNOTE=0"; + $nvpstr = $nvpstr."&ALLOWNOTE=0"; } if (empty($conf->global->PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS)) { - $nvpstr = $nvpstr . "&NOSHIPPING=1"; // An empty or not complete shipping address will be accepted + $nvpstr = $nvpstr."&NOSHIPPING=1"; // An empty or not complete shipping address will be accepted } else { - $nvpstr = $nvpstr . "&NOSHIPPING=0"; // A valid shipping address is required (full required fields mandatory) + $nvpstr = $nvpstr."&NOSHIPPING=0"; // A valid shipping address is required (full required fields mandatory) } - $nvpstr = $nvpstr . "&SOLUTIONTYPE=" . urlencode($solutionType); - $nvpstr = $nvpstr . "&LANDINGPAGE=" . urlencode($landingPage); - if (! empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER)) + $nvpstr = $nvpstr."&SOLUTIONTYPE=".urlencode($solutionType); + $nvpstr = $nvpstr."&LANDINGPAGE=".urlencode($landingPage); + if (!empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER)) { - $nvpstr = $nvpstr . "&CUSTOMERSERVICENUMBER=" . urlencode($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER); // Hotline phone number + $nvpstr = $nvpstr."&CUSTOMERSERVICENUMBER=".urlencode($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER); // Hotline phone number } $paypalprefix = 'PAYMENTREQUEST_0_'; //$paypalprefix = ''; - if (! empty($paypalprefix) && $paymentType == 'Sole') $paymentType='Sale'; + if (!empty($paypalprefix) && $paymentType == 'Sole') $paymentType = 'Sale'; - $nvpstr = $nvpstr . "&AMT=". urlencode($paymentAmount); // Total for all elements + $nvpstr = $nvpstr."&AMT=".urlencode($paymentAmount); // Total for all elements - $nvpstr = $nvpstr . "&".$paypalprefix."INVNUM=" . urlencode($tag); - $nvpstr = $nvpstr . "&".$paypalprefix."AMT=". urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT - $nvpstr = $nvpstr . "&".$paypalprefix."ITEMAMT=". urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT - $nvpstr = $nvpstr . "&".$paypalprefix."PAYMENTACTION=" . urlencode($paymentType); // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION - $nvpstr = $nvpstr . "&".$paypalprefix."CURRENCYCODE=" . urlencode($currencyCodeType); // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE + $nvpstr = $nvpstr."&".$paypalprefix."INVNUM=".urlencode($tag); + $nvpstr = $nvpstr."&".$paypalprefix."AMT=".urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT + $nvpstr = $nvpstr."&".$paypalprefix."ITEMAMT=".urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT + $nvpstr = $nvpstr."&".$paypalprefix."PAYMENTACTION=".urlencode($paymentType); // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION + $nvpstr = $nvpstr."&".$paypalprefix."CURRENCYCODE=".urlencode($currencyCodeType); // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE - $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_QTY0=1"; - $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_AMT0=".urlencode($paymentAmount); - $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_NAME0=".urlencode($desc); - $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_NUMBER0=0"; + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_QTY0=1"; + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_AMT0=".urlencode($paymentAmount); + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_NAME0=".urlencode($desc); + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_NUMBER0=0"; - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTONAME=" . urlencode($shipToName); // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTREET=" . urlencode($shipToStreet); // - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTREET2=" . urlencode($shipToStreet2); - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOCITY=" . urlencode($shipToCity); - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTATE=" . urlencode($shipToState); - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOCOUNTRYCODE=" . urlencode($shipToCountryCode); - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOZIP=" . urlencode($shipToZip); - $nvpstr = $nvpstr . "&".$paypalprefix."PHONENUM=" . urlencode($phoneNum); - if (! empty($email)) $nvpstr = $nvpstr . "&".$paypalprefix."EMAIL=" . urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL - if (! empty($desc)) $nvpstr = $nvpstr . "&".$paypalprefix."DESC=" . urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTONAME=".urlencode($shipToName); // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTREET=".urlencode($shipToStreet); // + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTREET2=".urlencode($shipToStreet2); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOCITY=".urlencode($shipToCity); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTATE=".urlencode($shipToState); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOCOUNTRYCODE=".urlencode($shipToCountryCode); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOZIP=".urlencode($shipToZip); + $nvpstr = $nvpstr."&".$paypalprefix."PHONENUM=".urlencode($phoneNum); + if (!empty($email)) $nvpstr = $nvpstr."&".$paypalprefix."EMAIL=".urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL + if (!empty($desc)) $nvpstr = $nvpstr."&".$paypalprefix."DESC=".urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC - if (! empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo) + if (!empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo) { global $dolibarr_main_url_root; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $urllogo=$urlwithroot."/viewimage.php?modulepart=mycompany&file=".urlencode('logos/'.$mysoc->logo); - $nvpstr = $nvpstr . "&LOGOIMG=" . urlencode($urllogo); + $urllogo = $urlwithroot."/viewimage.php?modulepart=mycompany&file=".urlencode('logos/'.$mysoc->logo); + $nvpstr = $nvpstr."&LOGOIMG=".urlencode($urllogo); } - if (! empty($conf->global->PAYPAL_BRANDNAME)) + if (!empty($conf->global->PAYPAL_BRANDNAME)) { - $nvpstr = $nvpstr . "&BRANDNAME=" . urlencode($conf->global->PAYPAL_BRANDNAME); // BRANDNAME + $nvpstr = $nvpstr."&BRANDNAME=".urlencode($conf->global->PAYPAL_BRANDNAME); // BRANDNAME } - if (! empty($conf->global->PAYPAL_NOTETOBUYER)) + if (!empty($conf->global->PAYPAL_NOTETOBUYER)) { - $nvpstr = $nvpstr . "&NOTETOBUYER=" . urlencode($conf->global->PAYPAL_NOTETOBUYER); // PAYPAL_NOTETOBUYER + $nvpstr = $nvpstr."&NOTETOBUYER=".urlencode($conf->global->PAYPAL_NOTETOBUYER); // PAYPAL_NOTETOBUYER } $_SESSION["FinalPaymentAmt"] = $paymentAmount; $_SESSION["currencyCodeType"] = $currencyCodeType; - $_SESSION["PaymentType"] = $paymentType; // 'Mark', 'Sole' - $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip + $_SESSION["PaymentType"] = $paymentType; // 'Mark', 'Sole' + $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip //'--------------------------------------------------------------------------------------------------------------- //' Make the API call to PayPal //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. //' If an error occured, show the resulting errors //'--------------------------------------------------------------------------------------------------------------- - $resArray=hash_call("SetExpressCheckout", $nvpstr); + $resArray = hash_call("SetExpressCheckout", $nvpstr); $ack = strtoupper($resArray["ACK"]); - if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $token = urldecode($resArray["TOKEN"]); - $_SESSION['TOKEN']=$token; + $_SESSION['TOKEN'] = $token; } return $resArray; @@ -459,7 +459,7 @@ function getDetails($token) //' Build a second API request to PayPal, using the token as the //' ID to get the details on the payment authorization //'--------------------------------------------------------------------------- - $nvpstr="&TOKEN=" . $token; + $nvpstr = "&TOKEN=".$token; //'--------------------------------------------------------------------------- //' Make the API call and store the results in an array. @@ -467,9 +467,9 @@ function getDetails($token) //' an action to complete the payment. //' If failed, show the error //'--------------------------------------------------------------------------- - $resArray=hash_call("GetExpressCheckoutDetails", $nvpstr); + $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr); $ack = strtoupper($resArray["ACK"]); - if($ack == "SUCCESS" || $ack=="SUCCESSWITHWARNING") + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $_SESSION['payer_id'] = $resArray['PAYERID']; } @@ -502,18 +502,18 @@ function confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipad global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; $nvpstr = ''; - $nvpstr .= '&TOKEN=' . urlencode($token); - $nvpstr .= '&PAYERID=' . urlencode($payerID); - $nvpstr .= '&PAYMENTACTION=' . urlencode($paymentType); - $nvpstr .= '&AMT=' . urlencode($FinalPaymentAmt); - $nvpstr .= '&CURRENCYCODE=' . urlencode($currencyCodeType); - $nvpstr .= '&IPADDRESS=' . urlencode($ipaddress); - $nvpstr .= '&INVNUM=' . urlencode($tag); + $nvpstr .= '&TOKEN='.urlencode($token); + $nvpstr .= '&PAYERID='.urlencode($payerID); + $nvpstr .= '&PAYMENTACTION='.urlencode($paymentType); + $nvpstr .= '&AMT='.urlencode($FinalPaymentAmt); + $nvpstr .= '&CURRENCYCODE='.urlencode($currencyCodeType); + $nvpstr .= '&IPADDRESS='.urlencode($ipaddress); + $nvpstr .= '&INVNUM='.urlencode($tag); /* Make the call to PayPal to finalize payment If an error occured, show the resulting errors */ - $resArray=hash_call("DoExpressCheckoutPayment", $nvpstr); + $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr); /* Display the API response back to the browser. If the response from PayPal was a success, display the response parameters' @@ -591,8 +591,8 @@ function hash_call($methodName, $nvpStr) global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; // TODO problem with triggers - $API_version="98.0"; - if (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha')) // We can force sand box with param 'forcesandbox' + $API_version = "98.0"; + if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha')) // We can force sand box with param 'forcesandbox' { $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; @@ -604,14 +604,14 @@ function hash_call($methodName, $nvpStr) } // Clean parameters - $PAYPAL_API_USER=""; - if (! empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; - $PAYPAL_API_PASSWORD=""; - if (! empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; - $PAYPAL_API_SIGNATURE=""; - if (! empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; - $PAYPAL_API_SANDBOX=""; - if (! empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; + $PAYPAL_API_USER = ""; + if (!empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER; + $PAYPAL_API_PASSWORD = ""; + if (!empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD; + $PAYPAL_API_SIGNATURE = ""; + if (!empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE; + $PAYPAL_API_SANDBOX = ""; + if (!empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX; // TODO END problem with triggers dol_syslog("Paypal API endpoint ".$API_Endpoint); @@ -626,14 +626,14 @@ function hash_call($methodName, $nvpStr) curl_setopt($ch, CURLOPT_URL, $API_Endpoint); curl_setopt($ch, CURLOPT_VERBOSE, 1); // TLSv1 by default or change to TLSv1.2 in module configuration - curl_setopt($ch, CURLOPT_SSLVERSION, (empty($conf->global->PAYPAL_SSLVERSION)?1:$conf->global->PAYPAL_SSLVERSION)); + curl_setopt($ch, CURLOPT_SSLVERSION, (empty($conf->global->PAYPAL_SSLVERSION) ? 1 : $conf->global->PAYPAL_SSLVERSION)); //turning off the server and peer verification(TrustManager Concept). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT)?5:$conf->global->MAIN_USE_CONNECT_TIMEOUT); - curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT)?30:$conf->global->MAIN_USE_RESPONSE_TIMEOUT); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); @@ -641,15 +641,15 @@ function hash_call($methodName, $nvpStr) //if USE_PROXY constant set to true in Constants.php, then only proxy will be enabled. if ($USE_PROXY) { - dol_syslog("Paypal API hash_call set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS); + dol_syslog("Paypal API hash_call set proxy to ".$PROXY_HOST.":".$PROXY_PORT." - ".$PROXY_USER.":".$PROXY_PASS); //curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10 - curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT); - if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS); + curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST.":".$PROXY_PORT); + if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER.":".$PROXY_PASS); } //NVPRequest for submitting to server - $nvpreq ="METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($API_version) . "&PWD=" . urlencode($PAYPAL_API_PASSWORD) . "&USER=" . urlencode($PAYPAL_API_USER) . "&SIGNATURE=" . urlencode($PAYPAL_API_SIGNATURE) . $nvpStr; - $nvpreq.="&LOCALECODE=".strtoupper($langs->getDefaultLang(1)); + $nvpreq = "METHOD=".urlencode($methodName)."&VERSION=".urlencode($API_version)."&PWD=".urlencode($PAYPAL_API_PASSWORD)."&USER=".urlencode($PAYPAL_API_USER)."&SIGNATURE=".urlencode($PAYPAL_API_SIGNATURE).$nvpStr; + $nvpreq .= "&LOCALECODE=".strtoupper($langs->getDefaultLang(1)); //$nvpreq.="&BRANDNAME=".urlencode(); // Override merchant name //$nvpreq.="&NOTIFYURL=".urlencode(); // For Instant Payment Notification url @@ -662,18 +662,18 @@ function hash_call($methodName, $nvpStr) //getting response from server $response = curl_exec($ch); - $nvpReqArray=deformatNVP($nvpreq); - $_SESSION['nvpReqArray']=$nvpReqArray; + $nvpReqArray = deformatNVP($nvpreq); + $_SESSION['nvpReqArray'] = $nvpReqArray; //convrting NVPResponse to an Associative Array dol_syslog("Paypal API hash_call Response nvpresp=".$response); - $nvpResArray=deformatNVP($response); + $nvpResArray = deformatNVP($response); if (curl_errno($ch)) { // moving to display page to display curl errors - $_SESSION['curl_error_no']=curl_errno($ch); - $_SESSION['curl_error_msg']=curl_error($ch); + $_SESSION['curl_error_no'] = curl_errno($ch); + $_SESSION['curl_error_msg'] = curl_error($ch); //Execute the Error handling module to display errors. } @@ -696,22 +696,22 @@ function hash_call($methodName, $nvpStr) */ function deformatNVP($nvpstr) { - $intial=0; + $intial = 0; $nvpArray = array(); - while(strlen($nvpstr)) + while (strlen($nvpstr)) { //postion of Key - $keypos= strpos($nvpstr, '='); + $keypos = strpos($nvpstr, '='); //position of value - $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&'): strlen($nvpstr); + $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr); /*getting the Key and Value values and storing in a Associative Array*/ - $keyval=substr($nvpstr, $intial, $keypos); - $valval=substr($nvpstr, $keypos+1, $valuepos-$keypos-1); + $keyval = substr($nvpstr, $intial, $keypos); + $valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1); //decoding the respose - $nvpArray[urldecode($keyval)] =urldecode($valval); - $nvpstr=substr($nvpstr, $valuepos+1, strlen($nvpstr)); + $nvpArray[urldecode($keyval)] = urldecode($valval); + $nvpstr = substr($nvpstr, $valuepos + 1, strlen($nvpstr)); } return $nvpArray; } @@ -723,16 +723,16 @@ function deformatNVP($nvpstr) */ function getApiError() { - $errors=array(); + $errors = array(); - $resArray=$_SESSION['reshash']; + $resArray = $_SESSION['reshash']; - if(isset($_SESSION['curl_error_no'])) + if (isset($_SESSION['curl_error_no'])) { $errors[] = $_SESSION['curl_error_no'].'-'.$_SESSION['curl_error_msg']; } - foreach($resArray as $key => $value) + foreach ($resArray as $key => $value) { $errors[] = $key.'-'.$value; } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 51deaf8c73b..f9a4a12b0df 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -673,18 +673,18 @@ class Products extends DolibarrApi throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode'); } - $id = (empty($id)?0:$id); + $id = (empty($id) ? 0 : $id); - if(! DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(403); } $result = $this->product->fetch($id, $ref, $ref_ext, $barcode); - if(! $result ) { + if (!$result) { throw new RestException(404, 'Product not found'); } - if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { + if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -765,18 +765,18 @@ class Products extends DolibarrApi throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode'); } - $id = (empty($id)?0:$id); + $id = (empty($id) ? 0 : $id); - if(! DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(403); } $result = $this->product->fetch($id, $ref, $ref_ext, $barcode); - if(! $result ) { + if (!$result) { throw new RestException(404, 'Product not found'); } - if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { + if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 72fd475e6ae..3c05b4e1ad1 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -37,11 +37,11 @@ class FormProduct /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; // Cache arrays - public $cache_warehouses=array(); - public $cache_lot=array(); + public $cache_warehouses = array(); + public $cache_lot = array(); /** @@ -76,7 +76,7 @@ class FormProduct { global $conf, $langs; - if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product + if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product if (is_array($exclude)) $excludeGroups = implode("','", $exclude); @@ -100,59 +100,59 @@ class FormProduct { if (!empty($batch)) { - $sql.= ", pb.qty as stock"; + $sql .= ", pb.qty as stock"; } else { - $sql.= ", ps.reel as stock"; + $sql .= ", ps.reel as stock"; } } elseif ($sumStock) { - $sql.= ", sum(ps.reel) as stock"; + $sql .= ", sum(ps.reel) as stock"; } - $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_entrepot = e.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_entrepot = e.rowid"; if (!empty($fk_product)) { - $sql.= " AND ps.fk_product = '".$fk_product."'"; + $sql .= " AND ps.fk_product = '".$fk_product."'"; if (!empty($batch)) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'"; } } - $sql.= " WHERE e.entity IN (".getEntity('stock').")"; + $sql .= " WHERE e.entity IN (".getEntity('stock').")"; if (count($warehouseStatus)) { - $sql.= " AND e.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")"; + $sql .= " AND e.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")"; } else { - $sql.= " AND e.statut = 1"; + $sql .= " AND e.statut = 1"; } - if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; + if (!empty($exclude)) $sql .= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; // minimum stock if ($stockMin !== false) { if (!empty($fk_product)) { if (!empty($batch)) { - $sql .= " AND pb.qty > " . $this->db->escape($stockMin); + $sql .= " AND pb.qty > ".$this->db->escape($stockMin); } else { - $sql .= " AND ps.reel > " . $this->db->escape($stockMin); + $sql .= " AND ps.reel > ".$this->db->escape($stockMin); } } } if ($sumStock && empty($fk_product)) { - $sql.= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent"; + $sql .= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent"; // minimum stock if ($stockMin !== false) { - $sql .= " HAVING sum(ps.reel) > " . $this->db->escape($stockMin); + $sql .= " HAVING sum(ps.reel) > ".$this->db->escape($stockMin); } } - $sql.= " ORDER BY " . $orderBy; + $sql .= " ORDER BY ".$orderBy; dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG); $resql = $this->db->query($sql); @@ -164,16 +164,16 @@ class FormProduct { $obj = $this->db->fetch_object($resql); if ($sumStock) $obj->stock = price2num($obj->stock, 5); - $this->cache_warehouses[$obj->rowid]['id'] =$obj->rowid; - $this->cache_warehouses[$obj->rowid]['label']=$obj->label; - $this->cache_warehouses[$obj->rowid]['parent_id']=$obj->fk_parent; + $this->cache_warehouses[$obj->rowid]['id'] = $obj->rowid; + $this->cache_warehouses[$obj->rowid]['label'] = $obj->label; + $this->cache_warehouses[$obj->rowid]['parent_id'] = $obj->fk_parent; $this->cache_warehouses[$obj->rowid]['description'] = $obj->description; $this->cache_warehouses[$obj->rowid]['stock'] = $obj->stock; $i++; } // Full label init - foreach($this->cache_warehouses as $obj_rowid=>$tab) { + foreach ($this->cache_warehouses as $obj_rowid=>$tab) { $this->cache_warehouses[$obj_rowid]['full_label'] = $this->get_parent_path($tab); } @@ -197,11 +197,11 @@ class FormProduct private function get_parent_path($tab, $final_label = '') { //phpcs:enable - if(empty($final_label)) $final_label = $tab['label']; + if (empty($final_label)) $final_label = $tab['label']; - if(empty($tab['parent_id'])) return $final_label; + if (empty($tab['parent_id'])) return $final_label; else { - if(!empty($this->cache_warehouses[$tab['parent_id']])) { + if (!empty($this->cache_warehouses[$tab['parent_id']])) { $final_label = $this->cache_warehouses[$tab['parent_id']]['label'].' >> '.$final_label; return $this->get_parent_path($this->cache_warehouses[$tab['parent_id']], $final_label); } @@ -309,8 +309,8 @@ class FormProduct print '
        '; } else { if ($selected) { - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php'; - $warehousestatic=new Entrepot($this->db); + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + $warehousestatic = new Entrepot($this->db); $warehousestatic->fetch($selected); print $warehousestatic->getNomUrl(); } else { @@ -357,7 +357,7 @@ class FormProduct $return = ''; // TODO Use a cache - require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; $measuringUnits = new CUnits($db); $filter = array(); @@ -392,7 +392,7 @@ class FormProduct elseif ($mode == 2 && $lines->scale == $default) $return .= ' selected'; elseif ($mode == 0 && $lines->id == $default) $return .= ' selected'; $return .= '>'; - if ($measuring_style == 'time') $return.= $langs->trans(ucfirst($lines->label)); + if ($measuring_style == 'time') $return .= $langs->trans(ucfirst($lines->label)); else $return .= $langs->trans($lines->label); $return .= ''; } @@ -426,11 +426,11 @@ class FormProduct dol_syslog(get_class($this)."::selectLot $selected, $htmlname, $filterstatus, $empty, $disabled, $fk_product, $fk_entrepot, $empty_label, $forcecombo, $morecss", LOG_DEBUG); - $out=''; + $out = ''; $productIdArray = array(); - if (! is_array($objectLines) || ! count($objectLines)) + if (!is_array($objectLines) || !count($objectLines)) { - if (! empty($fk_product)) $productIdArray[] = $fk_product; + if (!empty($fk_product)) $productIdArray[] = $fk_product; } else { @@ -515,7 +515,7 @@ class FormProduct // check cache already loaded for product id's foreach ($productIdArray as $productId) { - $cacheLoaded = ! empty($this->cache_lot[$productId]) ? true : false; + $cacheLoaded = !empty($this->cache_lot[$productId]) ? true : false; } } if ($cacheLoaded) @@ -528,14 +528,14 @@ class FormProduct $this->cache_lot = array(); $productIdList = implode(',', $productIdArray); $sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.ref as label, ps.fk_product"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.rowid = pb.fk_product_stock"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.rowid = pb.fk_product_stock"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")"; if (!empty($productIdList)) { - $sql.= " WHERE ps.fk_product IN (".$productIdList.")"; + $sql .= " WHERE ps.fk_product IN (".$productIdList.")"; } - $sql.= " ORDER BY e.ref, pb.batch"; + $sql .= " ORDER BY e.ref, pb.batch"; dol_syslog(get_class($this).'::loadLotStock', LOG_DEBUG); $resql = $this->db->query($sql); @@ -546,10 +546,10 @@ class FormProduct while ($i < $num) { $obj = $this->db->fetch_object($resql); - $this->cache_lot[$obj->fk_product][$obj->rowid]['id'] =$obj->rowid; - $this->cache_lot[$obj->fk_product][$obj->rowid]['batch']=$obj->batch; - $this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_id']=$obj->fk_entrepot; - $this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_label']=$obj->label; + $this->cache_lot[$obj->fk_product][$obj->rowid]['id'] = $obj->rowid; + $this->cache_lot[$obj->fk_product][$obj->rowid]['batch'] = $obj->batch; + $this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_id'] = $obj->fk_entrepot; + $this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_label'] = $obj->label; $this->cache_lot[$obj->fk_product][$obj->rowid]['qty'] = $obj->qty; $i++; } diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 2659d325676..43821b99b31 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -27,15 +27,15 @@ include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("stocks","other")); +$langs->loadLangs(array("stocks", "other")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectcard'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) @@ -48,28 +48,28 @@ else } // Initialize technical objects -$object=new Inventory($db); +$object = new Inventory($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->stock->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } -if (empty($action) && empty($id) && empty($ref)) $action='view'; +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user //if ($user->socid > 0) access_forbidden(); @@ -92,13 +92,13 @@ else * Actions */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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)) { - $error=0; + $error = 0; $backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php'; @@ -125,7 +125,7 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); llxHeader('', $langs->trans('Inventory'), ''); @@ -160,10 +160,10 @@ if ($action == 'create') print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print '
        '."\n"; @@ -172,7 +172,7 @@ if ($action == 'create') print '
        '; print ''; print '  '; - print ''; // Cancel for create does not post form if we don't know the backtopage + print ''; // Cancel for create does not post form if we don't know the backtopage print '
        '; print ''; @@ -196,10 +196,10 @@ if (($id || $ref) && $action == 'edit') print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; print '
        '; @@ -224,7 +224,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } // Confirmation to delete line if ($action == 'deleteline') @@ -236,14 +236,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action == 'clone') { // Create an array for form $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -251,9 +251,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
        '; + $morehtmlref = '
        '; /* // Ref bis $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->inventory->creer, 'string', '', 0, 1); @@ -293,7 +293,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } */ - $morehtmlref.='
        '; + $morehtmlref .= '
        '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -305,10 +305,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Other attributes. Fields from hook formObjectOptions and Extrafields. - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
        '; print '
        '; @@ -322,14 +322,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Buttons for actions if ($action != 'presend' && $action != 'editline') { print '
        '."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { // Send - print '' . $langs->trans('SendMail') . ''."\n"; + print ''.$langs->trans('SendMail').''."\n"; if ($permissiontoadd) { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 41e91b04d0c..6f8c5648275 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -33,28 +33,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'companies', 'categories')); -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); -$confirm=GETPOST('confirm'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm'); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "DESC"; -$backtopage=GETPOST('backtopage', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); // Security check //$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('warehousecard', 'globalcard')); @@ -66,7 +66,7 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || ! empty($ref)) { +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); // if ($ret > 0) // $ret = $object->fetch_thirdparty(); @@ -87,8 +87,8 @@ $usercanread = (($user->rights->stock->lire)); $usercancreate = (($user->rights->stock->creer)); $usercandelete = (($user->rights->stock->supprimer)); -$parameters=array('id'=>$id, 'ref'=>$ref); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id, 'ref'=>$ref); +$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)) { @@ -106,7 +106,7 @@ if (empty($reshook)) $object->town = GETPOST("town"); $object->country_id = GETPOST("country_id"); - if (! empty($object->libelle)) + if (!empty($object->libelle)) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -115,7 +115,7 @@ if (empty($reshook)) $action = 'create'; } - if (! $error) { + if (!$error) { $id = $object->create($user); if ($id > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -123,10 +123,10 @@ if (empty($reshook)) $categories = GETPOST('categories', 'array'); $object->setCategories($categories); if (!empty($backtopage)) { - header("Location: " . $backtopage); + header("Location: ".$backtopage); exit; } else { - header("Location: card.php?id=" . $id); + header("Location: card.php?id=".$id); exit; } } else { @@ -138,7 +138,7 @@ if (empty($reshook)) else { setEventMessages($langs->trans("ErrorWarehouseRefRequired"), null, 'errors'); - $action="create"; // Force retour sur page creation + $action = "create"; // Force retour sur page creation } } @@ -146,7 +146,7 @@ if (empty($reshook)) if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->supprimer) { $object->fetch(GETPOST('id', 'int')); - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); @@ -156,7 +156,7 @@ if (empty($reshook)) else { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } @@ -179,7 +179,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (! $error) { + if (!$error) { $ret = $object->update($id, $user); if ($ret < 0) $error++; } @@ -205,7 +205,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) { + if (!$error) { $result = $object->insertExtraFields(); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -232,13 +232,13 @@ if (empty($reshook)) * View */ -$productstatic=new Product($db); -$form=new Form($db); -$formproduct=new FormProduct($db); -$formcompany=new FormCompany($db); +$productstatic = new Product($db); +$form = new Form($db); +$formproduct = new FormProduct($db); +$formcompany = new FormCompany($db); $formfile = new FormFile($db); -$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; +$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; llxHeader("", $langs->trans("WarehouseCard"), $help_url); @@ -260,7 +260,7 @@ if ($action == 'create') // Ref print '
        '.$langs->trans("Ref").'
        '.$langs->trans("LocationSummary").'
        '.$langs->trans("LocationSummary").'
        '.$langs->trans("AddIn").''; @@ -271,25 +271,25 @@ if ($action == 'create') print '
        '.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('desc', (!empty($object->description)?$object->description:''), '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor('desc', (!empty($object->description) ? $object->description : ''), '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); print '
        '.$langs->trans('Address').'
        '.$langs->trans('Zip').''; - print $formcompany->select_ziptown((!empty($object->zip)?$object->zip:''), 'zipcode', array('town','selectcountry_id','state_id'), 6); + print $formcompany->select_ziptown((!empty($object->zip) ? $object->zip : ''), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print '
        '.$langs->trans('Town').''; - print $formcompany->select_ziptown((!empty($object->town)?$object->town:''), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((!empty($object->town) ? $object->town : ''), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
        '.$langs->trans('Country').''; - print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code), 'country_id'); + print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code), 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
        '.$langs->trans("Description").''.nl2br($object->description).'
        '.$langs->trans("NumberOfDifferentProducts").''; - print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']; + print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']; print "
        '.$langs->trans("NumberOfProducts").''; - $valtoshow=price2num($calcproducts['nb'], 'MS'); - print empty($valtoshow)?'0':$valtoshow; + $valtoshow = price2num($calcproducts['nb'], 'MS'); + print empty($valtoshow) ? '0' : $valtoshow; print "
        '; @@ -424,7 +424,7 @@ else // Value print ''.$langs->trans("EstimatedStockValueShort").''; - print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); + print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); print ""; // Last movement @@ -450,9 +450,9 @@ else } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Categories - if($conf->categorie->enabled) { + if ($conf->categorie->enabled) { print ''.$langs->trans("Categories").''; print $form->showCategories($object->id, 'warehouse', 1); print ""; @@ -476,8 +476,8 @@ else print "
        \n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if (empty($action)) @@ -525,16 +525,16 @@ else } print "\n"; - $totalunit=0; - $totalvalue=$totalvaluesell=0; + $totalunit = 0; + $totalvalue = $totalvaluesell = 0; $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; - $sql.= " ps.reel as value"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; - $sql.= " WHERE ps.fk_product = p.rowid"; - $sql.= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) - $sql.= " AND ps.fk_entrepot = ".$object->id; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " ps.reel as value"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; + $sql .= " WHERE ps.fk_product = p.rowid"; + $sql .= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) + $sql .= " AND ps.fk_entrepot = ".$object->id; + $sql .= $db->order($sortfield, $sortorder); dol_syslog('List products', LOG_DEBUG); $resql = $db->query($sql); @@ -547,13 +547,13 @@ else $objp = $db->fetch_object($resql); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$objp->rowid; - $sql.= " AND lang='". $langs->getDefaultLang() ."'"; - $sql.= " LIMIT 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$objp->rowid; + $sql .= " AND lang='".$langs->getDefaultLang()."'"; + $sql .= " LIMIT 1"; $result = $db->query($sql); if ($result) @@ -567,12 +567,12 @@ else //print ''.dol_print_date($objp->datem).''; print ''; print ""; - $productstatic->id=$objp->rowid; + $productstatic->id = $objp->rowid; $productstatic->ref = $objp->ref; $productstatic->label = $objp->produit; - $productstatic->type=$objp->type; - $productstatic->entity=$objp->entity; - $productstatic->status_batch=$objp->tobatch; + $productstatic->type = $objp->type; + $productstatic->entity = $objp->entity; + $productstatic->status_batch = $objp->tobatch; print $productstatic->getNomUrl(1, 'stock', 16); print ''; @@ -580,31 +580,31 @@ else print ''.$objp->produit.''; print ''; - $valtoshow=price(price2num($objp->value, 'MS'), 0, '', 0, 0); // TODO replace with a qty() function - print empty($valtoshow)?'0':$valtoshow; + $valtoshow = price(price2num($objp->value, 'MS'), 0, '', 0, 0); // TODO replace with a qty() function + print empty($valtoshow) ? '0' : $valtoshow; print ''; - $totalunit+=$objp->value; + $totalunit += $objp->value; // Price buy PMP print ''.price(price2num($objp->ppmp, 'MU')).''; // Total PMP - print ''.price(price2num($objp->ppmp*$objp->value, 'MT')).''; - $totalvalue+=price2num($objp->ppmp*$objp->value, 'MT'); + print ''.price(price2num($objp->ppmp * $objp->value, 'MT')).''; + $totalvalue += price2num($objp->ppmp * $objp->value, 'MT'); // Price sell min if (empty($conf->global->PRODUIT_MULTIPRICES)) { - $pricemin=$objp->price; + $pricemin = $objp->price; print ''; print price(price2num($pricemin, 'MU'), 1); print ''; // Total sell min print ''; - print price(price2num($pricemin*$objp->value, 'MT'), 1); + print price(price2num($pricemin * $objp->value, 'MT'), 1); print ''; } - $totalvaluesell+=price2num($pricemin*$objp->value, 'MT'); + $totalvaluesell += price2num($pricemin * $objp->value, 'MT'); if ($user->rights->stock->mouvement->creer) { @@ -627,8 +627,8 @@ else print ''.$langs->trans("Total").''; print ''; - $valtoshow=price2num($totalunit, 'MS'); - print empty($valtoshow)?'0':$valtoshow; + $valtoshow = price2num($totalunit, 'MS'); + print empty($valtoshow) ? '0' : $valtoshow; print ''; print ' '; print ''.price(price2num($totalvalue, 'MT')).''; @@ -681,7 +681,7 @@ else print ''.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('desc', $object->description, '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor('desc', $object->description, '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); print ''; @@ -691,15 +691,15 @@ else // Zip / Town print ''.$langs->trans('Zip').''; - print $formcompany->select_ziptown($object->zip, 'zipcode', array('town','selectcountry_id','state_id'), 6); + print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print ''; print ''.$langs->trans('Town').''; - print $formcompany->select_ziptown($object->town, 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); print ''; // Country print ''.$langs->trans('Country').''; - print $form->select_country($object->country_id?$object->country_id:$mysoc->country_code, 'country_id'); + print $form->select_country($object->country_id ? $object->country_id : $mysoc->country_code, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; @@ -721,8 +721,8 @@ else print ''; // Other attributes - $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('colspan' => ' colspan="3"', 'cols'=>3); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -735,8 +735,8 @@ else $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE, '', 'parent', 64, 0, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_WAREHOUSE); - $arrayselected=array(); - foreach($cats as $cat) { + $arrayselected = array(); + foreach ($cats as $cat) { $arrayselected[] = $cat->id; } print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); @@ -763,7 +763,7 @@ else if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $modulepart='stock'; + $modulepart = 'stock'; if ($action != 'create' && $action != 'edit' && $action != 'delete') { @@ -773,28 +773,28 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // Documents $objectref = dol_sanitizeFileName($object->ref); - $relativepath = $comref . '/' . $objectref . '.pdf'; - $filedir = $conf->stock->dir_output . '/' . $objectref; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$usercanread; - $delallowed=$usercancreate; + $relativepath = $comref.'/'.$objectref.'.pdf'; + $filedir = $conf->stock->dir_output.'/'.$objectref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $usercanread; + $delallowed = $usercancreate; $modulepart = 'stock'; print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); - $somethingshown=$formfile->numoffiles; + $somethingshown = $formfile->numoffiles; print '
        '; $MAXEVENT = 10; $morehtmlright = ''; - $morehtmlright.= $langs->trans("SeeAll"); - $morehtmlright.= ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'stock', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product + $somethingshown = $formactions->showactions($object, 'stock', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product print '
        '; } diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 60c98d81a60..09273ee947d 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -37,29 +37,29 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! empty($conf->projet->enabled)) { +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'orders')); -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); // Security check -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$msid=GETPOST('msid', 'int'); -$product_id=GETPOST("product_id", 'int'); -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'movementlist'; +$msid = GETPOST('msid', 'int'); +$product_id = GETPOST("product_id", 'int'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; // Security check //$result=restrictedArea($user, 'stock', $id, 'entrepot&stock'); -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); $idproduct = GETPOST('idproduct', 'int'); $year = GETPOST("year"); @@ -73,18 +73,18 @@ $search_inventorycode = trim(GETPOST("search_inventorycode")); $search_user = trim(GETPOST("search_user")); $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); -$search_type_mouvement=GETPOST('search_type_mouvement', 'int'); +$search_type_mouvement = GETPOST('search_type_mouvement', 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (! $sortfield) $sortfield="m.datem"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "m.datem"; +if (!$sortorder) $sortorder = "DESC"; -$pdluoid=GETPOST('pdluoid', 'int'); +$pdluoid = GETPOST('pdluoid', 'int'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new MouvementStock($db); @@ -95,17 +95,17 @@ $formfile = new FormFile($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -$arrayfields=array( +$arrayfields = array( 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1), 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'), 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1), - 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(! $id > 0)), // If we are on specific warehouse, we hide it + 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(!$id > 0)), // If we are on specific warehouse, we hide it 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1), @@ -132,11 +132,11 @@ $usercanread = (($user->rights->stock->mouvement->lire)); $usercancreate = (($user->rights->stock->mouvement->creer)); $usercandelete = (($user->rights->stock->mouvement->supprimer)); -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -144,45 +144,45 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $year=''; - $month=''; - $search_ref=''; - $search_movement=""; - $search_type_mouvement=""; - $search_inventorycode=""; - $search_product_ref=""; - $search_product=""; - $search_warehouse=""; - $search_user=""; - $search_batch=""; - $search_qty=''; - $sall=""; - $toselect=''; - $search_array_options=array(); + $year = ''; + $month = ''; + $search_ref = ''; + $search_movement = ""; + $search_type_mouvement = ""; + $search_inventorycode = ""; + $search_product_ref = ""; + $search_product = ""; + $search_warehouse = ""; + $search_user = ""; + $search_batch = ""; + $search_qty = ''; + $sall = ""; + $toselect = ''; + $search_array_options = array(); } // Correct stock if ($action == "correct_stock") { $product = new Product($db); - if (! empty($product_id)) $result=$product->fetch($product_id); + if (!empty($product_id)) $result = $product->fetch($product_id); - $error=0; + $error = 0; if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); - $action='correction'; + $action = 'correction'; } - if (! is_numeric($_POST["nbpiece"])) + if (!is_numeric($_POST["nbpiece"])) { $error++; setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); - $action='correction'; + $action = 'correction'; } - if (! $error) + if (!$error) { $origin_element = ''; $origin_id = null; @@ -227,7 +227,7 @@ if ($action == "correct_stock") GETPOST('inventorycode'), $origin_element, $origin_id - ); // We do not change value of stock for a correction + ); // We do not change value of stock for a correction } if ($result > 0) @@ -239,72 +239,72 @@ if ($action == "correct_stock") { $error++; setEventMessages($product->error, $product->errors, 'errors'); - $action='correction'; + $action = 'correction'; } } - if (! $error) $action=''; + if (!$error) $action = ''; } // Transfer stock from a warehouse to another warehouse -if ($action == "transfert_stock" && ! $cancel) +if ($action == "transfert_stock" && !$cancel) { $product = new Product($db); - if (! empty($product_id)) $result=$product->fetch($product_id); + if (!empty($product_id)) $result = $product->fetch($product_id); - if (! (GETPOST("id_entrepot_destination", 'int') > 0)) + if (!(GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); - $action='transfert'; + $action = 'transfert'; } - if (! GETPOST("nbpiece", 'int')) + if (!GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } if ($id == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } - if (! empty($conf->productbatch->enabled)) + if (!empty($conf->productbatch->enabled)) { $product = new Product($db); - $result=$product->fetch($product_id); + $result = $product->fetch($product_id); - if ($product->hasbatch() && ! GETPOST("batch_number")) + if ($product->hasbatch() && !GETPOST("batch_number")) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } } - if (! $error) + if (!$error) { if ($id) { $object = new Entrepot($db); - $result=$object->fetch($id); + $result = $object->fetch($id); $db->begin(); - $product->load_stock('novirtual'); // Load array product->stock_warehouse + $product->load_stock('novirtual'); // Load array product->stock_warehouse // Define value of products moved - $pricesrc=0; - if (isset($product->pmp)) $pricesrc=$product->pmp; - $pricedest=$pricesrc; + $pricesrc = 0; + if (isset($product->pmp)) $pricesrc = $product->pmp; + $pricedest = $pricesrc; if ($product->hasbatch()) { @@ -312,13 +312,13 @@ if ($action == "transfert_stock" && ! $cancel) if ($pdluoid > 0) { - $result=$pdluo->fetch($pdluoid); + $result = $pdluo->fetch($pdluoid); if ($result) { - $srcwarehouseid=$pdluo->warehouseid; - $batch=$pdluo->batch; - $eatby=$pdluo->eatby; - $sellby=$pdluo->sellby; + $srcwarehouseid = $pdluo->warehouseid; + $batch = $pdluo->batch; + $eatby = $pdluo->eatby; + $sellby = $pdluo->sellby; } else { @@ -328,16 +328,16 @@ if ($action == "transfert_stock" && ! $cancel) } else { - $srcwarehouseid=$id; - $batch=GETPOST('batch_number'); - $eatby=$d_eatby; - $sellby=$d_sellby; + $srcwarehouseid = $id; + $batch = GETPOST('batch_number'); + $eatby = $d_eatby; + $sellby = $d_sellby; } - if (! $error) + if (!$error) { // Remove stock - $result1=$product->correct_stock_batch( + $result1 = $product->correct_stock_batch( $user, $srcwarehouseid, GETPOST("nbpiece", 'int'), @@ -348,7 +348,7 @@ if ($action == "transfert_stock" && ! $cancel) GETPOST('inventorycode') ); // Add stock - $result2=$product->correct_stock_batch( + $result2 = $product->correct_stock_batch( $user, GETPOST("id_entrepot_destination", 'int'), GETPOST("nbpiece", 'int'), @@ -363,7 +363,7 @@ if ($action == "transfert_stock" && ! $cancel) else { // Remove stock - $result1=$product->correct_stock( + $result1 = $product->correct_stock( $user, $id, GETPOST("nbpiece"), @@ -374,7 +374,7 @@ if ($action == "transfert_stock" && ! $cancel) ); // Add stock - $result2=$product->correct_stock( + $result2 = $product->correct_stock( $user, GETPOST("id_entrepot_destination"), GETPOST("nbpiece"), @@ -384,7 +384,7 @@ if ($action == "transfert_stock" && ! $cancel) GETPOST('inventorycode') ); } - if (! $error && $result1 >= 0 && $result2 >= 0) + if (!$error && $result1 >= 0 && $result2 >= 0) { $db->commit(); @@ -403,7 +403,7 @@ if ($action == "transfert_stock" && ! $cancel) { setEventMessages($product->error, $product->errors, 'errors'); $db->rollback(); - $action='transfert'; + $action = 'transfert'; } } } @@ -484,9 +484,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -if(empty($search_inventorycode)) +if (empty($search_inventorycode)) { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } else { @@ -497,7 +497,7 @@ else $resql = $db->query($sql); -if(!empty($search_inventorycode)) $limit = $db->num_rows($resql); +if (!empty($search_inventorycode)) $limit = $db->num_rows($resql); if ($resql) { @@ -519,16 +519,16 @@ if ($resql) $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); $i = 0; - $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; if ($msid) $texte = $langs->trans('StockMovementForId', $msid); else { $texte = $langs->trans("ListOfStockMovements"); - if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')'; + if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; } llxHeader("", $texte, $help_url); @@ -565,18 +565,18 @@ if ($resql) // Description print ''.$langs->trans("Description").''.dol_htmlentitiesbr($object->description).''; - $calcproductsunique=$object->nb_different_products(); - $calcproducts=$object->nb_products(); + $calcproductsunique = $object->nb_different_products(); + $calcproducts = $object->nb_products(); // Total nb of different products print ''.$langs->trans("NumberOfDifferentProducts").''; - print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']; + print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']; print ""; // Nb of products print ''.$langs->trans("NumberOfProducts").''; - $valtoshow=price2num($calcproducts['nb'], 'MS'); - print empty($valtoshow)?'0':$valtoshow; + $valtoshow = price2num($calcproducts['nb'], 'MS'); + print empty($valtoshow) ? '0' : $valtoshow; print ""; print ''; @@ -590,7 +590,7 @@ if ($resql) // Value print ''.$langs->trans("EstimatedStockValueShort").''; - print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); + print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); print ""; // Last movement @@ -601,7 +601,7 @@ if ($resql) if ($resqlbis) { $obj = $db->fetch_object($resqlbis); - $lastmovementdate=$db->jdate($obj->datem); + $lastmovementdate = $db->jdate($obj->datem); } else { @@ -673,32 +673,32 @@ if ($resql) print '

        '; } - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($id > 0) $param.='&id='.$id; - if ($search_movement) $param.='&search_movement='.urlencode($search_movement); - if ($search_inventorycode) $param.='&search_inventorycode='.urlencode($search_inventorycode); - if ($search_type_mouvement) $param.='&search_type_mouvement='.urlencode($search_type_mouvement); - if ($search_product_ref) $param.='&search_product_ref='.urlencode($search_product_ref); - if ($search_product) $param.='&search_product='.urlencode($search_product); - if ($search_batch) $param.='&search_batch='.urlencode($search_batch); - if ($search_warehouse > 0) $param.='&search_warehouse='.urlencode($search_warehouse); - if (!empty($sref)) $param.='&sref='.urlencode($sref); // FIXME $sref is not defined - if (!empty($snom)) $param.='&snom='.urlencode($snom); // FIXME $snom is not defined - if ($search_user) $param.='&search_user='.urlencode($search_user); - if ($idproduct > 0) $param.='&idproduct='.$idproduct; + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($id > 0) $param .= '&id='.$id; + if ($search_movement) $param .= '&search_movement='.urlencode($search_movement); + if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); + if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); + if ($search_product_ref) $param .= '&search_product_ref='.urlencode($search_product_ref); + if ($search_product) $param .= '&search_product='.urlencode($search_product); + if ($search_batch) $param .= '&search_batch='.urlencode($search_batch); + if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse); + if (!empty($sref)) $param .= '&sref='.urlencode($sref); // FIXME $sref is not defined + if (!empty($snom)) $param .= '&snom='.urlencode($snom); // FIXME $snom is not defined + if ($search_user) $param .= '&search_user='.urlencode($search_user); + if ($idproduct > 0) $param .= '&idproduct='.$idproduct; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( // 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
        '; if ($optioncss != '') print ''; @@ -717,147 +717,147 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
        '.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
        '; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
        '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
        '; } - $moreforfilter=''; + $moreforfilter = ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
        '; print $moreforfilter; print '
        '; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '
        '; - print ''."\n"; + print '
        '."\n"; // Fields title search print ''; - if (! empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) { // Ref print ''; } - if (! empty($arrayfields['m.datem']['checked'])) + if (!empty($arrayfields['m.datem']['checked'])) { print ''; } - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { // Product Ref print ''; } - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { // Product label print ''; } // Batch - if (! empty($arrayfields['m.batch']['checked'])) + if (!empty($arrayfields['m.batch']['checked'])) { print ''; } - if (! empty($arrayfields['pl.eatby']['checked'])) + if (!empty($arrayfields['pl.eatby']['checked'])) { print ''; } - if (! empty($arrayfields['pl.sellby']['checked'])) + if (!empty($arrayfields['pl.sellby']['checked'])) { print ''; } // Warehouse - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print ''; } - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) { // Author print ''; } - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print ''; } - if (! empty($arrayfields['m.label']['checked'])) + if (!empty($arrayfields['m.label']['checked'])) { // Label of movement print ''; } - if (! empty($arrayfields['m.type_mouvement']['checked'])) + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement print ''; } - if (! empty($arrayfields['origin']['checked'])) + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print ''; } - if (! empty($arrayfields['m.value']['checked'])) + if (!empty($arrayfields['m.value']['checked'])) { // Qty print ''; } - if (! empty($arrayfields['m.price']['checked'])) + if (!empty($arrayfields['m.price']['checked'])) { // Price print ''; } - if (! empty($arrayfields['m.fk_projet']['checked'])) + if (!empty($arrayfields['m.fk_projet']['checked'])) { // fk_project print ''; } // Date modification - if (! empty($arrayfields['m.tms']['checked'])) + if (!empty($arrayfields['m.tms']['checked'])) { print ''; } // Actions print ''; print "\n"; print ''; - if (! empty($arrayfields['m.rowid']['checked'])) { + if (!empty($arrayfields['m.rowid']['checked'])) { print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['m.datem']['checked'])) { + if (!empty($arrayfields['m.datem']['checked'])) { print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.ref']['checked'])) { + if (!empty($arrayfields['p.ref']['checked'])) { print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.label']['checked'])) { + if (!empty($arrayfields['p.label']['checked'])) { print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['m.batch']['checked'])) { + if (!empty($arrayfields['m.batch']['checked'])) { print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['pl.eatby']['checked'])) { + if (!empty($arrayfields['pl.eatby']['checked'])) { print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['pl.sellby']['checked'])) { + if (!empty($arrayfields['pl.sellby']['checked'])) { print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['e.ref']['checked'])) { + if (!empty($arrayfields['e.ref']['checked'])) { // We are on a specific warehouse card, no filter on other should be possible print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.fk_user_author']['checked'])) { + if (!empty($arrayfields['m.fk_user_author']['checked'])) { print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.inventorycode']['checked'])) { + if (!empty($arrayfields['m.inventorycode']['checked'])) { print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.label']['checked'])) { + if (!empty($arrayfields['m.label']['checked'])) { print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.type_mouvement']['checked'])) { + if (!empty($arrayfields['m.type_mouvement']['checked'])) { print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['origin']['checked'])) { + if (!empty($arrayfields['origin']['checked'])) { print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.value']['checked'])) { + if (!empty($arrayfields['m.value']['checked'])) { print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['m.price']['checked'])) { + if (!empty($arrayfields['m.price']['checked'])) { print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['m.fk_projet']['checked'])) { + if (!empty($arrayfields['m.fk_projet']['checked'])) { print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, 'align="right"', $sortfield, $sortorder); } @@ -1001,23 +1001,23 @@ if ($resql) print ''; // Id movement - if (! empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) { - print ''; // This is primary not movement id + print ''; // This is primary not movement id } - if (! empty($arrayfields['m.datem']['checked'])) + if (!empty($arrayfields['m.datem']['checked'])) { // Date print ''; } - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { // Product ref print '\n"; } - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { // Product label print '\n"; } - if (! empty($arrayfields['m.batch']['checked'])) + if (!empty($arrayfields['m.batch']['checked'])) { print ''; } - if (! empty($arrayfields['pl.eatby']['checked'])) + if (!empty($arrayfields['pl.eatby']['checked'])) { - print ''; + print ''; } - if (! empty($arrayfields['pl.sellby']['checked'])) + if (!empty($arrayfields['pl.sellby']['checked'])) { - print ''; + print ''; } // Warehouse - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print '\n"; } // Author - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) { print '\n"; } - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print ''; } - if (! empty($arrayfields['m.type_mouvement']['checked'])) + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement - switch($objp->type_mouvement){ + switch ($objp->type_mouvement) { case "0": print ''; break; @@ -1093,12 +1093,12 @@ if ($resql) break; } } - if (! empty($arrayfields['origin']['checked'])) + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print ''; } - if (! empty($arrayfields['m.value']['checked'])) + if (!empty($arrayfields['m.value']['checked'])) { // Qty print ''; } - if (! empty($arrayfields['m.price']['checked'])) + if (!empty($arrayfields['m.price']['checked'])) { // Price print ''; } - if (! empty($arrayfields['m.fk_projet']['checked'])) + if (!empty($arrayfields['m.fk_projet']['checked'])) { // fk_project print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; $i++; @@ -1145,16 +1145,16 @@ if ($resql) { print "
        "; - $productidselected=0; + $productidselected = 0; foreach ($arrayofuniqueproduct as $key => $val) { - $productidselected=$key; - $productlabelselected=$val; + $productidselected = $key; + $productlabelselected = $val; } - $datebefore=dol_get_first_day($year?$year:strftime("%Y", time()), $month?$month:1, true); - $dateafter=dol_get_last_day($year?$year:strftime("%Y", time()), $month?$month:12, true); - $balancebefore=$movement->calculateBalanceForProductBefore($productidselected, $datebefore); - $balanceafter=$movement->calculateBalanceForProductBefore($productidselected, $dateafter); + $datebefore = dol_get_first_day($year ? $year : strftime("%Y", time()), $month ? $month : 1, true); + $dateafter = dol_get_last_day($year ? $year : strftime("%Y", time()), $month ? $month : 12, true); + $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore); + $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter); //print ''; // Customer proposals - if (! empty($conf->propal->enabled) && $user->rights->propale->lire) + if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $nblines++; - $ret=$product->load_stats_propale($socid); + $ret = $product->load_stats_propale($socid); if ($ret < 0) dol_print_error($db); $langs->load("propal"); print ''; } // Supplier proposals - if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) + if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { $nblines++; - $ret=$product->load_stats_proposal_supplier($socid); + $ret = $product->load_stats_proposal_supplier($socid); if ($ret < 0) dol_print_error($db); $langs->load("propal"); print ''; } // Customer orders - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $nblines++; - $ret=$product->load_stats_commande($socid); + $ret = $product->load_stats_commande($socid); if ($ret < 0) dol_print_error($db); $langs->load("orders"); print ''; } // Supplier orders - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { $nblines++; - $ret=$product->load_stats_commande_fournisseur($socid); + $ret = $product->load_stats_commande_fournisseur($socid); if ($ret < 0) dol_print_error($db); $langs->load("orders"); print ''; } // Customer invoices - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $nblines++; - $ret=$product->load_stats_facture($socid); + $ret = $product->load_stats_facture($socid); if ($ret < 0) dol_print_error($db); $langs->load("bills"); print ''; } // Supplier invoices - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { $nblines++; - $ret=$product->load_stats_facture_fournisseur($socid); + $ret = $product->load_stats_facture_fournisseur($socid); if ($ret < 0) dol_print_error($db); $langs->load("bills"); print '"; // Project status print '"; } @@ -494,7 +494,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print "'; - $plannedworkloadoutputformat='allhourmin'; - $timespentoutputformat='allhourmin'; - if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; - if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; + $plannedworkloadoutputformat = 'allhourmin'; + $timespentoutputformat = 'allhourmin'; + if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; + if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; // Planned Workload (in working hours) print '\n"; - if (! $showlineingray) $inc++; + if (!$showlineingray) $inc++; if ($level >= 0) // Call sublevels { @@ -662,7 +662,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); print ''; print ''; @@ -719,7 +719,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; } // Contacts of task - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { print ''; } @@ -1169,11 +1169,11 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr // Ref print '\n"; - $disabledproject=1;$disabledtask=1; + $disabledproject = 1; $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { - $disabledproject=0; - $disabledtask=0; + $disabledproject = 0; + $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { - $disabledtask=1; + $disabledtask = 1; } // Form to add new time @@ -1392,7 +1392,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $obj = &$lines[$i]; // To display extrafields // If we want all or we have a role on task, we show it - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) { //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); @@ -1530,7 +1530,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ */ // Project - if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) + if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { print '\n"; - $disabledproject=1;$disabledtask=1; + $disabledproject = 1; $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { - $disabledproject=0; - $disabledtask=0; + $disabledproject = 0; + $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { - $disabledtask=1; + $disabledtask = 1; } //var_dump($projectstatic->weekWorkLoadPerTask); @@ -1686,9 +1686,9 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields); //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); //var_dump($ret); - foreach($ret as $key => $val) + foreach ($ret as $key => $val) { - $totalforeachday[$key]+=$val; + $totalforeachday[$key] += $val; } //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); //var_dump($totalforeachday); @@ -1717,8 +1717,8 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) { //print 'Search in line with parent id = '.$parent.'
        '; - $numlines=count($lines); - for ($i = 0 ; $i < $numlines ; $i++) + $numlines = count($lines); + for ($i = 0; $i < $numlines; $i++) { // Process line $lines[$i] if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) @@ -1811,40 +1811,40 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks { $project_year_filter = date("Y"); } - $sql.= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")"; - $sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")"; + $sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")"; + $sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")"; } } // Get id of project we must show tasks - $arrayidofprojects=array(); + $arrayidofprojects = array(); $sql1 = "SELECT p.rowid as projectid"; - $sql1.= $sql; + $sql1 .= $sql; $resql = $db->query($sql1); if ($resql) { - $i=0; + $i = 0; $num = $db->num_rows($resql); while ($i < $num) { $objp = $db->fetch_object($resql); - $arrayidofprojects[$objp->projectid]=$objp->projectid; + $arrayidofprojects[$objp->projectid] = $objp->projectid; $i++; } } else dol_print_error($db); - if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1; + if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1; // Get list of project with calculation on tasks $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,"; - $sql2.= " p.dateo, p.datee,"; - $sql2.= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; - $sql2.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; - $sql2.= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")"; - $sql2.= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee"; - $sql2.= " ORDER BY p.title, p.ref"; + $sql2 .= " p.dateo, p.datee,"; + $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; + $sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")"; + $sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee"; + $sql2 .= " ORDER BY p.title, p.ref"; $resql = $db->query($sql2); if ($resql) @@ -1859,7 +1859,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print_liste_field_titre($title.''.$num.'', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre("OpportunityStatus", "", "", "", "", 'align="right"', $sortfield, $sortorder); @@ -1867,14 +1867,14 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks if (empty($conf->global->PROJECT_HIDE_TASKS)) { print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder); - if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder); - if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder); + if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder); + if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder); } print_liste_field_titre("Status", "", "", "", "", 'align="right"', $sortfield, $sortorder); print "\n"; - $total_plannedworkload=0; - $total_declaredprogressworkload=0; + $total_plannedworkload = 0; + $total_declaredprogressworkload = 0; while ($i < $num) { $objp = $db->fetch_object($resql); @@ -1887,7 +1887,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $userAccess = $projectstatic->restrictedProjectArea($user); if ($userAccess >= 0) { - $projectstatic->ref=$objp->ref; + $projectstatic->ref = $objp->ref; $projectstatic->statut = $objp->status; $projectstatic->title = $objp->title; $projectstatic->datee = $db->jdate($objp->datee); @@ -1897,18 +1897,18 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print ''; print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print ''; - $plannedworkload=$objp->planned_workload; - $total_plannedworkload+=$plannedworkload; - if (! in_array('plannedworkload', $hiddenfields)) + $plannedworkload = $objp->planned_workload; + $total_plannedworkload += $plannedworkload; + if (!in_array('plannedworkload', $hiddenfields)) { - print ''; + print ''; } - if (! in_array('declaredprogress', $hiddenfields)) + if (!in_array('declaredprogress', $hiddenfields)) { - $declaredprogressworkload=$objp->declared_progess_workload; - $total_declaredprogressworkload+=$declaredprogressworkload; + $declaredprogressworkload = $objp->declared_progess_workload; + $total_declaredprogressworkload += $declaredprogressworkload; print ''; } } @@ -1952,7 +1952,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print '"; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print ''; print ''; @@ -1960,8 +1960,8 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks if (empty($conf->global->PROJECT_HIDE_TASKS)) { print ''; - if (! in_array('plannedworkload', $hiddenfields)) print ''; - if (! in_array('declaredprogress', $hiddenfields)) print ''; + if (!in_array('plannedworkload', $hiddenfields)) print ''; + if (!in_array('declaredprogress', $hiddenfields)) print ''; } print ''; print ''; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 542a02dffeb..02c5cf8dcf7 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -77,8 +77,8 @@ function dolKeepOnlyPhpCode($str) $parts = explode('fetch(0, $website->id, '', $containeraliasalt); if ($result > 0) { @@ -426,10 +426,10 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri if (defined('USEDOLIBARRSERVER')) // When page called from Dolibarr server { // Check new container exists - if (! $containeraliasalt) // If containeraliasalt set, we already did the test + if (!$containeraliasalt) // If containeraliasalt set, we already did the test { include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; - $tmpwebsitepage=new WebsitePage($db); + $tmpwebsitepage = new WebsitePage($db); $result = $tmpwebsitepage->fetch(0, $website->id, $containerref); unset($tmpwebsitepage); } @@ -503,14 +503,14 @@ function includeContainer($containerref) //print preg_replace(array('/^.*]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/ ob_start(); - $res = include $fullpathfile; // Include because we want to execute code content + $res = include $fullpathfile; // Include because we want to execute code content $tmpoutput = ob_get_contents(); ob_end_clean(); print "\n".''."\n"; - print preg_replace(array('/^.*]*>/ims','/<\/body>.*$/ims'), array('', ''), $tmpoutput); + print preg_replace(array('/^.*]*>/ims', '/<\/body>.*$/ims'), array('', ''), $tmpoutput); - if (! $res) + if (!$res) { print 'ERROR: FAILED TO INCLUDE PAGE '.$containerref.".\n"; } @@ -803,45 +803,45 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify { global $conf; - $error=0; + $error = 0; dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto); - $alreadygrabbed=array(); + $alreadygrabbed = array(); - if (preg_match('/\/$/', $urltograb)) $urltograb.='.'; - $urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1 + if (preg_match('/\/$/', $urltograb)) $urltograb .= '.'; + $urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1 // Search X in "img...src=X" preg_match_all('/]*)>/i', $tmp, $regs); foreach ($regs[0] as $key => $val) { - if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images + if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images if (preg_match('/^\//', $regs[2][$key])) { $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb); - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot } else { - $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file + $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file } $linkwithoutdomain = $regs[2][$key]; $dirforimages = '/'.$objectpage->pageurl; - if ($grabimagesinto == 'root') $dirforimages=''; + if ($grabimagesinto == 'root') $dirforimages = ''; // Define $filetosave and $filename - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key]) ? '' : '/').$regs[2][$key]; if (preg_match('/^http/', $regs[2][$key])) { $urltograbbis = $regs[2][$key]; $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain; } - $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain; // Clean the aa/bb/../cc into aa/cc $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); @@ -860,24 +860,24 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify { $error++; setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); - $action='create'; + $action = 'create'; } elseif ($tmpgeturl['http_code'] != '200') { $error++; setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); - $action='create'; + $action = 'create'; } else { - $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. + $alreadygrabbed[$urltograbbis] = 1; // Track that file was alreay grabbed. dol_mkdir(dirname($filetosave)); $fp = fopen($filetosave, "w"); fputs($fp, $tmpgeturl['content']); fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); } } @@ -894,33 +894,33 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify foreach ($regs[0] as $key => $val) { - if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images + if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images if (preg_match('/^\//', $regs[2][$key])) { $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb); - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot } else { - $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file + $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file } $linkwithoutdomain = $regs[2][$key]; $dirforimages = '/'.$objectpage->pageurl; - if ($grabimagesinto == 'root') $dirforimages=''; + if ($grabimagesinto == 'root') $dirforimages = ''; - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key]) ? '' : '/').$regs[2][$key]; if (preg_match('/^http/', $regs[2][$key])) { $urltograbbis = $regs[2][$key]; $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain; } - $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain; // Clean the aa/bb/../cc into aa/cc $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); @@ -939,24 +939,24 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify { $error++; setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); - $action='create'; + $action = 'create'; } elseif ($tmpgeturl['http_code'] != '200') { $error++; setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); - $action='create'; + $action = 'create'; } else { - $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. + $alreadygrabbed[$urltograbbis] = 1; // Track that file was alreay grabbed. dol_mkdir(dirname($filetosave)); $fp = fopen($filetosave, "w"); fputs($fp, $tmpgeturl['content']); fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); } } diff --git a/htdocs/core/login/functions_googleoauth.php b/htdocs/core/login/functions_googleoauth.php index 9defe57c3f1..2f1fbcf3667 100644 --- a/htdocs/core/login/functions_googleoauth.php +++ b/htdocs/core/login/functions_googleoauth.php @@ -41,11 +41,11 @@ */ function check_user_password_googleoauth($usertotest, $passwordtotest, $entitytotest) { - global $_POST,$db,$conf,$langs; + global $_POST, $db, $conf, $langs; dol_syslog("functions_googleoauth::check_user_password_googleoauth usertotest=".$usertotest); - $login=''; + $login = ''; // Get identity from user and redirect browser to Google OAuth Server if (isset($_POST['username'])) diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 6819ab864b3..cc8a2d42ce5 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -179,7 +179,7 @@ function print_start_menu_array_auguria() global $conf; print '
        '; - print '
        '; print ''; print ''; print ''; if (empty($conf->productbatch->enabled)) print ' '; //else print '
        '; - $syear = $year?$year:-1; + $syear = $year ? $year : -1; print ''; //print $formother->selectyear($syear,'year',1, 20, 5); print '
        '; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; //print ''; print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print ''; print ''; print ''; print ''; print ''; print ''; print ''; //print ''; print ''; print ajax_combobox('search_type_mouvement'); // TODO: add new function $formentrepot->selectTypeOfMovement(...) like // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print ''; print '  '; print ''; print ''; print ''; print '  '; print ''; @@ -870,76 +870,76 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['m.datec']['checked'])) + if (!empty($arrayfields['m.datec']['checked'])) { print ''; print ''; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
        '.$objp->mid.''.$objp->mid.''.dol_print_date($db->jdate($objp->datem), 'dayhour').''; print $productstatic->getNomUrl(1, 'stock', 16); print "'; @@ -1028,36 +1028,36 @@ if ($resql) print $productstatic->label; print "'; if ($productlot->id > 0) print $productlot->getNomUrl(1); - else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. print ''. dol_print_date($objp->eatby, 'day') .''.dol_print_date($objp->eatby, 'day').''. dol_print_date($objp->sellby, 'day') .''.dol_print_date($objp->sellby, 'day').''; print $warehousestatic->getNomUrl(1); print "'; print $userstatic->getNomUrl(-1); print "'.''.$objp->label.''.$langs->trans('StockIncreaseAfterCorrectTransfer').''.$origin.''; @@ -1106,14 +1106,14 @@ if ($resql) print $objp->qty; print ''; if ($objp->price != 0) print price($objp->price); print ''; @@ -1124,12 +1124,12 @@ if ($resql) print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
        '; print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt')); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 77dcaa641d2..fffab036d2d 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -115,9 +115,9 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Definition of fields for list -$arrayfields=array(); -$arrayfields['t.planned_workload']=array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); -$arrayfields['t.progress']=array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields = array(); +$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); /*$arrayfields=array( // Project 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), @@ -130,17 +130,17 @@ $arrayfields['t.progress']=array('label'=>'ProgressDeclared', 'checked'=>1, 'ena // Extra fields 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 => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["efpt.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["efpt.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $arrayfields = dol_sort_array($arrayfields, 'position'); -$search_array_options_project=$extrafields->getOptionalsFromPost($project->table_element, '', 'search_'); -$search_array_options_task=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_task_'); +$search_array_options_project = $extrafields->getOptionalsFromPost($project->table_element, '', 'search_'); +$search_array_options_task = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_task_'); /* @@ -151,7 +151,7 @@ $search_array_options_task=$extrafields->getOptionalsFromPost($object->table_ele 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 { $action = ''; - $search_categ=''; + $search_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -163,7 +163,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_array_options_task = array(); // We redefine $usertoprocess - $usertoprocess=$user; + $usertoprocess = $user; } if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) { @@ -196,35 +196,35 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors'); $error++; } - if (! GETPOST('type')) + if (!GETPOST('type')) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } - if (! $error) + if (!$error) { - $idfortaskuser=$usertoprocess->id; + $idfortaskuser = $usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); if ($result >= 0 || $result == -2) // Contact add ok or already contact of task { // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) - $sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; - $sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; - $resql=$db->query($sql); + $sql = 'SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; + $sql .= ' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); - if (! $obj) // User is not already linked to project, so we will create link to first type + $obj = $db->fetch_object($resql); + if (!$obj) // User is not already linked to project, so we will create link to first type { $project = new Project($db); $project->fetch($object->fk_project); // Get type - $listofprojcontact=$project->liste_type_contact('internal'); + $listofprojcontact = $project->liste_type_contact('internal'); if (count($listofprojcontact)) { - $typeforprojectcontact=reset(array_keys($listofprojcontact)); + $typeforprojectcontact = reset(array_keys($listofprojcontact)); $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal'); } } @@ -250,22 +250,22 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if (! $error) + if (!$error) { setEventMessages("TaskAssignedToEnterTime", null); - $taskid=0; + $taskid = 0; } - $action=''; + $action = ''; } if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { - $timespent_duration=array(); + $timespent_duration = array(); if (is_array($_POST)) { - foreach($_POST as $key => $time) + foreach ($_POST as $key => $time) { if (intval($time) > 0) { @@ -276,10 +276,10 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac if ($id > 0) { // We store HOURS in seconds - if($matches[2]=='hour') $timespent_duration[$id] += $time*60*60; + if ($matches[2] == 'hour') $timespent_duration[$id] += $time * 60 * 60; // We store MINUTES in seconds - if($matches[2]=='min') $timespent_duration[$id] += $time*60; + if ($matches[2] == 'min') $timespent_duration[$id] += $time * 60; } } } @@ -288,11 +288,11 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac if (count($timespent_duration) > 0) { - foreach($timespent_duration as $key => $val) + foreach ($timespent_duration as $key => $val) { $object->fetch($key); - if (GETPOSTISSET($taskid . 'progress')) $object->progress = GETPOST($taskid . 'progress', 'int'); + if (GETPOSTISSET($taskid.'progress')) $object->progress = GETPOST($taskid.'progress', 'int'); else unset($object->progress); $object->timespent_duration = $val; @@ -311,7 +311,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac if ($object->timespent_date > 0) { - $result=$object->addTimeSpent($user); + $result = $object->addTimeSpent($user); } else { @@ -328,12 +328,12 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); // Redirect to avoid submit twice on back - header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday); + header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid ? 'id='.$projectid : '').($search_usertoprocessid ? '&search_usertoprocessid='.$search_usertoprocessid : '').($mode ? '&mode='.$mode : '').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday); exit; } } @@ -349,11 +349,11 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac * View */ -$form=new Form($db); +$form = new Form($db); $formother = new FormOther($db); -$formcompany=new FormCompany($db); -$formproject=new FormProjets($db); -$projectstatic=new Project($db); +$formcompany = new FormCompany($db); +$formproject = new FormProjets($db); +$projectstatic = new Project($db); $project = new Project($db); $taskstatic = new Task($db); $thirdpartystatic = new Societe($db); @@ -369,9 +369,9 @@ $next_year = $next['year']; $next_month = $next['mon']; $next_day = $next['mday']; -$title=$langs->trans("TimeSpent"); +$title = $langs->trans("TimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id)?2:0), 1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project if ($id) { @@ -379,14 +379,14 @@ if ($id) $project->fetch_thirdparty(); } -$onlyopenedproject=1; // or -1 -$morewherefilter=''; +$onlyopenedproject = 1; // or -1 +$morewherefilter = ''; -if ($search_project_ref) $morewherefilter.=natural_search(array("p.ref", "p.title"), $search_project_ref); -if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); -if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label"), $search_task_label); -if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); -if ($search_declared_progress) $morewherefilter.=natural_search("t.progress", $search_declared_progress, 1); +if ($search_project_ref) $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); +if ($search_task_ref) $morewherefilter .= natural_search("t.ref", $search_task_ref); +if ($search_task_label) $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); +if ($search_thirdparty) $morewherefilter .= natural_search("s.nom", $search_thirdparty); +if ($search_declared_progress) $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); $sql = &$morewherefilter; @@ -397,18 +397,18 @@ $extrafieldsobjectkey='projet'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; */ $search_array_options = $search_array_options_task; -$extrafieldsobjectprefix='efpt.'; -$search_options_pattern='search_task_options_'; -$extrafieldsobjectkey='projet_task'; +$extrafieldsobjectprefix = 'efpt.'; +$search_options_pattern = 'search_task_options_'; +$extrafieldsobjectkey = 'projet_task'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0), 0, $extrafields); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +$tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks { - $tasksarraywithoutfilter=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. + $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } -$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); -$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); +$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject); +$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject); //var_dump($usertoprocess); //var_dump($projectsrole); //var_dump($taskrole); @@ -417,33 +417,33 @@ llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js')); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'project'); -$param=''; -$param.=($mode?'&mode='.urlencode($mode):''); -$param.=($search_project_ref?'&search_project_ref='.urlencode($search_project_ref):''); -$param.=($search_usertoprocessid?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); -$param.=($search_thirdparty?'&search_thirdparty='.urlencode($search_thirdparty):''); -$param.=($search_task_ref?'&search_task_ref='.urlencode($search_task_ref):''); -$param.=($search_task_label?'&search_task_label='.urlencode($search_task_label):''); +$param = ''; +$param .= ($mode ? '&mode='.urlencode($mode) : ''); +$param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : ''); +$param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); +$param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : ''); +$param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : ''); +$param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); /*$search_array_options=$search_array_options_project; $search_options_pattern='search_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ -$search_array_options=$search_array_options_task; -$search_options_pattern='search_task_options_'; +$search_array_options = $search_array_options_task; +$search_options_pattern = 'search_task_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Show navigation bar -$nav =''.img_previous($langs->trans("Previous"))."\n"; -$nav.=dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "%A").' '; -$nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "day")." \n"; -$nav.=''.img_next($langs->trans("Next"))."\n"; -$nav.="   (".$langs->trans("Today").")"; -$nav.='
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; -$nav.=' '; +$nav = ''.img_previous($langs->trans("Previous"))."\n"; +$nav .= dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "%A").' '; +$nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "day")." \n"; +$nav .= ''.img_next($langs->trans("Next"))."\n"; +$nav .= "   (".$langs->trans("Today").")"; +$nav .= '
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; +$nav .= ' '; -$picto='calendarweek'; +$picto = 'calendarweek'; print 'id > 0 ? '?id='.$project->id : '').'">'; print ''; @@ -456,18 +456,18 @@ print ''; print ''; print ''; -$head=project_timesheet_prepare_head($mode, $usertoprocess); +$head = project_timesheet_prepare_head($mode, $usertoprocess); dol_fiche_head($head, 'inputperday', $langs->trans('TimeSpent'), -1, 'task'); // Show description of content print '
        '; -if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; else { if (empty($usertoprocess->id) || $usertoprocess->id < 0) { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; - else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; + if ($user->rights->projet->all->lire && !$socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; + else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; } } if ($mine || ($usertoprocess->id == $user->id)) @@ -482,13 +482,13 @@ print '
        '; dol_fiche_end(); -print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. +print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. print '
        '; $titleassigntask = $langs->transnoentities("AssignTaskToMe"); if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); print '
        '; -$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); +$formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); print '
        '; print ' '; print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); @@ -498,7 +498,7 @@ print '
        '; print '
        '; -$moreforfilter=''; +$moreforfilter = ''; // Filter on categories /*if (! empty($conf->categorie->enabled)) @@ -511,66 +511,66 @@ $moreforfilter=''; }*/ // If the user can view user other than himself -$moreforfilter.='
        '; -$moreforfilter.='
        '.$langs->trans('User'). '
        '; -$includeonly='hierarchyme'; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200 marginleftonly'); -$moreforfilter.='
        '; +$moreforfilter .= '
        '; +$moreforfilter .= '
        '.$langs->trans('User').'
        '; +$includeonly = 'hierarchyme'; +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200 marginleftonly'); +$moreforfilter .= '
        '; if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { - $moreforfilter.='
        '; - $moreforfilter.='
        '.$langs->trans('Project'). '
        '; - $moreforfilter.=''; - $moreforfilter.='
        '; + $moreforfilter .= '
        '; + $moreforfilter .= '
        '.$langs->trans('Project').'
        '; + $moreforfilter .= ''; + $moreforfilter .= '
        '; - $moreforfilter.='
        '; - $moreforfilter.='
        '.$langs->trans('ThirdParty'). '
        '; - $moreforfilter.=''; - $moreforfilter.='
        '; + $moreforfilter .= '
        '; + $moreforfilter .= '
        '.$langs->trans('ThirdParty').'
        '; + $moreforfilter .= ''; + $moreforfilter .= '
        '; } -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
        '; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
        '; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields // This must be after the $selectedfields -$addcolspan=0; -if (! empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; -if (! empty($arrayfields['t.progress']['checked'])) $addcolspan++; +$addcolspan = 0; +if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; +if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++; foreach ($arrayfields as $key => $val) { if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++; } print '
        '; -print ''."\n"; +print '
        '."\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; // TASK fields -$search_options_pattern='search_task_options_'; -$extrafieldsobjectkey='projet_task'; -$extrafieldsobjectprefix='efpt.'; +$search_options_pattern = 'search_task_options_'; +$extrafieldsobjectkey = 'projet_task'; +$extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; print ''; -if (! empty($arrayfields['t.planned_workload']['checked'])) +if (!empty($arrayfields['t.planned_workload']['checked'])) { print ''; } -if (! empty($arrayfields['t.progress']['checked'])) +if (!empty($arrayfields['t.progress']['checked'])) { print ''; } @@ -580,24 +580,24 @@ print ''; print ''; // Action column print ''; print "\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; // TASK fields -$extrafieldsobjectkey='projet_task'; -$extrafieldsobjectprefix='efpt.'; +$extrafieldsobjectkey = 'projet_task'; +$extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; -if (! empty($arrayfields['t.planned_workload']['checked'])) +if (!empty($arrayfields['t.planned_workload']['checked'])) { print ''; } -if (! empty($arrayfields['t.progress']['checked'])) +if (!empty($arrayfields['t.progress']['checked'])) { print ''; } @@ -605,17 +605,17 @@ if (! empty($arrayfields['t.progress']['checked'])) if ($usertoprocess->id == $user->id) print ''; else print '';*/ print ''; -print ''; +print ''; print ''; +print ''; print ''; //print ''; print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; -$colspan=4+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2); +$colspan = 4 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); if ($conf->use_javascript_ajax) { print ''; - print ''; print ''; - $tmparray = dol_getdate($daytoparse, true); // detail of current day + $tmparray = dol_getdate($daytoparse, true); // detail of current day $idw = $tmparray['wday']; - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - $cssonholiday=''; - if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$daytoparse]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayafternoon '; - print ''; + print ''; print ''; print ''; @@ -690,32 +690,32 @@ if (count($tasksarray) > 0) //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter) //var_dump($tasksrole); - $j=0; - $level=0; + $j = 0; + $level = 0; $totalforvisibletasks = projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse, $isavailable, 0, $arrayfields, $extrafields); //var_dump($totalforvisibletasks); // Show total for all other tasks // Calculate total for all tasks - $listofdistinctprojectid=array(); // List of all distinct projects + $listofdistinctprojectid = array(); // List of all distinct projects if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { - foreach($tasksarraywithoutfilter as $tmptask) + foreach ($tasksarraywithoutfilter as $tmptask) { - $listofdistinctprojectid[$tmptask->fk_project]=$tmptask->fk_project; + $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project; } } //var_dump($listofdistinctprojectid); - $totalforeachday=array(); - foreach($listofdistinctprojectid as $tmpprojectid) + $totalforeachday = array(); + foreach ($listofdistinctprojectid as $tmpprojectid) { - $projectstatic->id=$tmpprojectid; - $projectstatic->loadTimeSpent($daytoparse, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week + $projectstatic->id = $tmpprojectid; + $projectstatic->loadTimeSpent($daytoparse, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week for ($idw = 0; $idw < 7; $idw++) { - $tmpday=dol_time_plus_duree($daytoparse, $idw, 'd'); - $totalforeachday[$tmpday]+=$projectstatic->weekWorkLoad[$tmpday]; + $tmpday = dol_time_plus_duree($daytoparse, $idw, 'd'); + $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday]; } } //var_dump($totalforeachday); @@ -724,10 +724,10 @@ if (count($tasksarray) > 0) $isdiff = 0; if (count($totalforeachday)) { - $timeonothertasks=($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); + $timeonothertasks = ($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); if ($timeonothertasks) { - $isdiff=1; + $isdiff = 1; } } @@ -735,12 +735,12 @@ if (count($tasksarray) > 0) if ($isdiff) { print ''; - print ''; print ''; print ''; print ''; - $tmparray = dol_getdate($daytoparse, true); // detail of current day + $tmparray = dol_getdate($daytoparse, true); // detail of current day $idw = $tmparray['wday']; - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - $cssonholiday=''; - if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$daytoparse]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayafternoon '; - print ''; + print ''; print ' @@ -794,12 +794,12 @@ print ''; print ''."\n"; print '
        '; -print ''; +print ''; print '
        '; print ''; -$modeinput='hours'; +$modeinput = 'hours'; if ($conf->use_javascript_ajax) { diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 8af733394bf..535f8e17522 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -97,26 +97,26 @@ $next_month = $next['month']; $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) -$firstdaytoshow=dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); -$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); +$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); +$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { - $usertoprocess=$user; - $search_usertoprocessid=$usertoprocess->id; + $usertoprocess = $user; + $search_usertoprocessid = $usertoprocess->id; } elseif ($search_usertoprocessid > 0) { - $usertoprocess=new User($db); + $usertoprocess = new User($db); $usertoprocess->fetch($search_usertoprocessid); - $search_usertoprocessid=$usertoprocess->id; + $search_usertoprocessid = $usertoprocess->id; } else { - $usertoprocess=new User($db); + $usertoprocess = new User($db); } -$object=new Task($db); +$object = new Task($db); // Extra fields $extrafields = new ExtraFields($db); @@ -125,7 +125,7 @@ $extrafields = new ExtraFields($db); //$extrafields->fetch_name_optionals_label('projet'); $extrafields->fetch_name_optionals_label('projet_task'); -$arrayfields=array(); +$arrayfields = array(); /*$arrayfields=array( // Project 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), @@ -134,8 +134,8 @@ $arrayfields=array(); 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115), );*/ -$arrayfields['t.planned_workload']=array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); -$arrayfields['t.progress']=array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); /*foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field @@ -145,17 +145,17 @@ $arrayfields['t.progress']=array('label'=>'ProgressDeclared', 'checked'=>1, 'ena // Extra fields if (is_array($extrafields->attributes['projet_task']['label']) && count($extrafields->attributes['projet_task']['label']) > 0) { - foreach($extrafields->attributes['projet_task']['label'] as $key => $val) + foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { - if (! empty($extrafields->attributes['projet_task']['list'][$key])) - $arrayfields["efpt.".$key]=array('label'=>$extrafields->attributes['projet_task']['label'][$key], 'checked'=>(($extrafields->attributes['projet_task']['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes['projet_task']['pos'][$key], 'enabled'=>(abs($extrafields->attributes['projet_task']['list'][$key])!=3 && $extrafields->attributes['projet_task']['perms'][$key])); + if (!empty($extrafields->attributes['projet_task']['list'][$key])) + $arrayfields["efpt.".$key] = array('label'=>$extrafields->attributes['projet_task']['label'][$key], 'checked'=>(($extrafields->attributes['projet_task']['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes['projet_task']['pos'][$key], 'enabled'=>(abs($extrafields->attributes['projet_task']['list'][$key]) != 3 && $extrafields->attributes['projet_task']['perms'][$key])); } } $arrayfields = dol_sort_array($arrayfields, 'position'); -$search_array_options=array(); -$search_array_options_project=$extrafields->getOptionalsFromPost('projet', '', 'search_'); -$search_array_options_task=$extrafields->getOptionalsFromPost('projet_task', '', 'search_task_'); +$search_array_options = array(); +$search_array_options_project = $extrafields->getOptionalsFromPost('projet', '', 'search_'); +$search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', '', 'search_task_'); @@ -167,7 +167,7 @@ $search_array_options_task=$extrafields->getOptionalsFromPost('projet_task', '', 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 { $action = ''; - $search_categ=''; + $search_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -179,7 +179,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_array_options_task = array(); // We redefine $usertoprocess - $usertoprocess=$user; + $usertoprocess = $user; } if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) { @@ -209,36 +209,36 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors'); $error++; } - if (! GETPOST('type')) + if (!GETPOST('type')) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } - if (! $error) + if (!$error) { - $idfortaskuser=$usertoprocess->id; + $idfortaskuser = $usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); if ($result >= 0 || $result == -2) // Contact add ok or already contact of task { // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) - $sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; - $sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; - $resql=$db->query($sql); + $sql = 'SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; + $sql .= ' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); - if (! $obj) // User is not already linked to project, so we will create link to first type + $obj = $db->fetch_object($resql); + if (!$obj) // User is not already linked to project, so we will create link to first type { $project = new Project($db); $project->fetch($object->fk_project); // Get type - $listofprojcontact=$project->liste_type_contact('internal'); + $listofprojcontact = $project->liste_type_contact('internal'); if (count($listofprojcontact)) { - $typeforprojectcontact=reset(array_keys($listofprojcontact)); + $typeforprojectcontact = reset(array_keys($listofprojcontact)); $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal'); } } @@ -264,43 +264,43 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if (! $error) + if (!$error) { setEventMessages("TaskAssignedToEnterTime", null); - $taskid=0; + $taskid = 0; } - $action=''; + $action = ''; } if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { - $timetoadd=$_POST['task']; + $timetoadd = $_POST['task']; if (empty($timetoadd)) { setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); } else { - foreach($timetoadd as $taskid => $value) // Loop on each task + foreach ($timetoadd as $taskid => $value) // Loop on each task { - $updateoftaskdone=0; - foreach($value as $key => $val) // Loop on each day + $updateoftaskdone = 0; + foreach ($value as $key => $val) // Loop on each day { - $amountoadd=$timetoadd[$taskid][$key]; - if (! empty($amountoadd)) + $amountoadd = $timetoadd[$taskid][$key]; + if (!empty($amountoadd)) { - $tmpduration=explode(':', $amountoadd); - $newduration=0; - if (! empty($tmpduration[0])) $newduration+=($tmpduration[0] * 3600); - if (! empty($tmpduration[1])) $newduration+=($tmpduration[1] * 60); - if (! empty($tmpduration[2])) $newduration+=($tmpduration[2]); + $tmpduration = explode(':', $amountoadd); + $newduration = 0; + if (!empty($tmpduration[0])) $newduration += ($tmpduration[0] * 3600); + if (!empty($tmpduration[1])) $newduration += ($tmpduration[1] * 60); + if (!empty($tmpduration[2])) $newduration += ($tmpduration[2]); if ($newduration > 0) { $object->fetch($taskid); - if (GETPOSTISSET($taskid . 'progress')) $object->progress = GETPOST($taskid . 'progress', 'int'); + if (GETPOSTISSET($taskid.'progress')) $object->progress = GETPOST($taskid.'progress', 'int'); else unset($object->progress); $object->timespent_duration = $newduration; @@ -308,7 +308,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac $object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd'); $object->timespent_datehour = $object->timespent_date; - $result=$object->addTimeSpent($user); + $result = $object->addTimeSpent($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -321,14 +321,14 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } } - if (! $updateoftaskdone) // Check to update progress if no update were done on task. + if (!$updateoftaskdone) // Check to update progress if no update were done on task. { $object->fetch($taskid); //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit; - if ($object->progress != GETPOST($taskid . 'progress', 'int')) + if ($object->progress != GETPOST($taskid.'progress', 'int')) { - $object->progress = GETPOST($taskid . 'progress', 'int'); - $result=$object->update($user); + $object->progress = GETPOST($taskid.'progress', 'int'); + $result = $object->update($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -339,29 +339,29 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $param=''; - $param.=($mode?'&mode='.urlencode($mode):''); - $param.=($projectid?'id='.urlencode($projectid):''); - $param.=($search_usertoprocessid?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); - $param.=($day?'&day='.urlencode($day):'').($month?'&month='.urlencode($month):'').($year?'&year='.urlencode($year):''); - $param.=($search_project_ref?'&search_project_ref='.urlencode($search_project_ref):''); - $param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); - $param.=($search_thirdparty?'&search_thirdparty='.urlencode($search_thirdparty):''); - $param.=($search_declared_progress?'&search_declared_progress='.urlencode($search_declared_progress):''); - $param.=($search_task_ref?'&search_task_ref='.urlencode($search_task_ref):''); - $param.=($search_task_label?'&search_task_label='.urlencode($search_task_label):''); + $param = ''; + $param .= ($mode ? '&mode='.urlencode($mode) : ''); + $param .= ($projectid ? 'id='.urlencode($projectid) : ''); + $param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); + $param .= ($day ? '&day='.urlencode($day) : '').($month ? '&month='.urlencode($month) : '').($year ? '&year='.urlencode($year) : ''); + $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : ''); + $param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); + $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : ''); + $param .= ($search_declared_progress ? '&search_declared_progress='.urlencode($search_declared_progress) : ''); + $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : ''); + $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); /*$search_array_options=$search_array_options_project; $search_options_pattern='search_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ - $search_array_options=$search_array_options_task; - $search_options_pattern='search_task_options_'; + $search_array_options = $search_array_options_task; + $search_options_pattern = 'search_task_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Redirect to avoid submit twice on back @@ -377,19 +377,19 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac * View */ -$form=new Form($db); -$formother=new FormOther($db); -$formcompany=new FormCompany($db); -$formproject=new FormProjets($db); -$projectstatic=new Project($db); +$form = new Form($db); +$formother = new FormOther($db); +$formcompany = new FormCompany($db); +$formproject = new FormProjets($db); +$projectstatic = new Project($db); $project = new Project($db); $taskstatic = new Task($db); $thirdpartystatic = new Societe($db); $holiday = new Holiday($db); -$title=$langs->trans("TimeSpent"); +$title = $langs->trans("TimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id)?2:0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project //var_dump($projectsListId); if ($id) { @@ -397,14 +397,14 @@ if ($id) $project->fetch_thirdparty(); } -$onlyopenedproject=1; // or -1 -$morewherefilter=''; +$onlyopenedproject = 1; // or -1 +$morewherefilter = ''; -if ($search_project_ref) $morewherefilter.=natural_search(array("p.ref", "p.title"), $search_project_ref); -if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); -if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label"), $search_task_label); -if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); -if ($search_declared_progress) $morewherefilter.=natural_search("t.progress", $search_declared_progress, 1); +if ($search_project_ref) $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); +if ($search_task_ref) $morewherefilter .= natural_search("t.ref", $search_task_ref); +if ($search_task_label) $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); +if ($search_thirdparty) $morewherefilter .= natural_search("s.nom", $search_thirdparty); +if ($search_declared_progress) $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); $sql = &$morewherefilter; @@ -415,18 +415,18 @@ $extrafieldsobjectkey='projet'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; */ $search_array_options = $search_array_options_task; -$extrafieldsobjectprefix='efpt.'; -$search_options_pattern='search_task_options_'; -$extrafieldsobjectkey='projet_task'; +$extrafieldsobjectprefix = 'efpt.'; +$search_options_pattern = 'search_task_options_'; +$extrafieldsobjectkey = 'projet_task'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +$tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks { - $tasksarraywithoutfilter=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. + $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } -$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); -$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); +$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject); +$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject); //var_dump($tasksarray); //var_dump($projectsrole); //var_dump($taskrole); @@ -436,31 +436,31 @@ llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js')); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'project'); -$param=''; -$param.=($mode?'&mode='.urlencode($mode):''); -$param.=($search_project_ref?'&search_project_ref='.urlencode($search_project_ref):''); -$param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); -$param.=($search_thirdparty?'&search_thirdparty='.urlencode($search_thirdparty):''); -$param.=($search_task_ref?'&search_task_ref='.urlencode($search_task_ref):''); -$param.=($search_task_label?'&search_task_label='.urlencode($search_task_label):''); +$param = ''; +$param .= ($mode ? '&mode='.urlencode($mode) : ''); +$param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : ''); +$param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); +$param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : ''); +$param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : ''); +$param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); -$search_array_options=$search_array_options_project; -$search_options_pattern='search_options_'; +$search_array_options = $search_array_options_project; +$search_options_pattern = 'search_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -$search_array_options=$search_array_options_task; -$search_options_pattern='search_task_options_'; +$search_array_options = $search_array_options_task; +$search_options_pattern = 'search_task_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Show navigation bar -$nav =''.img_previous($langs->trans("Previous"))."\n"; -$nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; -$nav.=''.img_next($langs->trans("Next"))."\n"; -$nav.="   (".$langs->trans("Today").")"; -$nav.='
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; -$nav.=' '; +$nav = ''.img_previous($langs->trans("Previous"))."\n"; +$nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; +$nav .= ''.img_next($langs->trans("Next"))."\n"; +$nav .= "   (".$langs->trans("Today").")"; +$nav .= '
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; +$nav .= ' '; -$picto='calendarweek'; +$picto = 'calendarweek'; print ''; print ''; @@ -472,18 +472,18 @@ print ''; print ''; print ''; -$head=project_timesheet_prepare_head($mode, $usertoprocess); +$head = project_timesheet_prepare_head($mode, $usertoprocess); dol_fiche_head($head, 'inputperweek', $langs->trans('TimeSpent'), -1, 'task'); // Show description of content print '
        '; -if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; else { if (empty($usertoprocess->id) || $usertoprocess->id < 0) { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; - else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; + if ($user->rights->projet->all->lire && !$socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; + else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; } } if ($mine || ($usertoprocess->id == $user->id)) @@ -498,13 +498,13 @@ print '
        '; dol_fiche_end(); -print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. +print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. print '
        '; $titleassigntask = $langs->transnoentities("AssignTaskToMe"); if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); print '
        '; -$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); +$formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); print '
        '; print ' '; print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); @@ -514,13 +514,13 @@ print '
        '; print '
        '; -$startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); +$startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); // Get if user is available or not for each day -$isavailable=array(); -if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) +$isavailable = array(); +if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { - $tmparray=explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); + $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); if (count($tmparray) >= 2) { $numstartworkingday = $tmparray[0]; @@ -528,9 +528,9 @@ if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) } } -for ($idw=0; $idw<7; $idw++) +for ($idw = 0; $idw < 7; $idw++) { - $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 + $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow @@ -543,11 +543,11 @@ for ($idw=0; $idw<7; $idw++) $statusofholidaytocheck = '3'; $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck); - $isavailable[$dayinloopfromfirstdaytoshow]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day + $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day } -$moreforfilter=''; +$moreforfilter = ''; // Filter on categories /* @@ -561,96 +561,96 @@ if (! empty($conf->categorie->enabled)) }*/ // If the user can view user other than himself -$moreforfilter.='
        '; -$moreforfilter.='
        '.$langs->trans('User'). '
        '; -$includeonly='hierarchyme'; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); -$moreforfilter.='
        '; +$moreforfilter .= '
        '; +$moreforfilter .= '
        '.$langs->trans('User').'
        '; +$includeonly = 'hierarchyme'; +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= '
        '; if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { - $moreforfilter.='
        '; - $moreforfilter.='
        '.$langs->trans('Project'). '
        '; - $moreforfilter.=''; - $moreforfilter.='
        '; + $moreforfilter .= '
        '; + $moreforfilter .= '
        '.$langs->trans('Project').'
        '; + $moreforfilter .= ''; + $moreforfilter .= '
        '; - $moreforfilter.='
        '; - $moreforfilter.='
        '.$langs->trans('ThirdParty'). '
        '; - $moreforfilter.=''; - $moreforfilter.='
        '; + $moreforfilter .= '
        '; + $moreforfilter .= '
        '.$langs->trans('ThirdParty').'
        '; + $moreforfilter .= ''; + $moreforfilter .= '
        '; } -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
        '; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
        '; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields // This must be after the $selectedfields -$addcolspan=0; -if (! empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; -if (! empty($arrayfields['t.progress']['checked'])) $addcolspan++; +$addcolspan = 0; +if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; +if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++; foreach ($arrayfields as $key => $val) { if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++; } print '
        '; -print '
        '; -$searchpicto=$form->showFilterAndCheckAddButtons(0); +$searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
        '.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Task").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
        ('.$langs->trans("Everybody").')
        '.$langs->trans("TimeSpent").($usertoprocess->firstname?'
        ('.dol_trunc($usertoprocess->firstname, 10).')':'').'
        '.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
        ('.dol_trunc($usertoprocess->firstname, 10).')' : '').'
        '.$langs->trans("HourStart").''; // By default, we can edit only tasks we are assigned to -$restrictviewformytask=((! isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); +$restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); // Get if user is available or not for each day -$isavailable=array(); -if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) +$isavailable = array(); +if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { - $tmparray=explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); + $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); if (count($tmparray) >= 2) { $numstartworkingday = $tmparray[0]; @@ -624,59 +624,59 @@ if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) } $statusofholidaytocheck = '3'; -$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck); // $daytoparse is a date with hours = 0 -$isavailable[$daytoparse]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day +$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck); // $daytoparse is a date with hours = 0 +$isavailable[$daytoparse] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day -$tmparray = dol_getdate($daytoparse, true); // detail of current day +$tmparray = dol_getdate($daytoparse, true); // detail of current day $idw = $tmparray['wday']; -$cssweekend=''; +$cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } -$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); +$tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); -$cssonholiday=''; -if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayallday '; -elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; -elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; +$cssonholiday = ''; +if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayallday '; +elseif (!$isavailable[$daytoparse]['morning']) $cssonholiday .= 'onholidaymorning '; +elseif (!$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayafternoon '; -print ''.$langs->trans("Duration").''.$langs->trans("Duration").''.$langs->trans("Note").'
        '; + print ''; print $langs->trans("Total"); print ''; //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print '
         
         
        '; + print ''; print $langs->trans("OtherFilteredTasks"); print ''; - $timeonothertasks=($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); + $timeonothertasks = ($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); //if ($timeonothertasks) //{ print ''; - print ''; + print ''; print $langs->trans("Total"); print ''; //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print '
         
         
        '."\n"; +print '
        '."\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; // TASK fields -$search_options_pattern='search_task_options_'; -$extrafieldsobjectkey='projet_task'; -$extrafieldsobjectprefix='efpt.'; +$search_options_pattern = 'search_task_options_'; +$extrafieldsobjectkey = 'projet_task'; +$extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; print ''; -if (! empty($arrayfields['t.planned_workload']['checked'])) +if (!empty($arrayfields['t.planned_workload']['checked'])) { print ''; } -if (! empty($arrayfields['t.progress']['checked'])) +if (!empty($arrayfields['t.progress']['checked'])) { print ''; } print ''; -for ($idw=0;$idw<7;$idw++) +for ($idw = 0; $idw < 7; $idw++) { print ''; } // Action column print ''; print "\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; // TASK fields -$extrafieldsobjectkey='projet_task'; -$extrafieldsobjectprefix='efpt.'; +$extrafieldsobjectkey = 'projet_task'; +$extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; -if (! empty($arrayfields['t.planned_workload']['checked'])) +if (!empty($arrayfields['t.planned_workload']['checked'])) { print ''; } -if (! empty($arrayfields['t.progress']['checked'])) +if (!empty($arrayfields['t.progress']['checked'])) { print ''; } @@ -658,27 +658,27 @@ if (! empty($arrayfields['t.progress']['checked'])) if ($usertoprocess->id == $user->id) print ''; else print '';*/ print ''; -print ''; +print ''; -for ($idw=0; $idw<7; $idw++) +for ($idw = 0; $idw < 7; $idw++) { - $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 + $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $cssonholiday=''; - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; - print ''; + print ''; } //print ''; print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -686,32 +686,32 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print "\n"; -$colspan=3+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2); +$colspan = 3 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); if ($conf->use_javascript_ajax) { print ''; - print ''; for ($idw = 0; $idw < 7; $idw++) { - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $cssonholiday=''; - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; - print ''; + print ''; } print ''; print ''; @@ -720,39 +720,39 @@ if ($conf->use_javascript_ajax) // By default, we can edit only tasks we are assigned to -$restrictviewformytask=((! isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); +$restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); if (count($tasksarray) > 0) { //var_dump($tasksarray); // contains only selected tasks //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter) //var_dump($tasksrole); - $j=0; - $level=0; + $j = 0; + $level = 0; $totalforvisibletasks = projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $arrayfields, $extrafields); //var_dump($totalforvisibletasks); // Show total for all other tasks // Calculate total for all tasks - $listofdistinctprojectid=array(); // List of all distinct projects + $listofdistinctprojectid = array(); // List of all distinct projects if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { - foreach($tasksarraywithoutfilter as $tmptask) + foreach ($tasksarraywithoutfilter as $tmptask) { - $listofdistinctprojectid[$tmptask->fk_project]=$tmptask->fk_project; + $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project; } } //var_dump($listofdistinctprojectid); - $totalforeachday=array(); - foreach($listofdistinctprojectid as $tmpprojectid) + $totalforeachday = array(); + foreach ($listofdistinctprojectid as $tmpprojectid) { - $projectstatic->id=$tmpprojectid; - $projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week + $projectstatic->id = $tmpprojectid; + $projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week for ($idw = 0; $idw < 7; $idw++) { - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $totalforeachday[$tmpday]+=$projectstatic->weekWorkLoad[$tmpday]; + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday]; } } @@ -765,11 +765,11 @@ if (count($tasksarray) > 0) { for ($idw = 0; $idw < 7; $idw++) { - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); if ($timeonothertasks) { - $isdiff=1; + $isdiff = 1; break; } } @@ -779,20 +779,20 @@ if (count($tasksarray) > 0) if ($isdiff) { print ''; - print ''; for ($idw = 0; $idw < 7; $idw++) { - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - print ''; // Categories - if($conf->categorie->enabled) { + if ($conf->categorie->enabled) { print '"; @@ -1095,11 +1095,11 @@ elseif ($object->id > 0) print ''; // Change probability from status - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Default value to close or not when we set opp to 'WON'. - $defaultcheckedwhenoppclose=1; - if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0; + $defaultcheckedwhenoppclose = 1; + if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose = 0; print ''; print ''; print ''."\n"; } -if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT) -|| ! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) +if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) +|| !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - $amount=0; - if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount=$conf->global->MEMBER_NEWFORM_AMOUNT; + $amount = 0; + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } - if (! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount=GETPOST('amount')?GETPOST('amount'):$conf->global->MEMBER_NEWFORM_AMOUNT; + $amount = GETPOST('amount') ?GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT; } // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' print ''; print ''; - if (isset($object->photo) && $object->photo !='') + if (isset($object->photo) && $object->photo != '') { $form = new Form($db); print ''; echo ''; - $i=0; + $i = 0; while ($i < 7) { if (($i + 1) < $begin_d || ($i + 1) > $end_d) @@ -679,7 +679,7 @@ while($currentdaytoshow<$lastdaytoshow) { $usernames = array(); //init $usernamesid = array(); /* Use this to have list of users only if users have events */ - if (! empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW)) + if (!empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW)) { foreach ($eventarray as $daykey => $notused) { @@ -699,12 +699,12 @@ while($currentdaytoshow<$lastdaytoshow) { else { $sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; - $sql.= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user').")"; - if ($usergroup > 0) $sql.= " AND ug.fk_usergroup = ".$usergroup; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; + $sql .= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user').")"; + if ($usergroup > 0) $sql .= " AND ug.fk_usergroup = ".$usergroup; //print $sql; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -714,7 +714,7 @@ while($currentdaytoshow<$lastdaytoshow) { while ($i < $num) { $obj = $db->fetch_object($resql); - $usernamesid[$obj->rowid]=$obj->rowid; + $usernamesid[$obj->rowid] = $obj->rowid; $i++; } } @@ -722,11 +722,11 @@ while($currentdaytoshow<$lastdaytoshow) { else dol_print_error($db); } //var_dump($usernamesid); - foreach($usernamesid as $id) + foreach ($usernamesid as $id) { - $tmpuser=new User($db); - $result=$tmpuser->fetch($id); - $usernames[]=$tmpuser; + $tmpuser = new User($db); + $result = $tmpuser->fetch($id); + $usernames[] = $tmpuser; } /* @@ -791,11 +791,11 @@ while($currentdaytoshow<$lastdaytoshow) { $tmpmonth = $tmparray['mon']; $tmpyear = $tmparray['year']; - $style='cal_current_month'; - if ($iter_day == 6) $style.=' cal_other_month'; - $today=0; - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; - if ($today) $style='cal_today_peruser'; + $style = 'cal_current_month'; + if ($iter_day == 6) $style .= ' cal_other_month'; + $today = 0; + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; + if ($today) $style = 'cal_today_peruser'; show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); @@ -808,21 +808,21 @@ while($currentdaytoshow<$lastdaytoshow) { echo "
        '; -$searchpicto=$form->showFilterAndCheckAddButtons(0); +$searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
        '.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Task").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
        ('.$langs->trans("Everybody").')
        '.$langs->trans("TimeSpent").($usertoprocess->firstname?'
        ('.dol_trunc($usertoprocess->firstname, 10).')':'').'
        '.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
        ('.dol_trunc($usertoprocess->firstname, 10).')' : '').'
        '.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
        '.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'
        '.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
        '.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'
        '; + print ''; print $langs->trans("Total"); print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print '
         
         
         
        '; + print ''; print $langs->trans("OtherFilteredTasks"); print ''; - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); + print ''; + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); if ($timeonothertasks) { print 'use_javascript_ajax) { @@ -865,7 +865,7 @@ if ($conf->use_javascript_ajax) } });'."\n"; - $idw=0; + $idw = 0; while ($idw < 7) { print ' updateTotal('.$idw.',\''.$modeinput.'\');'; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 51af2f2b14d..74f53cc9b72 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -94,9 +94,9 @@ if (empty($reshook)) // Cancel if ($cancel) { - if (GETPOST("comefromclone")==1) + if (GETPOST("comefromclone") == 1) { - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { header("Location: index.php"); @@ -119,7 +119,7 @@ if (empty($reshook)) if ($action == 'add' && $user->rights->projet->creer) { - $error=0; + $error = 0; if (empty($_POST["ref"])) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); @@ -131,21 +131,21 @@ if (empty($reshook)) $error++; } - if (GETPOST('opp_amount') != '' && ! (GETPOST('opp_status') > 0)) + if (GETPOST('opp_amount') != '' && !(GETPOST('opp_status') > 0)) { $error++; setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } // Create with status validated immediatly - if (! empty($conf->global->PROJECT_CREATE_NO_DRAFT)) + if (!empty($conf->global->PROJECT_CREATE_NO_DRAFT)) { - $status=Project::STATUS_VALIDATED; + $status = Project::STATUS_VALIDATED; } - if (! $error) + if (!$error) { - $error=0; + $error = 0; $db->begin(); @@ -156,23 +156,23 @@ if (empty($reshook)) $object->public = GETPOST('public', 'alpha'); $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha')); $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha')); - $object->date_c = dol_now(); + $object->date_c = dol_now(); $object->date_start = $date_start; $object->date_end = $date_end; $object->statut = $status; $object->opp_status = $opp_status; $object->opp_percent = $opp_percent; - $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha')=='on'?1:0); - $object->usage_task = (GETPOST('usage_task', 'alpha')=='on'?1:0); - $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha')=='on'?1:0); - $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha')=='on'?1:0); + $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0); + $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0); + $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0); + $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; $result = $object->create($user); - if (! $error && $result > 0) + if (!$error && $result > 0) { // Add myself as project leader $result = $object->add_contact($user->id, 'PROJECTLEADER', 'internal'); @@ -189,19 +189,19 @@ if (empty($reshook)) setEventMessages($langs->trans($object->error), null, 'errors'); $error++; } - if (! $error && !empty($object->id) > 0) + if (!$error && !empty($object->id) > 0) { // Category association $categories = GETPOST('categories', 'array'); - $result=$object->setCategories($categories); - if ($result<0) { + $result = $object->setCategories($categories); + if ($result < 0) { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $error++; } } - if (! $error) + if (!$error) { $db->commit(); @@ -231,9 +231,9 @@ if (empty($reshook)) } } - if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) + if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) { - $error=0; + $error = 0; if (empty($ref)) { @@ -250,7 +250,7 @@ if (empty($reshook)) $db->begin(); - if (! $error) + if (!$error) { $object->oldcopy = clone $object; @@ -260,18 +260,18 @@ if (empty($reshook)) $object->title = GETPOST('title', 'none'); // Do not use 'alpha' here, we want field as it is $object->statut = GETPOST('status', 'int'); $object->socid = GETPOST('socid', 'int'); - $object->description = GETPOST('description', 'none'); // Do not use 'alpha' here, we want field as it is + $object->description = GETPOST('description', 'none'); // Do not use 'alpha' here, we want field as it is $object->public = GETPOST('public', 'alpha'); - $object->date_start = empty($_POST["projectstart"])?'':$date_start; - $object->date_end = empty($_POST["projectend"])?'':$date_end; + $object->date_start = empty($_POST["projectstart"]) ? '' : $date_start; + $object->date_end = empty($_POST["projectend"]) ? '' : $date_end; if (isset($_POST['opp_amount'])) $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha')); - if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount', 'alpha')); + if (isset($_POST['budget_amount'])) $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha')); if (isset($_POST['opp_status'])) $object->opp_status = $opp_status; if (isset($_POST['opp_percent'])) $object->opp_percent = $opp_percent; - $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha')=='on'?1:0); - $object->usage_task = (GETPOST('usage_task', 'alpha')=='on'?1:0); - $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha')=='on'?1:0); - $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha')=='on'?1:0); + $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0); + $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0); + $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0); + $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -284,18 +284,18 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } - if (! $error) + if (!$error) { - $result=$object->update($user); + $result = $object->update($user); if ($result < 0) { $error++; if ($result == -4) setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); else setEventMessages($object->error, $object->errors, 'errors'); - }else { + } else { // Category association $categories = GETPOST('categories', 'array'); - $result=$object->setCategories($categories); + $result = $object->setCategories($categories); if ($result < 0) { $error++; @@ -304,11 +304,11 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { - if (GETPOST("reportdate") && ($object->date_start!=$old_start_date)) + if (GETPOST("reportdate") && ($object->date_start != $old_start_date)) { - $result=$object->shiftTaskDate($old_start_date); + $result = $object->shiftTaskDate($old_start_date); if ($result < 0) { $error++; @@ -332,7 +332,7 @@ if (empty($reshook)) if ($error) { $db->rollback(); - $action='edit'; + $action = 'edit'; } else { @@ -355,11 +355,11 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); } - $result= $object->generateDocument($object->modelpdf, $outputlangs); + $result = $object->generateDocument($object->modelpdf, $outputlangs); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } @@ -368,11 +368,11 @@ if (empty($reshook)) { if ($object->id > 0) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("other"); $upload_dir = $conf->projet->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); + $file = $upload_dir.'/'.GETPOST('file'); $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); @@ -413,7 +413,7 @@ if (empty($reshook)) if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) { $object->fetch($id); - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); @@ -429,15 +429,15 @@ if (empty($reshook)) if ($action == 'confirm_clone' && $user->rights->projet->creer && $confirm == 'yes') { - $clone_contacts=GETPOST('clone_contacts')?1:0; - $clone_tasks=GETPOST('clone_tasks')?1:0; + $clone_contacts = GETPOST('clone_contacts') ? 1 : 0; + $clone_tasks = GETPOST('clone_tasks') ? 1 : 0; $clone_project_files = GETPOST('clone_project_files') ? 1 : 0; $clone_task_files = GETPOST('clone_task_files') ? 1 : 0; - $clone_notes=GETPOST('clone_notes')?1:0; - $move_date=GETPOST('move_date')?1:0; - $clone_thirdparty=GETPOST('socid', 'int')?GETPOST('socid', 'int'):0; + $clone_notes = GETPOST('clone_notes') ? 1 : 0; + $move_date = GETPOST('move_date') ? 1 : 0; + $clone_thirdparty = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : 0; - $result=$object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty); + $result = $object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -445,21 +445,21 @@ if (empty($reshook)) else { // Load new object - $newobject=new Project($db); + $newobject = new Project($db); $newobject->fetch($result); $newobject->fetch_optionals(); - $newobject->fetch_thirdparty(); // Load new object - $object=$newobject; - $action='edit'; - $comefromclone=true; + $newobject->fetch_thirdparty(); // Load new object + $object = $newobject; + $action = 'edit'; + $comefromclone = true; } } // Actions to send emails - $trigger_name='PROJECT_SENTBYMAIL'; - $paramname='id'; - $autocopy='MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add - $trackid='proj'.$object->id; + $trigger_name = 'PROJECT_SENTBYMAIL'; + $paramname = 'id'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add + $trackid = 'proj'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -473,21 +473,21 @@ $formfile = new FormFile($db); $formproject = new FormProjets($db); $userstatic = new User($db); -$title=$langs->trans("Project").' - '.$object->ref.($object->thirdparty->name?' - '.$object->thirdparty->name:'').($object->title?' - '.$object->title:''); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) $title=$object->ref.($object->thirdparty->name?' - '.$object->thirdparty->name:'').($object->title?' - '.$object->title:''); -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$title = $langs->trans("Project").' - '.$object->ref.($object->thirdparty->name ? ' - '.$object->thirdparty->name : '').($object->title ? ' - '.$object->title : ''); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) $title = $object->ref.($object->thirdparty->name ? ' - '.$object->thirdparty->name : '').($object->title ? ' - '.$object->title : ''); +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); -$titleboth=$langs->trans("LeadsOrProjects"); -$titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default +$titleboth = $langs->trans("LeadsOrProjects"); +$titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0) { - $titleboth=$langs->trans("Projects"); + $titleboth = $langs->trans("Projects"); $titlenew = $langs->trans("NewProject"); } if ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only - $titleboth=$langs->trans("Leads"); + $titleboth = $langs->trans("Leads"); $titlenew = $langs->trans("NewLead"); } @@ -497,7 +497,7 @@ if ($action == 'create' && $user->rights->projet->creer) * Create */ - $thirdparty=new Societe($db); + $thirdparty = new Societe($db); if ($socid > 0) $thirdparty->fetch($socid); print load_fiche_titre($titlenew, '', 'project'); @@ -511,18 +511,18 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; - $defaultref=''; - $modele = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; + $defaultref = ''; + $modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON; // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); + $file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = $modele; break; } @@ -530,16 +530,16 @@ if ($action == 'create' && $user->rights->projet->creer) if ($filefound) { - $result=dol_include_once($reldir."core/modules/project/".$modele.'.php'); + $result = dol_include_once($reldir."core/modules/project/".$modele.'.php'); $modProject = new $classname; $defaultref = $modProject->getNextValue($thirdparty, $object); } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; // Ref - $suggestedref=($_POST["ref"]?$_POST["ref"]:$defaultref); + $suggestedref = ($_POST["ref"] ? $_POST["ref"] : $defaultref); print ''; @@ -552,23 +552,23 @@ if ($action == 'create' && $user->rights->projet->creer) print $langs->trans("Usage"); print ''; print ''; // Date start print ''; // Date end print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity status print ''; print ''; // Opportunity probability print ''; - print ''; print ''; // Opportunity amount print ''; - print ''; + print ''; print ''; } // Budget print ''; - print ''; + print ''; print ''; // Description @@ -664,14 +664,14 @@ if ($action == 'create' && $user->rights->projet->creer) // Categories print '"; } // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -684,7 +684,7 @@ if ($action == 'create' && $user->rights->projet->creer) print '
        '; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -692,7 +692,7 @@ if ($action == 'create' && $user->rights->projet->creer) else { print '     '; - print ''; + print ''; } print '
        '; @@ -721,7 +721,7 @@ elseif ($object->id > 0) * Show or edit */ - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); // To verify role of users $userAccess = $object->restrictedProjectArea($user, 'read'); @@ -748,26 +748,26 @@ elseif ($object->id > 0) // Confirmation delete if ($action == 'delete') { - $text=$langs->trans("ConfirmDeleteAProject"); - $task=new Task($db); - $taskarray=$task->getTasksArray(0, 0, $object->id, 0, 0); - $nboftask=count($taskarray); - if ($nboftask) $text.='
        '.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask); + $text = $langs->trans("ConfirmDeleteAProject"); + $task = new Task($db); + $taskarray = $task->getTasksArray(0, 0, $object->id, 0, 0); + $nboftask = count($taskarray); + if ($nboftask) $text .= '
        '.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAProject"), $text, "confirm_delete", '', '', 1); } // Clone confirmation if ($action == 'clone') { - $formquestion=array( + $formquestion = array( 'text' => $langs->trans("ConfirmClone"), - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int')>0?GETPOST('socid', 'int'):$object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')), - array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true), - array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_project_files','label' => $langs->trans("CloneProjectFiles"), 'value' => false), - array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')), + array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true), + array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_project_files', 'label' => $langs->trans("CloneProjectFiles"), 'value' => false), + array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) ); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300, 590); @@ -803,9 +803,9 @@ elseif ($object->id > 0) // Status print ''; @@ -815,23 +815,23 @@ elseif ($object->id > 0) print $langs->trans("Usage"); print ''; print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity status print ''; @@ -881,33 +881,33 @@ elseif ($object->id > 0) // Opportunity probability print ''; - print ''; print ''; // Opportunity amount print ''; - print ''; + print ''; print ''; } // Date start print ''; // Date end print ''; // Budget print ''; - print ''; + print ''; print ''; // Description @@ -923,7 +923,7 @@ elseif ($object->id > 0) $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_PROJECT); - foreach($cats as $cat) { + foreach ($cats as $cat) { $arrayselected[] = $cat->id; } print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); @@ -931,8 +931,8 @@ elseif ($object->id > 0) } // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -943,28 +943,28 @@ elseif ($object->id > 0) } else { - dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); + dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); // Project card $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
        '; + $morehtmlref = '
        '; // Title - $morehtmlref.=$object->title; + $morehtmlref .= $object->title; // Thirdparty - $morehtmlref.='
        '.$langs->trans('ThirdParty') . ' : '; + $morehtmlref .= '
        '.$langs->trans('ThirdParty').' : '; if ($object->thirdparty->id > 0) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project'); } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; // Define a complementary filter for search of next/prev ref. - if (! $user->rights->projet->all->lire) + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")"; + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -981,23 +981,23 @@ elseif ($object->id > 0) print $langs->trans("Usage"); print ''; print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES) && ! empty($object->usage_opportunity)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) { // Opportunity status print ''; @@ -1050,7 +1050,7 @@ elseif ($object->id > 0) // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
        '.$langs->trans("Ref").''; print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref)); print '
        '; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
        '; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
        '; } - if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
        '; @@ -584,16 +584,16 @@ if ($action == 'create' && $user->rights->projet->creer) if ($conf->societe->enabled) { print '
        '; - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print $langs->trans("ThirdParty"); - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print ''; - $filteronlist=''; - if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; - $text=$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300'); + $filteronlist = ''; + if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + $text = $form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300'); if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { - $texthelp=$langs->trans("IfNeedToUseOtherObjectKeepEmpty"); + $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1); } else print $text; @@ -612,46 +612,46 @@ if ($action == 'create' && $user->rights->projet->creer) // Visibility print '
        '.$langs->trans("Visibility").''; - $array=array(); + $array = array(); if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); - print $form->selectarray('public', $array, GETPOST('public')?GETPOST('public'):$object->public); + print $form->selectarray('public', $array, GETPOST('public') ?GETPOST('public') : $object->public); print '
        '.$langs->trans("DateStart").''; - print $form->selectDate(($date_start?$date_start:''), 'projectstart', 0, 0, 0, '', 1, 0); + print $form->selectDate(($date_start ? $date_start : ''), 'projectstart', 0, 0, 0, '', 1, 0); print '
        '.$langs->trans("DateEnd").''; - print $form->selectDate(($date_end?$date_end:-1), 'projectend', 0, 0, 0, '', 1, 0); + print $form->selectDate(($date_end ? $date_end : -1), 'projectend', 0, 0, 0, '', 1, 0); print '
        '.$langs->trans("OpportunityStatus").''; - print $formproject->selectOpportunityStatus('opp_status', GETPOST('opp_status')?GETPOST('opp_status'):$object->opp_status); + print $formproject->selectOpportunityStatus('opp_status', GETPOST('opp_status') ?GETPOST('opp_status') : $object->opp_status); print '
        '.$langs->trans("OpportunityProbability").' %'; - print ''; + print ' %'; + print ''; print '
        '.$langs->trans("OpportunityAmount").'
        '.$langs->trans("Budget").'
        '.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1); - $arrayselected=GETPOST('categories', 'array'); + $arrayselected = GETPOST('categories', 'array'); print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); print "
        '.$langs->trans("Status").''; print ''; print '
        '; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
        '; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; + print 'usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
        '; } - if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
        '; @@ -842,16 +842,16 @@ elseif ($object->id > 0) if ($conf->societe->enabled) { print '
        '; - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print $langs->trans("ThirdParty"); - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print ''; - $filteronlist=''; - if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; - $text=$form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300'); + $filteronlist = ''; + if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + $text = $form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300'); if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { - $texthelp=$langs->trans("IfNeedToUseOtherObjectKeepEmpty"); + $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2); } else print $text; @@ -860,13 +860,13 @@ elseif ($object->id > 0) // Visibility print '
        '.$langs->trans("Visibility").''; - $array=array(); + $array = array(); if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); print $form->selectarray('public', $array, $object->public); print '
        '.$langs->trans("OpportunityStatus").'
        '.$langs->trans("OpportunityProbability").' %'; + print ' %'; print ''; print '
        '.$langs->trans("OpportunityAmount").'
        '.$langs->trans("DateStart").''; - print $form->selectDate($object->date_start?$object->date_start:-1, 'projectstart', 0, 0, 0, '', 1, 0); + print $form->selectDate($object->date_start ? $object->date_start : -1, 'projectstart', 0, 0, 0, '', 1, 0); print '     '. $langs->trans("ProjectReportDate"); + if ($comefromclone) {print ' checked '; } + print '/> '.$langs->trans("ProjectReportDate"); print '
        '.$langs->trans("DateEnd").''; - print $form->selectDate($object->date_end?$object->date_end:-1, 'projectend', 0, 0, 0, '', 1, 0); + print $form->selectDate($object->date_end ? $object->date_end : -1, 'projectend', 0, 0, 0, '', 1, 0); print '
        '.$langs->trans("Budget").'
        '; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
        '; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; + print 'usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
        '; } - if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
        '; @@ -1010,7 +1010,7 @@ elseif ($object->id > 0) else print $langs->trans('PrivateProject'); print '
        '.$langs->trans("OpportunityStatus").''; @@ -1036,10 +1036,10 @@ elseif ($object->id > 0) // Date start - end print '
        '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start, 'day'); - print ($start?$start:'?'); + print ($start ? $start : '?'); $end = dol_print_date($object->date_end, 'day'); print ' - '; - print ($end?$end:'?'); + print ($end ? $end : '?'); if ($object->hasDelay()) print img_warning("Late"); print '
        '; @@ -1067,7 +1067,7 @@ elseif ($object->id > 0) print '
        '.$langs->trans("Categories").''; print $form->showCategories($object->id, 'project', 1); print "
        '.$langs->trans("Subscription").''; - if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { print ''; } @@ -730,7 +730,7 @@ dol_fiche_end(); // Save print '
        '; print ''; -if (! empty($backtopage)) +if (!empty($backtopage)) { print '     '; } diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index e10186458fa..32a83e5c432 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -25,14 +25,14 @@ * \brief File to show a public card of a member */ -if (! defined('NOLOGIN')) define("NOLOGIN", 1); // This means this output page does not require to be logged. -if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. -if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +if (!defined('NOLOGIN')) define("NOLOGIN", 1); // This means this output page does not require to be logged. +if (!defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php // TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; @@ -46,7 +46,7 @@ if (empty($conf->adherent->enabled)) accessforbidden('', 0, 0, 1); $langs->loadLangs(array("main", "members", "companies", "other")); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $object = new Adherent($db); $extrafields = new ExtraFields($db); @@ -64,9 +64,9 @@ $extrafields = new ExtraFields($db); * View */ -$morehead=''; -if (! empty($conf->global->MEMBER_PUBLIC_CSS)) $morehead=''; -else $morehead=''; +$morehead = ''; +if (!empty($conf->global->MEMBER_PUBLIC_CSS)) $morehead = ''; +else $morehead = ''; llxHeaderVierge($langs->trans("MemberCard"), $morehead); @@ -75,9 +75,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); if ($id > 0) { - $res=$object->fetch($id); + $res = $object->fetch($id); if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); print load_fiche_titre($langs->trans("MemberCard"), '', ''); @@ -101,7 +101,7 @@ if ($id > 0) print '
        '.$langs->trans("EMail").''.$object->email.' 
        '.$langs->trans("Birthday").''.dol_print_date($object->birth, 'day').'
        URL Photo'; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 9829aa03f7b..834d5aa67ee 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","other","ticket")); +$langs->loadLangs(array("companies", "other", "ticket")); // Get parameters $track_id = GETPOST('track_id', 'alpha'); @@ -117,7 +117,7 @@ if ($action == "view_ticketlist") { } } if ($object->fk_user_create > 0) { - $tmpuser=new User($db); + $tmpuser = new User($db); $tmpuser->fetch($object->fk_user_create); if ($email == $tmpuser->email) { $display_ticket_list = true; @@ -159,7 +159,7 @@ $user_create = new User($db); $formTicket = new FormTicket($db); if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) { - print '
        ' . $langs->trans('TicketPublicInterfaceForbidden') . '
        '; + print '
        '.$langs->trans('TicketPublicInterfaceForbidden').'
        '; $db->close(); exit(); } @@ -235,50 +235,50 @@ if ($action == "view_ticketlist") if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate') { - $arrayfields["ef." . $key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => $extrafields->attributes[$object->table_element]['list'][$key], 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => $extrafields->attributes[$object->table_element]['perms'][$key]); + $arrayfields["ef.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => $extrafields->attributes[$object->table_element]['list'][$key], 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => $extrafields->attributes[$object->table_element]['perms'][$key]); } } } if (!empty($search_subject)) { $filter['t.subject'] = $search_subject; - $param .= '&search_subject=' .urlencode($search_subject); + $param .= '&search_subject='.urlencode($search_subject); } if (!empty($search_type)) { $filter['t.type_code'] = $search_type; - $param .= '&search_type=' . urlencode($search_type); + $param .= '&search_type='.urlencode($search_type); } if (!empty($search_category)) { $filter['t.category_code'] = $search_category; - $param .= '&search_category=' . urlencode($search_category); + $param .= '&search_category='.urlencode($search_category); } if (!empty($search_severity)) { $filter['t.severity_code'] = $search_severity; - $param .= '&search_severity=' . urlencode($search_severity); + $param .= '&search_severity='.urlencode($search_severity); } if (!empty($search_fk_user_assign)) { // -1 value = all so no filter if ($search_fk_user_assign > 0) { $filter['t.fk_user_assign'] = $search_fk_user_assign; - $param .= '&search_fk_user_assign=' . urlencode($search_fk_user_assign); + $param .= '&search_fk_user_assign='.urlencode($search_fk_user_assign); } } if (!empty($search_fk_user_create)) { // -1 value = all so no filter if ($search_fk_user_create > 0) { $filter['t.fk_user_create'] = $search_fk_user_create; - $param .= '&search_fk_user_create=' . urlencode($search_fk_user_create); + $param .= '&search_fk_user_create='.urlencode($search_fk_user_create); } } if ((isset($search_fk_status) && $search_fk_status != '') && $search_fk_status != '-1' && $search_fk_status != 'non_closed') { $filter['t.fk_statut'] = $search_fk_status; - $param .= '&search_fk_status=' . urlencode($search_fk_status); + $param .= '&search_fk_status='.urlencode($search_fk_status); } if (isset($search_fk_status) && $search_fk_status == 'non_closed') { $filter['t.fk_statut'] = array(0, 1, 3, 4, 5, 6); $param .= '&search_fk_status=non_closed'; } - require DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; + require DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -325,54 +325,54 @@ if ($action == "view_ticketlist") // Add fields for extrafields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key . ' as options_' . $key : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } - $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_type as type ON type.code=t.type_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_category as category ON category.code=t.category_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid=t.fk_soc"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as uc ON uc.rowid=t.fk_user_create"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as ua ON ua.rowid=t.fk_user_assign"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON ec.element_id=t.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON ec.fk_c_type_contact=tc.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople sp ON ec.fk_socpeople=sp.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as uc ON uc.rowid=t.fk_user_create"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON ua.rowid=t.fk_user_assign"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id=t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON ec.fk_c_type_contact=tc.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople sp ON ec.fk_socpeople=sp.rowid"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "ticket_extrafields as ef on (t.rowid = ef.fk_object)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields as ef on (t.rowid = ef.fk_object)"; } - $sql .= " WHERE t.entity IN (" . getEntity('ticket') . ")"; + $sql .= " WHERE t.entity IN (".getEntity('ticket').")"; $sql .= " AND ((tc.source = 'external'"; - $sql .= " AND tc.element='" . $db->escape($object->dao->element) . "'"; + $sql .= " AND tc.element='".$db->escape($object->dao->element)."'"; $sql .= " AND tc.active=1)"; - $sql .= " OR (sp.email='" . $db->escape($_SESSION['email_customer']) . "'"; - $sql .= " OR s.email='" . $db->escape($_SESSION['email_customer']) . "'"; - $sql .= " OR t.origin_email='" . $db->escape($_SESSION['email_customer']) . "'))"; + $sql .= " OR (sp.email='".$db->escape($_SESSION['email_customer'])."'"; + $sql .= " OR s.email='".$db->escape($_SESSION['email_customer'])."'"; + $sql .= " OR t.origin_email='".$db->escape($_SESSION['email_customer'])."'))"; // Manage filter if (!empty($filter)) { foreach ($filter as $key => $value) { if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year - $sql .= ' AND ' . $key . ' = \'' . $value . '\''; + $sql .= ' AND '.$key.' = \''.$value.'\''; } elseif (($key == 't.fk_user_assign') || ($key == 't.type_code') || ($key == 't.category_code') || ($key == 't.severity_code')) { - $sql .= " AND " . $key . " = '" . $db->escape($value) ."'"; + $sql .= " AND ".$key." = '".$db->escape($value)."'"; } elseif ($key == 't.fk_statut') { if (is_array($value) && count($value) > 0) { - $sql .= 'AND ' . $key . ' IN (' . implode(',', $value) . ')'; + $sql .= 'AND '.$key.' IN ('.implode(',', $value).')'; } else { - $sql .= ' AND ' . $key . ' = ' . $db->escape($value); + $sql .= ' AND '.$key.' = '.$db->escape($value); } } else { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } } } //$sql .= " GROUP BY t.track_id"; - $sql .= " ORDER BY " . $sortfield . ' ' . $sortorder; + $sql .= " ORDER BY ".$sortfield.' '.$sortorder; $resql = $db->query($sql); if ($resql) { $num_total = $db->num_rows($resql); if (!empty($limit)) { - $sql .= ' ' . $db->plimit($limit + 1, $offset); + $sql .= ' '.$db->plimit($limit + 1, $offset); } $resql = $db->query($sql); @@ -381,16 +381,16 @@ if ($action == "view_ticketlist") print_barre_liste($langs->trans('TicketList'), $page, 'public/list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket'); // Search bar - print '
        ' . "\n"; + print ''."\n"; print ''; print ''; - print ''; - print ''; + print ''; + print ''; $varpage = empty($contextpage) ? $url_page_current : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print ''; + print '
        '; // Filter bar print ''; @@ -412,7 +412,7 @@ if ($action == "view_ticketlist") if (!empty($arrayfields['t.subject']['checked'])) { print ''; } @@ -454,8 +454,8 @@ if ($action == "view_ticketlist") include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Status @@ -468,7 +468,7 @@ if ($action == "view_ticketlist") // Action column print ''; print ''; @@ -516,8 +516,8 @@ if ($action == "view_ticketlist") include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['t.fk_statut']['checked'])) { @@ -561,7 +561,7 @@ if ($action == "view_ticketlist") // Subject if (!empty($arrayfields['t.subject']['checked'])) { print ''; } @@ -620,20 +620,20 @@ if ($action == "view_ticketlist") } if (!empty($arrayfields['t.tms']['checked'])) { - print ''; + print ''; } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (!empty($arrayfields["ef." . $key]['checked'])) { + if (!empty($arrayfields["ef.".$key]['checked'])) { print 'getAlignFlag($key); if ($align) { - print ' align="' . $align . '"'; + print ' align="'.$align.'"'; } print '>'; - $tmpkey = 'options_' . $key; + $tmpkey = 'options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; } @@ -657,8 +657,8 @@ if ($action == "view_ticketlist") print '
        '; - print ''; + print ''; print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
        '; - print '' . $obj->subject . ''; + print ''.$obj->subject.''; print '' . dol_print_date($db->jdate($obj->tms), 'dayhour') . ''.dol_print_date($db->jdate($obj->tms), 'dayhour').'
        '; print '
        '; - print '
        '; - echo $langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7)); + echo $langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)); print "
        "; if ($i) print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day'); else print dol_print_date($currentdaytoshow, 'day'); @@ -655,7 +655,7 @@ while($currentdaytoshow<$lastdaytoshow) { echo '
        \n"; echo "
        "; - $currentdaytoshow = dol_time_plus_duree($currentdaytoshow, 7, 'd'); + $currentdaytoshow = dol_time_plus_duree($currentdaytoshow, 7, 'd'); } echo '
        '; -if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) +if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && !empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) { $langs->load("commercial"); print '
        '.$langs->trans("Legend").':
        '; - foreach($colorsbytype as $code => $color) + foreach ($colorsbytype as $code => $color) { if ($color) { - print '
         
        '; - print $langs->trans("Action".$code)!="Action".$code?$langs->trans("Action".$code):$labelbytype[$code]; + print '
         
        '; + print $langs->trans("Action".$code) != "Action".$code ? $langs->trans("Action".$code) : $labelbytype[$code]; //print $code; print '
        '; } @@ -907,21 +907,21 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & { global $db; global $user, $conf, $langs, $hookmanager, $action; - global $filter, $filtert, $status, $actioncode; // Filters used into search form - global $theme_datacolor; // Array with a list of different we can use (come from theme) + global $filter, $filtert, $status, $actioncode; // Filters used into search form + global $theme_datacolor; // Array with a list of different we can use (come from theme) global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused; global $begin_h, $end_h; - $cases1 = array(); // Color first half hour + $cases1 = array(); // Color first half hour $cases2 = array(); // Color second half hour $curtime = dol_mktime(0, 0, 0, $month, $day, $year, false, 0); - $i=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); - $ymd=sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); + $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); + $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); - $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 - $nextindextouse=count($colorindexused); // At first run this is 0, so first user has 0, next 1, ... + $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 + $nextindextouse = count($colorindexused); // At first run this is 0, so first user has 0, next 1, ... //if ($username->id && $day==1) var_dump($eventarray); // We are in a particular day for $username, now we scan all events @@ -932,96 +932,96 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $jour = date('d', $daykey); //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."
        \n"; - if ($day==$jour && $month==$mois && $year==$annee) // Is it the day we are looking for when calling function ? + if ($day == $jour && $month == $mois && $year == $annee) // Is it the day we are looking for when calling function ? { // Scan all event for this date foreach ($eventarray[$daykey] as $index => $event) { //var_dump($event); - $keysofuserassigned=array_keys($event->userassigned); - $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); + $keysofuserassigned = array_keys($event->userassigned); + $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); - if (! in_array($username->id, $keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show + if (!in_array($username->id, $keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show - $parameters=array(); - $reshook=$hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Define $color (Hex string like '0088FF') and $cssclass of event - $color=-1; $cssclass=''; $colorindex=-1; + $color = -1; $cssclass = ''; $colorindex = -1; if (in_array($user->id, $keysofuserassigned)) { - $cssclass='family_mytasks'; + $cssclass = 'family_mytasks'; if (empty($cacheusers[$event->userownerid])) { - $newuser=new User($db); + $newuser = new User($db); $newuser->fetch($event->userownerid); - $cacheusers[$event->userownerid]=$newuser; + $cacheusers[$event->userownerid] = $newuser; } //var_dump($cacheusers[$event->userownerid]->color); // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; - if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color; + if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color = $event->type_color; } elseif ($event->type_code == 'ICALEVENT') { $numical++; - if (! empty($event->icalname)) + if (!empty($event->icalname)) { - if (! isset($numicals[dol_string_nospecial($event->icalname)])) { + if (!isset($numicals[dol_string_nospecial($event->icalname)])) { $numicals[dol_string_nospecial($event->icalname)] = 0; } $numicals[dol_string_nospecial($event->icalname)]++; } - $color=$event->icalcolor; - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable'); + $color = $event->icalcolor; + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other unsortable'); } elseif ($event->type_code == 'BIRTHDAY') { - $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unsortable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } else { $numother++; - $color=($event->icalcolor?$event->icalcolor:-1); - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other'); + $color = ($event->icalcolor ? $event->icalcolor : -1); + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); if (empty($cacheusers[$event->userownerid])) { - $newuser=new User($db); + $newuser = new User($db); $newuser->fetch($event->userownerid); - $cacheusers[$event->userownerid]=$newuser; + $cacheusers[$event->userownerid] = $newuser; } //var_dump($cacheusers[$event->userownerid]->color); // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; - if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color; + if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color = $event->type_color; } if ($color < 0) // Color was not set on user card. Set color according to color index. { // Define color index if not yet defined - $idusertouse=($event->userownerid?$event->userownerid:0); + $idusertouse = ($event->userownerid ? $event->userownerid : 0); if (isset($colorindexused[$idusertouse])) { - $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user + $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user } else { - $colorindex=$nextindextouse; - $colorindexused[$idusertouse]=$colorindex; - if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color + $colorindex = $nextindextouse; + $colorindexused[$idusertouse] = $colorindex; + if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color } // Define color - $color=sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } //$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd; diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 0e3d7a7725e..bbc7677867d 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -29,22 +29,22 @@ require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; $langs->load("mails"); // Security check -$result=restrictedArea($user, 'mailing'); +$result = restrictedArea($user, 'mailing'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $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 (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="m.date_creat"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "m.date_creat"; -$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref=GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha"); -$filteremail=GETPOST('filteremail', 'alpha'); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha"); +$filteremail = GETPOST('filteremail', 'alpha'); $object = new Mailing($db); @@ -69,11 +69,11 @@ $fieldstosearchall = array( * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +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 +$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)) @@ -82,7 +82,7 @@ if (empty($reshook)) 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 + 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 { /*foreach($object->fields as $key => $val) { @@ -90,13 +90,13 @@ if (empty($reshook)) }*/ $search_ref = ''; $search_all = ''; - $toselect=''; - $search_array_options=array(); + $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 + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions @@ -121,28 +121,28 @@ $form = new Form($db); if ($filteremail) { $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,"; - $sql.= " mc.statut as sendstatut"; - $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql.= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity; - $sql.= " AND mc.email = '".$db->escape($filteremail)."'"; - if ($search_ref) $sql.= " AND m.rowid = '".$db->escape($search_ref)."'"; - if ($search_all) $sql.= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="m.rowid"; - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($conf->liste_limit +1, $offset); + $sql .= " mc.statut as sendstatut"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity; + $sql .= " AND mc.email = '".$db->escape($filteremail)."'"; + if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; + if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "m.rowid"; + $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($conf->liste_limit + 1, $offset); } else { $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi"; - $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; - $sql.= " WHERE m.entity = ".$conf->entity; - if ($search_ref) $sql.= " AND m.rowid = '".$db->escape($search_ref)."'"; - if ($search_all) $sql.= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="m.rowid"; - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($conf->liste_limit +1, $offset); + $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; + $sql .= " WHERE m.entity = ".$conf->entity; + if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; + if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "m.rowid"; + $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($conf->liste_limit + 1, $offset); } //print $sql; @@ -178,7 +178,7 @@ if ($result) $moreforfilter = ''; print '
        '; - print ''."\n"; + print '
        '."\n"; print ''; print '\n"; - $email=new Mailing($db); + $email = new Mailing($db); while ($i < min($num, $limit)) { @@ -233,7 +233,7 @@ if ($result) print ''; // Nb of email - if (! $filteremail) + if (!$filteremail) { print '
        '; @@ -202,15 +202,15 @@ if ($result) print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "m.rowid", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "m.titre", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", $param, "", 'align="center"', $sortfield, $sortorder); - 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); + 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, "", 'class="right"', $sortfield, $sortorder); + 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 "
        '; $nbemail = $obj->nbemail; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 54ad29d32f4..0c093d561c0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -31,11 +31,11 @@ * \ingroup commande * \brief Fichier des classes de commandes */ -include_once DOL_DOCUMENT_ROOT .'/core/class/commonorder.class.php'; -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; -require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php'; -require_once DOL_DOCUMENT_ROOT .'/multicurrency/class/multicurrency.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/commonorder.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; /** * Class to manage customers orders @@ -45,12 +45,12 @@ class Commande extends CommonOrder /** * @var string ID to identify managed object */ - public $element='commande'; + public $element = 'commande'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='commande'; + public $table_element = 'commande'; /** * @var string Name of subtable line @@ -178,7 +178,7 @@ class Commande extends CommonOrder */ public $date_commande; - public $date_livraison; // Date expected of shipment (date starting shipment, not the reception that occurs some days after) + public $date_livraison; // Date expected of shipment (date starting shipment, not the reception that occurs some days after) /** * @var int ID @@ -190,10 +190,10 @@ class Commande extends CommonOrder public $info_bits; public $rang; public $special_code; - public $source; // Order mode. How we received order (by phone, by email, ...) - public $extraparams=array(); + public $source; // Order mode. How we received order (by phone, by email, ...) + public $extraparams = array(); - public $linked_objects=array(); + public $linked_objects = array(); /** * @var int User author ID @@ -253,7 +253,7 @@ class Commande extends CommonOrder * Shipment on process */ const STATUS_SHIPMENTONPROCESS = 2; - const STATUS_ACCEPTED = 2; // For backward compatibility. Use key STATUS_SHIPMENTONPROCESS instead. + const STATUS_ACCEPTED = 2; // For backward compatibility. Use key STATUS_SHIPMENTONPROCESS instead. /** * Closed (Sent, billed or not) @@ -288,21 +288,21 @@ class Commande extends CommonOrder global $langs, $conf; $langs->load("order"); - if (! empty($conf->global->COMMANDE_ADDON)) + if (!empty($conf->global->COMMANDE_ADDON)) { - $mybool=false; + $mybool = false; $file = $conf->global->COMMANDE_ADDON.".php"; $classname = $conf->global->COMMANDE_ADDON; // Include file with class - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/commande/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } if ($mybool === false) @@ -320,7 +320,7 @@ class Commande extends CommonOrder } else { - $this->error=$obj->error; + $this->error = $obj->error; //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } @@ -356,15 +356,15 @@ class Commande extends CommonOrder return 0; } - if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))) + if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->validate)))) { - $this->error='NotEnoughPermissions'; + $this->error = 'NotEnoughPermissions'; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); return -1; } - $now=dol_now(); + $now = dol_now(); $this->db->begin(); @@ -373,10 +373,10 @@ class Commande extends CommonOrder $soc->fetch($this->socid); // Class of company linked to order - $result=$soc->set_as_client(); + $result = $soc->set_as_client(); // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($soc); } @@ -420,11 +420,11 @@ class Commande extends CommonOrder $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrement stock of product (and sub-products) - $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr", $num)); + $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr", $num)); if ($result < 0) { $error++; - $this->error=$mouvP->error; + $this->error = $mouvP->error; } } if ($error) break; @@ -432,15 +432,15 @@ class Commande extends CommonOrder } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ORDER_VALIDATE', $user); + $result = $this->call_trigger('ORDER_VALIDATE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -481,14 +481,14 @@ class Commande extends CommonOrder } // Set new ref and current status - if (! $error) + if (!$error) { $this->ref = $num; $this->statut = self::STATUS_VALIDATED; $this->brouillon = 0; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -511,9 +511,9 @@ class Commande extends CommonOrder public function setDraft($user, $idwarehouse = -1) { //phpcs:enable - global $conf,$langs; + global $conf, $langs; - $error=0; + $error = 0; // Protection if ($this->statut <= self::STATUS_DRAFT) @@ -521,10 +521,10 @@ class Commande extends CommonOrder return 0; } - if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))) + if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->validate)))) { - $this->error='Permission denied'; + $this->error = 'Permission denied'; return -1; } @@ -533,25 +533,25 @@ class Commande extends CommonOrder $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; - $sql.= " SET fk_statut = ".self::STATUS_DRAFT; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET fk_statut = ".self::STATUS_DRAFT; + $sql .= " WHERE rowid = ".$this->id; if ($this->db->query($sql)) { - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; } // If stock is decremented on validate order, we must reincrement it - if (! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) + if (!empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { $result = 0; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); - $num=count($this->lines); + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { if ($this->lines[$i]->fk_product > 0) @@ -559,30 +559,30 @@ class Commande extends CommonOrder $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We increment stock of product (and sub-products) - $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr", $this->ref)); - if ($result < 0) { $error++; $this->error=$mouvP->error; break; } + $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr", $this->ref)); + if ($result < 0) { $error++; $this->error = $mouvP->error; break; } } } } if (!$error) { // Call trigger - $result=$this->call_trigger('ORDER_UNVALIDATE', $user); + $result = $this->call_trigger('ORDER_UNVALIDATE', $user); if ($result < 0) $error++; } if (!$error) { - $this->statut=self::STATUS_DRAFT; + $this->statut = self::STATUS_DRAFT; $this->db->commit(); return 1; - }else { + } else { $this->db->rollback(); return -1; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -600,7 +600,7 @@ class Commande extends CommonOrder public function set_reopen($user) { // phpcs:enable - $error=0; + $error = 0; if ($this->statut != self::STATUS_CANCELED && $this->statut != self::STATUS_CLOSED) { @@ -611,26 +611,26 @@ class Commande extends CommonOrder $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql.= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0'; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0'; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('ORDER_REOPEN', $user); + $result = $this->call_trigger('ORDER_REOPEN', $user); if ($result < 0) $error++; // End call triggers } else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_print_error($this->db); } - if (! $error) + if (!$error) { $this->statut = self::STATUS_VALIDATED; $this->billed = 0; @@ -640,13 +640,13 @@ class Commande extends CommonOrder } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::set_reopen ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -701,7 +701,7 @@ class Commande extends CommonOrder } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -719,72 +719,72 @@ class Commande extends CommonOrder */ public function cancel($idwarehouse = -1) { - global $conf,$user,$langs; + global $conf, $user, $langs; - $error=0; + $error = 0; $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; - $sql.= " SET fk_statut = ".self::STATUS_CANCELED; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND fk_statut = ".self::STATUS_VALIDATED; + $sql .= " SET fk_statut = ".self::STATUS_CANCELED; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND fk_statut = ".self::STATUS_VALIDATED; dol_syslog(get_class($this)."::cancel", LOG_DEBUG); if ($this->db->query($sql)) { // If stock is decremented on validate order, we must reincrement it - if (! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) + if (!empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); - $num=count($this->lines); + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); // We increment stock of product (and sub-products) - $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderCanceledInDolibarr", $this->ref)); // price is 0, we don't want WAP to be changed + $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderCanceledInDolibarr", $this->ref)); // price is 0, we don't want WAP to be changed if ($result < 0) { $error++; - $this->error=$mouvP->error; + $this->error = $mouvP->error; break; } } } } - if (! $error) + if (!$error) { // Call trigger - $result=$this->call_trigger('ORDER_CANCEL', $user); + $result = $this->call_trigger('ORDER_CANCEL', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { - $this->statut=self::STATUS_CANCELED; + $this->statut = self::STATUS_CANCELED; $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::cancel ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -800,17 +800,17 @@ class Commande extends CommonOrder */ public function create($user, $notrigger = 0) { - global $conf,$langs; - $error=0; + global $conf, $langs; + $error = 0; // Clean parameters - $this->brouillon = 1; // set command as draft + $this->brouillon = 1; // set command as draft // $date_commande is deprecated $date = ($this->date_commande ? $this->date_commande : $this->date); // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $date); + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $date); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) { @@ -822,12 +822,12 @@ class Commande extends CommonOrder dol_syslog(get_class($this)."::create user=".$user->id); // Check parameters - if (! empty($this->ref)) // We check that ref is not already used + if (!empty($this->ref)) // We check that ref is not already used { - $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used + $result = self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used if ($result > 0) { - $this->error='ErrorRefAlreadyExists'; + $this->error = 'ErrorRefAlreadyExists'; dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); $this->db->rollback(); return -1; @@ -925,7 +925,7 @@ class Commande extends CommonOrder // Complete vat rate with code $vatrate = $line->tva_tx; - if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; + if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; $result = $this->addline( $line->desc, @@ -958,7 +958,7 @@ class Commande extends CommonOrder { if ($result != self::STOCK_NOT_ENOUGH_FOR_ORDER) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_print_error($this->db); } $this->db->rollback(); @@ -971,8 +971,8 @@ class Commande extends CommonOrder } // update ref - $initialref='(PROV'.$this->id.')'; - if (! empty($this->ref)) $initialref=$this->ref; + $initialref = '(PROV'.$this->id.')'; + if (!empty($this->ref)) $initialref = $this->ref; $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id; if ($this->db->query($sql)) @@ -981,24 +981,24 @@ class Commande extends CommonOrder { $this->ref = $initialref; - if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) { - foreach($this->linked_objects as $origin => $tmp_origin_id) + foreach ($this->linked_objects as $origin => $tmp_origin_id) { if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) { - foreach($tmp_origin_id as $origin_id) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -1007,22 +1007,22 @@ class Commande extends CommonOrder { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } } } - if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object { $originforcontact = $this->origin; $originidforcontact = $this->origin_id; if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order { - require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $exp = new Expedition($this->db); $exp->fetch($this->origin_id); $exp->fetchObjectLinked(); @@ -1039,36 +1039,36 @@ class Commande extends CommonOrder } $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; + $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { - while($objcontact = $this->db->fetch_object($resqlcontact)) + while ($objcontact = $this->db->fetch_object($resqlcontact)) { //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object } } else dol_print_error($resqlcontact); } } - if (! $error) + if (!$error) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ORDER_CREATE', $user); + $result = $this->call_trigger('ORDER_CREATE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -1076,12 +1076,12 @@ class Commande extends CommonOrder else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -1105,55 +1105,55 @@ class Commande extends CommonOrder */ public function createFromClone(User $user, $socid = 0) { - global $conf, $user,$hookmanager; + global $conf, $user, $hookmanager; - $error=0; + $error = 0; $this->db->begin(); // get lines so they will be clone - foreach($this->lines as $line) + foreach ($this->lines as $line) $line->fetch_optionals(); // Load source object $objFrom = clone $this; // Change socid if needed - if (! empty($socid) && $socid != $this->socid) + if (!empty($socid) && $socid != $this->socid) { $objsoc = new Societe($this->db); - if ($objsoc->fetch($socid)>0) + if ($objsoc->fetch($socid) > 0) { - $this->socid = $objsoc->id; - $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $this->fk_project = 0; - $this->fk_delivery_address = 0; + $this->socid = $objsoc->id; + $this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $this->fk_project = 0; + $this->fk_delivery_address = 0; } // TODO Change product price if multi-prices } - $this->id=0; + $this->id = 0; $this->ref = ''; - $this->statut=self::STATUS_DRAFT; + $this->statut = self::STATUS_DRAFT; // Clear fields $this->user_author_id = $user->id; $this->user_valid = ''; - $this->date = dol_now(); - $this->date_commande = dol_now(); + $this->date = dol_now(); + $this->date_commande = dol_now(); $this->date_creation = ''; $this->date_validation = ''; if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $this->ref_client = ''; // Create clone $this->context['createfromclone'] = 'createfromclone'; - $result=$this->create($user); + $result = $this->create($user); if ($result < 0) $error++; - if (! $error) + if (!$error) { // copy internal contacts if ($this->copy_linked_contact($objFrom, 'internal') < 0) @@ -1162,7 +1162,7 @@ class Commande extends CommonOrder } } - if (! $error) + if (!$error) { // copy external contacts if same company if ($this->socid == $objFrom->socid) @@ -1172,14 +1172,14 @@ class Commande extends CommonOrder } } - if (! $error) + if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters=array('objFrom'=>$objFrom); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('objFrom'=>$objFrom); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } } @@ -1187,7 +1187,7 @@ class Commande extends CommonOrder unset($this->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -1213,13 +1213,13 @@ class Commande extends CommonOrder dol_include_once('/core/class/extrafields.class.php'); - $error=0; + $error = 0; $this->date_commande = dol_now(); $this->source = 0; - $num=count($object->lines); + $num = count($object->lines); for ($i = 0; $i < $num; $i++) { $line = new OrderLine($this->db); @@ -1242,9 +1242,9 @@ class Commande extends CommonOrder $line->rang = $object->lines[$i]->rang; $line->special_code = $object->lines[$i]->special_code; $line->fk_parent_line = $object->lines[$i]->fk_parent_line; - $line->fk_unit = $object->lines[$i]->fk_unit; + $line->fk_unit = $object->lines[$i]->fk_unit; - $line->date_start = $object->lines[$i]->date_start; + $line->date_start = $object->lines[$i]->date_start; $line->date_end = $object->lines[$i]->date_end; $line->fk_fournprice = $object->lines[$i]->fk_fournprice; @@ -1255,7 +1255,7 @@ class Commande extends CommonOrder // get extrafields from original line $object->lines[$i]->fetch_optionals(); - foreach($object->lines[$i]->array_options as $options_key => $value) + foreach ($object->lines[$i]->array_options as $options_key => $value) $line->array_options[$options_key] = $value; $this->lines[$i] = $line; @@ -1282,8 +1282,8 @@ class Commande extends CommonOrder $this->note_public = $object->note_public; } - $this->origin = $object->element; - $this->origin_id = $object->id; + $this->origin = $object->element; + $this->origin_id = $object->id; // get extrafields from original line $object->fetch_optionals($object->id); @@ -1291,14 +1291,14 @@ class Commande extends CommonOrder $e = new ExtraFields($this->db); $element_extrafields = $e->fetch_name_optionals_label($this->table_element); - foreach($object->array_options as $options_key => $value) { - if(array_key_exists(str_replace('options_', '', $options_key), $element_extrafields)){ + foreach ($object->array_options as $options_key => $value) { + if (array_key_exists(str_replace('options_', '', $options_key), $element_extrafields)) { $this->array_options[$options_key] = $value; } } // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; - if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) + if (is_array($object->other_linked_objects) && !empty($object->other_linked_objects)) { $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); } @@ -1310,12 +1310,12 @@ class Commande extends CommonOrder // Actions hooked (by external module) $hookmanager->initHooks(array('orderdao')); - $parameters=array('objFrom'=>$object); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('objFrom'=>$object); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; - if (! $error) + if (!$error) { // Ne pas passer par la commande provisoire if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1) @@ -1374,8 +1374,8 @@ class Commande extends CommonOrder global $mysoc, $conf, $langs, $user; $logtext = "::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent"; - $logtext.= ", info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start"; - $logtext.= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise"; + $logtext .= ", info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start"; + $logtext .= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise"; dol_syslog(get_class($this).$logtext, LOG_DEBUG); if ($this->statut == self::STATUS_DRAFT) @@ -1383,60 +1383,60 @@ class Commande extends CommonOrder include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters - if (empty($remise_percent)) $remise_percent=0; - if (empty($qty)) $qty=0; - if (empty($info_bits)) $info_bits=0; - if (empty($rang)) $rang=0; - if (empty($txtva)) $txtva=0; - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; - if (empty($this->fk_multicurrency)) $this->fk_multicurrency=0; + if (empty($remise_percent)) $remise_percent = 0; + if (empty($qty)) $qty = 0; + if (empty($info_bits)) $info_bits = 0; + if (empty($rang)) $rang = 0; + if (empty($txtva)) $txtva = 0; + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; + if (empty($this->fk_multicurrency)) $this->fk_multicurrency = 0; - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - $pu_ht=price2num($pu_ht); - $pu_ht_devise=price2num($pu_ht_devise); - $pu_ttc=price2num($pu_ttc); - $pa_ht=price2num($pa_ht); + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + $pu_ht = price2num($pu_ht); + $pu_ht_devise = price2num($pu_ht_devise); + $pu_ttc = price2num($pu_ttc); + $pa_ht = price2num($pa_ht); if (!preg_match('/\((.*)\)/', $txtva)) { - $txtva = price2num($txtva); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' + $txtva = price2num($txtva); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - if ($price_base_type=='HT') + if ($price_base_type == 'HT') { - $pu=$pu_ht; + $pu = $pu_ht; } else { - $pu=$pu_ttc; + $pu = $pu_ttc; } - $label=trim($label); - $desc=trim($desc); + $label = trim($label); + $desc = trim($desc); // Check parameters if ($type < 0) return -1; if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } $this->db->begin(); - $product_type=$type; + $product_type = $type; if (!empty($fk_product)) { - $product=new Product($this->db); - $result=$product->fetch($fk_product); - $product_type=$product->type; + $product = new Product($this->db); + $result = $product->fetch($fk_product); + $product_type = $product->type; - if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty) + if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref); dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR); $this->db->rollback(); return self::STOCK_NOT_ENOUGH_FOR_ORDER; @@ -1447,14 +1447,14 @@ class Commande extends CommonOrder // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); @@ -1575,7 +1575,7 @@ class Commande extends CommonOrder } else { - $this->error=$this->line->error; + $this->error = $this->line->error; dol_syslog(get_class($this)."::addline error=".$this->error, LOG_ERR); $this->db->rollback(); return -2; @@ -1609,49 +1609,49 @@ class Commande extends CommonOrder // phpcs:enable global $conf, $mysoc; - if (! $qty) $qty = 1; + if (!$qty) $qty = 1; if ($idproduct > 0) { - $prod=new Product($this->db); + $prod = new Product($this->db); $prod->fetch($idproduct); $tva_tx = get_default_tva($mysoc, $this->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $this->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr=0; - $vat_src_code = ''; // May be defined into tva_tx + if (empty($tva_tx)) $tva_npr = 0; + $vat_src_code = ''; // May be defined into tva_tx - $localtax1_tx=get_localtax($tva_tx, 1, $this->thirdparty, $mysoc, $tva_npr); - $localtax2_tx=get_localtax($tva_tx, 2, $this->thirdparty, $mysoc, $tva_npr); + $localtax1_tx = get_localtax($tva_tx, 1, $this->thirdparty, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $this->thirdparty, $mysoc, $tva_npr); // multiprix - if($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level) { + if ($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level) { $price = $prod->multiprices[$this->thirdparty->price_level]; } else { $price = $prod->price; } - $line=new OrderLine($this->db); + $line = new OrderLine($this->db); $line->context = $this->context; - $line->fk_product=$idproduct; - $line->desc=$prod->description; - $line->qty=$qty; - $line->subprice=$price; - $line->remise_percent=$remise_percent; - $line->vat_src_code=$vat_src_code; - $line->tva_tx=$tva_tx; - $line->localtax1_tx=$localtax1_tx; - $line->localtax2_tx=$localtax2_tx; - $line->ref=$prod->ref; - $line->libelle=$prod->label; - $line->product_desc=$prod->description; - $line->fk_unit=$prod->fk_unit; + $line->fk_product = $idproduct; + $line->desc = $prod->description; + $line->qty = $qty; + $line->subprice = $price; + $line->remise_percent = $remise_percent; + $line->vat_src_code = $vat_src_code; + $line->tva_tx = $tva_tx; + $line->localtax1_tx = $localtax1_tx; + $line->localtax2_tx = $localtax2_tx; + $line->ref = $prod->ref; + $line->libelle = $prod->label; + $line->product_desc = $prod->description; + $line->fk_unit = $prod->fk_unit; // Save the start and end date of the line in the object if ($date_start) { $line->date_start = $date_start; } - if ($date_end) { $line->date_end = $date_end; } + if ($date_end) { $line->date_end = $date_end; } $this->lines[] = $line; @@ -1732,56 +1732,56 @@ class Commande extends CommonOrder $obj = $this->db->fetch_object($result); if ($obj) { - $this->id = $obj->rowid; - $this->entity = $obj->entity; + $this->id = $obj->rowid; + $this->entity = $obj->entity; - $this->ref = $obj->ref; - $this->ref_client = $obj->ref_client; - $this->ref_customer = $obj->ref_client; + $this->ref = $obj->ref; + $this->ref_client = $obj->ref_client; + $this->ref_customer = $obj->ref_client; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; - $this->socid = $obj->fk_soc; - $this->statut = $obj->fk_statut; - $this->user_author_id = $obj->fk_user_author; - $this->user_valid = $obj->fk_user_valid; + $this->socid = $obj->fk_soc; + $this->statut = $obj->fk_statut; + $this->user_author_id = $obj->fk_user_author; + $this->user_valid = $obj->fk_user_valid; $this->total_ht = $obj->total_ht; $this->total_tva = $obj->total_tva; $this->total_localtax1 = $obj->total_localtax1; $this->total_localtax2 = $obj->total_localtax2; $this->total_ttc = $obj->total_ttc; - $this->date = $this->db->jdate($obj->date_commande); + $this->date = $this->db->jdate($obj->date_commande); $this->date_commande = $this->db->jdate($obj->date_commande); $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date_validation = $this->db->jdate($obj->date_valid); - $this->date_modification = $this->db->jdate($obj->tms); + $this->date_validation = $this->db->jdate($obj->date_valid); + $this->date_modification = $this->db->jdate($obj->tms); $this->remise = $obj->remise; $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; $this->source = $obj->source; $this->billed = $obj->billed; - $this->note = $obj->note_private; // deprecated - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; - $this->fk_project = $obj->fk_project; - $this->modelpdf = $obj->model_pdf; - $this->last_main_doc = $obj->last_main_doc; + $this->note = $obj->note_private; // deprecated + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->fk_project = $obj->fk_project; + $this->modelpdf = $obj->model_pdf; + $this->last_main_doc = $obj->last_main_doc; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement_libelle; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; - $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; - $this->fk_account = $obj->fk_account; - $this->availability_id = $obj->fk_availability; + $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + $this->fk_account = $obj->fk_account; + $this->availability_id = $obj->fk_availability; $this->availability_code = $obj->availability_code; $this->availability = $obj->availability_label; $this->demand_reason_id = $obj->fk_input_reason; - $this->demand_reason_code = $obj->demand_reason_code; - $this->date_livraison = $this->db->jdate($obj->date_livraison); - $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; - $this->warehouse_id = ($obj->fk_warehouse>0)?$obj->fk_warehouse:null; - $this->fk_delivery_address = $obj->fk_delivery_address; + $this->demand_reason_code = $obj->demand_reason_code; + $this->date_livraison = $this->db->jdate($obj->date_livraison); + $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; + $this->warehouse_id = ($obj->fk_warehouse > 0) ? $obj->fk_warehouse : null; + $this->fk_delivery_address = $obj->fk_delivery_address; $this->module_source = $obj->module_source; $this->pos_source = $obj->pos_source; @@ -1792,15 +1792,15 @@ class Commande extends CommonOrder // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_code = $obj->multicurrency_code; $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); - $this->lines = array(); + $this->lines = array(); if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; @@ -1813,7 +1813,7 @@ class Commande extends CommonOrder /* * Lines */ - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { return -3; @@ -1822,13 +1822,13 @@ class Commande extends CommonOrder } else { - $this->error='Order with id '.$id.' not found sql='.$sql; + $this->error = 'Order with id '.$id.' not found sql='.$sql; return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1851,42 +1851,42 @@ class Commande extends CommonOrder $this->db->begin(); - $remise=new DiscountAbsolute($this->db); - $result=$remise->fetch($idremise); + $remise = new DiscountAbsolute($this->db); + $result = $remise->fetch($idremise); if ($result > 0) { if ($remise->fk_facture) // Protection against multiple submission { - $this->error=$langs->trans("ErrorDiscountAlreadyUsed"); + $this->error = $langs->trans("ErrorDiscountAlreadyUsed"); $this->db->rollback(); return -5; } $line = new OrderLine($this->db); - $line->fk_commande=$this->id; - $line->fk_remise_except=$remise->id; - $line->desc=$remise->description; // Description ligne - $line->vat_src_code=$remise->vat_src_code; - $line->tva_tx=$remise->tva_tx; - $line->subprice=-$remise->amount_ht; - $line->price=-$remise->amount_ht; - $line->fk_product=0; // Id produit predefini - $line->qty=1; - $line->remise=0; - $line->remise_percent=0; - $line->rang=-1; - $line->info_bits=2; + $line->fk_commande = $this->id; + $line->fk_remise_except = $remise->id; + $line->desc = $remise->description; // Description ligne + $line->vat_src_code = $remise->vat_src_code; + $line->tva_tx = $remise->tva_tx; + $line->subprice = -$remise->amount_ht; + $line->price = -$remise->amount_ht; + $line->fk_product = 0; // Id produit predefini + $line->qty = 1; + $line->remise = 0; + $line->remise_percent = 0; + $line->rang = -1; + $line->info_bits = 2; $line->total_ht = -$remise->amount_ht; $line->total_tva = -$remise->amount_tva; $line->total_ttc = -$remise->amount_ttc; - $result=$line->insert(); + $result = $line->insert(); if ($result > 0) { - $result=$this->update_price(1); + $result = $this->update_price(1); if ($result > 0) { $this->db->commit(); @@ -1900,7 +1900,7 @@ class Commande extends CommonOrder } else { - $this->error=$line->error; + $this->error = $line->error; $this->db->rollback(); return -2; } @@ -1925,18 +1925,18 @@ class Commande extends CommonOrder { global $langs, $conf; // phpcs:enable - $this->lines=array(); + $this->lines = array(); $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,'; - $sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,'; - $sql.= ' l.fk_unit,'; - $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; - $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label, p.tobatch as product_tobatch,'; - $sql.= ' p.weight, p.weight_units, p.volume, p.volume_units'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)'; - $sql.= ' WHERE l.fk_commande = '.$this->id; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,'; + $sql .= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,'; + $sql .= ' l.fk_unit,'; + $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; + $sql .= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label, p.tobatch as product_tobatch,'; + $sql .= ' p.weight, p.weight_units, p.volume, p.volume_units'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'commandedet as l'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)'; + $sql .= ' WHERE l.fk_commande = '.$this->id; if ($only_product) $sql .= ' AND p.fk_product_type = 0'; $sql .= ' ORDER BY l.rang, l.rowid'; @@ -1959,7 +1959,7 @@ class Commande extends CommonOrder $line->commande_id = $objp->fk_commande; $line->label = $objp->custom_label; $line->desc = $objp->description; - $line->description = $objp->description; // Description line + $line->description = $objp->description; // Description line $line->product_type = $objp->product_type; $line->qty = $objp->qty; @@ -1979,23 +1979,23 @@ class Commande extends CommonOrder $line->remise_percent = $objp->remise_percent; $line->price = $objp->price; $line->fk_product = $objp->fk_product; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; $line->marge_tx = $marginInfos[1]; $line->marque_tx = $marginInfos[2]; $line->rang = $objp->rang; $line->info_bits = $objp->info_bits; - $line->special_code = $objp->special_code; - $line->fk_parent_line = $objp->fk_parent_line; + $line->special_code = $objp->special_code; + $line->fk_parent_line = $objp->fk_parent_line; - $line->ref = $objp->product_ref; - $line->product_ref = $objp->product_ref; - $line->libelle = $objp->product_label; - $line->product_label = $objp->product_label; + $line->ref = $objp->product_ref; + $line->product_ref = $objp->product_ref; + $line->libelle = $objp->product_label; + $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; $line->product_tobatch = $objp->product_tobatch; - $line->fk_product_type = $objp->fk_product_type; // Produit ou service + $line->fk_product_type = $objp->fk_product_type; // Produit ou service $line->fk_unit = $objp->fk_unit; $line->weight = $objp->weight; @@ -2007,8 +2007,8 @@ class Commande extends CommonOrder $line->date_end = $this->db->jdate($objp->date_end); // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; $line->multicurrency_subprice = $objp->multicurrency_subprice; $line->multicurrency_total_ht = $objp->multicurrency_total_ht; $line->multicurrency_total_tva = $objp->multicurrency_total_tva; @@ -2034,7 +2034,7 @@ class Commande extends CommonOrder } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -3; } } @@ -2047,8 +2047,8 @@ class Commande extends CommonOrder */ public function getNbOfProductsLines() { - $nb=0; - foreach($this->lines as $line) + $nb = 0; + foreach ($this->lines as $line) { if ($line->product_type == 0) $nb++; } @@ -2062,8 +2062,8 @@ class Commande extends CommonOrder */ public function getNbOfServicesLines() { - $nb=0; - foreach($this->lines as $line) + $nb = 0; + foreach ($this->lines as $line) { if ($line->product_type == 1) $nb++; } @@ -2080,11 +2080,11 @@ class Commande extends CommonOrder $nb = 0; $sql = 'SELECT COUNT(DISTINCT ed.fk_expedition) as nb'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,'; - $sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd'; - $sql.= ' WHERE'; - $sql.= ' ed.fk_origin_line = cd.rowid'; - $sql.= ' AND cd.fk_commande =' .$this->id; + $sql .= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,'; + $sql .= ' '.MAIN_DB_PREFIX.'commandedet as cd'; + $sql .= ' WHERE'; + $sql .= ' ed.fk_origin_line = cd.rowid'; + $sql .= ' AND cd.fk_commande ='.$this->id; //print $sql; dol_syslog(get_class($this)."::getNbOfShipments", LOG_DEBUG); @@ -2099,7 +2099,7 @@ class Commande extends CommonOrder } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -2116,17 +2116,17 @@ class Commande extends CommonOrder $this->expeditions = array(); $sql = 'SELECT cd.rowid, cd.fk_product,'; - $sql.= ' sum(ed.qty) as qty'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,'; - if ($filtre_statut >= 0) $sql.= ' '.MAIN_DB_PREFIX.'expedition as e,'; - $sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd'; - $sql.= ' WHERE'; - if ($filtre_statut >= 0) $sql.= ' ed.fk_expedition = e.rowid AND'; - $sql.= ' ed.fk_origin_line = cd.rowid'; - $sql.= ' AND cd.fk_commande =' .$this->id; - 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'; + $sql .= ' sum(ed.qty) as qty'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,'; + if ($filtre_statut >= 0) $sql .= ' '.MAIN_DB_PREFIX.'expedition as e,'; + $sql .= ' '.MAIN_DB_PREFIX.'commandedet as cd'; + $sql .= ' WHERE'; + if ($filtre_statut >= 0) $sql .= ' ed.fk_expedition = e.rowid AND'; + $sql .= ' ed.fk_origin_line = cd.rowid'; + $sql .= ' AND cd.fk_commande ='.$this->id; + 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'; //print $sql; dol_syslog(get_class($this)."::loadExpeditions", LOG_DEBUG); @@ -2146,7 +2146,7 @@ class Commande extends CommonOrder } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -2163,11 +2163,11 @@ class Commande extends CommonOrder { // phpcs:enable $sql = 'SELECT count(*)'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'expedition as e'; - $sql.= ', '.MAIN_DB_PREFIX.'element_element as el'; - $sql.= ' WHERE el.fk_source = '.$this->id; - $sql.= " AND el.fk_target = e.rowid"; - $sql.= " AND el.targettype = 'shipping'"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'expedition as e'; + $sql .= ', '.MAIN_DB_PREFIX.'element_element as el'; + $sql .= ' WHERE el.fk_source = '.$this->id; + $sql .= " AND el.fk_target = e.rowid"; + $sql .= " AND el.targettype = 'shipping'"; $resql = $this->db->query($sql); if ($resql) @@ -2193,16 +2193,16 @@ class Commande extends CommonOrder $this->stocks = array(); // Tableau des id de produit de la commande - $array_of_product=array(); + $array_of_product = array(); // Recherche total en stock pour chaque produit // TODO $array_of_product est défini vide juste au dessus !! if (count($array_of_product)) { $sql = "SELECT fk_product, sum(ps.reel) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; - $sql.= " WHERE ps.fk_product IN (".join(',', $array_of_product).")"; - $sql.= ' GROUP BY fk_product '; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " WHERE ps.fk_product IN (".join(',', $array_of_product).")"; + $sql .= ' GROUP BY fk_product '; $resql = $this->db->query($sql); if ($resql) { @@ -2234,8 +2234,8 @@ class Commande extends CommonOrder $this->db->begin(); $sql = "SELECT fk_product, qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet"; - $sql.= " WHERE rowid = ".$lineid; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet"; + $sql .= " WHERE rowid = ".$lineid; $result = $this->db->query($sql); if ($result) @@ -2255,7 +2255,7 @@ class Commande extends CommonOrder if ($line->delete($user) > 0) { - $result=$this->update_price(1); + $result = $this->update_price(1); if ($result > 0) { @@ -2265,14 +2265,14 @@ class Commande extends CommonOrder else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } else { $this->db->rollback(); - $this->error=$line->error; + $this->error = $line->error; return -1; } } @@ -2285,13 +2285,13 @@ class Commande extends CommonOrder else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } else { - $this->error='ErrorDeleteLineNotAllowedByObjectStatus'; + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -1; } } @@ -2308,57 +2308,57 @@ class Commande extends CommonOrder public function set_remise($user, $remise, $notrigger = 0) { // phpcs:enable - $remise=trim($remise)?trim($remise):0; + $remise = trim($remise) ?trim($remise) : 0; if ($user->rights->commande->creer) { - $error=0; + $error = 0; $this->db->begin(); - $remise=price2num($remise); + $remise = price2num($remise); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql.= ' SET remise_percent = '.$remise; - $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; + $sql .= ' SET remise_percent = '.$remise; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; $this->remise_percent = $remise; $this->update_price(1); } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('ORDER_MODIFY', $user); + $result = $this->call_trigger('ORDER_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } } @@ -2376,57 +2376,57 @@ class Commande extends CommonOrder public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable - $remise=trim($remise)?trim($remise):0; + $remise = trim($remise) ?trim($remise) : 0; if ($user->rights->commande->creer) { - $error=0; + $error = 0; $this->db->begin(); - $remise=price2num($remise); + $remise = price2num($remise); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql.= ' SET remise_absolue = '.$remise; - $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; + $sql .= ' SET remise_absolue = '.$remise; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; $this->remise_absolue = $remise; $this->update_price(1); } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('ORDER_MODIFY', $user); + $result = $this->call_trigger('ORDER_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } } @@ -2446,50 +2446,50 @@ class Commande extends CommonOrder // phpcs:enable if ($user->rights->commande->creer) { - $error=0; + $error = 0; $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; - $sql.= " SET date_commande = ".($date ? "'".$this->db->idate($date)."'" : 'null'); - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT; + $sql .= " SET date_commande = ".($date ? "'".$this->db->idate($date)."'" : 'null'); + $sql .= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; $this->date = $date; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('ORDER_MODIFY', $user); + $result = $this->call_trigger('ORDER_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else @@ -2512,50 +2512,50 @@ class Commande extends CommonOrder // phpcs:enable if ($user->rights->commande->creer) { - $error=0; + $error = 0; $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; - $sql.= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; $this->date_livraison = $date_livraison; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('ORDER_MODIFY', $user); + $result = $this->call_trigger('ORDER_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else @@ -2586,23 +2586,23 @@ class Commande extends CommonOrder $ga = array(); $sql = "SELECT s.rowid, s.nom as name, s.client,"; - $sql.= " c.rowid as cid, c.ref"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.entity IN (".getEntity('commande').")"; - $sql.= " AND c.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) //restriction + $sql .= " c.rowid as cid, c.ref"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.entity IN (".getEntity('commande').")"; + $sql .= " AND c.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) //restriction { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } - if ($socid) $sql.= " AND s.rowid = ".$socid; - if ($draft) $sql.= " AND c.fk_statut = ".self::STATUS_DRAFT; - if (is_object($excluser)) $sql.= " AND c.fk_user_author <> ".$excluser->id; - $sql.= $this->db->order($sortfield, $sortorder); - $sql.= $this->db->plimit($limit, $offset); + if ($socid) $sql .= " AND s.rowid = ".$socid; + if ($draft) $sql .= " AND c.fk_statut = ".self::STATUS_DRAFT; + if (is_object($excluser)) $sql .= " AND c.fk_user_author <> ".$excluser->id; + $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit, $offset); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { $numc = $this->db->num_rows($result); @@ -2623,7 +2623,7 @@ class Commande extends CommonOrder } else { - $ga[$i]['id'] = $obj->cid; + $ga[$i]['id'] = $obj->cid; $ga[$i]['ref'] = $obj->ref; $ga[$i]['name'] = $obj->name; } @@ -2653,7 +2653,7 @@ class Commande extends CommonOrder dol_syslog('Commande::availability('.$availability_id.')'); if ($this->statut >= self::STATUS_DRAFT) { - $error=0; + $error = 0; $this->db->begin(); @@ -2662,49 +2662,49 @@ class Commande extends CommonOrder $sql .= ' WHERE rowid='.$this->id; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; $this->availability_id = $availability_id; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('ORDER_MODIFY', $user); + $result = $this->call_trigger('ORDER_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else { - $error_str='Command status do not meet requirement '.$this->statut; + $error_str = 'Command status do not meet requirement '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR); - $this->error=$error_str; - $this->errors[]= $this->error; + $this->error = $error_str; + $this->errors[] = $this->error; return -2; } } @@ -2725,7 +2725,7 @@ class Commande extends CommonOrder dol_syslog('Commande::demand_reason('.$demand_reason_id.')'); if ($this->statut >= self::STATUS_DRAFT) { - $error=0; + $error = 0; $this->db->begin(); @@ -2734,49 +2734,49 @@ class Commande extends CommonOrder $sql .= ' WHERE rowid='.$this->id; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; $this->demand_reason_id = $demand_reason_id; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('ORDER_MODIFY', $user); + $result = $this->call_trigger('ORDER_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else { - $error_str='order status do not meet requirement '.$this->statut; + $error_str = 'order status do not meet requirement '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR); - $this->error=$error_str; - $this->errors[]= $this->error; + $this->error = $error_str; + $this->errors[] = $this->error; return -2; } } @@ -2795,49 +2795,49 @@ class Commande extends CommonOrder // phpcs:enable if ($user->rights->commande->creer) { - $error=0; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET'; - $sql.= ' ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\''); - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\''); + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; $this->ref_client = $ref_client; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('ORDER_MODIFY', $user); + $result = $this->call_trigger('ORDER_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else @@ -2916,43 +2916,43 @@ class Commande extends CommonOrder $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 0'; - $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; dol_syslog(get_class($this)."::classifyUnBilled", LOG_DEBUG); if ($this->db->query($sql)) { - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; - $this->billed=1; + $this->oldcopy = clone $this; + $this->billed = 1; } // Call trigger - $result=$this->call_trigger('ORDER_CLASSIFY_UNBILLED', $user); + $result = $this->call_trigger('ORDER_CLASSIFY_UNBILLED', $user); if ($result < 0) $error++; // End call triggers - if (! $error) + if (!$error) { - $this->billed=0; + $this->billed = 0; $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::classifyUnBilled ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -2997,28 +2997,28 @@ class Commande extends CommonOrder if ($this->statut == Commande::STATUS_DRAFT) { // Clean parameters - if (empty($qty)) $qty=0; - if (empty($info_bits)) $info_bits=0; - if (empty($txtva)) $txtva=0; - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; - if (empty($remise_percent)) $remise_percent=0; - if (empty($special_code) || $special_code == 3) $special_code=0; + if (empty($qty)) $qty = 0; + if (empty($info_bits)) $info_bits = 0; + if (empty($txtva)) $txtva = 0; + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; + if (empty($remise_percent)) $remise_percent = 0; + if (empty($special_code) || $special_code == 3) $special_code = 0; if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); $pu = price2num($pu); - $pa_ht=price2num($pa_ht); - $pu_ht_devise=price2num($pu_ht_devise); - $txtva=price2num($txtva); - $txlocaltax1=price2num($txlocaltax1); - $txlocaltax2=price2num($txlocaltax2); + $pa_ht = price2num($pa_ht); + $pu_ht_devise = price2num($pu_ht_devise); + $txtva = price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); $this->db->begin(); @@ -3027,17 +3027,17 @@ class Commande extends CommonOrder // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -3077,14 +3077,14 @@ class Commande extends CommonOrder if (!empty($line->fk_product)) { - $product=new Product($this->db); - $result=$product->fetch($line->fk_product); - $product_type=$product->type; + $product = new Product($this->db); + $result = $product->fetch($line->fk_product); + $product_type = $product->type; - if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty) + if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref); dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR); $this->db->rollback(); return self::STOCK_NOT_ENOUGH_FOR_ORDER; @@ -3121,14 +3121,14 @@ class Commande extends CommonOrder $this->line->special_code = $special_code; $this->line->total_ht = $total_ht; $this->line->total_tva = $total_tva; - $this->line->total_localtax1= $total_localtax1; - $this->line->total_localtax2= $total_localtax2; + $this->line->total_localtax1 = $total_localtax1; + $this->line->total_localtax2 = $total_localtax2; $this->line->total_ttc = $total_ttc; $this->line->date_start = $date_start; $this->line->date_end = $date_end; $this->line->product_type = $type; $this->line->fk_parent_line = $fk_parent_line; - $this->line->skip_update_total=$skip_update_total; + $this->line->skip_update_total = $skip_update_total; $this->line->fk_unit = $fk_unit; $this->line->fk_fournprice = $fk_fournprice; @@ -3141,18 +3141,18 @@ class Commande extends CommonOrder $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; // TODO deprecated - $this->line->price=$price; - $this->line->remise=$remise; + $this->line->price = $price; + $this->line->remise = $remise; - if (is_array($array_options) && count($array_options)>0) { - $this->line->array_options=$array_options; + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; } - $result=$this->line->update($user, $notrigger); + $result = $this->line->update($user, $notrigger); if ($result > 0) { // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); // Mise a jour info denormalisees $this->update_price(1); @@ -3162,7 +3162,7 @@ class Commande extends CommonOrder } else { - $this->error=$this->line->error; + $this->error = $this->line->error; $this->db->rollback(); return -1; @@ -3170,8 +3170,8 @@ class Commande extends CommonOrder } else { - $this->error=get_class($this)."::updateline Order status makes operation forbidden"; - $this->errors=array('OrderStatusMakeOperationForbidden'); + $this->error = get_class($this)."::updateline Order status makes operation forbidden"; + $this->errors = array('OrderStatusMakeOperationForbidden'); return -2; } } @@ -3187,15 +3187,15 @@ class Commande extends CommonOrder { global $conf; - $error=0; + $error = 0; // Clean parameters - if (isset($this->ref)) $this->ref=trim($this->ref); - if (isset($this->ref_client)) $this->ref_client=trim($this->ref_client); - if (isset($this->note) || isset($this->note_private)) $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); - if (isset($this->note_public)) $this->note_public=trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); - if (isset($this->import_key)) $this->import_key=trim($this->import_key); + if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client); + if (isset($this->note) || isset($this->note_private)) $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note)); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); + if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); + if (isset($this->import_key)) $this->import_key = trim($this->import_key); // Check parameters // Put here code to add control on parameters values @@ -3203,52 +3203,52 @@ class Commande extends CommonOrder // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET"; - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; - $sql.= " ref_client=".(isset($this->ref_client)?"'".$this->db->escape($this->ref_client)."'":"null").","; - $sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").","; - $sql.= " fk_soc=".(isset($this->socid)?$this->socid:"null").","; - $sql.= " date_commande=".(strval($this->date_commande)!='' ? "'".$this->db->idate($this->date_commande)."'" : 'null').","; - $sql.= " date_valid=".(strval($this->date_validation)!='' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; - $sql.= " tva=".(isset($this->total_tva)?$this->total_tva:"null").","; - $sql.= " localtax1=".(isset($this->total_localtax1)?$this->total_localtax1:"null").","; - $sql.= " localtax2=".(isset($this->total_localtax2)?$this->total_localtax2:"null").","; - $sql.= " total_ht=".(isset($this->total_ht)?$this->total_ht:"null").","; - $sql.= " total_ttc=".(isset($this->total_ttc)?$this->total_ttc:"null").","; - $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").","; - $sql.= " fk_user_author=".(isset($this->user_author_id)?$this->user_author_id:"null").","; - $sql.= " fk_user_valid=".(isset($this->user_valid)?$this->user_valid:"null").","; - $sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").","; - $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null").","; - $sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null").","; - $sql.= " fk_account=".($this->fk_account>0?$this->fk_account:"null").","; - $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; - $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; - $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").""; + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " ref_client=".(isset($this->ref_client) ? "'".$this->db->escape($this->ref_client)."'" : "null").","; + $sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").","; + $sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").","; + $sql .= " date_commande=".(strval($this->date_commande) != '' ? "'".$this->db->idate($this->date_commande)."'" : 'null').","; + $sql .= " date_valid=".(strval($this->date_validation) != '' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; + $sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; + $sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").","; + $sql .= " localtax2=".(isset($this->total_localtax2) ? $this->total_localtax2 : "null").","; + $sql .= " total_ht=".(isset($this->total_ht) ? $this->total_ht : "null").","; + $sql .= " total_ttc=".(isset($this->total_ttc) ? $this->total_ttc : "null").","; + $sql .= " fk_statut=".(isset($this->statut) ? $this->statut : "null").","; + $sql .= " fk_user_author=".(isset($this->user_author_id) ? $this->user_author_id : "null").","; + $sql .= " fk_user_valid=".(isset($this->user_valid) ? $this->user_valid : "null").","; + $sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").","; + $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").","; + $sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id : "null").","; + $sql .= " fk_account=".($this->fk_account > 0 ? $this->fk_account : "null").","; + $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; + $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; + $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ORDER_MODIFY', $user); + $result = $this->call_trigger('ORDER_MODIFY', $user); if ($result < 0) $error++; // End call triggers } @@ -3256,13 +3256,13 @@ class Commande extends CommonOrder // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -3285,14 +3285,14 @@ class Commande extends CommonOrder $error = 0; - dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG); + dol_syslog(get_class($this)."::delete ".$this->id, LOG_DEBUG); $this->db->begin(); - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ORDER_DELETE', $user); + $result = $this->call_trigger('ORDER_DELETE', $user); if ($result < 0) $error++; // End call triggers } @@ -3303,37 +3303,37 @@ class Commande extends CommonOrder $error++; } - if (! $error) + if (!$error) { // Delete order details $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE fk_commande = ".$this->id; - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } - if (! $error) + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; } - if (! $error) + if (!$error) { // Delete linked contacts $res = $this->delete_linked_contact(); if ($res < 0) $error++; } - if (! $error) + if (!$error) { // Remove 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(); + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -3373,9 +3373,9 @@ class Commande extends CommonOrder } if (file_exists($dir)) { - if (! dol_delete_dir_recursive($dir)) + if (!dol_delete_dir_recursive($dir)) { - $this->error=$langs->trans("ErrorCanNotDeleteDir", $dir); + $this->error = $langs->trans("ErrorCanNotDeleteDir", $dir); $this->db->rollback(); return 0; } @@ -3383,19 +3383,19 @@ class Commande extends CommonOrder } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -3457,7 +3457,7 @@ class Commande extends CommonOrder } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -3471,7 +3471,7 @@ class Commande extends CommonOrder { global $langs; - $label=$langs->trans('OrderSource'.$this->source); + $label = $langs->trans('OrderSource'.$this->source); if ($label == 'OrderSource') return ''; return $label; @@ -3567,11 +3567,11 @@ class Commande extends CommonOrder { global $conf, $langs, $user; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result=''; + $result = ''; - if (! empty($conf->expedition->enabled) && ($option == '1' || $option == '2')) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id; + if (!empty($conf->expedition->enabled) && ($option == '1' || $option == '2')) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id; else $url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id; if (!$user->rights->commande->lire) @@ -3580,9 +3580,9 @@ class Commande extends CommonOrder if ($option !== 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } if ($short) return $url; @@ -3597,28 +3597,28 @@ class Commande extends CommonOrder $label .= '
        '.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); } if (!empty($this->total_tva)) { - $label .= '
        '.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + $label .= '
        '.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); } if (!empty($this->total_ttc)) { $label .= '
        '.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); } } - $linkclose=''; + $linkclose = ''; if (empty($notooltip) && $user->rights->commande->lire) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowOrder"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowOrder"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; if ($option === 'nolink') { $linkstart = ''; @@ -3626,8 +3626,8 @@ class Commande extends CommonOrder } $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; return $result; @@ -3643,12 +3643,12 @@ class Commande extends CommonOrder public function info($id) { $sql = 'SELECT c.rowid, date_creation as datec, tms as datem,'; - $sql.= ' date_valid as datev,'; - $sql.= ' date_cloture as datecloture,'; - $sql.= ' fk_user_author, fk_user_valid, fk_user_cloture'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c'; - $sql.= ' WHERE c.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' date_valid as datev,'; + $sql .= ' date_cloture as datecloture,'; + $sql .= ' fk_user_author, fk_user_valid, fk_user_cloture'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'commande as c'; + $sql .= ' WHERE c.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -3659,7 +3659,7 @@ class Commande extends CommonOrder { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -3673,7 +3673,7 @@ class Commande extends CommonOrder { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); @@ -3708,8 +3708,8 @@ class Commande extends CommonOrder $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -3724,52 +3724,52 @@ class Commande extends CommonOrder } // Initialise parametres - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->socid = 1; $this->date = time(); - $this->date_lim_reglement=$this->date+3600*24*30; + $this->date_lim_reglement = $this->date + 3600 * 24 * 30; $this->cond_reglement_code = 'RECEP'; $this->mode_reglement_code = 'CHQ'; $this->availability_code = 'DSP'; $this->demand_reason_code = 'SRC_00'; - $this->note_public='This is a comment (public)'; - $this->note_private='This is a comment (private)'; + $this->note_public = 'This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; // Lines $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { - $line=new OrderLine($this->db); + $line = new OrderLine($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->qty=1; - $line->subprice=100; - $line->price=100; - $line->tva_tx=20; + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->qty = 1; + $line->subprice = 100; + $line->price = 100; + $line->tva_tx = 20; if ($xnbp == 2) { - $line->total_ht=50; - $line->total_ttc=60; - $line->total_tva=10; - $line->remise_percent=50; + $line->total_ht = 50; + $line->total_ttc = 60; + $line->total_tva = 10; + $line->remise_percent = 50; } else { - $line->total_ht=100; - $line->total_ttc=120; - $line->total_tva=20; - $line->remise_percent=0; + $line->total_ht = 100; + $line->total_ttc = 120; + $line->total_tva = 20; + $line->remise_percent = 0; } if ($num_prods > 0) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->product_ref='SPECIMEN'; + $line->fk_product = $prodids[$prodid]; + $line->product_ref = 'SPECIMEN'; } - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $this->total_ht += $line->total_ht; $this->total_tva += $line->total_tva; @@ -3818,7 +3818,7 @@ class Commande extends CommonOrder else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -3892,8 +3892,8 @@ class Commande extends CommonOrder { global $conf; - if (! ($this->statut > Commande::STATUS_DRAFT && $this->statut < Commande::STATUS_CLOSED)) { - return false; // Never late if not inside this status range + if (!($this->statut > Commande::STATUS_DRAFT && $this->statut < Commande::STATUS_CLOSED)) { + return false; // Never late if not inside this status range } $now = dol_now(); @@ -3910,9 +3910,9 @@ class Commande extends CommonOrder { global $conf, $langs; - if (empty($this->date_livraison)) $text=$langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day'); - else $text=$text=$langs->trans("DeliveryDate").' '.dol_print_date($this->date_livraison, 'day'); - $text.=' '.($conf->commande->client->warning_delay>0?'+':'-').' '.round(abs($conf->commande->client->warning_delay)/3600/24, 1).' '.$langs->trans("days").' < '.$langs->trans("Today"); + if (empty($this->date_livraison)) $text = $langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day'); + else $text = $text = $langs->trans("DeliveryDate").' '.dol_print_date($this->date_livraison, 'day'); + $text .= ' '.($conf->commande->client->warning_delay > 0 ? '+' : '-').' '.round(abs($conf->commande->client->warning_delay) / 3600 / 24, 1).' '.$langs->trans("days").' < '.$langs->trans("Today"); return $text; } @@ -3927,9 +3927,9 @@ class OrderLine extends CommonOrderLine /** * @var string ID to identify managed object */ - public $element='commandedet'; + public $element = 'commandedet'; - public $table_element='commandedet'; + public $table_element = 'commandedet'; public $oldline; @@ -3988,7 +3988,7 @@ class OrderLine extends CommonOrderLine */ public function __construct($db) { - $this->db= $db; + $this->db = $db; } /** @@ -4000,21 +4000,21 @@ class OrderLine extends CommonOrderLine public function fetch($rowid) { $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,'; - $sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,'; - $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,'; - $sql.= ' cd.fk_unit,'; - $sql.= ' cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc,'; - $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc, p.tobatch as product_tobatch,'; - $sql.= ' cd.date_start, cd.date_end'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; - $sql.= ' WHERE cd.rowid = '.$rowid; + $sql .= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,'; + $sql .= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,'; + $sql .= ' cd.fk_unit,'; + $sql .= ' cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc,'; + $sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc, p.tobatch as product_tobatch,'; + $sql .= ' cd.date_start, cd.date_end'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; + $sql .= ' WHERE cd.rowid = '.$rowid; $result = $this->db->query($sql); if ($result) { $objp = $this->db->fetch_object($result); $this->rowid = $objp->rowid; - $this->id = $objp->rowid; + $this->id = $objp->rowid; $this->fk_commande = $objp->fk_commande; $this->fk_parent_line = $objp->fk_parent_line; $this->label = $objp->custom_label; @@ -4032,24 +4032,24 @@ class OrderLine extends CommonOrderLine $this->fk_product = $objp->fk_product; $this->product_type = $objp->product_type; $this->info_bits = $objp->info_bits; - $this->special_code = $objp->special_code; + $this->special_code = $objp->special_code; $this->total_ht = $objp->total_ht; $this->total_tva = $objp->total_tva; $this->total_localtax1 = $objp->total_localtax1; $this->total_localtax2 = $objp->total_localtax2; $this->total_ttc = $objp->total_ttc; - $this->fk_fournprice = $objp->fk_fournprice; + $this->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); $this->pa_ht = $marginInfos[0]; $this->marge_tx = $marginInfos[1]; $this->marque_tx = $marginInfos[2]; - $this->special_code = $objp->special_code; - $this->rang = $objp->rang; + $this->special_code = $objp->special_code; + $this->rang = $objp->rang; - $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_libelle; // deprecated - $this->product_label = $objp->product_libelle; + $this->ref = $objp->product_ref; // deprecated + $this->product_ref = $objp->product_ref; + $this->libelle = $objp->product_libelle; // deprecated + $this->product_label = $objp->product_libelle; $this->product_desc = $objp->product_desc; $this->product_tobatch = $objp->product_tobatch; $this->fk_unit = $objp->fk_unit; @@ -4057,8 +4057,8 @@ class OrderLine extends CommonOrderLine $this->date_start = $this->db->jdate($objp->date_start); $this->date_end = $this->db->jdate($objp->date_end); - $this->fk_multicurrency = $objp->fk_multicurrency; - $this->multicurrency_code = $objp->multicurrency_code; + $this->fk_multicurrency = $objp->fk_multicurrency; + $this->multicurrency_code = $objp->multicurrency_code; $this->multicurrency_subprice = $objp->multicurrency_subprice; $this->multicurrency_total_ht = $objp->multicurrency_total_ht; $this->multicurrency_total_tva = $objp->multicurrency_total_tva; @@ -4135,10 +4135,10 @@ class OrderLine extends CommonOrderLine } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINEORDER_DELETE', $user); + $result = $this->call_trigger('LINEORDER_DELETE', $user); if ($result < 0) $error++; // End call triggers } @@ -4148,17 +4148,17 @@ class OrderLine extends CommonOrderLine return 1; } - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -4174,27 +4174,27 @@ class OrderLine extends CommonOrderLine { global $langs, $conf; - $error=0; + $error = 0; $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. dol_syslog(get_class($this)."::insert rang=".$this->rang); // Clean parameters - if (empty($this->tva_tx)) $this->tva_tx=0; - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; - if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->rang)) $this->rang=0; - if (empty($this->remise)) $this->remise=0; - if (empty($this->remise_percent)) $this->remise_percent=0; - if (empty($this->info_bits)) $this->info_bits=0; - if (empty($this->special_code)) $this->special_code=0; - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; - if (empty($this->pa_ht)) $this->pa_ht=0; + if (empty($this->tva_tx)) $this->tva_tx = 0; + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; + if (empty($this->localtax1_type)) $this->localtax1_type = 0; + if (empty($this->localtax2_type)) $this->localtax2_type = 0; + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; + if (empty($this->rang)) $this->rang = 0; + if (empty($this->remise)) $this->remise = 0; + if (empty($this->remise_percent)) $this->remise_percent = 0; + if (empty($this->info_bits)) $this->info_bits = 0; + if (empty($this->special_code)) $this->special_code = 0; + if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; + if (empty($this->pa_ht)) $this->pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) @@ -4292,17 +4292,17 @@ class OrderLine extends CommonOrderLine return 1; } - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -2; } @@ -4317,30 +4317,30 @@ class OrderLine extends CommonOrderLine */ public function update(User $user, $notrigger = 0) { - global $conf,$langs; + global $conf, $langs; - $error=0; + $error = 0; $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. // Clean parameters - if (empty($this->tva_tx)) $this->tva_tx=0; - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; - if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; - if (empty($this->qty)) $this->qty=0; - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->marque_tx)) $this->marque_tx=0; - if (empty($this->marge_tx)) $this->marge_tx=0; - if (empty($this->remise)) $this->remise=0; - if (empty($this->remise_percent)) $this->remise_percent=0; - if (empty($this->info_bits)) $this->info_bits=0; - if (empty($this->special_code)) $this->special_code=0; - if (empty($this->product_type)) $this->product_type=0; - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; - if (empty($this->pa_ht)) $this->pa_ht=0; + if (empty($this->tva_tx)) $this->tva_tx = 0; + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; + if (empty($this->localtax1_type)) $this->localtax1_type = 0; + if (empty($this->localtax2_type)) $this->localtax2_type = 0; + if (empty($this->qty)) $this->qty = 0; + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; + if (empty($this->marque_tx)) $this->marque_tx = 0; + if (empty($this->marge_tx)) $this->marge_tx = 0; + if (empty($this->remise)) $this->remise = 0; + if (empty($this->remise_percent)) $this->remise_percent = 0; + if (empty($this->info_bits)) $this->info_bits = 0; + if (empty($this->special_code)) $this->special_code = 0; + if (empty($this->product_type)) $this->product_type = 0; + if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; + if (empty($this->pa_ht)) $this->pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) @@ -4359,64 +4359,64 @@ class OrderLine extends CommonOrderLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; - $sql.= " description='".$this->db->escape($this->desc)."'"; - $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); - $sql.= " , vat_src_code=".(! empty($this->vat_src_code)?"'".$this->db->escape($this->vat_src_code)."'":"''"); - $sql.= " , tva_tx=".price2num($this->tva_tx); - $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); - $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); - $sql.= " , localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql.= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; - $sql.= " , qty=".price2num($this->qty); - $sql.= " , subprice=".price2num($this->subprice).""; - $sql.= " , remise_percent=".price2num($this->remise_percent).""; - $sql.= " , price=".price2num($this->price).""; // TODO A virer - $sql.= " , remise=".price2num($this->remise).""; // TODO A virer + $sql .= " description='".$this->db->escape($this->desc)."'"; + $sql .= " , label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= " , vat_src_code=".(!empty($this->vat_src_code) ? "'".$this->db->escape($this->vat_src_code)."'" : "''"); + $sql .= " , tva_tx=".price2num($this->tva_tx); + $sql .= " , localtax1_tx=".price2num($this->localtax1_tx); + $sql .= " , localtax2_tx=".price2num($this->localtax2_tx); + $sql .= " , localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql .= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql .= " , qty=".price2num($this->qty); + $sql .= " , subprice=".price2num($this->subprice).""; + $sql .= " , remise_percent=".price2num($this->remise_percent).""; + $sql .= " , price=".price2num($this->price).""; // TODO A virer + $sql .= " , remise=".price2num($this->remise).""; // TODO A virer if (empty($this->skip_update_total)) { - $sql.= " , total_ht=".price2num($this->total_ht).""; - $sql.= " , total_tva=".price2num($this->total_tva).""; - $sql.= " , total_ttc=".price2num($this->total_ttc).""; - $sql.= " , total_localtax1=".price2num($this->total_localtax1); - $sql.= " , total_localtax2=".price2num($this->total_localtax2); + $sql .= " , total_ht=".price2num($this->total_ht).""; + $sql .= " , total_tva=".price2num($this->total_tva).""; + $sql .= " , total_ttc=".price2num($this->total_ttc).""; + $sql .= " , total_localtax1=".price2num($this->total_localtax1); + $sql .= " , total_localtax2=".price2num($this->total_localtax2); } - $sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?$this->fk_fournprice:"null"); - $sql.= " , buy_price_ht='".price2num($this->pa_ht)."'"; - $sql.= " , info_bits=".$this->info_bits; - $sql.= " , special_code=".$this->special_code; - $sql.= " , date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null"); - $sql.= " , date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); - $sql.= " , product_type=".$this->product_type; - $sql.= " , fk_parent_line=".(! empty($this->fk_parent_line)?$this->fk_parent_line:"null"); - if (! empty($this->rang)) $sql.= ", rang=".$this->rang; - $sql.= " , fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= " , fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? $this->fk_fournprice : "null"); + $sql .= " , buy_price_ht='".price2num($this->pa_ht)."'"; + $sql .= " , info_bits=".$this->info_bits; + $sql .= " , special_code=".$this->special_code; + $sql .= " , date_start=".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null"); + $sql .= " , date_end=".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null"); + $sql .= " , product_type=".$this->product_type; + $sql .= " , fk_parent_line=".(!empty($this->fk_parent_line) ? $this->fk_parent_line : "null"); + if (!empty($this->rang)) $sql .= ", rang=".$this->rang; + $sql .= " , fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); // Multicurrency - $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; + $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; + $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; + $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $this->id=$this->rowid; - $result=$this->insertExtraFields(); + $this->id = $this->rowid; + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINEORDER_UPDATE', $user); + $result = $this->call_trigger('LINEORDER_UPDATE', $user); if ($result < 0) $error++; // End call triggers } @@ -4426,17 +4426,17 @@ class OrderLine extends CommonOrderLine return 1; } - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -2; } @@ -4455,21 +4455,21 @@ class OrderLine extends CommonOrderLine $this->db->begin(); // Clean parameters - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; - $sql.= " total_ht='".price2num($this->total_ht)."'"; - $sql.= ",total_tva='".price2num($this->total_tva)."'"; - $sql.= ",total_localtax1='".price2num($this->total_localtax1)."'"; - $sql.= ",total_localtax2='".price2num($this->total_localtax2)."'"; - $sql.= ",total_ttc='".price2num($this->total_ttc)."'"; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " total_ht='".price2num($this->total_ht)."'"; + $sql .= ",total_tva='".price2num($this->total_tva)."'"; + $sql .= ",total_localtax1='".price2num($this->total_localtax1)."'"; + $sql .= ",total_localtax2='".price2num($this->total_localtax2)."'"; + $sql .= ",total_ttc='".price2num($this->total_ttc)."'"; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog("OrderLine::update_total", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); @@ -4477,7 +4477,7 @@ class OrderLine extends CommonOrderLine } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -2; } diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 1a250a83b10..b70a3ba2c77 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -25,11 +25,11 @@ * \brief Page de gestion des documents attaches a un compte bancaire */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . "/core/lib/bank.lib.php"; -require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; -require_once DOL_DOCUMENT_ROOT . "/core/lib/images.lib.php"; -require_once DOL_DOCUMENT_ROOT . "/core/class/html.formfile.class.php"; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/bank.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'companies', 'other')); @@ -79,10 +79,10 @@ $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); if ($object->id > 0) { $object->fetch_thirdparty(); - $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref); } -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -108,7 +108,7 @@ if ($id > 0 || !empty($ref)) { $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); $totalsize = 0; foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } $morehtmlref = ''; @@ -122,8 +122,8 @@ if ($id > 0 || !empty($ref)) { print '
        '; print ''; - print ''; - print ''; + print ''; + print ''; print "
        ' . $langs->trans("NbOfAttachedFiles") . '' . count($filearray) . '
        ' . $langs->trans("TotalSizeOfAttachedFiles") . '' .dol_print_size($totalsize, 1, 1).'
        '.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
        '.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
        \n"; print ''; @@ -134,8 +134,8 @@ if ($id > 0 || !empty($ref)) { $modulepart = 'bank'; $permission = $user->rights->banque->modifier; $permtoedit = $user->rights->banque->modifier; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { dol_print_error($db); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 2244a73b02a..8dc5fa9c0d1 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -64,8 +64,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='b.label'; -if (! $sortorder) $sortorder='ASC'; +if (!$sortfield) $sortfield = 'b.label'; +if (!$sortorder) $sortorder = 'ASC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Account($db); @@ -82,14 +82,14 @@ $fieldstosearchall = array( 'b.label'=>'Label', ); -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1), 'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1), 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1), - 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(! empty($conf->accounting->enabled) || ! empty($conf->accounting->enabled))), - 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(! empty($conf->accounting->enabled) || ! empty($conf->accounting->enabled))), + 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), + 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1), 'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0), 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), @@ -114,11 +114,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -126,10 +126,10 @@ 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_ref=''; - $search_label=''; - $search_number=''; - $search_status=''; + $search_ref = ''; + $search_label = ''; + $search_number = ''; + $search_status = ''; } @@ -179,7 +179,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -249,89 +249,89 @@ print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bank', 0, $newcardbutton, '', $limit, 1); -$topicmail="Information"; +$topicmail = "Information"; //$modelmail="subscription"; -$objecttmp=new Account($db); +$objecttmp = new Account($db); //$trackid='sub'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
        '.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
        '; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
        '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
        '; } -$moreforfilter=''; +$moreforfilter = ''; // Bank accounts -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
        '; print $moreforfilter; print '
        '; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '
        '; -print ''."\n"; +print '
        '."\n"; print ''; // Ref -if (! empty($arrayfields['b.ref']['checked'])) +if (!empty($arrayfields['b.ref']['checked'])) { print ''; } // Label -if (! empty($arrayfields['b.label']['checked'])) +if (!empty($arrayfields['b.label']['checked'])) { print ''; } // Account type -if (! empty($arrayfields['accountype']['checked'])) +if (!empty($arrayfields['accountype']['checked'])) { print ''; } // Bank number -if (! empty($arrayfields['b.number']['checked'])) +if (!empty($arrayfields['b.number']['checked'])) { print ''; } // Account number -if (! empty($arrayfields['b.account_number']['checked'])) +if (!empty($arrayfields['b.account_number']['checked'])) { print ''; } // Accountancy journal -if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) +if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { print ''; } // Transactions to reconcile -if (! empty($arrayfields['toreconcile']['checked'])) +if (!empty($arrayfields['toreconcile']['checked'])) { print ''; } // Currency -if (! empty($arrayfields['b.currency_code']['checked'])) +if (!empty($arrayfields['b.currency_code']['checked'])) { print ''; @@ -340,26 +340,26 @@ if (! empty($arrayfields['b.currency_code']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (! empty($arrayfields['b.datec']['checked'])) +if (!empty($arrayfields['b.datec']['checked'])) { print ''; } // Date modification -if (! empty($arrayfields['b.tms']['checked'])) +if (!empty($arrayfields['b.tms']['checked'])) { print ''; } // Status -if (! empty($arrayfields['b.clos']['checked'])) +if (!empty($arrayfields['b.clos']['checked'])) { print ''; } // Balance -if (! empty($arrayfields['balance']['checked'])) +if (!empty($arrayfields['balance']['checked'])) { print ''; } // Action column print ''; print ''; // Fields title print ''; -if (! empty($arrayfields['b.ref']['checked'])) print_liste_field_titre($arrayfields['b.ref']['label'], $_SERVER["PHP_SELF"], 'b.ref', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER["PHP_SELF"], 'b.label', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['accountype']['checked'])) print_liste_field_titre($arrayfields['accountype']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'], $_SERVER["PHP_SELF"], 'b.number', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'], $_SERVER["PHP_SELF"], 'b.account_number', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'], $_SERVER["PHP_SELF"], 'b.fk_accountancy_journal', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.currency_code']['checked'])) print_liste_field_titre($arrayfields['b.currency_code']['label'], $_SERVER["PHP_SELF"], 'b.currency_code', '', $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['b.ref']['checked'])) print_liste_field_titre($arrayfields['b.ref']['label'], $_SERVER["PHP_SELF"], 'b.ref', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER["PHP_SELF"], 'b.label', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['accountype']['checked'])) print_liste_field_titre($arrayfields['accountype']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'], $_SERVER["PHP_SELF"], 'b.number', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'], $_SERVER["PHP_SELF"], 'b.account_number', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'], $_SERVER["PHP_SELF"], 'b.fk_accountancy_journal', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.currency_code']['checked'])) print_liste_field_titre($arrayfields['b.currency_code']['label'], $_SERVER["PHP_SELF"], 'b.currency_code', '', $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$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 +$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; -if (! empty($arrayfields['b.datec']['checked'])) print_liste_field_titre($arrayfields['b.datec']['label'], $_SERVER["PHP_SELF"], "b.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['b.tms']['checked'])) print_liste_field_titre($arrayfields['b.tms']['label'], $_SERVER["PHP_SELF"], "b.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['b.clos']['checked'])) print_liste_field_titre($arrayfields['b.clos']['label'], $_SERVER["PHP_SELF"], 'b.clos', '', $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['b.datec']['checked'])) print_liste_field_titre($arrayfields['b.datec']['label'], $_SERVER["PHP_SELF"], "b.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['b.tms']['checked'])) print_liste_field_titre($arrayfields['b.tms']['label'], $_SERVER["PHP_SELF"], "b.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['b.clos']['checked'])) print_liste_field_titre($arrayfields['b.clos']['label'], $_SERVER["PHP_SELF"], 'b.clos', '', $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; -$total = array(); $found = 0; $i=0; $lastcurrencycode=''; +$total = array(); $found = 0; $i = 0; $lastcurrencycode = ''; foreach ($accounts as $key=>$type) { @@ -488,26 +488,26 @@ foreach ($accounts as $key=>$type) print ''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Currency - if (! empty($arrayfields['b.currency_code']['checked'])) + if (!empty($arrayfields['b.currency_code']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Transactions to reconcile - if (! empty($arrayfields['toreconcile']['checked'])) + if (!empty($arrayfields['toreconcile']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 7070946e2c7..b144ab58392 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -125,11 +125,11 @@ if ($object->id) print '
        '; // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } print '
        '; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; - $array=array( + $array = array( 'opened'=>$langs->trans("Opened"), 'closed'=>$langs->trans("Closed") ); @@ -367,42 +367,42 @@ if (! empty($arrayfields['b.clos']['checked'])) print ''; -$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); +$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print '
        '; print $objecttmp->currency_code; print ''; if ($objecttmp->rappro) { - $result=$objecttmp->load_board($user, $objecttmp->id); - if ($result<0) { + $result = $objecttmp->load_board($user, $objecttmp->id); + if ($result < 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); } else { print ''.$result->nbtodo.''; @@ -571,12 +571,12 @@ foreach ($accounts as $key=>$type) print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($objecttmp->id, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($objecttmp->id, $arrayofselected)) $selected = 1; + print ''; } print '
        '; @@ -146,8 +146,8 @@ if ($object->id) $modulepart = 'banque'; $permission = $user->rights->banque->modifier; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index d73d6d8a391..d279041e2af 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -175,7 +175,7 @@ if ($result) print_barre_liste($langs->trans("VariousPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'invoicing', 0, $newcardbutton, '', $limit); print '
        '; - print '
        '."\n"; + print '
        '."\n"; print ''; @@ -200,7 +200,7 @@ if ($result) print ''; // Account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''; } @@ -236,23 +236,23 @@ if ($result) print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "v.label", "", $param, '', $sortfield, $sortorder, 'left '); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "v.datep,v.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'left '); - 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, '', $sortfield, $sortorder, 'left '); + 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, '', $sortfield, $sortorder, 'left '); print_liste_field_titre("Debit", $_SERVER["PHP_SELF"], "v.amount", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Credit", $_SERVER["PHP_SELF"], "v.amount", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; - $totalarray=array(); + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($result); print ''; - $variousstatic->id=$obj->rowid; - $variousstatic->ref=$obj->rowid; + $variousstatic->id = $obj->rowid; + $variousstatic->ref = $obj->rowid; // Ref print "\n"; @@ -271,24 +271,24 @@ if ($result) if (! $i) $totalarray['nbfield']++; // Account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print '"; print ""; - $i=0; + $i = 0; while ($i < $num) { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 90c673e9e25..dc3581eaf20 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -65,23 +65,23 @@ function dol_dir_list($path, $types = "all", $recursive = 0, $filter = "", $excl dol_syslog("files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".json_encode($excludefilter)); //print 'xxx'."files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".json_encode($excludefilter); - $loaddate=($mode==1||$mode==2)?true:false; - $loadsize=($mode==1||$mode==3)?true:false; + $loaddate = ($mode == 1 || $mode == 2) ?true:false; + $loadsize = ($mode == 1 || $mode == 3) ?true:false; // Clean parameters - $path=preg_replace('/([\\/]+)$/i', '', $path); - $newpath=dol_osencode($path); + $path = preg_replace('/([\\/]+)$/i', '', $path); + $newpath = dol_osencode($path); $reshook = 0; $file_list = array(); - if (is_object($hookmanager) && ! $nohook) + if (is_object($hookmanager) && !$nohook) { - $hookmanager->resArray=array(); + $hookmanager->resArray = array(); $hookmanager->initHooks(array('fileslib')); - $parameters=array( + $parameters = array( 'path' => $newpath, 'types'=> $types, 'recursive' => $recursive, @@ -93,63 +93,63 @@ function dol_dir_list($path, $types = "all", $recursive = 0, $filter = "", $excl 'loadsize' => $loadsize, 'mode' => $mode ); - $reshook=$hookmanager->executeHooks('getDirList', $parameters, $object); + $reshook = $hookmanager->executeHooks('getDirList', $parameters, $object); } // $hookmanager->resArray may contain array stacked by other modules if (empty($reshook)) { - if (! is_dir($newpath)) return array(); + if (!is_dir($newpath)) return array(); if ($dir = opendir($newpath)) { - $filedate=''; - $filesize=''; + $filedate = ''; + $filesize = ''; while (false !== ($file = readdir($dir))) // $file is always a basename (into directory $newpath) { - if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in utf8 in memory - $fullpathfile=($newpath?$newpath.'/':'').$file; + if (!utf8_check($file)) $file = utf8_encode($file); // To be sure data is stored in utf8 in memory + $fullpathfile = ($newpath ? $newpath.'/' : '').$file; - $qualified=1; + $qualified = 1; // Define excludefilterarray - $excludefilterarray=array('^\.'); + $excludefilterarray = array('^\.'); if (is_array($excludefilter)) { - $excludefilterarray=array_merge($excludefilterarray, $excludefilter); + $excludefilterarray = array_merge($excludefilterarray, $excludefilter); } - elseif ($excludefilter) $excludefilterarray[]=$excludefilter; + elseif ($excludefilter) $excludefilterarray[] = $excludefilter; // Check if file is qualified - foreach($excludefilterarray as $filt) + foreach ($excludefilterarray as $filt) { if (preg_match('/'.$filt.'/i', $file) || preg_match('/'.$filt.'/i', $fullpathfile)) { - $qualified=0; break; + $qualified = 0; break; } } //print $fullpathfile.' '.$file.' '.$qualified.'
        '; if ($qualified) { - $isdir=is_dir(dol_osencode($path."/".$file)); + $isdir = is_dir(dol_osencode($path."/".$file)); // Check whether this is a file or directory and whether we're interested in that type - if ($isdir && (($types=="directories") || ($types=="all") || $recursive)) + if ($isdir && (($types == "directories") || ($types == "all") || $recursive)) { // Add entry into file_list array - if (($types=="directories") || ($types=="all")) + if (($types == "directories") || ($types == "all")) { - if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file); - if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file); + if ($loaddate || $sortcriteria == 'date') $filedate = dol_filemtime($path."/".$file); + if ($loadsize || $sortcriteria == 'size') $filesize = dol_filesize($path."/".$file); - if (! $filter || preg_match('/'.$filter.'/i', $file)) // We do not search key $filter into all $path, only into $file part + if (!$filter || preg_match('/'.$filter.'/i', $file)) // We do not search key $filter into all $path, only into $file part { preg_match('/([^\/]+)\/[^\/]+$/', $path.'/'.$file, $reg); - $level1name=(isset($reg[1])?$reg[1]:''); + $level1name = (isset($reg[1]) ? $reg[1] : ''); $file_list[] = array( "name" => $file, "path" => $path, "level1name" => $level1name, - "relativename" => ($relativename?$relativename.'/':'').$file, + "relativename" => ($relativename ? $relativename.'/' : '').$file, "fullname" => $path.'/'.$file, "date" => $filedate, "size" => $filesize, @@ -161,28 +161,28 @@ function dol_dir_list($path, $types = "all", $recursive = 0, $filter = "", $excl // if we're in a directory and we want recursive behavior, call this function again if ($recursive) { - if (empty($donotfollowsymlinks) || ! is_link($path."/".$file)) + if (empty($donotfollowsymlinks) || !is_link($path."/".$file)) { //var_dump('eee '. $path."/".$file. ' '.is_dir($path."/".$file).' '.is_link($path."/".$file)); - $file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename!=''?$relativename.'/':'').$file, $donotfollowsymlinks)); + $file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename != '' ? $relativename.'/' : '').$file, $donotfollowsymlinks)); } } } - elseif (! $isdir && (($types == "files") || ($types == "all"))) + elseif (!$isdir && (($types == "files") || ($types == "all"))) { // Add file into file_list array - if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file); - if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file); + if ($loaddate || $sortcriteria == 'date') $filedate = dol_filemtime($path."/".$file); + if ($loadsize || $sortcriteria == 'size') $filesize = dol_filesize($path."/".$file); - if (! $filter || preg_match('/'.$filter.'/i', $file)) // We do not search key $filter into $path, only into $file + if (!$filter || preg_match('/'.$filter.'/i', $file)) // We do not search key $filter into $path, only into $file { preg_match('/([^\/]+)\/[^\/]+$/', $path.'/'.$file, $reg); - $level1name=(isset($reg[1])?$reg[1]:''); + $level1name = (isset($reg[1]) ? $reg[1] : ''); $file_list[] = array( "name" => $file, "path" => $path, "level1name" => $level1name, - "relativename" => ($relativename?$relativename.'/':'').$file, + "relativename" => ($relativename ? $relativename.'/' : '').$file, "fullname" => $path.'/'.$file, "date" => $filedate, "size" => $filesize, @@ -225,17 +225,17 @@ function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $s { global $conf, $db; - $sql =" SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m,"; - $sql.=" acl, position, share"; - if ($mode) $sql.=", description"; - $sql.=" FROM ".MAIN_DB_PREFIX."ecm_files"; - $sql.=" WHERE filepath = '".$db->escape($path)."'"; - $sql.=" AND entity = ".$conf->entity; + $sql = " SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m,"; + $sql .= " acl, position, share"; + if ($mode) $sql .= ", description"; + $sql .= " FROM ".MAIN_DB_PREFIX."ecm_files"; + $sql .= " WHERE filepath = '".$db->escape($path)."'"; + $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $file_list=array(); + $file_list = array(); $num = $db->num_rows($resql); $i = 0; while ($i < $num) @@ -244,10 +244,10 @@ function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $s if ($obj) { preg_match('/([^\/]+)\/[^\/]+$/', DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename, $reg); - $level1name=(isset($reg[1])?$reg[1]:''); + $level1name = (isset($reg[1]) ? $reg[1] : ''); $file_list[] = array( "rowid" => $obj->rowid, - "label" => $obj->label, // md5 + "label" => $obj->label, // md5 "name" => $obj->filename, "path" => DOL_DATA_ROOT.'/'.$obj->filepath, "level1name" => $level1name, @@ -267,12 +267,12 @@ function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $s } // Obtain a list of columns - if (! empty($sortcriteria)) + if (!empty($sortcriteria)) { - $myarray=array(); + $myarray = array(); foreach ($file_list as $key => $row) { - $myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:''); + $myarray[$key] = (isset($row[$sortcriteria]) ? $row[$sortcriteria] : ''); } // Sort the data if ($sortorder) array_multisort($myarray, $sortorder, $file_list); @@ -304,11 +304,11 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) // TODO Remove this when PRODUCT_USE_OLD_PATH_FOR_PHOTO will be removed global $modulepart; - if ($modulepart == 'produit' && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { + if ($modulepart == 'produit' && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { global $object; - if (! empty($object->id)) + if (!empty($object->id)) { - if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + if (!empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; $relativedirold = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dirold); @@ -322,38 +322,38 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) //var_dump($filearrayindatabase); // Complete filearray with properties found into $filearrayindatabase - foreach($filearray as $key => $val) + foreach ($filearray as $key => $val) { - $found=0; + $found = 0; // Search if it exists into $filearrayindatabase - foreach($filearrayindatabase as $key2 => $val2) + foreach ($filearrayindatabase as $key2 => $val2) { if ($filearrayindatabase[$key2]['name'] == $filearray[$key]['name']) { - $filearray[$key]['position_name']=($filearrayindatabase[$key2]['position']?$filearrayindatabase[$key2]['position']:'0').'_'.$filearrayindatabase[$key2]['name']; - $filearray[$key]['position']=$filearrayindatabase[$key2]['position']; - $filearray[$key]['cover']=$filearrayindatabase[$key2]['cover']; - $filearray[$key]['acl']=$filearrayindatabase[$key2]['acl']; - $filearray[$key]['rowid']=$filearrayindatabase[$key2]['rowid']; - $filearray[$key]['label']=$filearrayindatabase[$key2]['label']; - $filearray[$key]['share']=$filearrayindatabase[$key2]['share']; - $found=1; + $filearray[$key]['position_name'] = ($filearrayindatabase[$key2]['position'] ? $filearrayindatabase[$key2]['position'] : '0').'_'.$filearrayindatabase[$key2]['name']; + $filearray[$key]['position'] = $filearrayindatabase[$key2]['position']; + $filearray[$key]['cover'] = $filearrayindatabase[$key2]['cover']; + $filearray[$key]['acl'] = $filearrayindatabase[$key2]['acl']; + $filearray[$key]['rowid'] = $filearrayindatabase[$key2]['rowid']; + $filearray[$key]['label'] = $filearrayindatabase[$key2]['label']; + $filearray[$key]['share'] = $filearrayindatabase[$key2]['share']; + $found = 1; break; } } - if (! $found) // This happen in transition toward version 6, or if files were added manually into os dir. + if (!$found) // This happen in transition toward version 6, or if files were added manually into os dir. { - $filearray[$key]['position']='999999'; // File not indexed are at end. So if we add a file, it will not replace an existing position - $filearray[$key]['cover']=0; - $filearray[$key]['acl']=''; + $filearray[$key]['position'] = '999999'; // File not indexed are at end. So if we add a file, it will not replace an existing position + $filearray[$key]['cover'] = 0; + $filearray[$key]['acl'] = ''; $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filearray[$key]['fullname']); - if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file + if (!preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file { dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it"); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($db); + $ecmfile = new EcmFiles($db); // Add entry into database $filename = basename($rel_filename); @@ -363,11 +363,11 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) $ecmfile->filepath = $rel_dir; $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($filearray[$key]['fullname'])); // $destfile is a full path to file + $ecmfile->label = md5_file(dol_osencode($filearray[$key]['fullname'])); // $destfile is a full path to file $ecmfile->fullpath_orig = $filearray[$key]['fullname']; $ecmfile->gen_or_uploaded = 'unknown'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content $result = $ecmfile->create($user); if ($result < 0) { @@ -375,12 +375,12 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) } else { - $filearray[$key]['rowid']=$result; + $filearray[$key]['rowid'] = $result; } } else { - $filearray[$key]['rowid']=0; // Should not happened + $filearray[$key]['rowid'] = 0; // Should not happened } } } @@ -401,10 +401,10 @@ function dol_compare_file($a, $b) global $sortorder; global $sortfield; - $sortorder=strtoupper($sortorder); + $sortorder = strtoupper($sortorder); - if ($sortorder == 'ASC') { $retup=-1; $retdown=1; } - else { $retup=1; $retdown=-1; } + if ($sortorder == 'ASC') { $retup = -1; $retdown = 1; } + else { $retup = 1; $retdown = -1; } if ($sortfield == 'name') { @@ -432,7 +432,7 @@ function dol_compare_file($a, $b) */ function dol_is_dir($folder) { - $newfolder=dol_osencode($folder); + $newfolder = dol_osencode($folder); if (is_dir($newfolder)) return true; else return false; } @@ -457,7 +457,7 @@ function dol_is_dir_empty($dir) */ function dol_is_file($pathoffile) { - $newpathoffile=dol_osencode($pathoffile); + $newpathoffile = dol_osencode($pathoffile); return is_file($newpathoffile); } @@ -469,7 +469,7 @@ function dol_is_file($pathoffile) */ function dol_is_link($pathoffile) { - $newpathoffile=dol_osencode($pathoffile); + $newpathoffile = dol_osencode($pathoffile); return is_link($newpathoffile); } @@ -481,8 +481,8 @@ function dol_is_link($pathoffile) */ function dol_is_url($url) { - $tmpprot=array('file','http','https','ftp','zlib','data','ssh','ssh2','ogg','expect'); - foreach($tmpprot as $prot) + $tmpprot = array('file', 'http', 'https', 'ftp', 'zlib', 'data', 'ssh', 'ssh2', 'ogg', 'expect'); + foreach ($tmpprot as $prot) { if (preg_match('/^'.$prot.':/i', $url)) return true; } @@ -497,7 +497,7 @@ function dol_is_url($url) */ function dol_dir_is_emtpy($folder) { - $newfolder=dol_osencode($folder); + $newfolder = dol_osencode($folder); if (is_dir($newfolder)) { $handle = opendir($newfolder); @@ -506,7 +506,7 @@ function dol_dir_is_emtpy($folder) { $name_array[] = $name; } - foreach($name_array as $temp) $folder_content .= $temp; + foreach ($name_array as $temp) $folder_content .= $temp; closedir($handle); @@ -526,24 +526,24 @@ function dol_dir_is_emtpy($folder) */ function dol_count_nb_of_line($file) { - $nb=0; + $nb = 0; - $newfile=dol_osencode($file); + $newfile = dol_osencode($file); //print 'x'.$file; - $fp=fopen($newfile, 'r'); + $fp = fopen($newfile, 'r'); if ($fp) { while (!feof($fp)) { - $line=fgets($fp); + $line = fgets($fp); // We increase count only if read was success. We need test because feof return true only after fgets so we do n+1 fgets for a file with n lines. - if (! $line === false) $nb++; + if (!$line === false) $nb++; } fclose($fp); } else { - $nb=-1; + $nb = -1; } return $nb; @@ -559,7 +559,7 @@ function dol_count_nb_of_line($file) */ function dol_filesize($pathoffile) { - $newpathoffile=dol_osencode($pathoffile); + $newpathoffile = dol_osencode($pathoffile); return filesize($newpathoffile); } @@ -571,7 +571,7 @@ function dol_filesize($pathoffile) */ function dol_filemtime($pathoffile) { - $newpathoffile=dol_osencode($pathoffile); + $newpathoffile = dol_osencode($pathoffile); return @filemtime($newpathoffile); // @Is to avoid errors if files does not exists } @@ -594,24 +594,24 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask dol_syslog("files.lib.php::dolReplaceInFile srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." indexdatabase=".$indexdatabase." arrayreplacementisregex=".$arrayreplacementisregex); if (empty($srcfile)) return -1; - if (empty($destfile)) $destfile=$srcfile; + if (empty($destfile)) $destfile = $srcfile; - $destexists=dol_is_file($destfile); + $destexists = dol_is_file($destfile); if (($destfile != $srcfile) && $destexists) return 0; - $tmpdestfile=$destfile.'.tmp'; + $tmpdestfile = $destfile.'.tmp'; - $newpathofsrcfile=dol_osencode($srcfile); - $newpathoftmpdestfile=dol_osencode($tmpdestfile); - $newpathofdestfile=dol_osencode($destfile); - $newdirdestfile=dirname($newpathofdestfile); + $newpathofsrcfile = dol_osencode($srcfile); + $newpathoftmpdestfile = dol_osencode($tmpdestfile); + $newpathofdestfile = dol_osencode($destfile); + $newdirdestfile = dirname($newpathofdestfile); - if ($destexists && ! is_writable($newpathofdestfile)) + if ($destexists && !is_writable($newpathofdestfile)) { dol_syslog("files.lib.php::dolReplaceInFile failed Permission denied to overwrite target file", LOG_WARNING); return -1; } - if (! is_writable($newdirdestfile)) + if (!is_writable($newdirdestfile)) { dol_syslog("files.lib.php::dolReplaceInFile failed Permission denied to write into target directory ".$newdirdestfile, LOG_WARNING); return -2; @@ -638,17 +638,17 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask @chmod($newpathoftmpdestfile, octdec($newmask)); // Rename - $result=dol_move($newpathoftmpdestfile, $newpathofdestfile, $newmask, (($destfile == $srcfile)?1:0), 0, $indexdatabase); - if (! $result) + $result = dol_move($newpathoftmpdestfile, $newpathofdestfile, $newmask, (($destfile == $srcfile) ? 1 : 0), 0, $indexdatabase); + if (!$result) { dol_syslog("files.lib.php::dolReplaceInFile failed to move tmp file to final dest", LOG_WARNING); return -3; } - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; + if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; if (empty($newmask)) // This should no happen { dol_syslog("Warning: dolReplaceInFile called with empty value for newmask and no default value defined", LOG_WARNING); - $newmask='0664'; + $newmask = '0664'; } @chmod($newpathofdestfile, octdec($newmask)); @@ -675,36 +675,36 @@ function dol_copy($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1) if (empty($srcfile) || empty($destfile)) return -1; - $destexists=dol_is_file($destfile); - if (! $overwriteifexists && $destexists) return 0; + $destexists = dol_is_file($destfile); + if (!$overwriteifexists && $destexists) return 0; - $newpathofsrcfile=dol_osencode($srcfile); - $newpathofdestfile=dol_osencode($destfile); - $newdirdestfile=dirname($newpathofdestfile); + $newpathofsrcfile = dol_osencode($srcfile); + $newpathofdestfile = dol_osencode($destfile); + $newdirdestfile = dirname($newpathofdestfile); - if ($destexists && ! is_writable($newpathofdestfile)) + if ($destexists && !is_writable($newpathofdestfile)) { dol_syslog("files.lib.php::dol_copy failed Permission denied to overwrite target file", LOG_WARNING); return -1; } - if (! is_writable($newdirdestfile)) + if (!is_writable($newdirdestfile)) { dol_syslog("files.lib.php::dol_copy failed Permission denied to write into target directory ".$newdirdestfile, LOG_WARNING); return -2; } // Copy with overwriting if exists - $result=@copy($newpathofsrcfile, $newpathofdestfile); + $result = @copy($newpathofsrcfile, $newpathofdestfile); //$result=copy($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @ - if (! $result) + if (!$result) { dol_syslog("files.lib.php::dol_copy failed to copy", LOG_WARNING); return -3; } - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; + if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; if (empty($newmask)) // This should no happen { dol_syslog("Warning: dol_copy called with empty value for newmask and no default value defined", LOG_WARNING); - $newmask='0664'; + $newmask = '0664'; } @chmod($newpathofdestfile, octdec($newmask)); @@ -727,40 +727,40 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep { global $conf; - $result=0; + $result = 0; dol_syslog("files.lib.php::dolCopyDir srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists); if (empty($srcfile) || empty($destfile)) return -1; - $destexists=dol_is_dir($destfile); + $destexists = dol_is_dir($destfile); //if (! $overwriteifexists && $destexists) return 0; // The overwriteifexists is for files only, so propagated to dol_copy only. - if (! $destexists) + if (!$destexists) { // We must set mask just before creating dir, becaause it can be set differently by dol_copy umask(0); - $dirmaskdec=octdec($newmask); - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK); - $dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files + $dirmaskdec = octdec($newmask); + if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) $dirmaskdec = octdec($conf->global->MAIN_UMASK); + $dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files dol_mkdir($destfile, '', decoct($dirmaskdec)); } - $ossrcfile=dol_osencode($srcfile); - $osdestfile=dol_osencode($destfile); + $ossrcfile = dol_osencode($srcfile); + $osdestfile = dol_osencode($destfile); // Recursive function to copy all subdirectories and contents: if (is_dir($ossrcfile)) { - $dir_handle=opendir($ossrcfile); - while ($file=readdir($dir_handle)) + $dir_handle = opendir($ossrcfile); + while ($file = readdir($dir_handle)) { - if ($file != "." && $file != ".." && ! is_link($ossrcfile."/".$file)) + if ($file != "." && $file != ".." && !is_link($ossrcfile."/".$file)) { if (is_dir($ossrcfile."/".$file)) { //var_dump("xxx dolCopyDir $srcfile/$file, $destfile/$file, $newmask, $overwriteifexists"); - $tmpresult=dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement); + $tmpresult = dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement); } else { @@ -768,12 +768,12 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep // Replace destination filename with a new one if (is_array($arrayreplacement)) { - foreach($arrayreplacement as $key => $val) + foreach ($arrayreplacement as $key => $val) { $newfile = str_replace($key, $val, $newfile); } } - $tmpresult=dol_copy($srcfile."/".$file, $destfile."/".$newfile, $newmask, $overwriteifexists); + $tmpresult = dol_copy($srcfile."/".$file, $destfile."/".$newfile, $newmask, $overwriteifexists); } // Set result if ($result > 0 && $tmpresult >= 0) @@ -782,7 +782,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep } else { - $result=$tmpresult; + $result = $tmpresult; } if ($result < 0) break; } @@ -818,28 +818,28 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $testvirus = 0, $indexdatabase = 1) { global $user, $db, $conf; - $result=false; + $result = false; dol_syslog("files.lib.php::dol_move srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists); - $srcexists=dol_is_file($srcfile); - $destexists=dol_is_file($destfile); + $srcexists = dol_is_file($srcfile); + $destexists = dol_is_file($destfile); - if (! $srcexists) + if (!$srcexists) { dol_syslog("files.lib.php::dol_move srcfile does not exists. we ignore the move request."); return false; } - if ($overwriteifexists || ! $destexists) + if ($overwriteifexists || !$destexists) { - $newpathofsrcfile=dol_osencode($srcfile); - $newpathofdestfile=dol_osencode($destfile); + $newpathofsrcfile = dol_osencode($srcfile); + $newpathofdestfile = dol_osencode($destfile); // Check virus - $testvirusarray=array(); + $testvirusarray = array(); if ($testvirus) { - $testvirusarray=dolCheckVirus($newpathofsrcfile); + $testvirusarray = dolCheckVirus($newpathofsrcfile); if (count($testvirusarray)) { dol_syslog("files.lib.php::dol_move canceled because a virus was found into source file. we ignore the move request.", LOG_WARNING); @@ -847,15 +847,15 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te } } - $result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @ - if (! $result) + $result = @rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @ + if (!$result) { if ($destexists) { dol_syslog("files.lib.php::dol_move Failed. We try to delete target first and move after.", LOG_WARNING); // We force delete and try again. Rename function sometimes fails to replace dest file with some windows NTFS partitions. dol_delete_file($destfile); - $result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @ + $result = @rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @ } else dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING); } @@ -866,7 +866,7 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te // Rename entry into ecm database $rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $srcfile); $rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $destfile); - if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file + if (!preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file { $rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore); $rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter); @@ -875,14 +875,14 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te dol_syslog("Try to rename also entries in database for full relative path before = ".$rel_filetorenamebefore." after = ".$rel_filetorenameafter, LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfiletarget=new EcmFiles($db); + $ecmfiletarget = new EcmFiles($db); $resultecmtarget = $ecmfiletarget->fetch(0, '', $rel_filetorenameafter); if ($resultecmtarget > 0) // An entry for target name already exists for target, we delete it, a new one will be created. { $ecmfiletarget->delete($user); } - $ecmfile=new EcmFiles($db); + $ecmfile = new EcmFiles($db); $resultecm = $ecmfile->fetch(0, '', $rel_filetorenamebefore); if ($resultecm > 0) // If an entry was found for src file, we use it to move entry { @@ -904,11 +904,11 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te $ecmfile->filepath = $rel_dir; $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($destfile)); // $destfile is a full path to file + $ecmfile->label = md5_file(dol_osencode($destfile)); // $destfile is a full path to file $ecmfile->fullpath_orig = $srcfile; $ecmfile->gen_or_uploaded = 'unknown'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content $resultecm = $ecmfile->create($user); if ($resultecm < 0) { @@ -920,13 +920,13 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); } - if ($resultecm > 0) $result=true; + if ($resultecm > 0) $result = true; else $result = false; } } - if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK; - $newmaskdec=octdec($newmask); + if (empty($newmask)) $newmask = empty($conf->global->MAIN_UMASK) ? '0755' : $conf->global->MAIN_UMASK; + $newmaskdec = octdec($newmask); // Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too) // to allow mask usage for dir, we shoul introduce a new param "isdir" to 1 to complete newmask like this // if ($isdir) $newmaskdec |= octdec('0111'); // Set x bit required for directories @@ -962,16 +962,16 @@ function dolCheckVirus($src_file) { global $conf; - if (! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) + if (!empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) { - if (! class_exists('AntiVir')) { + if (!class_exists('AntiVir')) { require_once DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php'; } - $antivir=new AntiVir($db); + $antivir = new AntiVir($db); $result = $antivir->dol_avscan_file($src_file); if ($result < 0) // If virus or error, we stop here { - $reterrors=$antivir->errors; + $reterrors = $antivir->errors; return $reterrors; } } @@ -1003,15 +1003,15 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable global $conf, $db, $user, $langs; global $object, $hookmanager; - $reshook=0; + $reshook = 0; $file_name = $dest_file; if (empty($nohook)) { - $reshook=$hookmanager->initHooks(array('fileslib')); + $reshook = $hookmanager->initHooks(array('fileslib')); - $parameters=array('dest_file' => $dest_file, 'src_file' => $src_file, 'file_name' => $file_name, 'varfiles' => $varfiles, 'allowoverwrite' => $allowoverwrite); - $reshook=$hookmanager->executeHooks('moveUploadedFile', $parameters, $object); + $parameters = array('dest_file' => $dest_file, 'src_file' => $src_file, 'file_name' => $file_name, 'varfiles' => $varfiles, 'allowoverwrite' => $allowoverwrite); + $reshook = $hookmanager->executeHooks('moveUploadedFile', $parameters, $object); } if (empty($reshook)) @@ -1019,7 +1019,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable // If an upload error has been reported if ($uploaderrorcode) { - switch($uploaderrorcode) + switch ($uploaderrorcode) { case UPLOAD_ERR_INI_SIZE: // 1 return 'ErrorFileSizeTooLarge'; @@ -1041,7 +1041,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable // If we need to make a virus scan if (empty($disablevirusscan) && file_exists($src_file)) { - $checkvirusarray=dolCheckVirus($src_file); + $checkvirusarray = dolCheckVirus($src_file); if (count($checkvirusarray)) { dol_syslog('Files.lib::dol_move_uploaded_file File "'.$src_file.'" (target name "'.$dest_file.'") KO with antivirus: errors='.join(',', $checkvirusarray), LOG_WARNING); @@ -1054,7 +1054,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code. if (isAFileWithExecutableContent($dest_file) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) { - $file_name.= '.noexe'; + $file_name .= '.noexe'; } // Security: @@ -1077,24 +1077,24 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable if ($reshook < 0) // At least one blocking error returned by one hook { $errmsg = join(',', $hookmanager->errors); - if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks'; // Should not occurs. Added if hook is bugged and does not set ->errors when there is error. + if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks'; // Should not occurs. Added if hook is bugged and does not set ->errors when there is error. return $errmsg; } elseif (empty($reshook)) { // The file functions must be in OS filesystem encoding. - $src_file_osencoded=dol_osencode($src_file); - $file_name_osencoded=dol_osencode($file_name); + $src_file_osencoded = dol_osencode($src_file); + $file_name_osencoded = dol_osencode($file_name); // Check if destination dir is writable - if (! is_writable(dirname($file_name_osencoded))) + if (!is_writable(dirname($file_name_osencoded))) { dol_syslog("Files.lib::dol_move_uploaded_file Dir ".dirname($file_name_osencoded)." is not writable. Return 'ErrorDirNotWritable'", LOG_WARNING); return 'ErrorDirNotWritable'; } // Check if destination file already exists - if (! $allowoverwrite) + if (!$allowoverwrite) { if (file_exists($file_name_osencoded)) { @@ -1104,21 +1104,21 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable } // Move file - $return=move_uploaded_file($src_file_osencoded, $file_name_osencoded); + $return = move_uploaded_file($src_file_osencoded, $file_name_osencoded); if ($return) { - if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK)); + if (!empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK)); dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG); - return 1; // Success + return 1; // Success } else { dol_syslog("Files.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR); - return -3; // Unknown error + return -3; // Unknown error } } - return 1; // Success + return 1; // Success } /** @@ -1147,7 +1147,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, // Security: // We refuse transversal using .. and pipes into filenames. - if ((! $allowdotdot && preg_match('/\.\./', $file)) || preg_match('/[<>|]/', $file)) + if ((!$allowdotdot && preg_match('/\.\./', $file)) || preg_match('/[<>|]/', $file)) { dol_syslog("Refused to delete file ".$file, LOG_WARNING); return false; @@ -1157,13 +1157,13 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, { $hookmanager->initHooks(array('fileslib')); - $parameters=array( + $parameters = array( 'GET' => $_GET, 'file' => $file, 'disableglob'=> $disableglob, 'nophperrors' => $nophperrors ); - $reshook=$hookmanager->executeHooks('deleteFile', $parameters, $object); + $reshook = $hookmanager->executeHooks('deleteFile', $parameters, $object); } if (empty($nohook) && $reshook != 0) // reshook = 0 to do standard actions, 1 = ok, -1 = ko @@ -1173,29 +1173,29 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, } else { - $error=0; + $error = 0; //print "x".$file." ".$disableglob;exit; - $file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset - if (empty($disableglob) && ! empty($file_osencoded)) + $file_osencoded = dol_osencode($file); // New filename encoded in OS filesystem encoding charset + if (empty($disableglob) && !empty($file_osencoded)) { - $ok=true; - $globencoded=str_replace('[', '\[', $file_osencoded); - $globencoded=str_replace(']', '\]', $globencoded); - $listofdir=glob($globencoded); - if (! empty($listofdir) && is_array($listofdir)) + $ok = true; + $globencoded = str_replace('[', '\[', $file_osencoded); + $globencoded = str_replace(']', '\]', $globencoded); + $listofdir = glob($globencoded); + if (!empty($listofdir) && is_array($listofdir)) { foreach ($listofdir as $filename) { - if ($nophperrors) $ok=@unlink($filename); - else $ok=unlink($filename); + if ($nophperrors) $ok = @unlink($filename); + else $ok = unlink($filename); if ($ok) { dol_syslog("Removed file ".$filename, LOG_DEBUG); // Delete entry into ecm database $rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filename); - if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) // If not a tmp file + if (!preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) // If not a tmp file { $rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete); @@ -1203,7 +1203,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, { dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($db); + $ecmfile = new EcmFiles($db); $result = $ecmfile->fetch(0, '', $rel_filetodelete); if ($result >= 0 && $ecmfile->id > 0) { @@ -1228,9 +1228,9 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, } else { - $ok=false; - if ($nophperrors) $ok=@unlink($file_osencoded); - else $ok=unlink($file_osencoded); + $ok = false; + if ($nophperrors) $ok = @unlink($file_osencoded); + else $ok = unlink($file_osencoded); if ($ok) dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG); else dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING); } @@ -1258,8 +1258,8 @@ function dol_delete_dir($dir, $nophperrors = 0) return false; } - $dir_osencoded=dol_osencode($dir); - return ($nophperrors?@rmdir($dir_osencoded):rmdir($dir_osencoded)); + $dir_osencoded = dol_osencode($dir); + return ($nophperrors ? @rmdir($dir_osencoded) : rmdir($dir_osencoded)); } /** @@ -1277,22 +1277,22 @@ function dol_delete_dir_recursive($dir, $count = 0, $nophperrors = 0, $onlysub = dol_syslog("functions.lib:dol_delete_dir_recursive ".$dir, LOG_DEBUG); if (dol_is_dir($dir)) { - $dir_osencoded=dol_osencode($dir); + $dir_osencoded = dol_osencode($dir); if ($handle = opendir("$dir_osencoded")) { while (false !== ($item = readdir($handle))) { - if (! utf8_check($item)) $item=utf8_encode($item); // should be useless + if (!utf8_check($item)) $item = utf8_encode($item); // should be useless if ($item != "." && $item != "..") { - if (is_dir(dol_osencode("$dir/$item")) && ! is_link(dol_osencode("$dir/$item"))) + if (is_dir(dol_osencode("$dir/$item")) && !is_link(dol_osencode("$dir/$item"))) { - $count=dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted); + $count = dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted); } else { - $result=dol_delete_file("$dir/$item", 1, $nophperrors); + $result = dol_delete_file("$dir/$item", 1, $nophperrors); $count++; if ($result) $countdeleted++; //else print 'Error on '.$item."\n"; @@ -1303,7 +1303,7 @@ function dol_delete_dir_recursive($dir, $count = 0, $nophperrors = 0, $onlysub = if (empty($onlysub)) { - $result=dol_delete_dir($dir, $nophperrors); + $result = dol_delete_dir($dir, $nophperrors); $count++; if ($result) $countdeleted++; //else print 'Error on '.$dir."\n"; @@ -1325,7 +1325,7 @@ function dol_delete_dir_recursive($dir, $count = 0, $nophperrors = 0, $onlysub = */ function dol_delete_preview($object) { - global $langs,$conf; + global $langs, $conf; // Define parent dir of elements $element = $object->element; @@ -1336,54 +1336,54 @@ function dol_delete_preview($object) elseif ($object->element == 'shipping') $dir = $conf->expedition->dir_output.'/sending'; elseif ($object->element == 'delivery') $dir = $conf->expedition->dir_output.'/receipt'; elseif ($object->element == 'fichinter') $dir = $conf->ficheinter->dir_output; - else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; + else $dir = empty($conf->$element->dir_output) ? '' : $conf->$element->dir_output; if (empty($dir)) return 'ErrorObjectNoSupportedByFunction'; $refsan = dol_sanitizeFileName($object->ref); - $dir = $dir . "/" . $refsan ; - $filepreviewnew = $dir . "/" . $refsan . ".pdf_preview.png"; - $filepreviewnewbis = $dir . "/" . $refsan . ".pdf_preview-0.png"; - $filepreviewold = $dir . "/" . $refsan . ".pdf.png"; + $dir = $dir."/".$refsan; + $filepreviewnew = $dir."/".$refsan.".pdf_preview.png"; + $filepreviewnewbis = $dir."/".$refsan.".pdf_preview-0.png"; + $filepreviewold = $dir."/".$refsan.".pdf.png"; // For new preview files if (file_exists($filepreviewnew) && is_writable($filepreviewnew)) { - if (! dol_delete_file($filepreviewnew, 1)) + if (!dol_delete_file($filepreviewnew, 1)) { - $object->error=$langs->trans("ErrorFailedToDeleteFile", $filepreviewnew); + $object->error = $langs->trans("ErrorFailedToDeleteFile", $filepreviewnew); return 0; } } if (file_exists($filepreviewnewbis) && is_writable($filepreviewnewbis)) { - if (! dol_delete_file($filepreviewnewbis, 1)) + if (!dol_delete_file($filepreviewnewbis, 1)) { - $object->error=$langs->trans("ErrorFailedToDeleteFile", $filepreviewnewbis); + $object->error = $langs->trans("ErrorFailedToDeleteFile", $filepreviewnewbis); return 0; } } // For old preview files if (file_exists($filepreviewold) && is_writable($filepreviewold)) { - if (! dol_delete_file($filepreviewold, 1)) + if (!dol_delete_file($filepreviewold, 1)) { - $object->error=$langs->trans("ErrorFailedToDeleteFile", $filepreviewold); + $object->error = $langs->trans("ErrorFailedToDeleteFile", $filepreviewold); return 0; } } else { - $multiple = $filepreviewold . "."; + $multiple = $filepreviewold."."; for ($i = 0; $i < 20; $i++) { $preview = $multiple.$i; if (file_exists($preview) && is_writable($preview)) { - if ( ! dol_delete_file($preview, 1) ) + if (!dol_delete_file($preview, 1)) { - $object->error=$langs->trans("ErrorFailedToOpenFile", $preview); + $object->error = $langs->trans("ErrorFailedToOpenFile", $preview); return 0; } } @@ -1406,10 +1406,10 @@ function dol_meta_create($object) global $conf; // Create meta file - if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0; // By default, no metafile. + if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0; // By default, no metafile. // Define parent dir of elements - $element=$object->element; + $element = $object->element; if ($object->element == 'order_supplier') $dir = $conf->fournisseur->dir_output.'/commande'; elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->dir_output.'/facture'; @@ -1417,17 +1417,17 @@ function dol_meta_create($object) elseif ($object->element == 'shipping') $dir = $conf->expedition->dir_output.'/sending'; elseif ($object->element == 'delivery') $dir = $conf->expedition->dir_output.'/receipt'; elseif ($object->element == 'fichinter') $dir = $conf->ficheinter->dir_output; - else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; + else $dir = empty($conf->$element->dir_output) ? '' : $conf->$element->dir_output; if ($dir) { $object->fetch_thirdparty(); $objectref = dol_sanitizeFileName($object->ref); - $dir = $dir . "/" . $objectref; - $file = $dir . "/" . $objectref . ".meta"; + $dir = $dir."/".$objectref; + $file = $dir."/".$objectref.".meta"; - if (! is_dir($dir)) + if (!is_dir($dir)) { dol_mkdir($dir); } @@ -1457,7 +1457,7 @@ function dol_meta_create($object) $fp = fopen($file, "w"); fputs($fp, $meta); fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); return 1; @@ -1482,24 +1482,24 @@ function dol_meta_create($object) */ function dol_init_file_process($pathtoscan = '', $trackid = '') { - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); + $listofpaths = array(); + $listofnames = array(); + $listofmimes = array(); if ($pathtoscan) { - $listoffiles=dol_dir_list($pathtoscan, 'files'); - foreach($listoffiles as $key => $val) + $listoffiles = dol_dir_list($pathtoscan, 'files'); + foreach ($listoffiles as $key => $val) { - $listofpaths[]=$val['fullname']; - $listofnames[]=$val['name']; - $listofmimes[]=dol_mimetype($val['name']); + $listofpaths[] = $val['fullname']; + $listofnames[] = $val['name']; + $listofmimes[] = dol_mimetype($val['name']); } } - $keytoavoidconflict = empty($trackid)?'':'-'.$trackid; - $_SESSION["listofpaths".$keytoavoidconflict]=join(';', $listofpaths); - $_SESSION["listofnames".$keytoavoidconflict]=join(';', $listofnames); - $_SESSION["listofmimes".$keytoavoidconflict]=join(';', $listofmimes); + $keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid; + $_SESSION["listofpaths".$keytoavoidconflict] = join(';', $listofpaths); + $_SESSION["listofnames".$keytoavoidconflict] = join(';', $listofnames); + $_SESSION["listofmimes".$keytoavoidconflict] = join(';', $listofmimes); } @@ -1520,11 +1520,11 @@ function dol_init_file_process($pathtoscan = '', $trackid = '') */ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesession = 0, $varfiles = 'addedfile', $savingdocmask = '', $link = null, $trackid = '', $generatethumbs = 1) { - global $db,$user,$conf,$langs; + global $db, $user, $conf, $langs; $res = 0; - if (! empty($_FILES[$varfiles])) // For view $_FILES[$varfiles]['error'] + if (!empty($_FILES[$varfiles])) // For view $_FILES[$varfiles]['error'] { dol_syslog('dol_add_file_process upload_dir='.$upload_dir.' allowoverwrite='.$allowoverwrite.' donotupdatesession='.$donotupdatesession.' savingdocmask='.$savingdocmask, LOG_DEBUG); if (dol_mkdir($upload_dir) >= 0) @@ -1633,7 +1633,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess } } } elseif ($link) { - require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $linkObject = new Link($db); $linkObject->entity = $conf->entity; $linkObject->url = $link; @@ -1670,25 +1670,25 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess */ function dol_remove_file_process($filenb, $donotupdatesession = 0, $donotdeletefile = 1, $trackid = '') { - global $db,$user,$conf,$langs,$_FILES; + global $db, $user, $conf, $langs, $_FILES; - $keytodelete=$filenb; + $keytodelete = $filenb; $keytodelete--; - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); - $keytoavoidconflict = empty($trackid)?'':'-'.$trackid; - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';', $_SESSION["listofnames".$keytoavoidconflict]); - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); + $listofpaths = array(); + $listofnames = array(); + $listofmimes = array(); + $keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid; + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); if ($keytodelete >= 0) { - $pathtodelete=$listofpaths[$keytodelete]; - $filetodelete=$listofnames[$keytodelete]; - if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete, 1); // The delete of ecm database is inside the function dol_delete_file - else $result=0; + $pathtodelete = $listofpaths[$keytodelete]; + $filetodelete = $listofnames[$keytodelete]; + if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete, 1); // The delete of ecm database is inside the function dol_delete_file + else $result = 0; if ($result >= 0) { if (empty($donotdeletefile)) @@ -1728,21 +1728,21 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $dir); - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir { $filename = basename($file); $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($db); + $ecmfile = new EcmFiles($db); $ecmfile->filepath = $rel_dir; $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($dir.'/'.$file)); // MD5 of file content + $ecmfile->label = md5_file(dol_osencode($dir.'/'.$file)); // MD5 of file content $ecmfile->fullpath_orig = $fullpathorig; $ecmfile->gen_or_uploaded = $mode; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content if ($setsharekey) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; @@ -1788,26 +1788,26 @@ function deleteFilesIntoDatabaseIndex($dir, $file, $mode = 'uploaded') $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); - if (! $error) + if (!$error) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'ecm_files'; - $sql.= ' WHERE entity = '.$conf->entity; - $sql.= " AND filepath = '" . $db->escape($rel_dir) . "'"; - if ($file) $sql.= " AND filename = '" . $db->escape($file) . "'"; - if ($mode) $sql.= " AND gen_or_uploaded = '" . $db->escape($mode) . "'"; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'ecm_files'; + $sql .= ' WHERE entity = '.$conf->entity; + $sql .= " AND filepath = '".$db->escape($rel_dir)."'"; + if ($file) $sql .= " AND filename = '".$db->escape($file)."'"; + if ($mode) $sql .= " AND gen_or_uploaded = '".$db->escape($mode)."'"; $resql = $db->query($sql); if (!$resql) { $error++; - dol_syslog(__METHOD__ . ' ' . $db->lasterror(), LOG_ERR); + dol_syslog(__METHOD__.' '.$db->lasterror(), LOG_ERR); } } // Commit or rollback if ($error) { $db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $db->commit(); return 1; @@ -1830,12 +1830,12 @@ function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '', $page = '' global $langs; if (class_exists('Imagick')) { - $image=new Imagick(); + $image = new Imagick(); try { - $filetoconvert=$fileinput.(($page != '')?'['.$page.']':''); + $filetoconvert = $fileinput.(($page != '') ? '['.$page.']' : ''); //var_dump($filetoconvert); $ret = $image->readImage($filetoconvert); - } catch(Exception $e) { + } catch (Exception $e) { $ext = pathinfo($fileinput, PATHINFO_EXTENSION); dol_syslog("Failed to read image using Imagick (Try to install package 'apt-get install php-imagick ghostscript' and check there is no policy to disable ".$ext." convertion in /etc/ImageMagick*/policy.xml): ".$e->getMessage(), LOG_WARNING); return 0; @@ -2031,20 +2031,20 @@ function dol_uncompress($inputfile, $outputdir) dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir); include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php'; $archive = new PclZip($inputfile); - $result=$archive->extract(PCLZIP_OPT_PATH, $outputdir); + $result = $archive->extract(PCLZIP_OPT_PATH, $outputdir); //var_dump($result); - if (! is_array($result) && $result <= 0) return array('error'=>$archive->errorInfo(true)); + if (!is_array($result) && $result <= 0) return array('error'=>$archive->errorInfo(true)); else { - $ok=1; $errmsg=''; + $ok = 1; $errmsg = ''; // Loop on each file to check result for unzipping file - foreach($result as $key => $val) + foreach ($result as $key => $val) { if ($val['status'] == 'path_creation_fail') { $langs->load("errors"); - $ok=0; - $errmsg=$langs->trans("ErrorFailToCreateDir", $val['filename']); + $ok = 0; + $errmsg = $langs->trans("ErrorFailToCreateDir", $val['filename']); break; } } @@ -2118,7 +2118,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = //if (class_exists('ZipArchive') && ! empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_COMPRESS)) if (class_exists('ZipArchive')) { - $foundhandler=1; + $foundhandler = 1; // Initialize archive object $zip = new ZipArchive(); @@ -2161,7 +2161,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = } } - if (! $foundhandler) + if (!$foundhandler) { dol_syslog("Try to zip with format ".$mode." with no handler for this format", LOG_ERR); return -2; @@ -2177,7 +2177,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = $langs->load("errors"); dol_syslog("Failed to open file ".$outputfile, LOG_ERR); dol_syslog($e->getMessage(), LOG_ERR); - $errormsg=$langs->trans("ErrorFailedToWriteInDir", $outputfile); + $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputfile); return -1; } } @@ -2194,9 +2194,9 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @return string Full path to most recent file */ -function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('(\.meta|_preview.*\.png)$','^\.'), $nohook = false, $mode = '') +function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('(\.meta|_preview.*\.png)$', '^\.'), $nohook = false, $mode = '') { - $tmparray=dol_dir_list($dir, 'files', 0, $regexfilter, $excludefilter, 'date', SORT_DESC, $mode, $nohook); + $tmparray = dol_dir_list($dir, 'files', 0, $regexfilter, $excludefilter, 'date', SORT_DESC, $mode, $nohook); return $tmparray[0]; } @@ -2486,9 +2486,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); if ($fuser->rights->societe->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->societe->multidir_output[$entity].'/'.$original_file; + $original_file = $conf->societe->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$db->escape($refname)."' AND entity IN (".getEntity('societe').")"; } @@ -2498,9 +2498,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); if ($fuser->rights->societe->{$lire}) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->societe->multidir_output[$entity].'/contact/'.$original_file; + $original_file = $conf->societe->multidir_output[$entity].'/contact/'.$original_file; } // Wrapping for invoices @@ -2600,9 +2600,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->ficheinter->dir_output.'/'.$original_file; + $original_file = $conf->ficheinter->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } @@ -2611,9 +2611,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->deplacement->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->deplacement->dir_output.'/'.$original_file; + $original_file = $conf->deplacement->dir_output.'/'.$original_file; //$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } // Wrapping pour les propales @@ -2621,9 +2621,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->propale->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->propal->multidir_output[$entity].'/'.$original_file; + $original_file = $conf->propal->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."propal WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } @@ -2643,18 +2643,18 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->projet->dir_output.'/'.$original_file; + $original_file = $conf->projet->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")"; } elseif ($modulepart == 'project_task' && !empty($conf->projet->dir_output)) { if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->projet->dir_output.'/'.$original_file; + $original_file = $conf->projet->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")"; } @@ -2663,9 +2663,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file; + $original_file = $conf->fournisseur->commande->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } @@ -2684,9 +2684,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->fournisseur->payment->dir_output.'/'.$original_file; + $original_file = $conf->fournisseur->payment->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."paiementfournisseur WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } @@ -2695,10 +2695,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - if ($fuser->societe_id > 0) $original_file=$conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file; - else $original_file=$conf->facture->dir_output.'/payments/'.$original_file; + if ($fuser->societe_id > 0) $original_file = $conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file; + else $original_file = $conf->facture->dir_output.'/payments/'.$original_file; } // Wrapping for accounting exports @@ -2706,9 +2706,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->accounting->bind->write || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->accounting->dir_output.'/'.$original_file; + $original_file = $conf->accounting->dir_output.'/'.$original_file; } // Wrapping pour les expedition @@ -2716,18 +2716,18 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->expedition->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->expedition->dir_output."/sending/".$original_file; + $original_file = $conf->expedition->dir_output."/sending/".$original_file; } // Wrapping pour les bons de livraison elseif ($modulepart == 'livraison' && !empty($conf->expedition->dir_output)) { if ($fuser->rights->expedition->livraison->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->expedition->dir_output."/receipt/".$original_file; + $original_file = $conf->expedition->dir_output."/receipt/".$original_file; } // Wrapping pour les actions @@ -2735,9 +2735,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->agenda->myactions->{$read} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->agenda->dir_output.'/'.$original_file; + $original_file = $conf->agenda->dir_output.'/'.$original_file; } // Wrapping pour les actions @@ -2745,7 +2745,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->agenda->allactions->{$read} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } $original_file = $conf->agenda->dir_temp."/".$original_file; } @@ -2756,10 +2756,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (empty($entity) || (empty($conf->product->multidir_output[$entity]) && empty($conf->service->multidir_output[$entity]))) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); if (($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - if (! empty($conf->product->enabled)) $original_file=$conf->product->multidir_output[$entity].'/'.$original_file; - elseif (! empty($conf->service->enabled)) $original_file=$conf->service->multidir_output[$entity].'/'.$original_file; + if (!empty($conf->product->enabled)) $original_file = $conf->product->multidir_output[$entity].'/'.$original_file; + elseif (!empty($conf->service->enabled)) $original_file = $conf->service->multidir_output[$entity].'/'.$original_file; } // Wrapping pour les lots produits @@ -2768,9 +2768,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (empty($entity) || (empty($conf->productbatch->multidir_output[$entity]))) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); if (($fuser->rights->produit->{$lire} ) || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - if (! empty($conf->productbatch->enabled)) $original_file=$conf->productbatch->multidir_output[$entity].'/'.$original_file; + if (!empty($conf->productbatch->enabled)) $original_file = $conf->productbatch->multidir_output[$entity].'/'.$original_file; } // Wrapping for stock movements @@ -2779,9 +2779,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (empty($entity) || empty($conf->stock->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); if (($fuser->rights->stock->{$lire} || $fuser->rights->stock->movement->{$lire} || $fuser->rights->stock->mouvement->{$lire}) || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - if (! empty($conf->stock->enabled)) $original_file=$conf->stock->multidir_output[$entity].'/movement/'.$original_file; + if (!empty($conf->stock->enabled)) $original_file = $conf->stock->multidir_output[$entity].'/movement/'.$original_file; } // Wrapping pour les contrats @@ -2789,9 +2789,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->contrat->dir_output.'/'.$original_file; + $original_file = $conf->contrat->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."contrat WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('contract').")"; } @@ -2800,9 +2800,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->don->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->don->dir_output.'/'.$original_file; + $original_file = $conf->don->dir_output.'/'.$original_file; } // Wrapping pour les dons @@ -2810,9 +2810,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->resource->{$read} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->resource->dir_output.'/'.$original_file; + $original_file = $conf->resource->dir_output.'/'.$original_file; } // Wrapping pour les remises de cheques @@ -2820,10 +2820,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->banque->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->bank->dir_output.'/checkdeposits/'.$original_file; // original_file should contains relative path so include the get_exdir result + $original_file = $conf->bank->dir_output.'/checkdeposits/'.$original_file; // original_file should contains relative path so include the get_exdir result } // Wrapping for bank @@ -2831,9 +2831,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->banque->{$lire}) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->bank->dir_output.'/'.$original_file; + $original_file = $conf->bank->dir_output.'/'.$original_file; } // Wrapping for export module @@ -2841,45 +2841,45 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { // Aucun test necessaire car on force le rep de download sur // le rep export qui est propre a l'utilisateur - $accessallowed=1; - $original_file=$conf->export->dir_temp.'/'.$fuser->id.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->export->dir_temp.'/'.$fuser->id.'/'.$original_file; } // Wrapping for import module elseif ($modulepart == 'import' && !empty($conf->import->dir_temp)) { - $accessallowed=1; - $original_file=$conf->import->dir_temp.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->import->dir_temp.'/'.$original_file; } // Wrapping pour l'editeur wysiwyg elseif ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output)) { - $accessallowed=1; - $original_file=$conf->fckeditor->dir_output.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->fckeditor->dir_output.'/'.$original_file; } // Wrapping for backups elseif ($modulepart == 'systemtools' && !empty($conf->admin->dir_output)) { - if ($fuser->admin) $accessallowed=1; - $original_file=$conf->admin->dir_output.'/'.$original_file; + if ($fuser->admin) $accessallowed = 1; + $original_file = $conf->admin->dir_output.'/'.$original_file; } // Wrapping for upload file test elseif ($modulepart == 'admin_temp' && !empty($conf->admin->dir_temp)) { - if ($fuser->admin) $accessallowed=1; - $original_file=$conf->admin->dir_temp.'/'.$original_file; + if ($fuser->admin) $accessallowed = 1; + $original_file = $conf->admin->dir_temp.'/'.$original_file; } // Wrapping pour BitTorrent elseif ($modulepart == 'bittorrent' && !empty($conf->bittorrent->dir_output)) { - $accessallowed=1; - $dir='files'; - if (dol_mimetype($original_file) == 'application/x-bittorrent') $dir='torrents'; - $original_file=$conf->bittorrent->dir_output.'/'.$dir.'/'.$original_file; + $accessallowed = 1; + $dir = 'files'; + if (dol_mimetype($original_file) == 'application/x-bittorrent') $dir = 'torrents'; + $original_file = $conf->bittorrent->dir_output.'/'.$dir.'/'.$original_file; } // Wrapping pour Foundation module @@ -2887,16 +2887,16 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->adherent->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->adherent->dir_output.'/'.$original_file; + $original_file = $conf->adherent->dir_output.'/'.$original_file; } // Wrapping for Scanner elseif ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp)) { - $accessallowed=1; - $original_file=$conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file; } // GENERIC Wrapping @@ -2906,8 +2906,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, // If modulepart=module Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart else { - if (preg_match('/^specimen/i', $original_file)) $accessallowed=1; // If link to a file called specimen. Test must be done before changing $original_file int full path. - if ($fuser->admin) $accessallowed=1; // If user is admin + if (preg_match('/^specimen/i', $original_file)) $accessallowed = 1; // If link to a file called specimen. Test must be done before changing $original_file int full path. + if ($fuser->admin) $accessallowed = 1; // If user is admin // Define $accessallowed if (preg_match('/^([a-z]+)_user_temp$/i', $modulepart, $reg)) @@ -2917,8 +2917,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); exit; } - if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1; - $original_file=$conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file; + if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed = 1; + $original_file = $conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file; } elseif (preg_match('/^([a-z]+)_temp$/i', $modulepart, $reg)) { @@ -2927,8 +2927,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); exit; } - if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1; - $original_file=$conf->{$reg[1]}->dir_temp.'/'.$original_file; + if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed = 1; + $original_file = $conf->{$reg[1]}->dir_temp.'/'.$original_file; } elseif (preg_match('/^([a-z]+)_user$/i', $modulepart, $reg)) { @@ -2937,8 +2937,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, dol_print_error('', 'Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); exit; } - if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1; - $original_file=$conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file; + if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed = 1; + $original_file = $conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file; } elseif (preg_match('/^massfilesarea_([a-z]+)$/i', $modulepart, $reg)) { @@ -2949,9 +2949,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } if ($fuser->rights->{$reg[1]}->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->{$reg[1]}->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file = $conf->{$reg[1]}->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } else { @@ -2961,34 +2961,34 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, exit; } - $perm=GETPOST('perm'); - $subperm=GETPOST('subperm'); + $perm = GETPOST('perm'); + $subperm = GETPOST('subperm'); if ($perm || $subperm) { - if (($perm && ! $subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) $accessallowed=1; - $original_file=$conf->$modulepart->dir_output.'/'.$original_file; + if (($perm && !$subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) $accessallowed = 1; + $original_file = $conf->$modulepart->dir_output.'/'.$original_file; } else { - if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) $accessallowed=1; - $original_file=$conf->$modulepart->dir_output.'/'.$original_file; + if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) $accessallowed = 1; + $original_file = $conf->$modulepart->dir_output.'/'.$original_file; } } // For modules who wants to manage different levels of permissions for documents $subPermCategoryConstName = strtoupper($modulepart).'_SUBPERMCATEGORY_FOR_DOCUMENTS'; - if (! empty($conf->global->$subPermCategoryConstName)) + if (!empty($conf->global->$subPermCategoryConstName)) { $subPermCategory = $conf->global->$subPermCategoryConstName; - if (! empty($subPermCategory) && (($fuser->rights->$modulepart->$subPermCategory->{$lire}) || ($fuser->rights->$modulepart->$subPermCategory->{$read}) || ($fuser->rights->$modulepart->$subPermCategory->{$download}))) + if (!empty($subPermCategory) && (($fuser->rights->$modulepart->$subPermCategory->{$lire}) || ($fuser->rights->$modulepart->$subPermCategory->{$read}) || ($fuser->rights->$modulepart->$subPermCategory->{$download}))) { - $accessallowed=1; + $accessallowed = 1; } } // Define $sqlprotectagainstexternals for modules who want to protect access using a SQL query. $sqlProtectConstName = strtoupper($modulepart).'_SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS'; - if (! empty($conf->global->$sqlProtectConstName)) // If module want to define its own $sqlprotectagainstexternals + if (!empty($conf->global->$sqlProtectConstName)) // If module want to define its own $sqlprotectagainstexternals { // Example: mymodule__SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS = "SELECT fk_soc FROM ".MAIN_DB_PREFIX.$modulepart." WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; eval('$sqlprotectagainstexternals = "'.$conf->global->$sqlProtectConstName.'";'); @@ -3014,8 +3014,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, */ function dol_filecache($directory, $filename, $object) { - if (! dol_is_dir($directory)) dol_mkdir($directory); - $cachefile = $directory . $filename; + if (!dol_is_dir($directory)) dol_mkdir($directory); + $cachefile = $directory.$filename; file_put_contents($cachefile, serialize($object), LOCK_EX); @chmod($cachefile, 0644); } @@ -3031,8 +3031,8 @@ function dol_filecache($directory, $filename, $object) function dol_cache_refresh($directory, $filename, $cachetime) { $now = dol_now(); - $cachefile = $directory . $filename; - $refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile); + $cachefile = $directory.$filename; + $refresh = !file_exists($cachefile) || ($now - $cachetime) > dol_filemtime($cachefile); return $refresh; } @@ -3045,7 +3045,7 @@ function dol_cache_refresh($directory, $filename, $cachetime) */ function dol_readcachefile($directory, $filename) { - $cachefile = $directory . $filename; + $cachefile = $directory.$filename; $object = unserialize(file_get_contents($cachefile)); return $object; } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 0ff2a32f408..12d9b06fee6 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -52,7 +52,7 @@ function jsUnEscape($source) $pos++; $unicodeHexVal = substr($source, $pos, 4); $unicode = hexdec($unicodeHexVal); - $entity = "&#". $unicode . ';'; + $entity = "&#".$unicode.';'; $decodedStr .= utf8_encode($entity); $pos += 4; } @@ -82,28 +82,28 @@ function dolGetModulesDirs($subdir = '') { global $conf; - $modulesdir=array(); + $modulesdir = array(); foreach ($conf->file->dol_document_root as $type => $dirroot) { // Default core/modules dir if ($type === 'main') { - $modulesdir[$dirroot . '/core/modules' . $subdir . '/'] = $dirroot . '/core/modules' . $subdir . '/'; + $modulesdir[$dirroot.'/core/modules'.$subdir.'/'] = $dirroot.'/core/modules'.$subdir.'/'; } // Scan dir from external modules - $handle=@opendir($dirroot); + $handle = @opendir($dirroot); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (preg_match('/disabled/', $file)) continue; // We discard module if it contains disabled into name. + if (preg_match('/disabled/', $file)) continue; // We discard module if it contains disabled into name. if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') { - if (is_dir($dirroot . '/' . $file . '/core/modules'.$subdir.'/')) + if (is_dir($dirroot.'/'.$file.'/core/modules'.$subdir.'/')) { - $modulesdir[$dirroot . '/' . $file . '/core/modules'.$subdir.'/'] = $dirroot . '/' . $file . '/core/modules'.$subdir.'/'; + $modulesdir[$dirroot.'/'.$file.'/core/modules'.$subdir.'/'] = $dirroot.'/'.$file.'/core/modules'.$subdir.'/'; } } } @@ -124,13 +124,13 @@ function dol_getDefaultFormat(Translate $outputlangs = null) { global $langs; - $selected='EUA4'; + $selected = 'EUA4'; if (!$outputlangs) { - $outputlangs=$langs; + $outputlangs = $langs; } - if ($outputlangs->defaultlang == 'ca_CA') $selected='CAP4'; // Canada - if ($outputlangs->defaultlang == 'en_US') $selected='USLetter'; // US + if ($outputlangs->defaultlang == 'ca_CA') $selected = 'CAP4'; // Canada + if ($outputlangs->defaultlang == 'en_US') $selected = 'USLetter'; // US return $selected; } @@ -147,15 +147,15 @@ function dol_print_file($langs, $filename, $searchalt = 0) global $conf; // Test if file is in lang directory - foreach($langs->dir as $searchdir) + foreach ($langs->dir as $searchdir) { - $formfile=($searchdir."/langs/".$langs->defaultlang."/".$filename); + $formfile = ($searchdir."/langs/".$langs->defaultlang."/".$filename); dol_syslog('functions2::dol_print_file search file '.$formfile, LOG_DEBUG); if (is_readable($formfile)) { - $content=file_get_contents($formfile); - $isutf8=utf8_check($content); - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); + $content = file_get_contents($formfile); + $isutf8 = utf8_check($content); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); else print $content; return true; @@ -170,9 +170,9 @@ function dol_print_file($langs, $filename, $searchalt = 0) //print 'getcwd='.getcwd().' htmlfilealt='.$formfilealt.' X '.file_exists(getcwd().'/'.$formfilealt); if (is_readable($formfilealt)) { - $content=file_get_contents($formfilealt); - $isutf8=utf8_check($content); - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); + $content = file_get_contents($formfilealt); + $isutf8 = utf8_check($content); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); else print $content; return true; @@ -201,16 +201,16 @@ function dol_print_object_info($object, $usetable = 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $deltadateforserver=getServerTimeZoneInt('now'); - $deltadateforclient=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); + $deltadateforserver = getServerTimeZoneInt('now'); + $deltadateforclient = ((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); //$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); - $deltadateforuser=round($deltadateforclient-$deltadateforserver); + $deltadateforuser = round($deltadateforclient - $deltadateforserver); //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; if ($usetable) print '
        '; $form->select_comptes($search_account, 'search_account', 0, '', 1); @@ -208,11 +208,11 @@ if ($result) } // Accounting account - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print '
        '; - print $formaccounting->select_account($search_accountancy_code, 'search_accountancy_code', 1, array (), 1, 1, 'maxwidth200'); + print $formaccounting->select_account($search_accountancy_code, 'search_accountancy_code', 1, array(), 1, 1, 'maxwidth200'); print '
        '; print '
        ".$variousstatic->getNomUrl(1)."'; if ($obj->bid > 0) { - $accountstatic->id=$obj->bid; - $accountstatic->ref=$obj->bref; - $accountstatic->number=$obj->bnumber; + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; - if (! empty($conf->accounting->enabled)) { - $accountstatic->account_number=$obj->bank_account_number; + if (!empty($conf->accounting->enabled)) { + $accountstatic->account_number = $obj->bank_account_number; $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($obj->accountancy_journal); $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } - $accountstatic->label=$obj->blabel; + $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); } else print ' '; @@ -297,7 +297,7 @@ if ($result) } // Accounting account - if (! empty($conf->accounting->enabled)) { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $obj->accountancy_code, 1); @@ -332,9 +332,9 @@ if ($result) $i++; } - $colspan=4; - if (! empty($conf->banque->enabled)) $colspan++; - if (! empty($conf->accounting->enabled)) $colspan++; + $colspan = 4; + if (!empty($conf->banque->enabled)) $colspan++; + if (!empty($conf->accounting->enabled)) $colspan++; // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index 96c8013c18c..2829e257b3b 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -55,22 +55,22 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; $object = new Deplacement($db); $object->fetch($id, $ref); $upload_dir = $conf->deplacement->dir_output.'/'.dol_sanitizeFileName($object->ref); -$modulepart='trip'; +$modulepart = 'trip'; /* * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -86,23 +86,23 @@ if ($object->id) { $object->fetch_thirdparty(); - $head=trip_prepare_head($object); + $head = trip_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip'); // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } print ''; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; // Ref print '
        '.$langs->trans("Ref").''; @@ -120,8 +120,8 @@ if ($object->id) $modulepart = 'deplacement'; $permission = $user->rights->deplacement->creer; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index da5ad40002b..7c7437bfb8e 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -63,12 +63,12 @@ class Invoices extends DolibarrApi */ public function get($id, $contact_list = 1) { - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } @@ -78,7 +78,7 @@ class Invoices extends DolibarrApi $this->invoice->totaldeposits = $this->invoice->getSumDepositsUsed(); $this->invoice->remaintopay = price2num($this->invoice->total_ttc - $this->invoice->totalpaid - $this->invoice->totalcreditnotes - $this->invoice->totaldeposits, 'MT'); - if (! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -116,25 +116,25 @@ class Invoices 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 && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."facture as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ' WHERE t.entity IN ('.getEntity('invoice').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; + $sql .= ' WHERE t.entity IN ('.getEntity('invoice').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Filter by status - if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; - if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)"; - if ($status == 'paid') $sql.= " AND t.fk_statut IN (2)"; - if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (3)"; + if ($status == 'draft') $sql .= " AND t.fk_statut IN (0)"; + if ($status == 'unpaid') $sql .= " AND t.fk_statut IN (1)"; + if ($status == 'paid') $sql .= " AND t.fk_statut IN (2)"; + if ($status == 'cancelled') $sql .= " AND t.fk_statut IN (3)"; // Insert sale filter if ($search_sale > 0) { @@ -143,15 +143,15 @@ class Invoices extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -160,13 +160,13 @@ class Invoices extends DolibarrApi } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $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) @@ -192,7 +192,7 @@ class Invoices extends DolibarrApi else { throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No invoice found'); } return $obj_ret; @@ -206,16 +206,16 @@ class Invoices extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->invoice->$field = $value; } - if(! array_key_exists('date', $request_data)) { + if (!array_key_exists('date', $request_data)) { $this->invoice->date = dol_now(); } /* We keep lines as an array @@ -250,12 +250,12 @@ class Invoices extends DolibarrApi public function createInvoiceFromOrder($orderid) { - require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - if (! DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } - if (! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } if (empty($orderid)) { @@ -264,12 +264,12 @@ class Invoices extends DolibarrApi $order = new Commande($this->db); $result = $order->fetch($orderid); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } $result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user); - if ( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->invoice->error); } $this->invoice->fetchObjectLinked(); @@ -287,16 +287,16 @@ class Invoices extends DolibarrApi */ public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->invoice->getLinesArray(); @@ -325,16 +325,16 @@ class Invoices extends DolibarrApi */ public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; @@ -388,13 +388,13 @@ class Invoices extends DolibarrApi */ public function postContact($id, $contactid, $type) { - if(!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if(!$result) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } @@ -402,7 +402,7 @@ class Invoices extends DolibarrApi throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); } - if(!DolibarrApi::_checkAccessToResource('invoice', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('invoice', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -430,7 +430,7 @@ class Invoices extends DolibarrApi */ public function deleteContact($id, $rowid) { - if(!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } @@ -471,19 +471,19 @@ class Invoices extends DolibarrApi public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - if(empty($lineid)) { + if (empty($lineid)) { throw new RestException(400, 'Line ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } @@ -508,20 +508,20 @@ class Invoices extends DolibarrApi */ public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->invoice->$field = $value; } @@ -548,19 +548,19 @@ class Invoices extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->facture->supprimer) { + if (!DolibarrApiAccess::$user->rights->facture->supprimer) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( $this->invoice->delete($id) < 0) + if ($this->invoice->delete($id) < 0) { throw new RestException(500); } @@ -598,16 +598,16 @@ class Invoices extends DolibarrApi */ public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -644,7 +644,7 @@ class Invoices extends DolibarrApi $request_data->origin, $request_data->origin_id, $request_data->fk_parent_line, - empty($request_data->fk_fournprice)?null:$request_data->fk_fournprice, + empty($request_data->fk_fournprice) ?null:$request_data->fk_fournprice, $pa_ht, $request_data->label, $request_data->array_options, @@ -682,15 +682,15 @@ class Invoices extends DolibarrApi */ public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -700,11 +700,11 @@ class Invoices extends DolibarrApi } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -732,15 +732,15 @@ class Invoices extends DolibarrApi */ public function settodraft($id, $idwarehouse = -1) { - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -753,11 +753,11 @@ class Invoices extends DolibarrApi } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -784,15 +784,15 @@ class Invoices extends DolibarrApi */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -805,11 +805,11 @@ class Invoices extends DolibarrApi } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -835,15 +835,15 @@ class Invoices extends DolibarrApi */ public function settopaid($id, $close_code = '', $close_note = '') { - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -857,11 +857,11 @@ class Invoices extends DolibarrApi $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -886,15 +886,15 @@ class Invoices extends DolibarrApi */ public function settounpaid($id) { - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -940,11 +940,11 @@ class Invoices extends DolibarrApi } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -956,12 +956,12 @@ class Invoices extends DolibarrApi $this->invoice->fetch_thirdparty(); // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) - $discountcheck=new DiscountAbsolute($this->db); - $result=$discountcheck->fetch(0, $this->invoice->id); + $discountcheck = new DiscountAbsolute($this->db); + $result = $discountcheck->fetch(0, $this->invoice->id); - $canconvert=0; - if ($this->invoice->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) - if (($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_STANDARD) && $this->invoice->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) + $canconvert = 0; + if ($this->invoice->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) + if (($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_STANDARD) && $this->invoice->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) if ($canconvert) { $this->db->begin(); @@ -1011,13 +1011,13 @@ class Invoices extends DolibarrApi // Total payments $sql = 'SELECT SUM(pf.amount) as total_paiements'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql.= ' WHERE pf.fk_facture = '.$this->invoice->id; - $sql.= ' AND pf.fk_paiement = p.rowid'; - $sql.= ' AND p.entity IN ('.getEntity('invoice').')'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql .= ' WHERE pf.fk_facture = '.$this->invoice->id; + $sql .= ' AND pf.fk_paiement = p.rowid'; + $sql .= ' AND p.entity IN ('.getEntity('invoice').')'; $resql = $this->db->query($sql); - if (! $resql) dol_print_error($this->db); + if (!$resql) dol_print_error($this->db); $res = $this->db->fetch_object($resql); $total_paiements = $res->total_paiements; @@ -1026,8 +1026,8 @@ class Invoices extends DolibarrApi $total_creditnote_and_deposit = 0; $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; - $sql .= " WHERE fk_facture = " . $this->invoice->id; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_facture = ".$this->invoice->id; $resql = $this->db->query($sql); if (!empty($resql)) { while ($obj = $this->db->fetch_object($resql)) $total_creditnote_and_deposit += $obj->amount_ttc; @@ -1066,7 +1066,7 @@ class Invoices extends DolibarrApi if (empty($error)) { - if($this->invoice->type != Facture::TYPE_DEPOSIT) { + if ($this->invoice->type != Facture::TYPE_DEPOSIT) { // Classe facture $result = $this->invoice->set_paid(DolibarrApiAccess::$user); if ($result >= 0) @@ -1111,27 +1111,27 @@ class Invoices extends DolibarrApi public function useDiscount($id, $discountid) { - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Invoice ID is mandatory'); } - if(empty($discountid)) { + if (empty($discountid)) { throw new RestException(400, 'Discount ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } $result = $this->invoice->insert_discount($discountid); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->invoice->error); } @@ -1157,29 +1157,29 @@ class Invoices extends DolibarrApi public function useCreditNote($id, $discountid) { - require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Invoice ID is mandatory'); } - if(empty($discountid)) { + if (empty($discountid)) { throw new RestException(400, 'Credit ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $discount = new DiscountAbsolute($this->db); $result = $discount->fetch($discountid); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Credit not found'); } $result = $discount->link_to_invoice(0, $id); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $discount->error); } @@ -1202,24 +1202,24 @@ class Invoices extends DolibarrApi public function getPayments($id) { - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Invoice ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } $result = $this->invoice->getListOfPayments(); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->invoice->error); } @@ -1251,32 +1251,32 @@ class Invoices extends DolibarrApi { global $conf; - require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(403); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Invoice ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (! empty($conf->banque->enabled)) { - if(empty($accountid)) { + if (!empty($conf->banque->enabled)) { + if (empty($accountid)) { throw new RestException(400, 'Account ID is mandatory'); } } - if(empty($paiementid)) { + if (empty($paiementid)) { throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); } $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } @@ -1310,28 +1310,28 @@ class Invoices extends DolibarrApi // Creation of payment line $paiement = new Paiement($this->db); $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = $paiementid; $paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1); $paiement->num_paiement = $num_paiement; $paiement->note = $comment; - $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices + $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices if ($paiement_id < 0) { $this->db->rollback(); throw new RestException(400, 'Payment error : '.$paiement->error); } - if (! empty($conf->banque->enabled)) { - $label='(CustomerInvoicePayment)'; + if (!empty($conf->banque->enabled)) { + $label = '(CustomerInvoicePayment)'; - if($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { + if ($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode); } - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label='(CustomerInvoicePaymentBack)'; // Refund of a credit note - $result=$paiement->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result = $paiement->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); if ($result < 0) { $this->db->rollback(); @@ -1371,26 +1371,26 @@ class Invoices extends DolibarrApi { global $conf; - require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(403); } - foreach($arrayofamounts as $id => $amount) { - if(empty($id)) { + foreach ($arrayofamounts as $id => $amount) { + if (empty($id)) { throw new RestException(400, 'Invoice ID is mandatory. Fill the invoice id and amount into arrayofamounts parameter. For example: {"1": "99.99", "2": "10"}'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $id)) { + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { throw new RestException(403, 'Access not allowed on invoice ID '.$id.' for login '.DolibarrApiAccess::$user->login); } } - if (! empty($conf->banque->enabled)) { - if(empty($accountid)) { + if (!empty($conf->banque->enabled)) { + if (empty($accountid)) { throw new RestException(400, 'Account ID is mandatory'); } } - if(empty($paiementid)) { + if (empty($paiementid)) { throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); } @@ -1400,10 +1400,10 @@ class Invoices extends DolibarrApi $multicurrency_amounts = array(); // Loop on each invoice to pay - foreach($arrayofamounts as $id => $amount) + foreach ($arrayofamounts as $id => $amount) { $result = $this->invoice->fetch($id); - if( ! $result ) { + if (!$result) { $this->db->rollback(); throw new RestException(404, 'Invoice ID '.$id.' not found'); } @@ -1441,25 +1441,25 @@ class Invoices extends DolibarrApi // Creation of payment line $paiement = new Paiement($this->db); $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = $paiementid; $paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1); $paiement->num_paiement = $num_paiement; $paiement->note = $comment; - $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices + $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices if ($paiement_id < 0) { $this->db->rollback(); throw new RestException(400, 'Payment error : '.$paiement->error); } - if (! empty($conf->banque->enabled)) { - $label='(CustomerInvoicePayment)'; - if($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { + if (!empty($conf->banque->enabled)) { + $label = '(CustomerInvoicePayment)'; + if ($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode); } - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label='(CustomerInvoicePaymentBack)'; // Refund of a credit note - $result=$paiement->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result = $paiement->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); if ($result < 0) { $this->db->rollback(); diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 2201412f3f8..d928147d35b 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -50,16 +50,16 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="dp"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "dp"; -$year=GETPOST("year"); -$month=GETPOST("month"); +$year = GETPOST("year"); +$month = GETPOST("month"); -$form=new Form($db); +$form = new Form($db); $formother = new FormOther($db); -$checkdepositstatic=new RemiseCheque($db); -$accountstatic=new Account($db); +$checkdepositstatic = new RemiseCheque($db); +$accountstatic = new Account($db); /* @@ -69,11 +69,11 @@ $accountstatic=new Account($db); // If click on 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_ref=''; - $search_amount=''; - $search_account=''; - $year=''; - $month=''; + $search_ref = ''; + $search_amount = ''; + $search_account = ''; + $year = ''; + $month = ''; } @@ -112,7 +112,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print "$sql"; $resql = $db->query($sql); @@ -141,10 +141,10 @@ if ($resql) print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_bank.png', 0, $newcardbutton, '', $limit); - $moreforfilter=''; + $moreforfilter = ''; print '
        '; - print ''."\n"; + print '
        '."\n"; // Fields title search print ''; @@ -152,9 +152,9 @@ if ($resql) print ''; print ''; print ''; print ''; // Date - print ''; // TODO Use date hour + print ''; // TODO Use date hour // Bank print ''; print ''; @@ -1946,25 +1946,25 @@ else } // Form to activate line - if ($user->rights->contrat->activer && $action == 'activateline' && $object->lines[$cursorline-1]->id == GETPOST('ligne')) + if ($user->rights->contrat->activer && $action == 'activateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { print ''; print ''; - print '
        '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($year?$year:-1, 'year', 1, 20, 5); + $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); print ''; $form->select_comptes($search_account, 'search_account', 0, '', 1); @@ -190,14 +190,14 @@ if ($resql) // Num ref cheque print ''; - $checkdepositstatic->id=$objp->rowid; - $checkdepositstatic->ref=($objp->ref?$objp->ref:$objp->rowid); - $checkdepositstatic->statut=$objp->statut; + $checkdepositstatic->id = $objp->rowid; + $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid); + $checkdepositstatic->statut = $objp->statut; print $checkdepositstatic->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->dp), 'day').''.dol_print_date($db->jdate($objp->dp), 'day').''; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index c3eaece8c93..859ed250312 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -73,14 +73,14 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="p.rowid"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "p.rowid"; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('paymentlist')); $extrafields = new ExtraFields($db); -$arrayfields=array(); +$arrayfields = array(); /* @@ -89,16 +89,16 @@ $arrayfields=array(); 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_ref=""; - $search_account=""; - $search_amount=""; - $search_paymenttype=""; - $search_payment_num=""; - $search_company=""; - $day=''; - $year=''; - $month=''; - $search_array_options=array(); + $search_ref = ""; + $search_account = ""; + $search_amount = ""; + $search_paymenttype = ""; + $search_payment_num = ""; + $search_company = ""; + $day = ''; + $year = ''; + $month = ''; + $search_array_options = array(); } @@ -106,8 +106,8 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' * View */ -$form=new Form($db); -$formother=new FormOther($db); +$form = new Form($db); +$formother = new FormOther($db); llxHeader('', $langs->trans('ListPayment')); @@ -190,7 +190,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print "$sql"; $resql = $db->query($sql); @@ -198,15 +198,15 @@ if ($resql) { $num = $db->num_rows($resql); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - $param.=(GETPOST("orphelins")?"&orphelins=1":""); - $param.=($search_ref?"&search_ref=".urlencode($search_ref):""); - $param.=($search_company?"&search_company=".urlencode($search_company):""); - $param.=($search_amount?"&search_amount=".urlencode($search_amount):""); - $param.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):""); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + $param .= (GETPOST("orphelins") ? "&orphelins=1" : ""); + $param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : ""); + $param .= ($search_company ? "&search_company=".urlencode($search_company) : ""); + $param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : ""); + $param .= ($search_payment_num ? "&search_payment_num=".urlencode($search_payment_num) : ""); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); print '
        '; if ($optioncss != '') print ''; @@ -221,7 +221,7 @@ if ($resql) print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'invoicing', 0, '', '', $limit); print '
        '; - print ''."\n"; + print '
        '."\n"; // Lines for filters fields print ''; @@ -229,9 +229,9 @@ if ($resql) print ''; print ''; print ''; print ''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print '\n"; $i = 0; - $totalarray=array(); + $totalarray = array(); while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); - $paymentstatic->id=$objp->rowid; - $paymentstatic->ref=$objp->ref; + $paymentstatic->id = $objp->rowid; + $paymentstatic->ref = $objp->ref; - $companystatic->id=$objp->socid; - $companystatic->name=$objp->name; - $companystatic->email=$objp->email; + $companystatic->id = $objp->socid; + $companystatic->name = $objp->name; + $companystatic->email = $objp->email; print ''; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Date $dateformatforpayment = 'day'; - if (! empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment='dayhour'; + if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment = 'dayhour'; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Thirdparty print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Type print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Payment number print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Amount print ''; - if (! $i) $totalarray['nbfield']++; - $totalarray['pos'][7]='amount'; + if (!$i) $totalarray['nbfield']++; + $totalarray['pos'][7] = 'amount'; $totalarray['val']['amount'] += $objp->amount; - if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) + if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index eb18618ab62..2e1915f780e 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -44,15 +44,15 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="p.datec"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "p.datec"; // Get supervariables $statut = GETPOST('statut', 'int'); $search_ref = GETPOST('search_ref', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); -$bon=new BonPrelevement($db, ""); +$bon = new BonPrelevement($db, ""); /* @@ -61,8 +61,8 @@ $bon=new BonPrelevement($db, ""); 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_ref=""; - $search_amount=""; + $search_ref = ""; + $search_amount = ""; } @@ -73,12 +73,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' llxHeader('', $langs->trans("WithdrawalsReceipts")); $sql = "SELECT p.rowid, p.ref, p.amount, p.statut, p.datec"; -$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; -$sql.= " WHERE p.entity IN (".getEntity('invoice').")"; -if ($search_ref) $sql.=natural_search("p.ref", $search_ref); -if ($search_amount) $sql.=natural_search("p.amount", $search_amount, 1); +$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; +$sql .= " WHERE p.entity IN (".getEntity('invoice').")"; +if ($search_ref) $sql .= natural_search("p.ref", $search_ref); +if ($search_amount) $sql .= natural_search("p.amount", $search_amount, 1); -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -93,7 +93,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 50d062612f8..1ac766a4e34 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -53,7 +53,7 @@ $search_day_lim = GETPOST('search_day_lim', 'int'); $search_month_lim = GETPOST('search_month_lim', 'int'); $search_year_lim = GETPOST('search_year_lim', 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -135,45 +135,45 @@ if ($year > 0) $sql .= ")"; } if ($filtre) { - $filtre=str_replace(":", "=", $filtre); + $filtre = str_replace(":", "=", $filtre); $sql .= " AND ".$filtre; } if ($search_typeid) { $sql .= " AND cs.fk_type=".$db->escape($search_typeid); } -$sql.= " GROUP BY cs.rowid, cs.fk_type, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle"; -$sql.= $db->order($sortfield, $sortorder); +$sql .= " GROUP BY cs.rowid, cs.fk_type, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle"; +$sql .= $db->order($sortfield, $sortorder); -$totalnboflines=0; -$result=$db->query($sql); +$totalnboflines = 0; +$result = $db->query($sql); if ($result) { $totalnboflines = $db->num_rows($result); } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - $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_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_label) $param.='&search_label='.urlencode($search_label); - if ($search_amount) $param.='&search_amount='.urlencode($search_amount); - if ($search_typeid) $param.='&search_typeid='.urlencode($search_typeid); - if ($search_status != '' && $search_status != '-1') $param.='&search_status='.urlencode($search_status); - if ($year) $param.='&year='.urlencode($year); + $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_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); + if ($search_typeid) $param .= '&search_typeid='.urlencode($search_typeid); + if ($search_status != '' && $search_status != '-1') $param .= '&search_status='.urlencode($search_status); + if ($year) $param .= '&year='.urlencode($year); - $newcardbutton=''; - if($user->rights->tax->charges->creer) + $newcardbutton = ''; + if ($user->rights->tax->charges->creer) { - $newcardbutton=''.$langs->trans('MenuNewSocialContribution').''; - $newcardbutton.= ''; - $newcardbutton.= ''; + $newcardbutton = ''.$langs->trans('MenuNewSocialContribution').''; + $newcardbutton .= ''; + $newcardbutton .= ''; } print ''; @@ -199,14 +199,14 @@ if ($resql) { print '
        '; $langs->load("errors"); - $countrynotdefined=$langs->trans("ErrorSetACountryFirst"); + $countrynotdefined = $langs->trans("ErrorSetACountryFirst"); print $countrynotdefined; print '
        '; } else { print '
        '; - print '
        '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($year?$year:-1, 'year', 1, 20, 5); + $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); print ''; print ''; @@ -242,7 +242,7 @@ if ($resql) print ''; print ''; print ''; $form->select_comptes($search_account, 'search_account', 0, '', 1); @@ -268,46 +268,46 @@ if ($resql) print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "c.libelle", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "p.num_paiement", "", $param, "", $sortfield, $sortorder); - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); } print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "p.amount", "", $param, 'class="right"', $sortfield, $sortorder); //print_liste_field_titre("Invoices"),"","","",$param,'class="left"',$sortfield,$sortorder); - $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 + $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; - if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.statut", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.statut", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "
        '; print $paymentstatic->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->dp), $dateformatforpayment).''; @@ -316,27 +316,27 @@ if ($resql) print $companystatic->getNomUrl(1, '', 24); } print ''.$langs->trans("PaymentTypeShort".$objp->paiement_code).''.$objp->num_paiement.''; if ($objp->bid > 0) { - $accountstatic->id=$objp->bid; - $accountstatic->ref=$objp->bref; - $accountstatic->label=$objp->blabel; - $accountstatic->number=$objp->number; - $accountstatic->account_number=$objp->account_number; + $accountstatic->id = $objp->bid; + $accountstatic->ref = $objp->bref; + $accountstatic->label = $objp->blabel; + $accountstatic->number = $objp->number; + $accountstatic->account_number = $objp->account_number; $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($objp->accountancy_journal); @@ -345,27 +345,27 @@ if ($resql) print $accountstatic->getNomUrl(1); } print ''.price($objp->amount).''; if ($objp->statut == 0) print ''; print $paymentstatic->LibStatut($objp->statut, 5); if ($objp->statut == 0) print ''; print '
        '."\n"; + print '
        '."\n"; print ''; // Ref diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 8ffc88d1a14..df1dfb0b293 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -require_once DOL_DOCUMENT_ROOT. '/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -95,25 +95,25 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='a.datep, a.id'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'a.datep, a.id'; +if (!$sortorder) $sortorder = 'DESC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('contactagenda','globalcard')); +$hookmanager->initHooks(array('contactagenda', 'globalcard')); /* * Actions */ -$parameters=array('id'=>$id, 'objcanvas'=>$objcanvas); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id, 'objcanvas'=>$objcanvas); +$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)) { // Cancel - if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -122,8 +122,8 @@ if (empty($reshook)) // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $actioncode=''; - $search_agenda_label=''; + $actioncode = ''; + $search_agenda_label = ''; } } @@ -134,9 +134,9 @@ if (empty($reshook)) $form = new Form($db); -$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title=$object->lastname; -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname; +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); @@ -154,11 +154,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (empty($object->error) && $id) { $object = new Contact($db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); } - $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + $objcanvas->display_canvas($action); // Show template } else { @@ -171,30 +171,30 @@ else { if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage?'&backtopage='.$backtopage:''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); } } /* * Onglets */ - $head=array(); + $head = array(); if ($id > 0) { // Si edition contact deja existant $object = new Contact($db); - $res=$object->fetch($id, $user); + $res = $object->fetch($id, $user); if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); if ($res < 0) { dol_print_error($db, $object->error); exit; } // Show tabs $head = contact_prepare_head($object); - $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); } - if (! empty($id) && $action != 'edit' && $action != 'create') + if (!empty($id) && $action != 'edit' && $action != 'create') { $objsoc = new Societe($db); @@ -208,17 +208,17 @@ else $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
        '; + $morehtmlref = '
        '; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - $objsoc=new Societe($db); + $objsoc = new Societe($db); $objsoc->fetch($object->socid); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : '; - if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1); - else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany"); + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); @@ -236,17 +236,17 @@ else // Actions buttons - $objcon=$object; + $objcon = $object; $object->fetch_thirdparty(); - $objthirdparty=$object->thirdparty; + $objthirdparty = $object->thirdparty; - $out=''; - $permok=$user->rights->agenda->myactions->create; - if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok) + $out = ''; + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='trans("AddAnAction"),'filenew'); //$out.=""; diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index a15e3748598..fbd31812fe8 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -45,7 +45,7 @@ abstract class ActionsContactCardCommon /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** @@ -71,7 +71,7 @@ abstract class ActionsContactCardCommon else {*/ $object = new Contact($this->db); - if (! empty($id)) $object->fetch($id); + if (!empty($id)) $object->fetch($id); $this->object = $object; //} } @@ -92,13 +92,13 @@ abstract class ActionsContactCardCommon if ($action == 'add' || $action == 'update') $this->assign_post(); - foreach($this->object as $key => $value) + foreach ($this->object as $key => $value) { $this->tpl[$key] = $value; } - $this->tpl['error']=$this->error; - $this->tpl['errors']=$this->errors; + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; if ($action == 'create' || $action == 'edit') { @@ -129,7 +129,7 @@ abstract class ActionsContactCardCommon $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); // Predefined with third party - if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) { if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; @@ -140,10 +140,10 @@ abstract class ActionsContactCardCommon } // Zip - $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town','selectcountry_id','state_id'), 6); + $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); // Town - $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode','selectcountry_id','state_id')); + $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; @@ -158,14 +158,14 @@ abstract class ActionsContactCardCommon else $this->tpl['select_state'] = $countrynotdefined; // Public or private - $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); $this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0); } if ($action == 'view' || $action == 'edit' || $action == 'delete') { // Emailing - if (! empty($conf->mailing->enabled)) + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); @@ -173,40 +173,40 @@ abstract class ActionsContactCardCommon // Linked element $this->tpl['contact_element'] = array(); - $i=0; + $i = 0; $this->object->load_ref_elements(); - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande?$this->object->ref_commande:$langs->trans("NoContactForAnyOrder"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder"); $i++; } - if (! empty($conf->propal->enabled)) + if (!empty($conf->propal->enabled)) { $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal?$this->object->ref_propal:$langs->trans("NoContactForAnyProposal"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal"); $i++; } - if (! empty($conf->contrat->enabled)) + if (!empty($conf->contrat->enabled)) { $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat?$this->object->ref_contrat:$langs->trans("NoContactForAnyContract"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat ? $this->object->ref_contrat : $langs->trans("NoContactForAnyContract"); $i++; } - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation?$this->object->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation ? $this->object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); $i++; } // Dolibarr user if ($this->object->user_id) { - $dolibarr_user=new User($this->db); - $result=$dolibarr_user->fetch($this->object->user_id); + $dolibarr_user = new User($this->db); + $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); @@ -232,16 +232,16 @@ abstract class ActionsContactCardCommon $this->tpl['address'] = dol_nl2br($this->object->address); - $this->tpl['zip'] = ($this->object->zip?$this->object->zip.' ':''); + $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); - $img=picto_from_langcode($this->object->country_code); - $this->tpl['country'] = ($img?$img.' ':'').$this->object->country; + $img = picto_from_langcode($this->object->country_code); + $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; - $this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX'); - $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); + $this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX'); + $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); $this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv); @@ -253,13 +253,13 @@ abstract class ActionsContactCardCommon // Full firstname and lastname separated with a dot : firstname.lastname include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $login=dol_buildlogin($this->object->lastname, $this->object->firstname); + $login = dol_buildlogin($this->object->lastname, $this->object->firstname); - $generated_password=getRandomPassword(false); - $password=$generated_password; + $generated_password = getRandomPassword(false); + $password = $generated_password; // Create a form array - $formquestion=array( + $formquestion = array( array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); @@ -278,34 +278,34 @@ abstract class ActionsContactCardCommon // phpcs:enable global $langs, $mysoc; - $this->object->old_name = $_POST["old_name"]; - $this->object->old_firstname = $_POST["old_firstname"]; + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; - $this->object->socid = $_POST["socid"]; + $this->object->socid = $_POST["socid"]; $this->object->lastname = $_POST["name"]; $this->object->firstname = $_POST["firstname"]; - $this->object->civility_id = $_POST["civility_id"]; + $this->object->civility_id = $_POST["civility_id"]; $this->object->poste = $_POST["poste"]; - $this->object->address = $_POST["address"]; - $this->object->zip = $_POST["zipcode"]; + $this->object->address = $_POST["address"]; + $this->object->zip = $_POST["zipcode"]; $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone_pro = $_POST["phone_pro"]; - $this->object->phone_perso = $_POST["phone_perso"]; - $this->object->phone_mobile = $_POST["phone_mobile"]; - $this->object->fax = $_POST["fax"]; + $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; + $this->object->state_id = $_POST["state_id"]; + $this->object->phone_pro = $_POST["phone_pro"]; + $this->object->phone_perso = $_POST["phone_perso"]; + $this->object->phone_mobile = $_POST["phone_mobile"]; + $this->object->fax = $_POST["fax"]; $this->object->email = $_POST["email"]; - $this->object->jabberid = $_POST["jabberid"]; + $this->object->jabberid = $_POST["jabberid"]; $this->object->priv = $_POST["priv"]; $this->object->note = $_POST["note"]; - $this->object->canvas = $_POST["canvas"]; + $this->object->canvas = $_POST["canvas"]; // We set country_id, and country_code label of the chosen country if ($this->object->country_id) { $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -314,9 +314,9 @@ abstract class ActionsContactCardCommon { dol_print_error($this->db); } - $this->object->country_id = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; + $this->object->country_id = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; + $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; } } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index f72edeb3a34..1e0a2f9446c 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -120,30 +120,30 @@ if (empty($reshook)) // Creation user $nuser = new User($db); - $result=$nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha) + $result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha) if ($result > 0) { - $result2=$nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) + $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) if ($result2) { $db->commit(); } else { - $error=$nuser->error; $errors=$nuser->errors; + $error = $nuser->error; $errors = $nuser->errors; $db->rollback(); } } else { - $error=$nuser->error; $errors=$nuser->errors; + $error = $nuser->error; $errors = $nuser->errors; $db->rollback(); } } else { - $error=$object->error; $errors=$object->errors; + $error = $object->error; $errors = $object->errors; } } @@ -152,7 +152,7 @@ if (empty($reshook)) if ($action == 'disable') { $object->fetch($id); - if ($object->setstatus(0)<0) + if ($object->setstatus(0) < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -167,7 +167,7 @@ if (empty($reshook)) if ($action == 'enable') { $object->fetch($id); - if ($object->setstatus(1)<0) + if ($object->setstatus(1) < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -232,18 +232,18 @@ if (empty($reshook)) $action = 'create'; } - if (! GETPOST("lastname")) + if (!GETPOST("lastname")) { - $error++; $errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); + $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); $action = 'create'; } - if (! $error) + if (!$error) { - $id = $object->create($user); + $id = $object->create($user); if ($id <= 0) { - $error++; $errors=array_merge($errors, ($object->error?array($object->error):$object->errors)); + $error++; $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); $action = 'create'; } else { // Categories association @@ -268,11 +268,11 @@ if (empty($reshook)) } } - if (! $error && $id > 0) + if (!$error && $id > 0) { $db->commit(); - if (! empty($backtopage)) $url=$backtopage; - else $url='card.php?id='.$id; + if (!empty($backtopage)) $url = $backtopage; + else $url = 'card.php?id='.$id; header("Location: ".$url); exit; } @@ -310,17 +310,17 @@ if (empty($reshook)) } } - if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) + if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) { if (empty($_POST["lastname"])) { - $error++; $errors=array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); + $error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); $action = 'edit'; } - if (! $error) + if (!$error) { - $contactid=GETPOST("contactid", 'int'); + $contactid = GETPOST("contactid", 'int'); $object->fetch($contactid); // Photo save @@ -328,8 +328,8 @@ if (empty($reshook)) $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if (GETPOST('deletephoto') && $object->photo) { - $fileimg=$dir.'/'.$object->photo; - $dirthumbs=$dir.'/thumbs'; + $fileimg = $dir.'/'.$object->photo; + $dirthumbs = $dir.'/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); $object->photo = ''; @@ -342,10 +342,10 @@ if (empty($reshook)) if (@is_dir($dir)) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (! $result > 0) + if (!$result > 0) { $errors[] = "ErrorFailedToSaveFile"; } @@ -365,7 +365,7 @@ if (empty($reshook)) } else { - switch($_FILES['photo']['error']) + switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form @@ -471,9 +471,9 @@ if (empty($reshook)) } } - if (! $error && empty($errors)) + if (!$error && empty($errors)) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -482,9 +482,9 @@ if (empty($reshook)) } // Actions to send emails - $trigger_name='CONTACT_SENTBYMAIL'; - $paramname='id'; - $mode='emailfromcontact'; + $trigger_name = 'CONTACT_SENTBYMAIL'; + $paramname = 'id'; + $mode = 'emailfromcontact'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -494,15 +494,15 @@ if (empty($reshook)) */ -$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title=$object->lastname; -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname; +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); $form = new Form($db); $formcompany = new FormCompany($db); -$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($socid > 0) { @@ -518,11 +518,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (empty($object->error) && $id) { $object = new Contact($db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); } - $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + $objcanvas->display_canvas($action); // Show template } else { @@ -612,7 +612,7 @@ else print ''; print ''; print ''; - if (! empty($objsoc)) { + if (!empty($objsoc)) { print ''; } @@ -622,9 +622,9 @@ else // Name print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) @@ -673,23 +673,23 @@ else print ''; // Zip / Town - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party print ''; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print ''; - print ''; + print ''; print ''; print ''; // Firstname print ''; - print ''; + print ''; print ''; // Company @@ -989,20 +989,20 @@ else // Zip / Town print ''; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print ''; - if (! empty($conf->mailing->enabled)) + if (!empty($conf->mailing->enabled)) { $noemail = ''; - if (empty($noemail) && ! empty($object->email)) + if (empty($noemail) && !empty($object->email)) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; //print $sql; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $noemail = $obj->nb; } } print ''; - print ''; + print ''; } else { @@ -1141,7 +1141,7 @@ else // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print ''; + print ''; print ''; } - if (! empty($conf->propal->enabled)) + if (!empty($conf->propal->enabled)) { print ''; } - if (! empty($conf->contrat->enabled)) + if (!empty($conf->contrat->enabled)) { print ''; } - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { print ''; } @@ -1204,8 +1204,8 @@ else print ''; // Email - if (! empty($conf->mailing->enabled)) + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); print ''; @@ -1325,14 +1325,14 @@ else { //print 'eee'.$object->email; $noemail = $object->no_email; - if (empty($noemail) && ! empty($object->email)) + if (empty($noemail) && !empty($object->email)) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; //print $sql; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $noemail = $obj->nb; } } @@ -1352,8 +1352,8 @@ else print '
        lastname).'" autofocus="autofocus">lastname).'" autofocus="autofocus">firstname).'">
        firstname).'">
        / '; - print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha')?GETPOST("zipcode", 'alpha'):$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6).' '; - print $formcompany->select_ziptown((GETPOST("town", 'alpha')?GETPOST("town", 'alpha'):$object->town), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha') ?GETPOST("zipcode", 'alpha') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; + print $formcompany->select_ziptown((GETPOST("town", 'alpha') ?GETPOST("town", 'alpha') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
        '; - print $form->select_country((GETPOST("country_id", 'alpha')?GETPOST("country_id", 'alpha'):$object->country_id), 'country_id'); + print $form->select_country((GETPOST("country_id", 'alpha') ?GETPOST("country_id", 'alpha') : $object->country_id), 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
        '; } @@ -700,7 +700,7 @@ else if ($object->country_id) { - print $formcompany->select_state(GETPOST("state_id", 'alpha')?GETPOST("state_id", 'alpha'):$object->state_id, $object->country_code, 'state_id'); + print $formcompany->select_state(GETPOST("state_id", 'alpha') ?GETPOST("state_id", 'alpha') : $object->state_id, $object->country_code, 'state_id'); } else { @@ -843,7 +843,7 @@ else // Date To Birth print '
        '; - $form=new Form($db); + $form = new Form($db); if ($object->birthday) { print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0); @@ -871,7 +871,7 @@ else print '
        '; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -879,13 +879,13 @@ else else { print '     '; - print ''; + print ''; } print '
        '; print ""; } - elseif ($action == 'edit' && ! empty($id)) + elseif ($action == 'edit' && !empty($id)) { /* * Fiche en mode edition @@ -894,9 +894,9 @@ else // We set country_id, and country_code label of the chosen country if (isset($_POST["country_id"]) || $object->country_id) { - $tmparray=getCountry($object->country_id, 'all'); - $object->country_code = $tmparray['code']; - $object->country = $tmparray['label']; + $tmparray = getCountry($object->country_id, 'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; } $objsoc = new Societe($db); @@ -951,12 +951,12 @@ else // Lastname print '
        lastname).'" autofocus="autofocus">lastname).'" autofocus="autofocus">
        firstname).'">firstname).'">
        / '; - print $formcompany->select_ziptown((isset($_POST["zipcode"])?GETPOST("zipcode"):$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6).' '; - print $formcompany->select_ziptown((isset($_POST["town"])?GETPOST("town"):$object->town), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((isset($_POST["zipcode"]) ?GETPOST("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; + print $formcompany->select_ziptown((isset($_POST["town"]) ?GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
        '; - print $form->select_country(isset($_POST["country_id"])?GETPOST("country_id"):$object->country_id, 'country_id'); + print $form->select_country(isset($_POST["country_id"]) ?GETPOST("country_id") : $object->country_id, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
        '; } @@ -1043,23 +1043,23 @@ else // Unsubscribe print '
        '.$form->selectyesno('no_email', (GETPOSTISSET("no_email")?GETPOST("no_email", 'alpha'):$noemail), 1).''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'
        ' . $form->editfieldkey('Categories', 'contcats', '', $object, 0) . '
        '.$form->editfieldkey('Categories', 'contcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, null, null, null, 1); $c = new Categorie($db); @@ -1162,8 +1162,8 @@ else } // Other attributes - $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('colspan' => ' colspan="3"', 'cols'=>3); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1172,31 +1172,31 @@ else $object->load_ref_elements(); - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { print '
        '.$langs->trans("ContactForOrders").''; - print $object->ref_commande?$object->ref_commande:$langs->trans("NoContactForAnyOrder"); + print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder"); print '
        '.$langs->trans("ContactForProposals").''; - print $object->ref_propal?$object->ref_propal:$langs->trans("NoContactForAnyProposal"); + print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); print '
        '.$langs->trans("ContactForContracts").''; - print $object->ref_contrat?$object->ref_contrat:$langs->trans("NoContactForAnyContract"); + print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); print '
        '.$langs->trans("ContactForInvoices").''; - print $object->ref_facturation?$object->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); print '
        '.$langs->trans("DolibarrLogin").''; if ($object->user_id) { - $dolibarr_user=new User($db); - $result=$dolibarr_user->fetch($object->user_id); + $dolibarr_user = new User($db); + $result = $dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); } else print $langs->trans("NoDolibarrAccess"); @@ -1242,7 +1242,7 @@ else } } - if (! empty($id) && $action != 'edit' && $action != 'create') + if (!empty($id) && $action != 'edit' && $action != 'create') { $objsoc = new Societe($db); @@ -1257,15 +1257,15 @@ else { // Full firstname and lastname separated with a dot : firstname.lastname include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $login=dol_buildlogin($object->lastname, $object->firstname); + $login = dol_buildlogin($object->lastname, $object->firstname); - $generated_password=''; - if (! $ldap_sid) // TODO ldap_sid ? + $generated_password = ''; + if (!$ldap_sid) // TODO ldap_sid ? { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generated_password=getRandomPassword(false); + $generated_password = getRandomPassword(false); } - $password=$generated_password; + $password = $generated_password; // Create a form array $formquestion = array( @@ -1273,27 +1273,27 @@ else array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password), //array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External'))) ); - $text=$langs->trans("ConfirmCreateContact").'
        '; - if (! empty($conf->societe->enabled)) + $text = $langs->trans("ConfirmCreateContact").'
        '; + if (!empty($conf->societe->enabled)) { - if ($object->socid > 0) $text.=$langs->trans("UserWillBeExternalUser"); - else $text.=$langs->trans("UserWillBeInternalUser"); + if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser"); + else $text .= $langs->trans("UserWillBeInternalUser"); } print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); } $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
        '; + $morehtmlref = '
        '; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc->fetch($object->socid); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : '; - if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1, 'contact'); - else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany"); + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); @@ -1313,7 +1313,7 @@ else print '
        '.$langs->trans("PostOrFunction").''.$object->poste.'
        '.$langs->trans("NbOfEMailingsSend").'
        '; // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { - print ''; + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { + print ''; print ''; @@ -1368,49 +1368,49 @@ else // Other attributes $cols = 3; - $parameters=array('socid'=>$socid); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('socid'=>$socid); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; $object->load_ref_elements(); - if (! empty($conf->propal->enabled)) + if (!empty($conf->propal->enabled)) { print ''; } - if (! empty($conf->commande->enabled) || ! empty($conf->expedition->enabled)) + if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) { print ''; } - if (! empty($conf->contrat->enabled)) + if (!empty($conf->contrat->enabled)) { print ''; } - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { print ''; } print ''; @@ -1194,7 +1194,7 @@ if ($action == 'create') // Thirdparty print ''; print ''; - if ($socid>0) + if ($socid > 0) { print ''."\n"; - if($socid>0) + if ($socid > 0) { // Ligne info remises tiers print ''; // Commercial signature print ''; print '
        ' . $langs->trans("Categories") . '
        '.$langs->trans("Categories").''; print $form->showCategories($object->id, 'contact', 1); print '
        '.$langs->trans("ContactForProposals").''; - print $object->ref_propal?$object->ref_propal:$langs->trans("NoContactForAnyProposal"); + print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); print '
        '; - if (! empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } + if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders"); print ''; - $none=$langs->trans("NoContactForAnyOrder"); - if (! empty($conf->expedition->enabled)) { $none=$langs->trans("NoContactForAnyOrderOrShipments"); } - print $object->ref_commande?$object->ref_commande:$none; + $none = $langs->trans("NoContactForAnyOrder"); + if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); } + print $object->ref_commande ? $object->ref_commande : $none; print '
        '.$langs->trans("ContactForContracts").''; - print $object->ref_contrat?$object->ref_contrat:$langs->trans("NoContactForAnyContract"); + print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); print '
        '.$langs->trans("ContactForInvoices").''; - print $object->ref_facturation?$object->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); print '
        '.$langs->trans("DolibarrLogin").''; if ($object->user_id) { - $dolibarr_user=new User($db); - $result=$dolibarr_user->fetch($object->user_id); + $dolibarr_user = new User($db); + $result = $dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); } else print $langs->trans("NoDolibarrAccess"); @@ -1434,11 +1434,11 @@ else // Barre d'actions print '
        '; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && $action!='presend') + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && $action != 'presend') { - if (! empty($object->email)) + if (!empty($object->email)) { $langs->load("mails"); print ''; @@ -1454,7 +1454,7 @@ else print ''.$langs->trans('Modify').''; } - if (! $object->user_id && $user->rights->user->user->creer) + if (!$object->user_id && $user->rights->user->user->creer) { print ''.$langs->trans("CreateDolibarrLogin").''; } @@ -1473,15 +1473,15 @@ else // Delete if ($user->rights->societe->contact->supprimer) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } } print "
        "; // Presend form - $modelmail='contact'; - $defaulttopic='Information'; + $modelmail = 'contact'; + $defaulttopic = 'Information'; $diroutput = $conf->contact->dir_output; $trackid = 'con'.$object->id; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index d1239087cfe..75f6271dbe4 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -100,9 +100,9 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer) { @@ -120,12 +120,12 @@ if (empty($reshook)) elseif ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->contrat->activer) { - if (! GETPOST('dateend')) + if (!GETPOST('dateend')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors'); } - if (! $error) + if (!$error) { $result = $object->close_line($user, GETPOST('ligne'), GETPOST('dateend'), urldecode(GETPOST('comment'))); if ($result > 0) @@ -141,56 +141,56 @@ if (empty($reshook)) } // Si ajout champ produit predefini - if (GETPOST('mode')=='predefined') + if (GETPOST('mode') == 'predefined') { - $date_start=''; - $date_end=''; + $date_start = ''; + $date_end = ''; if (GETPOST('date_startmonth') && GETPOST('date_startday') && GETPOST('date_startyear')) { - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); } if (GETPOST('date_endmonth') && GETPOST('date_endday') && GETPOST('date_endyear')) { - $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); } } // Si ajout champ produit libre - if (GETPOST('mode')=='libre') + if (GETPOST('mode') == 'libre') { - $date_start_sl=''; - $date_end_sl=''; + $date_start_sl = ''; + $date_end_sl = ''; if (GETPOST('date_start_slmonth') && GETPOST('date_start_slday') && GETPOST('date_start_slyear')) { - $date_start_sl=dol_mktime(GETPOST('date_start_slhour'), GETPOST('date_start_slmin'), 0, GETPOST('date_start_slmonth'), GETPOST('date_start_slday'), GETPOST('date_start_slyear')); + $date_start_sl = dol_mktime(GETPOST('date_start_slhour'), GETPOST('date_start_slmin'), 0, GETPOST('date_start_slmonth'), GETPOST('date_start_slday'), GETPOST('date_start_slyear')); } if (GETPOST('date_end_slmonth') && GETPOST('date_end_slday') && GETPOST('date_end_slyear')) { - $date_end_sl=dol_mktime(GETPOST('date_end_slhour'), GETPOST('date_end_slmin'), 0, GETPOST('date_end_slmonth'), GETPOST('date_end_slday'), GETPOST('date_end_slyear')); + $date_end_sl = dol_mktime(GETPOST('date_end_slhour'), GETPOST('date_end_slmin'), 0, GETPOST('date_end_slmonth'), GETPOST('date_end_slday'), GETPOST('date_end_slyear')); } } // Param dates - $date_contrat=''; - $date_start_update=''; - $date_end_update=''; - $date_start_real_update=''; - $date_end_real_update=''; + $date_contrat = ''; + $date_start_update = ''; + $date_end_update = ''; + $date_start_real_update = ''; + $date_end_real_update = ''; if (GETPOST('date_start_updatemonth') && GETPOST('date_start_updateday') && GETPOST('date_start_updateyear')) { - $date_start_update=dol_mktime(GETPOST('date_start_updatehour'), GETPOST('date_start_updatemin'), 0, GETPOST('date_start_updatemonth'), GETPOST('date_start_updateday'), GETPOST('date_start_updateyear')); + $date_start_update = dol_mktime(GETPOST('date_start_updatehour'), GETPOST('date_start_updatemin'), 0, GETPOST('date_start_updatemonth'), GETPOST('date_start_updateday'), GETPOST('date_start_updateyear')); } if (GETPOST('date_end_updatemonth') && GETPOST('date_end_updateday') && GETPOST('date_end_updateyear')) { - $date_end_update=dol_mktime(GETPOST('date_end_updatehour'), GETPOST('date_end_updatemin'), 0, GETPOST('date_end_updatemonth'), GETPOST('date_end_updateday'), GETPOST('date_end_updateyear')); + $date_end_update = dol_mktime(GETPOST('date_end_updatehour'), GETPOST('date_end_updatemin'), 0, GETPOST('date_end_updatemonth'), GETPOST('date_end_updateday'), GETPOST('date_end_updateyear')); } if (GETPOST('date_start_real_updatemonth') && GETPOST('date_start_real_updateday') && GETPOST('date_start_real_updateyear')) { - $date_start_real_update=dol_mktime(GETPOST('date_start_real_updatehour'), GETPOST('date_start_real_updatemin'), 0, GETPOST('date_start_real_updatemonth'), GETPOST('date_start_real_updateday'), GETPOST('date_start_real_updateyear')); + $date_start_real_update = dol_mktime(GETPOST('date_start_real_updatehour'), GETPOST('date_start_real_updatemin'), 0, GETPOST('date_start_real_updatemonth'), GETPOST('date_start_real_updateday'), GETPOST('date_start_real_updateyear')); } if (GETPOST('date_end_real_updatemonth') && GETPOST('date_end_real_updateday') && GETPOST('date_end_real_updateyear')) { - $date_end_real_update=dol_mktime(GETPOST('date_end_real_updatehour'), GETPOST('date_end_real_updatemin'), 0, GETPOST('date_end_real_updatemonth'), GETPOST('date_end_real_updateday'), GETPOST('date_end_real_updateyear')); + $date_end_real_update = dol_mktime(GETPOST('date_end_real_updatehour'), GETPOST('date_end_real_updatemin'), 0, GETPOST('date_end_real_updatemonth'), GETPOST('date_end_real_updateday'), GETPOST('date_end_real_updateyear')); } if (GETPOST('remonth') && GETPOST('reday') && GETPOST('reyear')) { @@ -250,15 +250,15 @@ if (empty($reshook)) } // For compatibility - if ($element == 'order') { $element = $subelement = 'commande'; } - if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } + if ($element == 'order') { $element = $subelement = 'commande'; } + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } $object->origin = $origin; $object->origin_id = $originid; // Possibility to add external linked objects with hooks $object->linked_objects[$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) + if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } @@ -276,7 +276,7 @@ if (empty($reshook)) $srcobject = new $classname($db); dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); - $result=$srcobject->fetch($object->origin_id); + $result = $srcobject->fetch($object->origin_id); if ($result > 0) { $srcobject->fetch_thirdparty(); @@ -287,43 +287,43 @@ if (empty($reshook)) $lines = $srcobject->lines; } - $fk_parent_line=0; - $num=count($lines); + $fk_parent_line = 0; + $num = count($lines); - for ($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); - if ($product_type == 1 || (! empty($conf->global->CONTRACT_SUPPORT_PRODUCTS) && in_array($product_type, array(0,1)))) { // TODO Exclude also deee + if ($product_type == 1 || (!empty($conf->global->CONTRACT_SUPPORT_PRODUCTS) && in_array($product_type, array(0, 1)))) { // TODO Exclude also deee // service prédéfini if ($lines[$i]->fk_product > 0) { $product_static = new Product($db); // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $prod = new Product($db); - $prod->id=$lines[$i]->fk_product; + $prod->id = $lines[$i]->fk_product; $prod->getMultiLangs(); $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if (empty($newlang)) $newlang=$srcobject->thirdparty->default_lang; - if (! empty($newlang)) + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (empty($newlang)) $newlang = $srcobject->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; } else { $label = $lines[$i]->product_label; } - $desc = ($lines[$i]->desc && $lines[$i]->desc!=$lines[$i]->libelle)?dol_htmlentitiesbr($lines[$i]->desc):''; + $desc = ($lines[$i]->desc && $lines[$i]->desc != $lines[$i]->libelle) ?dol_htmlentitiesbr($lines[$i]->desc) : ''; } else { $desc = dol_htmlentitiesbr($lines[$i]->desc); @@ -337,7 +337,7 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - $txtva = $lines[$i]->vat_src_code ? $lines[$i]->tva_tx . ' (' . $lines[$i]->vat_src_code . ')' : $lines[$i]->tva_tx; + $txtva = $lines[$i]->vat_src_code ? $lines[$i]->tva_tx.' ('.$lines[$i]->vat_src_code.')' : $lines[$i]->tva_tx; // View third's localtaxes for now $localtax1_tx = get_localtax($txtva, 1, $object->thirdparty); @@ -401,7 +401,7 @@ if (empty($reshook)) else { setEventMessages($object->error, $object->errors, 'errors'); } - $action='create'; + $action = 'create'; } } } @@ -415,18 +415,18 @@ if (empty($reshook)) elseif ($action == 'addline' && $user->rights->contrat->creer) { // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $predef = ''; + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); $price_ht = GETPOST('price_ht'); $price_ht_devise = GETPOST('multicurrency_price_ht'); if (GETPOST('prod_entry_mode') == 'free') { - $idprod=0; + $idprod = 0; $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } @@ -459,16 +459,16 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } - if (! $error) + if (!$error) { // Clean parameters - $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $price_base_type = (GETPOST('price_base_type', 'alpha') ?GETPOST('price_base_type', 'alpha') : 'HT'); // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit @@ -482,7 +482,7 @@ if (empty($reshook)) // Update if prices fields are defined $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; @@ -497,13 +497,13 @@ if (empty($reshook)) $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); + $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result) { @@ -512,9 +512,9 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines [0]->price_ttc); $price_base_type = $prodcustprice->lines [0]->price_base_type; $tva_tx = $prodcustprice->lines [0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; } } } @@ -596,13 +596,13 @@ if (empty($reshook)) if ($result > 0) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && ! empty($conf->global->CONTRACT_ADDON_PDF)) // No generation if default type not defined + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && !empty($conf->global->CONTRACT_ADDON_PDF)) // No generation if default type not defined { $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -651,7 +651,7 @@ if (empty($reshook)) } } - elseif ($action == 'updateline' && $user->rights->contrat->creer && ! GETPOST('cancel', 'alpha')) { + elseif ($action == 'updateline' && $user->rights->contrat->creer && !GETPOST('cancel', 'alpha')) { $error = 0; if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update) @@ -662,7 +662,7 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $objectline = new ContratLigne($db); if ($objectline->fetch(GETPOST('elrowid')) < 0) @@ -674,10 +674,10 @@ if (empty($reshook)) $db->begin(); - if (! $error) + if (!$error) { - if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture; - if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture; + if ($date_start_real_update == '') $date_start_real_update = $objectline->date_ouverture; + if ($date_end_real_update == '') $date_end_real_update = $objectline->date_cloture; $vat_rate = GETPOST('eltva_tx'); // Define info_bits @@ -687,44 +687,44 @@ if (empty($reshook)) // Define vat_rate $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_tx=get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); - $localtax2_tx=get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); + $localtax1_tx = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); + $localtax2_tx = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); $txtva = $vat_rate; // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } // ajout prix d'achat $fk_fournprice = $_POST['fournprice']; - if ( ! empty($_POST['buying_price']) ) + if (!empty($_POST['buying_price'])) $pa_ht = $_POST['buying_price']; else $pa_ht = null; $fk_unit = GETPOST('unit', 'alpha'); - $objectline->description=GETPOST('product_desc', 'none'); - $objectline->price_ht=GETPOST('elprice'); - $objectline->subprice=GETPOST('elprice'); - $objectline->qty=GETPOST('elqty'); - $objectline->remise_percent=GETPOST('elremise_percent'); - $objectline->tva_tx=($txtva?$txtva:0); // Field may be disabled, so we use vat rate 0 - $objectline->vat_src_code=$vat_src_code; - $objectline->localtax1_tx=is_numeric($localtax1_tx)?$localtax1_tx:0; - $objectline->localtax2_tx=is_numeric($localtax2_tx)?$localtax2_tx:0; - $objectline->date_ouverture_prevue=$date_start_update; - $objectline->date_ouverture=$date_start_real_update; - $objectline->date_fin_validite=$date_end_update; - $objectline->date_cloture=$date_end_real_update; - $objectline->fk_user_cloture=$user->id; - $objectline->fk_fournprice=$fk_fournprice; - $objectline->pa_ht=$pa_ht; + $objectline->description = GETPOST('product_desc', 'none'); + $objectline->price_ht = GETPOST('elprice'); + $objectline->subprice = GETPOST('elprice'); + $objectline->qty = GETPOST('elqty'); + $objectline->remise_percent = GETPOST('elremise_percent'); + $objectline->tva_tx = ($txtva ? $txtva : 0); // Field may be disabled, so we use vat rate 0 + $objectline->vat_src_code = $vat_src_code; + $objectline->localtax1_tx = is_numeric($localtax1_tx) ? $localtax1_tx : 0; + $objectline->localtax2_tx = is_numeric($localtax2_tx) ? $localtax2_tx : 0; + $objectline->date_ouverture_prevue = $date_start_update; + $objectline->date_ouverture = $date_start_real_update; + $objectline->date_fin_validite = $date_end_update; + $objectline->date_cloture = $date_end_real_update; + $objectline->fk_user_cloture = $user->id; + $objectline->fk_fournprice = $fk_fournprice; + $objectline->pa_ht = $pa_ht; if ($fk_unit > 0) { $objectline->fk_unit = GETPOST('unit'); @@ -747,7 +747,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $db->commit(); } @@ -785,11 +785,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -832,7 +832,7 @@ if (empty($reshook)) elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) { - $result=$object->delete($user); + $result = $object->delete($user); if ($result >= 0) { header("Location: list.php?restore_lastsearch_values=1"); @@ -849,9 +849,9 @@ if (empty($reshook)) if (GETPOST('newcid') > 0) { $contractline = new ContratLigne($db); - $result=$contractline->fetch(GETPOST('lineid')); + $result = $contractline->fetch(GETPOST('lineid')); $contractline->fk_contrat = GETPOST('newcid'); - $result=$contractline->update($user, 1); + $result = $contractline->update($user, 1); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); @@ -875,7 +875,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) { + if (!$error) { $result = $object->insertExtraFields('CONTRACT_MODIFY'); if ($result < 0) { @@ -888,7 +888,7 @@ if (empty($reshook)) $action = 'edit_extras'; } } - elseif ($action=='setref_supplier') + elseif ($action == 'setref_supplier') { $cancelbutton = GETPOST('cancel', 'alpha'); if (!$cancelbutton) { @@ -904,11 +904,11 @@ if (empty($reshook)) } } else { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } } - elseif ($action=='setref_customer') + elseif ($action == 'setref_customer') { $cancelbutton = GETPOST('cancel', 'alpha'); @@ -926,11 +926,11 @@ if (empty($reshook)) } } else { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } } - elseif ($action=='setref') + elseif ($action == 'setref') { $cancelbutton = GETPOST('cancel', 'alpha'); @@ -948,8 +948,8 @@ if (empty($reshook)) $action = 'editref'; } else { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $old_filedir = $conf->contrat->dir_output . '/' . dol_sanitizeFileName($old_ref); - $new_filedir = $conf->contrat->dir_output . '/' . dol_sanitizeFileName($object->ref); + $old_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($old_ref); + $new_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($object->ref); $files = dol_dir_list($old_filedir); if (!empty($files)) @@ -961,16 +961,16 @@ if (empty($reshook)) } } - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } } else { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } } - elseif ($action=='setdate_contrat') + elseif ($action == 'setdate_contrat') { $cancelbutton = GETPOST('cancel', 'alpha'); @@ -979,18 +979,18 @@ if (empty($reshook)) if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - $datacontrat=dol_mktime(GETPOST('date_contrathour'), GETPOST('date_contratmin'), 0, GETPOST('date_contratmonth'), GETPOST('date_contratday'), GETPOST('date_contratyear')); + $datacontrat = dol_mktime(GETPOST('date_contrathour'), GETPOST('date_contratmin'), 0, GETPOST('date_contratmonth'), GETPOST('date_contratday'), GETPOST('date_contratyear')); $result = $object->setValueFrom('date_contrat', $datacontrat, '', null, 'date', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'editdate_contrat'; } else { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } } else { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } } @@ -1002,14 +1002,14 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails - $trigger_name='CONTRACT_SENTBYMAIL'; - $paramname='id'; - $mode='emailfromcontract'; - $trackid='con'.$object->id; + $trigger_name = 'CONTRACT_SENTBYMAIL'; + $paramname = 'id'; + $mode = 'emailfromcontract'; + $trackid = 'con'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) { if ($action == 'addcontact') { @@ -1038,7 +1038,7 @@ if (empty($reshook)) // bascule du statut d'un contact elseif ($action == 'swapstatut') { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } // Efface un contact @@ -1060,7 +1060,7 @@ if (empty($reshook)) // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { - if (! GETPOST('socid', 3)) + if (!GETPOST('socid', 3)) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } @@ -1069,7 +1069,7 @@ if (empty($reshook)) if ($object->id > 0) { $result = $object->createFromClone($user, $socid); if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit(); } else { if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); @@ -1109,7 +1109,7 @@ if ($action == 'create') print load_fiche_titre($langs->trans('AddContract'), '', 'commercial'); $soc = new Societe($db); - if ($socid>0) $soc->fetch($socid); + if ($socid > 0) $soc->fetch($socid); if (GETPOST('origin') && GETPOST('originid')) { @@ -1123,13 +1123,13 @@ if ($action == 'create') if ($element == 'project') { - $projectid=GETPOST('originid'); + $projectid = GETPOST('originid'); } else { // For compatibility - if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; } - if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } + if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; } + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); @@ -1143,12 +1143,12 @@ if ($action == 'create') $objectsrc->fetch_optionals($originid); $object->array_options = $objectsrc->array_options; - $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); + $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); $soc = $objectsrc->thirdparty; - $note_private = (! empty($objectsrc->note_private) ? $objectsrc->note_private : ''); - $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); + $note_private = (!empty($objectsrc->note_private) ? $objectsrc->note_private : ''); + $note_public = (!empty($objectsrc->note_public) ? $objectsrc->note_public : ''); // Object source contacts list $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); @@ -1175,10 +1175,10 @@ if ($action == 'create') // Ref print '
        '.$langs->trans('Ref').''; - if (! empty($modCodeContract->code_auto)) { - $tmpcode=$langs->trans("Draft"); + if (!empty($modCodeContract->code_auto)) { + $tmpcode = $langs->trans("Draft"); } else { - $tmpcode=''; + $tmpcode = ''; } print $tmpcode; print '
        '.$langs->trans('ThirdParty').''; print $soc->getNomUrl(1); @@ -1210,14 +1210,14 @@ if ($action == 'create') } print '
        '.$langs->trans('Discounts').''; if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); else print $langs->trans("CompanyHasNoRelativeDiscount"); print '. '; - $absolute_discount=$soc->getAvailableDiscounts(); + $absolute_discount = $soc->getAvailableDiscounts(); if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); else print $langs->trans("CompanyHasNoAbsoluteDiscount"); print '.'; @@ -1226,12 +1226,12 @@ if ($action == 'create') // Commercial suivi print '
        '.$langs->trans("TypeContact_contrat_internal_SALESREPFOLL").''; - print $form->select_dolusers(GETPOST("commercial_suivi_id")?GETPOST("commercial_suivi_id"):$user->id, 'commercial_suivi_id', 1, ''); + print $form->select_dolusers(GETPOST("commercial_suivi_id") ?GETPOST("commercial_suivi_id") : $user->id, 'commercial_suivi_id', 1, ''); print '
        '.$langs->trans("TypeContact_contrat_internal_SALESREPSIGN").''; - print $form->select_dolusers(GETPOST("commercial_signature_id")?GETPOST("commercial_signature_id"):$user->id, 'commercial_signature_id', 1, ''); + print $form->select_dolusers(GETPOST("commercial_signature_id") ?GETPOST("commercial_signature_id") : $user->id, 'commercial_signature_id', 1, ''); print '
        '.$langs->trans("Date").''; @@ -1281,7 +1281,7 @@ if ($action == 'create') print '
        '; print ''; print '     '; - print ''; + print ''; print '
        '; if (is_object($objectsrc)) @@ -1304,20 +1304,20 @@ else /* */ /* *************************************************************************** */ { - $now=dol_now(); + $now = dol_now(); if ($object->id > 0) { $object->fetch_thirdparty(); - $soc = $object->thirdparty; // $soc is used later + $soc = $object->thirdparty; // $soc is used later - $result=$object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed + $result = $object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed if ($result < 0) { dol_print_error($db, $object->error); } - $nbofservices=count($object->lines); + $nbofservices = count($object->lines); $author = new User($db); $author->fetch($object->user_author_id); @@ -1356,8 +1356,8 @@ else $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", '', 0, 1); } elseif ($action == 'clone') { // Clone confirmation - $formquestion = array(array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formquestion = array(array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } @@ -1380,7 +1380,7 @@ else /* * Contrat */ - if (! empty($object->brouillon) && $user->rights->contrat->creer) + if (!empty($object->brouillon) && $user->rights->contrat->creer) { print '
        '; print ''; @@ -1460,7 +1460,7 @@ else print '
        '.$langs->trans('Discount').''; if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount=$object->thirdparty->getAvailableDiscounts(); + $absolute_discount = $object->thirdparty->getAvailableDiscounts(); print '. '; if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); else print $langs->trans("CompanyHasNoAbsoluteDiscount"); @@ -1478,27 +1478,27 @@ else // Other attributes $cols = 3; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print "
        "; print '
        '; - if (! empty($object->brouillon) && $user->rights->contrat->creer) + if (!empty($object->brouillon) && $user->rights->contrat->creer) { print ''; } echo '
        '; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); @@ -1508,53 +1508,53 @@ else $colorb = '666666'; - $arrayothercontracts=$object->getListOfContracts('others'); + $arrayothercontracts = $object->getListOfContracts('others'); /* * Lines of contracts */ - $productstatic=new Product($db); + $productstatic = new Product($db); - $usemargins=0; - if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element, array('facture','propal','commande'))) $usemargins=1; + $usemargins = 0; + if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'propal', 'commande'))) $usemargins = 1; - $var=false; + $var = false; // Title line for service - $cursorline=1; + $cursorline = 1; print '
        '; while ($cursorline <= $nbofservices) { - print '
        '; + print '
        '; print '
        '; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; // Area with common detail of line print '
        '; print ''; $sql = "SELECT cd.rowid, cd.statut, cd.label as label_det, cd.fk_product, cd.product_type, cd.description, cd.price_ht, cd.qty,"; - $sql.= " cd.tva_tx, cd.vat_src_code, cd.remise_percent, cd.info_bits, cd.subprice, cd.multicurrency_subprice,"; - $sql.= " cd.date_ouverture_prevue as date_debut, cd.date_ouverture as date_debut_reelle,"; - $sql.= " cd.date_fin_validite as date_fin, cd.date_cloture as date_fin_reelle,"; - $sql.= " cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,"; - $sql.= " cd.fk_unit,"; - $sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; - $sql.= " WHERE cd.rowid = ".$object->lines[$cursorline-1]->id; + $sql .= " cd.tva_tx, cd.vat_src_code, cd.remise_percent, cd.info_bits, cd.subprice, cd.multicurrency_subprice,"; + $sql .= " cd.date_ouverture_prevue as date_debut, cd.date_ouverture as date_debut_reelle,"; + $sql .= " cd.date_fin_validite as date_fin, cd.date_cloture as date_fin_reelle,"; + $sql .= " cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,"; + $sql .= " cd.fk_unit,"; + $sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; + $sql .= " WHERE cd.rowid = ".$object->lines[$cursorline - 1]->id; $result = $db->query($sql); if ($result) { $total = 0; - print ''; + print ''; print ''; print ''; print ''; @@ -1564,7 +1564,7 @@ else print ''; if ($conf->global->PRODUCT_USE_UNITS) print ''; print ''; - if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''; + if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''; print ''; print "\n"; @@ -1578,11 +1578,11 @@ else if ($objp->fk_product > 0) { print ''; } @@ -1608,7 +1608,7 @@ else } // VAT print ''; // Price print '\n"; @@ -1631,7 +1631,7 @@ else } // Margin - if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''; + if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print ''; // Icon move, update et delete (statut contrat 0=brouillon,1=valide,2=ferme) print ''; - print ''; + print ''; print "\n"; } @@ -1823,7 +1823,7 @@ else /* * Confirmation to delete service line of contract */ - if ($action == 'deleteline' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == GETPOST('rowid')) + if ($action == 'deleteline' && !$_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'), $langs->trans("DeleteContractLine"), $langs->trans("ConfirmDeleteContractLine"), "confirm_deleteline", '', 0, 1); if ($ret == 'html') print '
        '.$langs->trans("ServiceNb", $cursorline).''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").''.$langs->trans("Unit").''.$langs->trans("ReductionShort").''.$langs->trans("BuyingPrice").''.$langs->trans("BuyingPrice").' 
        '; - $productstatic->id=$objp->fk_product; - $productstatic->type=$objp->ptype; - $productstatic->ref=$objp->pref; - $productstatic->entity=$objp->pentity; - $productstatic->label=$objp->plabel; + $productstatic->id = $objp->fk_product; + $productstatic->type = $objp->ptype; + $productstatic->ref = $objp->pref; + $productstatic->entity = $objp->pentity; + $productstatic->label = $objp->plabel; $text = $productstatic->getNomUrl(1, '', 32); if ($objp->plabel) { @@ -1592,13 +1592,13 @@ else $description = $objp->description; // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { - $text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'
        '.dol_htmlentitiesbr($objp->description):''; - $description = ''; // Already added into main visible desc + $text .= (!empty($objp->description) && $objp->description != $objp->plabel) ? '
        '.dol_htmlentitiesbr($objp->description) : ''; + $description = ''; // Already added into main visible desc } - echo $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); + echo $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); print '
        '; - print vatrate($objp->tva_tx.($objp->vat_src_code?(' ('.$objp->vat_src_code.')'):''), '%', $objp->info_bits); + print vatrate($objp->tva_tx.($objp->vat_src_code ? (' ('.$objp->vat_src_code.')') : ''), '%', $objp->info_bits); print ''.($objp->subprice != '' ? price($objp->subprice) : '')."'.price($objp->pa_ht).''.price($objp->pa_ht).''; @@ -1648,7 +1648,7 @@ else print img_edit(); print ''; } - if ( $user->rights->contrat->creer && ($object->statut >= 0)) + if ($user->rights->contrat->creer && ($object->statut >= 0)) { print ''; print img_delete(); @@ -1679,7 +1679,7 @@ else print dol_print_date($db->jdate($objp->date_debut), 'day'); // Warning si date prevu passee et pas en service if ($objp->statut == 0 && $db->jdate($objp->date_debut) < ($now - $conf->contrat->services->inactifs->warning_delay)) { - $warning_delay=$conf->contrat->services->inactifs->warning_delay / 3600 / 24; + $warning_delay = $conf->contrat->services->inactifs->warning_delay / 3600 / 24; $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); print " ".img_warning($textlate); } @@ -1691,7 +1691,7 @@ else { print dol_print_date($db->jdate($objp->date_fin), 'day'); if ($objp->statut == 4 && $db->jdate($objp->date_fin) < ($now - $conf->contrat->services->expires->warning_delay)) { - $warning_delay=$conf->contrat->services->expires->warning_delay / 3600 / 24; + $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24; $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); print " ".img_warning($textlate); } @@ -1810,7 +1810,7 @@ else if ($object->statut > 0) { print '


        '; @@ -1832,16 +1832,16 @@ else /* * Confirmation to move service toward another contract */ - if ($action == 'move' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == GETPOST('rowid')) + if ($action == 'move' && !$_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { - $arraycontractid=array(); - foreach($arrayothercontracts as $contractcursor) + $arraycontractid = array(); + foreach ($arrayothercontracts as $contractcursor) { - $arraycontractid[$contractcursor->id]=$contractcursor->ref; + $arraycontractid[$contractcursor->id] = $contractcursor->ref; } //var_dump($arraycontractid); // Cree un tableau formulaire - $formquestion=array( + $formquestion = array( 'text' => $langs->trans("ConfirmMoveToAnotherContractQuestion"), array('type' => 'select', 'name' => 'newcid', 'values' => $arraycontractid)); @@ -1852,7 +1852,7 @@ else /* * Confirmation de la validation activation */ - if ($action == 'active' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == GETPOST('ligne')) + if ($action == 'active' && !$_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); @@ -1864,7 +1864,7 @@ else /* * Confirmation de la validation fermeture */ - if ($action == 'closeline' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == GETPOST('ligne')) + if ($action == 'closeline' && !$_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); @@ -1918,13 +1918,13 @@ else print '
        '; // Si pas encore active - if (! $objp->date_debut_reelle) { + if (!$objp->date_debut_reelle) { print $langs->trans("DateStartReal").': '; if ($objp->date_debut_reelle) print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); else print $langs->trans("ContractStatusNotRunning"); } // Si active et en cours - if ($objp->date_debut_reelle && ! $objp->date_fin_reelle) { + if ($objp->date_debut_reelle && !$objp->date_fin_reelle) { print $langs->trans("DateStartReal").': '; print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); } @@ -1936,7 +1936,7 @@ else print $langs->trans("DateEndReal").': '; print dol_print_date($db->jdate($objp->date_fin_reelle), 'day'); } - if (! empty($objp->comment)) print "  -  ".$objp->comment; + if (!empty($objp->comment)) print "  -  ".$objp->comment; print ' 
        '; + print '
        '; // Definie date debut et fin par defaut $dateactstart = $objp->date_debut; if (GETPOST('remonth')) $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - elseif (! $dateactstart) $dateactstart = time(); + elseif (!$dateactstart) $dateactstart = time(); $dateactend = $objp->date_fin; if (GETPOST('endmonth')) $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - elseif (! $dateactend) + elseif (!$dateactend) { if ($objp->fk_product > 0) { - $product=new Product($db); + $product = new Product($db); $product->fetch($objp->fk_product); $dateactend = dol_time_plus_duree(time(), $product->duration_value, $product->duration_unit); } @@ -1983,7 +1983,7 @@ else print ''; print ''; - print ''; + print ''; print ''; } else { - $out.=''; + $out .= ''; } // Status - $out.=''; + $out .= ''; // Actions - $out.=''; + $out .= ''; - $out.="\n"; + $out .= "\n"; $i++; } - $out.="
        '.$langs->trans("Comment").''.$langs->trans("Comment").''; print '   '; print ''; @@ -1995,37 +1995,37 @@ else print ''; } - if ($user->rights->contrat->activer && $action == 'unactivateline' && $object->lines[$cursorline-1]->id == GETPOST('ligne')) + if ($user->rights->contrat->activer && $action == 'unactivateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { /** * Disable a contract line */ print ''."\n"; - print '
        '; + print ''; print ''; print ''; - print ''; + print '
        '; // Definie date debut et fin par defaut $dateactstart = $objp->date_debut_reelle; if (GETPOST('remonth')) $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - elseif (! $dateactstart) $dateactstart = time(); + elseif (!$dateactstart) $dateactstart = time(); $dateactend = $objp->date_fin_reelle; if (GETPOST('endmonth')) $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - elseif (! $dateactend) + elseif (!$dateactend) { if ($objp->fk_product > 0) { - $product=new Product($db); + $product = new Product($db); $product->fetch($objp->fk_product); $dateactend = dol_time_plus_duree(time(), $product->duration_value, $product->duration_unit); } } - $now=dol_now(); - if ($dateactend > $now) $dateactend=$now; + $now = dol_now(); + if ($dateactend > $now) $dateactend = $now; print ''; @@ -2102,17 +2102,17 @@ else { print '
        '; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { // Send if ($object->statut == 1) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { - print ''; + print ''; } else - print ''; + print ''; } if ($object->statut == 0 && $nbofservices) @@ -2126,14 +2126,14 @@ else else print ''; } - if (! empty($conf->facture->enabled) && $object->statut > 0) + if (!empty($conf->facture->enabled) && $object->statut > 0) { $langs->load("bills"); if ($user->rights->facture->creer) print ''; else print ''; } - if (! empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) + if (!empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) { $langs->load("orders"); if ($user->rights->commande->creer) print ''; @@ -2142,7 +2142,7 @@ else // Clone if ($user->rights->contrat->creer) { - print ''; + print ''; } if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) @@ -2205,8 +2205,8 @@ else * Documents generes */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $filedir = $conf->contrat->dir_output."/".dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->rights->contrat->lire; $delallowed = $user->rights->contrat->creer; @@ -2226,7 +2226,7 @@ else $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt', DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id); // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'contract', $socid, 1, 'listactions', $MAXEVENT, '', $morehtmlright); @@ -2235,8 +2235,8 @@ else } // Presend form - $modelmail='contract'; - $defaulttopic='SendContractRef'; + $modelmail = 'contract'; + $defaulttopic = 'SendContractRef'; $diroutput = $conf->contrat->dir_output; $trackid = 'con'.$object->id; @@ -2251,7 +2251,7 @@ $db->close(); ?> margin->enabled) && $action == 'editline') +if (!empty($conf->margin->enabled) && $action == 'editline') { // TODO Why this ? To manage margin on contracts ? ?> diff --git a/htdocs/core/actions_changeselectedfields.inc.php b/htdocs/core/actions_changeselectedfields.inc.php index 45f588a71ef..9a03ba0d29e 100644 --- a/htdocs/core/actions_changeselectedfields.inc.php +++ b/htdocs/core/actions_changeselectedfields.inc.php @@ -30,16 +30,16 @@ // Save selection if (GETPOST('formfilteraction', 'none') == 'listafterchangingselectedfields') { - $tabparam=array(); + $tabparam = array(); - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields"); - else $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=''; + if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); + else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $result=dol_set_user_param($db, $conf, $user, $tabparam); + $result = dol_set_user_param($db, $conf, $user, $tabparam); //$action='list'; //var_dump($tabparam);exit; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 6a9bc0c9f29..e9e9706ae91 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -37,7 +37,7 @@ abstract class CommonDocGenerator /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Array of error strings @@ -74,7 +74,7 @@ abstract class CommonDocGenerator // phpcs:enable global $conf; - $logotouse=$conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo; + $logotouse = $conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo; return array( 'myuser_lastname'=>$user->lastname, @@ -112,20 +112,20 @@ abstract class CommonDocGenerator // phpcs:enable global $conf; - if (empty($mysoc->forme_juridique) && ! empty($mysoc->forme_juridique_code)) + if (empty($mysoc->forme_juridique) && !empty($mysoc->forme_juridique_code)) { - $mysoc->forme_juridique=getFormeJuridiqueLabel($mysoc->forme_juridique_code); + $mysoc->forme_juridique = getFormeJuridiqueLabel($mysoc->forme_juridique_code); } - if (empty($mysoc->country) && ! empty($mysoc->country_code)) + if (empty($mysoc->country) && !empty($mysoc->country_code)) { - $mysoc->country=$outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code); + $mysoc->country = $outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code); } - if (empty($mysoc->state) && ! empty($mysoc->state_code)) + if (empty($mysoc->state) && !empty($mysoc->state_code)) { - $mysoc->state=getState($mysoc->state_code, 0); + $mysoc->state = getState($mysoc->state_code, 0); } - $logotouse=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; + $logotouse = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; return array( 'mycompany_logo'=>$logotouse, @@ -172,13 +172,13 @@ abstract class CommonDocGenerator // phpcs:enable global $conf; - if (empty($object->country) && ! empty($object->country_code)) + if (empty($object->country) && !empty($object->country_code)) { - $object->country=$outputlangs->transnoentitiesnoconv("Country".$object->country_code); + $object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code); } - if (empty($object->state) && ! empty($object->state_code)) + if (empty($object->state) && !empty($object->state_code)) { - $object->state=getState($object->state_code, 0); + $object->state = getState($object->state_code, 0); } $array_thirdparty = array( @@ -326,7 +326,7 @@ abstract class CommonDocGenerator // phpcs:enable global $conf; - $now=dol_now('gmt'); // gmt + $now = dol_now('gmt'); // gmt $array_other = array( // Date in default language 'current_date'=>dol_print_date($now, 'day', 'tzuser'), @@ -341,7 +341,7 @@ abstract class CommonDocGenerator ); - foreach($conf->global as $key => $val) + foreach ($conf->global as $key => $val) { if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) $newval = '*****forbidden*****'; else $newval = $val; @@ -366,12 +366,12 @@ abstract class CommonDocGenerator // phpcs:enable global $conf; - $sumpayed=$sumdeposit=$sumcreditnote=''; - $already_payed_all=0; - $remain_to_pay=0; + $sumpayed = $sumdeposit = $sumcreditnote = ''; + $already_payed_all = 0; + $remain_to_pay = 0; if ($object->element == 'facture') { - $invoice_source=new Facture($this->db); + $invoice_source = new Facture($this->db); if ($object->fk_facture_source > 0) { $invoice_source->fetch($object->fk_facture_source); @@ -379,44 +379,44 @@ abstract class CommonDocGenerator $sumpayed = $object->getSommePaiement(); $sumdeposit = $object->getSumDepositsUsed(); $sumcreditnote = $object->getSumCreditNotesUsed(); - $already_payed_all=$sumpayed + $sumdeposit + $sumcreditnote; - $remain_to_pay=$sumpayed - $sumdeposit - $sumcreditnote; + $already_payed_all = $sumpayed + $sumdeposit + $sumcreditnote; + $remain_to_pay = $sumpayed - $sumdeposit - $sumcreditnote; } $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); - $resarray=array( + $resarray = array( $array_key.'_id'=>$object->id, $array_key.'_ref'=>$object->ref, $array_key.'_ref_ext'=>$object->ref_ext, - $array_key.'_ref_customer'=>(! empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), - $array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), + $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), + $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), $array_key.'_source_invoice_ref'=>$invoice_source->ref, // Dates $array_key.'_hour'=>dol_print_date($date, 'hour'), $array_key.'_date'=>dol_print_date($date, 'day'), $array_key.'_date_rfc'=>dol_print_date($date, 'dayrfc'), - $array_key.'_date_limit'=>(! empty($object->date_lim_reglement)?dol_print_date($object->date_lim_reglement, 'day'):''), - $array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite, 'day'):''), + $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ?dol_print_date($object->date_lim_reglement, 'day') : ''), + $array_key.'_date_end'=>(!empty($object->fin_validite) ?dol_print_date($object->fin_validite, 'day') : ''), $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), - $array_key.'_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification, 'day'):''), - $array_key.'_date_validation'=>(! empty($object->date_validation)?dol_print_date($object->date_validation, 'dayhour'):''), - $array_key.'_date_delivery_planed'=>(! empty($object->date_livraison)?dol_print_date($object->date_livraison, 'day'):''), - $array_key.'_date_close'=>(! empty($object->date_cloture)?dol_print_date($object->date_cloture, 'dayhour'):''), + $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), + $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), + $array_key.'_date_delivery_planed'=>(!empty($object->date_livraison) ?dol_print_date($object->date_livraison, 'day') : ''), + $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), $array_key.'_payment_mode_code'=>$object->mode_reglement_code, - $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement), + $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) : $object->mode_reglement), $array_key.'_payment_term_code'=>$object->cond_reglement_code, - $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):($object->cond_reglement_doc?$object->cond_reglement_doc:$object->cond_reglement)), + $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), - $array_key.'_total_vat_locale'=>(! empty($object->total_vat)?price($object->total_vat, 0, $outputlangs):price($object->total_tva, 0, $outputlangs)), + $array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)), $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), $array_key.'_total_ht'=>price2num($object->total_ht), - $array_key.'_total_vat'=>(! empty($object->total_vat)?price2num($object->total_vat):price2num($object->total_tva)), + $array_key.'_total_vat'=>(!empty($object->total_vat) ?price2num($object->total_vat) : price2num($object->total_tva)), $array_key.'_total_localtax1'=>price2num($object->total_localtax1), $array_key.'_total_localtax2'=>price2num($object->total_localtax2), $array_key.'_total_ttc'=>price2num($object->total_ttc), @@ -432,7 +432,7 @@ abstract class CommonDocGenerator $array_key.'_note_private'=>$object->note, $array_key.'_note_public'=>$object->note_public, - $array_key.'_note'=>$object->note_public, // For backward compatibility + $array_key.'_note'=>$object->note_public, // For backward compatibility // Payments $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), @@ -459,9 +459,9 @@ abstract class CommonDocGenerator } // Fetch project information if there is a project assigned to this object - if ($object->element != "project" && ! empty($object->fk_project) && $object->fk_project > 0) + if ($object->element != "project" && !empty($object->fk_project) && $object->fk_project > 0) { - if (! is_object($object->project)) + if (!is_object($object->project)) { $object->fetch_projet(); } @@ -513,7 +513,7 @@ abstract class CommonDocGenerator // Retrieve extrafields if (is_array($object->array_options) && count($object->array_options)) { - $extrafieldkey=$object->element; + $extrafieldkey = $object->element; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); @@ -539,7 +539,7 @@ abstract class CommonDocGenerator // phpcs:enable global $conf; - $resarray= array( + $resarray = array( 'line_fulldesc'=>doc_getlinedesc($line, $outputlangs), 'line_product_ref'=>$line->product_ref, 'line_product_ref_fourn'=>$line->ref_fourn, // for supplier doc lines @@ -554,7 +554,7 @@ abstract class CommonDocGenerator 'line_total_up'=>price2num($line->subprice * $line->qty), 'line_total_up_locale'=>price($line->subprice * $line->qty, 0, $outputlangs), 'line_qty'=>$line->qty, - 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), + 'line_discount_percent'=>($line->remise_percent ? $line->remise_percent.'%' : ''), 'line_price_ht'=>price2num($line->total_ht), 'line_price_ttc'=>price2num($line->total_ttc), 'line_price_vat'=>price2num($line->total_tva), @@ -625,7 +625,7 @@ abstract class CommonDocGenerator { $tmpproduct = new Product($this->db); $result = $tmpproduct->fetch($line->fk_product); - foreach($tmpproduct->array_options as $key=>$label) + foreach ($tmpproduct->array_options as $key=>$label) $resarray["line_product_".$key] = $label; } @@ -647,9 +647,9 @@ abstract class CommonDocGenerator global $conf; dol_include_once('/core/lib/product.lib.php'); $object->list_delivery_methods($object->shipping_method_id); - $calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth); + $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); - $array_shipment=array( + $array_shipment = array( $array_key.'_id'=>$object->id, $array_key.'_ref'=>$object->ref, $array_key.'_ref_ext'=>$object->ref_ext, @@ -676,8 +676,8 @@ abstract class CommonDocGenerator // Add vat by rates foreach ($object->lines as $line) { - if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; - $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; + if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx] = 0; + $array_shipment[$array_key.'_total_vat_'.$line->tva_tx] += $line->total_tva; } // Retrieve extrafields @@ -758,7 +758,7 @@ abstract class CommonDocGenerator // phpcs:enable $array_other = array(); if (!empty($object)) { - foreach($object as $key => $value) { + foreach ($object as $key => $value) { if (!empty($value)) { if (!is_array($value) && !is_object($value)) { $array_other['object_'.$key] = $value; @@ -862,7 +862,7 @@ abstract class CommonDocGenerator } } - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); } return $array_to_fill; @@ -883,10 +883,10 @@ abstract class CommonDocGenerator */ public function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) { - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); - $pdf->line($x+$l, $y, $x+$l, $y+$h); - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); - $pdf->line($x, $y+$h, $x, $y); + if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y); + $pdf->line($x + $l, $y, $x + $l, $y + $h); + if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h); + $pdf->line($x, $y + $h, $x, $y); } @@ -899,8 +899,8 @@ abstract class CommonDocGenerator */ public function columnSort($a, $b) { - if(empty($a['rank'])){ $a['rank'] = 0; } - if(empty($b['rank'])){ $b['rank'] = 0; } + if (empty($a['rank'])) { $a['rank'] = 0; } + if (empty($b['rank'])) { $b['rank'] = 0; } if ($a['rank'] == $b['rank']) { return 0; } @@ -956,25 +956,25 @@ abstract class CommonDocGenerator foreach ($this->cols as $colKey =>& $colDef) { // setting empty conf with default - if(!empty($colDef['title'])){ + if (!empty($colDef['title'])) { $colDef['title'] = array_replace($this->defaultTitlesFieldsStyle, $colDef['title']); } - else{ + else { $colDef['title'] = $this->defaultTitlesFieldsStyle; } // setting empty conf with default - if(!empty($colDef['content'])){ + if (!empty($colDef['content'])) { $colDef['content'] = array_replace($this->defaultContentsFieldsStyle, $colDef['content']); } - else{ + else { $colDef['content'] = $this->defaultContentsFieldsStyle; } - if($this->getColumnStatus($colKey)) + if ($this->getColumnStatus($colKey)) { // In case of flexible column - if(empty($colDef['width'])){ + if (empty($colDef['width'])) { $colDef['width'] = abs(($arrayWidth - $totalDefinedColWidth)) / $countFlexCol; } @@ -1020,7 +1020,7 @@ abstract class CommonDocGenerator */ public function getColumnRank($colKey) { - if(!isset($this->cols[$colKey]['rank'])) return -1; + if (!isset($this->cols[$colKey]['rank'])) return -1; return $this->cols[$colKey]['rank']; } @@ -1039,22 +1039,22 @@ abstract class CommonDocGenerator $rank = -1; // try to get rank from target column - if(!empty($targetCol)){ + if (!empty($targetCol)) { $rank = $this->getColumnRank($targetCol); - if($rank>=0 && $insertAfterTarget){ $rank++; } + if ($rank >= 0 && $insertAfterTarget) { $rank++; } } // get rank from new column definition - if($rank<0 && !empty($defArray['rank'])){ + if ($rank < 0 && !empty($defArray['rank'])) { $rank = $defArray['rank']; } // error: no rank - if($rank<0){ return -1; } + if ($rank < 0) { return -1; } foreach ($this->cols as $colKey =>& $colDef) { - if( $rank <= $colDef['rank']) + if ($rank <= $colDef['rank']) { $colDef['rank'] = $colDef['rank'] + 1; } @@ -1080,16 +1080,16 @@ abstract class CommonDocGenerator { global $hookmanager; - $parameters=array( + $parameters = array( 'curY' => &$curY, 'columnText' => $columnText, 'colKey' => $colKey ); - $reshook=$hookmanager->executeHooks('printStdColumnContent', $parameters, $this); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printStdColumnContent', $parameters, $this); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (!$reshook) { - if(empty($columnText)) return; + if (empty($columnText)) return; $pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position $colDef = $this->cols[$colKey]; $pdf->writeHTMLCell($this->getColumnContentWidth($colKey), 2, $this->getColumnContentXStart($colKey), $curY, $columnText, 0, 0, 0, true, $colDef['content']['align']); @@ -1105,7 +1105,7 @@ abstract class CommonDocGenerator */ public function getColumnStatus($colKey) { - if( !empty($this->cols[$colKey]['status'])){ + if (!empty($this->cols[$colKey]['status'])) { return true; } else return false; @@ -1135,7 +1135,7 @@ abstract class CommonDocGenerator 'hidetop' => $hidetop ); - $reshook = $hookmanager->executeHooks('pdfTabTitles', $parameters, $this); // Note that $object may have been modified by hook + $reshook = $hookmanager->executeHooks('pdfTabTitles', $parameters, $this); // Note that $object may have been modified by hook if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } elseif (empty($reshook)) { diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 9ba90d00e62..b4512b167f8 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -51,8 +51,8 @@ class Conf //! Used to store current currency (ISO code like 'USD', 'EUR', ...) public $currency; //! Used to store current css (from theme) - public $theme; // Contains current theme ("eldy", "auguria", ...) - public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...) + public $theme; // Contains current theme ("eldy", "auguria", ...) + public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...) //! Used to store current menu handler public $standard_menu; // List of activated modules @@ -86,15 +86,15 @@ class Conf //! To store properties of multi-company public $multicompany; //! Used to store running instance for multi-company (default 1) - public $entity = 1; + public $entity = 1; //! Used to store list of entities to use for each element - public $entities = array(); + public $entities = array(); - public $dol_hide_topmenu; // Set if we force param dol_hide_topmenu into login url - public $dol_hide_leftmenu; // Set if we force param dol_hide_leftmenu into login url - public $dol_optimize_smallscreen; // Set if we force param dol_optimize_smallscreen into login url or if browser is smartphone - public $dol_no_mouse_hover; // Set if we force param dol_no_mouse_hover into login url or if browser is smartphone - public $dol_use_jmobile; // Set if we force param dol_use_jmobile into login url + public $dol_hide_topmenu; // Set if we force param dol_hide_topmenu into login url + public $dol_hide_leftmenu; // Set if we force param dol_hide_leftmenu into login url + public $dol_optimize_smallscreen; // Set if we force param dol_optimize_smallscreen into login url or if browser is smartphone + public $dol_no_mouse_hover; // Set if we force param dol_no_mouse_hover into login url or if browser is smartphone + public $dol_use_jmobile; // Set if we force param dol_use_jmobile into login url /** @@ -103,38 +103,38 @@ class Conf public function __construct() { // Properly declare multi-modules objects. - $this->file = new stdClass(); - $this->db = new stdClass(); - $this->global = new stdClass(); - $this->mycompany = new stdClass(); + $this->file = new stdClass(); + $this->db = new stdClass(); + $this->global = new stdClass(); + $this->mycompany = new stdClass(); $this->admin = new stdClass(); $this->user = new stdClass(); $this->syslog = new stdClass(); - $this->browser = new stdClass(); + $this->browser = new stdClass(); $this->medias = new stdClass(); - $this->multicompany = new stdClass(); + $this->multicompany = new stdClass(); //! Charset for HTML output and for storing data in memory - $this->file->character_set_client='UTF-8'; // UTF-8, ISO-8859-1 + $this->file->character_set_client = 'UTF-8'; // UTF-8, ISO-8859-1 // First level object // TODO Remove this part. - $this->expedition_bon = new stdClass(); - $this->livraison_bon = new stdClass(); - $this->fournisseur = new stdClass(); + $this->expedition_bon = new stdClass(); + $this->livraison_bon = new stdClass(); + $this->fournisseur = new stdClass(); $this->product = new stdClass(); $this->service = new stdClass(); $this->contrat = new stdClass(); $this->actions = new stdClass(); - $this->commande = new stdClass(); - $this->propal = new stdClass(); + $this->commande = new stdClass(); + $this->propal = new stdClass(); $this->facture = new stdClass(); $this->contrat = new stdClass(); $this->usergroup = new stdClass(); $this->adherent = new stdClass(); - $this->bank = new stdClass(); + $this->bank = new stdClass(); $this->notification = new stdClass(); - $this->mailing = new stdClass(); + $this->mailing = new stdClass(); $this->expensereport = new stdClass(); $this->productbatch = new stdClass(); } @@ -155,10 +155,10 @@ class Conf //Define all global constants into $this->global->key=value $sql = "SELECT ".$db->decrypt('name')." as name,"; - $sql.= " ".$db->decrypt('value')." as value, entity"; - $sql.= " FROM ".MAIN_DB_PREFIX."const"; - $sql.= " WHERE entity IN (0,".$this->entity.")"; - $sql.= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite. + $sql .= " ".$db->decrypt('value')." as value, entity"; + $sql .= " FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE entity IN (0,".$this->entity.")"; + $sql .= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite. $resql = $db->query($sql); if ($resql) @@ -168,12 +168,12 @@ class Conf while ($i < $numr) { $objp = $db->fetch_object($resql); - $key=$objp->name; - $value=$objp->value; + $key = $objp->name; + $value = $objp->value; if ($key) { //if (! defined("$key")) define("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install) - $this->global->$key=$value; + $this->global->$key = $value; if ($value && preg_match('/^MAIN_MODULE_/', $key)) { @@ -182,9 +182,9 @@ class Conf if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) { $partname = 'tabs'; - $params=explode(':', $value, 2); - if (! isset($this->modules_parts[$partname]) || ! is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } - $this->modules_parts[$partname][$params[0]][]=$value; // $value may be a string or an array + $params = explode(':', $value, 2); + if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } + $this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array } // If this is constant for all generic part activated by a module. It initializes // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'], @@ -195,24 +195,24 @@ class Conf { $modulename = strtolower($reg[1]); $partname = strtolower($reg[2]); - if (! isset($this->modules_parts[$partname]) || ! is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } + if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } $arrValue = json_decode($value, true); - if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue; - elseif (in_array($partname, array('login','menus','substitutions','triggers','tpl'))) $value = '/'.$modulename.'/core/'.$partname.'/'; - elseif (in_array($partname, array('models','theme'))) $value = '/'.$modulename.'/'; + if (is_array($arrValue) && !empty($arrValue)) $value = $arrValue; + elseif (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) $value = '/'.$modulename.'/core/'.$partname.'/'; + elseif (in_array($partname, array('models', 'theme'))) $value = '/'.$modulename.'/'; elseif (in_array($partname, array('sms'))) $value = '/'.$modulename.'/'; - elseif ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe - $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array + elseif ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe + $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array } // If this is a module constant (must be at end) elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) { - $modulename=strtolower($reg[1]); - if ($modulename == 'propale') $modulename='propal'; - if ($modulename == 'supplierproposal') $modulename='supplier_proposal'; - if (! isset($this->$modulename) || ! is_object($this->$modulename)) $this->$modulename=new stdClass(); - $this->$modulename->enabled=true; - $this->modules[]=$modulename; // Add this module in list of enabled modules + $modulename = strtolower($reg[1]); + if ($modulename == 'propale') $modulename = 'propal'; + if ($modulename == 'supplierproposal') $modulename = 'supplier_proposal'; + if (!isset($this->$modulename) || !is_object($this->$modulename)) $this->$modulename = new stdClass(); + $this->$modulename->enabled = true; + $this->modules[] = $modulename; // Add this module in list of enabled modules } } } @@ -237,19 +237,19 @@ class Conf // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC. // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore. //$this->global->MAIN_SERVER_TZ='Europe/Paris'; - if (! empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto') + if (!empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto') { try { date_default_timezone_set($this->global->MAIN_SERVER_TZ); } - catch(Exception $e) + catch (Exception $e) { dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=".$this->global->MAIN_SERVER_TZ, LOG_ERR); } } // Object $mc - if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) { + if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) { global $mc; $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); if ($ret) { @@ -259,60 +259,60 @@ class Conf } // Clean some variables - if (empty($this->global->MAIN_MENU_STANDARD)) $this->global->MAIN_MENU_STANDARD="eldy_menu.php"; - if (empty($this->global->MAIN_MENUFRONT_STANDARD)) $this->global->MAIN_MENUFRONT_STANDARD="eldy_menu.php"; - if (empty($this->global->MAIN_MENU_SMARTPHONE)) $this->global->MAIN_MENU_SMARTPHONE="eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones - if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) $this->global->MAIN_MENUFRONT_SMARTPHONE="eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones + if (empty($this->global->MAIN_MENU_STANDARD)) $this->global->MAIN_MENU_STANDARD = "eldy_menu.php"; + if (empty($this->global->MAIN_MENUFRONT_STANDARD)) $this->global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php"; + if (empty($this->global->MAIN_MENU_SMARTPHONE)) $this->global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones + if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) $this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones // Clean var use vat for company - if (! isset($this->global->FACTURE_TVAOPTION)) $this->global->FACTURE_TVAOPTION=1; - elseif (! empty($this->global->FACTURE_TVAOPTION) && ! is_numeric($this->global->FACTURE_TVAOPTION)) + if (!isset($this->global->FACTURE_TVAOPTION)) $this->global->FACTURE_TVAOPTION = 1; + elseif (!empty($this->global->FACTURE_TVAOPTION) && !is_numeric($this->global->FACTURE_TVAOPTION)) { // Old value of option, we clean to use new value (0 or 1) - if ($this->global->FACTURE_TVAOPTION != "franchise") $this->global->FACTURE_TVAOPTION=1; - else $this->global->FACTURE_TVAOPTION=0; + if ($this->global->FACTURE_TVAOPTION != "franchise") $this->global->FACTURE_TVAOPTION = 1; + else $this->global->FACTURE_TVAOPTION = 0; } // Variable globales LDAP - if (empty($this->global->LDAP_FIELD_FULLNAME)) $this->global->LDAP_FIELD_FULLNAME=''; - if (! isset($this->global->LDAP_KEY_USERS)) $this->global->LDAP_KEY_USERS=$this->global->LDAP_FIELD_FULLNAME; - if (! isset($this->global->LDAP_KEY_GROUPS)) $this->global->LDAP_KEY_GROUPS=$this->global->LDAP_FIELD_FULLNAME; - if (! isset($this->global->LDAP_KEY_CONTACTS)) $this->global->LDAP_KEY_CONTACTS=$this->global->LDAP_FIELD_FULLNAME; - if (! isset($this->global->LDAP_KEY_MEMBERS)) $this->global->LDAP_KEY_MEMBERS=$this->global->LDAP_FIELD_FULLNAME; - if (! isset($this->global->LDAP_KEY_MEMBERS_TYPES)) $this->global->LDAP_KEY_MEMBERS_TYPES=$this->global->LDAP_FIELD_FULLNAME; + if (empty($this->global->LDAP_FIELD_FULLNAME)) $this->global->LDAP_FIELD_FULLNAME = ''; + if (!isset($this->global->LDAP_KEY_USERS)) $this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME; + if (!isset($this->global->LDAP_KEY_GROUPS)) $this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME; + if (!isset($this->global->LDAP_KEY_CONTACTS)) $this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME; + if (!isset($this->global->LDAP_KEY_MEMBERS)) $this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME; + if (!isset($this->global->LDAP_KEY_MEMBERS_TYPES)) $this->global->LDAP_KEY_MEMBERS_TYPES = $this->global->LDAP_FIELD_FULLNAME; // Load translation object with current language - if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US"; + if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT = "en_US"; $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; // If multicompany module is enabled, we redefine the root of data - if (! empty($this->multicompany->enabled) && ! empty($this->entity) && $this->entity > 1) + if (!empty($this->multicompany->enabled) && !empty($this->entity) && $this->entity > 1) { - $rootfordata.='/'.$this->entity; + $rootfordata .= '/'.$this->entity; } // Define default dir_output and dir_temp for directories of modules - foreach($this->modules as $module) + foreach ($this->modules as $module) { //var_dump($module); // For multicompany sharings - $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module); - $this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp"); + $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module); + $this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp"); // For backward compatibility - $this->$module->dir_output = $rootfordata."/".$module; - $this->$module->dir_temp = $rootfordata."/".$module."/temp"; + $this->$module->dir_output = $rootfordata."/".$module; + $this->$module->dir_temp = $rootfordata."/".$module."/temp"; } // External modules storage - if (! empty($this->modules_parts['dir'])) + if (!empty($this->modules_parts['dir'])) { - foreach($this->modules_parts['dir'] as $module => $dirs) + foreach ($this->modules_parts['dir'] as $module => $dirs) { - if (! empty($this->$module->enabled)) + if (!empty($this->$module->enabled)) { - foreach($dirs as $type => $name) + foreach ($dirs as $type => $name) { - $subdir=($type=='temp'?'/temp':''); + $subdir = ($type == 'temp' ? '/temp' : ''); // For multicompany sharings $varname = 'multidir_'.$type; $this->$module->$varname = array($this->entity => $rootfordata."/".$name.$subdir); @@ -706,7 +706,7 @@ class Conf $dir = dol_buildpath($reldir, 0); $newdir = dol_osencode($dir); if (is_dir($newdir)) { - $file = $newdir . $handler . '.php'; + $file = $newdir.$handler.'.php'; if (file_exists($file)) { $handler_files[] = $file; } @@ -714,7 +714,7 @@ class Conf } if (empty($handler_files)) { - throw new Exception('Missing log handler file ' . $handler . '.php'); + throw new Exception('Missing log handler file '.$handler.'.php'); } require_once $handler_files[0]; diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index b0e0ab3c86c..b571858cc84 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -34,7 +34,7 @@ class Cstate // extends CommonObject /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -56,12 +56,12 @@ class Cstate // extends CommonObject * @deprecated * @see $name */ - public $nom=''; + public $nom = ''; /** * @var string name */ - public $name=''; + public $name = ''; public $active; @@ -89,36 +89,36 @@ class Cstate // extends CommonObject public function create($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); - if (isset($this->nom)) $this->nom=trim($this->nom); - if (isset($this->active)) $this->active=trim($this->active); + if (isset($this->code_departement)) $this->code_departement = trim($this->code_departement); + if (isset($this->nom)) $this->nom = trim($this->nom); + if (isset($this->active)) $this->active = trim($this->active); // Check parameters // Put here code to add control on parameters values // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_departements("; - $sql.= "rowid,"; - $sql.= "code_departement,"; - $sql.= "nom,"; - $sql.= "active"; - $sql.= ") VALUES ("; - $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").","; - $sql.= " ".(! isset($this->code_departement)?'NULL':"'".$this->db->escape($this->code_departement)."'").","; - $sql.= " ".(! isset($this->nom)?'NULL':"'".$this->db->escape($this->nom)."'").","; - $sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").""; - $sql.= ")"; + $sql .= "rowid,"; + $sql .= "code_departement,"; + $sql .= "nom,"; + $sql .= "active"; + $sql .= ") VALUES ("; + $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; + $sql .= " ".(!isset($this->code_departement) ? 'NULL' : "'".$this->db->escape($this->code_departement)."'").","; + $sql .= " ".(!isset($this->nom) ? 'NULL' : "'".$this->db->escape($this->nom)."'").","; + $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'").""; + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) { + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); //if (! $notrigger) { @@ -137,13 +137,13 @@ class Cstate // extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -164,23 +164,23 @@ class Cstate // extends CommonObject { global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.code_departement,"; - $sql.= " t.nom,"; - $sql.= " t.active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_departements as t"; - if ($id) $sql.= " WHERE t.rowid = ".$id; - elseif ($code) $sql.= " WHERE t.code_departement = '".$this->db->escape($code)."'"; + $sql .= " t.rowid,"; + $sql .= " t.code_departement,"; + $sql .= " t.nom,"; + $sql .= " t.active"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_departements as t"; + if ($id) $sql .= " WHERE t.rowid = ".$id; + elseif ($code) $sql .= " WHERE t.code_departement = '".$this->db->escape($code)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code_departement = $obj->code_departement; $this->nom = $obj->nom; $this->active = $obj->active; @@ -191,7 +191,7 @@ class Cstate // extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -207,12 +207,12 @@ class Cstate // extends CommonObject public function update($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->code_departement)) $this->code_departement=trim($this->code_departement); - if (isset($this->nom)) $this->nom=trim($this->nom); - if (isset($this->active)) $this->active=trim($this->active); + if (isset($this->code_departement)) $this->code_departement = trim($this->code_departement); + if (isset($this->nom)) $this->nom = trim($this->nom); + if (isset($this->active)) $this->active = trim($this->active); // Check parameters @@ -220,16 +220,16 @@ class Cstate // extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET"; - $sql.= " code_departement=".(isset($this->code_departement)?"'".$this->db->escape($this->code_departement)."'":"null").","; - $sql.= " nom=".(isset($this->nom)?"'".$this->db->escape($this->nom)."'":"null").","; - $sql.= " active=".(isset($this->active)?$this->active:"null").""; - $sql.= " WHERE rowid=".$this->id; + $sql .= " code_departement=".(isset($this->code_departement) ? "'".$this->db->escape($this->code_departement)."'" : "null").","; + $sql .= " nom=".(isset($this->nom) ? "'".$this->db->escape($this->nom)."'" : "null").","; + $sql .= " active=".(isset($this->active) ? $this->active : "null").""; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } //if (! $error) //{ @@ -271,16 +271,16 @@ class Cstate // extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_departements"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } //if (! $error) //{ @@ -301,13 +301,13 @@ class Cstate // extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 8567ef595a0..a335397ec9a 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -140,7 +140,7 @@ class ExtraFields /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Array of Error code (or message) @@ -153,7 +153,7 @@ class ExtraFields public $errno; - public static $type2label=array( + public static $type2label = array( 'varchar'=>'String', 'text'=>'TextLong', 'html'=>'HtmlText', @@ -280,67 +280,67 @@ class ExtraFields */ private function create($attrname, $type = 'varchar', $length = 255, $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = '', $perms = '', $list = '0', $computed = '', $help = '') { - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - $table=$elementtype.'_extrafields'; - if ($elementtype == 'categorie') $table='categories_extrafields'; + $table = $elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table = 'categories_extrafields'; - if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/", $attrname) && ! is_numeric($attrname)) + if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/", $attrname) && !is_numeric($attrname)) { - if ($type=='boolean') { - $typedb='int'; - $lengthdb='1'; - } elseif($type=='price') { - $typedb='double'; - $lengthdb='24,8'; - } elseif($type=='phone') { - $typedb='varchar'; - $lengthdb='20'; - } elseif($type=='mail') { - $typedb='varchar'; - $lengthdb='128'; - } elseif($type=='url') { - $typedb='varchar'; - $lengthdb='255'; - } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox') ||($type=='chkbxlst')){ - $typedb='varchar'; - $lengthdb='255'; - } elseif ($type=='link') { - $typedb='int'; - $lengthdb='11'; - } elseif ($type=='html') { - $typedb='text'; - $lengthdb=$length; - } elseif($type=='password') { - $typedb='varchar'; - $lengthdb='128'; + if ($type == 'boolean') { + $typedb = 'int'; + $lengthdb = '1'; + } elseif ($type == 'price') { + $typedb = 'double'; + $lengthdb = '24,8'; + } elseif ($type == 'phone') { + $typedb = 'varchar'; + $lengthdb = '20'; + } elseif ($type == 'mail') { + $typedb = 'varchar'; + $lengthdb = '128'; + } elseif ($type == 'url') { + $typedb = 'varchar'; + $lengthdb = '255'; + } elseif (($type == 'select') || ($type == 'sellist') || ($type == 'radio') || ($type == 'checkbox') || ($type == 'chkbxlst')) { + $typedb = 'varchar'; + $lengthdb = '255'; + } elseif ($type == 'link') { + $typedb = 'int'; + $lengthdb = '11'; + } elseif ($type == 'html') { + $typedb = 'text'; + $lengthdb = $length; + } elseif ($type == 'password') { + $typedb = 'varchar'; + $lengthdb = '128'; } else { - $typedb=$type; - $lengthdb=$length; - if ($type == 'varchar' && empty($lengthdb)) $lengthdb='255'; + $typedb = $type; + $lengthdb = $length; + if ($type == 'varchar' && empty($lengthdb)) $lengthdb = '255'; } $field_desc = array( 'type'=>$typedb, 'value'=>$lengthdb, - 'null'=>($required?'NOT NULL':'NULL'), + 'null'=>($required ? 'NOT NULL' : 'NULL'), 'default' => $default_value ); - $result=$this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); + $result = $this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); if ($result > 0) { if ($unique) { - $sql="ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; - $resql=$this->db->query($sql, 1, 'dml'); + $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; + $resql = $this->db->query($sql, 1, 'dml'); } return 1; } else { - $this->error=$this->db->lasterror(); - $this->errno=$this->db->lasterrno(); + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); return -1; } } @@ -378,19 +378,19 @@ class ExtraFields private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = 0, $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0) { // phpcs:enable - global $conf,$user; + global $conf, $user; - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; // Clean parameters - if (empty($pos)) $pos=0; - if (empty($list)) $list='0'; - if (empty($required)) $required=0; - if (empty($unique)) $unique=0; - if (empty($alwayseditable)) $alwayseditable=0; + if (empty($pos)) $pos = 0; + if (empty($list)) $list = '0'; + if (empty($required)) $required = 0; + if (empty($unique)) $unique = 0; + if (empty($alwayseditable)) $alwayseditable = 0; - if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname) && ! is_numeric($attrname)) + if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname) && !is_numeric($attrname)) { if (is_array($param) && count($param) > 0) { @@ -460,8 +460,8 @@ class ExtraFields } else { - $this->error=$this->db->lasterror(); - $this->errno=$this->db->lasterrno(); + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); return -1; } } @@ -476,30 +476,30 @@ class ExtraFields */ public function delete($attrname, $elementtype = 'member') { - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - $table=$elementtype.'_extrafields'; - if ($elementtype == 'categorie') $table='categories_extrafields'; + $table = $elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table = 'categories_extrafields'; - $error=0; + $error = 0; - if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) + if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { - $result=$this->delete_label($attrname, $elementtype); + $result = $this->delete_label($attrname, $elementtype); if ($result < 0) { - $this->error=$this->db->lasterror(); - $this->errors[]=$this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } - if (! $error) + if (!$error) { $sql = "SELECT COUNT(rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; - $sql.= " WHERE elementtype = '".$elementtype."'"; - $sql.= " AND name = '".$attrname."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."extrafields"; + $sql .= " WHERE elementtype = '".$elementtype."'"; + $sql .= " AND name = '".$attrname."'"; //$sql.= " AND entity IN (0,".$conf->entity.")"; Do not test on entity here. We want to see if there is still on field remaning in other entities before deleting field in table $resql = $this->db->query($sql); if ($resql) @@ -507,11 +507,11 @@ class ExtraFields $obj = $this->db->fetch_object($resql); if ($obj->nb <= 0) { - $result=$this->db->DDLDropField(MAIN_DB_PREFIX.$table, $attrname); // This also drop the unique key + $result = $this->db->DDLDropField(MAIN_DB_PREFIX.$table, $attrname); // This also drop the unique key if ($result < 0) { - $this->error=$this->db->lasterror(); - $this->errors[]=$this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } } @@ -539,18 +539,18 @@ class ExtraFields // phpcs:enable global $conf; - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; - $sql.= " WHERE name = '".$attrname."'"; - $sql.= " AND entity IN (0,".$conf->entity.')'; - $sql.= " AND elementtype = '".$elementtype."'"; + $sql .= " WHERE name = '".$attrname."'"; + $sql .= " AND entity IN (0,".$conf->entity.')'; + $sql .= " AND elementtype = '".$elementtype."'"; dol_syslog(get_class($this)."::delete_label", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { return 1; @@ -593,80 +593,80 @@ class ExtraFields */ public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0) { - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - $table=$elementtype.'_extrafields'; - if ($elementtype == 'categorie') $table='categories_extrafields'; + $table = $elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table = 'categories_extrafields'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { - if ($type=='boolean') { - $typedb='int'; - $lengthdb='1'; - } elseif($type=='price') { - $typedb='double'; - $lengthdb='24,8'; - } elseif($type=='phone') { - $typedb='varchar'; - $lengthdb='20'; - } elseif($type=='mail') { - $typedb='varchar'; - $lengthdb='128'; - } elseif($type=='url') { - $typedb='varchar'; - $lengthdb='255'; - } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') || ($type=='checkbox') || ($type=='chkbxlst')) { - $typedb='varchar'; - $lengthdb='255'; + if ($type == 'boolean') { + $typedb = 'int'; + $lengthdb = '1'; + } elseif ($type == 'price') { + $typedb = 'double'; + $lengthdb = '24,8'; + } elseif ($type == 'phone') { + $typedb = 'varchar'; + $lengthdb = '20'; + } elseif ($type == 'mail') { + $typedb = 'varchar'; + $lengthdb = '128'; + } elseif ($type == 'url') { + $typedb = 'varchar'; + $lengthdb = '255'; + } elseif (($type == 'select') || ($type == 'sellist') || ($type == 'radio') || ($type == 'checkbox') || ($type == 'chkbxlst')) { + $typedb = 'varchar'; + $lengthdb = '255'; } elseif ($type == 'html') { - $typedb='text'; - } elseif ($type=='link') { - $typedb='int'; - $lengthdb='11'; - } elseif($type=='password') { - $typedb='varchar'; - $lengthdb='50'; + $typedb = 'text'; + } elseif ($type == 'link') { + $typedb = 'int'; + $lengthdb = '11'; + } elseif ($type == 'password') { + $typedb = 'varchar'; + $lengthdb = '50'; } else { - $typedb=$type; - $lengthdb=$length; + $typedb = $type; + $lengthdb = $length; } - $field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required?'NOT NULL':'NULL'), 'default'=>$default); + $field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required ? 'NOT NULL' : 'NULL'), 'default'=>$default); if ($type != 'separate') // No table update when separate type { - $result=$this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); + $result = $this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); } if ($result > 0 || $type == 'separate') { if ($label) { - $result=$this->update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable); + $result = $this->update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable); } if ($result > 0) { - $sql=''; + $sql = ''; if ($unique) { - $sql="ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; + $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; } else { - $sql="ALTER TABLE ".MAIN_DB_PREFIX.$table." DROP INDEX uk_".$table."_".$attrname; + $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." DROP INDEX uk_".$table."_".$attrname; } dol_syslog(get_class($this).'::update', LOG_DEBUG); - $resql=$this->db->query($sql, 1, 'dml'); + $resql = $this->db->query($sql, 1, 'dml'); return 1; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -708,17 +708,17 @@ class ExtraFields dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled.", ".$totalizable); // Clean parameters - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - if (empty($pos)) $pos=0; - if (empty($list)) $list='0'; + if (empty($pos)) $pos = 0; + if (empty($list)) $list = '0'; if (empty($totalizable)) { $totalizable = 0; } - if (empty($required)) $required=0; - if (empty($unique)) $unique=0; - if (empty($alwayseditable)) $alwayseditable=0; + if (empty($required)) $required = 0; + if (empty($unique)) $unique = 0; + if (empty($alwayseditable)) $alwayseditable = 0; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { @@ -734,76 +734,76 @@ class ExtraFields } else { - $params=''; + $params = ''; } if ($entity === '' || $entity != '0') { // We dont want on all entities, we delete all and current $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; - $sql_del.= " WHERE name = '".$attrname."'"; - $sql_del.= " AND entity IN (0, ".($entity===''?$conf->entity:$entity).")"; - $sql_del.= " AND elementtype = '".$elementtype."'"; + $sql_del .= " WHERE name = '".$attrname."'"; + $sql_del .= " AND entity IN (0, ".($entity === '' ? $conf->entity : $entity).")"; + $sql_del .= " AND elementtype = '".$elementtype."'"; } else { // We want on all entities ($entities = '0'), we delete on all only (we keep setup specific to each entity) $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; - $sql_del.= " WHERE name = '".$attrname."'"; - $sql_del.= " AND entity = 0"; - $sql_del.= " AND elementtype = '".$elementtype."'"; + $sql_del .= " WHERE name = '".$attrname."'"; + $sql_del .= " AND entity = 0"; + $sql_del .= " AND elementtype = '".$elementtype."'"; } - $resql1=$this->db->query($sql_del); + $resql1 = $this->db->query($sql_del); $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields("; - $sql.= " name,"; // This is code - $sql.= " entity,"; - $sql.= " label,"; - $sql.= " type,"; - $sql.= " size,"; - $sql.= " elementtype,"; - $sql.= " fieldunique,"; - $sql.= " fieldrequired,"; - $sql.= " perms,"; - $sql.= " langs,"; - $sql.= " pos,"; - $sql.= " alwayseditable,"; - $sql.= " param,"; - $sql.= " list,"; - $sql.= " totalizable,"; - $sql.= " fielddefault,"; - $sql.= " fieldcomputed,"; - $sql.= " fk_user_author,"; - $sql.= " fk_user_modif,"; - $sql.= " datec,"; - $sql.= " enabled,"; - $sql.= " help"; - $sql.= ") VALUES ("; - $sql.= "'".$attrname."',"; - $sql.= " ".($entity===''?$conf->entity:$entity).","; - $sql.= " '".$this->db->escape($label)."',"; - $sql.= " '".$this->db->escape($type)."',"; - $sql.= " '".$this->db->escape($size)."',"; - $sql.= " '".$this->db->escape($elementtype)."',"; - $sql.= " ".$unique.","; - $sql.= " ".$required.","; - $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; - $sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").","; - $sql.= " ".$pos.","; - $sql.= " '".$this->db->escape($alwayseditable)."',"; - $sql.= " '".$this->db->escape($params)."',"; - $sql.= " '".$this->db->escape($list)."', "; - $sql.= " ".$totalizable.","; - $sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").","; - $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; - $sql .= " " . $user->id . ","; - $sql .= " " . $user->id . ","; - $sql .= "'" . $this->db->idate(dol_now()) . "',"; - $sql .= "'" . $this->db->escape($enabled). "',"; - $sql.= " ".($help?"'".$this->db->escape($help)."'":"null"); - $sql.= ")"; + $sql .= " name,"; // This is code + $sql .= " entity,"; + $sql .= " label,"; + $sql .= " type,"; + $sql .= " size,"; + $sql .= " elementtype,"; + $sql .= " fieldunique,"; + $sql .= " fieldrequired,"; + $sql .= " perms,"; + $sql .= " langs,"; + $sql .= " pos,"; + $sql .= " alwayseditable,"; + $sql .= " param,"; + $sql .= " list,"; + $sql .= " totalizable,"; + $sql .= " fielddefault,"; + $sql .= " fieldcomputed,"; + $sql .= " fk_user_author,"; + $sql .= " fk_user_modif,"; + $sql .= " datec,"; + $sql .= " enabled,"; + $sql .= " help"; + $sql .= ") VALUES ("; + $sql .= "'".$attrname."',"; + $sql .= " ".($entity === '' ? $conf->entity : $entity).","; + $sql .= " '".$this->db->escape($label)."',"; + $sql .= " '".$this->db->escape($type)."',"; + $sql .= " '".$this->db->escape($size)."',"; + $sql .= " '".$this->db->escape($elementtype)."',"; + $sql .= " ".$unique.","; + $sql .= " ".$required.","; + $sql .= " ".($perms ? "'".$this->db->escape($perms)."'" : "null").","; + $sql .= " ".($langfile ? "'".$this->db->escape($langfile)."'" : "null").","; + $sql .= " ".$pos.","; + $sql .= " '".$this->db->escape($alwayseditable)."',"; + $sql .= " '".$this->db->escape($params)."',"; + $sql .= " '".$this->db->escape($list)."', "; + $sql .= " ".$totalizable.","; + $sql .= " ".(($default != '') ? "'".$this->db->escape($default)."'" : "null").","; + $sql .= " ".($computed ? "'".$this->db->escape($computed)."'" : "null").","; + $sql .= " ".$user->id.","; + $sql .= " ".$user->id.","; + $sql .= "'".$this->db->idate(dol_now())."',"; + $sql .= "'".$this->db->escape($enabled)."',"; + $sql .= " ".($help ? "'".$this->db->escape($help)."'" : "null"); + $sql .= ")"; - $resql2=$this->db->query($sql); + $resql2 = $this->db->query($sql); if ($resql1 && $resql2) { @@ -871,12 +871,12 @@ class ExtraFields // We should not have several time this request. If we have, there is some optimization to do by calling a simple $extrafields->fetch_optionals() in top of code and not into subcode $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,totalizable,fielddefault,fieldcomputed,entity,enabled,help"; - $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; + $sql .= " FROM ".MAIN_DB_PREFIX."extrafields"; //$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later - if ($elementtype) $sql.= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element - $sql.= " ORDER BY pos"; + if ($elementtype) $sql .= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element + $sql .= " ORDER BY pos"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -888,7 +888,7 @@ class ExtraFields // This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field without default value if ($tab->fieldrequired && is_null($tab->fielddefault)) { - $this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name]=$tab->type; + $this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name] = $tab->type; } continue; } @@ -1034,21 +1034,21 @@ class ExtraFields { $morecss = 'minwidth200imp'; } - elseif (in_array($type, array('int','integer','double','price'))) + elseif (in_array($type, array('int', 'integer', 'double', 'price'))) { $morecss = 'maxwidth75'; } elseif ($type == 'password') { - $morecss='maxwidth100'; + $morecss = 'maxwidth100'; } elseif ($type == 'url') { - $morecss='minwidth400'; + $morecss = 'minwidth400'; } elseif ($type == 'boolean') { - $morecss=''; + $morecss = ''; } else { @@ -1067,10 +1067,10 @@ class ExtraFields } } - if (in_array($type, array('date','datetime'))) + if (in_array($type, array('date', 'datetime'))) { - $tmp=explode(',', $size); - $newsize=$tmp[0]; + $tmp = explode(',', $size); + $newsize = $tmp[0]; $showtime = in_array($type, array('datetime')) ? 1 : 0; @@ -1199,22 +1199,22 @@ class ExtraFields // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value // 5 : id category type // 6 : ids categories list separated by comma for category root - $keyList=(empty($InfoFieldList[2])?'rowid':$InfoFieldList[2].' as rowid'); + $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid'); - if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4])) + if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) { if (strpos($InfoFieldList[4], 'extra.') !== false) { - $keyList='main.'.$InfoFieldList[2].' as rowid'; + $keyList = 'main.'.$InfoFieldList[2].' as rowid'; } else { - $keyList=$InfoFieldList[2].' as rowid'; + $keyList = $InfoFieldList[2].' as rowid'; } } - if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) + if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) { list($parentName, $parentField) = explode('|', $InfoFieldList[3]); - $keyList.= ', '.$parentField; + $keyList .= ', '.$parentField; } $filter_categorie = false; @@ -1232,8 +1232,8 @@ class ExtraFields } $sqlwhere = ''; - $sql = 'SELECT ' . $keyList; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; + $sql = 'SELECT '.$keyList; + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { // can use curent entity filter if (strpos($InfoFieldList[4], '$ENTITY$') !== false) { @@ -1252,24 +1252,24 @@ class ExtraFields } //We have to join on extrafield table if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; - $sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4]; + $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; + $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; } else { - $sqlwhere .= ' WHERE ' . $InfoFieldList[4]; + $sqlwhere .= ' WHERE '.$InfoFieldList[4]; } } else { $sqlwhere .= ' WHERE 1=1'; } // Some tables may have field, some other not. For the moment we disable it. if (in_array($InfoFieldList[0], array('tablewithentity'))) { - $sqlwhere .= ' AND entity = ' . $conf->entity; + $sqlwhere .= ' AND entity = '.$conf->entity; } $sql .= $sqlwhere; //print $sql; - $sql .= ' ORDER BY ' . implode(', ', $fields_label); + $sql .= ' ORDER BY '.implode(', ', $fields_label); - dol_syslog(get_class($this) . '::showInputField type=sellist', LOG_DEBUG); + dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $out .= ''; @@ -1500,7 +1500,7 @@ class ExtraFields if (is_array($fields_label)) { $notrans = true; foreach ($fields_label as $field_toshow) { - $labeltoshow .= $obj->$field_toshow . ' '; + $labeltoshow .= $obj->$field_toshow.' '; } } else { $labeltoshow = $obj->{$InfoFieldList[1]}; @@ -1511,9 +1511,9 @@ class ExtraFields foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); if ($translabel != $obj->$field_toshow) { - $labeltoshow = dol_trunc($translabel, 18) . ' '; + $labeltoshow = dol_trunc($translabel, 18).' '; } else { - $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' '; + $labeltoshow = dol_trunc($obj->$field_toshow, 18).' '; } } @@ -1535,7 +1535,7 @@ class ExtraFields } if (!empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName . ':' . $obj->{$parentField}; + $parent = $parentName.':'.$obj->{$parentField}; } $data[$obj->rowid] = $labeltoshow; @@ -1725,38 +1725,38 @@ class ExtraFields $resql = $this->db->query($sql); if ($resql) { - $value=''; // value was used, so now we reste it to use it to build final output + $value = ''; // value was used, so now we reste it to use it to build final output $obj = $this->db->fetch_object($resql); // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); - if(is_array($fields_label) && count($fields_label)>1) + if (is_array($fields_label) && count($fields_label) > 1) { foreach ($fields_label as $field_toshow) { - $translabel=''; + $translabel = ''; if (!empty($obj->$field_toshow)) { - $translabel=$langs->trans($obj->$field_toshow); + $translabel = $langs->trans($obj->$field_toshow); } - if ($translabel!=$field_toshow) { - $value.=dol_trunc($translabel, 18).' '; - }else { - $value.=$obj->$field_toshow.' '; + if ($translabel != $field_toshow) { + $value .= dol_trunc($translabel, 18).' '; + } else { + $value .= $obj->$field_toshow.' '; } } } else { - $translabel=''; + $translabel = ''; if (!empty($obj->{$InfoFieldList[1]})) { - $translabel=$langs->trans($obj->{$InfoFieldList[1]}); + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); } - if ($translabel!=$obj->{$InfoFieldList[1]}) { - $value=dol_trunc($translabel, 18); - }else { - $value=$obj->{$InfoFieldList[1]}; + if ($translabel != $obj->{$InfoFieldList[1]}) { + $value = dol_trunc($translabel, 18); + } else { + $value = $obj->{$InfoFieldList[1]}; } } } @@ -1764,20 +1764,20 @@ class ExtraFields } elseif ($type == 'radio') { - $value=$param['options'][$value]; + $value = $param['options'][$value]; } elseif ($type == 'checkbox') { - $value_arr=explode(',', $value); - $value=''; - $toprint=array(); + $value_arr = explode(',', $value); + $value = ''; + $toprint = array(); if (is_array($value_arr)) { foreach ($value_arr as $keyval=>$valueval) { - $toprint[]='
      • '.$param['options'][$valueval].'
      • '; + $toprint[] = '
      • '.$param['options'][$valueval].'
      • '; } } - $value='
          '.implode(' ', $toprint).'
        '; + $value = '
          '.implode(' ', $toprint).'
        '; } elseif ($type == 'chkbxlst') { @@ -1791,7 +1791,7 @@ class ExtraFields if (count($InfoFieldList) >= 3) { $selectkey = $InfoFieldList[2]; - $keyList = $InfoFieldList[2] . ' as rowid'; + $keyList = $InfoFieldList[2].' as rowid'; } $fields_label = explode('|', $InfoFieldList[1]); @@ -1878,24 +1878,24 @@ class ExtraFields } elseif ($type == 'text') { - $value=dol_htmlentitiesbr($value); + $value = dol_htmlentitiesbr($value); } elseif ($type == 'html') { - $value=dol_htmlentitiesbr($value); + $value = dol_htmlentitiesbr($value); } elseif ($type == 'password') { - $value=dol_trunc(preg_replace('/./i', '*', $value), 8, 'right', 'UTF-8', 1); + $value = dol_trunc(preg_replace('/./i', '*', $value), 8, 'right', 'UTF-8', 1); } else { - $showsize=round($size); - if ($showsize > 48) $showsize=48; + $showsize = round($size); + if ($showsize > 48) $showsize = 48; } //print $type.'-'.$size; - $out=$value; + $out = $value; return $out; } @@ -1909,44 +1909,44 @@ class ExtraFields */ public function getAlignFlag($key, $extrafieldsobjectkey = '') { - global $conf,$langs; + global $conf, $langs; - if (! empty($extrafieldsobjectkey)) $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; - else $type=$this->attribute_type[$key]; + if (!empty($extrafieldsobjectkey)) $type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; + else $type = $this->attribute_type[$key]; - $align=''; + $align = ''; if ($type == 'date') { - $align="center"; + $align = "center"; } elseif ($type == 'datetime') { - $align="center"; + $align = "center"; } elseif ($type == 'int') { - $align="right"; + $align = "right"; } elseif ($type == 'double') { - $align="right"; + $align = "right"; } elseif ($type == 'boolean') { - $align="center"; + $align = "center"; } elseif ($type == 'radio') { - $align="center"; + $align = "center"; } elseif ($type == 'checkbox') { - $align="center"; + $align = "center"; } elseif ($type == 'price') { - $align="right"; + $align = "right"; } return $align; @@ -2144,29 +2144,29 @@ class ExtraFields $key_type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; } - if (in_array($key_type, array('date','datetime'))) + if (in_array($key_type, array('date', 'datetime'))) { // Clean parameters - $value_key=dol_mktime($_POST[$keysuffix."options_".$key.$keyprefix."hour"], $_POST[$keysuffix."options_".$key.$keyprefix."min"], 0, $_POST[$keysuffix."options_".$key.$keyprefix."month"], $_POST[$keysuffix."options_".$key.$keyprefix."day"], $_POST[$keysuffix."options_".$key.$keyprefix."year"]); + $value_key = dol_mktime($_POST[$keysuffix."options_".$key.$keyprefix."hour"], $_POST[$keysuffix."options_".$key.$keyprefix."min"], 0, $_POST[$keysuffix."options_".$key.$keyprefix."month"], $_POST[$keysuffix."options_".$key.$keyprefix."day"], $_POST[$keysuffix."options_".$key.$keyprefix."year"]); } elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) { - $value_arr=GETPOST($keysuffix."options_".$key.$keyprefix); + $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); // Make sure we get an array even if there's only one checkbox - $value_arr=(array) $value_arr; - $value_key=implode(',', $value_arr); + $value_arr = (array) $value_arr; + $value_key = implode(',', $value_arr); } - elseif (in_array($key_type, array('price','double'))) + elseif (in_array($key_type, array('price', 'double'))) { - $value_arr=GETPOST($keysuffix."options_".$key.$keyprefix); - $value_key=price2num($value_arr); + $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); + $value_key = price2num($value_arr); } else { - $value_key=GETPOST($keysuffix."options_".$key.$keyprefix); + $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); } - $array_options[$keysuffix."options_".$key]=$value_key; // No keyprefix here. keyprefix is used only for read. + $array_options[$keysuffix."options_".$key] = $value_key; // No keyprefix here. keyprefix is used only for read. } return $array_options; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index b0fb1131f17..0d098b9f964 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -37,7 +37,7 @@ class FormActions /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** @@ -67,7 +67,7 @@ class FormActions public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100') { // phpcs:enable - global $langs,$conf; + global $langs, $conf; $listofstatus = array( '-1' => $langs->trans("ActionNotApplicable"), @@ -77,7 +77,7 @@ class FormActions ); // +ActionUncomplete - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print "\n"; print "\n"; } - if (! empty($conf->use_javascript_ajax) || $onlyselect) + if (!empty($conf->use_javascript_ajax) || $onlyselect) { //var_dump($selected); - if ($selected == 'done') $selected='100'; - print ''; + if ($showempty) print ''; + foreach ($listofstatus as $key => $val) { print ''; if ($key == '50' && $onlyselect == 2) @@ -140,17 +140,17 @@ class FormActions } } print ''; - if ($selected == 0 || $selected == 100) $canedit=0; + if ($selected == 0 || $selected == 100) $canedit = 0; if (empty($onlyselect)) { - print ' =0)?'':' disabled').'>'; + print ' = 0) ? '' : ' disabled').'>'; print '%'; } } else { - print ' %'; + print ' %'; } } @@ -284,8 +284,8 @@ class FormActions print '
        '; // Ref - print ''; + print ''; // Label print ''; // Date start @@ -856,7 +856,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel */ function show_contacts($conf, $langs, $db, $object, $backtopage = '') { - global $user,$conf,$extrafields,$hookmanager; + global $user, $conf, $extrafields, $hookmanager; global $contextpage; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -1147,7 +1147,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (is_array($contactstatic->array_options)) { - foreach($contactstatic->array_options as $key => $val) + foreach ($contactstatic->array_options as $key => $val) { $obj->$key = $val; } @@ -1156,7 +1156,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print ''; // ID - if (! empty($arrayfields['t.rowid']['checked'])) + if (!empty($arrayfields['t.rowid']['checked'])) { print ''; } // Extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Actions print ''; } print "\n
        '; if ($objp->statut >= 4) @@ -2033,7 +2033,7 @@ else if ($objp->statut == 4) { print $langs->trans("DateEndReal").' '; - print $form->selectDate($dateactend, "end", $usehm, $usehm, ($objp->date_fin_reelle>0?0:1), "closeline", 1, 1); + print $form->selectDate($dateactend, "end", $usehm, $usehm, ($objp->date_fin_reelle > 0 ? 0 : 1), "closeline", 1, 1); } } print ''.dol_print_date($action->datep, 'dayhour', 'tzuserrel'); if ($action->datef) { - $tmpa=dol_getdate($action->datep); - $tmpb=dol_getdate($action->datef); + $tmpa = dol_getdate($action->datep); + $tmpb = dol_getdate($action->datef); if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); @@ -335,39 +335,39 @@ class FormActions public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0) { // phpcs:enable - global $langs,$user,$form,$conf; + global $langs, $user, $form, $conf; - if (! is_object($form)) $form=new Form($this->db); + if (!is_object($form)) $form = new Form($this->db); require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $caction=new CActionComm($this->db); + $caction = new CActionComm($this->db); // Suggest a list with manual events or all auto events - $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); - array_unshift($arraylist, ' '); // Add empty line at start + $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot); + array_unshift($arraylist, ' '); // Add empty line at start //asort($arraylist); - if ($selected == 'manual') $selected='AC_OTH'; - if ($selected == 'auto') $selected='AC_OTH_AUTO'; + if ($selected == 'manual') $selected = 'AC_OTH'; + if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); - $out=''; + $out = ''; - if (! empty($multiselect)) + if (!empty($multiselect)) { if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); - $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); + $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); } else { - $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); + $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); } if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) { - $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); } if ($nooutput) return $out; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index feeeed6baa6..dbdba9db085 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -72,10 +72,10 @@ class FormOther { // phpcs:enable $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."export_model"; - $sql.= " WHERE type = '".$type."'"; - if (!empty($fk_user)) $sql.=" AND fk_user IN (0, ".$fk_user.")"; // An export model - $sql.= " ORDER BY rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."export_model"; + $sql .= " WHERE type = '".$type."'"; + if (!empty($fk_user)) $sql .= " AND fk_user IN (0, ".$fk_user.")"; // An export model + $sql .= " ORDER BY rowid"; $result = $this->db->query($sql); if ($result) { @@ -124,9 +124,9 @@ class FormOther { // phpcs:enable $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."import_model"; - $sql.= " WHERE type = '".$type."'"; - $sql.= " ORDER BY rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."import_model"; + $sql .= " WHERE type = '".$type."'"; + $sql .= " ORDER BY rowid"; $result = $this->db->query($sql); if ($result) { @@ -175,13 +175,13 @@ class FormOther global $langs; $sql = "SELECT e.rowid, e.code, e.label, e.price, e.organization,"; - $sql.= " c.label as country"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_country as c"; - $sql.= " WHERE e.active = 1 AND e.fk_pays = c.rowid"; - $sql.= " ORDER BY country, e.organization ASC, e.code ASC"; + $sql .= " c.label as country"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_ecotaxe as e,".MAIN_DB_PREFIX."c_country as c"; + $sql .= " WHERE e.active = 1 AND e.fk_pays = c.rowid"; + $sql .= " ORDER BY country, e.organization ASC, e.code ASC"; dol_syslog(get_class($this).'::select_ecotaxes', LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { print ''; + $out .= ''; + $out .= ''; return $out; } else @@ -294,24 +294,24 @@ class FormOther public function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0) { // phpcs:enable - $return = ''; + if ($showempty) $return .= ''; - for ($i = $start ; $i <= $end ; $i += $increment) + for ($i = $start; $i <= $end; $i += $increment) { if ($selected != '' && (int) $selected == $i) { - $return.= ''; + $return .= $i.' % '; + $return .= ''; } - $return.= ''; + $return .= ''; return $return; } @@ -338,7 +338,7 @@ class FormOther // For backward compatibility if (is_numeric($type)) { - dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); + dol_syslog(__METHOD__.': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); } // Load list of "categories" @@ -349,30 +349,30 @@ class FormOther // Enhance with select2 if ($conf->use_javascript_ajax) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox('select_categ_'.$htmlname); - $moreforfilter.=$comboenhancement; + $moreforfilter .= $comboenhancement; } // Print a select with each of them - $moreforfilter.=''; + if ($showempty) $moreforfilter .= ''; // Should use -1 to say nothing if (is_array($tab_categs)) { foreach ($tab_categs as $categ) { - $moreforfilter.=''; + $moreforfilter .= ''; } - $moreforfilter.=''; + $moreforfilter .= ''; return $moreforfilter; } @@ -533,14 +533,14 @@ class FormOther require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; //print $modeproject.'-'.$modetask; - $task=new Task($this->db); - $tasksarray=$task->getTasksArray($modetask?$user:0, $modeproject?$user:0, $projectid, 0, $mode, '', $filteronprojstatus); + $task = new Task($this->db); + $tasksarray = $task->getTasksArray($modetask ? $user : 0, $modeproject ? $user : 0, $projectid, 0, $mode, '', $filteronprojstatus); if ($tasksarray) { - print ''; if ($useempty) print ''; - $j=0; - $level=0; + $j = 0; + $level = 0; $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid); print ''; @@ -568,10 +568,10 @@ class FormOther { global $langs, $user, $conf; - $lastprojectid=0; + $lastprojectid = 0; - $numlines=count($lines); - for ($i = 0 ; $i < $numlines ; $i++) { + $numlines = count($lines); + for ($i = 0; $i < $numlines; $i++) { if ($lines[$i]->fk_parent == $parent) { $var = !$var; @@ -585,7 +585,7 @@ class FormOther if ($i > 0) print ''; print '\n"; - $lastprojectid=$lines[$i]->fk_project; + $lastprojectid = $lines[$i]->fk_project; $inc++; } } - $newdisablechildoftaskid=$disablechildoftaskid; + $newdisablechildoftaskid = $disablechildoftaskid; // Print task if (isset($lines[$i]->id)) // We use isset because $lines[$i]->id may be null if project has no task and are on root project (tasks may be caught by a left join). We enter here only if '0' or >0 { // Check if we must disable entry - $disabled=0; + $disabled = 0; if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_parent == $disablechildoftaskid))) { $disabled++; - if ($lines[$i]->fk_parent == $disablechildoftaskid) $newdisablechildoftaskid=$lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too + if ($lines[$i]->fk_parent == $disablechildoftaskid) $newdisablechildoftaskid = $lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too } print ''; foreach ($arrayofcolors as $val) { - $out.= ''; @@ -953,39 +953,39 @@ class FormOther */ public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle maxwidth75imp') { - $out=''; + $out = ''; - $currentyear = date("Y")+$offset; - $max_year = $currentyear+$max_year; - $min_year = $currentyear-$min_year; - if(empty($selected) && empty($useempty)) $selected = $currentyear; + $currentyear = date("Y") + $offset; + $max_year = $currentyear + $max_year; + $min_year = $currentyear - $min_year; + if (empty($selected) && empty($useempty)) $selected = $currentyear; - $out.= ''; + if ($useempty) { - $selected_html=''; + $selected_html = ''; if ($selected == '') $selected_html = ' selected'; - $out.= ''; + $out .= ''; } - if (! $invert) + if (!$invert) { for ($y = $max_year; $y >= $min_year; $y--) { - $selected_html=''; + $selected_html = ''; if ($selected > 0 && $y == $selected) $selected_html = ' selected'; - $out.= ''; + $out .= ''; } } else { for ($y = $min_year; $y <= $max_year; $y++) { - $selected_html=''; + $selected_html = ''; if ($selected > 0 && $y == $selected) $selected_html = ' selected'; - $out.= ''; + $out .= ''; } } - $out.= "\n"; + $out .= "\n"; return $out; } @@ -1001,70 +1001,70 @@ class FormOther */ public static function getBoxesArea($user, $areacode) { - global $conf,$langs,$db; + global $conf, $langs, $db; include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - $confuserzone='MAIN_BOXES_'.$areacode; + $confuserzone = 'MAIN_BOXES_'.$areacode; // $boxactivated will be array of boxes enabled into global setup // $boxidactivatedforuser will be array of boxes choosed by user - $selectboxlist=''; - $boxactivated=InfoBox::listBoxes($db, 'activated', $areacode, (empty($user->conf->$confuserzone)?null:$user), array(), 0); // Search boxes of common+user (or common only if user has no specific setup) + $selectboxlist = ''; + $boxactivated = InfoBox::listBoxes($db, 'activated', $areacode, (empty($user->conf->$confuserzone) ?null:$user), array(), 0); // Search boxes of common+user (or common only if user has no specific setup) - $boxidactivatedforuser=array(); - foreach($boxactivated as $box) + $boxidactivatedforuser = array(); + foreach ($boxactivated as $box) { - if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user + if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id] = $box->id; // We keep only boxes to show for user } // Define selectboxlist - $arrayboxtoactivatelabel=array(); - if (! empty($user->conf->$confuserzone)) + $arrayboxtoactivatelabel = array(); + if (!empty($user->conf->$confuserzone)) { - $boxorder=''; - $langs->load("boxes"); // Load label of boxes - foreach($boxactivated as $box) + $boxorder = ''; + $langs->load("boxes"); // Load label of boxes + foreach ($boxactivated as $box) { - if (! empty($boxidactivatedforuser[$box->id])) continue; // Already visible for user - $label=$langs->transnoentitiesnoconv($box->boxlabel); + if (!empty($boxidactivatedforuser[$box->id])) continue; // Already visible for user + $label = $langs->transnoentitiesnoconv($box->boxlabel); //if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph").')'; if (preg_match('/graph/', $box->class) && $conf->browser->layout != 'phone') { - $label=$label.' '; + $label = $label.' '; } - $arrayboxtoactivatelabel[$box->id]=$label; // We keep only boxes not shown for user, to show into combo list + $arrayboxtoactivatelabel[$box->id] = $label; // We keep only boxes not shown for user, to show into combo list } - foreach($boxidactivatedforuser as $boxid) + foreach ($boxidactivatedforuser as $boxid) { - if (empty($boxorder)) $boxorder.='A:'; - $boxorder.=$boxid.','; + if (empty($boxorder)) $boxorder .= 'A:'; + $boxorder .= $boxid.','; } //var_dump($boxidactivatedforuser); // Class Form must have been already loaded - $selectboxlist.=''."\n"; - $selectboxlist.=''; - $selectboxlist.=''; - $selectboxlist.=''; - $selectboxlist.=''; - $selectboxlist.=''; - $selectboxlist.=Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone', 0, 'hidden selected', 0, 1); - if (empty($conf->use_javascript_ajax)) $selectboxlist.=' '; - $selectboxlist.=''; - if (! empty($conf->use_javascript_ajax)) + $selectboxlist .= ''."\n"; + $selectboxlist .= '
        '; + $selectboxlist .= ''; + $selectboxlist .= ''; + $selectboxlist .= ''; + $selectboxlist .= ''; + $selectboxlist .= Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone', 0, 'hidden selected', 0, 1); + if (empty($conf->use_javascript_ajax)) $selectboxlist .= ' '; + $selectboxlist .= '
        '; + if (!empty($conf->use_javascript_ajax)) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $selectboxlist.=ajax_combobox("boxcombo"); + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $selectboxlist .= ajax_combobox("boxcombo"); } } // Javascript code for dynamic actions - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { - $selectboxlist.=''."\n"; + $selectboxlist .= ''."\n"; } // Define boxlista and boxlistb - $nbboxactivated=count($boxidactivatedforuser); + $nbboxactivated = count($boxidactivatedforuser); if ($nbboxactivated) { // Load translation files required by the page - $langs->loadLangs(array("boxes","projects")); + $langs->loadLangs(array("boxes", "projects")); - $emptybox=new ModeleBoxes($db); + $emptybox = new ModeleBoxes($db); - $boxlista.="\n\n"; + $boxlista .= "\n\n"; // Define $box_max_lines - $box_max_lines=5; - if (! empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines=$conf->global->MAIN_BOXES_MAXLINES; + $box_max_lines = 5; + if (!empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines = $conf->global->MAIN_BOXES_MAXLINES; - $ii=0; + $ii = 0; foreach ($boxactivated as $key => $box) { - if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; - if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='A'.sprintf("%02d", ($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0 + if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; + if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order = 'A'.sprintf("%02d", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0 if (preg_match('/^A/i', $box->box_order)) // column A { $ii++; @@ -1160,26 +1160,26 @@ class FormOther //print 'box_order '.$boxactivated[$ii]->box_order.'
        '; // Show box $box->loadBox($box_max_lines); - $boxlista.= $box->outputBox(); + $boxlista .= $box->outputBox(); } } if ($conf->browser->layout != 'phone') { - $emptybox->box_id='A'; - $emptybox->info_box_head=array(); - $emptybox->info_box_contents=array(); - $boxlista.= $emptybox->outputBox(array(), array()); + $emptybox->box_id = 'A'; + $emptybox->info_box_head = array(); + $emptybox->info_box_contents = array(); + $boxlista .= $emptybox->outputBox(array(), array()); } - $boxlista.= "\n"; + $boxlista .= "\n"; - $boxlistb.= "\n\n"; + $boxlistb .= "\n\n"; - $ii=0; + $ii = 0; foreach ($boxactivated as $key => $box) { - if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; - if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='B'.sprintf("%02d", ($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0 + if ((!empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; + if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order = 'B'.sprintf("%02d", ($ii + 1)); // When box_order was not yet set to Axx or Bxx and is still 0 if (preg_match('/^B/i', $box->box_order)) // colonne B { $ii++; @@ -1187,22 +1187,22 @@ class FormOther //print 'box_order '.$boxactivated[$ii]->box_order.'
        '; // Show box $box->loadBox($box_max_lines); - $boxlistb.= $box->outputBox(); + $boxlistb .= $box->outputBox(); } } if ($conf->browser->layout != 'phone') { - $emptybox->box_id='B'; - $emptybox->info_box_head=array(); - $emptybox->info_box_contents=array(); - $boxlistb.= $emptybox->outputBox(array(), array()); + $emptybox->box_id = 'B'; + $emptybox->info_box_head = array(); + $emptybox->info_box_contents = array(); + $boxlistb .= $emptybox->outputBox(array(), array()); } - $boxlistb.= "\n"; + $boxlistb .= "\n"; } - return array('selectboxlist'=>count($boxactivated)?$selectboxlist:'', 'boxactivated'=>$boxactivated, 'boxlista'=>$boxlista, 'boxlistb'=>$boxlistb); + return array('selectboxlist'=>count($boxactivated) ? $selectboxlist : '', 'boxactivated'=>$boxactivated, 'boxlista'=>$boxlista, 'boxlistb'=>$boxlistb); } @@ -1227,8 +1227,8 @@ class FormOther $langs->load("admin"); $sql = "SELECT rowid, ".$keyfield.", ".$labelfield; - $sql.= " FROM ".MAIN_DB_PREFIX.$dictionarytable; - $sql.= " ORDER BY ".$labelfield; + $sql .= " FROM ".MAIN_DB_PREFIX.$dictionarytable; + $sql .= " ORDER BY ".$labelfield; dol_syslog(get_class($this)."::select_dictionary", LOG_DEBUG); $result = $this->db->query($sql); @@ -1238,7 +1238,7 @@ class FormOther $i = 0; if ($num) { - print ''; if ($useempty == 1 || ($useempty == 2 && $num > 1)) { print ''; @@ -1283,17 +1283,17 @@ class FormOther { global $langs; - $automatic="automatic"; $manual="manual"; + $automatic = "automatic"; $manual = "manual"; if ($option) { - $automatic="1"; - $manual="0"; + $automatic = "1"; + $manual = "0"; } $disabled = ($disabled ? ' disabled' : ''); $resultautomanual = '
        '.img_object($langs->trans("ShowProject"), ($obj->public?'projectpub':'project'))." ".$obj->ref.''.img_object($langs->trans("ShowProject"), ($obj->public ? 'projectpub' : 'project'))." ".$obj->ref.''.$obj->title.'
        '; print $contactstatic->id; @@ -1164,7 +1164,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Photo - Name - if (! empty($arrayfields['t.name']['checked'])) + if (!empty($arrayfields['t.name']['checked'])) { print ''; print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1); @@ -1173,7 +1173,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Job position - if (! empty($arrayfields['t.poste']['checked'])) + if (!empty($arrayfields['t.poste']['checked'])) { print ''; if ($obj->poste) print $obj->poste; @@ -1181,7 +1181,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Address - Phone - Email - if (! empty($arrayfields['t.address']['checked'])) + if (!empty($arrayfields['t.address']['checked'])) { print ''; print $contactstatic->getBannerAddress('contact', $object); @@ -1197,20 +1197,20 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Status - if (! empty($arrayfields['t.statut']['checked'])) + if (!empty($arrayfields['t.statut']['checked'])) { print ''.$contactstatic->getLibStatut(5).''; // Add to agenda - if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { print ''; print img_object($langs->trans("Event"), "action"); @@ -1233,8 +1233,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } else { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '
        '.$langs->trans("None").'
        \n"; @@ -1260,7 +1260,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') */ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '') { - global $user,$conf; + global $user, $conf; $out = show_actions_done($conf, $langs, $db, $filterobj, $objcon, 1, $actioncode, 'todo'); @@ -1295,12 +1295,12 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin dol_include_once('/comm/action/class/actioncomm.class.php'); // Check parameters - if (! is_object($filterobj) && ! is_object($objcon)) dol_print_error('', 'BadParameter'); + if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter'); - $out=''; - $histo=array(); - $numaction = 0 ; - $now=dol_now('tzuser'); + $out = ''; + $histo = array(); + $numaction = 0; + $now = dol_now('tzuser'); // Open DSI -- Fix order by -- Begin $sortfield_list = explode(',', $sortfield); @@ -1311,7 +1311,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } $sortfield_new = implode(',', $sortfield_new_list); - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm if (is_object($objcon) && $objcon->id > 0) { @@ -1464,19 +1464,19 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if ($obj->type == 'action') { $contactaction = new ActionComm($db); - $contactaction->id=$obj->id; + $contactaction->id = $obj->id; $result = $contactaction->fetchResources(); - if ($result<0) { + if ($result < 0) { dol_print_error($db); setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); } //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - $tododone=''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone='todo'; + $tododone = ''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>$tododone, 'id'=>$obj->id, @@ -1500,11 +1500,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin // Type of event 'acode'=>$obj->acode, 'alabel'=>$obj->alabel, - 'libelle'=>$obj->alabel, // deprecated + 'libelle'=>$obj->alabel, // deprecated 'apicto'=>$obj->apicto ); } else { - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>'done', 'id'=>$obj->id, @@ -1740,8 +1740,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if ($result > 0) { $out .= $contact->getNomUrl(1); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { - if (! empty($contact->phone_pro)) - $out .= '(' . dol_print_phone($contact->phone_pro) . ')'; + if (!empty($contact->phone_pro)) + $out .= '('.dol_print_phone($contact->phone_pro).')'; } $out .= '
        '; } @@ -1749,23 +1749,23 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= '
          '.$actionstatic->LibStatut($histo[$key]['percent'], 3, 0, $histo[$key]['datestart']).''.$actionstatic->LibStatut($histo[$key]['percent'], 3, 0, $histo[$key]['datestart']).'
        \n"; - $out.="
        \n"; + $out .= "
        \n"; + $out .= "\n"; } - $out.=''; + $out .= ''; if ($noprint) return $out; else print $out; @@ -1784,13 +1784,13 @@ function show_subsidiaries($conf, $langs, $db, $object) { global $user; - $i=-1; + $i = -1; $sql = "SELECT s.rowid, s.client, s.fournisseur, s.nom as name, s.name_alias, s.email, s.address, s.zip, s.town, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.canvas"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.parent = ".$object->id; - $sql.= " AND s.entity IN (".getEntity('societe').")"; - $sql.= " ORDER BY s.nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.parent = ".$object->id; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + $sql .= " ORDER BY s.nom"; $result = $db->query($sql); $num = $db->num_rows($result); @@ -1808,7 +1808,7 @@ function show_subsidiaries($conf, $langs, $db, $object) print "
         
        '; // Import key - if (! empty($object->import_key)) + if (!empty($object->import_key)) { if ($usetable) print ''; else print '
        '; } // User change (old method using already loaded object and not id is kept for backward compatibility) - if (! empty($object->user_modification) || ! empty($object->user_modification_id)) + if (!empty($object->user_modification) || !empty($object->user_modification_id)) { if ($usetable) print ''; else print '
        '; } // User validation (old method using already loaded object and not id is kept for backward compatibility) - if (! empty($object->user_validation) || ! empty($object->user_validation_id)) + if (!empty($object->user_validation) || !empty($object->user_validation_id)) { if ($usetable) print ''; else print '
        '; } // User approve (old method using already loaded object and not id is kept for backward compatibility) - if (! empty($object->user_approve) || ! empty($object->user_approve_id)) + if (!empty($object->user_approve) || !empty($object->user_approve_id)) { if ($usetable) print ''; else print '
        '; } // User approve - if (! empty($object->user_approve_id2)) + if (!empty($object->user_approve_id2)) { if ($usetable) print ''; else print '
        '; } // User close - if (! empty($object->user_cloture)) + if (!empty($object->user_cloture)) { if ($usetable) print ''; else print '
        '; } // User conciliate - if (! empty($object->user_rappro)) + if (!empty($object->user_rappro)) { if ($usetable) print ''; else print '
        '; } // Date send - if (! empty($object->date_envoi)) + if (!empty($object->date_envoi)) { if ($usetable) print ''; else print '
        '; } @@ -492,8 +492,8 @@ function dol_print_object_info($object, $usetable = 0) */ function dolAddEmailTrackId($email, $trackingid) { - $tmp=explode('@', $email); - return $tmp[0].'+'.$trackingid.'@'.(isset($tmp[1])?$tmp[1]:''); + $tmp = explode('@', $email); + return $tmp[0].'+'.$trackingid.'@'.(isset($tmp[1]) ? $tmp[1] : ''); } /** @@ -535,7 +535,7 @@ function isValidUrl($url, $http = 0, $pass = 0, $port = 0, $path = 0, $query = 0 // HOSTNAME OR IP //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // x allowed (ex. http://localhost, http://routerlogin) //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)+"; // x.x - $urlregex .= "([a-z0-9+\$_\\\:-])+(\.[a-z0-9+\$_-][a-z0-9+\$_-]+)*"; // x ou x.xx (2 x ou plus) + $urlregex .= "([a-z0-9+\$_\\\:-])+(\.[a-z0-9+\$_-][a-z0-9+\$_-]+)*"; // x ou x.xx (2 x ou plus) //use only one of the above // PORT @@ -596,16 +596,16 @@ function clean_url($url, $http = 1) // Also, there's no need of escape a dot sign in a class if (preg_match('/^(https?:[\\/]+)?([0-9A-Z.-]+\.[A-Z]{2,4})(:[0-9]+)?/i', $url, $regs)) { - $proto=$regs[1]; - $domain=$regs[2]; - $port=isset($regs[3])?$regs[3]:''; + $proto = $regs[1]; + $domain = $regs[2]; + $port = isset($regs[3]) ? $regs[3] : ''; //print $url." -> ".$proto." - ".$domain." - ".$port; //$url = dol_string_nospecial(trim($url)); $url = trim($url); // Si http: defini on supprime le http (Si https on ne supprime pas) - $newproto=$proto; - if ($http==0) + $newproto = $proto; + if ($http == 0) { if (preg_match('/^http:[\\/]+/i', $url)) { @@ -637,7 +637,7 @@ function clean_url($url, $http = 1) */ function dolObfuscateEmail($mail, $replace = "*", $nbreplace = 8, $nbdisplaymail = 4, $nbdisplaydomain = 3, $displaytld = true) { - if(!isValidEmail($mail))return ''; + if (!isValidEmail($mail))return ''; $tab = explode('@', $mail); $tab2 = explode('.', $tab[1]); $string_replace = ''; @@ -646,24 +646,24 @@ function dolObfuscateEmail($mail, $replace = "*", $nbreplace = 8, $nbdisplaymail $mail_tld = ''; $nbofelem = count($tab2); - for($i=1; $i < $nbofelem && $displaytld; $i++) + for ($i = 1; $i < $nbofelem && $displaytld; $i++) { $mail_tld .= '.'.$tab2[$i]; } - for($i=0; $i < $nbreplace; $i++){ + for ($i = 0; $i < $nbreplace; $i++) { $string_replace .= $replace; } - if(strlen($mail_name) > $nbdisplaymail){ + if (strlen($mail_name) > $nbdisplaymail) { $mail_name = substr($mail_name, 0, $nbdisplaymail); } - if(strlen($mail_domaine) > $nbdisplaydomain){ - $mail_domaine = substr($mail_domaine, strlen($mail_domaine)-$nbdisplaydomain); + if (strlen($mail_domaine) > $nbdisplaydomain) { + $mail_domaine = substr($mail_domaine, strlen($mail_domaine) - $nbdisplaydomain); } - return $mail_name . $string_replace . $mail_domaine . $mail_tld; + return $mail_name.$string_replace.$mail_domaine.$mail_tld; } @@ -678,12 +678,12 @@ function dolObfuscateEmail($mail, $replace = "*", $nbreplace = 8, $nbdisplaymail */ function array2tr($data, $troptions = '', $tdoptions = '') { - $text = '' ; - foreach($data as $key => $item){ - $text.= '' ; + $text = ''; + foreach ($data as $key => $item) { + $text .= ''; } - $text.= '' ; - return $text ; + $text .= ''; + return $text; } /** @@ -698,20 +698,20 @@ function array2tr($data, $troptions = '', $tdoptions = '') */ function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = '', $tdoptions = '') { - $text='' ; - if($tableMarkup) $text = '
        '; print $langs->trans("ImportedWithSet"); @@ -222,7 +222,7 @@ function dol_print_object_info($object, $usetable = 0) } // User creation (old method using already loaded object and not id is kept for backward compatibility) - if (! empty($object->user_creation) || ! empty($object->user_creation_id)) + if (!empty($object->user_creation) || !empty($object->user_creation_id)) { if ($usetable) print '
        '; print $langs->trans("CreatedBy"); @@ -235,7 +235,7 @@ function dol_print_object_info($object, $usetable = 0) } else { - $userstatic=new User($db); + $userstatic = new User($db); $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); else print $langs->trans("Unknown"); @@ -245,20 +245,20 @@ function dol_print_object_info($object, $usetable = 0) } // Date creation - if (! empty($object->date_creation)) + if (!empty($object->date_creation)) { if ($usetable) print '
        '; print $langs->trans("DateCreation"); if ($usetable) print ''; else print ': '; print dol_print_date($object->date_creation, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_creation+($deltadateforuser*3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_creation + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); if ($usetable) print '
        '; print $langs->trans("ModifiedBy"); @@ -271,7 +271,7 @@ function dol_print_object_info($object, $usetable = 0) } else { - $userstatic=new User($db); + $userstatic = new User($db); $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); else print $langs->trans("Unknown"); @@ -281,20 +281,20 @@ function dol_print_object_info($object, $usetable = 0) } // Date change - if (! empty($object->date_modification)) + if (!empty($object->date_modification)) { if ($usetable) print '
        '; print $langs->trans("DateLastModification"); if ($usetable) print ''; else print ': '; print dol_print_date($object->date_modification, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_modification+($deltadateforuser*3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_modification + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); if ($usetable) print '
        '; print $langs->trans("ValidatedBy"); @@ -307,7 +307,7 @@ function dol_print_object_info($object, $usetable = 0) } else { - $userstatic=new User($db); + $userstatic = new User($db); $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); else print $langs->trans("Unknown"); @@ -317,20 +317,20 @@ function dol_print_object_info($object, $usetable = 0) } // Date validation - if (! empty($object->date_validation)) + if (!empty($object->date_validation)) { if ($usetable) print '
        '; print $langs->trans("DateValidation"); if ($usetable) print ''; else print ': '; print dol_print_date($object->date_validation, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_validation+($deltadateforuser*3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_validation + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); if ($usetable) print '
        '; print $langs->trans("ApprovedBy"); @@ -343,7 +343,7 @@ function dol_print_object_info($object, $usetable = 0) } else { - $userstatic=new User($db); + $userstatic = new User($db); $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); else print $langs->trans("Unknown"); @@ -353,26 +353,26 @@ function dol_print_object_info($object, $usetable = 0) } // Date approve - if (! empty($object->date_approve)) + if (!empty($object->date_approve)) { if ($usetable) print '
        '; print $langs->trans("DateApprove"); if ($usetable) print ''; else print ': '; print dol_print_date($object->date_approve, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve+($deltadateforuser*3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); if ($usetable) print '
        '; print $langs->trans("ApprovedBy"); if ($usetable) print ''; else print ': '; - $userstatic=new User($db); + $userstatic = new User($db); $userstatic->fetch($object->user_approve_id2); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); else print $langs->trans("Unknown"); @@ -381,20 +381,20 @@ function dol_print_object_info($object, $usetable = 0) } // Date approve - if (! empty($object->date_approve2)) + if (!empty($object->date_approve2)) { if ($usetable) print '
        '; print $langs->trans("DateApprove2"); if ($usetable) print ''; else print ': '; print dol_print_date($object->date_approve2, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve2+($deltadateforuser*3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_approve2 + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); if ($usetable) print '
        '; print $langs->trans("ClosedBy"); @@ -407,7 +407,7 @@ function dol_print_object_info($object, $usetable = 0) } else { - $userstatic=new User($db); + $userstatic = new User($db); $userstatic->fetch($object->user_cloture); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); else print $langs->trans("Unknown"); @@ -417,20 +417,20 @@ function dol_print_object_info($object, $usetable = 0) } // Date close - if (! empty($object->date_cloture)) + if (!empty($object->date_cloture)) { if ($usetable) print '
        '; print $langs->trans("DateClosing"); if ($usetable) print ''; else print ': '; print dol_print_date($object->date_cloture, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_cloture+($deltadateforuser*3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_cloture + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); if ($usetable) print '
        '; print $langs->trans("ConciliatedBy"); @@ -443,7 +443,7 @@ function dol_print_object_info($object, $usetable = 0) } else { - $userstatic=new User($db); + $userstatic = new User($db); $userstatic->fetch($object->user_rappro); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); else print $langs->trans("Unknown"); @@ -453,27 +453,27 @@ function dol_print_object_info($object, $usetable = 0) } // Date conciliate - if (! empty($object->date_rappro)) + if (!empty($object->date_rappro)) { if ($usetable) print '
        '; print $langs->trans("DateConciliating"); if ($usetable) print ''; else print ': '; print dol_print_date($object->date_rappro, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_rappro+($deltadateforuser*3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_rappro + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); if ($usetable) print '
        '; print $langs->trans("DateLastSend"); if ($usetable) print ''; else print ': '; print dol_print_date($object->date_envoi, 'dayhour'); - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_envoi+($deltadateforuser*3600), "dayhour").'  '.$langs->trans("ClientHour"); + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").'   /   '.dol_print_date($object->date_envoi + ($deltadateforuser * 3600), "dayhour").'  '.$langs->trans("ClientHour"); if ($usetable) print '
        '.$item.'
        '.$item.'
        ' ; - foreach($data as $key => $item){ - if(is_array($item)){ - $text.=array2tr($item, $troptions, $tdoptions); + $text = ''; + if ($tableMarkup) $text = '
        '; + foreach ($data as $key => $item) { + if (is_array($item)) { + $text .= array2tr($item, $troptions, $tdoptions); } else { - $text.= '' ; - $text.= '' ; - $text.= '' ; - $text.= '' ; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; } } - if($tableMarkup) $text.= '
        '.$key.''.$item.'
        '.$key.''.$item.'
        ' ; - return $text ; + if ($tableMarkup) $text .= '
        '; + return $text; } /** @@ -752,42 +752,42 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ //$date=dol_mktime(12, 0, 0, 1, 1, 1900); //$date=dol_stringtotime('20130101'); - $hasglobalcounter=false; + $hasglobalcounter = false; // Extract value for mask counter, mask raz and mask offset if (preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $mask, $reg)) { - $masktri=$reg[1].(! empty($reg[2])?$reg[2]:'').(! empty($reg[3])?$reg[3]:''); - $maskcounter=$reg[1]; - $hasglobalcounter=true; + $masktri = $reg[1].(!empty($reg[2]) ? $reg[2] : '').(!empty($reg[3]) ? $reg[3] : ''); + $maskcounter = $reg[1]; + $hasglobalcounter = true; } else { // setting some defaults so the rest of the code won't fail if there is a third party counter - $masktri='00000'; - $maskcounter='00000'; + $masktri = '00000'; + $maskcounter = '00000'; } - $maskraz=-1; - $maskoffset=0; - $resetEveryMonth=false; + $maskraz = -1; + $maskoffset = 0; + $resetEveryMonth = false; if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) return 'ErrorCounterMustHaveMoreThan3Digits'; // Extract value for third party mask counter if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) { - $maskrefclient=$regClientRef[1].$regClientRef[2]; - $maskrefclient_maskclientcode=$regClientRef[1]; - $maskrefclient_maskcounter=$regClientRef[2]; - $maskrefclient_maskoffset=0; //default value of maskrefclient_counter offset - $maskrefclient_clientcode=substr($valueforccc, 0, dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code where n is length in mask - $maskrefclient_clientcode=str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode - $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like + $maskrefclient = $regClientRef[1].$regClientRef[2]; + $maskrefclient_maskclientcode = $regClientRef[1]; + $maskrefclient_maskcounter = $regClientRef[2]; + $maskrefclient_maskoffset = 0; //default value of maskrefclient_counter offset + $maskrefclient_clientcode = substr($valueforccc, 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code where n is length in mask + $maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode + $maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; } - else $maskrefclient=''; + else $maskrefclient = ''; // fail if there is neither a global nor a third party counter - if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) + if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) { return 'ErrorBadMask'; } @@ -795,14 +795,14 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ // Extract value for third party type if (preg_match('/\{(t+)\}/i', $mask, $regType)) { - $masktype=$regType[1]; - $masktype_value=substr(preg_replace('/^TE_/', '', $objsoc->typent_code), 0, dol_strlen($regType[1]));// get n first characters of thirdpaty typent_code (where n is length in mask) - $masktype_value=str_pad($masktype_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask + $masktype = $regType[1]; + $masktype_value = substr(preg_replace('/^TE_/', '', $objsoc->typent_code), 0, dol_strlen($regType[1])); // get n first characters of thirdpaty typent_code (where n is length in mask) + $masktype_value = str_pad($masktype_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask } else { - $masktype=''; - $masktype_value=''; + $masktype = ''; + $masktype_value = ''; } // Extract value for user @@ -891,79 +891,79 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ // Define posy, posm and reg if ($maskraz > 1) // if reset is not first month, we need month and year into mask { - if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy=2; $posm=3; } - elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy=3; $posm=2; } + if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 3; } + elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 3; $posm = 2; } else return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit'; } else // if reset is for a specific month in year, we need year { - if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy=3; $posm=2; } - elseif (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy=2; $posm=3; } - elseif (preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy=2; $posm=0; } + if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 3; $posm = 2; } + elseif (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 3; } + elseif (preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 0; } else return 'ErrorCantUseRazIfNoYearInMask'; } // Define length - $yearlen = $posy?dol_strlen($reg[$posy]):0; - $monthlen = $posm?dol_strlen($reg[$posm]):0; + $yearlen = $posy ?dol_strlen($reg[$posy]) : 0; + $monthlen = $posm ?dol_strlen($reg[$posm]) : 0; // Define pos - $yearpos = (dol_strlen($reg[1])+1); - $monthpos = ($yearpos+$yearlen); + $yearpos = (dol_strlen($reg[1]) + 1); + $monthpos = ($yearpos + $yearlen); if ($posy == 3 && $posm == 2) { // if month is before year - $monthpos = (dol_strlen($reg[1])+1); - $yearpos = ($monthpos+$monthlen); + $monthpos = (dol_strlen($reg[1]) + 1); + $yearpos = ($monthpos + $monthlen); } //print "xxx ".$maskwithonlyymcode." maskraz=".$maskraz." posy=".$posy." yearlen=".$yearlen." yearpos=".$yearpos." posm=".$posm." monthlen=".$monthlen." monthpos=".$monthpos." yearoffsettype=".$yearoffsettype." resetEveryMonth=".$resetEveryMonth."\n"; // Define $yearcomp and $monthcomp (that will be use in the select where to search max number) - $monthcomp=$maskraz; - $yearcomp=0; + $monthcomp = $maskraz; + $yearcomp = 0; - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + + if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + { - $currentyear=date("Y", $date); - $fiscaldate=dol_mktime('0', '0', '0', $maskraz, '1', $currentyear); - $newyeardate=dol_mktime('0', '0', '0', '1', '1', $currentyear); - $nextnewyeardate=dol_mktime('0', '0', '0', '1', '1', $currentyear+1); + $currentyear = date("Y", $date); + $fiscaldate = dol_mktime('0', '0', '0', $maskraz, '1', $currentyear); + $newyeardate = dol_mktime('0', '0', '0', '1', '1', $currentyear); + $nextnewyeardate = dol_mktime('0', '0', '0', '1', '1', $currentyear + 1); //echo 'currentyear='.$currentyear.' date='.dol_print_date($date, 'day').' fiscaldate='.dol_print_date($fiscaldate, 'day').'
        '; // If after or equal of current fiscal date if ($date >= $fiscaldate) { // If before of next new year date - if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset=1; + if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset = 1; } // If after or equal of current new year date - elseif ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1; + elseif ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset = -1; } // For backward compatibility - elseif (date("m", $date) < $maskraz && empty($resetEveryMonth)) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year + elseif (date("m", $date) < $maskraz && empty($resetEveryMonth)) { $yearoffset = -1; } // If current month lower that month of return to zero, year is previous year - if ($yearlen == 4) $yearcomp=sprintf("%04d", date("Y", $date)+$yearoffset); - elseif ($yearlen == 2) $yearcomp=sprintf("%02d", date("y", $date)+$yearoffset); - elseif ($yearlen == 1) $yearcomp=substr(date("y", $date), 2, 1)+$yearoffset; + if ($yearlen == 4) $yearcomp = sprintf("%04d", date("Y", $date) + $yearoffset); + elseif ($yearlen == 2) $yearcomp = sprintf("%02d", date("y", $date) + $yearoffset); + elseif ($yearlen == 1) $yearcomp = substr(date("y", $date), 2, 1) + $yearoffset; if ($monthcomp > 1 && empty($resetEveryMonth)) // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) { - if ($yearlen == 4) $yearcomp1=sprintf("%04d", date("Y", $date)+$yearoffset+1); - elseif ($yearlen == 2) $yearcomp1=sprintf("%02d", date("y", $date)+$yearoffset+1); + if ($yearlen == 4) $yearcomp1 = sprintf("%04d", date("Y", $date) + $yearoffset + 1); + elseif ($yearlen == 2) $yearcomp1 = sprintf("%02d", date("y", $date) + $yearoffset + 1); - $sqlwhere.="("; - $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; - $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") >= '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; - $sqlwhere.=" OR"; - $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp1."'"; - $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') "; - $sqlwhere.=')'; + $sqlwhere .= "("; + $sqlwhere .= " (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; + $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") >= '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; + $sqlwhere .= " OR"; + $sqlwhere .= " (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp1."'"; + $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') "; + $sqlwhere .= ')'; } elseif ($resetEveryMonth) { - $sqlwhere.="(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; - $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; + $sqlwhere .= "(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; + $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; } else // reset is done on january { - $sqlwhere.='(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')"; + $sqlwhere .= '(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')"; } } //print "sqlwhere=".$sqlwhere." yearcomp=".$yearcomp."
        \n"; // sqlwhere and yearcomp defined only if we ask a reset @@ -972,14 +972,14 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ // Define $sqlstring if (function_exists('mb_strrpos')) { - $posnumstart=mb_strrpos($maskwithnocode, $maskcounter, 'UTF-8'); + $posnumstart = mb_strrpos($maskwithnocode, $maskcounter, 'UTF-8'); } else { - $posnumstart=strrpos($maskwithnocode, $maskcounter); + $posnumstart = strrpos($maskwithnocode, $maskcounter); } // Pos of counter in final string (from 0 to ...) if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence'; - $sqlstring='SUBSTRING('.$field.', '.($posnumstart+1).', '.dol_strlen($maskcounter).')'; + $sqlstring = 'SUBSTRING('.$field.', '.($posnumstart + 1).', '.dol_strlen($maskcounter).')'; // Define $maskLike $maskLike = dol_string_nospecial($mask); @@ -995,27 +995,27 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), str_pad("", dol_strlen($maskrefclient), "_"), $maskLike); if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); - foreach($maskperso as $key => $val) + foreach ($maskperso as $key => $val) { $maskLike = str_replace(dol_string_nospecial($maskperso[$key]), $maskpersonew[$key], $maskLike); } // Get counter in database - $counter=0; + $counter = 0; $sql = "SELECT MAX(".$sqlstring.") as val"; - $sql.= " FROM ".MAIN_DB_PREFIX.$table; - $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; - $sql.= " AND ".$field." NOT LIKE '(PROV%)'"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table; + $sql .= " WHERE ".$field." LIKE '".$maskLike."'"; + $sql .= " AND ".$field." NOT LIKE '(PROV%)'"; if ($bentityon) // only if entity enable - $sql.= " AND entity IN (".getEntity($sharetable).")"; - elseif (! empty($forceentity)) - $sql.= " AND entity IN (".$forceentity.")"; - if ($where) $sql.=$where; - if ($sqlwhere) $sql.=' AND '.$sqlwhere; + $sql .= " AND entity IN (".getEntity($sharetable).")"; + elseif (!empty($forceentity)) + $sql .= " AND entity IN (".$forceentity.")"; + if ($where) $sql .= $where; + if ($sqlwhere) $sql .= ' AND '.$sqlwhere; //print $sql.'
        '; dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -1024,17 +1024,17 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ else dol_print_error($db); // Check if we must force counter to maskoffset - if (empty($counter)) $counter=$maskoffset; + if (empty($counter)) $counter = $maskoffset; elseif (preg_match('/[^0-9]/i', $counter)) { - $counter=0; + $counter = 0; dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR); } - elseif ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter=$maskoffset; + elseif ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter = $maskoffset; if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice. { - $counterpadded=str_pad($counter, dol_strlen($maskcounter), "0", STR_PAD_LEFT); + $counterpadded = str_pad($counter, dol_strlen($maskcounter), "0", STR_PAD_LEFT); // Define $maskLike $maskLike = dol_string_nospecial($mask); @@ -1050,20 +1050,20 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); - $ref=''; + $ref = ''; $sql = "SELECT ".$field." as ref"; - $sql.= " FROM ".MAIN_DB_PREFIX.$table; - $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; - $sql.= " AND ".$field." NOT LIKE '%PROV%'"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table; + $sql .= " WHERE ".$field." LIKE '".$maskLike."'"; + $sql .= " AND ".$field." NOT LIKE '%PROV%'"; if ($bentityon) // only if entity enable - $sql.= " AND entity IN (".getEntity($sharetable).")"; - elseif (! empty($forceentity)) - $sql.= " AND entity IN (".$forceentity.")"; - if ($where) $sql.=$where; - if ($sqlwhere) $sql.=' AND '.$sqlwhere; + $sql .= " AND entity IN (".getEntity($sharetable).")"; + elseif (!empty($forceentity)) + $sql .= " AND entity IN (".$forceentity.")"; + if ($where) $sql .= $where; + if ($sqlwhere) $sql .= ' AND '.$sqlwhere; dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -1071,7 +1071,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ } else dol_print_error($db); - $numFinal=$ref; + $numFinal = $ref; } elseif ($mode == 'next') { @@ -1080,17 +1080,17 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ // If value for $counter has a length higher than $maskcounter chars if ($counter >= pow(10, dol_strlen($maskcounter))) { - $counter='ErrorMaxNumberReachForThisMask'; + $counter = 'ErrorMaxNumberReachForThisMask'; } - if (! empty($maskrefclient_maskcounter)) + if (!empty($maskrefclient_maskcounter)) { //print "maskrefclient_maskcounter=".$maskrefclient_maskcounter." maskwithnocode=".$maskwithnocode." maskrefclient=".$maskrefclient."\n
        "; // Define $sqlstring - $maskrefclient_posnumstart=strpos($maskwithnocode, $maskrefclient_maskcounter, strpos($maskwithnocode, $maskrefclient)); // Pos of counter in final string (from 0 to ...) + $maskrefclient_posnumstart = strpos($maskwithnocode, $maskrefclient_maskcounter, strpos($maskwithnocode, $maskrefclient)); // Pos of counter in final string (from 0 to ...) if ($maskrefclient_posnumstart <= 0) return 'ErrorBadMask'; - $maskrefclient_sqlstring='SUBSTRING('.$field.', '.($maskrefclient_posnumstart+1).', '.dol_strlen($maskrefclient_maskcounter).')'; + $maskrefclient_sqlstring = 'SUBSTRING('.$field.', '.($maskrefclient_posnumstart + 1).', '.dol_strlen($maskrefclient_maskcounter).')'; //print "x".$sqlstring; // Define $maskrefclient_maskLike @@ -1106,21 +1106,21 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $maskrefclient_maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), $maskrefclient_clientcode.str_pad("", dol_strlen($maskrefclient_maskcounter), "_"), $maskrefclient_maskLike); // Get counter in database - $maskrefclient_counter=0; + $maskrefclient_counter = 0; $maskrefclient_sql = "SELECT MAX(".$maskrefclient_sqlstring.") as val"; - $maskrefclient_sql.= " FROM ".MAIN_DB_PREFIX.$table; + $maskrefclient_sql .= " FROM ".MAIN_DB_PREFIX.$table; //$sql.= " WHERE ".$field." not like '(%'"; - $maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; + $maskrefclient_sql .= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; if ($bentityon) // only if entity enable - $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; - elseif (! empty($forceentity)) - $sql.= " AND entity IN (".$forceentity.")"; - if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask - if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask - $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode, $maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; + $maskrefclient_sql .= " AND entity IN (".getEntity($sharetable).")"; + elseif (!empty($forceentity)) + $sql .= " AND entity IN (".$forceentity.")"; + if ($where) $maskrefclient_sql .= $where; //use the same optional where as general mask + if ($sqlwhere) $maskrefclient_sql .= ' AND '.$sqlwhere; //use the same sqlwhere as general mask + $maskrefclient_sql .= ' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode, $maskrefclient) + 1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; dol_syslog("functions2::get_next_value maskrefclient", LOG_DEBUG); - $maskrefclient_resql=$db->query($maskrefclient_sql); + $maskrefclient_resql = $db->query($maskrefclient_sql); if ($maskrefclient_resql) { $maskrefclient_obj = $db->fetch_object($maskrefclient_resql); @@ -1128,7 +1128,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ } else dol_print_error($db); - if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i', $maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset; + if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i', $maskrefclient_counter)) $maskrefclient_counter = $maskrefclient_maskoffset; $maskrefclient_counter++; } @@ -1136,11 +1136,11 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $numFinal = $mask; // We replace special codes except refclient - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year + if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year { - $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date)+$yearoffset, $numFinal); - $numFinal = preg_replace('/\{yy\}/i', date("y", $date)+$yearoffset, $numFinal); - $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1)+$yearoffset, $numFinal); + $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date) + $yearoffset, $numFinal); + $numFinal = preg_replace('/\{yy\}/i', date("y", $date) + $yearoffset, $numFinal); + $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1) + $yearoffset, $numFinal); } else // we want yyyy to be current year { @@ -1152,8 +1152,8 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $numFinal = preg_replace('/\{dd\}/i', date("d", $date), $numFinal); // Now we replace the counter - $maskbefore='{'.$masktri.'}'; - $maskafter=str_pad($counter, dol_strlen($maskcounter), "0", STR_PAD_LEFT); + $maskbefore = '{'.$masktri.'}'; + $maskafter = str_pad($counter, dol_strlen($maskcounter), "0", STR_PAD_LEFT); //print 'x'.$maskbefore.'-'.$maskafter.'y'; $numFinal = str_replace($maskbefore, $maskafter, $numFinal); @@ -1296,8 +1296,8 @@ function check_value($mask, $value) // // Check length - $len=dol_strlen($maskwithnocode); - if (dol_strlen($value) != $len) $result=-1; + $len = dol_strlen($maskwithnocode); + if (dol_strlen($value) != $len) $result = -1; // Define $maskLike /* seems not used @@ -1327,11 +1327,11 @@ function check_value($mask, $value) */ function binhex($bin, $pad = false, $upper = false) { - $last = dol_strlen($bin)-1; - for($i=0; $i<=$last; $i++){ $x += $bin[$last-$i] * pow(2, $i); } + $last = dol_strlen($bin) - 1; + for ($i = 0; $i <= $last; $i++) { $x += $bin[$last - $i] * pow(2, $i); } $x = dechex($x); - if($pad){ while(dol_strlen($x) < intval(dol_strlen($bin))/4){ $x = "0$x"; } } - if($upper){ $x = strtoupper($x); } + if ($pad) { while (dol_strlen($x) < intval(dol_strlen($bin)) / 4) { $x = "0$x"; } } + if ($upper) { $x = strtoupper($x); } return $x; } @@ -1343,11 +1343,11 @@ function binhex($bin, $pad = false, $upper = false) */ function hexbin($hexa) { - $bin=''; + $bin = ''; $strLength = dol_strlen($hexa); - for($i=0;$i<$strLength;$i++) + for ($i = 0; $i < $strLength; $i++) { - $bin.=str_pad(decbin(hexdec($hexa{$i})), 4, '0', STR_PAD_LEFT); + $bin .= str_pad(decbin(hexdec($hexa{$i})), 4, '0', STR_PAD_LEFT); } return $bin; } @@ -1378,27 +1378,27 @@ function numero_semaine($time) */ // Definition du Jeudi de la semaine - if (date("w", mktime(12, 0, 0, $mois, $jour, $annee))==0) // Dimanche - $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee)-3*24*60*60; - elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee))<4) // du Lundi au Mercredi - $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee)+(4-date("w", mktime(12, 0, 0, $mois, $jour, $annee)))*24*60*60; - elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee))>4) // du Vendredi au Samedi - $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee)-(date("w", mktime(12, 0, 0, $mois, $jour, $annee))-4)*24*60*60; + if (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) == 0) // Dimanche + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - 3 * 24 * 60 * 60; + elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) < 4) // du Lundi au Mercredi + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) + (4 - date("w", mktime(12, 0, 0, $mois, $jour, $annee))) * 24 * 60 * 60; + elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) > 4) // du Vendredi au Samedi + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) - 4) * 24 * 60 * 60; else // Jeudi $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee); // Definition du premier Jeudi de l'annee - if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))==0) // Dimanche + if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 0) // Dimanche { - $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))+4*24*60*60; + $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + 4 * 24 * 60 * 60; } - elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))<4) // du Lundi au Mercredi + elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) < 4) // du Lundi au Mercredi { - $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))+(4-date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))))*24*60*60; + $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (4 - date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))) * 24 * 60 * 60; } - elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))>4) // du Vendredi au Samedi + elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) > 4) // du Vendredi au Samedi { - $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))+(7-(date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))-4))*24*60*60; + $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (7 - (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) - 4)) * 24 * 60 * 60; } else // Jeudi { @@ -1406,7 +1406,7 @@ function numero_semaine($time) } // Definition du numero de semaine: nb de jours entre "premier Jeudi de l'annee" et "Jeudi de la semaine"; - $numeroSemaine = ( + $numeroSemaine = ( ( date("z", mktime(12, 0, 0, date("m", $jeudiSemaine), date("d", $jeudiSemaine), date("Y", $jeudiSemaine))) - @@ -1415,10 +1415,10 @@ function numero_semaine($time) ) + 1; // Cas particulier de la semaine 53 - if ($numeroSemaine==53) + if ($numeroSemaine == 53) { // Les annees qui commence un Jeudi et les annees bissextiles commencant un Mercredi en possede 53 - if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))==4 || (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))==3 && date("z", mktime(12, 0, 0, 12, 31, date("Y", $jeudiSemaine)))==365)) + if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 4 || (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 3 && date("z", mktime(12, 0, 0, 12, 31, date("Y", $jeudiSemaine))) == 365)) { $numeroSemaine = 53; } @@ -1448,7 +1448,7 @@ function weight_convert($weight, &$from_unit, $to_unit) * weigh_convert(320, $f, 0) retournera 0.32 * */ - while ($from_unit <> $to_unit) + while ($from_unit <> $to_unit) { if ($from_unit > $to_unit) { @@ -1487,21 +1487,21 @@ function dol_set_user_param($db, $conf, &$user, $tab) // We remove old parameters for all keys in $tab $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; - $sql.= " WHERE fk_user = ".$user->id; - $sql.= " AND entity = ".$conf->entity; - $sql.= " AND param in ("; - $i=0; + $sql .= " WHERE fk_user = ".$user->id; + $sql .= " AND entity = ".$conf->entity; + $sql .= " AND param in ("; + $i = 0; foreach ($tab as $key => $value) { - if ($i > 0) $sql.=','; - $sql.="'".$db->escape($key)."'"; + if ($i > 0) $sql .= ','; + $sql .= "'".$db->escape($key)."'"; $i++; } - $sql.= ")"; + $sql .= ")"; dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); $db->rollback(); @@ -1514,12 +1514,12 @@ function dol_set_user_param($db, $conf, &$user, $tab) if ($value) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_param(fk_user,entity,param,value)"; - $sql.= " VALUES (".$user->id.",".$conf->entity.","; - $sql.= " '".$db->escape($key)."','".$db->escape($value)."')"; + $sql .= " VALUES (".$user->id.",".$conf->entity.","; + $sql .= " '".$db->escape($key)."','".$db->escape($value)."')"; dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG); - $result=$db->query($sql); - if (! $result) + $result = $db->query($sql); + if (!$result) { dol_print_error($db); $db->rollback(); @@ -1568,7 +1568,7 @@ function dol_print_reduction($reduction, $langs) */ function version_os() { - $osversion=php_uname(); + $osversion = php_uname(); return $osversion; } @@ -1718,10 +1718,10 @@ function is_ip($ip) // First we test if it is a valid IPv4 if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { // Then we test if it is a private range - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; + if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; // Then we test if it is a reserved range - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; + if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; return 1; } @@ -1738,10 +1738,10 @@ function is_ip($ip) */ function dol_buildlogin($lastname, $firstname) { - $login=strtolower(dol_string_unaccent($firstname)); - $login.=($login?'.':''); - $login.=strtolower(dol_string_unaccent($lastname)); - $login=dol_string_nospecial($login, ''); // For special names + $login = strtolower(dol_string_unaccent($firstname)); + $login .= ($login ? '.' : ''); + $login .= strtolower(dol_string_unaccent($lastname)); + $login = dol_string_nospecial($login, ''); // For special names return $login; } @@ -1754,18 +1754,18 @@ function getSoapParams() { global $conf; - $params=array(); - $proxyuse =(empty($conf->global->MAIN_PROXY_USE)?false:true); - $proxyhost=(empty($conf->global->MAIN_PROXY_USE)?false:$conf->global->MAIN_PROXY_HOST); - $proxyport=(empty($conf->global->MAIN_PROXY_USE)?false:$conf->global->MAIN_PROXY_PORT); - $proxyuser=(empty($conf->global->MAIN_PROXY_USE)?false:$conf->global->MAIN_PROXY_USER); - $proxypass=(empty($conf->global->MAIN_PROXY_USE)?false:$conf->global->MAIN_PROXY_PASS); - $timeout =(empty($conf->global->MAIN_USE_CONNECT_TIMEOUT)?10:$conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout - $response_timeout=(empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT)?30:$conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout + $params = array(); + $proxyuse = (empty($conf->global->MAIN_PROXY_USE) ?false:true); + $proxyhost = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_HOST); + $proxyport = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PORT); + $proxyuser = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_USER); + $proxypass = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PASS); + $timeout = (empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout + $response_timeout = (empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout //print extension_loaded('soap'); if ($proxyuse) { - $params=array('connection_timeout'=>$timeout, + $params = array('connection_timeout'=>$timeout, 'response_timeout'=>$response_timeout, 'proxy_use' => 1, 'proxy_host' => $proxyhost, @@ -1777,7 +1777,7 @@ function getSoapParams() } else { - $params=array('connection_timeout'=>$timeout, + $params = array('connection_timeout'=>$timeout, 'response_timeout'=>$response_timeout, 'proxy_use' => 0, 'proxy_host' => false, @@ -1804,7 +1804,7 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') { global $db, $conf, $langs; - $ret=''; + $ret = ''; // Parse element/subelement (ex: project_task) $module = $element = $subelement = $objecttype; @@ -1886,34 +1886,34 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; - $classname='FactureFournisseur'; + $classname = 'FactureFournisseur'; $classpath = 'fourn/class'; - $module='fournisseur'; + $module = 'fournisseur'; } - elseif ($objecttype == 'order_supplier') { + elseif ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; - $classname='CommandeFournisseur'; + $classname = 'CommandeFournisseur'; $classpath = 'fourn/class'; - $module='fournisseur'; + $module = 'fournisseur'; } - elseif ($objecttype == 'stock') { + elseif ($objecttype == 'stock') { $classpath = 'product/stock/class'; - $classfile='entrepot'; - $classname='Entrepot'; + $classfile = 'entrepot'; + $classname = 'Entrepot'; } - if (! empty($conf->$module->enabled)) + if (!empty($conf->$module->enabled)) { - $res=dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); + $res = dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); if ($res) { if (class_exists($classname)) { $object = new $classname($db); - $res=$object->fetch($objectid); + $res = $object->fetch($objectid); if ($res > 0) { - $ret=$object->getNomUrl($withpicto, $option); - } elseif($res==0) { - $ret=$langs->trans('Deleted'); + $ret = $object->getNomUrl($withpicto, $option); + } elseif ($res == 0) { + $ret = $langs->trans('Deleted'); } unset($object); } @@ -1934,12 +1934,12 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') */ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) { - $totalnb=0; - $listofid=array(); - $listofparentid=array(); + $totalnb = 0; + $listofid = array(); + $listofparentid = array(); // Get list of all id in array listofid and all parents in array listofparentid - $sql='SELECT rowid, '.$fieldfkparent.' as parent_id FROM '.MAIN_DB_PREFIX.$tabletocleantree; + $sql = 'SELECT rowid, '.$fieldfkparent.' as parent_id FROM '.MAIN_DB_PREFIX.$tabletocleantree; $resql = $db->query($sql); if ($resql) { @@ -1948,8 +1948,8 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) while ($i < $num) { $obj = $db->fetch_object($resql); - $listofid[]=$obj->rowid; - if ($obj->parent_id > 0) $listofparentid[$obj->rowid]=$obj->parent_id; + $listofid[] = $obj->rowid; + if ($obj->parent_id > 0) $listofparentid[$obj->rowid] = $obj->parent_id; $i++; } } @@ -1963,51 +1963,51 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) print 'Code requested to clean tree (may be to solve data corruption), so we check/clean orphelins and loops.'."
        \n"; // Check loops on each other - $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree." SET ".$fieldfkparent." = 0 WHERE ".$fieldfkparent." = rowid"; // So we update only records linked to themself + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree." SET ".$fieldfkparent." = 0 WHERE ".$fieldfkparent." = rowid"; // So we update only records linked to themself $resql = $db->query($sql); if ($resql) { - $nb=$db->affected_rows($sql); + $nb = $db->affected_rows($sql); if ($nb > 0) { print '
        Some record that were parent of themself were cleaned.'; } - $totalnb+=$nb; + $totalnb += $nb; } //else dol_print_error($db); // Check other loops - $listofidtoclean=array(); - foreach($listofparentid as $id => $pid) + $listofidtoclean = array(); + foreach ($listofparentid as $id => $pid) { // Check depth //print 'Analyse record id='.$id.' with parent '.$pid.'
        '; - $cursor=$id; $arrayidparsed=array(); // We start from child $id + $cursor = $id; $arrayidparsed = array(); // We start from child $id while ($cursor > 0) { - $arrayidparsed[$cursor]=1; + $arrayidparsed[$cursor] = 1; if ($arrayidparsed[$listofparentid[$cursor]]) // We detect a loop. A record with a parent that was already into child { print 'Found a loop between id '.$id.' - '.$cursor.'
        '; unset($arrayidparsed); - $listofidtoclean[$cursor]=$id; + $listofidtoclean[$cursor] = $id; break; } - $cursor=$listofparentid[$cursor]; + $cursor = $listofparentid[$cursor]; } if (count($listofidtoclean)) break; } $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; - $sql.= " SET ".$fieldfkparent." = 0"; - $sql.= " WHERE rowid IN (".join(',', $listofidtoclean).")"; // So we update only records detected wrong + $sql .= " SET ".$fieldfkparent." = 0"; + $sql .= " WHERE rowid IN (".join(',', $listofidtoclean).")"; // So we update only records detected wrong $resql = $db->query($sql); if ($resql) { - $nb=$db->affected_rows($sql); + $nb = $db->affected_rows($sql); if ($nb > 0) { // Removed orphelins records @@ -2015,18 +2015,18 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) print join(',', $listofidtoclean); } - $totalnb+=$nb; + $totalnb += $nb; } //else dol_print_error($db); // Check and clean orphelins $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; - $sql.= " SET ".$fieldfkparent." = 0"; - $sql.= " WHERE ".$fieldfkparent." NOT IN (".join(',', $listofid).")"; // So we update only records linked to a non existing parent + $sql .= " SET ".$fieldfkparent." = 0"; + $sql .= " WHERE ".$fieldfkparent." NOT IN (".join(',', $listofid).")"; // So we update only records linked to a non existing parent $resql = $db->query($sql); if ($resql) { - $nb=$db->affected_rows($sql); + $nb = $db->affected_rows($sql); if ($nb > 0) { // Removed orphelins records @@ -2034,7 +2034,7 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) print join(',', $listofid); } - $totalnb+=$nb; + $totalnb += $nb; } //else dol_print_error($db); @@ -2053,7 +2053,7 @@ function getElementProperties($element_type) { // Parse element/subelement (ex: project_task) $module = $element_type; - $element = $element_type; + $element = $element_type; $subelement = $element_type; // If we ask an resource form external module (instead of default path) @@ -2063,7 +2063,7 @@ function getElementProperties($element_type) } //print '
        1. element : '.$element.' - module : '.$module .'
        '; - if ( preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) { + if (preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) { $module = $element = $regs[1]; $subelement = $regs[2]; } @@ -2078,7 +2078,7 @@ function getElementProperties($element_type) // To work with non standard path if ($element_type == 'facture' || $element_type == 'invoice') { $classpath = 'compta/facture/class'; - $module ='facture'; + $module = 'facture'; $subelement = 'facture'; } if ($element_type == 'commande' || $element_type == 'order') { @@ -2086,10 +2086,10 @@ function getElementProperties($element_type) $module = 'commande'; $subelement = 'commande'; } - if ($element_type == 'propal') { + if ($element_type == 'propal') { $classpath = 'comm/propal/class'; } - if ($element_type == 'supplier_proposal') { + if ($element_type == 'supplier_proposal') { $classpath = 'supplier_proposal/class'; } if ($element_type == 'shipping') { @@ -2104,49 +2104,49 @@ function getElementProperties($element_type) } if ($element_type == 'contract') { $classpath = 'contrat/class'; - $module='contrat'; - $subelement='contrat'; + $module = 'contrat'; + $subelement = 'contrat'; } if ($element_type == 'member') { $classpath = 'adherents/class'; - $module='adherent'; - $subelement='adherent'; + $module = 'adherent'; + $subelement = 'adherent'; } if ($element_type == 'cabinetmed_cons') { $classpath = 'cabinetmed/class'; - $module='cabinetmed'; - $subelement='cabinetmedcons'; + $module = 'cabinetmed'; + $subelement = 'cabinetmedcons'; } if ($element_type == 'fichinter') { $classpath = 'fichinter/class'; - $module='ficheinter'; - $subelement='fichinter'; + $module = 'ficheinter'; + $subelement = 'fichinter'; } if ($element_type == 'dolresource' || $element_type == 'resource') { $classpath = 'resource/class'; - $module='resource'; - $subelement='dolresource'; + $module = 'resource'; + $subelement = 'dolresource'; } if ($element_type == 'propaldet') { $classpath = 'comm/propal/class'; - $module='propal'; - $subelement='propaleligne'; + $module = 'propal'; + $subelement = 'propaleligne'; } - if ($element_type == 'order_supplier') { + if ($element_type == 'order_supplier') { $classpath = 'fourn/class'; - $module='fournisseur'; - $subelement='commandefournisseur'; - $classfile='fournisseur.commande'; + $module = 'fournisseur'; + $subelement = 'commandefournisseur'; + $classfile = 'fournisseur.commande'; } - if ($element_type == 'invoice_supplier') { + if ($element_type == 'invoice_supplier') { $classpath = 'fourn/class'; - $module='fournisseur'; - $subelement='facturefournisseur'; - $classfile='fournisseur.facture'; + $module = 'fournisseur'; + $subelement = 'facturefournisseur'; + $classfile = 'fournisseur.facture'; } if ($element_type == "service") { $classpath = 'product/class'; - $subelement='product'; + $subelement = 'product'; } if (!isset($classfile)) $classfile = strtolower($subelement); @@ -2204,7 +2204,7 @@ function fetchObjectByElement($element_id, $element_type, $element_ref = '') */ function colorArrayToHex($arraycolor, $colorifnotfound = '888888') { - if (! is_array($arraycolor)) return $colorifnotfound; + if (!is_array($arraycolor)) return $colorifnotfound; if (empty($arraycolor)) return $colorifnotfound; return sprintf("%02s", dechex($arraycolor[0])).sprintf("%02s", dechex($arraycolor[1])).sprintf("%02s", dechex($arraycolor[2])); } @@ -2219,18 +2219,18 @@ function colorArrayToHex($arraycolor, $colorifnotfound = '888888') * @return array RGB hex value (without # before). For example: FF00FF * @see colorArrayToHex(), colorHexToRgb() */ -function colorStringToArray($stringcolor, $colorifnotfound = array(88,88,88)) +function colorStringToArray($stringcolor, $colorifnotfound = array(88, 88, 88)) { - if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is - $reg=array(); - $tmp=preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/', $stringcolor, $reg); - if (! $tmp) + if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is + $reg = array(); + $tmp = preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/', $stringcolor, $reg); + if (!$tmp) { - $tmp=explode(',', $stringcolor); + $tmp = explode(',', $stringcolor); if (count($tmp) < 3) return $colorifnotfound; return $tmp; } - return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); + return array(hexdec($reg[1]), hexdec($reg[2]), hexdec($reg[3])); } /** @@ -2372,18 +2372,18 @@ function colorHexToRgb($hex, $alpha = false, $returnArray = false) $rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0)); $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0)); $rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0)); - if ( $alpha !== false ) { + if ($alpha !== false) { $rgb['a'] = floatval($alpha); $string = 'rgba('.implode(',', $rgb).')'; } - else{ + else { $string = 'rgb('.implode(',', $rgb).')'; } - if($returnArray){ + if ($returnArray) { return $rgb; } - else{ + else { return $string; } } @@ -2406,8 +2406,8 @@ function cartesianArray(array $input) foreach ($input as $key => $values) { $append = array(); - foreach($result as $product) { - foreach($values as $item) { + foreach ($result as $product) { + foreach ($values as $item) { $product[$key] = $item; $append[] = $product; } @@ -2428,7 +2428,7 @@ function cartesianArray(array $input) */ function getModuleDirForApiClass($module) { - $moduledirforclass=$module; + $moduledirforclass = $module; if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i', '', $moduledirforclass); if ($module == 'contracts') { @@ -2525,11 +2525,11 @@ function randomColorPart($min = 0, $max = 255) */ function randomColor($min = 0, $max = 255) { - return randomColorPart($min, $max) . randomColorPart($min, $max) . randomColorPart($min, $max); + return randomColorPart($min, $max).randomColorPart($min, $max).randomColorPart($min, $max); } -if (! function_exists('dolEscapeXML')) +if (!function_exists('dolEscapeXML')) { /** * Encode string for xml usage @@ -2539,7 +2539,7 @@ if (! function_exists('dolEscapeXML')) */ function dolEscapeXML($string) { - return strtr($string, array('\''=>''','"'=>'"','&'=>'&','<'=>'<','>'=>'>')); + return strtr($string, array('\''=>''', '"'=>'"', '&'=>'&', '<'=>'<', '>'=>'>')); } } @@ -2555,25 +2555,25 @@ if (! function_exists('dolEscapeXML')) function autoOrManual($automaticmanual, $case = 1, $color = 0) { global $langs; - $result='unknown'; $classname=''; + $result = 'unknown'; $classname = ''; if ($automaticmanual == 1 || strtolower($automaticmanual) == 'automatic' || strtolower($automaticmanual) == 'true') // A mettre avant test sur no a cause du == 0 { - $result=$langs->trans('automatic'); - if ($case == 1 || $case == 3) $result=$langs->trans("Automatic"); - if ($case == 2) $result=''; - if ($case == 3) $result=' '.$result; + $result = $langs->trans('automatic'); + if ($case == 1 || $case == 3) $result = $langs->trans("Automatic"); + if ($case == 2) $result = ''; + if ($case == 3) $result = ' '.$result; - $classname='ok'; + $classname = 'ok'; } elseif ($automaticmanual == 0 || strtolower($automaticmanual) == 'manual' || strtolower($automaticmanual) == 'false') { - $result=$langs->trans("manual"); - if ($case == 1 || $case == 3) $result=$langs->trans("Manual"); - if ($case == 2) $result=''; - if ($case == 3) $result=' '.$result; + $result = $langs->trans("manual"); + if ($case == 1 || $case == 3) $result = $langs->trans("Manual"); + if ($case == 2) $result = ''; + if ($case == 3) $result = ' '.$result; - if ($color == 2) $classname='ok'; - else $classname='error'; + if ($color == 2) $classname = 'ok'; + else $classname = 'error'; } if ($color) return ''.$result.''; return $result; diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 97ab411bdfc..54d850d99b6 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -34,13 +34,13 @@ function commande_prepare_head(Commande $object) { global $db, $langs, $conf, $user; - if (! empty($conf->expedition->enabled)) $langs->load("sendings"); + if (!empty($conf->expedition->enabled)) $langs->load("sendings"); $langs->load("orders"); $h = 0; $head = array(); - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id; $head[$h][1] = $langs->trans("OrderCard"); diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index cac2208eb2f..ff4322a6983 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -90,9 +90,9 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') global $conf; // Define constant for TCPDF - if (! defined('K_TCPDF_EXTERNAL_CONFIG')) + if (!defined('K_TCPDF_EXTERNAL_CONFIG')) { - define('K_TCPDF_EXTERNAL_CONFIG', 1); // this avoid using tcpdf_config file + define('K_TCPDF_EXTERNAL_CONFIG', 1); // this avoid using tcpdf_config file define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/'); define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/'); dol_mkdir(K_PATH_CACHE); @@ -119,7 +119,7 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') define('HEAD_MAGNIFICATION', 1.1); define('K_CELL_HEIGHT_RATIO', 1.25); define('K_TITLE_MAGNIFICATION', 1.3); - define('K_SMALL_RATIO', 2/3); + define('K_SMALL_RATIO', 2 / 3); define('K_THAI_TOPCHARS', true); define('K_TCPDF_CALLS_IN_HTML', true); define('K_TCPDF_THROW_EXCEPTION_ERROR', false); @@ -135,14 +135,14 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') //$format=array($arrayformat['width'],$arrayformat['height']); //$metric=$arrayformat['unit']; - $pdfa=false; // PDF-1.3 - if (! empty($conf->global->PDF_USE_1A)) $pdfa=true; // PDF1/A + $pdfa = false; // PDF-1.3 + if (!empty($conf->global->PDF_USE_1A)) $pdfa = true; // PDF1/A if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); else $pdf = new TCPDF($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); // Protection and encryption of pdf - if (! empty($conf->global->PDF_SECURITY_ENCRYPTION)) + if (!empty($conf->global->PDF_SECURITY_ENCRYPTION)) { /* Permission supported by TCPDF - print : Print the document; @@ -157,20 +157,20 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') */ // For TCPDF, we specify permission we want to block - $pdfrights = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS)?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS, true):array('modify','copy')); // Json format in llx_const + $pdfrights = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS, true) : array('modify', 'copy')); // Json format in llx_const // Password for the end user - $pdfuserpass = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_USERPASS)?$conf->global->PDF_SECURITY_ENCRYPTION_USERPASS:''); + $pdfuserpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_USERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_USERPASS : ''); // Password of the owner, created randomly if not defined - $pdfownerpass = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS)?$conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS:null); + $pdfownerpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS : null); // For encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit - $encstrength = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH)?$conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH:0); + $encstrength = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH) ? $conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH : 0); // Array of recipients containing public-key certificates ('c') and permissions ('p'). // For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print'))) - $pubkeys = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS)?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS, true):null); // Json format in llx_const + $pubkeys = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS, true) : null); // Json format in llx_const $pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass, $encstrength, $pubkeys); } @@ -219,14 +219,14 @@ function pdf_getPDFFont($outputlangs) { global $conf; - if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT; + if (!empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT; - $font='Helvetica'; // By default, for FPDI, or ISO language on TCPDF + $font = 'Helvetica'; // By default, for FPDI, or ISO language on TCPDF if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) { - if ($outputlangs->trans('FONTFORPDF')!='FONTFORPDF') + if ($outputlangs->trans('FONTFORPDF') != 'FONTFORPDF') { - $font=$outputlangs->trans('FONTFORPDF'); + $font = $outputlangs->trans('FONTFORPDF'); } } return $font; @@ -266,14 +266,14 @@ function pdf_getPDFFontSize($outputlangs) function pdf_getHeightForLogo($logo, $url = false) { global $conf; - $height=(empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT)?22:$conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT); - $maxwidth=130; + $height = (empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT) ? 22 : $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT); + $maxwidth = 130; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $tmp=dol_getImageSize($logo, $url); + $tmp = dol_getImageSize($logo, $url); if ($tmp['height']) { - $width=round($height*$tmp['width']/$tmp['height']); - if ($width > $maxwidth) $height=$height*$maxwidth/$width; + $width = round($height * $tmp['width'] / $tmp['height']); + if ($width > $maxwidth) $height = $height * $maxwidth / $width; } //print $tmp['width'].' '.$tmp['height'].' '.$width; exit; return $height; @@ -307,9 +307,9 @@ function pdfGetHeightForHtmlContent(&$pdf, $htmlcontent) } else { - for ($page=$start_page; $page <= $end_page; ++$page) { + for ($page = $start_page; $page <= $end_page; ++$page) { $pdf->setPage($page); - $tmpm=$pdf->getMargins(); + $tmpm = $pdf->getMargins(); $tMargin = $tmpm['top']; if ($page == $start_page) { // first page @@ -346,7 +346,7 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali if ($thirdparty instanceof Societe) { $socname .= $thirdparty->name; - if (($includealias || ! empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) { + if (($includealias || !empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) { $socname .= "\n".$thirdparty->name_alias; } } elseif ($thirdparty instanceof Contact) { @@ -462,10 +462,10 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t { if ($usecontact) { - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1)); if (!empty($targetcontact->address)) { - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcontact)); } else { $companytouseforaddress = $targetcompany; @@ -476,73 +476,73 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t $companytouseforaddress = $targetcontact->thirdparty; } - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress)); } // Country if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) { - $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code)); } elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { - $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); } - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) { // Phone - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) { - if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; - if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); - if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / "; - if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); + if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": "; + if (!empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); + if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) $stringaddress .= " / "; + if (!empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); } // Fax - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) { - if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); + if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); } // EMail - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) { - if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); + if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); } // Web - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) { - if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); + if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); } } } else { - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany)); // Country - if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); + if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) { // Phone - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) { - if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; - if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); - if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / "; - if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); + if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": "; + if (!empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); + if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) $stringaddress .= " / "; + if (!empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); } // Fax - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) { - if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); + if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); } // EMail - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) { - if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); + if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); } // Web - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) { - if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); + if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); } } } @@ -550,57 +550,57 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t // Intra VAT if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) { - if ($targetcompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); + if ($targetcompany->tva_intra) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); } // Professionnal Ids - if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1)) + if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1)) { - $tmp=$outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); + $tmp = $outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); } - if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2)) + if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2)) { - $tmp=$outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); + $tmp = $outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); } - if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3)) + if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3)) { - $tmp=$outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); + $tmp = $outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); } - if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4)) + if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4)) { - $tmp=$outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); + $tmp = $outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); } - if (! empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && ! empty($targetcompany->idprof5)) + if (!empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && !empty($targetcompany->idprof5)) { - $tmp=$outputlangs->transcountrynoentities("ProfId5", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); + $tmp = $outputlangs->transcountrynoentities("ProfId5", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); } - if (! empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && ! empty($targetcompany->idprof6)) + if (!empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && !empty($targetcompany->idprof6)) { - $tmp=$outputlangs->transcountrynoentities("ProfId6", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); + $tmp = $outputlangs->transcountrynoentities("ProfId6", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); } // Public note - if (! empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) + if (!empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) { - if ($mode == 'source' && ! empty($sourcecompany->note_public)) + if ($mode == 'source' && !empty($sourcecompany->note_public)) { - $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($sourcecompany->note_public); + $stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($sourcecompany->note_public); } - if (($mode == 'target' || preg_match('/targetwithdetails/', $mode)) && ! empty($targetcompany->note_public)) + if (($mode == 'target' || preg_match('/targetwithdetails/', $mode)) && !empty($targetcompany->note_public)) { - $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($targetcompany->note_public); + $stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($targetcompany->note_public); } } } @@ -623,11 +623,11 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) global $conf; // Add a background image on document - if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image + if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image { - $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image - $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height); - $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak + $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image + $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); + $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak } } @@ -644,8 +644,8 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) function pdf_getSubstitutionArray($outputlangs, $exclude = null, $object = null, $onlykey = 0) { $substitutionarray = getCommonSubstitutionArray($outputlangs, $onlykey, $exclude, $object); - $substitutionarray['__FROM_NAME__']='__FROM_NAME__'; - $substitutionarray['__FROM_EMAIL__']='__FROM_EMAIL__'; + $substitutionarray['__FROM_NAME__'] = '__FROM_NAME__'; + $substitutionarray['__FROM_EMAIL__'] = '__FROM_EMAIL__'; return $substitutionarray; } @@ -666,31 +666,31 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) global $langs, $mysoc, $user; // Print Draft Watermark - if ($unit=='pt') $k=1; - elseif ($unit=='mm') $k=72/25.4; - elseif ($unit=='cm') $k=72/2.54; - elseif ($unit=='in') $k=72; + if ($unit == 'pt') $k = 1; + elseif ($unit == 'mm') $k = 72 / 25.4; + elseif ($unit == 'cm') $k = 72 / 2.54; + elseif ($unit == 'in') $k = 72; // Make substitution - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, null); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, null); complete_substitutions_array($substitutionarray, $outputlangs, null); - $text=make_substitutions($text, $substitutionarray, $outputlangs); - $text=$outputlangs->convToOutputCharset($text); + $text = make_substitutions($text, $substitutionarray, $outputlangs); + $text = $outputlangs->convToOutputCharset($text); - $savx=$pdf->getX(); $savy=$pdf->getY(); + $savx = $pdf->getX(); $savy = $pdf->getY(); - $watermark_angle=atan($h/$w)/2; - $watermark_x_pos=0; - $watermark_y_pos=$h/3; - $watermark_x=$w/2; - $watermark_y=$h/3; + $watermark_angle = atan($h / $w) / 2; + $watermark_x_pos = 0; + $watermark_y_pos = $h / 3; + $watermark_x = $w / 2; + $watermark_y = $h / 3; $pdf->SetFont('', 'B', 40); $pdf->SetTextColor(255, 192, 203); //rotate - $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x*$k, ($h-$watermark_y)*$k, -$watermark_x*$k, -($h-$watermark_y)*$k)); + $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x * $k, ($h - $watermark_y) * $k, -$watermark_x * $k, -($h - $watermark_y) * $k)); //print watermark $pdf->SetXY($watermark_x_pos, $watermark_y_pos); - $pdf->Cell($w-20, 25, $outputlangs->convToOutputCharset($text), "", 2, "C", 0); + $pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text), "", 2, "C", 0); //antirotate $pdf->_out('Q'); @@ -716,37 +716,37 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); - $diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + $diffsizecontent = (empty($conf->global->PDF_DIFFSIZE_CONTENT) ? 4 : $conf->global->PDF_DIFFSIZE_CONTENT); $pdf->SetXY($curx, $cury); if (empty($onlynumber)) { $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); - $cury+=4; + $cury += 4; } $outputlangs->load("banks"); // Use correct name of bank id according to country - $bickey="BICNumber"; - if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($account->getCountryCode() == 'IN') $bickey = "SWIFT"; // Get format of bank account according to its country - $usedetailedbban=$account->useDetailedBBAN(); + $usedetailedbban = $account->useDetailedBBAN(); //$onlynumber=0; $usedetailedbban=1; // For tests if ($usedetailedbban) { - $savcurx=$curx; + $savcurx = $curx; if (empty($onlynumber)) { $pdf->SetFont('', '', $default_font_size - $diffsizecontent); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); + $cury += 3; } if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enougth for them @@ -756,12 +756,12 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, // desk = code guichet (FR), used only when $usedetailedbban = 1 // number = account number // key = check control key used only when $usedetailedbban = 1 - if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+6); + if (empty($onlynumber)) $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6); foreach ($account->getFieldsToShow() as $val) { - $pdf->SetXY($curx, $cury+4); + $pdf->SetXY($curx, $cury + 4); $pdf->SetFont('', '', $default_font_size - 3); if ($val == 'BankCode') { @@ -799,54 +799,54 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, } } - $curx=$savcurx; - $cury+=8; + $curx = $savcurx; + $cury += 8; } } else { $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); + $cury += 3; $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': '.$outputlangs->convToOutputCharset($account->number), 0, 'L', 0); + $cury += 3; - if ($diffsizecontent <= 2) $cury+=1; + if ($diffsizecontent <= 2) $cury += 1; } $pdf->SetFont('', '', $default_font_size - $diffsizecontent); - if (empty($onlynumber) && ! empty($account->domiciliation)) + if (empty($onlynumber) && !empty($account->domiciliation)) { $pdf->SetXY($curx, $cury); - $val=$outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation); + $val = $outputlangs->transnoentities("Residence").': '.$outputlangs->convToOutputCharset($account->domiciliation); $pdf->MultiCell(100, 3, $val, 0, 'L', 0); //$nboflines=dol_nboflines_bis($val,120); //$cury+=($nboflines*3)+2; - $tmpy=$pdf->getStringHeight(100, $val); - $cury+=$tmpy; + $tmpy = $pdf->getStringHeight(100, $val); + $cury += $tmpy; } - if (! empty($account->proprio)) + if (!empty($account->proprio)) { $pdf->SetXY($curx, $cury); - $val=$outputlangs->transnoentities("BankAccountOwner").': ' . $outputlangs->convToOutputCharset($account->proprio); + $val = $outputlangs->transnoentities("BankAccountOwner").': '.$outputlangs->convToOutputCharset($account->proprio); $pdf->MultiCell(100, 3, $val, 0, 'L', 0); - $tmpy=$pdf->getStringHeight(100, $val); - $cury+=$tmpy; - $cur+=1; + $tmpy = $pdf->getStringHeight(100, $val); + $cury += $tmpy; + $cur += 1; } - elseif (! $usedetailedbban) $cury+=1; + elseif (!$usedetailedbban) $cury += 1; // Use correct name of bank id according to country $ibankey = FormBank::getIBANLabel($account); - if (! empty($account->iban)) + if (!empty($account->iban)) { //Remove whitespaces to ensure we are dealing with the format we expect $ibanDisplay_temp = str_replace(' ', '', $outputlangs->convToOutputCharset($account->iban)); @@ -856,20 +856,20 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, for ($i = 0; $i < $nbIbanDisplay_temp; $i++) { $ibanDisplay .= $ibanDisplay_temp[$i]; - if($i%4 == 3 && $i > 0) $ibanDisplay .= " "; + if ($i % 4 == 3 && $i > 0) $ibanDisplay .= " "; } $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': ' . $ibanDisplay, 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': '.$ibanDisplay, 0, 'L', 0); + $cury += 3; } - if (! empty($account->bic)) + if (!empty($account->bic)) { $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': '.$outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); } return $pdf->getY(); @@ -975,7 +975,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Managers if ($fromcompany->managers) { - $line2.=($line2?" - ":"").$fromcompany->managers; + $line2 .= ($line2 ? " - " : "").$fromcompany->managers; } } @@ -983,90 +983,90 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Juridical status if ($fromcompany->forme_juridique_code) { - $line3.=($line3?" - ":"").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); + $line3 .= ($line3 ? " - " : "").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); } // Capital if ($fromcompany->capital) { $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string - if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); - else $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs); + if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); + else $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs); } // Prof Id 1 - if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) { - $field=$outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); + $field = $outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); } // Prof Id 2 if ($fromcompany->idprof2) { - $field=$outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2); + $field = $outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2); } // Line 4 of company infos // Prof Id 3 if ($fromcompany->idprof3) { - $field=$outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); + $field = $outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); } // Prof Id 4 if ($fromcompany->idprof4) { - $field=$outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); + $field = $outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); } // Prof Id 5 if ($fromcompany->idprof5) { - $field=$outputlangs->transcountrynoentities("ProfId5", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5); + $field = $outputlangs->transcountrynoentities("ProfId5", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5); } // Prof Id 6 if ($fromcompany->idprof6) { - $field=$outputlangs->transcountrynoentities("ProfId6", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6); + $field = $outputlangs->transcountrynoentities("ProfId6", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6); } // IntraCommunautary VAT if ($fromcompany->tva_intra != '') { - $line4.=($line4?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra); + $line4 .= ($line4 ? " - " : "").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra); } $pdf->SetFont('', '', 7); $pdf->SetDrawColor(224, 224, 224); // The start of the bottom of this page footer is positioned according to # of lines - $freetextheight=0; + $freetextheight = 0; if ($line) // Free text { //$line="sample text
        \nfdsfsdf
        \nghfghg
        "; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. - if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { - $width=200; $align='C'; + $width = 20000; $align = 'L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. + if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { + $width = 200; $align = 'C'; } - $freetextheight=$pdf->getStringHeight($width, $line); + $freetextheight = $pdf->getStringHeight($width, $line); } else { - $freetextheight=pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); // New method (works for HTML content) + $freetextheight = pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); // New method (works for HTML content) //print '
        '.$freetextheight;exit; } } - $marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0); - $posy=$marginwithfooter+0; + $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0); + $posy = $marginwithfooter + 0; if ($line) // Free text { @@ -1077,50 +1077,50 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } else { - $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk']-$marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); + $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); } - $posy-=$freetextheight; + $posy -= $freetextheight; } $pdf->SetY(-$posy); - $pdf->line($dims['lm'], $dims['hk']-$posy, $dims['wk']-$dims['rm'], $dims['hk']-$posy); + $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); $posy--; - if (! empty($line1)) + if (!empty($line1)) { $pdf->SetFont('', 'B', 7); $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line1, 0, 'C', 0); - $posy-=3; + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line1, 0, 'C', 0); + $posy -= 3; $pdf->SetFont('', '', 7); } - if (! empty($line2)) + if (!empty($line2)) { $pdf->SetFont('', 'B', 7); $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line2, 0, 'C', 0); - $posy-=3; + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line2, 0, 'C', 0); + $posy -= 3; $pdf->SetFont('', '', 7); } - if (! empty($line3)) + if (!empty($line3)) { $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line3, 0, 'C', 0); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line3, 0, 'C', 0); } - if (! empty($line4)) + if (!empty($line4)) { - $posy-=3; + $posy -= 3; $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line4, 0, 'C', 0); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line4, 0, 'C', 0); } // Show page nb only on iso languages (so default Helvetica font) if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { - $pdf->SetXY($dims['wk']-$dims['rm']-15, -$posy); + $pdf->SetXY($dims['wk'] - $dims['rm'] - 15, -$posy); //print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; $pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); } @@ -1145,17 +1145,17 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ function pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size) { $linkedobjects = pdf_getLinkedObjects($object, $outputlangs); - if (! empty($linkedobjects)) + if (!empty($linkedobjects)) { - foreach($linkedobjects as $linkedobject) + foreach ($linkedobjects as $linkedobject) { $reftoshow = $linkedobject["ref_title"].' : '.$linkedobject["ref_value"]; - if (! empty($linkedobject["date_value"])) + if (!empty($linkedobject["date_value"])) { $reftoshow .= ' / '.$linkedobject["date_value"]; } - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetFont('', '', $default_font_size - 2); $pdf->MultiCell($w, $h, $reftoshow, '', $align); @@ -1185,22 +1185,22 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos { global $db, $conf, $langs, $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code); - $action=''; - $reshook=$hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('pdf'=>$pdf, 'i'=>$i, 'outputlangs'=>$outputlangs, 'w'=>$w, 'h'=>$h, 'posx'=>$posx, 'posy'=>$posy, 'hideref'=>$hideref, 'hidedesc'=>$hidedesc, 'issupplierline'=>$issupplierline, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $labelproductservice=pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline); + $labelproductservice = pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline); //var_dump($labelproductservice);exit; @@ -1212,7 +1212,7 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos // Description $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, 'J', true); - $result.=$labelproductservice; + $result .= $labelproductservice; } return $result; } @@ -1232,12 +1232,12 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { global $db, $conf, $langs; - $idprod=(! empty($object->lines[$i]->fk_product)?$object->lines[$i]->fk_product:false); - $label=(! empty($object->lines[$i]->label)?$object->lines[$i]->label:(! empty($object->lines[$i]->product_label)?$object->lines[$i]->product_label:'')); - $desc=(! empty($object->lines[$i]->desc)?$object->lines[$i]->desc:(! empty($object->lines[$i]->description)?$object->lines[$i]->description:'')); - $ref_supplier=(! empty($object->lines[$i]->ref_supplier)?$object->lines[$i]->ref_supplier:(! empty($object->lines[$i]->ref_fourn)?$object->lines[$i]->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders - $note=(! empty($object->lines[$i]->note)?$object->lines[$i]->note:''); - $dbatch=(! empty($object->lines[$i]->detail_batch)?$object->lines[$i]->detail_batch:false); + $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); + $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); + $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); + $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders + $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); + $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); if ($issupplierline) { @@ -1254,9 +1254,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated - if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) + if (!empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) { - $translatealsoifmodified=(! empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) + $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation // ($textwasmodified is replaced with $textwasmodifiedorcompleted and we add completion). @@ -1264,63 +1264,63 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Set label // If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation. //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit; - $textwasmodified=($label == $prodser->label); - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; + $textwasmodified = ($label == $prodser->label); + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label = $prodser->multilangs[$outputlangs->defaultlang]["label"]; // Set desc // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no - $textwasmodified=false; + $textwasmodified = false; if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) { - $textwasmodified=(strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401))!==false); + $textwasmodified = (strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401)) !== false); } else { - $textwasmodified=($desc == $prodser->description); + $textwasmodified = ($desc == $prodser->description); } - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"]; // Set note - $textwasmodified=($note == $prodser->note); - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; + $textwasmodified = ($note == $prodser->note); + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; } } // Description short of product line - $libelleproduitservice=$label; + $libelleproduitservice = $label; // Description long of product line - if (! empty($desc) && ($desc != $label)) + if (!empty($desc) && ($desc != $label)) { if ($libelleproduitservice && empty($hidedesc)) { - $libelleproduitservice.='__N__'; + $libelleproduitservice .= '__N__'; } if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); // Add date of deposit - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; } if ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); } elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { @@ -1330,17 +1330,17 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) { - $libelleproduitservice=$desc."\n".$libelleproduitservice; + $libelleproduitservice = $desc."\n".$libelleproduitservice; } else { - $libelleproduitservice.=$desc; + $libelleproduitservice .= $desc; } } } else { - $libelleproduitservice.=$desc; + $libelleproduitservice .= $desc; } } } @@ -1348,7 +1348,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // We add ref of product (and supplier ref if defined) $prefix_prodserv = ""; $ref_prodserv = ""; - if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this + if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this { if ($prodser->isService()) { @@ -1367,11 +1367,11 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) $ref_prodserv = $ref_supplier; elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) - $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; + $ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; else // Common case { $ref_prodserv = $prodser->ref; // Show local ref - if ($ref_supplier) $ref_prodserv.= ($prodser->ref?' (':'').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref?')':''); + if ($ref_supplier) $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : ''); } } else @@ -1462,21 +1462,21 @@ function pdf_getlinenum($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinenum', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $result.=$hookmanager->resPrint; + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinenum', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $result.=dol_htmlentitiesbr($object->lines[$i]->num); + $result .= dol_htmlentitiesbr($object->lines[$i]->num); } return $result; } @@ -1495,21 +1495,21 @@ function pdf_getlineref($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineref', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $result.=$hookmanager->resPrint; + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineref', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $result.=dol_htmlentitiesbr($object->lines[$i]->product_ref); + $result .= dol_htmlentitiesbr($object->lines[$i]->product_ref); } return $result; } @@ -1527,21 +1527,21 @@ function pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $result.=$hookmanager->resPrint; + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $result.=dol_htmlentitiesbr($object->lines[$i]->ref_supplier); + $result .= dol_htmlentitiesbr($object->lines[$i]->ref_supplier); } return $result; } @@ -1559,47 +1559,47 @@ function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager, $mysoc; - $result=''; - $reshook=0; + $result = ''; + $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if (empty($hidedetails) || $hidedetails > 1) { - $tmpresult=''; + $tmpresult = ''; - $tmpresult.=vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); + $tmpresult .= vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) { if ($object->lines[$i]->total_localtax1 != 0) { - if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult.='/'; - else $tmpresult=''; - $tmpresult.=vatrate(abs($object->lines[$i]->localtax1_tx), 0); + if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult .= '/'; + else $tmpresult = ''; + $tmpresult .= vatrate(abs($object->lines[$i]->localtax1_tx), 0); } } if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) { if ($object->lines[$i]->total_localtax2 != 0) { - if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult.='/'; - else $tmpresult=''; - $tmpresult.=vatrate(abs($object->lines[$i]->localtax2_tx), 0); + if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult .= '/'; + else $tmpresult = ''; + $tmpresult .= vatrate(abs($object->lines[$i]->localtax2_tx), 0); } } - $tmpresult.= '%'; + $tmpresult .= '%'; - $result.=$tmpresult; + $result .= $tmpresult; } } return $result; @@ -1618,28 +1618,28 @@ function pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $result=''; - $reshook=0; + $result = ''; + $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if (empty($hidedetails) || $hidedetails > 1) { $subprice = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice); - $result.=price($sign * $subprice, 0, $outputlangs); + $result .= price($sign * $subprice, 0, $outputlangs); } } return $result; @@ -1656,27 +1656,27 @@ function pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails = 0) */ function pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails = 0) { - global $hookmanager,$conf; + global $hookmanager, $conf; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $result=''; - $reshook=0; + $result = ''; + $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { - if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs); + if (empty($hidedetails) || $hidedetails > 1) $result .= price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs); } return $result; } @@ -1728,23 +1728,23 @@ function pdf_getlineqty_asked($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty_asked; + if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_asked; } return $result; } @@ -1762,23 +1762,23 @@ function pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty_shipped; + if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_shipped; } return $result; } @@ -1796,23 +1796,23 @@ function pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); + if (empty($hidedetails) || $hidedetails > 1) $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); } return $result; } @@ -1831,8 +1831,8 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag { global $langs; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { @@ -1847,14 +1847,14 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag 'special_code' => $special_code ); $action = ''; - $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); + if (empty($hidedetails) || $hidedetails > 1) $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); } return $result; } @@ -1875,23 +1875,23 @@ function pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails = 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs); + if (empty($hidedetails) || $hidedetails > 1) $result .= dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs); } return $result; } @@ -1911,8 +1911,8 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm if (empty($hookmanager)) global $hookmanager; global $conf; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { @@ -1920,9 +1920,9 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code); $action = ''; - $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint; } if (empty($reshook)) { @@ -1936,10 +1936,10 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm { $prev_progress = $object->lines[$i]->get_prev_progress($object->id); } - $result = ($object->lines[$i]->situation_percent - $prev_progress) . '%'; + $result = ($object->lines[$i]->situation_percent - $prev_progress).'%'; } else - $result = $object->lines[$i]->situation_percent . '%'; + $result = $object->lines[$i]->situation_percent.'%'; } } return $result; @@ -1958,21 +1958,21 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code, 'sign'=>$sign); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code, 'sign'=>$sign); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { @@ -2015,31 +2015,31 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) */ function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0) { - global $hookmanager,$conf; + global $hookmanager, $conf; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) { - $result.=$outputlangs->transnoentities("Option"); + $result .= $outputlangs->transnoentities("Option"); } - elseif (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); + elseif (empty($hidedetails) || $hidedetails > 1) $result .= price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht) * ($object->lines[$i]->tva_tx) / 100, 0, $outputlangs); } return $result; } @@ -2104,11 +2104,11 @@ function pdf_getLinkedObjects($object, $outputlangs) { global $hookmanager; - $linkedobjects=array(); + $linkedobjects = array(); $object->fetchObjectLinked(); - foreach($object->linkedObjects as $objecttype => $objects) + foreach ($object->linkedObjects as $objecttype => $objects) { if ($objecttype == 'facture') { @@ -2118,7 +2118,7 @@ function pdf_getLinkedObjects($object, $outputlangs) { $outputlangs->load('propal'); - foreach($objects as $elementobject) + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); @@ -2129,10 +2129,10 @@ function pdf_getLinkedObjects($object, $outputlangs) elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') { $outputlangs->load('orders'); - foreach($objects as $elementobject) + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder"); - $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref) . ($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '') . ($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : ''); + $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : ''); $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate"); $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs); } @@ -2140,7 +2140,7 @@ function pdf_getLinkedObjects($object, $outputlangs) elseif ($objecttype == 'contrat') { $outputlangs->load('contracts'); - foreach($objects as $elementobject) + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); @@ -2152,29 +2152,29 @@ function pdf_getLinkedObjects($object, $outputlangs) { $outputlangs->loadLangs(array("orders", "sendings")); - foreach($objects as $x => $elementobject) + foreach ($objects as $x => $elementobject) { - $order=null; + $order = null; // We concat this record info into fields xxx_value. title is overwrote. if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order { $elementobject->fetchObjectLinked(); - if (! empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); + if (!empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); } - if (! is_object($order)) + if (!is_object($order)) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending"); - if (! empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'].=' / '; - $linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref); + if (!empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] .= ' / '; + $linkedobjects[$objecttype]['ref_value'] .= $outputlangs->transnoentities($elementobject->ref); //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateShipment"); //if (! empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'].=' / '; //$linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs); } else { - $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending"); - if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : ''); - $linkedobjects[$objecttype]['ref_value'].= ' / ' . $outputlangs->transnoentities($elementobject->ref); + $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending"); + if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : ''); + $linkedobjects[$objecttype]['ref_value'] .= ' / '.$outputlangs->transnoentities($elementobject->ref); //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ($elementobject->date_delivery ? ' / ' . $outputlangs->transnoentities("DateShipment") : ''); //if (empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date,'day','',$outputlangs); //$linkedobjects[$objecttype]['date_value'].= ($elementobject->date_delivery ? ' / ' . dol_print_date($elementobject->date_delivery,'day','',$outputlangs) : ''); @@ -2187,9 +2187,9 @@ function pdf_getLinkedObjects($object, $outputlangs) if (is_object($hookmanager)) { $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); - $action=''; - $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; + $action = ''; + $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; } return $linkedobjects; @@ -2206,24 +2206,24 @@ function pdf_getSizeForImage($realpath) { global $conf; - $maxwidth=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); - $maxheight=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT)?32:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT); + $maxwidth = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); + $maxheight = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT) ? 32 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT); include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $tmp=dol_getImageSize($realpath); + $tmp = dol_getImageSize($realpath); if ($tmp['height']) { - $width=(int) round($maxheight*$tmp['width']/$tmp['height']); // I try to use maxheight + $width = (int) round($maxheight * $tmp['width'] / $tmp['height']); // I try to use maxheight if ($width > $maxwidth) // Pb with maxheight, so i use maxwidth { - $width=$maxwidth; - $height=(int) round($maxwidth*$tmp['height']/$tmp['width']); + $width = $maxwidth; + $height = (int) round($maxwidth * $tmp['height'] / $tmp['width']); } else // No pb with maxheight { - $height=$maxheight; + $height = $maxheight; } } - return array('width'=>$width,'height'=>$height); + return array('width'=>$width, 'height'=>$height); } /** diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index bdeb9181d3b..8dfed7f436c 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -45,7 +45,7 @@ function product_prepare_head($object) $head[$h][2] = 'card'; $h++; - if (! empty($object->status)) + if (!empty($object->status)) { $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id; $head[$h][1] = $langs->trans("SellingPrices"); @@ -53,10 +53,10 @@ function product_prepare_head($object) $h++; } - if (! empty($object->status_buy) || (! empty($conf->margin->enabled) && ! empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase + if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase { - if ((! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) - || (! empty($conf->margin->enabled) && $user->rights->margin->liretous) + if ((!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) + || (!empty($conf->margin->enabled) && $user->rights->margin->liretous) ) { $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id; @@ -67,7 +67,7 @@ function product_prepare_head($object) } // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { $head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$object->id; $head[$h][1] = $langs->trans("Translation"); @@ -130,16 +130,16 @@ function product_prepare_head($object) // Tab to link resources if (!empty($conf->resource->enabled)) { - if ($object->isProduct() && ! empty($conf->global->RESOURCE_ON_PRODUCTS)) + if ($object->isProduct() && !empty($conf->global->RESOURCE_ON_PRODUCTS)) { - $head[$h][0] = DOL_URL_ROOT . '/resource/element_resource.php?element=product&ref=' . $object->ref; + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=product&ref='.$object->ref; $head[$h][1] = $langs->trans("Resources"); $head[$h][2] = 'resources'; $h++; } - if ($object->isService() && ! empty($conf->global->RESOURCE_ON_SERVICES)) + if ($object->isService() && !empty($conf->global->RESOURCE_ON_SERVICES)) { - $head[$h][0] = DOL_URL_ROOT . '/resource/element_resource.php?element=service&ref=' . $object->ref; + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=service&ref='.$object->ref; $head[$h][1] = $langs->trans("Resources"); $head[$h][2] = 'resources'; $h++; @@ -188,10 +188,10 @@ function product_prepare_head($object) // Log $head[$h][0] = DOL_URL_ROOT.'/product/agenda.php?id='.$object->id; $head[$h][1] = $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; @@ -210,7 +210,7 @@ function productlot_prepare_head($object) global $db, $langs, $conf, $user; // Load translation files required by the page - $langs->loadLangs(array("products","productbatch")); + $langs->loadLangs(array("products", "productbatch")); $h = 0; $head = array(); @@ -270,7 +270,7 @@ function product_admin_prepare_head() $head[$h][2] = 'general'; $h++; - if (!empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { $head[$h] = array( 0 => DOL_URL_ROOT."/product/admin/price_rules.php", @@ -342,7 +342,7 @@ function product_lot_admin_prepare_head() */ function show_stats_for_company($product, $socid) { - global $conf,$langs,$user,$db; + global $conf, $langs, $user, $db; $nblines = 0; @@ -354,10 +354,10 @@ function show_stats_for_company($product, $socid) print '
        '; @@ -372,10 +372,10 @@ function show_stats_for_company($product, $socid) print '
        '; @@ -390,10 +390,10 @@ function show_stats_for_company($product, $socid) print '
        '; @@ -408,10 +408,10 @@ function show_stats_for_company($product, $socid) print '
        '; @@ -426,10 +426,10 @@ function show_stats_for_company($product, $socid) print '
        '; @@ -444,10 +444,10 @@ function show_stats_for_company($product, $socid) print '
        '; @@ -463,10 +463,10 @@ function show_stats_for_company($product, $socid) } // Contracts - if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $nblines++; - $ret=$product->load_stats_contrat($socid); + $ret = $product->load_stats_contrat($socid); if ($ret < 0) dol_print_error($db); $langs->load("contracts"); print '
        '; @@ -555,8 +555,8 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho */ function measuring_units_squared($unit) { - $measuring_units=array(); - $measuring_units[0] = 0; // m -> m3 + $measuring_units = array(); + $measuring_units[0] = 0; // m -> m3 $measuring_units[-1] = -2; // dm-> dm2 $measuring_units[-2] = -4; // cm -> cm2 $measuring_units[-3] = -6; // mm -> mm2 @@ -575,8 +575,8 @@ function measuring_units_squared($unit) */ function measuring_units_cubed($unit) { - $measuring_units=array(); - $measuring_units[0] = 0; // m -> m2 + $measuring_units = array(); + $measuring_units[0] = 0; // m -> m2 $measuring_units[-1] = -3; // dm-> dm3 $measuring_units[-2] = -6; // cm -> cm3 $measuring_units[-3] = -9; // mm -> mm3 diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 21df0301d49..0b0f57d9d91 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -259,13 +259,13 @@ function project_timesheet_prepare_head($mode, $fuser = null) $h = 0; - $param=''; - $param.=($mode?'&mode='.$mode:''); - if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id; + $param = ''; + $param .= ($mode ? '&mode='.$mode : ''); + if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id; if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) { - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerWeek"); $head[$h][2] = 'inputperweek'; $h++; @@ -273,7 +273,7 @@ function project_timesheet_prepare_head($mode, $fuser = null) if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) { - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerDay"); $head[$h][2] = 'inputperday'; $h++; @@ -353,10 +353,10 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t global $user, $bc, $langs, $conf, $db; global $projectstatic, $taskstatic; - $lastprojectid=0; + $lastprojectid = 0; - $projectsArrayId=explode(',', $projectsListId); - if ($filterprogresscalc!=='') { + $projectsArrayId = explode(',', $projectsListId); + if ($filterprogresscalc !== '') { foreach ($lines as $key=>$line) { if (!empty($line->planned_workload) && !empty($line->duration)) { $filterprogresscalc = str_replace(' = ', ' == ', $filterprogresscalc); @@ -393,26 +393,26 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines { // Show task line. - $showline=1; - $showlineingray=0; + $showline = 1; + $showlineingray = 0; // If there is filters to use if (is_array($taskrole)) { // If task not legitimate to show, search if a legitimate task exists later in tree - if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) + if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) { // So search if task has a subtask legitimate to show - $foundtaskforuserdeeper=0; + $foundtaskforuserdeeper = 0; searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole); //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'
        '; if ($foundtaskforuserdeeper > 0) { - $showlineingray=1; // We will show line but in gray + $showlineingray = 1; // We will show line but in gray } else { - $showline=0; // No reason to show line + $showline = 0; // No reason to show line } } } @@ -423,12 +423,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (empty($user->rights->projet->all->lire)) { // User is not allowed on this project and project is not public, so we hide line - if (! in_array($lines[$i]->fk_project, $projectsArrayId)) + if (!in_array($lines[$i]->fk_project, $projectsArrayId)) { // Note that having a user assigned to a task into a project user has no permission on, should not be possible // because assignement on task can be done only on contact of project. // If assignement was done and after, was removed from contact of project, then we can hide the line. - $showline=0; + $showline = 0; } } } @@ -466,14 +466,14 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Project ref print "
        "; //if ($showlineingray) print ''; - if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); + if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); else print $projectstatic->getNomUrl(1, 'nolink'); //if ($showlineingray) print ''; print "'; - $projectstatic->statut=$lines[$i]->projectstatus; + $projectstatic->statut = $lines[$i]->projectstatus; print $projectstatic->getLibStatut(2); print ""; if ($showlineingray) print ''; //else print ''; - for ($k = 0 ; $k < $level ; $k++) + for ($k = 0; $k < $level; $k++) { print '
        '; } @@ -518,15 +518,15 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); print '
        '; - $fullhour=convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); - $workingdelay=convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks + $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); + $workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks if ($lines[$i]->planned_workload != '') { print $fullhour; @@ -539,7 +539,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Time spent print ''; if ($showlineingray) print ''; - else print ''; + else print ''; if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); else print '--:--'; if ($showlineingray) print ''; @@ -600,20 +600,20 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Contacts of task - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { print ''; - foreach(array('internal','external') as $source) + foreach (array('internal', 'external') as $source) { $tab = $lines[$i]->liste_contact(-1, $source); - $num=count($tab); - if (!empty($num)){ - foreach ($tab as $contacttask){ + $num = count($tab); + if (!empty($num)) { + foreach ($tab as $contacttask) { //var_dump($contacttask); if ($source == 'internal') $c = new User($db); else $c = new Contact($db); $c->fetch($contacttask['id']); - print $c->getNomUrl(1) . ' (' . $contacttask['libelle'] . ')' . '
        '; + print $c->getNomUrl(1).' ('.$contacttask['libelle'].')'.'
        '; } } } @@ -628,7 +628,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print "
        '; - if ($projectidfortotallink > 0) print ''; + if ($projectidfortotallink > 0) print ''; print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); if ($projectidfortotallink > 0) print ''; print ''; print ''; - for ($k = 0 ; $k < $level ; $k++) print "   "; + for ($k = 0; $k < $level; $k++) print "   "; print $taskstatic->getNomUrl(1, 'withproject', 'time'); // Label task print '
        '; - for ($k = 0 ; $k < $level ; $k++) print "   "; + for ($k = 0; $k < $level; $k++) print "   "; print $taskstatic->label; //print "
        "; //for ($k = 0 ; $k < $level ; $k++) print "   "; @@ -1221,20 +1221,20 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr else print '--:--'; print "
        '; if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); @@ -1538,7 +1538,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ } // Thirdparty - if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) + if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { print ''; if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project'); @@ -1596,25 +1596,25 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ // Time spent by user print ''; - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); else print '--:--'; print "
        '; print $projectstatic->getNomUrl(1); - if (! in_array('projectlabel', $hiddenfields)) print '
        '.dol_trunc($objp->title, 24); + if (!in_array('projectlabel', $hiddenfields)) print '
        '.dol_trunc($objp->title, 24); print '
        '; if ($objp->fk_soc > 0) { - $thirdpartystatic->id=$objp->fk_soc; - $thirdpartystatic->ref=$objp->socname; - $thirdpartystatic->name=$objp->socname; + $thirdpartystatic->id = $objp->fk_soc; + $thirdpartystatic->ref = $objp->socname; + $thirdpartystatic->name = $objp->socname; print $thirdpartystatic->getNomUrl(1); } print ''; if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); @@ -1922,19 +1922,19 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks { print ''.$objp->nb.''.($plannedworkload?convertSecondToTime($plannedworkload):'').''.($plannedworkload ?convertSecondToTime($plannedworkload) : '').''; //print $objp->planned_workload.'-'.$objp->declared_progess_workload."
        "; - print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload, 0).'%':''); + print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : ''); print '
        '.$langs->trans("Total")."'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).''.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).''.$total_task.''.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').''.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload, 0).'%':'').''.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').''.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').'
        '; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
        '; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment")); + $tooltip .= $langs->trans("GenericMaskCodes5"); - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= '
        '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
        '; - $texte.= ''; + $texte .= ''.$langs->trans("Mask").':'; + $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte .= '  '; + $texte .= ''; + $texte .= ''; + $texte .= ''; return $texte; } @@ -96,17 +96,17 @@ class mod_expedition_ribera extends ModelNumRefExpedition */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $old_code_type=$mysoc->typent_code; - $mysoc->code_client='CCCCCCCCCC'; - $mysoc->typent_code='TTTTTTTTTT'; + $old_code_client = $mysoc->code_client; + $old_code_type = $mysoc->typent_code; + $mysoc->code_client = 'CCCCCCCCCC'; + $mysoc->typent_code = 'TTTTTTTTTT'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; - $mysoc->typent_code=$old_code_type; + $mysoc->code_client = $old_code_client; + $mysoc->typent_code = $old_code_type; - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -122,21 +122,21 @@ class mod_expedition_ribera extends ModelNumRefExpedition */ public function getNextValue($objsoc, $shipment) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $mask=$conf->global->EXPEDITION_RIBERA_MASK; + $mask = $conf->global->EXPEDITION_RIBERA_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } $date = $shipment->date_expedition; - $numFinal=get_next_value($db, $mask, 'expedition', 'ref', '', $objsoc, $date); + $numFinal = get_next_value($db, $mask, 'expedition', 'ref', '', $objsoc, $date); return $numFinal; } diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index f485a0c7c22..afbeec748ea 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -21,7 +21,7 @@ * \ingroup expedition * \brief File of class to manage shipments numbering rules Safor */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/expedition/modules_expedition.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; /** * Class to manage expedition numbering rules Safor @@ -34,24 +34,24 @@ class mod_expedition_safor extends ModelNumRefExpedition */ public $version = 'dolibarr'; - public $prefix='SH'; + public $prefix = 'SH'; /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string Nom du modele * @deprecated * @see $name */ - public $nom='Safor'; + public $nom = 'Safor'; /** * @var string model name */ - public $name='Safor'; + public $name = 'Safor'; /** @@ -84,26 +84,26 @@ class mod_expedition_safor extends ModelNumRefExpedition */ public function canBeActivated() { - global $conf,$langs,$db; + global $conf, $langs, $db; - $coyymm=''; $max=''; + $coyymm = ''; $max = ''; - $posindice=8; + $posindice = 8; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."expedition"; - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $row = $db->fetch_row($resql); - if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; } + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } } - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { $langs->load("errors"); - $this->error=$langs->trans('ErrorNumRefModel', $max); + $this->error = $langs->trans('ErrorNumRefModel', $max); return false; } @@ -119,20 +119,20 @@ class mod_expedition_safor extends ModelNumRefExpedition */ public function getNextValue($objsoc, $shipment) { - global $db,$conf; + global $db, $conf; - $posindice=8; + $posindice = 8; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."expedition"; - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj) $max = intval($obj->max); - else $max=0; + else $max = 0; } else { @@ -140,11 +140,11 @@ class mod_expedition_safor extends ModelNumRefExpedition return -1; } - $date=time(); + $date = time(); $yymm = strftime("%y%m", $date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s", $max+1); + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max + 1); dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 76564cffa84..a2cefcf9ff0 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -180,19 +180,19 @@ class pdf_standard extends ModeleExpenseReport // } if ($this->page_largeur < 210) // To work with US executive format { - $this->posxdate-=20; - $this->posxtype-=20; - $this->posxprojet-=20; - $this->posxtva-=20; - $this->posxup-=20; - $this->posxqty-=20; - $this->postotalttc-=20; + $this->posxdate -= 20; + $this->posxtype -= 20; + $this->posxprojet -= 20; + $this->posxtva -= 20; + $this->posxup -= 20; + $this->posxqty -= 20; + $this->postotalttc -= 20; } - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; } @@ -213,9 +213,9 @@ class pdf_standard extends ModeleExpenseReport // phpcs:enable global $user, $langs, $conf, $mysoc, $db, $hookmanager; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "trips", "projects", "dict", "bills", "banks")); @@ -226,20 +226,20 @@ class pdf_standard extends ModeleExpenseReport // Definition of $dir and $file if ($object->specimen) { $dir = $conf->expensereport->dir_output; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->expensereport->dir_output . "/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + $dir = $conf->expensereport->dir_output."/".$objectref; + $file = $dir."/".$objectref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -247,23 +247,23 @@ class pdf_standard extends ModeleExpenseReport if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Create pdf instance - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 40; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 40; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; $pdf->SetAutoPageBreak(1, 0); @@ -274,14 +274,14 @@ class pdf_standard extends ModeleExpenseReport } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -394,10 +394,10 @@ class pdf_standard extends ModeleExpenseReport } //nexY $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $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. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. //$nblineFollowComment = 1; // Search number of lines coming to know if there is enough room @@ -432,10 +432,10 @@ class pdf_standard extends ModeleExpenseReport $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -448,7 +448,7 @@ class pdf_standard extends ModeleExpenseReport $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -457,18 +457,18 @@ class pdf_standard extends ModeleExpenseReport // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } $pdf->SetFont('', '', 10); // Show total area box - $posy=$bottomlasttab+5; + $posy = $bottomlasttab + 5; $posy_start_of_totals = $posy; $pdf->SetXY(130, $posy); $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L'); @@ -479,7 +479,7 @@ class pdf_standard extends ModeleExpenseReport if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { // TODO Show vat amout per tax level - $posy+=5; + $posy += 5; $pdf->SetXY(130, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(70, 5, $outputlangs->transnoentities("TotalVAT"), 1, 'L'); @@ -487,7 +487,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 180, 5, price($object->total_tva), 1, 'R'); } - $posy+=5; + $posy += 5; $pdf->SetXY(130, $posy); $pdf->SetFont('', 'B', 10); $pdf->SetTextColor(0, 0, 60); @@ -498,7 +498,7 @@ class pdf_standard extends ModeleExpenseReport // show payments zone $sumPayments = $object->getSumPayments(); if ($sumPayments > 0 && empty($conf->global->PDF_EXPENSEREPORT_NO_PAYMENT_DETAILS)) { - $posy=$this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs); + $posy = $this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs); } // Page footer @@ -557,14 +557,14 @@ class pdf_standard extends ModeleExpenseReport // Accountancy piece $pdf->SetXY($this->posxpiece, $curY); - $pdf->writeHTMLCell($this->posxcomment-$this->posxpiece-0.8, 4, $this->posxpiece-1, $curY, $linenumber + 1, 0, 1); + $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1); // Date //$pdf->SetXY($this->posxdate -1, $curY); //$pdf->MultiCell($this->posxtype-$this->posxdate-0.8, 4, dol_print_date($object->lines[$linenumber]->date,"day",false,$outputlangs), 0, 'C'); // Type - $pdf->SetXY($this->posxtype -1, $curY); + $pdf->SetXY($this->posxtype - 1, $curY); $nextColumnPosX = $this->posxup; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $nextColumnPosX = $this->posxtva; @@ -649,15 +649,15 @@ class pdf_standard extends ModeleExpenseReport */ // Draft watermark - if ($object->fk_statut == 0 && ! empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { + if ($object->fk_statut == 0 && !empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK); } $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-100; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; $pdf->SetXY($this->marge_gauche, $posy); @@ -665,86 +665,86 @@ class pdf_standard extends ModeleExpenseReport $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size -2); + $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); } } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } $pdf->SetFont('', 'B', $default_font_size + 4); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 6, $langs->trans("ExpenseReport"), 0, 'R'); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $langs->trans("ExpenseReport"), 0, 'R'); - $pdf->SetFont('', '', $default_font_size -1); + $pdf->SetFont('', '', $default_font_size - 1); // Ref complete - $posy+=8; + $posy += 8; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R'); // Date start period - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?dol_print_date($object->date_debut, "day", false, $outputlangs):''), '', 'R'); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateStart")." : ".($object->date_debut > 0 ?dol_print_date($object->date_debut, "day", false, $outputlangs) : ''), '', 'R'); // Date end period - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin, "day", false, $outputlangs):''), '', 'R'); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateEnd")." : ".($object->date_fin > 0 ?dol_print_date($object->date_fin, "day", false, $outputlangs) : ''), '', 'R'); // Status Expense Report - $posy+=6; + $posy += 6; $pdf->SetXY($posx, $posy); $pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetTextColor(111, 81, 124); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R'); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $object->getLibStatut(0), '', 'R'); if ($showaddress) { // Sender properties $carac_emetteur = ''; - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($this->emetteur->address); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town); $carac_emetteur .= "\n"; - if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); - if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); - if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); - if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); + if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone); + if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '').$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax); + if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($this->emetteur->email); + if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Web")." : ".$outputlangs->convToOutputCharset($this->emetteur->url); // Receiver Properties - $receiver=new User($this->db); + $receiver = new User($this->db); $receiver->fetch($object->fk_user_author); - $receiver_account=new UserBankAccount($this->db); + $receiver_account = new UserBankAccount($this->db); $receiver_account->fetch(0, '', $object->fk_user_author); $expense_receiver = ''; - $expense_receiver .= ($expense_receiver ? "\n" : '' ).$outputlangs->convToOutputCharset($receiver->address); - $expense_receiver .= ($expense_receiver ? "\n" : '' ).$outputlangs->convToOutputCharset($receiver->zip).' '.$outputlangs->convToOutputCharset($receiver->town); + $expense_receiver .= ($expense_receiver ? "\n" : '').$outputlangs->convToOutputCharset($receiver->address); + $expense_receiver .= ($expense_receiver ? "\n" : '').$outputlangs->convToOutputCharset($receiver->zip).' '.$outputlangs->convToOutputCharset($receiver->town); $expense_receiver .= "\n"; - if ($receiver->email) $expense_receiver .= ($expense_receiver ? "\n" : '' ).$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($receiver->email); - if ($receiver_account->iban) $expense_receiver .= ($expense_receiver ? "\n" : '' ).$outputlangs->transnoentities("IBAN")." : ".$outputlangs->convToOutputCharset($receiver_account->iban); + if ($receiver->email) $expense_receiver .= ($expense_receiver ? "\n" : '').$outputlangs->transnoentities("Email")." : ".$outputlangs->convToOutputCharset($receiver->email); + if ($receiver_account->iban) $expense_receiver .= ($expense_receiver ? "\n" : '').$outputlangs->transnoentities("IBAN")." : ".$outputlangs->convToOutputCharset($receiver_account->iban); // Show sender - $posy=50; - $posx=$this->marge_gauche; - $hautcadre=40; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; + $posy = 50; + $posx = $this->marge_gauche; + $hautcadre = 40; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = 118; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("TripSociete")." :", '', 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(224, 224, 224); @@ -868,8 +868,8 @@ class pdf_standard extends ModeleExpenseReport global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -977,7 +977,7 @@ class pdf_standard extends ModeleExpenseReport { global $conf; - $sign=1; + $sign = 1; $tab3_posx = $this->marge_gauche; $tab3_top = $posy; $tab3_width = 88; diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php index bef9d206448..a2d4cbd9182 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php @@ -22,7 +22,7 @@ * \brief Fichier contenant la classe du modele de numerotation de reference de note de frais Sand */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/expensereport/modules_expensereport.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; /** @@ -34,7 +34,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error message @@ -46,12 +46,12 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport * @deprecated * @see $name */ - public $nom='Sand'; + public $nom = 'Sand'; /** * @var string model name */ - public $name='Sand'; + public $name = 'Sand'; /** @@ -68,28 +68,28 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
        \n"; - $texte.= '
        '; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
        '; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport")); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport")); //$tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("ExpenseReport"), $langs->transnoentities("ExpenseReport")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
        '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
        '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
        '; - $texte.= '
        '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -101,15 +101,15 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport */ public function getExample() { - global $db, $conf,$langs,$user; + global $db, $conf, $langs, $user; - $exp=new ExpenseReport($db); + $exp = new ExpenseReport($db); $exp->initAsSpecimen(); $exp->fk_user_author = $user->id; $numExample = $this->getNextValue($exp); - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -124,20 +124,20 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport */ public function getNextValue($object) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // We get cursor rule - $mask=$conf->global->EXPENSEREPORT_SAND_MASK; + $mask = $conf->global->EXPENSEREPORT_SAND_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } - $date=$object->date_valid; // $object->date does not exists + $date = $object->date_valid; // $object->date does not exists if (empty($date)) { $this->error = 'Date valid not defined'; @@ -147,11 +147,11 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport $fuser = null; if ($object->fk_user_author > 0) { - $fuser=new User($db); + $fuser = new User($db); $fuser->fetch($object->fk_user_author); } - $numFinal=get_next_value($db, $mask, 'expensereport', 'ref', '', null, $date, 'next', true, $fuser); + $numFinal = get_next_value($db, $mask, 'expensereport', 'ref', '', null, $date, 'next', true, $fuser); return $numFinal; } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 8ee898b5a4e..e072b90e7b4 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -288,19 +288,19 @@ class pdf_crabe extends ModelePDFFactures if ($object->specimen) { $dir = $conf->facture->dir_output; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->facture->dir_output . "/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + $dir = $conf->facture->dir_output."/".$objectref; + $file = $dir."/".$objectref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -396,16 +396,16 @@ class pdf_crabe extends ModelePDFFactures // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90+$top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); + $tab_top = 90 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); // Incoterm if ($conf->incoterm->enabled) @@ -678,10 +678,10 @@ class pdf_crabe extends ModelePDFFactures $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -694,7 +694,7 @@ class pdf_crabe extends ModelePDFFactures $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -734,31 +734,31 @@ class pdf_crabe extends ModelePDFFactures // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR"); + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR"); return 0; } } @@ -781,8 +781,8 @@ class pdf_crabe extends ModelePDFFactures // phpcs:enable global $conf; - $sign=1; - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; $current_page = $pdf->getPage(); $tab3_posx = 120; @@ -798,115 +798,115 @@ class pdf_crabe extends ModelePDFFactures $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height); - $y=0; + $y = 0; $pdf->SetFont('', '', $default_font_size - 4); // Loop on each discount available (deposits and credit notes and excess of payment included) $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,"; - $sql.= " re.description, re.fk_facture_source,"; - $sql.= " f.type, f.datef"; - $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f"; - $sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id; - $resql=$this->db->query($sql); + $sql .= " re.description, re.fk_facture_source,"; + $sql .= " f.type, f.datef"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id; + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i=0; - $invoice=new Facture($this->db); + $i = 0; + $invoice = new Facture($this->db); while ($i < $num) { - $y+=3; - if ($tab3_top+$y >= ($this->page_hauteur - $heightforfooter)) + $y += 3; + if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) { - $y=0; + $y = 0; $current_page++; $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + 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); + $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"); - elseif ($obj->type == 3) $text=$outputlangs->transnoentities("Deposit"); - elseif ($obj->type == 0) $text=$outputlangs->transnoentities("ExcessReceived"); - else $text=$outputlangs->transnoentities("UnknownType"); + if ($obj->type == 2) $text = $outputlangs->transnoentities("CreditNote"); + elseif ($obj->type == 3) $text = $outputlangs->transnoentities("Deposit"); + elseif ($obj->type == 0) $text = $outputlangs->transnoentities("ExcessReceived"); + else $text = $outputlangs->transnoentities("UnknownType"); $invoice->fetch($obj->fk_facture_source); - $pdf->SetXY($tab3_posx, $tab3_top+$y); + $pdf->SetXY($tab3_posx, $tab3_top + $y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($obj->datef), 'day', false, $outputlangs, true), 0, 'L', 0); - $pdf->SetXY($tab3_posx+21, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 21, $tab3_top + $y); $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); - $pdf->SetXY($tab3_posx+40, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 40, $tab3_top + $y); $pdf->MultiCell(20, 3, $text, 0, 'L', 0); - $pdf->SetXY($tab3_posx+58, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 58, $tab3_top + $y); $pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0); - $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3); + $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3); $i++; } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } // Loop on each payment // TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; - $sql.= " cp.code"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; - $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; + $sql .= " cp.code"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; + $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; //$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1"; - $sql.= " ORDER BY p.datep"; + $sql .= " ORDER BY p.datep"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { - $y+=3; - if ($tab3_top+$y >= ($this->page_hauteur - $heightforfooter)) + $y += 3; + if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) { - $y=0; + $y = 0; $current_page++; $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + 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); + $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); + $pdf->SetXY($tab3_posx, $tab3_top + $y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0); - $pdf->SetXY($tab3_posx+21, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 21, $tab3_top + $y); $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0); - $pdf->SetXY($tab3_posx+40, $tab3_top+$y); - $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); + $pdf->SetXY($tab3_posx + 40, $tab3_top + $y); + $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code); $pdf->MultiCell(20, 3, $oper, 0, 'L', 0); - $pdf->SetXY($tab3_posx+58, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 58, $tab3_top + $y); $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0); - $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3); + $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3); $i++; } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -929,26 +929,26 @@ class pdf_crabe extends ModelePDFFactures protected function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height) { // phpcs:enable - $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); - if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); + $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->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->SetXY($tab3_posx + 21, $tab3_top); $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+40, $tab3_top); + $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->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); + $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -978,10 +978,10 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - $posy=$pdf->GetY()+4; + $posy = $pdf->GetY() + 4; } - $posxval=52; + $posxval = 52; // Show payments conditions if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) @@ -993,11 +993,11 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); - $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L'); - $posy=$pdf->GetY()+3; + $posy = $pdf->GetY() + 3; } if ($object->type != 2) @@ -1022,7 +1022,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell(80, 3, $this->error, 0, 'L', 0); $pdf->SetTextColor(0, 0, 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; } // Show payment mode @@ -1059,14 +1059,14 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } if ($conf->global->FACTURE_CHQ_NUMBER == -1) @@ -1074,14 +1074,14 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } } @@ -1090,19 +1090,19 @@ class pdf_crabe extends ModelePDFFactures // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { - if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) + if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) { - $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account); - if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank + $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); + if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank $account = new Account($this->db); $account->fetch($bankid); - $curx=$this->marge_gauche; - $cury=$posy; + $curx = $this->marge_gauche; + $cury = $posy; - $posy=pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); + $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); - $posy+=2; + $posy += 2; } } } @@ -1126,10 +1126,10 @@ class pdf_crabe extends ModelePDFFactures protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; - $sign=1; - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1141,32 +1141,32 @@ class pdf_crabe extends ModelePDFFactures $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { - $col2x-=20; + $col2x -= 20; } $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - $useborder=0; + $useborder = 0; $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248, 248, 248); $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; - $this->atleastoneratenotnull=0; + $this->atleastoneratenotnull = 0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) + $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) { // Nothing to do } @@ -1253,15 +1253,15 @@ class pdf_crabe extends ModelePDFFactures $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat.=vatrate($tvakey, 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat .= vatrate($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); @@ -1335,7 +1335,7 @@ class pdf_crabe extends ModelePDFFactures { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1); @@ -1346,7 +1346,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); @@ -1419,7 +1419,7 @@ class pdf_crabe extends ModelePDFFactures $labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes"); $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $labeltouse, 0, 'L', 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0); } @@ -1431,18 +1431,18 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1); - $resteapayer=0; + $resteapayer = 0; } $index++; $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); @@ -1473,8 +1473,8 @@ class pdf_crabe extends ModelePDFFactures global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1571,7 +1571,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->postotalht-1, $tab_top+1); + $pdf->SetXY($this->postotalht - 1, $tab_top + 1); $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); } } @@ -1598,7 +1598,7 @@ class pdf_crabe extends ModelePDFFactures pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==Facture::STATUS_DRAFT && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) ) + if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK); } @@ -1634,7 +1634,7 @@ class pdf_crabe extends ModelePDFFactures } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } @@ -1642,115 +1642,115 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("PdfInvoiceTitle"); - if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement"); - if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir"); - if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit"); - if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProForma"); - if ($this->situationinvoice) $title=$outputlangs->transnoentities("InvoiceSituation"); + $title = $outputlangs->transnoentities("PdfInvoiceTitle"); + if ($object->type == 1) $title = $outputlangs->transnoentities("InvoiceReplacement"); + if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir"); + if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit"); + if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma"); + if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation"); $pdf->MultiCell($w, 3, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $textref=$outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref); + $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref); if ($object->statut == Facture::STATUS_DRAFT) { $pdf->SetTextColor(128, 0, 0); - $textref.=' - '.$outputlangs->transnoentities("NotValidated"); + $textref .= ' - '.$outputlangs->transnoentities("NotValidated"); } $pdf->MultiCell($w, 4, $textref, '', 'R'); - $posy+=1; + $posy += 1; $pdf->SetFont('', '', $default_font_size - 2); if ($object->ref_client) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - $objectidnext=$object->getIdReplacingInvoice('validated'); + $objectidnext = $object->getIdReplacingInvoice('validated'); if ($object->type == 0 && $objectidnext) { - $objectreplacing=new Facture($this->db); + $objectreplacing = new Facture($this->db); $objectreplacing->fetch($objectidnext); - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R'); } if ($object->type == 1) { - $objectreplaced=new Facture($this->db); + $objectreplaced = new Facture($this->db); $objectreplaced->fetch($object->fk_facture_source); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); } if ($object->type == 2 && !empty($object->fk_facture_source)) { - $objectreplaced=new Facture($this->db); + $objectreplaced = new Facture($this->db); $objectreplaced->fetch($object->fk_facture_source); - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); } - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice")." : " . dol_print_date($object->date, "day", false, $outputlangs), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice")." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R'); - if (! empty($conf->global->INVOICE_POINTOFTAX_DATE)) + if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : " . dol_print_date($object->date_pointoftax, "day", false, $outputlangs), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : ".dol_print_date($object->date_pointoftax, "day", false, $outputlangs), '', 'R'); } if ($object->type != 2) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateDue")." : " . dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateDue")." : ".dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R'); } if ($object->thirdparty->code_client) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } // Get contact if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { - $usertmp=new User($this->db); + $usertmp = new User($this->db); $usertmp->fetch($arrayidcontact[0]); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - $posy+=1; + $posy += 1; $top_shift = 0; // Show list of linked objects @@ -1767,19 +1767,19 @@ class pdf_crabe extends ModelePDFFactures $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posy+=$top_shift; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy += $top_shift; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; - $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; + $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -1787,25 +1787,25 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0, 0, 60); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L'); + $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L'); // If BILLING contact defined on invoice, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'BILLING'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'BILLING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -1816,27 +1816,27 @@ class pdf_crabe extends ModelePDFFactures $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posy+=$top_shift; - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy += $top_shift; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); @@ -1844,7 +1844,7 @@ class pdf_crabe extends ModelePDFFactures // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } @@ -1865,7 +1865,7 @@ class pdf_crabe extends ModelePDFFactures protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 07ed5f5783c..b6a5c0297d0 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -139,7 +139,7 @@ class pdf_sponge extends ModelePDFFactures */ public function __construct($db) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Translations $langs->loadLangs(array("main", "bills")); @@ -262,16 +262,16 @@ class pdf_sponge extends ModelePDFFactures { if ($obj['photo_vignette']) { - $filename= $obj['photo_vignette']; + $filename = $obj['photo_vignette']; } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } $realpath = $dir.$filename; @@ -281,7 +281,7 @@ class pdf_sponge extends ModelePDFFactures } } - if ($realpath && $arephoto) $realpatharray[$i]=$realpath; + if ($realpath && $arephoto) $realpatharray[$i] = $realpath; } } @@ -299,19 +299,19 @@ class pdf_sponge extends ModelePDFFactures if ($object->specimen) { $dir = $conf->facture->dir_output; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->facture->dir_output . "/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + $dir = $conf->facture->dir_output."/".$objectref; + $file = $dir."/".$objectref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -386,17 +386,17 @@ class pdf_sponge extends ModelePDFFactures // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90+$top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); - $tab_height = 130-$top_shift; + $tab_top = 90 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + $tab_height = 130 - $top_shift; $tab_height_newpage = 150; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift; @@ -442,10 +442,10 @@ class pdf_sponge extends ModelePDFFactures { $tab_top -= 2; - $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite; + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; $pageposbeforenote = $pagenb; - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); @@ -453,12 +453,12 @@ class pdf_sponge extends ModelePDFFactures $pdf->startTransaction(); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); // Description - $pageposafternote=$pdf->getPage(); + $pageposafternote = $pdf->getPage(); $posyafter = $pdf->GetY(); - if($pageposafternote>$pageposbeforenote ) + if ($pageposafternote > $pageposbeforenote) { $pdf->rollbackTransaction(true); @@ -466,7 +466,7 @@ class pdf_sponge extends ModelePDFFactures while ($pagenb < $pageposafternote) { $pdf->AddPage(); $pagenb++; - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); // $this->_pagefoot($pdf,$object,$outputlangs,1); $pdf->setTopMargin($tab_top_newpage); @@ -478,12 +478,12 @@ class pdf_sponge extends ModelePDFFactures $pdf->setPage($pageposbeforenote); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); - $pageposafternote=$pdf->getPage(); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pageposafternote = $pdf->getPage(); $posyafter = $pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text { $pdf->AddPage('', '', true); $pagenb++; @@ -504,17 +504,17 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetDrawColor(128, 128, 128); // Draw note frame - if($i>$pageposbeforenote){ + if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1); + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); } - else{ + else { $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); } // Add footer - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $this->_pagefoot($pdf, $object, $outputlangs, 1); $i++; @@ -522,27 +522,27 @@ class pdf_sponge extends ModelePDFFactures // apply note frame to last page $pdf->setPage($pageposafternote); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $height_note=$posyafter-$tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1); + $height_note = $posyafter - $tab_top_newpage; + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); } else // No pagebreak { $pdf->commitTransaction(); $posyafter = $pdf->GetY(); - $height_note=$posyafter-$tab_top; - $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1); + $height_note = $posyafter - $tab_top; + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); - if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) ) + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // not enough space, need to add page $pdf->AddPage('', '', true); $pagenb++; $pageposafternote++; $pdf->setPage($pageposafternote); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $posyafter = $tab_top_newpage; @@ -550,11 +550,11 @@ class pdf_sponge extends ModelePDFFactures } $tab_height = $tab_height - $height_note; - $tab_top = $posyafter +6; + $tab_top = $posyafter + 6; } else { - $height_note=0; + $height_note = 0; } // Use new auto column system @@ -720,7 +720,7 @@ class pdf_sponge extends ModelePDFFactures } - $parameters=array( + $parameters = array( 'object' => $object, 'i' => $i, 'pdf' =>& $pdf, @@ -729,12 +729,12 @@ class pdf_sponge extends ModelePDFFactures 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails ); - $reshook=$hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $prev_progress = $object->lines[$i]->get_prev_progress($object->id); if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation @@ -861,31 +861,31 @@ class pdf_sponge extends ModelePDFFactures // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR"); + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR"); return 0; } } @@ -904,8 +904,8 @@ class pdf_sponge extends ModelePDFFactures { global $conf; - $sign=1; - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; $tab3_posx = 120; $tab3_top = $posy + 8; @@ -918,113 +918,113 @@ class pdf_sponge extends ModelePDFFactures $default_font_size = pdf_getPDFFontSize($outputlangs); - $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); - if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); + $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->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->SetXY($tab3_posx + 21, $tab3_top); $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+40, $tab3_top); + $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->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); + $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height); - $y=0; + $y = 0; $pdf->SetFont('', '', $default_font_size - 4); // Loop on each deposits and credit notes included $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,"; - $sql.= " re.description, re.fk_facture_source,"; - $sql.= " f.type, f.datef"; - $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f"; - $sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id; - $resql=$this->db->query($sql); + $sql .= " re.description, re.fk_facture_source,"; + $sql .= " f.type, f.datef"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id; + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i=0; - $invoice=new Facture($this->db); + $i = 0; + $invoice = new Facture($this->db); while ($i < $num) { - $y+=3; + $y += 3; $obj = $this->db->fetch_object($resql); - if ($obj->type == 2) $text=$outputlangs->trans("CreditNote"); - elseif ($obj->type == 3) $text=$outputlangs->trans("Deposit"); - else $text=$outputlangs->trans("UnknownType"); + if ($obj->type == 2) $text = $outputlangs->trans("CreditNote"); + elseif ($obj->type == 3) $text = $outputlangs->trans("Deposit"); + else $text = $outputlangs->trans("UnknownType"); $invoice->fetch($obj->fk_facture_source); - $pdf->SetXY($tab3_posx, $tab3_top+$y); + $pdf->SetXY($tab3_posx, $tab3_top + $y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($obj->datef), 'day', false, $outputlangs, true), 0, 'L', 0); - $pdf->SetXY($tab3_posx+21, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 21, $tab3_top + $y); $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); - $pdf->SetXY($tab3_posx+40, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 40, $tab3_top + $y); $pdf->MultiCell(20, 3, $text, 0, 'L', 0); - $pdf->SetXY($tab3_posx+58, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 58, $tab3_top + $y); $pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0); - $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3); + $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3); $i++; } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } // Loop on each payment // TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; - $sql.= " cp.code"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; - $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; + $sql .= " cp.code"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; + $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; //$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1"; - $sql.= " ORDER BY p.datep"; + $sql .= " ORDER BY p.datep"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { - $y+=3; + $y += 3; $row = $this->db->fetch_object($resql); - $pdf->SetXY($tab3_posx, $tab3_top+$y); + $pdf->SetXY($tab3_posx, $tab3_top + $y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0); - $pdf->SetXY($tab3_posx+21, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 21, $tab3_top + $y); $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0); - $pdf->SetXY($tab3_posx+40, $tab3_top+$y); - $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); + $pdf->SetXY($tab3_posx + 40, $tab3_top + $y); + $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code); $pdf->MultiCell(20, 3, $oper, 0, 'L', 0); - $pdf->SetXY($tab3_posx+58, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 58, $tab3_top + $y); $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0); - $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3); + $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3); $i++; } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1054,10 +1054,10 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - $posy=$pdf->GetY()+4; + $posy = $pdf->GetY() + 4; } - $posxval=52; + $posxval = 52; // Show payments conditions if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) @@ -1069,11 +1069,11 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); - $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L'); - $posy=$pdf->GetY()+3; + $posy = $pdf->GetY() + 3; } if ($object->type != 2) @@ -1098,7 +1098,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->MultiCell(80, 3, $this->error, 0, 'L', 0); $pdf->SetTextColor(0, 0, 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; } // Show payment mode @@ -1135,14 +1135,14 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } if ($conf->global->FACTURE_CHQ_NUMBER == -1) @@ -1150,14 +1150,14 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } } @@ -1166,19 +1166,19 @@ class pdf_sponge extends ModelePDFFactures // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { - if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) + if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) { - $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account); - if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank + $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); + if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank $account = new Account($this->db); $account->fetch($bankid); - $curx=$this->marge_gauche; - $cury=$posy; + $curx = $this->marge_gauche; + $cury = $posy; - $posy=pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); + $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); - $posy+=2; + $posy += 2; } } } @@ -1199,10 +1199,10 @@ class pdf_sponge extends ModelePDFFactures */ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs) { - global $conf,$mysoc; + global $conf, $mysoc; - $sign=1; - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1500,15 +1500,15 @@ class pdf_sponge extends ModelePDFFactures $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat.=vatrate($tvakey, 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat .= vatrate($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); @@ -1587,7 +1587,7 @@ class pdf_sponge extends ModelePDFFactures { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1); @@ -1598,7 +1598,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); @@ -1690,7 +1690,7 @@ class pdf_sponge extends ModelePDFFactures { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0); } @@ -1702,18 +1702,18 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1); - $resteapayer=0; + $resteapayer = 0; } $index++; $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); @@ -1758,8 +1758,8 @@ class pdf_sponge extends ModelePDFFactures global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1814,7 +1814,7 @@ class pdf_sponge extends ModelePDFFactures pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==Facture::STATUS_DRAFT && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) ) + if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK); } @@ -1850,7 +1850,7 @@ class pdf_sponge extends ModelePDFFactures } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } @@ -1858,115 +1858,115 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("PdfInvoiceTitle"); - if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement"); - if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir"); - if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit"); - if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProForma"); - if ($this->situationinvoice) $title=$outputlangs->transnoentities("InvoiceSituation"); + $title = $outputlangs->transnoentities("PdfInvoiceTitle"); + if ($object->type == 1) $title = $outputlangs->transnoentities("InvoiceReplacement"); + if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir"); + if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit"); + if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma"); + if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation"); $pdf->MultiCell($w, 3, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $textref=$outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref); + $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref); if ($object->statut == Facture::STATUS_DRAFT) { $pdf->SetTextColor(128, 0, 0); - $textref.=' - '.$outputlangs->transnoentities("NotValidated"); + $textref .= ' - '.$outputlangs->transnoentities("NotValidated"); } $pdf->MultiCell($w, 4, $textref, '', 'R'); - $posy+=1; + $posy += 1; $pdf->SetFont('', '', $default_font_size - 2); if ($object->ref_client) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - $objectidnext=$object->getIdReplacingInvoice('validated'); + $objectidnext = $object->getIdReplacingInvoice('validated'); if ($object->type == 0 && $objectidnext) { - $objectreplacing=new Facture($this->db); + $objectreplacing = new Facture($this->db); $objectreplacing->fetch($objectidnext); - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R'); } if ($object->type == 1) { - $objectreplaced=new Facture($this->db); + $objectreplaced = new Facture($this->db); $objectreplaced->fetch($object->fk_facture_source); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); } if ($object->type == 2 && !empty($object->fk_facture_source)) { - $objectreplaced=new Facture($this->db); + $objectreplaced = new Facture($this->db); $objectreplaced->fetch($object->fk_facture_source); - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); } - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice")." : " . dol_print_date($object->date, "day", false, $outputlangs), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice")." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R'); - if (! empty($conf->global->INVOICE_POINTOFTAX_DATE)) + if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : " . dol_print_date($object->date_pointoftax, "day", false, $outputlangs), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : ".dol_print_date($object->date_pointoftax, "day", false, $outputlangs), '', 'R'); } if ($object->type != 2) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateDue")." : " . dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateDue")." : ".dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R'); } if ($object->thirdparty->code_client) { - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } // Get contact if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { - $usertmp=new User($this->db); + $usertmp = new User($this->db); $usertmp->fetch($arrayidcontact[0]); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - $posy+=1; + $posy += 1; $top_shift = 0; // Show list of linked objects @@ -1983,19 +1983,19 @@ class pdf_sponge extends ModelePDFFactures $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posy+=$top_shift; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy += $top_shift; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; - $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; + $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -2003,23 +2003,23 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetTextColor(0, 0, 60); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L'); + $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L'); // If BILLING contact defined on invoice, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'BILLING'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'BILLING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -2030,27 +2030,27 @@ class pdf_sponge extends ModelePDFFactures $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posy+=$top_shift; - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy += $top_shift; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); @@ -2058,7 +2058,7 @@ class pdf_sponge extends ModelePDFFactures // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } @@ -2079,7 +2079,7 @@ class pdf_sponge extends ModelePDFFactures protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } @@ -2100,13 +2100,13 @@ class pdf_sponge extends ModelePDFFactures // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content $this->defaultTitlesFieldsStyle = array( 'align' => 'C', // R,C,L - 'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); /* @@ -2127,7 +2127,7 @@ class pdf_sponge extends ModelePDFFactures ); */ - $rank=0; // do not use negative rank + $rank = 0; // do not use negative rank $this->cols['desc'] = array( 'rank' => $rank, 'width' => false, // only for desc @@ -2137,7 +2137,7 @@ class pdf_sponge extends ModelePDFFactures 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', @@ -2148,19 +2148,19 @@ class pdf_sponge extends ModelePDFFactures $rank = $rank + 10; $this->cols['photo'] = array( 'rank' => $rank, - 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm + 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm 'status' => false, 'title' => array( 'textkey' => 'Photo', 'label' => ' ' ), 'content' => array( - 'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'border-left' => false, // remove left line separator ); - if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto)) + if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; } @@ -2215,7 +2215,7 @@ class pdf_sponge extends ModelePDFFactures 'border-left' => true, // add left line separator ); - if($this->situationinvoice) + if ($this->situationinvoice) { $this->cols['progress']['status'] = true; } @@ -2230,7 +2230,7 @@ class pdf_sponge extends ModelePDFFactures ), 'border-left' => true, // add left line separator ); - if($conf->global->PRODUCT_USE_UNITS){ + if ($conf->global->PRODUCT_USE_UNITS) { $this->cols['unit']['status'] = true; } @@ -2244,7 +2244,7 @@ class pdf_sponge extends ModelePDFFactures ), 'border-left' => true, // add left line separator ); - if ($this->atleastonediscount){ + if ($this->atleastonediscount) { $this->cols['discount']['status'] = true; } @@ -2260,7 +2260,7 @@ class pdf_sponge extends ModelePDFFactures ); - $parameters=array( + $parameters = array( 'object' => $object, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, @@ -2268,7 +2268,7 @@ class pdf_sponge extends ModelePDFFactures 'hideref' => $hideref ); - $reshook=$hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook + $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); diff --git a/htdocs/core/modules/livraison/mod_livraison_jade.php b/htdocs/core/modules/livraison/mod_livraison_jade.php index e7d84e4b25d..9bc56842fdd 100644 --- a/htdocs/core/modules/livraison/mod_livraison_jade.php +++ b/htdocs/core/modules/livraison/mod_livraison_jade.php @@ -24,7 +24,7 @@ * \brief Fichier contenant la classe du modele de numerotation de reference de bon de livraison Jade */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/livraison/modules_livraison.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php'; /** @@ -38,7 +38,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error message @@ -50,14 +50,14 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder * @deprecated * @see $name */ - public $nom='Jade'; + public $nom = 'Jade'; /** * @var string model name */ - public $name='Jade'; + public $name = 'Jade'; - public $prefix='BL'; + public $prefix = 'BL'; /** @@ -89,29 +89,29 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder */ public function canBeActivated() { - global $langs,$conf,$db; + global $langs, $conf, $db; $langs->load("bills"); // Check invoice num - $fayymm=''; $max=''; + $fayymm = ''; $max = ''; - $posindice=8; - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL - $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $posindice = 8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL + $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $row = $db->fetch_row($resql); - if ($row) { $fayymm = substr($row[0], 0, 6); $max=$row[0]; } + if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; } } - if ($fayymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm)) + if ($fayymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm)) { $langs->load("errors"); - $this->error=$langs->trans('ErrorNumRefModel', $max); + $this->error = $langs->trans('ErrorNumRefModel', $max); return false; } @@ -127,33 +127,33 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder */ public function getNextValue($objsoc, $object) { - global $db,$conf; + global $db, $conf; // D'abord on recupere la valeur max - $posindice=8; - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL - $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $posindice = 8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL + $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$db->query($sql); + $resql = $db->query($sql); dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG); if ($resql) { $obj = $db->fetch_object($resql); if ($obj) $max = intval($obj->max); - else $max=0; + else $max = 0; } else { return -1; } - $date=$object->date_delivery; - if (empty($date)) $date=dol_now(); + $date = $object->date_delivery; + if (empty($date)) $date = dol_now(); $yymm = strftime("%y%m", $date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s", $max+1); + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max + 1); dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/modules/livraison/mod_livraison_saphir.php b/htdocs/core/modules/livraison/mod_livraison_saphir.php index f5d05d45adb..286a5e7c52c 100644 --- a/htdocs/core/modules/livraison/mod_livraison_saphir.php +++ b/htdocs/core/modules/livraison/mod_livraison_saphir.php @@ -23,7 +23,7 @@ * \ingroup expedition * \brief Fichier contenant la classe du modele de numerotation de reference de livraison Saphir */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/livraison/modules_livraison.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php'; /** * \class mod_livraison_saphir @@ -35,7 +35,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error message @@ -47,12 +47,12 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * @deprecated * @see $name */ - public $nom='Saphir'; + public $nom = 'Saphir'; /** * @var string model name */ - public $name='Saphir'; + public $name = 'Saphir'; /** @@ -69,28 +69,28 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
        \n"; - $texte.= '
        '; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
        '; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Delivery"), $langs->transnoentities("Delivery")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Delivery"), $langs->transnoentities("Delivery")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Delivery"), $langs->transnoentities("Delivery")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Delivery"), $langs->transnoentities("Delivery")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
        '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
        '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
        '; - $texte.= '
        '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -102,14 +102,14 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $mysoc->code_client='CCCCCCCCCC'; + $old_code_client = $mysoc->code_client; + $mysoc->code_client = 'CCCCCCCCCC'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; + $mysoc->code_client = $old_code_client; - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -126,20 +126,20 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder */ public function getNextValue($objsoc, $object) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // On defini critere recherche compteur - $mask=$conf->global->LIVRAISON_SAPHIR_MASK; + $mask = $conf->global->LIVRAISON_SAPHIR_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } - $numFinal=get_next_value($db, $mask, 'livraison', 'ref', '', $objsoc, $object->date_livraison); + $numFinal = get_next_value($db, $mask, 'livraison', 'ref', '', $objsoc, $object->date_livraison); return $numFinal; } diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 9997e68ca14..70b461d6048 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -25,7 +25,7 @@ * \ingroup Double entry accounting * \brief Module to activate the double entry accounting module */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** * Description and activation class for module accounting expert @@ -53,7 +53,7 @@ class modAccounting extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version $this->version = 'dolibarr'; - $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto = 'accounting'; // Data directories to create when module is enabled @@ -63,12 +63,12 @@ class modAccounting extends DolibarrModules $this->config_page_url = array(); // Dependencies - $this->depends = array("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled + $this->depends = array("modFacture", "modBanque", "modTax"); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array("modComptabilite"); // List of modules are in conflict with this module $this->phpmin = array(5, 4); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3, 9); // Minimum version of Dolibarr required by module - $this->langfiles = array("accountancy","compta"); + $this->langfiles = array("accountancy", "compta"); // Constants // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) @@ -136,7 +136,7 @@ class modAccounting extends DolibarrModules "1", "", 0, 'current', 0 ); - $this->const[11] = array ( + $this->const[11] = array( "ACCOUNTING_EXPORT_DATE", "chaine", "%d%m%Y", diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index ad6a7d95ce8..58681006082 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -29,7 +29,7 @@ * \ingroup member * \brief File descriptor or module Member */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** * Class to describe and enable module Adherent @@ -57,7 +57,7 @@ class modAdherent extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto='user'; + $this->picto = 'user'; // Data directories to create when module is enabled $this->dirs = array("/adherent/temp"); @@ -66,16 +66,16 @@ class modAdherent extends DolibarrModules $this->config_page_url = array("adherent.php@adherents"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with - $this->langfiles = array("members","companies"); - $this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with + $this->langfiles = array("members", "companies"); + $this->phpmin = array(5, 4); // Minimum version of PHP required by module // Constants $this->const = array(); - $r=0; + $r = 0; $this->const[$r][0] = "ADHERENT_ADDON_PDF"; $this->const[$r][1] = "chaine"; @@ -253,12 +253,12 @@ class modAdherent extends DolibarrModules // Menus //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports //-------- - $r=0; + $r = 0; // $this->export_code[$r] Unique code identifying the export (all modules combined) // $this->export_label[$r] Libelle by default if translation of key "ExportXXX" not found (XXX = Code) @@ -384,7 +384,7 @@ class modAdherent extends DolibarrModules */ public function init($options = '') { - global $conf,$langs; + global $conf, $langs; // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index 082512627a0..ec611e22c9d 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -24,7 +24,7 @@ * \ingroup asset * \brief Description and activation file for module Assets */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -69,7 +69,7 @@ class modAsset extends DolibarrModules // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='generic'; + $this->picto = 'generic'; // Defined all module parts (triggers, login, substitutions, menus, css, etc...) // for default path (eg: /asset/core/xxxxx) (0=disable, 1=enable) @@ -85,15 +85,15 @@ class modAsset extends DolibarrModules $this->config_page_url = array("setup.php@asset"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->langfiles = array("assets"); - $this->phpmin = array(5,4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(7,0); // Minimum version of Dolibarr required by module - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->phpmin = array(5, 4); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(7, 0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) //$this->automatic_activation = array('FR'=>'AssetsWasAutomaticallyActivatedBecauseOfYourCountryChoice'); //$this->always_enabled = true; // If true, can't be disabled @@ -107,10 +107,10 @@ class modAsset extends DolibarrModules ); - if (! isset($conf->asset) || ! isset($conf->asset->enabled)) + if (!isset($conf->asset) || !isset($conf->asset->enabled)) { - $conf->asset=new stdClass(); - $conf->asset->enabled=0; + $conf->asset = new stdClass(); + $conf->asset->enabled = 0; } diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index b6a9f968a02..1846169dafd 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -29,7 +29,7 @@ * \ingroup produit * \brief File to describe module to manage catalog of predefined products */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -59,25 +59,25 @@ class modProduct extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto='product'; + $this->picto = 'product'; // Data directories to create when module is enabled $this->dirs = array("/product/temp"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array("modStock","modBarcode","modProductBatch","modVariants"); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with - $this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants"); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5, 4); // Minimum version of PHP required by module // Config pages $this->config_page_url = array("product.php@product"); - $this->langfiles = array("products","companies","stocks","bills"); + $this->langfiles = array("products", "companies", "stocks", "bills"); // Constants $this->const = array(); - $r=0; + $r = 0; $this->const[$r][0] = "PRODUCT_CODEPRODUCT_ADDON"; $this->const[$r][1] = "chaine"; @@ -102,15 +102,15 @@ class modProduct extends DolibarrModules // Boxes $this->boxes = array( - 0=>array('file'=>'box_produits.php','enabledbydefaulton'=>'Home'), - 1=>array('file'=>'box_produits_alerte_stock.php','enabledbydefaulton'=>''), - 2=>array('file'=>'box_graph_product_distribution.php','enabledbydefaulton'=>'Home') + 0=>array('file'=>'box_produits.php', 'enabledbydefaulton'=>'Home'), + 1=>array('file'=>'box_produits_alerte_stock.php', 'enabledbydefaulton'=>''), + 2=>array('file'=>'box_graph_product_distribution.php', 'enabledbydefaulton'=>'Home') ); // Permissions $this->rights = array(); $this->rights_class = 'produit'; - $r=0; + $r = 0; $this->rights[$r][0] = 31; // id de la permission $this->rights[$r][1] = 'Read products'; // libelle de la permission @@ -133,7 +133,7 @@ class modProduct extends DolibarrModules $this->rights[$r][4] = 'supprimer'; $r++; - $this->rights[$r][0] = 38; // Must be same permission than in service module + $this->rights[$r][0] = 38; // Must be same permission than in service module $this->rights[$r][1] = 'Export products'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; @@ -150,7 +150,7 @@ class modProduct extends DolibarrModules // Menus //------- - $this->menu = 1; // This module adds menu entries. They are coded into menu manager. + $this->menu = 1; // This module adds menu entries. They are coded into menu manager. /* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts $r=0; $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode @@ -411,8 +411,8 @@ class modProduct extends DolibarrModules ); if (!empty($conf->stock->enabled)) {//if Stock module enabled $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( - 'p.seuil_stock_alerte' => 'StockLimit',//lower limit for warning - 'p.pmp' => 'PMPValue',//weighted average price + 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning + 'p.pmp' => 'PMPValue', //weighted average price 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature )); } @@ -475,29 +475,29 @@ class modProduct extends DolibarrModules ) ); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); - if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); + if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields - $import_extrafield_sample=array(); - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; - $resql=$this->db->query($sql); + $import_extrafield_sample = array(); + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; + $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); - $import_extrafield_sample[$fieldname]=$fieldlabel; + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + $import_extrafield_sample[$fieldname] = $fieldlabel; } } // End add extra fields - $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r]=array( + $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_regex_array[$r] = array( 'p.ref' => '[^ ]', 'p.price_base_type' => '\AHT\z|\ATTC\z', 'p.tosell' => '^[0|1]$', @@ -577,21 +577,21 @@ class modProduct extends DolibarrModules ) )); } - $this->import_examplevalues_array[$r]=array_merge($import_sample, $import_extrafield_sample); + $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); - if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled + if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled - if (! empty($conf->fournisseur->enabled)) + if (!empty($conf->fournisseur->enabled)) { // Import suppliers prices (note: this code is duplicated in module Service) $r++; - $this->import_code[$r]=$this->rights_class.'_supplierprices'; - $this->import_label[$r]="SuppliersPricesOfProductsOrServices"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); - $this->import_tables_creator_array[$r]=array('sp'=>'fk_user'); - $this->import_fields_array[$r]=array(//field order as per structure of table llx_product_fournisseur_price, without optional fields + $this->import_code[$r] = $this->rights_class.'_supplierprices'; + $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); + $this->import_tables_creator_array[$r] = array('sp'=>'fk_user'); + $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields 'sp.fk_product'=>"ProductOrService*", 'sp.fk_soc' => "Supplier*", 'sp.ref_fourn' => 'SupplierRef', @@ -601,19 +601,19 @@ class modProduct extends DolibarrModules 'sp.delivery_time_days' => 'DeliveryDelay', 'sp.supplier_reputation' => 'SupplierReputation' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( 'sp.price'=>"PriceQtyMinHT*", - 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty + 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.remise_percent'=>'DiscountQtyMin' )); if ($conf->multicurrency->enabled) { - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( - 'sp.fk_multicurrency'=>'CurrencyCodeId',//ideally this should be automatically obtained from the CurrencyCode on the next line + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line 'sp.multicurrency_code'=>'CurrencyCode', 'sp.multicurrency_tx'=>'CurrencyRate', 'sp.multicurrency_unitprice'=>'CurrencyUnitPrice', @@ -639,9 +639,9 @@ class modProduct extends DolibarrModules 'sp.delivery_time_days' => '5', 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( 'sp.price' => "50.00", 'sp.unitprice' => '10', @@ -650,7 +650,7 @@ class modProduct extends DolibarrModules )); if ($conf->multicurrency->enabled) { - $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array( + $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', 'sp.multicurrency_code'=>'GBP', 'sp.multicurrency_tx'=>'1.12345', diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 5a2c5040e88..c09a4425c7d 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -27,7 +27,7 @@ * \ingroup societe * \brief Fichier de description et activation du module Societe */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -60,22 +60,22 @@ class modSociete extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->config_page_url = array("societe.php@societe"); // Name of image file used for this module. - $this->picto='company'; + $this->picto = 'company'; // Data directories to create when module is enabled $this->dirs = array("/societe/temp"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array("modExpedition","modFacture","modFournisseur","modFicheinter","modPropale","modContrat","modCommande"); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with - $this->phpmin = array(5,4); // Minimum version of PHP required by module - $this->langfiles = array("companies",'bills'); + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array("modExpedition", "modFacture", "modFournisseur", "modFicheinter", "modPropale", "modContrat", "modCommande"); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5, 4); // Minimum version of PHP required by module + $this->langfiles = array("companies", 'bills'); // Constants $this->const = array(); - $r=0; + $r = 0; $this->const[$r][0] = "SOCIETE_CODECLIENT_ADDON"; $this->const[$r][1] = "chaine"; @@ -123,7 +123,7 @@ class modSociete extends DolibarrModules // Boxes $this->boxes = array(); - $r=0; + $r = 0; $this->boxes[$r][1] = "box_clients.php"; $r++; $this->boxes[$r][1] = "box_prospect.php"; @@ -139,7 +139,7 @@ class modSociete extends DolibarrModules // Permissions $this->rights = array(); $this->rights_class = 'societe'; - $r=0; + $r = 0; $r++; $this->rights[$r][0] = 121; // id de la permission @@ -393,14 +393,14 @@ class modSociete extends DolibarrModules // Import list of third parties and attributes $r++; - $this->import_code[$r] = $this->rights_class . '_' . $r; + $this->import_code[$r] = $this->rights_class.'_'.$r; $this->import_label[$r] = 'ImportDataset_company_1'; $this->import_icon[$r] = 'company'; - $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon + $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon $this->import_tables_array[$r] = array( - 's' => MAIN_DB_PREFIX . 'societe', - 'extra' => MAIN_DB_PREFIX . 'societe_extrafields' - ); // List of tables to insert into (insert done in same order) + 's' => MAIN_DB_PREFIX.'societe', + 'extra' => MAIN_DB_PREFIX.'societe_extrafields' + ); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array(//field order as per structure of table llx_societe 's.nom' => "Name*", 's.name_alias' => "AliasNameShort", @@ -449,21 +449,21 @@ class modSociete extends DolibarrModules 's.multicurrency_code' => 'MulticurrencyCurrency' ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE elementtype = 'societe' AND entity = " . $conf->entity; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.' . $obj->name; + $fieldname = 'extra.'.$obj->name; $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); } } // End add extra fields $this->import_fieldshidden_array[$r] = array( 's.fk_user_creat' => 'user->id', - 'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'societe' - ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + 'extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'societe' + ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_convertvalue_array[$r] = array(//field order as per structure of table llx_societe 's.code_client' => array('rule' => 'getcustomercodeifauto'), 's.code_fournisseur' => array('rule' => 'getsuppliercodeifauto'), @@ -496,17 +496,17 @@ class modSociete extends DolibarrModules //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r] = array(//field order as per structure of table llx_societe 's.status' => '^[0|1]', - 's.fk_typent' => 'id@' . MAIN_DB_PREFIX . 'c_typent', + 's.fk_typent' => 'id@'.MAIN_DB_PREFIX.'c_typent', 's.client' => '^[0|1|2|3]', 's.fournisseur' => '^[0|1]', - 's.mode_reglement' => 'id@' . MAIN_DB_PREFIX . 'c_paiement', - 's.cond_reglement' => 'rowid@' . MAIN_DB_PREFIX . 'c_payment_term', - 's.mode_reglement_supplier' => 'id@' . MAIN_DB_PREFIX . 'c_paiement', - 's.cond_reglement_supplier' => 'rowid@' . MAIN_DB_PREFIX . 'c_payment_term', + 's.mode_reglement' => 'id@'.MAIN_DB_PREFIX.'c_paiement', + 's.cond_reglement' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term', + 's.mode_reglement_supplier' => 'id@'.MAIN_DB_PREFIX.'c_paiement', + 's.cond_reglement_supplier' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term', 's.tva_assuj' => '^[0|1]', 's.fk_multicurrency' => '^[0|1]', 's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$', - 's.multicurrency_code' => 'code_iso@' . MAIN_DB_PREFIX . 'c_currencies' + 's.multicurrency_code' => 'code_iso@'.MAIN_DB_PREFIX.'c_currencies' ); $this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe @@ -520,16 +520,16 @@ class modSociete extends DolibarrModules 's.address' => "61 Jump Street", 's.zip' => "123456", 's.town' => "Bigtown", - 's.fk_departement' => 'matches field "code_departement" in table "' . MAIN_DB_PREFIX . 'c_departements"', - 's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "' . MAIN_DB_PREFIX . 'c_country"', + 's.fk_departement' => 'matches field "code_departement" in table "'.MAIN_DB_PREFIX.'c_departements"', + 's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.'c_country"', 's.phone' => "eg: +34123456789", 's.fax' => "eg. +34987654321", 's.url' => "e.g. https://www.mybigcompany.com", 's.email' => "e.g. test@mybigcompany.com", 's.skype' => "Skype name", 's.fk_effectif' => "1/2/3/5: represents one of the five ranges of employees", - 's.fk_typent' => 'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "' . MAIN_DB_PREFIX . 'c_typent"', - 's.fk_forme_juridique' => '1/2/3 etc...matches field "code" in table "' . MAIN_DB_PREFIX . 'c_forme_juridique"', + 's.fk_typent' => 'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "'.MAIN_DB_PREFIX.'c_typent"', + 's.fk_forme_juridique' => '1/2/3 etc...matches field "code" in table "'.MAIN_DB_PREFIX.'c_forme_juridique"', 's.siret' => "", 's.siren' => "", 's.ape' => "", @@ -538,23 +538,23 @@ class modSociete extends DolibarrModules 's.idprof6' => "", 's.tva_intra' => 'VAT number e.g."FR0123456789"', 's.capital' => "10000", - 's.fk_stcomm' => '-1/0/1/2 etc... matches field "id" in table "' . MAIN_DB_PREFIX . 'c_stcomm"', + 's.fk_stcomm' => '-1/0/1/2 etc... matches field "id" in table "'.MAIN_DB_PREFIX.'c_stcomm"', 's.note_private' => "Example of a PRIVATE note.", 's.note_public' => "Example of a PUBLIC note.", 's.client' => '0 (no customer no prospect) / 1 (customer) / 2 (prospect)/ 3 (customer and prospect)', 's.fournisseur' => '0 (not supplier) / 1 (supplier)', - 's.fk_prospectlevel' => 'eg. "PL_MEDIUM" matches field "code" in table "' . MAIN_DB_PREFIX . 'c_prospectlevel"', - 's.mode_reglement' => '1/2/3...matches field "id" in table "' . MAIN_DB_PREFIX . 'c_paiement"', - 's.cond_reglement' => '1/2/3...matches field "rowid" in table "' . MAIN_DB_PREFIX . 'c_payment_term"', - 's.mode_reglement_supplier' => '1/2/3...matches field "id" in table "' . MAIN_DB_PREFIX . 'c_paiement"', - 's.cond_reglement_supplier' => '1/2/3...matches field "rowid" in table "' . MAIN_DB_PREFIX . 'c_payment_term"', + 's.fk_prospectlevel' => 'eg. "PL_MEDIUM" matches field "code" in table "'.MAIN_DB_PREFIX.'c_prospectlevel"', + 's.mode_reglement' => '1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.'c_paiement"', + 's.cond_reglement' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"', + 's.mode_reglement_supplier' => '1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.'c_paiement"', + 's.cond_reglement_supplier' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"', 's.tva_assuj' => '0 (VAT not used) / 1 (VAT used)', 's.barcode' => '123456789', 's.default_lang' => 'en_US / es_ES etc...matches a language directory in htdocs/langs/', 's.canvas' => "empty / a custom canvas form layout url e.g. mycanvas@mymodule", - 's.datec' => 'formatted as ' . dol_print_date(dol_now(), '%Y-%m-%d'), + 's.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'), 's.fk_multicurrency' => '0 (use system default currency) / 1 (use local currency)', - 's.multicurrency_code' => 'GBP/USD etc... matches field "code_iso" in table "' . MAIN_DB_PREFIX . 'c_currencies"' + 's.multicurrency_code' => 'GBP/USD etc... matches field "code_iso" in table "'.MAIN_DB_PREFIX.'c_currencies"' ); $this->import_updatekeys_array[$r] = array( 's.nom' => 'Name', @@ -566,14 +566,14 @@ class modSociete extends DolibarrModules // Import list of contacts/additional addresses and attributes $r++; - $this->import_code[$r] = $this->rights_class . '_' . $r; + $this->import_code[$r] = $this->rights_class.'_'.$r; $this->import_label[$r] = 'ImportDataset_company_2'; $this->import_icon[$r] = 'contact'; - $this->import_entities_array[$r] = array('s.fk_soc' => 'company'); // We define here only fields that use a different icon than the one defined in import_icon + $this->import_entities_array[$r] = array('s.fk_soc' => 'company'); // We define here only fields that use a different icon than the one defined in import_icon $this->import_tables_array[$r] = array( - 's' => MAIN_DB_PREFIX . 'socpeople', - 'extra' => MAIN_DB_PREFIX . 'socpeople_extrafields' - ); // List of tables to insert into (insert done in same order) + 's' => MAIN_DB_PREFIX.'socpeople', + 'extra' => MAIN_DB_PREFIX.'socpeople_extrafields' + ); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array(//field order as per structure of table llx_socpeople 's.datec' => "DateCreation", 's.fk_soc' => 'ThirdPartyName', @@ -597,21 +597,21 @@ class modSociete extends DolibarrModules 's.note_public' => "NotePublic" ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE elementtype = 'socpeople' AND entity = " . $conf->entity; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on an old database (during a migration for example) { while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 'extra.' . $obj->name; + $fieldname = 'extra.'.$obj->name; $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); } } // End add extra fields $this->import_fieldshidden_array[$r] = array( 's.fk_user_creat' => 'user->id', - 'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'socpeople' - ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + 'extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'socpeople' + ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_convertvalue_array[$r] = array( 's.fk_soc' => array( 'rule' => 'fetchidfromref', @@ -641,17 +641,17 @@ class modSociete extends DolibarrModules 's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$' ); $this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_socpeople - 's.datec' => 'formatted as ' . dol_print_date(dol_now(), '%Y-%m-%d'), + 's.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'), 's.fk_soc' => 'Third Party name eg. TPBigCompany', - 's.civility' => 'Title of civility eg: MR...matches field "code" in table "' . MAIN_DB_PREFIX . 'c_civility"', + 's.civility' => 'Title of civility eg: MR...matches field "code" in table "'.MAIN_DB_PREFIX.'c_civility"', 's.lastname' => "lastname or label", 's.firstname' => 'John', 's.address' => '61 Jump street', 's.zip' => '75000', 's.town' => 'Bigtown', - 's.fk_departement' => 'matches field "code_departement" in table "' . MAIN_DB_PREFIX . 'c_departements"', - 's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "' . MAIN_DB_PREFIX . 'c_country"', - 's.birthday' => 'formatted as ' . dol_print_date(dol_now(), '%Y-%m-%d'), + 's.fk_departement' => 'matches field "code_departement" in table "'.MAIN_DB_PREFIX.'c_departements"', + 's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.'c_country"', + 's.birthday' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'), 's.poste' => "Director", 's.phone' => "5551122", 's.phone_perso' => "5551133", @@ -665,11 +665,11 @@ class modSociete extends DolibarrModules // Import Bank Accounts $r++; - $this->import_code[$r] = $this->rights_class . '_' . $r; - $this->import_label[$r] = "ImportDataset_company_3"; // Translation key + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "ImportDataset_company_3"; // Translation key $this->import_icon[$r] = 'company'; - $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon to the one defined in import_icon - $this->import_tables_array[$r] = array('sr' => MAIN_DB_PREFIX . 'societe_rib'); + $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon to the one defined in import_icon + $this->import_tables_array[$r] = array('sr' => MAIN_DB_PREFIX.'societe_rib'); $this->import_fields_array[$r] = array(//field order as per structure of table llx_societe_rib 'sr.label' => "Label*", 'sr.fk_soc' => "ThirdPartyName*", @@ -699,7 +699,7 @@ class modSociete extends DolibarrModules $this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe_rib 'sr.label' => 'eg. "account1"', 'sr.fk_soc' => 'eg. "TPBigCompany"', - 'sr.datec' => 'date used for creating direct debit UMR formatted as ' . dol_print_date(dol_now(), + 'sr.datec' => 'date used for creating direct debit UMR formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'), 'sr.bank' => 'bank name eg: "ING-Direct"', 'sr.code_banque' => 'account sort code (GB)/Routing number (US) eg. "8456"', @@ -716,18 +716,18 @@ class modSociete extends DolibarrModules // Import Company Sales representatives $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="ImportDataset_company_4"; // Translation key - $this->import_icon[$r]='company'; - $this->import_entities_array[$r]=array('sr.fk_user'=>'user'); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('sr'=>MAIN_DB_PREFIX.'societe_commerciaux'); - $this->import_fields_array[$r]=array('sr.fk_soc'=>"ThirdPartyName*",'sr.fk_user'=>"User*"); + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = "ImportDataset_company_4"; // Translation key + $this->import_icon[$r] = 'company'; + $this->import_entities_array[$r] = array('sr.fk_user'=>'user'); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('sr'=>MAIN_DB_PREFIX.'societe_commerciaux'); + $this->import_fields_array[$r] = array('sr.fk_soc'=>"ThirdPartyName*", 'sr.fk_user'=>"User*"); - $this->import_convertvalue_array[$r]=array( - 'sr.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), - 'sr.fk_user'=>array('rule'=>'fetchidfromref','classfile'=>'/user/class/user.class.php','class'=>'User','method'=>'fetch','element'=>'User') + $this->import_convertvalue_array[$r] = array( + 'sr.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'), + 'sr.fk_user'=>array('rule'=>'fetchidfromref', 'classfile'=>'/user/class/user.class.php', 'class'=>'User', 'method'=>'fetch', 'element'=>'User') ); - $this->import_examplevalues_array[$r]=array('sr.fk_soc'=>"MyBigCompany",'sr.fk_user'=>"login"); + $this->import_examplevalues_array[$r] = array('sr.fk_soc'=>"MyBigCompany", 'sr.fk_user'=>"login"); } @@ -747,19 +747,19 @@ class modSociete extends DolibarrModules //$this->remove($options); //ODT template - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt'; - $dirodt=DOL_DATA_ROOT.'/doctemplates/thirdparties'; - $dest=$dirodt.'/template_thirdparty.odt'; + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/thirdparties'; + $dest = $dirodt.'/template_thirdparty.odt'; - if (file_exists($src) && ! file_exists($dest)) + if (file_exists($src) && !file_exists($dest)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_mkdir($dirodt); - $result=dol_copy($src, $dest, 0, 0); + $result = dol_copy($src, $dest, 0, 0); if ($result < 0) { $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); return 0; } } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 7db062d3cbc..d35bedb6c9e 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -127,7 +127,7 @@ class pdf_cyan extends ModelePDFPropales */ public function __construct($db) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Translations $langs->loadLangs(array("main", "bills")); @@ -246,16 +246,16 @@ class pdf_cyan extends ModelePDFPropales { if ($obj['photo_vignette']) { - $filename= $obj['photo_vignette']; + $filename = $obj['photo_vignette']; } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } $realpath = $dir.$filename; @@ -265,11 +265,11 @@ class pdf_cyan extends ModelePDFPropales } } - if ($realpath && $arephoto) $realpatharray[$i]=$realpath; + if ($realpath && $arephoto) $realpatharray[$i] = $realpath; } } - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; + if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva; if ($conf->propal->multidir_output[$conf->entity]) { @@ -281,20 +281,20 @@ class pdf_cyan extends ModelePDFPropales if ($object->specimen) { $dir = $conf->propal->multidir_output[$conf->entity]; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + $dir = $conf->propal->multidir_output[$object->entity]."/".$objectref; + $file = $dir."/".$objectref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -302,19 +302,19 @@ class pdf_cyan extends ModelePDFPropales if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Create pdf instance - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -339,13 +339,13 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Does we have at least one line with discount $this->atleastonediscount foreach ($object->lines as $line) { - if ($line->remise_percent){ + if ($line->remise_percent) { $this->atleastonediscount = true; break; } @@ -355,23 +355,23 @@ class pdf_cyan extends ModelePDFPropales // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $heightforinfotot = 40; // Height reserved to output the info and total part - $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0; - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)?12:22); // Height reserved to output the footer (value include bottom margin) + $heightforinfotot = 40; // Height reserved to output the info and total part + $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0; + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90+$top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); + $tab_top = 90 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); // Incoterm @@ -423,10 +423,10 @@ class pdf_cyan extends ModelePDFPropales { $tab_top -= 2; - $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite; + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; $pageposbeforenote = $pagenb; - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); @@ -434,12 +434,12 @@ class pdf_cyan extends ModelePDFPropales $pdf->startTransaction(); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); // Description - $pageposafternote=$pdf->getPage(); + $pageposafternote = $pdf->getPage(); $posyafter = $pdf->GetY(); - if($pageposafternote>$pageposbeforenote ) + if ($pageposafternote > $pageposbeforenote) { $pdf->rollbackTransaction(true); @@ -447,7 +447,7 @@ class pdf_cyan extends ModelePDFPropales while ($pagenb < $pageposafternote) { $pdf->AddPage(); $pagenb++; - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); // $this->_pagefoot($pdf,$object,$outputlangs,1); $pdf->setTopMargin($tab_top_newpage); @@ -459,12 +459,12 @@ class pdf_cyan extends ModelePDFPropales $pdf->setPage($pageposbeforenote); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); - $pageposafternote=$pdf->getPage(); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pageposafternote = $pdf->getPage(); $posyafter = $pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text { $pdf->AddPage('', '', true); $pagenb++; @@ -485,17 +485,17 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetDrawColor(128, 128, 128); // Draw note frame - if($i>$pageposbeforenote){ + if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1); + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); } - else{ + else { $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); } // Add footer - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $this->_pagefoot($pdf, $object, $outputlangs, 1); $i++; @@ -503,27 +503,27 @@ class pdf_cyan extends ModelePDFPropales // apply note frame to last page $pdf->setPage($pageposafternote); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $height_note=$posyafter-$tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1); + $height_note = $posyafter - $tab_top_newpage; + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); } else // No pagebreak { $pdf->commitTransaction(); $posyafter = $pdf->GetY(); - $height_note=$posyafter-$tab_top; - $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1); + $height_note = $posyafter - $tab_top; + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); - if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) ) + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // not enough space, need to add page $pdf->AddPage('', '', true); $pagenb++; $pageposafternote++; $pdf->setPage($pageposafternote); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $posyafter = $tab_top_newpage; @@ -531,11 +531,11 @@ class pdf_cyan extends ModelePDFPropales } $tab_height = $tab_height - $height_note; - $tab_top = $posyafter +6; + $tab_top = $posyafter + 6; } else { - $height_note=0; + $height_note = 0; } // Use new auto collum system @@ -699,7 +699,7 @@ class pdf_cyan extends ModelePDFPropales } - $parameters=array( + $parameters = array( 'object' => $object, 'i' => $i, 'pdf' =>& $pdf, @@ -777,10 +777,10 @@ class pdf_cyan extends ModelePDFPropales $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == $pageposafter) { @@ -793,7 +793,7 @@ class pdf_cyan extends ModelePDFPropales $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -803,19 +803,19 @@ class pdf_cyan extends ModelePDFPropales if ($pagenb == $pageposbeforeprintlines) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; } // Affiche zone infos - $posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs); + $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux - $posy=$this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs); + $posy = $this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs); // Affiche zone versements /* @@ -828,7 +828,7 @@ class pdf_cyan extends ModelePDFPropales // Customer signature area if (empty($conf->global->PROPAL_DISABLE_SIGNATURE)) { - $posy=$this->drawSignatureArea($pdf, $object, $posy, $outputlangs); + $posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs); } // Pied de page @@ -840,9 +840,9 @@ class pdf_cyan extends ModelePDFPropales { require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php'; - $already_merged = array (); + $already_merged = array(); foreach ($object->lines as $line) { - if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) { + if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) { // Find the desire PDF $filetomerge = new Propalmergepdfproduct($this->db); @@ -978,13 +978,13 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - $posy=$pdf->GetY()+4; + $posy = $pdf->GetY() + 4; } - $posxval=52; + $posxval = 52; // Show shipping date - if (! empty($object->date_livraison)) + if (!empty($object->date_livraison)) { $outputlangs->load("sendings"); $pdf->SetFont('', 'B', $default_font_size - 2); @@ -993,10 +993,10 @@ class pdf_cyan extends ModelePDFPropales $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $dlp=dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true); + $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true); $pdf->MultiCell(80, 4, $dlp, 0, 'L'); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; } elseif ($object->availability_code || $object->availability) // Show availability conditions { @@ -1007,11 +1007,11 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability); - $lib_availability=str_replace('\n', "\n", $lib_availability); + $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability); + $lib_availability = str_replace('\n', "\n", $lib_availability); $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; } // Show payments conditions @@ -1024,11 +1024,11 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); - $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L'); - $posy=$pdf->GetY()+3; + $posy = $pdf->GetY() + 3; } if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMMODE)) @@ -1060,19 +1060,19 @@ class pdf_cyan extends ModelePDFPropales $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); + $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') { // Si mode reglement non force ou si force a CHQ - if (! empty($conf->global->FACTURE_CHQ_NUMBER)) + if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); if ($conf->global->FACTURE_CHQ_NUMBER > 0) { @@ -1082,14 +1082,14 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } if ($conf->global->FACTURE_CHQ_NUMBER == -1) @@ -1097,14 +1097,14 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } } @@ -1113,19 +1113,19 @@ class pdf_cyan extends ModelePDFPropales // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { - if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) + if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) { - $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account); - if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank + $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); + if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank $account = new Account($this->db); $account->fetch($bankid); - $curx=$this->marge_gauche; - $cury=$posy; + $curx = $this->marge_gauche; + $cury = $posy; - $posy=pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); + $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); - $posy+=2; + $posy += 2; } } } @@ -1146,7 +1146,7 @@ class pdf_cyan extends ModelePDFPropales */ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs) { - global $conf,$mysoc; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $tab2_top = $posy; @@ -1157,32 +1157,32 @@ class pdf_cyan extends ModelePDFPropales $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { - $col2x-=20; + $col2x -= 20; } $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - $useborder=0; + $useborder = 0; $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248, 248, 248); $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; - $this->atleastoneratenotnull=0; + $this->atleastoneratenotnull = 0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) + $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) { // Nothing to do } @@ -1255,7 +1255,7 @@ class pdf_cyan extends ModelePDFPropales } //} // VAT - foreach($this->tva as $tvakey => $tvaval) + foreach ($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1264,15 +1264,15 @@ class pdf_cyan extends ModelePDFPropales $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat.=vatrate($tvakey, 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat .= vatrate($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); @@ -1351,7 +1351,7 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); @@ -1370,7 +1370,7 @@ class pdf_cyan extends ModelePDFPropales $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0); @@ -1395,7 +1395,7 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); @@ -1427,8 +1427,8 @@ class pdf_cyan extends ModelePDFPropales global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1473,7 +1473,7 @@ class pdf_cyan extends ModelePDFPropales */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs; + global $conf, $langs; $outputlangs->load("main"); $outputlangs->load("bills"); @@ -1485,7 +1485,7 @@ class pdf_cyan extends ModelePDFPropales pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK); } @@ -1519,7 +1519,7 @@ class pdf_cyan extends ModelePDFPropales } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } @@ -1527,61 +1527,61 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("PdfCommercialProposalTitle"); + $title = $outputlangs->transnoentities("PdfCommercialProposalTitle"); $pdf->MultiCell(100, 4, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); - $posy+=1; + $posy += 1; $pdf->SetFont('', '', $default_font_size - 2); if ($object->ref_client) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : ".dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R'); if ($object->thirdparty->code_client) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } // Get contact if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { - $usertmp=new User($this->db); + $usertmp = new User($this->db); $usertmp->fetch($arrayidcontact[0]); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - $posy+=2; + $posy += 2; $top_shift = 0; // Show list of linked objects @@ -1595,28 +1595,28 @@ class pdf_cyan extends ModelePDFPropales if ($showaddress) { // Sender properties - $carac_emetteur=''; + $carac_emetteur = ''; // Add internal contact of proposal if defined - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name")); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy=42+$top_shift; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; - $hautcadre=40; + $posy = 42 + $top_shift; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; + $hautcadre = 40; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -1624,24 +1624,24 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetTextColor(0, 0, 60); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); // If CUSTOMER contact defined, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -1652,26 +1652,26 @@ class pdf_cyan extends ModelePDFPropales $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox=100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=42+$top_shift; - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = 42 + $top_shift; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); @@ -1679,7 +1679,7 @@ class pdf_cyan extends ModelePDFPropales // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } @@ -1700,7 +1700,7 @@ class pdf_cyan extends ModelePDFPropales protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } @@ -1722,7 +1722,7 @@ class pdf_cyan extends ModelePDFPropales $posx = 120; $largcol = ($this->page_largeur - $this->marge_droite - $posx); - $useborder=0; + $useborder = 0; $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); @@ -1731,12 +1731,12 @@ class pdf_cyan extends ModelePDFPropales $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1); $pdf->SetXY($posx, $tab_top + $tab_hl); - $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R'); - if (! empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) { - $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl*3); + $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R'); + if (!empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) { + $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl * 3); } - return ($tab_hl*7); + return ($tab_hl * 7); } @@ -1757,13 +1757,13 @@ class pdf_cyan extends ModelePDFPropales // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content $this->defaultTitlesFieldsStyle = array( 'align' => 'C', // R,C,L - 'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); /* @@ -1784,7 +1784,7 @@ class pdf_cyan extends ModelePDFPropales ); */ - $rank=0; // do not use negative rank + $rank = 0; // do not use negative rank $this->cols['desc'] = array( 'rank' => $rank, 'width' => false, // only for desc @@ -1794,7 +1794,7 @@ class pdf_cyan extends ModelePDFPropales 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', @@ -1804,19 +1804,19 @@ class pdf_cyan extends ModelePDFPropales $rank = $rank + 10; $this->cols['photo'] = array( 'rank' => $rank, - 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm + 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm 'status' => false, 'title' => array( 'textkey' => 'Photo', 'label' => ' ' ), 'content' => array( - 'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'border-left' => false, // remove left line separator ); - if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto)) + if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; } @@ -1870,7 +1870,7 @@ class pdf_cyan extends ModelePDFPropales ), 'border-left' => true, // add left line separator ); - if($conf->global->PRODUCT_USE_UNITS){ + if ($conf->global->PRODUCT_USE_UNITS) { $this->cols['unit']['status'] = true; } @@ -1884,7 +1884,7 @@ class pdf_cyan extends ModelePDFPropales ), 'border-left' => true, // add left line separator ); - if ($this->atleastonediscount){ + if ($this->atleastonediscount) { $this->cols['discount']['status'] = true; } @@ -1900,7 +1900,7 @@ class pdf_cyan extends ModelePDFPropales ); - $parameters=array( + $parameters = array( 'object' => $object, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, @@ -1908,7 +1908,7 @@ class pdf_cyan extends ModelePDFPropales 'hideref' => $hideref ); - $reshook=$hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook + $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php index ee858c35cf7..8ff4c3ad429 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php @@ -122,7 +122,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders */ public function __construct($db) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Load translation files required by the page $langs->loadLangs(array("main", "bills")); @@ -133,40 +133,40 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Page size for A4 format $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 1; // Affiche mode reglement - $this->option_condreg = 1; // Affiche conditions reglement - $this->option_codeproduitservice = 1; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 1; // Affiche mode reglement + $this->option_condreg = 1; // Affiche conditions reglement + $this->option_codeproduitservice = 1; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->franchise=!$mysoc->tva_assuj; + $this->franchise = !$mysoc->tva_assuj; // Get source company - $this->emetteur=$mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; // For module retrocompatibility support durring PDF transition: TODO remove this at the end + $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support durring PDF transition: TODO remove this at the end - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } @@ -251,22 +251,22 @@ class pdf_cornas extends ModelePDFSuppliersOrders if ($object->specimen) { $dir = $conf->fournisseur->commande->dir_output; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); - $dir = $conf->fournisseur->commande->dir_output . '/'. $objectref; - $file = $dir . "/" . $objectref . ".pdf"; - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; + $dir = $conf->fournisseur->commande->dir_output.'/'.$objectref; + $file = $dir."/".$objectref.".pdf"; + if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -301,14 +301,14 @@ class pdf_cornas extends ModelePDFSuppliersOrders } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -316,13 +316,13 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Does we have at least one line with discount $this->atleastonediscount foreach ($object->lines as $line) { - if ($line->remise_percent){ + if ($line->remise_percent) { $this->atleastonediscount = true; break; } @@ -332,15 +332,15 @@ class pdf_cornas extends ModelePDFSuppliersOrders // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90+$top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); + $tab_top = 90 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); // Incoterm if ($conf->incoterm->enabled) @@ -382,12 +382,12 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->startTransaction(); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); // Description - $pageposafternote=$pdf->getPage(); + $pageposafternote = $pdf->getPage(); $posyafter = $pdf->GetY(); - if($pageposafternote>$pageposbeforenote ) + if ($pageposafternote > $pageposbeforenote) { $pdf->rollbackTransaction(true); @@ -395,7 +395,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders while ($pagenb < $pageposafternote) { $pdf->AddPage(); $pagenb++; - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); // $this->_pagefoot($pdf,$object,$outputlangs,1); $pdf->setTopMargin($tab_top_newpage); @@ -407,12 +407,12 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->setPage($pageposbeforenote); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); - $pageposafternote=$pdf->getPage(); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pageposafternote = $pdf->getPage(); $posyafter = $pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text { $pdf->AddPage('', '', true); $pagenb++; @@ -433,17 +433,17 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetDrawColor(128, 128, 128); // Draw note frame - if($i>$pageposbeforenote){ + if ($i > $pageposbeforenote) { $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1); + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); } - else{ + else { $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); } // Add footer - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $this->_pagefoot($pdf, $object, $outputlangs, 1); $i++; @@ -451,27 +451,27 @@ class pdf_cornas extends ModelePDFSuppliersOrders // apply note frame to last page $pdf->setPage($pageposafternote); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $height_note=$posyafter-$tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1); + $height_note = $posyafter - $tab_top_newpage; + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); } else // No pagebreak { $pdf->commitTransaction(); $posyafter = $pdf->GetY(); - $height_note=$posyafter-$tab_top; - $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1); + $height_note = $posyafter - $tab_top; + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); - if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) ) + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // not enough space, need to add page $pdf->AddPage('', '', true); $pagenb++; $pageposafternote++; $pdf->setPage($pageposafternote); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $posyafter = $tab_top_newpage; @@ -479,11 +479,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders } $tab_height = $tab_height - $height_note; - $tab_top = $posyafter +6; + $tab_top = $posyafter + 6; } else { - $height_note=0; + $height_note = 0; } $iniY = $tab_top + 7; @@ -715,10 +715,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == $pageposafter) { @@ -731,7 +731,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -741,24 +741,24 @@ class pdf_cornas extends ModelePDFSuppliersOrders if ($pagenb == $pageposbeforeprintlines) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Affiche zone infos - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { - $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); + $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); } // Pied de page @@ -840,10 +840,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - $posy=$pdf->GetY()+4; + $posy = $pdf->GetY() + 4; } - $posxval=52; + $posxval = 52; // Show payments conditions if (!empty($object->cond_reglement_code) || $object->cond_reglement) @@ -872,10 +872,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders $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); + $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; } @@ -897,7 +897,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -909,27 +909,27 @@ class pdf_cornas extends ModelePDFSuppliersOrders $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { - $col2x-=20; + $col2x -= 20; } $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - $useborder=0; + $useborder = 0; $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248, 248, 248); - $this->atleastoneratenotnull=0; - foreach($this->tva as $tvakey => $tvaval) + $this->atleastoneratenotnull = 0; + foreach ($this->tva as $tvakey => $tvaval) { if ($tvakey > 0) // On affiche pas taux 0 { @@ -938,47 +938,47 @@ class pdf_cornas extends ModelePDFSuppliersOrders $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat.=vatrate($tvakey, 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat .= vatrate($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, 'R', 1); } } - if (! $this->atleastoneratenotnull) // If no vat at all + if (!$this->atleastoneratenotnull) // If no vat at all { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); // Total LocalTax1 - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) + if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); } // Total LocalTax2 - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) + if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); } @@ -1020,11 +1020,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ //Local tax 2 - 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; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1033,15 +1033,15 @@ class pdf_cornas extends ModelePDFSuppliersOrders $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $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); + $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, 'R', 1); @@ -1055,7 +1055,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); @@ -1063,13 +1063,13 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetTextColor(0, 0, 0); - $creditnoteamount=0; - $depositsamount=0; + $creditnoteamount = 0; + $depositsamount = 0; //$creditnoteamount=$object->getSumCreditNotesUsed(); //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); - if (! empty($object->paye)) $resteapayer=0; + if (!empty($object->paye)) $resteapayer = 0; if ($deja_regle > 0) { @@ -1077,7 +1077,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); @@ -1085,7 +1085,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); @@ -1117,8 +1117,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1181,7 +1181,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $langs,$conf,$mysoc; + global $langs, $conf, $mysoc; // Load translation files required by the page $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "sendings")); @@ -1324,27 +1324,27 @@ class pdf_cornas extends ModelePDFSuppliersOrders if ($showaddress) { // Sender properties - $carac_emetteur=''; + $carac_emetteur = ''; // Add internal contact of proposal if defined - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy=42+$top_shift; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; - $hautcadre=40; + $posy = 42 + $top_shift; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; + $hautcadre = 40; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -1352,25 +1352,25 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetTextColor(0, 0, 60); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); // If BILLING contact defined on order, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'BILLING'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'BILLING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -1381,26 +1381,26 @@ class pdf_cornas extends ModelePDFSuppliersOrders $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox=100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=42+$top_shift; - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = 42 + $top_shift; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); @@ -1408,7 +1408,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } @@ -1428,7 +1428,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } @@ -1478,7 +1478,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders ); */ - $rank=0; // do not use negative rank + $rank = 0; // do not use negative rank $this->cols['desc'] = array( 'rank' => $rank, 'width' => false, // only for desc @@ -1498,7 +1498,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $rank = $rank + 10; $this->cols['photo'] = array( 'rank' => $rank, - 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm + 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm 'status' => false, 'title' => array( 'textkey' => 'Photo', @@ -1510,7 +1510,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders 'border-left' => false, // remove left line separator ); - if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) + if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) { $this->cols['photo']['status'] = true; } @@ -1564,7 +1564,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders ), 'border-left' => true, // add left line separator ); - if($conf->global->PRODUCT_USE_UNITS){ + if ($conf->global->PRODUCT_USE_UNITS) { $this->cols['unit']['status'] = true; } @@ -1578,7 +1578,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders ), 'border-left' => true, // add left line separator ); - if ($this->atleastonediscount){ + if ($this->atleastonediscount) { $this->cols['discount']['status'] = true; } @@ -1594,7 +1594,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders ); - $parameters=array( + $parameters = array( 'object' => $object, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, @@ -1602,7 +1602,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders 'hideref' => $hideref ); - $reshook=$hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook + $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -1633,8 +1633,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders */ public function columnSort($a, $b) { - if(empty($a['rank'])){ $a['rank'] = 0; } - if(empty($b['rank'])){ $b['rank'] = 0; } + if (empty($a['rank'])) { $a['rank'] = 0; } + if (empty($b['rank'])) { $b['rank'] = 0; } if ($a['rank'] == $b['rank']) { return 0; } @@ -1673,15 +1673,15 @@ class pdf_cornas extends ModelePDFSuppliersOrders { if (!$this->getColumnStatus($colKey)) continue; // continue if disabled - if (!empty($colDef['scale'])){ + if (!empty($colDef['scale'])) { // In case of column widht is defined by percentage $colDef['width'] = abs($arrayWidth * $colDef['scale'] / 100); } - if (empty($colDef['width'])){ + if (empty($colDef['width'])) { $countFlexCol++; } - else{ + else { $totalDefinedColWidth += $colDef['width']; } } @@ -1689,25 +1689,25 @@ class pdf_cornas extends ModelePDFSuppliersOrders foreach ($this->cols as $colKey => &$colDef) { // setting empty conf with default - if(!empty($colDef['title'])){ + if (!empty($colDef['title'])) { $colDef['title'] = array_replace($this->defaultTitlesFieldsStyle, $colDef['title']); } - else{ + else { $colDef['title'] = $this->defaultTitlesFieldsStyle; } // setting empty conf with default - if(!empty($colDef['content'])){ + if (!empty($colDef['content'])) { $colDef['content'] = array_replace($this->defaultContentsFieldsStyle, $colDef['content']); } - else{ + else { $colDef['content'] = $this->defaultContentsFieldsStyle; } - if($this->getColumnStatus($colKey)) + if ($this->getColumnStatus($colKey)) { // In case of flexible column - if(empty($colDef['width'])){ + if (empty($colDef['width'])) { $colDef['width'] = abs(($arrayWidth - $totalDefinedColWidth)) / $countFlexCol; } @@ -1753,7 +1753,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders */ public function getColumnRank($colKey) { - if(!isset($this->cols[$colKey]['rank'])) return -1; + if (!isset($this->cols[$colKey]['rank'])) return -1; return $this->cols[$colKey]['rank']; } @@ -1772,22 +1772,22 @@ class pdf_cornas extends ModelePDFSuppliersOrders $rank = -1; // try to get rank from target column - if(!empty($targetCol)){ + if (!empty($targetCol)) { $rank = $this->getColumnRank($targetCol); - if($rank>=0 && $insertAfterTarget){ $rank++; } + if ($rank >= 0 && $insertAfterTarget) { $rank++; } } // get rank from new column definition - if($rank<0 && !empty($defArray['rank'])){ + if ($rank < 0 && !empty($defArray['rank'])) { $rank = $defArray['rank']; } // error: no rank - if($rank<0){ return -1; } + if ($rank < 0) { return -1; } foreach ($this->cols as $colKey =>& $colDef) { - if( $rank <= $colDef['rank']) + if ($rank <= $colDef['rank']) { $colDef['rank'] = $colDef['rank'] + 1; } @@ -1837,7 +1837,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders */ public function getColumnStatus($colKey) { - if( !empty($this->cols[$colKey]['status'])){ + if (!empty($this->cols[$colKey]['status'])) { return true; } else return false; diff --git a/htdocs/core/tpl/bloc_comment.tpl.php b/htdocs/core/tpl/bloc_comment.tpl.php index 1a1b9023a98..30badf59efa 100644 --- a/htdocs/core/tpl/bloc_comment.tpl.php +++ b/htdocs/core/tpl/bloc_comment.tpl.php @@ -1,7 +1,7 @@ '; if (!empty($object->comments)) { // Default color for current user - $TColors = array($user->id => array('bgcolor'=>'efefef','color'=>'555')); + $TColors = array($user->id => array('bgcolor'=>'efefef', 'color'=>'555')); $first = true; - foreach($object->comments as $comment) + foreach ($object->comments as $comment) { $fk_user = $comment->fk_user_author; $userstatic->fetch($fk_user); @@ -75,8 +75,8 @@ if (!empty($object->comments)) { $bgcolor = $userstatic->color; } - $color = (colorIsLight($bgcolor))?'555':'fff'; - $TColors[$fk_user] = array('bgcolor'=>$bgcolor,'color'=>$color); + $color = (colorIsLight($bgcolor)) ? '555' : 'fff'; + $TColors[$fk_user] = array('bgcolor'=>$bgcolor, 'color'=>$color); } print '
        '; if ($fk_user != $user->id) { @@ -85,7 +85,7 @@ if (!empty($object->comments)) print '
        '; print '
        '; - if (! empty($user->photo)) + if (!empty($user->photo)) { print Form::showphoto('userphoto', $userstatic, 80, 0, 0, '', 'small', 0, 1).'
        '; } @@ -144,7 +144,7 @@ if (!empty($object->comments)) print '
        '; // End comment-right print '
        '; // End comment - if($fk_user == $user->id) { + if ($fk_user == $user->id) { print '
         
        '; } print '
        '; diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index db4a243005f..2c58bccc56e 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -23,7 +23,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -49,7 +49,7 @@ foreach($object->fields as $key => $val) if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop'; print '"'; print '>'; - if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); + if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); else print $langs->trans($val['label']); print ''; print ''; diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index a330840156a..eb1533ba759 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -22,12 +22,12 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } -if (! is_object($form)) $form=new Form($db); +if (!is_object($form)) $form = new Form($db); ?> diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php index ca30eb5ae92..0d2949b4e24 100644 --- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php @@ -1,36 +1,36 @@ table_element; +if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey = $object->table_element; // Loop to show all columns of extrafields from $obj, $extrafields and $db -if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... +if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... { if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) { if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.'; - foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) + foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) { - if (! empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) + if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) { - $align=$extrafields->getAlignFlag($key, $extrafieldsobjectkey); + $align = $extrafields->getAlignFlag($key, $extrafieldsobjectkey); print ''; - $tmpkey='options_'.$key; + $tmpkey = 'options_'.$key; if (in_array($extrafields->attributes[$extrafieldsobjectkey]['type'][$key], array('date', 'datetime', 'timestamp')) && !is_numeric($obj->$tmpkey)) { $datenotinstring = $obj->$tmpkey; - if (! is_numeric($obj->$tmpkey)) // For backward compatibility + if (!is_numeric($obj->$tmpkey)) // For backward compatibility { $datenotinstring = $db->jdate($datenotinstring); } @@ -53,18 +53,18 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ print $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; if ($extrafields->attributes[$extrafieldsobjectkey]['totalizable'][$key]) { - if (! $i) { + if (!$i) { // we keep position for the first line $totalarray['totalizable'][$key]['pos'] = $totalarray['nbfield']; } $totalarray['totalizable'][$key]['total'] += $obj->$tmpkey; } - if (! empty($val['isameasure'])) + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]=$extrafieldsobjectprefix.$tmpkey; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = $extrafieldsobjectprefix.$tmpkey; $totalarray['val'][$extrafieldsobjectprefix.$tmpkey] += $obj->$tmpkey; } } diff --git a/htdocs/core/tpl/extrafields_list_search_param.tpl.php b/htdocs/core/tpl/extrafields_list_search_param.tpl.php index c6657326ec9..ca72293365a 100644 --- a/htdocs/core/tpl/extrafields_list_search_param.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_param.tpl.php @@ -1,21 +1,21 @@ table_element like 'societe', 'socpeople', ... +if (!empty($search_array_options)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... { - if (empty($search_options_pattern)) $search_options_pattern='search_options_'; + if (empty($search_options_pattern)) $search_options_pattern = 'search_options_'; foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/'.$search_options_pattern.'/', '', $key); - if ($val != '') $param.='&'.$search_options_pattern.$tmpkey.'='.urlencode($val); + $crit = $val; + $tmpkey = preg_replace('/'.$search_options_pattern.'/', '', $key); + if ($val != '') $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val); } } diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index c2be08aa5da..7663af1c48e 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -18,7 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($object) || ! is_object($object)) { +if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; } diff --git a/htdocs/don/card.php b/htdocs/don/card.php index bc590174166..9cbb47503be 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -28,17 +28,17 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/dons/modules_don.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/donation.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmargin.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; -if (! empty($conf->projet->enabled)) { +require_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -46,11 +46,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->loadLangs(array("bills", "companies", "donations")); -$id=GETPOST('rowid')?GETPOST('rowid', 'int'):GETPOST('id', 'int'); -$action=GETPOST('action', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); -$amount=GETPOST('amount'); -$donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); +$id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$amount = GETPOST('amount'); +$donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); $object = new Don($db); @@ -74,13 +74,13 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if ($action == 'update') { - if (! empty($cancel)) + if (!empty($cancel)) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } - $error=0; + $error = 0; if (empty($donation_date)) { @@ -96,7 +96,7 @@ if ($action == 'update') $error++; } - if (! $error) + if (!$error) { $object->fetch($id); @@ -130,13 +130,13 @@ if ($action == 'update') if ($action == 'add') { - if (! empty($cancel)) + if (!empty($cancel)) { header("Location: index.php"); exit; } - $error=0; + $error = 0; if (empty($donation_date)) { @@ -152,7 +152,7 @@ if ($action == 'add') $error++; } - if (! $error) + if (!$error) { $object->socid = GETPOST("socid", 'int'); $object->firstname = GETPOST("firstname", 'alpha'); @@ -190,7 +190,7 @@ if ($action == 'add') if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->don->supprimer) { $object->fetch($id); - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { header("Location: index.php"); @@ -376,12 +376,12 @@ if ($action == 'create') print '
        '.$langs->trans("AddThirdParty").''; print ''; } - print '' . "\n"; + print ''."\n"; } // Date print ''.$langs->trans("Date").''; - print $form->selectDate($donation_date?$donation_date:-1, '', '', '', '', "add", 1, 1); + print $form->selectDate($donation_date ? $donation_date : -1, '', '', '', '', "add", 1, 1); print ''; // Amount @@ -389,7 +389,7 @@ if ($action == 'create') // Public donation print ''.$langs->trans("PublicDonation").""; - print $form->selectyesno("public", isset($_POST["public"])?$_POST["public"]:1, 1); + print $form->selectyesno("public", isset($_POST["public"]) ? $_POST["public"] : 1, 1); print "\n"; if (empty($conf->societe->enabled) || empty($conf->global->DONATION_USE_THIRDPARTIES)) @@ -402,14 +402,14 @@ if ($action == 'create') // Zip / Town print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6); + print $formcompany->select_ziptown((isset($_POST["zipcode"]) ? $_POST["zipcode"] : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print ' '; - print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((isset($_POST["town"]) ? $_POST["town"] : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print ''; // Country print ''; - print $form->select_country(GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id); + print $form->select_country(GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; @@ -424,7 +424,7 @@ if ($action == 'create') // Public note print ''; - print '' . $langs->trans('NotePublic') . ''; + print ''.$langs->trans('NotePublic').''; print ''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); @@ -434,7 +434,7 @@ if ($action == 'create') // Private note if (empty($user->socid)) { print ''; - print '' . $langs->trans('NotePrivate') . ''; + print ''.$langs->trans('NotePrivate').''; print ''; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); @@ -442,7 +442,7 @@ if ($action == 'create') print ''; } - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { print "".$langs->trans("Project").""; $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); @@ -450,8 +450,8 @@ if ($action == 'create') } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -479,21 +479,21 @@ if ($action == 'create') /* */ /* ************************************************************ */ -if (! empty($id) && $action == 'edit') +if (!empty($id) && $action == 'edit') { - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($db, $object->error); exit; } - $result=$object->fetch_optionals(); + $result = $object->fetch_optionals(); if ($result < 0) { dol_print_error($db); exit; } - $hselected='card'; + $hselected = 'card'; $head = donation_prepare_head($object); - print '
        '; + print ''; print ''; print ''; print ''; @@ -573,9 +573,9 @@ if (! empty($id) && $action == 'edit') print "".''.$langs->trans("Status").''.$object->getLibStatut(4).''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { - $formproject=new FormProjets($db); + $formproject = new FormProjets($db); $langs->load('projects'); print ''.$langs->trans('Project').''; @@ -584,8 +584,8 @@ if (! empty($id) && $action == 'edit') } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -608,25 +608,25 @@ if (! empty($id) && $action == 'edit') /* Donation card in view mode */ /* */ /* ************************************************************ */ -if (! empty($id) && $action != 'edit') +if (!empty($id) && $action != 'edit') { // Confirmation delete if ($action == 'delete') { - $text=$langs->trans("ConfirmDeleteADonation"); + $text = $langs->trans("ConfirmDeleteADonation"); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteADonation"), $text, "confirm_delete", '', '', 1); } - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($db, $object->error); exit; } - $result=$object->fetch_optionals(); + $result = $object->fetch_optionals(); if ($result < 0) { dol_print_error($db); exit; } - $hselected='card'; + $hselected = 'card'; $head = donation_prepare_head($object); dol_fiche_head($head, $hselected, $langs->trans("Donation"), -1, 'generic'); @@ -713,7 +713,7 @@ if (! empty($id) && $action != 'edit') // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; @@ -725,15 +725,15 @@ if (! empty($id) && $action != 'edit') * Payments */ $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,"; - $sql.= "c.code as type_code,c.libelle as paiement_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as p"; - $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; - $sql.= ", ".MAIN_DB_PREFIX."don as d"; - $sql.= " WHERE d.rowid = '".$id."'"; - $sql.= " AND p.fk_donation = d.rowid"; - $sql.= " AND d.entity IN (".getEntity('donation').")"; - $sql.= " AND p.fk_typepayment = c.id"; - $sql.= " ORDER BY dp"; + $sql .= "c.code as type_code,c.libelle as paiement_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as p"; + $sql .= ", ".MAIN_DB_PREFIX."c_paiement as c "; + $sql .= ", ".MAIN_DB_PREFIX."don as d"; + $sql .= " WHERE d.rowid = '".$id."'"; + $sql .= " AND p.fk_donation = d.rowid"; + $sql .= " AND d.entity IN (".getEntity('donation').")"; + $sql .= " AND p.fk_typepayment = c.id"; + $sql .= " ORDER BY dp"; //print $sql; $resql = $db->query($sql); @@ -756,7 +756,7 @@ if (! empty($id) && $action != 'edit') print ''; print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp), 'day')."\n"; - $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type; + $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "".$labeltype.' '.$objp->num_payment."\n"; print ''.price($objp->amount)."\n"; print ""; @@ -772,7 +772,7 @@ if (! empty($id) && $action != 'edit') $remaintopay = $object->amount - $totalpaid; print "".$langs->trans("RemainderToPay")." :"; - print ''.price($remaintopay)."\n"; + print ''.price($remaintopay)."\n"; } print ""; $db->free($resql); @@ -796,16 +796,16 @@ if (! empty($id) && $action != 'edit') print '
        '; - print ''; + print ''; if ($object->statut == 0) { - print ''; + print ''; } if (($object->statut == 0 || $object->statut == 1) && $totalpaid == 0 && $object->paid == 0) { - print '"; + print '"; } // Create payment @@ -813,18 +813,18 @@ if (! empty($id) && $action != 'edit') { if ($remaintopay == 0) { - print '
        ' . $langs->trans('DoPayment') . '
        '; + print '
        '.$langs->trans('DoPayment').'
        '; } else { - print ''; + print ''; } } // Classify 'paid' if ($object->statut == 1 && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer) { - print '"; + print '"; } // Delete @@ -852,11 +852,11 @@ if (! empty($id) && $action != 'edit') /* * Documents generes */ - $filename = dol_sanitizeFileName($object->id); - $filedir = $conf->don->dir_output . "/" . dol_sanitizeFileName($object->id); - $urlsource = $_SERVER['PHP_SELF'].'?rowid='.$object->id; - $genallowed = (($object->paid == 0 || $user->admin) && $user->rights->don->lire); - $delallowed = $user->rights->don->creer; + $filename = dol_sanitizeFileName($object->id); + $filedir = $conf->don->dir_output."/".dol_sanitizeFileName($object->id); + $urlsource = $_SERVER['PHP_SELF'].'?rowid='.$object->id; + $genallowed = (($object->paid == 0 || $user->admin) && $user->rights->don->lire); + $delallowed = $user->rights->don->creer; print $formfile->showdocuments('donation', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf); diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 4e9d86af3f8..0c0ba9bf619 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -55,11 +55,11 @@ if (!$user->rights->don->lire) accessforbidden(); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $search_all=""; - $search_ref=""; - $search_company=""; - $search_name=""; - $search_amount=""; + $search_all = ""; + $search_ref = ""; + $search_company = ""; + $search_name = ""; + $search_amount = ""; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -111,9 +111,9 @@ if (trim($search_name) != '') { $sql .= natural_search(array('d.lastname', 'd.firstname'), $search_name); } -if ($search_amount) $sql.= natural_search('d.amount', $search_amount, 1); +if ($search_amount) $sql .= natural_search('d.amount', $search_amount, 1); -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -127,7 +127,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -189,7 +189,7 @@ if ($resql) print ''; print ' '; print ''; - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { print ''; print ' '; @@ -245,16 +245,16 @@ if ($resql) } print "".$donationstatic->getFullName($langs).""; print ''.dol_print_date($db->jdate($objp->datedon), 'day').''; - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { print ""; if ($objp->pid) { - $projectstatic->id=$objp->pid; - $projectstatic->ref=$objp->ref; - $projectstatic->id=$objp->pid; - $projectstatic->public=$objp->public; - $projectstatic->title=$objp->title; + $projectstatic->id = $objp->pid; + $projectstatic->ref = $objp->ref; + $projectstatic->id = $objp->pid; + $projectstatic->public = $objp->public; + $projectstatic->title = $objp->title; print $projectstatic->getNomUrl(1); } else print ' '; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 84cad7fc56f..1cf2bdb2540 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -22,12 +22,12 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; /** @@ -209,11 +209,11 @@ class EmailCollector extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -359,19 +359,19 @@ class EmailCollector extends CommonObject $obj_ret = array(); $sql = "SELECT s.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector as s"; - $sql.= ' WHERE s.entity IN ('.getEntity('emailcollector').')'; + $sql .= " FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector as s"; + $sql .= ' WHERE s.entity IN ('.getEntity('emailcollector').')'; if ($activeOnly) { - $sql.= " AND s.status = 1"; + $sql .= " AND s.status = 1"; } - $sql.= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $this->db->plimit($limit + 1, $offset); + $sql .= $this->db->plimit($limit + 1, $offset); } $result = $this->db->query($sql); @@ -392,7 +392,7 @@ class EmailCollector extends CommonObject dol_syslog('EmailCollector::fetchAll Error when retrieve emailcollector list', LOG_ERR); $ret = -1; } - if (! count($obj_ret)) { + if (!count($obj_ret)) { dol_syslog('EmailCollector::fetchAll No emailcollector found', LOG_DEBUG); } @@ -477,22 +477,22 @@ class EmailCollector extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('emailcollectordao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -546,10 +546,10 @@ class EmailCollector extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -560,7 +560,7 @@ class EmailCollector extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -574,7 +574,7 @@ class EmailCollector extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); @@ -611,19 +611,19 @@ class EmailCollector extends CommonObject $this->filters = array(); $sql = 'SELECT rowid, type, rulevalue, status'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectorfilter'; - $sql.= ' WHERE fk_emailcollector = '.$this->id; + $sql .= ' FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectorfilter'; + $sql .= ' WHERE fk_emailcollector = '.$this->id; //$sql.= ' ORDER BY position'; $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); + $num = $this->db->num_rows($resql); $i = 0; - while($i < $num) + while ($i < $num) { - $obj=$this->db->fetch_object($resql); - $this->filters[$obj->rowid]=array('id'=>$obj->rowid, 'type'=>$obj->type, 'rulevalue'=>$obj->rulevalue, 'status'=>$obj->status); + $obj = $this->db->fetch_object($resql); + $this->filters[$obj->rowid] = array('id'=>$obj->rowid, 'type'=>$obj->type, 'rulevalue'=>$obj->rulevalue, 'status'=>$obj->status); $i++; } $this->db->free($resql); @@ -643,19 +643,19 @@ class EmailCollector extends CommonObject $this->actions = array(); $sql = 'SELECT rowid, type, actionparam, status'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectoraction'; - $sql.= ' WHERE fk_emailcollector = '.$this->id; - $sql.= ' ORDER BY position'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectoraction'; + $sql .= ' WHERE fk_emailcollector = '.$this->id; + $sql .= ' ORDER BY position'; $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); + $num = $this->db->num_rows($resql); $i = 0; - while($i < $num) + while ($i < $num) { - $obj=$this->db->fetch_object($resql); - $this->actions[$obj->rowid]=array('id'=>$obj->rowid, 'type'=>$obj->type, 'actionparam'=>$obj->actionparam, 'status'=>$obj->status); + $obj = $this->db->fetch_object($resql); + $this->actions[$obj->rowid] = array('id'=>$obj->rowid, 'type'=>$obj->type, 'actionparam'=>$obj->actionparam, 'status'=>$obj->status); $i++; } $this->db->free($resql); @@ -672,9 +672,9 @@ class EmailCollector extends CommonObject public function getConnectStringIMAP() { // Connect to IMAP - $flags ='/service=imap'; // IMAP - $flags.='/ssl'; // '/tls' - $flags.='/novalidate-cert'; + $flags = '/service=imap'; // IMAP + $flags .= '/ssl'; // '/tls' + $flags .= '/novalidate-cert'; //$flags.='/readonly'; //$flags.='/debug'; @@ -698,14 +698,14 @@ class EmailCollector extends CommonObject $arrayofcollectors = $this->fetchAll($user, 1); // Loop on each collector - foreach($arrayofcollectors as $emailcollector) + foreach ($arrayofcollectors as $emailcollector) { $result = $emailcollector->doCollectOneCollector(); dol_syslog("doCollect result = ".$result." for emailcollector->id = ".$emailcollector->id); - $this->error.='EmailCollector ID '.$emailcollector->id.':'.$emailcollector->error.'
        '; - if (! empty($emailcollector->errors)) $this->error.=join('
        ', $emailcollector->errors); - $this->output.='EmailCollector ID '.$emailcollector->id.': '.$emailcollector->lastresult.'
        '; + $this->error .= 'EmailCollector ID '.$emailcollector->id.':'.$emailcollector->error.'
        '; + if (!empty($emailcollector->errors)) $this->error .= join('
        ', $emailcollector->errors); + $this->output .= 'EmailCollector ID '.$emailcollector->id.': '.$emailcollector->lastresult.'
        '; } return $nberror; @@ -858,28 +858,28 @@ class EmailCollector extends CommonObject $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; $now = dol_now(); if (empty($this->host)) { - $this->error=$langs->trans('ErrorFieldRequired', 'EMailHost'); + $this->error = $langs->trans('ErrorFieldRequired', 'EMailHost'); return -1; } if (empty($this->login)) { - $this->error=$langs->trans('ErrorFieldRequired', 'Login'); + $this->error = $langs->trans('ErrorFieldRequired', 'Login'); return -1; } if (empty($this->source_directory)) { - $this->error=$langs->trans('ErrorFieldRequired', 'MailboxSourceDirectory'); + $this->error = $langs->trans('ErrorFieldRequired', 'MailboxSourceDirectory'); return -1; } - if (! function_exists('imap_open')) + if (!function_exists('imap_open')) { - $this->error='IMAP function not enabled on your PHP'; + $this->error = 'IMAP function not enabled on your PHP'; return -2; } @@ -1061,7 +1061,7 @@ class EmailCollector extends CommonObject if ($searchfilterdoltrackid > 0) { //if (empty($headers['X-Dolibarr-TRACKID'])) continue; - if (empty($headers['References']) || ! preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) + if (empty($headers['References']) || !preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) { $nbemailprocessed++; continue; @@ -1069,7 +1069,7 @@ class EmailCollector extends CommonObject } if ($searchfilternodoltrackid > 0) { - if (! empty($headers['References']) && preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) + if (!empty($headers['References']) && preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) { $nbemailprocessed++; continue; @@ -1077,9 +1077,9 @@ class EmailCollector extends CommonObject //if (! empty($headers['X-Dolibarr-TRACKID']) continue; } - $thirdpartystatic=new Societe($this->db); - $contactstatic=new Contact($this->db); - $projectstatic=new Project($this->db); + $thirdpartystatic = new Societe($this->db); + $contactstatic = new Contact($this->db); + $projectstatic = new Project($this->db); $nbactiondoneforemail = 0; $errorforemail = 0; @@ -1184,8 +1184,8 @@ class EmailCollector extends CommonObject // References: <1542377954.SMTPs-dolibarr-tic649@8f6014fde11ec6cdec9a822234fc557e> // References: <1542377954.SMTPs-dolibarr-abc649@8f6014fde11ec6cdec9a822234fc557e> $trackid = ''; - $reg=array(); - if (! empty($headers['References']) && preg_match('/dolibarr-([a-z]+)([0-9]+)@'.preg_quote($host, '/').'/', $headers['References'], $reg)) + $reg = array(); + if (!empty($headers['References']) && preg_match('/dolibarr-([a-z]+)([0-9]+)@'.preg_quote($host, '/').'/', $headers['References'], $reg)) { $trackid = $reg[1].$reg[2]; @@ -1234,7 +1234,7 @@ class EmailCollector extends CommonObject $thirdpartyid = $objectemail->fk_soc; $contactid = $objectemail->fk_socpeople; - $projectid = isset($objectemail->fk_project)?$objectemail->fk_project:$objectemail->fk_projet; + $projectid = isset($objectemail->fk_project) ? $objectemail->fk_project : $objectemail->fk_projet; } } @@ -1303,7 +1303,7 @@ class EmailCollector extends CommonObject } // Do operations - foreach($this->actions as $operation) + foreach ($this->actions as $operation) { if ($errorforactions) break; if (empty($operation['status'])) continue; @@ -1405,7 +1405,7 @@ class EmailCollector extends CommonObject } } - if (! $errorforactions && $nametouseforthirdparty) + if (!$errorforactions && $nametouseforthirdparty) { $result = $thirdpartystatic->fetch(0, $nametouseforthirdparty); if ($result < 0) @@ -1760,14 +1760,14 @@ class EmailCollector extends CommonObject } } - if (! $errorforactions) + if (!$errorforactions) { $nbactiondoneforemail++; } } // Error for email or not ? - if (! $errorforactions) + if (!$errorforactions) { if ($targetdir) { @@ -1797,7 +1797,7 @@ class EmailCollector extends CommonObject $nbemailprocessed++; - if (! $errorforemail) + if (!$errorforemail) { $nbactiondone += $nbactiondoneforemail; $nbemailok++; @@ -1839,13 +1839,13 @@ class EmailCollector extends CommonObject if (! $error) $this->datelastok = $now; - if (! empty($this->errors)) $this->lastresult.= " - ".join(" - ", $this->errors); + if (!empty($this->errors)) $this->lastresult .= " - ".join(" - ", $this->errors); $this->codelastresult = ($error ? 'KO' : 'OK'); $this->update($user); dol_syslog("EmailCollector::doCollectOneCollector end", LOG_DEBUG); - return $error?-1:1; + return $error ?-1 : 1; } diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index d9f1cfb0189..b5c1663f86f 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -23,7 +23,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -81,7 +81,7 @@ class EmailCollectorFilter extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'fk_emailcollector' => array('type'=>'integer', 'label'=>'Id of emailcollector', 'foreignkey'=>'emailcollector.rowid'), 'type' => array('type'=>'varchar(128)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1,), @@ -124,11 +124,11 @@ class EmailCollectorFilter extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -250,7 +250,7 @@ class EmailCollectorFilter extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); return $result; } @@ -308,35 +308,35 @@ class EmailCollectorFilter extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; $companylink = ''; - $label = '' . $langs->trans("EmailcollectorFilter") . ''; - $label.= '
        '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("EmailcollectorFilter").''; + $label .= '
        '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/emailcollector/emailcollectorfilter_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowEmailcollectorFilter"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowEmailcollectorFilter"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('emailcollectorfilterdao')); @@ -345,22 +345,22 @@ class EmailCollectorFilter extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('emailcollectorfilterdao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -441,10 +441,10 @@ class EmailCollectorFilter extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -455,7 +455,7 @@ class EmailCollectorFilter extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -469,7 +469,7 @@ class EmailCollectorFilter extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 6c2753429f8..e4ead9d6f88 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -44,11 +44,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; -if (! empty($conf->projet->enabled)) { +if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -108,8 +108,8 @@ $permissiondellink=$user->rights->expedition->livraison->creer; // Used by the i * Actions */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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)) @@ -120,7 +120,7 @@ if (empty($reshook)) $object->fetch($id); // show shipment also after canceling modification } - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once // Actions to build doc $upload_dir = $conf->expedition->dir_output.'/sending'; @@ -165,7 +165,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('SHIPMENT_MODIFY'); @@ -183,21 +183,21 @@ if (empty($reshook)) // Create shipment if ($action == 'add' && $user->rights->expedition->creer) { - $error=0; - $predef=''; + $error = 0; + $predef = ''; $db->begin(); - $object->note = GETPOST('note', 'alpha'); + $object->note = GETPOST('note', 'alpha'); $object->origin = $origin; - $object->origin_id = $origin_id; - $object->fk_project = GETPOST('projectid', 'int'); - $object->weight = GETPOST('weight', 'int')==''?"NULL":GETPOST('weight', 'int'); - $object->sizeH = GETPOST('sizeH', 'int')==''?"NULL":GETPOST('sizeH', 'int'); - $object->sizeW = GETPOST('sizeW', 'int')==''?"NULL":GETPOST('sizeW', 'int'); - $object->sizeS = GETPOST('sizeS', 'int')==''?"NULL":GETPOST('sizeS', 'int'); - $object->size_units = GETPOST('size_units', 'int'); - $object->weight_units = GETPOST('weight_units', 'int'); + $object->origin_id = $origin_id; + $object->fk_project = GETPOST('projectid', 'int'); + $object->weight = GETPOST('weight', 'int') == '' ? "NULL" : GETPOST('weight', 'int'); + $object->sizeH = GETPOST('sizeH', 'int') == '' ? "NULL" : GETPOST('sizeH', 'int'); + $object->sizeW = GETPOST('sizeW', 'int') == '' ? "NULL" : GETPOST('sizeW', 'int'); + $object->sizeS = GETPOST('sizeS', 'int') == '' ? "NULL" : GETPOST('sizeS', 'int'); + $object->size_units = GETPOST('size_units', 'int'); + $object->weight_units = GETPOST('weight_units', 'int'); $date_delivery = dol_mktime(GETPOST('date_deliveryhour', 'int'), GETPOST('date_deliverymin', 'int'), 0, GETPOST('date_deliverymonth', 'int'), GETPOST('date_deliveryday', 'int'), GETPOST('date_deliveryyear', 'int')); @@ -206,36 +206,36 @@ if (empty($reshook)) $objectsrc = new $classname($db); $objectsrc->fetch($object->origin_id); - $object->socid = $objectsrc->socid; - $object->ref_customer = GETPOST('ref_customer', 'alpha'); - $object->model_pdf = GETPOST('model'); - $object->date_delivery = $date_delivery; // Date delivery planed + $object->socid = $objectsrc->socid; + $object->ref_customer = GETPOST('ref_customer', 'alpha'); + $object->model_pdf = GETPOST('model'); + $object->date_delivery = $date_delivery; // Date delivery planed $object->fk_delivery_address = $objectsrc->fk_delivery_address; $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); - $object->tracking_number = GETPOST('tracking_number', 'alpha'); - $object->ref_int = GETPOST('ref_int', 'alpha'); - $object->note_private = GETPOST('note_private', 'none'); - $object->note_public = GETPOST('note_public', 'none'); - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); + $object->tracking_number = GETPOST('tracking_number', 'alpha'); + $object->ref_int = GETPOST('ref_int', 'alpha'); + $object->note_private = GETPOST('note_private', 'none'); + $object->note_public = GETPOST('note_public', 'none'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $batch_line = array(); $stockLine = array(); - $array_options=array(); + $array_options = array(); - $num=count($objectsrc->lines); - $totalqty=0; + $num = count($objectsrc->lines); + $totalqty = 0; for ($i = 0; $i < $num; $i++) { - $idl="idl".$i; + $idl = "idl".$i; - $sub_qty=array(); - $subtotalqty=0; + $sub_qty = array(); + $subtotalqty = 0; - $j=0; - $batch="batchl".$i."_0"; - $stockLocation="ent1".$i."_0"; + $j = 0; + $batch = "batchl".$i."_0"; + $stockLocation = "ent1".$i."_0"; $qty = "qtyl".$i; if ($objectsrc->lines[$i]->product_tobatch) // If product need a batch number @@ -247,27 +247,27 @@ if (empty($reshook)) while (isset($_POST[$batch])) { // save line of detail into sub_qty - $sub_qty[$j]['q']=GETPOST($qty, 'int'); // the qty we want to move for this stock record - $sub_qty[$j]['id_batch']=GETPOST($batch, 'int'); // the id into llx_product_batch of stock record to move - $subtotalqty+=$sub_qty[$j]['q']; + $sub_qty[$j]['q'] = GETPOST($qty, 'int'); // the qty we want to move for this stock record + $sub_qty[$j]['id_batch'] = GETPOST($batch, 'int'); // the id into llx_product_batch of stock record to move + $subtotalqty += $sub_qty[$j]['q']; //var_dump($qty);var_dump($batch);var_dump($sub_qty[$j]['q']);var_dump($sub_qty[$j]['id_batch']); $j++; - $batch="batchl".$i."_".$j; + $batch = "batchl".$i."_".$j; $qty = "qtyl".$i.'_'.$j; } - $batch_line[$i]['detail']=$sub_qty; // array of details - $batch_line[$i]['qty']=$subtotalqty; - $batch_line[$i]['ix_l']=GETPOST($idl, 'int'); + $batch_line[$i]['detail'] = $sub_qty; // array of details + $batch_line[$i]['qty'] = $subtotalqty; + $batch_line[$i]['ix_l'] = GETPOST($idl, 'int'); - $totalqty+=$subtotalqty; + $totalqty += $subtotalqty; } else { // No detail were provided for lots - if (! empty($_POST[$qty])) + if (!empty($_POST[$qty])) { // We try to set an amount // Case we dont use the list of available qty for each warehouse/lot @@ -283,14 +283,14 @@ if (empty($reshook)) while (isset($_POST[$stockLocation])) { // save sub line of warehouse - $stockLine[$i][$j]['qty']=GETPOST($qty, 'int'); - $stockLine[$i][$j]['warehouse_id']=GETPOST($stockLocation, 'int'); - $stockLine[$i][$j]['ix_l']=GETPOST($idl, 'int'); + $stockLine[$i][$j]['qty'] = GETPOST($qty, 'int'); + $stockLine[$i][$j]['warehouse_id'] = GETPOST($stockLocation, 'int'); + $stockLine[$i][$j]['ix_l'] = GETPOST($idl, 'int'); - $totalqty+=GETPOST($qty, 'int'); + $totalqty += GETPOST($qty, 'int'); $j++; - $stockLocation="ent1".$i."_".$j; + $stockLocation = "ent1".$i."_".$j; $qty = "qtyl".$i.'_'.$j; } } @@ -298,7 +298,7 @@ if (empty($reshook)) { //var_dump(GETPOST($qty,'int')); var_dump($_POST); var_dump($batch);exit; //shipment line for product with no batch management and no multiple stock location - if (GETPOST($qty, 'int') > 0) $totalqty+=GETPOST($qty, 'int'); + if (GETPOST($qty, 'int') > 0) $totalqty += GETPOST($qty, 'int'); } // Extrafields @@ -320,18 +320,18 @@ if (empty($reshook)) for ($i = 0; $i < $num; $i++) { $qty = "qtyl".$i; - if (! isset($batch_line[$i])) + if (!isset($batch_line[$i])) { // not batch mode if (isset($stockLine[$i])) { //shipment from multiple stock locations $nbstockline = count($stockLine[$i]); - for($j = 0; $j < $nbstockline; $j++) + for ($j = 0; $j < $nbstockline; $j++) { - if ($stockLine[$i][$j]['qty']>0) + if ($stockLine[$i][$j]['qty'] > 0) { - $ret=$object->addline($stockLine[$i][$j]['warehouse_id'], $stockLine[$i][$j]['ix_l'], $stockLine[$i][$j]['qty'], $array_options[$i]); + $ret = $object->addline($stockLine[$i][$j]['warehouse_id'], $stockLine[$i][$j]['ix_l'], $stockLine[$i][$j]['qty'], $array_options[$i]); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -346,11 +346,11 @@ if (empty($reshook)) { $ent = "entl".$i; $idl = "idl".$i; - $entrepot_id = is_numeric(GETPOST($ent, 'int'))?GETPOST($ent, 'int'):GETPOST('entrepot_id', 'int'); - if ($entrepot_id < 0) $entrepot_id=''; - if (! ($objectsrc->lines[$i]->fk_product > 0)) $entrepot_id = 0; + $entrepot_id = is_numeric(GETPOST($ent, 'int')) ?GETPOST($ent, 'int') : GETPOST('entrepot_id', 'int'); + if ($entrepot_id < 0) $entrepot_id = ''; + if (!($objectsrc->lines[$i]->fk_product > 0)) $entrepot_id = 0; - $ret=$object->addline($entrepot_id, GETPOST($idl, 'int'), GETPOST($qty, 'int'), $array_options[$i]); + $ret = $object->addline($entrepot_id, GETPOST($idl, 'int'), GETPOST($qty, 'int'), $array_options[$i]); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -362,9 +362,9 @@ if (empty($reshook)) else { // batch mode - if ($batch_line[$i]['qty']>0) + if ($batch_line[$i]['qty'] > 0) { - $ret=$object->addline_batch($batch_line[$i], $array_options[$i]); + $ret = $object->addline_batch($batch_line[$i], $array_options[$i]); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -393,7 +393,7 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $db->commit(); header("Location: card.php?id=".$object->id); @@ -402,8 +402,8 @@ if (empty($reshook)) else { $db->rollback(); - $_GET["commande_id"]=GETPOST('commande_id', 'int'); - $action='create'; + $_GET["commande_id"] = GETPOST('commande_id', 'int'); + $action = 'create'; } } @@ -425,8 +425,8 @@ if (empty($reshook)) } elseif ($action == 'confirm_valid' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate))) ) { $object->fetch_thirdparty(); @@ -447,14 +447,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } } @@ -487,10 +487,10 @@ if (empty($reshook)) elseif ($action == 'setdate_livraison' && $user->rights->expedition->creer) { //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datedelivery=dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); + $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object->fetch($id); - $result=$object->set_date_livraison($user, $datedelivery); + $result = $object->set_date_livraison($user, $datedelivery); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -509,23 +509,23 @@ if (empty($reshook)) && $user->rights->expedition->creer ) { - $error=0; + $error = 0; if ($action == 'settracking_number') $object->tracking_number = trim(GETPOST('tracking_number', 'alpha')); if ($action == 'settracking_url') $object->tracking_url = trim(GETPOST('tracking_url', 'int')); - if ($action == 'settrueWeight') { + if ($action == 'settrueWeight') { $object->trueWeight = trim(GETPOST('trueWeight', 'int')); $object->weight_units = GETPOST('weight_units', 'int'); } if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth', 'int')); - if ($action == 'settrueHeight'){ + if ($action == 'settrueHeight') { $object->trueHeight = trim(GETPOST('trueHeight', 'int')); $object->size_units = GETPOST('size_units', 'int'); } if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth', 'int')); if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id', 'int')); - if (! $error) + if (!$error) { if ($object->update($user) >= 0) { @@ -535,15 +535,15 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - $action=""; + $action = ""; } elseif ($action == 'classifybilled') { $object->fetch($id); $result = $object->set_billed(); - if($result >= 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + if ($result >= 0) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } setEventMessages($object->error, $object->errors, 'errors'); @@ -553,8 +553,8 @@ if (empty($reshook)) { $object->fetch($id); $result = $object->setClosed(); - if($result >= 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + if ($result >= 0) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } setEventMessages($object->error, $object->errors, 'errors'); @@ -563,14 +563,14 @@ if (empty($reshook)) /* * delete a line */ - elseif ($action == 'deleteline' && ! empty($line_id)) + elseif ($action == 'deleteline' && !empty($line_id)) { $object->fetch($id); $lines = $object->lines; $line = new ExpeditionLigne($db); $num_prod = count($lines); - for ($i = 0 ; $i < $num_prod ; $i++) + for ($i = 0; $i < $num_prod; $i++) { if ($lines[$i]->id == $line_id) { @@ -579,7 +579,7 @@ if (empty($reshook)) // delete multi warehouse lines foreach ($lines[$i]->details_entrepot as $details_entrepot) { $line->id = $details_entrepot->line_id; - if (! $error && $line->delete($user) < 0) + if (!$error && $line->delete($user) < 0) { $error++; } @@ -589,7 +589,7 @@ if (empty($reshook)) { // delete single warehouse line $line->id = $line_id; - if (! $error && $line->delete($user) < 0) + if (!$error && $line->delete($user) < 0) { $error++; } @@ -598,8 +598,8 @@ if (empty($reshook)) unset($_POST["lineid"]); } - if(! $error) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + if (!$error) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } else @@ -614,13 +614,13 @@ if (empty($reshook)) elseif ($action == 'updateline' && $user->rights->expedition->creer && GETPOST('save')) { // Clean parameters - $qty=0; + $qty = 0; $entrepot_id = 0; $batch_id = 0; $lines = $object->lines; $num_prod = count($lines); - for ($i = 0 ; $i < $num_prod ; $i++) + for ($i = 0; $i < $num_prod; $i++) { if ($lines[$i]->id == $line_id) // we have found line to update { @@ -641,11 +641,11 @@ if (empty($reshook)) foreach ($lines[$i]->detail_batch as $detail_batch) { $lotStock = new Productbatch($db); - $batch="batchl".$detail_batch->fk_expeditiondet."_".$detail_batch->fk_origin_stock; + $batch = "batchl".$detail_batch->fk_expeditiondet."_".$detail_batch->fk_origin_stock; $qty = "qtyl".$detail_batch->fk_expeditiondet.'_'.$detail_batch->id; $batch_id = GETPOST($batch, 'int'); $batch_qty = GETPOST($qty, 'int'); - if (! empty($batch_id) && ($batch_id != $detail_batch->fk_origin_stock || $batch_qty != $detail_batch->qty)) + if (!empty($batch_id) && ($batch_id != $detail_batch->fk_origin_stock || $batch_qty != $detail_batch->qty)) { if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) // $line is ExpeditionLine { @@ -656,7 +656,7 @@ if (empty($reshook)) } // detail_batch can be an object with keys, or an array of ExpeditionLineBatch - if (empty($line->detail_batch)) $line->detail_batch=new stdClass(); + if (empty($line->detail_batch)) $line->detail_batch = new stdClass(); $line->detail_batch->fk_origin_stock = $batch_id; $line->detail_batch->batch = $lotStock->batch; @@ -679,12 +679,12 @@ if (empty($reshook)) } // add new batch $lotStock = new Productbatch($db); - $batch="batchl".$line_id."_0"; + $batch = "batchl".$line_id."_0"; $qty = "qtyl".$line_id."_0"; $batch_id = GETPOST($batch, 'int'); $batch_qty = GETPOST($qty, 'int'); $lineIdToAddLot = 0; - if ($batch_qty > 0 && ! empty($batch_id)) + if ($batch_qty > 0 && !empty($batch_id)) { if ($lotStock->fetch($batch_id) > 0) { @@ -760,7 +760,7 @@ if (empty($reshook)) if ($lines[$i]->entrepot_id > 0) { // single warehouse shipment line - $stockLocation="entl".$line_id; + $stockLocation = "entl".$line_id; $qty = "qtyl".$line_id; $line->id = $line_id; $line->entrepot_id = GETPOST($stockLocation, 'int'); @@ -777,8 +777,8 @@ if (empty($reshook)) // multi warehouse shipment lines foreach ($lines[$i]->details_entrepot as $detail_entrepot) { - if (! $error) { - $stockLocation="entl".$detail_entrepot->line_id; + if (!$error) { + $stockLocation = "entl".$detail_entrepot->line_id; $qty = "qtyl".$detail_entrepot->line_id; $warehouse = GETPOST($stockLocation, 'int'); if (!empty($warehouse)) @@ -816,7 +816,7 @@ if (empty($reshook)) unset($_POST["lineid"]); - if (! $error) { + if (!$error) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -825,7 +825,7 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -836,22 +836,22 @@ if (empty($reshook)) } else { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // To redisplay the form being edited + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // To redisplay the form being edited exit(); } } elseif ($action == 'updateline' && $user->rights->expedition->creer && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // To redisplay the form being edited + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // To redisplay the form being edited exit(); } include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - if (empty($id)) $id=$facid; - $trigger_name='SHIPPING_SENTBYMAIL'; - $paramname='id'; - $mode='emailfromshipment'; - $trackid='shi'.$object->id; + if (empty($id)) $id = $facid; + $trigger_name = 'SHIPPING_SENTBYMAIL'; + $paramname = 'id'; + $mode = 'emailfromshipment'; + $trackid = 'shi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -865,7 +865,7 @@ llxHeader('', $langs->trans('Shipment'), 'Expedition'); $form = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $product_static = new Product($db); $shipment_static = new Expedition($db); @@ -875,7 +875,7 @@ if ($action == 'create2') { print load_fiche_titre($langs->trans("CreateShipment")).'
        '; print $langs->trans("ShipmentCreationIsDoneFromOrder"); - $action=''; $id=''; $ref=''; + $action = ''; $id = ''; $ref = ''; } // Mode creation. @@ -884,7 +884,7 @@ if ($action == 'create') $expe = new Expedition($db); print load_fiche_titre($langs->trans("CreateShipment")); - if (! $origin) + if (!$origin) { setEventMessages($langs->trans("ErrorBadParameters"), null, 'errors'); } @@ -902,7 +902,7 @@ if ($action == 'create') $author = new User($db); $author->fetch($object->user_author_id); - if (! empty($conf->stock->enabled)) $entrepot = new Entrepot($db); + if (!empty($conf->stock->enabled)) $entrepot = new Entrepot($db); print ''; print ''; @@ -921,11 +921,11 @@ if ($action == 'create') // Ref print ''; - if ($origin == 'commande' && ! empty($conf->commande->enabled)) + if ($origin == 'commande' && !empty($conf->commande->enabled)) { print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"), 'order').' '.$object->ref; } - if ($origin == 'propal' && ! empty($conf->propal->enabled)) + if ($origin == 'propal' && !empty($conf->propal->enabled)) { print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"), 'propal').' '.$object->ref; } @@ -948,17 +948,17 @@ if ($action == 'create') print ''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { - $projectid = GETPOST('projectid', 'int')?GETPOST('projectid', 'int'):0; - if(empty($projectid) && ! empty($object->fk_project)) $projectid = $object->fk_project; + $projectid = GETPOST('projectid', 'int') ?GETPOST('projectid', 'int') : 0; + if (empty($projectid) && !empty($object->fk_project)) $projectid = $object->fk_project; if ($origin == 'project') $projectid = ($originid ? $originid : 0); $langs->load("projects"); print ''; - print '' . $langs->trans("Project") . ''; + print ''.$langs->trans("Project").''; $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id).'">'.$langs->trans("AddProject").''; print ''; print ''; } @@ -967,8 +967,8 @@ if ($action == 'create') print ''.$langs->trans("DateDeliveryPlanned").''; print ''; //print dol_print_date($object->date_livraison, "day"); // date_livraison come from order and will be stored into date_delivery planed. - $date_delivery = ($date_delivery?$date_delivery:$object->date_livraison); // $date_delivery comes from GETPOST - print $form->selectDate($date_delivery?$date_delivery:-1, 'date_delivery', 1, 1, 1); + $date_delivery = ($date_delivery ? $date_delivery : $object->date_livraison); // $date_delivery comes from GETPOST + print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); print "\n"; print ''; @@ -1025,7 +1025,7 @@ if ($action == 'create') // Other attributes $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $expe, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $expe, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1043,12 +1043,12 @@ if ($action == 'create') print ''; print ''; print ''; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:'')); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print ''; } // Document model - include_once DOL_DOCUMENT_ROOT . '/core/modules/expedition/modules_expedition.php'; + include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; $liste = ModelePdfExpedition::liste_modeles($db); if (count($liste) > 1) { @@ -1108,7 +1108,7 @@ if ($action == 'create') print ' / '.$langs->trans("Reset").')'; } print ''; - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { if (empty($conf->productbatch->enabled)) { @@ -1136,11 +1136,11 @@ if ($action == 'create') if (empty($reshook)) { // Show product and description - $type=$line->product_type?$line->product_type:$line->fk_product_type; + $type = $line->product_type ? $line->product_type : $line->fk_product_type; // Try to enhance type detection using date_start and date_end for free lines where type // was not saved. - if (! empty($line->date_start)) $type=1; - if (! empty($line->date_end)) $type=1; + if (!empty($line->date_start)) $type = 1; + if (!empty($line->date_end)) $type = 1; print ''."\n"; print ''."\n"; @@ -1149,29 +1149,29 @@ if ($action == 'create') if ($line->fk_product > 0) // If predefined product { $product->fetch($line->fk_product); - $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch + $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch //var_dump($product->stock_warehouse[1]); print ''; print ''; // ancre pour retourner sur la ligne // Show product and description - $product_static->type=$line->fk_product_type; - $product_static->id=$line->fk_product; - $product_static->ref=$line->ref; - $product_static->status_batch=$line->product_tobatch; - $text=$product_static->getNomUrl(1); - $text.= ' - '.(! empty($line->label)?$line->label:$line->product_label); - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->desc)); + $product_static->type = $line->fk_product_type; + $product_static->id = $line->fk_product; + $product_static->ref = $line->ref; + $product_static->status_batch = $line->product_tobatch; + $text = $product_static->getNomUrl(1); + $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); + $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc)); print $form->textwithtooltip($text, $description, 3, '', '', $i); // Show range print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print ($line->desc && $line->desc!=$line->product_label)?'
        '.dol_htmlentitiesbr($line->desc):''; + print ($line->desc && $line->desc != $line->product_label) ? '
        '.dol_htmlentitiesbr($line->desc) : ''; } print ''; @@ -1179,11 +1179,11 @@ if ($action == 'create') else { print ""; - if ($type==1) $text = img_object($langs->trans('Service'), 'service'); + if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); - if (! empty($line->label)) { - $text.= ' '.$line->label.''; + if (!empty($line->label)) { + $text .= ' '.$line->label.''; print $form->textwithtooltip($text, $line->desc, 3, '', '', $i); } else { print $text.' '.nl2br($line->desc); @@ -1198,7 +1198,7 @@ if ($action == 'create') print ''.$line->qty; print ''; print ''; - $qtyProdCom=$line->qty; + $qtyProdCom = $line->qty; // Qty already shipped print ''; @@ -1220,20 +1220,20 @@ if ($action == 'create') $warehouse_id = GETPOST('entrepot_id', 'int'); $warehouseObject = null; - if ($warehouse_id > 0 || ! ($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection + if ($warehouse_id > 0 || !($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection { print ''; //ship from preselected location $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number - $deliverableQty=min($quantityToBeDelivered, $stock); + $deliverableQty = min($quantityToBeDelivered, $stock); if ($deliverableQty < 0) $deliverableQty = 0; - if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) + if (empty($conf->productbatch->enabled) || !$product->hasbatch()) { // Quantity to send print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty=GETPOST('qtyl'.$indiceAsked, 'int'); + if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty = GETPOST('qtyl'.$indiceAsked, 'int'); print ''; print ''; } @@ -1241,15 +1241,15 @@ if ($action == 'create') print ''; // Stock - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? + if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? { // Show warehouse combo list $ent = "entl".$indiceAsked; $idl = "idl".$indiceAsked; - $tmpentrepot_id = is_numeric(GETPOST($ent, 'int'))?GETPOST($ent, 'int'):$warehouse_id; + $tmpentrepot_id = is_numeric(GETPOST($ent, 'int')) ?GETPOST($ent, 'int') : $warehouse_id; if ($line->fk_product > 0) { print ''; @@ -1265,7 +1265,7 @@ if ($action == 'create') //print $stock.' '.$quantityToBeDelivered; if ($stock < $quantityToBeDelivered) { - print ' '.img_warning($langs->trans("StockTooLow")); // Stock too low for this $warehouse_id but you can change warehouse + print ' '.img_warning($langs->trans("StockTooLow")); // Stock too low for this $warehouse_id but you can change warehouse } } } @@ -1280,19 +1280,19 @@ if ($action == 'create') print "\n"; // Show subproducts of product - if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) + if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) { $product->get_sousproduits_arbo(); $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); - if(count($prods_arbo) > 0) + if (count($prods_arbo) > 0) { - foreach($prods_arbo as $key => $value) + foreach ($prods_arbo as $key => $value) { //print $value[0]; - $img=''; + $img = ''; if ($value['stock'] < $value['stock_alert']) { - $img=img_warning($langs->trans("StockTooLow")); + $img = img_warning($langs->trans("StockTooLow")); } print "      -> ".$value['fullpath']." @@ -1305,15 +1305,15 @@ if ($action == 'create') else { // Product need lot - print ''; // end line and start a new one for lot/serial + print ''; // end line and start a new one for lot/serial print ''; - $staticwarehouse=new Entrepot($db); + $staticwarehouse = new Entrepot($db); if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id); - $subj=0; + $subj = 0; // Define nb of lines suggested for this order line - $nbofsuggested=0; + $nbofsuggested = 0; if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) { foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) @@ -1327,9 +1327,9 @@ if ($action == 'create') foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) // $dbatch is instance of Productbatch { //var_dump($dbatch); - $batchStock = + $dbatch->qty; // To get a numeric + $batchStock = + $dbatch->qty; // To get a numeric $deliverableQty = min($quantityToBeDelivered, $batchStock); - print ''; + print ''; print ''; print ''; print ''; @@ -1341,12 +1341,12 @@ if ($action == 'create') print ''; - $detail=''; - $detail.= $langs->trans("Batch").': '.$dbatch->batch; - $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); - $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); - $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; - $detail.= '
        '; + $detail = ''; + $detail .= $langs->trans("Batch").': '.$dbatch->batch; + $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); + $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); + $detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty; + $detail .= '
        '; print $detail; $quantityToBeDelivered -= $deliverableQty; @@ -1374,15 +1374,15 @@ if ($action == 'create') else { // ship from multiple locations - if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) + if (empty($conf->productbatch->enabled) || !$product->hasbatch()) { print ''; - print ''."\n"; // end line and start a new one for each warehouse + print ''."\n"; // end line and start a new one for each warehouse print ''; - $subj=0; + $subj = 0; // Define nb of lines suggested for this order line - $nbofsuggested=0; + $nbofsuggested = 0; foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) { if ($stock_warehouse->real > 0) @@ -1390,7 +1390,7 @@ if ($action == 'create') $nbofsuggested++; } } - $tmpwarehouseObject=new Entrepot($db); + $tmpwarehouseObject = new Entrepot($db); foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock { $tmpwarehouseObject->fetch($warehouse_id); @@ -1400,9 +1400,9 @@ if ($action == 'create') $deliverableQty = min($quantityToBeDelivered, $stock); $deliverableQty = max(0, $deliverableQty); // Quantity to send - print ''; + print ''; print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { print ''; print ''; @@ -1411,10 +1411,10 @@ if ($action == 'create') print ''; // Stock - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { print $tmpwarehouseObject->getNomUrl(0).' '; @@ -1437,19 +1437,19 @@ if ($action == 'create') } } // Show subproducts of product (not recommanded) - if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) + if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) { $product->get_sousproduits_arbo(); $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); if (count($prods_arbo) > 0) { - foreach($prods_arbo as $key => $value) + foreach ($prods_arbo as $key => $value) { //print $value[0]; - $img=''; + $img = ''; if ($value['stock'] < $value['stock_alert']) { - $img=img_warning($langs->trans("StockTooLow")); + $img = img_warning($langs->trans("StockTooLow")); } print ''; print "      -> @@ -1464,15 +1464,15 @@ if ($action == 'create') else { print ''; - print ''; // end line and start a new one for lot/serial + print ''; // end line and start a new one for lot/serial - $subj=0; + $subj = 0; print ''; - $tmpwarehouseObject=new Entrepot($db); - $productlotObject=new Productlot($db); + $tmpwarehouseObject = new Entrepot($db); + $productlotObject = new Productlot($db); // Define nb of lines suggested for this order line - $nbofsuggested=0; + $nbofsuggested = 0; foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) { if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { @@ -1489,10 +1489,10 @@ if ($action == 'create') foreach ($stock_warehouse->detail_batch as $dbatch) { //var_dump($dbatch); - $batchStock = + $dbatch->qty; // To get a numeric + $batchStock = + $dbatch->qty; // To get a numeric $deliverableQty = min($quantityToBeDelivered, $batchStock); if ($deliverableQty < 0) $deliverableQty = 0; - print ''; + print ''; print ''; print ''; @@ -1525,14 +1525,14 @@ if ($action == 'create') { print ''; print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $disabled=''; - if (! empty($conf->productbatch->enabled) && $product->hasbatch()) + $disabled = ''; + if (!empty($conf->productbatch->enabled) && $product->hasbatch()) { - $disabled='disabled="disabled"'; + $disabled = 'disabled="disabled"'; } - print ' '; + print ' '; } else { @@ -1541,12 +1541,12 @@ if ($action == 'create') print ''; print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $warehouse_selected_id = GETPOST('entrepot_id', 'int'); if ($warehouse_selected_id > 0) { - $warehouseObject=new Entrepot($db); + $warehouseObject = new Entrepot($db); $warehouseObject->fetch($warehouse_selected_id); print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->label); } @@ -1591,7 +1591,7 @@ if ($action == 'create') print '
        '; print ''; print '  '; - print ''; // Cancel for create does not post form if we don't know the backtopage + print ''; // Cancel for create does not post form if we don't know the backtopage print '
        '; print ''; @@ -1622,7 +1622,7 @@ elseif ($id || $ref) $typeobject = $object->origin; $origin = $object->origin; $origin_id = $object->origin_id; - $object->fetch_origin(); // Load property $object->commande, $object->propal, ... + $object->fetch_origin(); // Load property $object->commande, $object->propal, ... } $soc = new Societe($db); @@ -1675,27 +1675,27 @@ elseif ($id || $ref) $text = $langs->trans("ConfirmValidateSending", $numref); - if (! empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; - $notify=new Notify($db); - $text.='
        '; - $text.=$notify->confirmMessage('SHIPPING_VALIDATE', $object->socid, $object); + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
        '; + $text .= $notify->confirmMessage('SHIPPING_VALIDATE', $object->socid, $object); } - $formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1); } // Confirm cancelation if ($action == 'annuler') { - $formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('CancelSending'), $langs->trans("ConfirmCancelSending", $object->ref), 'confirm_cancel', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('CancelSending'), $langs->trans("ConfirmCancelSending", $object->ref), 'confirm_cancel', '', 0, 1); } // Call Hook formConfirm $parameters = array(); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -1760,7 +1760,7 @@ elseif ($id || $ref) } } } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -1773,7 +1773,7 @@ elseif ($id || $ref) print ''; // Linked documents - if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled)) + if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) { print ''; @@ -1782,7 +1782,7 @@ elseif ($id || $ref) print "\n"; print ''; } - if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled)) + if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) { print ''; @@ -1811,7 +1811,7 @@ elseif ($id || $ref) print ''; print ''; print ''; - print $form->selectDate($object->date_delivery?$object->date_delivery:-1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); + print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); print ''; print ''; } @@ -1827,7 +1827,7 @@ elseif ($id || $ref) print $form->editfieldkey("Weight", 'trueWeight', $object->trueWeight, $object, $user->rights->expedition->creer); print ''; print '
        '; print $langs->trans("RefOrder").'
        '; print $langs->trans("RefProposal").'
        '; - if ($action=='edittrueWeight') + if ($action == 'edittrueWeight') { print '
        '; print ''; @@ -1893,12 +1893,12 @@ elseif ($id || $ref) print $langs->trans("Volume"); print '
        '; - $calculatedVolume=0; - $volumeUnit=0; + $calculatedVolume = 0; + $volumeUnit = 0; if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth); - $volumeUnit=$object->size_units * 3; + $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); + $volumeUnit = $object->size_units * 3; } // If sending volume not defined we use sum of products if ($calculatedVolume > 0) @@ -1921,7 +1921,7 @@ elseif ($id || $ref) // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
        '; @@ -1957,7 +1957,7 @@ elseif ($id || $ref) if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code=$langs->getLabelFromKey($db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + $code = $langs->getLabelFromKey($db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); print $langs->trans("SendingMethod".strtoupper($code)); } } @@ -1987,14 +1987,14 @@ elseif ($id || $ref) } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print ''; } // Other attributes $parameters = array('colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ""; @@ -2010,11 +2010,11 @@ elseif ($id || $ref) if ($action == 'editline') { - print ' - + print ' + - + '; } print '
        '; @@ -2024,7 +2024,7 @@ elseif ($id || $ref) print ''; print ''; // Adds a line numbering column - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print ' '; } @@ -2050,11 +2050,11 @@ elseif ($id || $ref) { print $langs->trans("QtyShipped").' - '; } - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { print $langs->trans("WarehouseSource").' - '; } - if (! empty($conf->productbatch->enabled)) + if (!empty($conf->productbatch->enabled)) { print $langs->trans("Batch"); } @@ -2110,22 +2110,22 @@ elseif ($id || $ref) if ($origin && $origin_id > 0) { $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end"; - $sql.= ", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot"; - $sql.= ", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition"; + $sql .= ", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot"; + $sql .= ", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition"; //if ($conf->livraison_bon->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; - $sql.= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch'; - $sql.= ', p.description as product_desc'; - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; - $sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj"; + $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch'; + $sql .= ', p.description as product_desc'; + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; + $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; - $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; - $sql.= " AND obj.fk_".$origin." = ".$origin_id; - $sql.= " AND obj.rowid = ed.fk_origin_line"; - $sql.= " AND ed.fk_expedition = e.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; + $sql .= " AND obj.fk_".$origin." = ".$origin_id; + $sql .= " AND obj.rowid = ed.fk_origin_line"; + $sql .= " AND ed.fk_expedition = e.rowid"; //if ($filter) $sql.= $filter; - $sql.= " ORDER BY obj.fk_product"; + $sql .= " ORDER BY obj.fk_product"; dol_syslog("get list of shipment lines", LOG_DEBUG); $resql = $db->query($sql); @@ -2134,13 +2134,13 @@ elseif ($id || $ref) $num = $db->num_rows($resql); $i = 0; - while($i < $num) + while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { // $obj->rowid is rowid in $origin."det" table - $alreadysent[$obj->rowid][$obj->shipmentline_id]=array('shipment_ref'=>$obj->shipment_ref, 'shipment_id'=>$obj->shipment_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty_shipped, 'date_valid'=>$db->jdate($obj->date_valid), 'date_delivery'=>$db->jdate($obj->date_delivery)); + $alreadysent[$obj->rowid][$obj->shipmentline_id] = array('shipment_ref'=>$obj->shipment_ref, 'shipment_id'=>$obj->shipment_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty_shipped, 'date_valid'=>$db->jdate($obj->date_valid), 'date_delivery'=>$db->jdate($obj->date_delivery)); } $i++; } @@ -2218,8 +2218,8 @@ elseif ($id || $ref) if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); - if (! empty($lines[$i]->label)) { - $text.= ' '.$lines[$i]->label.''; + if (!empty($lines[$i]->label)) { + $text .= ' '.$lines[$i]->label.''; print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); } else { print $text.' '.nl2br($lines[$i]->description); @@ -2241,7 +2241,7 @@ elseif ($id || $ref) if ($lines[$i]->fk_origin_line == $key) { $j = 0; - foreach($val as $shipmentline_id=> $shipmentline_var) + foreach ($val as $shipmentline_id=> $shipmentline_var) { if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) continue; // We want to show only "other shipments" @@ -2250,8 +2250,8 @@ elseif ($id || $ref) $shipment_static->fetch($shipmentline_var['shipment_id']); print $shipment_static->getNomUrl(1); print ' - '.$shipmentline_var['qty_shipped']; - $htmltext=$langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid'])?$langs->trans("Draft"):dol_print_date($shipmentline_var['date_valid'], 'dayhour')); - if (! empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0) + $htmltext = $langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($shipmentline_var['date_valid'], 'dayhour')); + if (!empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0) { $warehousestatic->fetch($shipmentline_var['warehouse']); $htmltext .= '
        '.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); @@ -2275,25 +2275,25 @@ elseif ($id || $ref) { print ''; // Qty to ship or shipped - print '' . '' . ''; + print ''.''.''; // Batch number managment if ($lines[$i]->entrepot_id == 0) { // only show lot numbers from src warehouse when shipping from multiple warehouses $line->fetch($detail_batch->fk_expeditiondet); } - print '' . $formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id). ''; + print ''.$formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id).''; print ''; } // add a 0 qty lot row to be able to add a lot print ''; // Qty to ship or shipped - print '' . '' . ''; + print ''.''.''; // Batch number managment - print '' . $formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product). ''; + print ''.$formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product).''; print ''; } - elseif (! empty($conf->stock->enabled)) + elseif (!empty($conf->stock->enabled)) { if ($lines[$i]->fk_product > 0) { @@ -2302,11 +2302,11 @@ elseif ($id || $ref) print ''; print ''; // Qty to ship or shipped - print '' . '' . ''; + print ''.''.''; // Warehouse source - print '' . $formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1). ''; + print ''.$formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).''; // Batch number managment - print ' - ' . $langs->trans("NA") . ''; + print ' - '.$langs->trans("NA").''; print ''; } elseif (count($lines[$i]->details_entrepot) > 1) @@ -2316,11 +2316,11 @@ elseif ($id || $ref) { print ''; // Qty to ship or shipped - print '' . '' . ''; + print ''.''.''; // Warehouse source - print '' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1) . ''; + print ''.$formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).''; // Batch number managment - print ' - ' . $langs->trans("NA") . ''; + print ' - '.$langs->trans("NA").''; print ''; } } @@ -2335,11 +2335,11 @@ elseif ($id || $ref) print ''; print ''; // Qty to ship or shipped - print '' . '' . ''; + print ''.''.''; // Warehouse source - print '' . ''; + print ''.''; // Batch number managment - print '' . ''; + print ''.''; print ''; } } @@ -2352,7 +2352,7 @@ elseif ($id || $ref) print ''.$lines[$i]->qty_shipped.''; // Warehouse source - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { print ''; if ($lines[$i]->entrepot_id > 0) @@ -2370,7 +2370,7 @@ elseif ($id || $ref) { $entrepot = new Entrepot($db); $entrepot->fetch($detail_entrepot->entrepot_id); - $detail.= $langs->trans("DetailWarehouseFormat", $entrepot->libelle, $detail_entrepot->qty_shipped).'
        '; + $detail .= $langs->trans("DetailWarehouseFormat", $entrepot->libelle, $detail_entrepot->qty_shipped).'
        '; } } print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"), $detail); @@ -2379,7 +2379,7 @@ elseif ($id || $ref) } // Batch number managment - if (! empty($conf->productbatch->enabled)) + if (!empty($conf->productbatch->enabled)) { if (isset($lines[$i]->detail_batch)) { @@ -2390,11 +2390,11 @@ elseif ($id || $ref) $detail = ''; foreach ($lines[$i]->detail_batch as $dbatch) // $dbatch is instance of ExpeditionLineBatch { - $detail.= $langs->trans("Batch").': '.$dbatch->batch; - $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); - $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); - $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; - $detail.= '
        '; + $detail .= $langs->trans("Batch").': '.$dbatch->batch; + $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); + $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); + $detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty; + $detail .= '
        '; } print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); } @@ -2503,8 +2503,8 @@ elseif ($id || $ref) { if ($object->statut == Expedition::STATUS_DRAFT && $num_prod > 0) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate))) + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate))) { print '
        '.$langs->trans("Validate").''; } @@ -2518,7 +2518,7 @@ elseif ($id || $ref) // 0=draft, 1=validated, 2=billed, we miss a status "delivered" (only available on order) if ($object->statut == Expedition::STATUS_CLOSED && $user->rights->expedition->creer) { - if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? + if (!empty($conf->facture->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? { print ''.$langs->trans("ClassifyUnbilled").''; } @@ -2539,7 +2539,7 @@ elseif ($id || $ref) } // Create bill - if (! empty($conf->facture->enabled) && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED)) + if (!empty($conf->facture->enabled) && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED)) { if ($user->rights->facture->creer) { @@ -2558,14 +2558,14 @@ elseif ($id || $ref) // Close if ($object->statut == Expedition::STATUS_VALIDATED) { - if ($user->rights->expedition->creer && $object->statut > 0 && ! $object->billed) + if ($user->rights->expedition->creer && $object->statut > 0 && !$object->billed) { - $label="Close"; $paramaction='classifyclosed'; // = Transferred/Received + $label = "Close"; $paramaction = 'classifyclosed'; // = Transferred/Received // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on shipments instead of orders - if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? + if (!empty($conf->facture->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? { - $label="ClassifyBilled"; - $paramaction='classifybilled'; + $label = "ClassifyBilled"; + $paramaction = 'classifybilled'; } print ''.$langs->trans($label).''; } @@ -2590,12 +2590,12 @@ elseif ($id || $ref) print '
        '; $objectref = dol_sanitizeFileName($object->ref); - $filedir = $conf->expedition->dir_output . "/sending/" .$objectref; + $filedir = $conf->expedition->dir_output."/sending/".$objectref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$user->rights->expedition->lire; - $delallowed=$user->rights->expedition->creer; + $genallowed = $user->rights->expedition->lire; + $delallowed = $user->rights->expedition->creer; print $formfile->showdocuments('expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); @@ -2609,7 +2609,7 @@ elseif ($id || $ref) // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); + $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'shipping', $socid, 1); print '
        '; @@ -2626,9 +2626,9 @@ elseif ($id || $ref) } // Presend form - $modelmail='shipping_send'; - $defaulttopic='SendShippingRef'; - $diroutput = $conf->expedition->dir_output. '/sending'; + $modelmail = 'shipping_send'; + $defaulttopic = 'SendShippingRef'; + $diroutput = $conf->expedition->dir_output.'/sending'; $trackid = 'shi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b55d4df0563..18132a5c4f5 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -35,9 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT."/core/class/commonobjectline.class.php"; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; /** @@ -48,22 +48,22 @@ class Expedition extends CommonObject /** * @var string ID to identify managed object */ - public $element="shipping"; + public $element = "shipping"; /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element="fk_expedition"; + public $fk_element = "fk_expedition"; /** * @var string Name of table without prefix where object is stored */ - public $table_element="expedition"; + public $table_element = "expedition"; /** * @var int Name of subtable line */ - public $table_element_line="expeditiondet"; + public $table_element_line = "expeditiondet"; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -94,7 +94,7 @@ class Expedition extends CommonObject * @var int warehouse id */ public $entrepot_id; - public $lines=array(); + public $lines = array(); /** * @var string Tracking number @@ -157,7 +157,7 @@ class Expedition extends CommonObject public $date_valid; public $meths; - public $listmeths; // List of carriers + public $listmeths; // List of carriers /** * Draft status @@ -229,10 +229,10 @@ class Expedition extends CommonObject $dir = dol_buildpath($reldir."core/modules/expedition/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } - if (! $mybool) + if (!$mybool) { dol_print_error('', "Failed to include file ".$file); return ''; @@ -242,7 +242,7 @@ class Expedition extends CommonObject $numref = ""; $numref = $obj->getNextValue($soc, $this); - if ( $numref != "") + if ($numref != "") { return $numref; } @@ -270,9 +270,9 @@ class Expedition extends CommonObject { global $conf, $hookmanager; - $now=dol_now(); + $now = dol_now(); - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $error = 0; // Clean parameters @@ -379,42 +379,42 @@ class Expedition extends CommonObject } // Actions on extra fields - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('SHIPPING_CREATE', $user); + $result = $this->call_trigger('SHIPPING_CREATE', $user); if ($result < 0) { $error++; } // End call triggers - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else { $error++; - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -3; } @@ -422,7 +422,7 @@ class Expedition extends CommonObject else { $error++; - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -2; } @@ -430,7 +430,7 @@ class Expedition extends CommonObject else { $error++; - $this->error=$this->db->error()." - sql=$sql"; + $this->error = $this->db->error()." - sql=$sql"; $this->db->rollback(); return -1; } @@ -462,7 +462,7 @@ class Expedition extends CommonObject if (($lineId = $expeditionline->insert($user)) < 0) { - $this->errors[]=$expeditionline->error; + $this->errors[] = $expeditionline->error; } return $lineId; } @@ -482,7 +482,7 @@ class Expedition extends CommonObject $error = 0; $stockLocationQty = array(); // associated array with batch qty in stock location - $tab=$line_ext->detail_batch; + $tab = $line_ext->detail_batch; // create stockLocation Qty array foreach ($tab as $detbatch) { @@ -503,8 +503,8 @@ class Expedition extends CommonObject // create shipment batch lines for stockLocation foreach ($tab as $detbatch) { - if ($detbatch->entrepot_id == $stockLocation){ - if (! ($detbatch->create($line_id) >0)) // Create an expeditionlinebatch + if ($detbatch->entrepot_id == $stockLocation) { + if (!($detbatch->create($line_id) > 0)) // Create an expeditionlinebatch { $error++; } @@ -513,7 +513,7 @@ class Expedition extends CommonObject } } - if (! $error) return 1; + if (!$error) return 1; else return -1; } @@ -617,7 +617,7 @@ class Expedition extends CommonObject /* * Thirdparty */ - $result=$this->fetch_thirdparty(); + $result = $this->fetch_thirdparty(); // Retreive extrafields $this->fetch_optionals(); @@ -625,7 +625,7 @@ class Expedition extends CommonObject /* * Lines */ - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { return -3; @@ -636,13 +636,13 @@ class Expedition extends CommonObject else { dol_syslog(get_class($this).'::Fetch no expedition found', LOG_ERR); - $this->error='Delivery with id '.$id.' not found'; + $this->error = 'Delivery with id '.$id.' not found'; return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -669,10 +669,10 @@ class Expedition extends CommonObject return 0; } - if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate)))) + if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate)))) { - $this->error='Permission denied'; + $this->error = 'Permission denied'; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); return -1; } @@ -686,10 +686,10 @@ class Expedition extends CommonObject $soc->fetch($this->socid); // Class of company linked to order - $result=$soc->set_as_client(); + $result = $soc->set_as_client(); // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $numref = $this->getNextNumRef($soc); } @@ -699,26 +699,26 @@ class Expedition extends CommonObject } $this->newref = $numref; - $now=dol_now(); + $now = dol_now(); // Validate $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sql.= " ref='".$numref."'"; - $sql.= ", fk_statut = 1"; - $sql.= ", date_valid = '".$this->db->idate($now)."'"; - $sql.= ", fk_user_valid = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " ref='".$numref."'"; + $sql .= ", fk_statut = 1"; + $sql .= ", date_valid = '".$this->db->idate($now)."'"; + $sql .= ", fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::valid update expedition", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } // If stock increment is done on sending (recommanded choice) - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -726,16 +726,16 @@ class Expedition extends CommonObject // Loop on each product line to add a stock movement $sql = "SELECT cd.fk_product, cd.subprice,"; - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; - $sql.= " WHERE ed.fk_expedition = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_origin_line"; + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; + $sql .= " WHERE ed.fk_expedition = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_origin_line"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -789,7 +789,7 @@ class Expedition extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -2; } } @@ -797,20 +797,20 @@ class Expedition extends CommonObject // Change status of order to "shipment in process" $ret = $this->setStatut(Commande::STATUS_SHIPMENTONPROCESS, $this->origin_id, $this->origin); - if (! $ret) + if (!$ret) { $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('SHIPPING_VALIDATE', $user); + $result = $this->call_trigger('SHIPPING_VALIDATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -836,13 +836,13 @@ class Expedition extends CommonObject { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->expedition->dir_output.'/sending/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->expedition->dir_output.'/sending/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -889,14 +889,14 @@ class Expedition extends CommonObject // Expedition validee include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; $delivery = new Livraison($this->db); - $result=$delivery->create_from_sending($user, $this->id); + $result = $delivery->create_from_sending($user, $this->id); if ($result > 0) { return $result; } else { - $this->error=$delivery->error; + $this->error = $delivery->error; return $result; } } @@ -933,22 +933,22 @@ class Expedition extends CommonObject // Copy the rang of the order line to the expedition line $line->rang = $orderline->rang; - if (! empty($conf->stock->enabled) && ! empty($orderline->fk_product)) + if (!empty($conf->stock->enabled) && !empty($orderline->fk_product)) { $fk_product = $orderline->fk_product; - if (! ($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS)) + if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS)) { $langs->load("errors"); - $this->error=$langs->trans("ErrorWarehouseRequiredIntoShipmentLine"); + $this->error = $langs->trans("ErrorWarehouseRequiredIntoShipmentLine"); return -1; } if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { // Check must be done for stock of product into warehouse if $entrepot_id defined - $product=new Product($this->db); - $result=$product->fetch($fk_product); + $product = new Product($this->db); + $result = $product->fetch($fk_product); if ($entrepot_id > 0) { $product->load_stock('warehouseopen'); @@ -957,11 +957,11 @@ class Expedition extends CommonObject else $product_stock = $product->stock_reel; - $product_type=$product->type; + $product_type = $product->type; if ($product_type == 0 && $product_stock < $qty) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $product->ref); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $product->ref); $this->db->rollback(); return -3; } @@ -969,14 +969,14 @@ class Expedition extends CommonObject } // If product need a batch number, we should not have called this function but addline_batch instead. - if (! empty($conf->productbatch->enabled) && ! empty($orderline->fk_product) && ! empty($orderline->product_tobatch)) + if (!empty($conf->productbatch->enabled) && !empty($orderline->fk_product) && !empty($orderline->product_tobatch)) { - $this->error='ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH'; + $this->error = 'ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH'; return -4; } // extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used $line->array_options = $array_options; $this->lines[$num] = $line; @@ -993,30 +993,30 @@ class Expedition extends CommonObject public function addline_batch($dbatch, $array_options = 0) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $num = count($this->lines); - if ($dbatch['qty']>0) + if ($dbatch['qty'] > 0) { $line = new ExpeditionLigne($this->db); - $tab=array(); + $tab = array(); foreach ($dbatch['detail'] as $key=>$value) { - if ($value['q']>0) + if ($value['q'] > 0) { // $value['q']=qty to move // $value['id_batch']=id into llx_product_batch of record to move //var_dump($value); $linebatch = new ExpeditionLineBatch($this->db); - $ret=$linebatch->fetchFromStock($value['id_batch']); // load serial, sellby, eatby - if ($ret<0) + $ret = $linebatch->fetchFromStock($value['id_batch']); // load serial, sellby, eatby + if ($ret < 0) { - $this->error=$linebatch->error; + $this->error = $linebatch->error; return -1; } - $linebatch->qty=$value['q']; - $tab[]=$linebatch; + $linebatch->qty = $value['q']; + $tab[] = $linebatch; if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { @@ -1027,7 +1027,7 @@ class Expedition extends CommonObject if ($prod_batch->qty < $linebatch->qty) { $langs->load("errors"); - $this->errors[]=$langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $prod_batch->fk_product); + $this->errors[] = $langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $prod_batch->fk_product); dol_syslog(get_class($this)."::addline_batch error=Product ".$prod_batch->batch.": ".$this->errorsToString(), LOG_ERR); $this->db->rollback(); return -1; @@ -1040,10 +1040,10 @@ class Expedition extends CommonObject $line->entrepot_id = $linebatch->entrepot_id; $line->origin_line_id = $dbatch['ix_l']; $line->qty = $dbatch['qty']; - $line->detail_batch=$tab; + $line->detail_batch = $tab; // extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used $line->array_options = $array_options; //var_dump($line); @@ -1062,29 +1062,29 @@ class Expedition extends CommonObject public function update($user = null, $notrigger = 0) { global $conf; - $error=0; + $error = 0; // Clean parameters - if (isset($this->ref)) $this->ref=trim($this->ref); - if (isset($this->entity)) $this->entity=trim($this->entity); - if (isset($this->ref_customer)) $this->ref_customer=trim($this->ref_customer); - if (isset($this->socid)) $this->socid=trim($this->socid); - if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); - if (isset($this->fk_user_valid)) $this->fk_user_valid=trim($this->fk_user_valid); - if (isset($this->fk_delivery_address)) $this->fk_delivery_address=trim($this->fk_delivery_address); - if (isset($this->shipping_method_id)) $this->shipping_method_id=trim($this->shipping_method_id); - if (isset($this->tracking_number)) $this->tracking_number=trim($this->tracking_number); - if (isset($this->statut)) $this->statut=(int) $this->statut; - if (isset($this->trueDepth)) $this->trueDepth=trim($this->trueDepth); - if (isset($this->trueWidth)) $this->trueWidth=trim($this->trueWidth); - if (isset($this->trueHeight)) $this->trueHeight=trim($this->trueHeight); - if (isset($this->size_units)) $this->size_units=trim($this->size_units); - if (isset($this->weight_units)) $this->weight_units=trim($this->weight_units); - if (isset($this->trueWeight)) $this->weight=trim($this->trueWeight); - if (isset($this->note_private)) $this->note=trim($this->note_private); - if (isset($this->note_public)) $this->note=trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); + if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->entity)) $this->entity = trim($this->entity); + if (isset($this->ref_customer)) $this->ref_customer = trim($this->ref_customer); + if (isset($this->socid)) $this->socid = trim($this->socid); + if (isset($this->fk_user_author)) $this->fk_user_author = trim($this->fk_user_author); + if (isset($this->fk_user_valid)) $this->fk_user_valid = trim($this->fk_user_valid); + if (isset($this->fk_delivery_address)) $this->fk_delivery_address = trim($this->fk_delivery_address); + if (isset($this->shipping_method_id)) $this->shipping_method_id = trim($this->shipping_method_id); + if (isset($this->tracking_number)) $this->tracking_number = trim($this->tracking_number); + if (isset($this->statut)) $this->statut = (int) $this->statut; + if (isset($this->trueDepth)) $this->trueDepth = trim($this->trueDepth); + if (isset($this->trueWidth)) $this->trueWidth = trim($this->trueWidth); + if (isset($this->trueHeight)) $this->trueHeight = trim($this->trueHeight); + if (isset($this->size_units)) $this->size_units = trim($this->size_units); + if (isset($this->weight_units)) $this->weight_units = trim($this->weight_units); + if (isset($this->trueWeight)) $this->weight = trim($this->trueWeight); + if (isset($this->note_private)) $this->note = trim($this->note_private); + if (isset($this->note_public)) $this->note = trim($this->note_public); + if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); @@ -1094,46 +1094,46 @@ class Expedition extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; - $sql.= " ref_customer=".(isset($this->ref_customer)?"'".$this->db->escape($this->ref_customer)."'":"null").","; - $sql.= " fk_soc=".(isset($this->socid)?$this->socid:"null").","; - $sql.= " date_creation=".(dol_strlen($this->date_creation)!=0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; - $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; - $sql.= " date_valid=".(dol_strlen($this->date_valid)!=0 ? "'".$this->db->idate($this->date_valid)."'" : 'null').","; - $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->fk_user_valid:"null").","; - $sql.= " date_expedition=".(dol_strlen($this->date_expedition)!=0 ? "'".$this->db->idate($this->date_expedition)."'" : 'null').","; - $sql.= " date_delivery=".(dol_strlen($this->date_delivery)!=0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').","; - $sql.= " fk_address=".(isset($this->fk_delivery_address)?$this->fk_delivery_address:"null").","; - $sql.= " fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0)?$this->shipping_method_id:"null").","; - $sql.= " tracking_number=".(isset($this->tracking_number)?"'".$this->db->escape($this->tracking_number)."'":"null").","; - $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").","; - $sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").","; - $sql.= " height=".(($this->trueHeight != '')?$this->trueHeight:"null").","; - $sql.= " width=".(($this->trueWidth != '')?$this->trueWidth:"null").","; - $sql.= " size_units=".(isset($this->size_units)?$this->size_units:"null").","; - $sql.= " size=".(($this->trueDepth != '')?$this->trueDepth:"null").","; - $sql.= " weight_units=".(isset($this->weight_units)?$this->weight_units:"null").","; - $sql.= " weight=".(($this->trueWeight != '')?$this->trueWeight:"null").","; - $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; - $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; - $sql.= " entity=".$conf->entity; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " ref_customer=".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").","; + $sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").","; + $sql .= " date_creation=".(dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; + $sql .= " fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author : "null").","; + $sql .= " date_valid=".(dol_strlen($this->date_valid) != 0 ? "'".$this->db->idate($this->date_valid)."'" : 'null').","; + $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? $this->fk_user_valid : "null").","; + $sql .= " date_expedition=".(dol_strlen($this->date_expedition) != 0 ? "'".$this->db->idate($this->date_expedition)."'" : 'null').","; + $sql .= " date_delivery=".(dol_strlen($this->date_delivery) != 0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').","; + $sql .= " fk_address=".(isset($this->fk_delivery_address) ? $this->fk_delivery_address : "null").","; + $sql .= " fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? $this->shipping_method_id : "null").","; + $sql .= " tracking_number=".(isset($this->tracking_number) ? "'".$this->db->escape($this->tracking_number)."'" : "null").","; + $sql .= " fk_statut=".(isset($this->statut) ? $this->statut : "null").","; + $sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").","; + $sql .= " height=".(($this->trueHeight != '') ? $this->trueHeight : "null").","; + $sql .= " width=".(($this->trueWidth != '') ? $this->trueWidth : "null").","; + $sql .= " size_units=".(isset($this->size_units) ? $this->size_units : "null").","; + $sql .= " size=".(($this->trueDepth != '') ? $this->trueDepth : "null").","; + $sql .= " weight_units=".(isset($this->weight_units) ? $this->weight_units : "null").","; + $sql .= " weight=".(($this->trueWeight != '') ? $this->trueWeight : "null").","; + $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; + $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; + $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; + $sql .= " entity=".$conf->entity; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('SHIPPING_MODIFY', $user); + $result = $this->call_trigger('SHIPPING_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -1142,13 +1142,13 @@ class Expedition extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -1207,13 +1207,13 @@ class Expedition extends CommonObject // Loop on each product line to add a stock movement $sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.rowid as expeditiondet_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql.= " WHERE ed.fk_expedition = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_origin_line"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= " WHERE ed.fk_expedition = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_origin_line"; dol_syslog(get_class($this)."::delete select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -1230,19 +1230,19 @@ class Expedition extends CommonObject if ($conf->productbatch->enabled) { $lotArray = ExpeditionLineBatch::fetchAll($this->db, $obj->expeditiondet_id); - if (! is_array($lotArray)) + if (!is_array($lotArray)) { - $error++;$this->errors[]="Error ".$this->db->lasterror(); + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } if (empty($lotArray)) { // no lot/serial // We increment stock of product (and sub-products) // We use warehouse selected for each line - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref)); // Price is set to 0, because we don't want to see WAP changed + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref)); // Price is set to 0, because we don't want to see WAP changed if ($result < 0) { - $error++;$this->errors=$this->errors + $mouvS->errors; + $error++; $this->errors = $this->errors + $mouvS->errors; break; } } @@ -1250,12 +1250,12 @@ class Expedition extends CommonObject { // We increment stock of batches // We use warehouse selected for each line - foreach($lotArray as $lot) + foreach ($lotArray as $lot) { - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch); // Price is set to 0, because we don't want to see WAP changed + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $lot->qty, 0, $langs->trans("ShipmentDeletedInDolibarr", $this->ref), $lot->eatby, $lot->sellby, $lot->batch); // Price is set to 0, because we don't want to see WAP changed if ($result < 0) { - $error++;$this->errors=$this->errors + $mouvS->errors; + $error++; $this->errors = $this->errors + $mouvS->errors; break; } } @@ -1265,41 +1265,41 @@ class Expedition extends CommonObject } else { - $error++;$this->errors[]="Error ".$this->db->lasterror(); + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } // delete batch expedition line - if (! $error && $conf->productbatch->enabled) + if (!$error && $conf->productbatch->enabled) { if (ExpeditionLineBatch::deletefromexp($this->db, $this->id) < 0) { - $error++;$this->errors[]="Error ".$this->db->lasterror(); + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet"; - $sql.= " WHERE fk_expedition = ".$this->id; + $sql .= " WHERE fk_expedition = ".$this->id; - if ( $this->db->query($sql) ) + if ($this->db->query($sql)) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; if ($this->db->query($sql)) { - if (! empty($this->origin) && $this->origin_id > 0) + if (!empty($this->origin) && $this->origin_id > 0) { $this->fetch_origin(); - $origin=$this->origin; + $origin = $this->origin; if ($this->$origin->statut == Commande::STATUS_SHIPMENTONPROCESS) // If order source of shipment is "shipment in progress" { // Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress" @@ -1312,19 +1312,19 @@ class Expedition extends CommonObject } } - if (! $error) + if (!$error) { $this->db->commit(); // We delete PDFs $ref = dol_sanitizeFileName($this->ref); - if (! empty($conf->expedition->dir_output)) + if (!empty($conf->expedition->dir_output)) { - $dir = $conf->expedition->dir_output . '/sending/' . $ref ; - $file = $dir . '/' . $ref . '.pdf'; + $dir = $conf->expedition->dir_output.'/sending/'.$ref; + $file = $dir.'/'.$ref.'.pdf'; if (file_exists($file)) { - if (! dol_delete_file($file)) + if (!dol_delete_file($file)) { return 0; } @@ -1333,7 +1333,7 @@ class Expedition extends CommonObject { if (!dol_delete_dir_recursive($dir)) { - $this->error=$langs->trans("ErrorCanNotDeleteDir", $dir); + $this->error = $langs->trans("ErrorCanNotDeleteDir", $dir); return 0; } } @@ -1349,21 +1349,21 @@ class Expedition extends CommonObject } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -3; } } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -2; } } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -1; } @@ -1425,8 +1425,8 @@ class Expedition extends CommonObject $obj = $this->db->fetch_object($resql); if ($originline == $obj->fk_origin_line) { - $line->entrepot_id = 0; // entrepod_id in details_entrepot - $line->qty_shipped += $obj->qty_shipped; + $line->entrepot_id = 0; // entrepod_id in details_entrepot + $line->qty_shipped += $obj->qty_shipped; } else { $line = new ExpeditionLigne($this->db); $line->entrepot_id = $obj->fk_entrepot; @@ -1440,24 +1440,24 @@ class Expedition extends CommonObject $line->details_entrepot[] = $detail_entrepot; $line->line_id = $obj->line_id; - $line->rowid = $obj->line_id; // TODO deprecated + $line->rowid = $obj->line_id; // TODO deprecated $line->id = $obj->line_id; - $line->fk_origin = 'orderline'; + $line->fk_origin = 'orderline'; $line->fk_origin_line = $obj->fk_origin_line; - $line->origin_line_id = $obj->fk_origin_line; // TODO deprecated + $line->origin_line_id = $obj->fk_origin_line; // TODO deprecated - $line->fk_expedition = $this->id; // id of parent + $line->fk_expedition = $this->id; // id of parent $line->product_type = $obj->product_type; $line->fk_product = $obj->fk_product; $line->fk_product_type = $obj->fk_product_type; - $line->ref = $obj->product_ref; // TODO deprecated - $line->product_ref = $obj->product_ref; - $line->product_label = $obj->product_label; - $line->libelle = $obj->product_label; // TODO deprecated - $line->product_tobatch = $obj->product_tobatch; - $line->label = $obj->custom_label; + $line->ref = $obj->product_ref; // TODO deprecated + $line->product_ref = $obj->product_ref; + $line->product_label = $obj->product_label; + $line->libelle = $obj->product_label; // TODO deprecated + $line->product_tobatch = $obj->product_tobatch; + $line->label = $obj->custom_label; $line->description = $obj->description; $line->qty_asked = $obj->qty_asked; $line->rang = $obj->rang; @@ -1466,44 +1466,44 @@ class Expedition extends CommonObject $line->length = $obj->length; $line->length_units = $obj->length_units; $line->surface = $obj->surface; - $line->surface_units = $obj->surface_units; + $line->surface_units = $obj->surface_units; $line->volume = $obj->volume; $line->volume_units = $obj->volume_units; - $line->pa_ht = $obj->pa_ht; + $line->pa_ht = $obj->pa_ht; // Local taxes - $localtax_array=array(0=>$obj->localtax1_type, 1=>$obj->localtax1_tx, 2=>$obj->localtax2_type, 3=>$obj->localtax2_tx); + $localtax_array = array(0=>$obj->localtax1_type, 1=>$obj->localtax1_tx, 2=>$obj->localtax2_type, 3=>$obj->localtax2_tx); $localtax1_tx = get_localtax($obj->tva_tx, 1, $this->thirdparty); $localtax2_tx = get_localtax($obj->tva_tx, 2, $this->thirdparty); // For invoicing - $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $localtax1_tx, $localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc, $localtax_array); // We force type to 0 - $line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements) - $line->qty = $line->qty_shipped; - $line->total_ht = $tabprice[0]; + $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $localtax1_tx, $localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc, $localtax_array); // We force type to 0 + $line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements) + $line->qty = $line->qty_shipped; + $line->total_ht = $tabprice[0]; $line->total_localtax1 = $tabprice[9]; $line->total_localtax2 = $tabprice[10]; $line->total_ttc = $tabprice[2]; $line->total_tva = $tabprice[1]; - $line->vat_src_code = $obj->vat_src_code; - $line->tva_tx = $obj->tva_tx; + $line->vat_src_code = $obj->vat_src_code; + $line->tva_tx = $obj->tva_tx; $line->localtax1_tx = $obj->localtax1_tx; $line->localtax2_tx = $obj->localtax2_tx; - $line->info_bits = $obj->info_bits; - $line->price = $obj->price; - $line->subprice = $obj->subprice; - $line->remise_percent = $obj->remise_percent; + $line->info_bits = $obj->info_bits; + $line->price = $obj->price; + $line->subprice = $obj->subprice; + $line->remise_percent = $obj->remise_percent; - $this->total_ht+= $tabprice[0]; - $this->total_tva+= $tabprice[1]; - $this->total_ttc+= $tabprice[2]; - $this->total_localtax1+= $tabprice[9]; - $this->total_localtax2+= $tabprice[10]; + $this->total_ht += $tabprice[0]; + $this->total_tva += $tabprice[1]; + $this->total_ttc += $tabprice[2]; + $this->total_localtax1 += $tabprice[9]; + $this->total_localtax2 += $tabprice[10]; // Multicurrency - $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; $this->multicurrency_subprice = $obj->multicurrency_subprice; $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; @@ -1515,7 +1515,7 @@ class Expedition extends CommonObject } // Detail of batch - if (! empty($conf->productbatch->enabled) && $obj->line_id > 0 && $obj->product_tobatch > 0) + if (!empty($conf->productbatch->enabled) && $obj->line_id > 0 && $obj->product_tobatch > 0) { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; @@ -1540,7 +1540,7 @@ class Expedition extends CommonObject } else { - $line->total_ht += $tabprice[0]; + $line->total_ht += $tabprice[0]; $line->total_localtax1 += $tabprice[9]; $line->total_localtax2 += $tabprice[10]; $line->total_ttc += $tabprice[2]; @@ -1555,7 +1555,7 @@ class Expedition extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -3; } } @@ -1575,7 +1575,7 @@ class Expedition extends CommonObject { $this->db->begin(); - $line=new ExpeditionLigne($this->db); + $line = new ExpeditionLigne($this->db); // For triggers $line->fetch($lineid); @@ -1595,7 +1595,7 @@ class Expedition extends CommonObject } else { - $this->error='ErrorDeleteLineNotAllowedByObjectStatus'; + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } } @@ -1616,9 +1616,9 @@ class Expedition extends CommonObject { global $langs; - $result=''; - $label = '' . $langs->trans("ShowSending") . ''; - $label .= '
        ' . $langs->trans('Ref') . ': '.$this->ref; + $result = ''; + $label = ''.$langs->trans("ShowSending").''; + $label .= '
        '.$langs->trans('Ref').': '.$this->ref; $label .= '
        '.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); $url = DOL_URL_ROOT.'/expedition/card.php?id='.$this->id; @@ -1628,29 +1628,29 @@ class Expedition extends CommonObject if ($option !== 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowSending"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowSending"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } $linkstart = ''; - $linkend=''; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; return $result; @@ -1701,7 +1701,7 @@ class Expedition extends CommonObject { global $langs; - $now=dol_now(); + $now = dol_now(); dol_syslog(get_class($this)."::initAsSpecimen"); @@ -1709,8 +1709,8 @@ class Expedition extends CommonObject $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -1724,20 +1724,20 @@ class Expedition extends CommonObject } } - $order=new Commande($this->db); + $order = new Commande($this->db); $order->initAsSpecimen(); // Initialise parametres - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->statut = self::STATUS_VALIDATED; $this->livraison_id = 0; $this->date = $now; $this->date_creation = $now; $this->date_valid = $now; $this->date_delivery = $now; - $this->date_expedition = $now + 24*3600; + $this->date_expedition = $now + 24 * 3600; $this->entrepot_id = 0; $this->fk_delivery_address = 0; @@ -1784,11 +1784,11 @@ class Expedition extends CommonObject if ($user->rights->expedition->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; - $sql.= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::set_date_livraison", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->date_delivery = $date_livraison; @@ -1796,7 +1796,7 @@ class Expedition extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1881,20 +1881,20 @@ class Expedition extends CommonObject public function update_delivery_method($id = '') { // phpcs:enable - if ($id=='') + if ($id == '') { $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; - $sql.=" VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; + $sql .= " VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; $resql = $this->db->query($sql); } else { $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; - $sql.= " code='".$this->db->escape($this->update['code'])."'"; - $sql.= ",libelle='".$this->db->escape($this->update['libelle'])."'"; - $sql.= ",description='".$this->db->escape($this->update['description'])."'"; - $sql.= ",tracking='".$this->db->escape($this->update['tracking'])."'"; - $sql.= " WHERE rowid=".$id; + $sql .= " code='".$this->db->escape($this->update['code'])."'"; + $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; + $sql .= ",description='".$this->db->escape($this->update['description'])."'"; + $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; + $sql .= " WHERE rowid=".$id; $resql = $this->db->query($sql); } if ($resql < 0) dol_print_error($this->db, ''); @@ -1911,7 +1911,7 @@ class Expedition extends CommonObject { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; - $sql.= ' WHERE rowid='.$id; + $sql .= ' WHERE rowid='.$id; $resql = $this->db->query($sql); } @@ -1928,7 +1928,7 @@ class Expedition extends CommonObject { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; - $sql.= ' WHERE rowid='.$id; + $sql .= ' WHERE rowid='.$id; $resql = $this->db->query($sql); } @@ -1942,11 +1942,11 @@ class Expedition extends CommonObject */ public function getUrlTrackingStatus($value = '') { - if (! empty($this->shipping_method_id)) + if (!empty($this->shipping_method_id)) { $sql = "SELECT em.code, em.tracking"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql.= " WHERE em.rowid = ".$this->shipping_method_id; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + $sql .= " WHERE em.rowid = ".$this->shipping_method_id; $resql = $this->db->query($sql); if ($resql) @@ -1961,7 +1961,7 @@ class Expedition extends CommonObject if (!empty($tracking) && !empty($value)) { $url = str_replace('{TRACKID}', $value, $tracking); - $this->tracking_url = sprintf(''.($value?$value:'url').'', $url, $url); + $this->tracking_url = sprintf(''.($value ? $value : 'url').'', $url, $url); } else { @@ -1976,16 +1976,16 @@ class Expedition extends CommonObject */ public function setClosed() { - global $conf,$langs,$user; + global $conf, $langs, $user; - $error=0; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut='.self::STATUS_CLOSED; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // Set order billed if 100% of order is shipped (qty in shipment lines match qty in order lines) @@ -1994,17 +1994,17 @@ class Expedition extends CommonObject $order = new Commande($this->db); $order->fetch($this->origin_id); - $order->loadExpeditions(self::STATUS_CLOSED); // Fill $order->expeditions = array(orderlineid => qty) + $order->loadExpeditions(self::STATUS_CLOSED); // Fill $order->expeditions = array(orderlineid => qty) $shipments_match_order = 1; - foreach($order->lines as $line) + foreach ($order->lines as $line) { $lineid = $line->id; $qty = $line->qty; - if (($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->expeditions[$lineid] != $qty) + if (($line->product_type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->expeditions[$lineid] != $qty) { $shipments_match_order = 0; - $text='Qty for order line id '.$lineid.' is '.$qty.'. However in the shipments with status Expedition::STATUS_CLOSED='.self::STATUS_CLOSED.' we have qty = '.$order->expeditions[$lineid].', so we can t close order'; + $text = 'Qty for order line id '.$lineid.' is '.$qty.'. However in the shipments with status Expedition::STATUS_CLOSED='.self::STATUS_CLOSED.' we have qty = '.$order->expeditions[$lineid].', so we can t close order'; dol_syslog($text); break; } @@ -2016,11 +2016,11 @@ class Expedition extends CommonObject } } - $this->statut=self::STATUS_CLOSED; + $this->statut = self::STATUS_CLOSED; // If stock increment is done on closing - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -2029,16 +2029,16 @@ class Expedition extends CommonObject // Loop on each product line to add a stock movement // TODO possibilite d'expedier a partir d'une propale ou autre origine ? $sql = "SELECT cd.fk_product, cd.subprice,"; - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; - $sql.= " WHERE ed.fk_expedition = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_origin_line"; + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; + $sql .= " WHERE ed.fk_expedition = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_origin_line"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -2064,7 +2064,7 @@ class Expedition extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $numref)); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $numref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -2076,7 +2076,7 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -2087,15 +2087,15 @@ class Expedition extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } // Call trigger - if (! $error) + if (!$error) { - $result=$this->call_trigger('SHIPPING_CLOSED', $user); + $result = $this->call_trigger('SHIPPING_CLOSED', $user); if ($result < 0) { $error++; } @@ -2107,7 +2107,7 @@ class Expedition extends CommonObject $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -2130,27 +2130,27 @@ class Expedition extends CommonObject { // phpcs:enable global $user; - $error=0; + $error = 0; $this->db->begin(); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->statut=self::STATUS_CLOSED; - $this->billed=1; + $this->statut = self::STATUS_CLOSED; + $this->billed = 1; // Call trigger - $result=$this->call_trigger('SHIPPING_BILLED', $user); + $result = $this->call_trigger('SHIPPING_BILLED', $user); if ($result < 0) { $error++; } } else { $error++; - $this->errors[]=$this->db->lasterror; + $this->errors[] = $this->db->lasterror; } if (empty($error)) { @@ -2159,8 +2159,8 @@ class Expedition extends CommonObject } else { - $this->statut=self::STATUS_VALIDATED; - $this->billed=0; + $this->statut = self::STATUS_VALIDATED; + $this->billed = 0; $this->db->rollback(); return -1; } @@ -2173,9 +2173,9 @@ class Expedition extends CommonObject */ public function reOpen() { - global $conf,$langs,$user; + global $conf, $langs, $user; - $error=0; + $error = 0; // Protection. This avoid to move stock later when we should not if ($this->statut == self::STATUS_VALIDATED) @@ -2185,19 +2185,19 @@ class Expedition extends CommonObject $this->db->begin(); - $oldbilled=$this->billed; + $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); + $resql = $this->db->query($sql); if ($resql) { - $this->statut=self::STATUS_VALIDATED; - $this->billed=0; + $this->statut = self::STATUS_VALIDATED; + $this->billed = 0; // If stock increment is done on closing - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -2206,16 +2206,16 @@ class Expedition extends CommonObject // Loop on each product line to add a stock movement // TODO possibilite d'expedier a partir d'une propale ou autre origine $sql = "SELECT cd.fk_product, cd.subprice,"; - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; - $sql.= " WHERE ed.fk_expedition = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_origin_line"; + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; + $sql .= " WHERE ed.fk_expedition = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_origin_line"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -2242,7 +2242,7 @@ class Expedition extends CommonObject // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr", $numref)); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr", $numref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -2254,7 +2254,7 @@ class Expedition extends CommonObject // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -2265,32 +2265,32 @@ class Expedition extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } - if (! $error) { + if (!$error) { // Call trigger - $result=$this->call_trigger('SHIPPING_REOPEN', $user); + $result = $this->call_trigger('SHIPPING_REOPEN', $user); if ($result < 0) { $error++; } } } else { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - $this->statut=self::STATUS_CLOSED; - $this->billed=$oldbilled; + $this->statut = self::STATUS_CLOSED; + $this->billed = $oldbilled; $this->db->rollback(); return -1; } @@ -2357,12 +2357,12 @@ class ExpeditionLigne extends CommonObjectLine /** * @var string ID to identify managed object */ - public $element='expeditiondet'; + public $element = 'expeditiondet'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='expeditiondet'; + public $table_element = 'expeditiondet'; /** * @deprecated @@ -2512,7 +2512,7 @@ class ExpeditionLigne extends CommonObjectLine */ public function __construct($db) { - $this->db=$db; + $this->db = $db; } /** @@ -2524,18 +2524,18 @@ class ExpeditionLigne extends CommonObjectLine public function fetch($rowid) { $sql = 'SELECT ed.rowid, ed.fk_expedition, ed.fk_entrepot, ed.fk_origin_line, ed.qty, ed.rang'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as ed'; - $sql.= ' WHERE ed.rowid = '.$rowid; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as ed'; + $sql .= ' WHERE ed.rowid = '.$rowid; $result = $this->db->query($sql); if ($result) { $objp = $this->db->fetch_object($result); - $this->id = $objp->rowid; - $this->fk_expedition = $objp->fk_expedition; - $this->entrepot_id = $objp->fk_entrepot; - $this->fk_origin_line = $objp->fk_origin_line; - $this->qty = $objp->qty; - $this->rang = $objp->rang; + $this->id = $objp->rowid; + $this->fk_expedition = $objp->fk_expedition; + $this->entrepot_id = $objp->fk_entrepot; + $this->fk_origin_line = $objp->fk_origin_line; + $this->qty = $objp->qty; + $this->rang = $objp->rang; $this->db->free($result); @@ -2601,19 +2601,19 @@ class ExpeditionLigne extends CommonObjectLine { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINESHIPPING_INSERT', $user); + $result = $this->call_trigger('LINESHIPPING_INSERT', $user); if ($result < 0) { $error++; @@ -2621,19 +2621,19 @@ class ExpeditionLigne extends CommonObjectLine // End call triggers } - if (! $error) { + if (!$error) { $this->db->commit(); return $this->id; } - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -2652,7 +2652,7 @@ class ExpeditionLigne extends CommonObjectLine { global $conf; - $error=0; + $error = 0; $this->db->begin(); @@ -2660,37 +2660,37 @@ class ExpeditionLigne extends CommonObjectLine if ($conf->productbatch->enabled) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_batch"; - $sql.= " WHERE fk_expeditiondet = ".$this->id; + $sql .= " WHERE fk_expeditiondet = ".$this->id; if (!$this->db->query($sql)) { - $this->errors[]=$this->db->lasterror()." - sql=$sql"; + $this->errors[] = $this->db->lasterror()." - sql=$sql"; $error++; } } $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; - if (! $error && $this->db->query($sql)) + if (!$error && $this->db->query($sql)) { // Remove extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->deleteExtraFields(); + $result = $this->deleteExtraFields(); if ($result < 0) { - $this->errors[]=$this->error; + $this->errors[] = $this->error; $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINESHIPPING_DELETE', $user); + $result = $this->call_trigger('LINESHIPPING_DELETE', $user); if ($result < 0) { - $this->errors[]=$this->error; + $this->errors[] = $this->error; $error++; } // End call triggers @@ -2698,23 +2698,23 @@ class ExpeditionLigne extends CommonObjectLine } else { - $this->errors[]=$this->db->lasterror()." - sql=$sql"; + $this->errors[] = $this->db->lasterror()." - sql=$sql"; $error++; } - if (! $error) { + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -2729,15 +2729,15 @@ class ExpeditionLigne extends CommonObjectLine { global $conf; - $error=0; + $error = 0; dol_syslog(get_class($this)."::update id=$this->id, entrepot_id=$this->entrepot_id, product_id=$this->fk_product, qty=$this->qty"); $this->db->begin(); // Clean parameters - if (empty($this->qty)) $this->qty=0; - $qty=price2num($this->qty); + if (empty($this->qty)) $this->qty = 0; + $qty = price2num($this->qty); $remainingQty = 0; $batch = null; $batch_id = null; @@ -2747,7 +2747,7 @@ class ExpeditionLigne extends CommonObjectLine if (count($this->detail_batch) > 1) { dol_syslog(get_class($this).'::update only possible for one batch', LOG_ERR); - $this->errors[]='ErrorBadParameters'; + $this->errors[] = 'ErrorBadParameters'; $error++; } else @@ -2758,13 +2758,13 @@ class ExpeditionLigne extends CommonObjectLine if ($this->entrepot_id != $this->detail_batch[0]->entrepot_id) { dol_syslog(get_class($this).'::update only possible for batch of same warehouse', LOG_ERR); - $this->errors[]='ErrorBadParameters'; + $this->errors[] = 'ErrorBadParameters'; $error++; } $qty = price2num($this->detail_batch[0]->qty); } } - elseif (! empty($this->detail_batch)) + elseif (!empty($this->detail_batch)) { $batch = $this->detail_batch->batch; $batch_id = $this->detail_batch->fk_origin_stock; @@ -2772,38 +2772,38 @@ class ExpeditionLigne extends CommonObjectLine if ($this->entrepot_id != $this->detail_batch->entrepot_id) { dol_syslog(get_class($this).'::update only possible for batch of same warehouse', LOG_ERR); - $this->errors[]='ErrorBadParameters'; + $this->errors[] = 'ErrorBadParameters'; $error++; } $qty = price2num($this->detail_batch->qty); } // check parameters - if (! isset($this->id) || ! isset($this->entrepot_id)) + if (!isset($this->id) || !isset($this->entrepot_id)) { dol_syslog(get_class($this).'::update missing line id and/or warehouse id', LOG_ERR); - $this->errors[]='ErrorMandatoryParametersNotProvided'; + $this->errors[] = 'ErrorMandatoryParametersNotProvided'; $error++; return -1; } // update lot - if (! empty($batch) && $conf->productbatch->enabled) + if (!empty($batch) && $conf->productbatch->enabled) { dol_syslog(get_class($this)."::update expedition batch id=$expedition_batch_id, batch_id=$batch_id, batch=$batch"); if (empty($batch_id) || empty($this->fk_product)) { dol_syslog(get_class($this).'::update missing fk_origin_stock (batch_id) and/or fk_product', LOG_ERR); - $this->errors[]='ErrorMandatoryParametersNotProvided'; + $this->errors[] = 'ErrorMandatoryParametersNotProvided'; $error++; } // fetch remaining lot qty require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; - if (! $error && ($lotArray = ExpeditionLineBatch::fetchAll($this->db, $this->id)) < 0) + if (!$error && ($lotArray = ExpeditionLineBatch::fetchAll($this->db, $this->id)) < 0) { - $this->errors[]=$this->db->lasterror()." - ExpeditionLineBatch::fetchAll"; + $this->errors[] = $this->db->lasterror()." - ExpeditionLineBatch::fetchAll"; $error++; } else @@ -2828,20 +2828,20 @@ class ExpeditionLigne extends CommonObjectLine $this->errors[] = $lot->errors; $error++; } - if (! $error && ! empty($expedition_batch_id)) + if (!$error && !empty($expedition_batch_id)) { // delete lot expedition line $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_batch"; - $sql.= " WHERE fk_expeditiondet = ".$this->id; - $sql.= " AND rowid = ".$expedition_batch_id; + $sql .= " WHERE fk_expeditiondet = ".$this->id; + $sql .= " AND rowid = ".$expedition_batch_id; if (!$this->db->query($sql)) { - $this->errors[]=$this->db->lasterror()." - sql=$sql"; + $this->errors[] = $this->db->lasterror()." - sql=$sql"; $error++; } } - if (! $error && $this->detail_batch->qty > 0) + if (!$error && $this->detail_batch->qty > 0) { // create lot expedition line if (isset($lot->id)) @@ -2855,48 +2855,48 @@ class ExpeditionLigne extends CommonObjectLine $shipmentLot->fk_origin_stock = $batch_id; if ($shipmentLot->create($this->id) < 0) { - $this->errors[]=$shipmentLot->errors; + $this->errors[] = $shipmentLot->errors; $error++; } } } } } - if (! $error) + if (!$error) { // update line $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; - $sql.= " fk_entrepot = ".($this->entrepot_id > 0 ? $this->entrepot_id : 'null'); - $sql.= " , qty = ".$qty; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " fk_entrepot = ".($this->entrepot_id > 0 ? $this->entrepot_id : 'null'); + $sql .= " , qty = ".$qty; + $sql .= " WHERE rowid = ".$this->id; if (!$this->db->query($sql)) { - $this->errors[]=$this->db->lasterror()." - sql=$sql"; + $this->errors[] = $this->db->lasterror()." - sql=$sql"; $error++; } } - if (! $error) + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { - $this->errors[]=$this->error; + $this->errors[] = $this->error; $error++; } } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINESHIPPING_UPDATE', $user); + $result = $this->call_trigger('LINESHIPPING_UPDATE', $user); if ($result < 0) { - $this->errors[]=$this->error; + $this->errors[] = $this->error; $error++; } // End call triggers @@ -2907,13 +2907,13 @@ class ExpeditionLigne extends CommonObjectLine } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } } diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 2bd6e67b595..3d9b7b2e78f 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -63,7 +63,7 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once @@ -105,11 +105,11 @@ if (empty($reshook)) if ($action == 'setdatedelivery' && $user->rights->commande->creer) { //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datelivraison=dol_mktime(0, 0, 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); + $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object = new Commande($db); $object->fetch($id); - $result=$object->set_date_livraison($user, $datelivraison); + $result = $object->set_date_livraison($user, $datelivraison); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -135,7 +135,7 @@ if (empty($reshook)) if ($action == 'setavailability' && $user->rights->commande->creer) { $object = new Commande($db); $object->fetch($id); - $result=$object->availability(GETPOST('availability_id')); + $result = $object->availability(GETPOST('availability_id')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -143,7 +143,7 @@ if (empty($reshook)) if ($action == 'setdemandreason' && $user->rights->commande->creer) { $object = new Commande($db); $object->fetch($id); - $result=$object->demand_reason(GETPOST('demand_reason_id')); + $result = $object->demand_reason(GETPOST('demand_reason_id')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -152,7 +152,7 @@ if (empty($reshook)) { $object = new Commande($db); $object->fetch($id); - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -170,7 +170,7 @@ if (empty($reshook)) if ($action == 'setshippingmethod' && $user->rights->commande->creer) { $object = new Commande($db); $object->fetch($id); - $result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int')); + $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -192,7 +192,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('SHIPMENT_MODIFY'); @@ -212,7 +212,7 @@ if (empty($reshook)) $object->fetch($id); $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit(); } @@ -226,19 +226,19 @@ if (empty($reshook)) $form = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } llxHeader('', $langs->trans('OrderCard'), ''); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $object = new Commande($db); - if ( $object->fetch($id, $ref) > 0) + if ($object->fetch($id, $ref) > 0) { $object->loadExpeditions(1); - $product_static=new Product($db); + $product_static = new Product($db); $soc = new Societe($db); $soc->fetch($object->socid); @@ -263,8 +263,8 @@ if ($id > 0 || ! empty($ref)) // Call Hook formConfirm $parameters = array(); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -327,7 +327,7 @@ if ($id > 0 || ! empty($ref)) print ''; // Discounts for third party - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -337,14 +337,14 @@ if ($id > 0 || ! empty($ref)) print ''; @@ -373,14 +373,14 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - print $form->selectDate($object->date_livraison>0?$object->date_livraison:-1, 'liv_', '', '', '', "setdatedelivery"); + print $form->selectDate($object->date_livraison > 0 ? $object->date_livraison : -1, 'liv_', '', '', '', "setdatedelivery"); print ''; print ''; } else { print dol_print_date($object->date_livraison, 'daytext'); - if ($object->hasDelay() && ! empty($object->date_livraison)) { + if ($object->hasDelay() && !empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } @@ -409,9 +409,9 @@ if ($id > 0 || ! empty($ref)) print ''; // Warehouse - if (! empty($conf->stock->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct=new FormProduct($db); + $formproduct = new FormProduct($db); print ''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { if ($object->fk_account > 0) { - $bankline=new AccountLine($db); + $bankline = new AccountLine($db); $bankline->fetch($object->fk_bank); print ''; @@ -271,8 +271,8 @@ if ($id) } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
        '.$langs->trans('Discounts').''; - $absolute_discount=$soc->getAvailableDiscounts('', $filterabsolutediscount); - $absolute_creditnote=$soc->getAvailableDiscounts('', $filtercreditnote); - $absolute_discount=price2num($absolute_discount, 'MT'); - $absolute_creditnote=price2num($absolute_creditnote, 'MT'); + $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); + $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); + $absolute_discount = price2num($absolute_discount, 'MT'); + $absolute_creditnote = price2num($absolute_creditnote, 'MT'); $thirdparty = $soc; $discount_type = 0; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); $cannotApplyDiscount = 1; include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '
        '; print ''; - print ''; + print ''; + print ''; print ''; // Multicurrency Amount VAT - print ''; - print ''; + print ''; + print ''; print ''; // Multicurrency Amount TTC - print ''; - print ''; + print ''; + print ''; print ''; } @@ -584,13 +584,13 @@ if ($id > 0 || ! empty($ref)) // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { - print ''; - print ''; + print ''; + print ''; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 IRPF { - print ''; - print ''; + print ''; + print ''; } // Total TTC @@ -640,7 +640,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { print ''; } @@ -650,8 +650,8 @@ if ($id > 0 || ! empty($ref)) } print "\n"; - $toBeShipped=array(); - $toBeShippedTotal=0; + $toBeShipped = array(); + $toBeShippedTotal = 0; while ($i < $num) { $objp = $db->fetch_object($resql); @@ -663,12 +663,12 @@ if ($id > 0 || ! empty($ref)) if (empty($reshook)) { // Show product and description - $type=isset($objp->type)?$objp->type:$objp->product_type; + $type = isset($objp->type) ? $objp->type : $objp->product_type; // Try to enhance type detection using date_start and date_end for free lines where type // was not saved. - if (! empty($objp->date_start)) $type=1; - if (! empty($objp->date_end)) $type=1; + if (!empty($objp->date_start)) $type = 1; + if (!empty($objp->date_end)) $type = 1; print ''; @@ -676,7 +676,7 @@ if ($id > 0 || ! empty($ref)) if ($objp->fk_product > 0) { // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object->fetch_thirdparty(); @@ -742,11 +742,11 @@ if ($id > 0 || ! empty($ref)) else { print "'; + print ''; // Qty already shipped - $qtyProdCom=$objp->qty; + $qtyProdCom = $objp->qty; print ''; // Qty remains to ship print '\n"; // Show subproducts lines - if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS)) + if ($objp->fk_product > 0 && !empty($conf->global->PRODUIT_SOUSPRODUITS)) { // Set tree of subproducts in product->sousprods $product->get_sousproduits_arbo(); @@ -817,12 +817,12 @@ if ($id > 0 || ! empty($ref)) //var_dump($prods_arbo); if (count($prods_arbo) > 0) { - foreach($prods_arbo as $key => $value) + foreach ($prods_arbo as $key => $value) { - $img=''; + $img = ''; if ($value['stock'] < $value['stock_alert']) { - $img=img_warning($langs->trans("StockTooLow")); + $img = img_warning($langs->trans("StockTooLow")); } print ''; print ''; @@ -837,7 +837,7 @@ if ($id > 0 || ! empty($ref)) } $db->free($resql); - if (! $num) + if (!$num) { print ''; - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { //print ''; //print ''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { - $formproject=new FormProjets($db); + $formproject = new FormProjets($db); $langs->load("project"); @@ -939,8 +939,8 @@ if ($action == 'create') else $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid'); */ - $numprojet=$formproject->select_projects($soc->id, $projectid, 'projectid'); - if ($numprojet==0) + $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid'); + if ($numprojet == 0) { print '   '.$langs->trans("AddProject").''; } @@ -952,8 +952,8 @@ if ($action == 'create') { $langs->load("contracts"); print ''; print ''; print '"; @@ -990,8 +990,8 @@ if ($action == 'create') } // Other attributes - $parameters=array('colspan' => ' colspan="2"'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('colspan' => ' colspan="2"'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -999,10 +999,10 @@ if ($action == 'create') } // Show link to origin object - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { - $newclassname=$classname; - if ($newclassname=='Propal') $newclassname='CommercialProposal'; + $newclassname = $classname; + if ($newclassname == 'Propal') $newclassname = 'CommercialProposal'; print ''; // Amount @@ -1037,7 +1037,7 @@ if ($action == 'create') print ''; print ''; } elseif ($origin == 'project' && !empty($projectid)) { - print ''; + print ''; } dol_fiche_end(); @@ -1072,7 +1072,7 @@ if ($action == 'create') print ''; print ''; } elseif ($origin == 'project' && !empty($projectid)) { - print ''; + print ''; } print '
        '; print $langs->trans('Warehouse'); @@ -557,18 +557,18 @@ if ($id > 0 || ! empty($ref)) if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print '
        ' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
        '.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
        ' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
        '.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
        ' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
        '.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
        ' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '
        '.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
        ' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '
        '.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
        '.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("KeepToShip").''.$langs->trans("RealStock").'
        "; - if ($type==1) $text = img_object($langs->trans('Service'), 'service'); + if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); - if (! empty($objp->label)) { - $text.= ' '.$objp->label.''; + if (!empty($objp->label)) { + $text .= ' '.$objp->label.''; print $form->textwithtooltip($text, $objp->description, 3, '', '', $i); } else { print $text.' '.nl2br($objp->description); @@ -758,19 +758,19 @@ if ($id > 0 || ! empty($ref)) } // Qty ordered - print '' . $objp->qty . ''.$objp->qty.''; // Nb of sending products for this line of order - $qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0); + $qtyAlreadyShipped = (!empty($object->expeditions[$objp->rowid]) ? $object->expeditions[$objp->rowid] : 0); print $qtyAlreadyShipped; print ''; - if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + if ($type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped; $toBeShippedTotal += $toBeShipped[$objp->fk_product]; @@ -789,7 +789,7 @@ if ($id > 0 || ! empty($ref)) $product->load_stock('warehouseopen'); } - if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && ! empty($conf->stock->enabled)) + if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && !empty($conf->stock->enabled)) { print ''; print $product->stock_reel; @@ -806,7 +806,7 @@ if ($id > 0 || ! empty($ref)) print "
              -> '.$value['fullpath'].' ('.$value['nb'].') '.$value['nb_total'].'
        '.$langs->trans("NoArticleOfTypeProduct").'
        '; } @@ -882,12 +882,12 @@ if ($id > 0 || ! empty($ref)) // Bouton expedier avec gestion des stocks - if (! empty($conf->stock->enabled) && $object->statut == Commande::STATUS_DRAFT) + if (!empty($conf->stock->enabled) && $object->statut == Commande::STATUS_DRAFT) { print $langs->trans("ValidateOrderFirstBeforeShipment"); } - if (! empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) + if (!empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { if ($user->rights->expedition->creer) { @@ -907,13 +907,13 @@ if ($id > 0 || ! empty($ref)) //print '
        '; print $langs->trans("WarehouseSource"); //print ''; - print $formproduct->selectWarehouses(! empty($object->warehouse_id)?$object->warehouse_id:'ifone', 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200'); + print $formproduct->selectWarehouses(!empty($object->warehouse_id) ? $object->warehouse_id : 'ifone', 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200'); if (count($formproduct->cache_warehouses) <= 0) { print '   '.$langs->trans("WarehouseSourceNotDefined").' '.$langs->trans("AddOne").''; @@ -933,7 +933,7 @@ if ($id > 0 || ! empty($ref)) print ''; - $somethingshown=1; + $somethingshown = 1; } else { diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php index 1bf2c0db8da..48461eec8bf 100644 --- a/htdocs/expensereport/document.php +++ b/htdocs/expensereport/document.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; // Load translation files required by the page -$langs->loadLangs(array("other","trips","companies","interventions")); +$langs->loadLangs(array("other", "trips", "companies", "interventions")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -55,15 +55,15 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="position_name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "position_name"; $object = new ExpenseReport($db); $object->fetch($id, $ref); $upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref); -$modulepart='trip'; +$modulepart = 'trip'; // Load object //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals @@ -73,7 +73,7 @@ $modulepart='trip'; * Actions */ -include DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -82,33 +82,33 @@ include DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title=$langs->trans("ExpenseReport") . " - " . $langs->trans("Documents"); -$helpurl="EN:Module_Expense_Reports"; +$title = $langs->trans("ExpenseReport")." - ".$langs->trans("Documents"); +$helpurl = "EN:Module_Expense_Reports"; llxHeader("", $title, $helpurl); if ($object->id) { $object->fetch_thirdparty(); - $head=expensereport_prepare_head($object); + $head = expensereport_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("ExpenseReport"), -1, 'trip'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
        '; - $morehtmlref.='
        '; + $morehtmlref = '
        '; + $morehtmlref .= '
        '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } print '
        '; @@ -116,7 +116,7 @@ if ($object->id) print ''; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; print ''; print ''; @@ -130,8 +130,8 @@ if ($object->id) $modulepart = 'expensereport'; $permission = $user->rights->expensereport->creer; $permtoedit = $user->rights->expensereport->creer; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index de2c6ba3132..12959e7946f 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -31,14 +31,14 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereportstats.class.ph // Load translation files required by the page $langs->loadLangs(array('trips', 'companies')); -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$mode=GETPOST("mode")?GETPOST("mode"):'customer'; -$object_status=GETPOST('object_status'); +$mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; +$object_status = GETPOST('object_status'); -$userid=GETPOST('userid', 'int'); -$socid=GETPOST('socid', 'int'); if ($socid < 0) $socid=0; +$userid = GETPOST('userid', 'int'); +$socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0; $id = GETPOST('id', 'int'); // Security check @@ -62,11 +62,11 @@ $endyear=$year; * View */ -$form=new Form($db); -$tmpexpensereport=new ExpenseReport($db); +$form = new Form($db); +$tmpexpensereport = new ExpenseReport($db); -$title=$langs->trans("TripsAndExpensesStatistics"); -$dir=$conf->expensereport->dir_temp; +$title = $langs->trans("TripsAndExpensesStatistics"); +$dir = $conf->expensereport->dir_temp; llxHeader('', $title); @@ -120,13 +120,13 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats& $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px2->SetData($data); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px2->SetLegend($legend); @@ -161,13 +161,13 @@ else $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px3->SetData($data); - $i = $startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px3->SetLegend($legend); @@ -187,16 +187,16 @@ if (! $mesg) // Show array $data = $stats->getAllByYear(); -$arrayyears=array(); -foreach($data as $val) { - $arrayyears[$val['year']]=$val['year']; +$arrayyears = array(); +foreach ($data as $val) { + $arrayyears[$val['year']] = $val['year']; } -if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; +if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; -$h=0; +$h = 0; $head = array(); -$head[$h][0] = DOL_URL_ROOT . '/expensereport/stats/index.php'; +$head[$h][0] = DOL_URL_ROOT.'/expensereport/stats/index.php'; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; @@ -222,18 +222,18 @@ print ''; */ // User print ''; // Status print ''; // Year print ''; @@ -251,11 +251,11 @@ print ''; print ''; print ''; -$oldyear=0; +$oldyear = 0; foreach ($data as $val) { $year = $val['year']; - while ($year && $oldyear > $year+1) + while ($year && $oldyear > $year + 1) { // If we have empty year $oldyear--; @@ -274,7 +274,7 @@ foreach ($data as $val) print ''; print ''; print ''; - $oldyear=$year; + $oldyear = $year; } print '
        '.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
        '.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
        '.$langs->trans("User").''; -$include=''; -if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $include='hierarchy'; +$include = ''; +if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $include = 'hierarchy'; print $form->select_dolusers($userid, 'userid', 1, '', 0, $include, '', 0, 0, 0, '', 0, '', 'maxwidth300'); print '
        '.$langs->trans("Status").''; -$liststatus=$tmpexpensereport->statuts; +$liststatus = $tmpexpensereport->statuts; print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4, 0, 0, '', 1); print '
        '.$langs->trans("Year").''; -if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; +if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; arsort($arrayyears); print $form->selectarray('year', $arrayyears, $year, 0); print '
        '.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
        '.price(price2num($val['total'], 'MT'), 1).''.price(price2num($val['avg'], 'MT'), 1).'
        '; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 9447b7e15ea..49f69813ce6 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -45,9 +45,9 @@ if ($conf->contrat->enabled) require_once DOL_DOCUMENT_ROOT."/core/class/html.formcontract.class.php"; require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"; } -if (! empty($conf->global->FICHEINTER_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.".php")) +if (!empty($conf->global->FICHEINTER_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.".php")) { - require_once DOL_DOCUMENT_ROOT ."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.'.php'; + require_once DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.'.php'; } require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -145,7 +145,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $object = $orig; - $action=''; + $action = ''; } } } @@ -161,15 +161,15 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $result=fichinter_create($db, $object, (!GETPOST('model', 'alpha'))?$object->modelpdf:GETPOST('model', 'alpha'), $outputlangs); + $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->modelpdf : GETPOST('model', 'alpha'), $outputlangs); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -177,7 +177,7 @@ if (empty($reshook)) } else { - $mesg='
        '.$object->error.'
        '; + $mesg = '
        '.$object->error.'
        '; } } @@ -190,15 +190,15 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $result=fichinter_create($db, $object, (!GETPOST('model', 'alpha'))?$object->modelpdf:GETPOST('model', 'alpha'), $outputlangs); + $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->modelpdf : GETPOST('model', 'alpha'), $outputlangs); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -206,27 +206,27 @@ if (empty($reshook)) } else { - $mesg='
        '.$object->error.'
        '; + $mesg = '
        '.$object->error.'
        '; } } elseif ($action == 'add' && $user->rights->ficheinter->creer) { - $object->socid = $socid; - $object->duration = GETPOST('duration', 'int'); + $object->socid = $socid; + $object->duration = GETPOST('duration', 'int'); $object->fk_project = GETPOST('projectid', 'int'); $object->fk_contrat = GETPOST('contratid', 'int'); - $object->author = $user->id; + $object->author = $user->id; $object->description = GETPOST('description', 'none'); - $object->ref = $ref; - $object->modelpdf = GETPOST('model', 'alpha'); - $object->note_private = GETPOST('note_private', 'none'); - $object->note_public = GETPOST('note_public', 'none'); + $object->ref = $ref; + $object->modelpdf = GETPOST('model', 'alpha'); + $object->note_private = GETPOST('note_private', 'none'); + $object->note_public = GETPOST('note_public', 'none'); if ($object->socid > 0) { // If creation from another object of another module (Example: origin=propal, originid=1) - if (!empty($origin) && !empty($originid) ) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $_POST['origin']; @@ -237,10 +237,10 @@ if (empty($reshook)) } // For compatibility - if ($element == 'order') { + if ($element == 'order') { $element = $subelement = 'commande'; } - if ($element == 'propal') { + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'contract') { @@ -252,7 +252,7 @@ if (empty($reshook)) // Possibility to add external linked objects with hooks $object->linked_objects[$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) + if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } @@ -273,7 +273,7 @@ if (empty($reshook)) $srcobject = new $classname($db); dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); - $result=$srcobject->fetch($object->origin_id); + $result = $srcobject->fetch($object->origin_id); if ($result > 0) { $srcobject->fetch_thirdparty(); @@ -284,12 +284,12 @@ if (empty($reshook)) $lines = $srcobject->lines; } - $fk_parent_line=0; - $num=count($lines); + $fk_parent_line = 0; + $num = count($lines); - for ($i=0; $i<$num; $i++) + for ($i = 0; $i < $num; $i++) { - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:Product::TYPE_PRODUCT); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : Product::TYPE_PRODUCT); if ($product_type == Product::TYPE_SERVICE || !empty($conf->global->FICHINTER_PRINT_PRODUCTS)) { //only services except if config includes products $duration = 3600; // Default to one hour @@ -301,19 +301,19 @@ if (empty($reshook)) $prod->id = $lines[$i]->fk_product; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $prod->getMultiLangs(); // We show if duration is present on service (so we get it) $prod->fetch($lines[$i]->fk_product); $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if (empty($newlang)) $newlang=$srcobject->thirdparty->default_lang; - if (! empty($newlang)) { + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (empty($newlang)) $newlang = $srcobject->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; } else { $prod->fetch($lines[$i]->fk_product); $label = $lines[$i]->product_label; @@ -349,10 +349,10 @@ if (empty($reshook)) // Common part (predefined or free line) $desc .= dol_htmlentitiesbr($lines[$i]->desc); $desc .= '
        '; - $desc .= ' (' . $langs->trans('Quantity') . ': ' . $lines[$i]->qty . ')'; + $desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')'; - $timearray=dol_getdate(mktime()); - $date_intervention=dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']); + $timearray = dol_getdate(mktime()); + $date_intervention = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']); if ($product_type == Product::TYPE_PRODUCT) { $duration = 0; @@ -383,13 +383,13 @@ if (empty($reshook)) } else { - $mesg=$srcobject->error; + $mesg = $srcobject->error; $error++; } } else { - $mesg=$object->error; + $mesg = $object->error; $error++; } } @@ -398,11 +398,11 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error ++; + $error++; $action = 'create'; } - if (! $error) + if (!$error) { // Extrafields $array_options = $extrafields->getOptionalsFromPost($object->table_element); @@ -412,7 +412,7 @@ if (empty($reshook)) $result = $object->create($user); if ($result > 0) { - $id=$result; // Force raffraichissement sur fiche venant d'etre cree + $id = $result; // Force raffraichissement sur fiche venant d'etre cree } else { @@ -448,21 +448,21 @@ if (empty($reshook)) // Set into a project elseif ($action == 'classin' && $user->rights->ficheinter->creer) { - $result=$object->setProject(GETPOST('projectid', 'int')); + $result = $object->setProject(GETPOST('projectid', 'int')); if ($result < 0) dol_print_error($db, $object->error); } // Set into a contract elseif ($action == 'setcontract' && $user->rights->contrat->creer) { - $result=$object->set_contrat($user, GETPOST('contratid', 'int')); + $result = $object->set_contrat($user, GETPOST('contratid', 'int')); if ($result < 0) dol_print_error($db, $object->error); } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer) { - $result=$object->delete($user); - if ($result<0) { + $result = $object->delete($user); + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -472,35 +472,35 @@ if (empty($reshook)) elseif ($action == 'setdescription' && $user->rights->ficheinter->creer) { - $result=$object->set_description($user, GETPOST('description')); + $result = $object->set_description($user, GETPOST('description')); if ($result < 0) dol_print_error($db, $object->error); } // Add line elseif ($action == "addline" && $user->rights->ficheinter->creer) { - if (!GETPOST('np_desc', 'none') && empty($conf->global->FICHINTER_EMPTY_LINE_DESC) ) + if (!GETPOST('np_desc', 'none') && empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) { - $mesg='
        '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")).'
        '; + $mesg = '
        '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")).'
        '; $error++; } if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && !GETPOST('durationhour', 'int') && !GETPOST('durationmin', 'int')) { - $mesg='
        '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Duration")).'
        '; + $mesg = '
        '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Duration")).'
        '; $error++; } if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && GETPOST('durationhour', 'int') >= 24 && GETPOST('durationmin', 'int') > 0) { - $mesg='
        '.$langs->trans("ErrorValueTooHigh").'
        '; + $mesg = '
        '.$langs->trans("ErrorValueTooHigh").'
        '; $error++; } - if (! $error) + if (!$error) { $db->begin(); - $desc=GETPOST('np_desc', 'none'); + $desc = GETPOST('np_desc', 'none'); $date_intervention = dol_mktime(GETPOST('dihour', 'int'), GETPOST('dimin', 'int'), 0, GETPOST('dimonth', 'int'), GETPOST('diday', 'int'), GETPOST('diyear', 'int')); - $duration = empty($conf->global->FICHINTER_WITHOUT_DURATION)?convertTime2Seconds(GETPOST('durationhour', 'int'), GETPOST('durationmin', 'int')) : 0; + $duration = empty($conf->global->FICHINTER_WITHOUT_DURATION) ?convertTime2Seconds(GETPOST('durationhour', 'int'), GETPOST('durationmin', 'int')) : 0; // Extrafields @@ -518,10 +518,10 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -537,7 +537,7 @@ if (empty($reshook)) } else { - $mesg=$object->error; + $mesg = $object->error; $db->rollback(); } } @@ -546,7 +546,7 @@ if (empty($reshook)) // Classify Billed elseif ($action == 'classifybilled' && $user->rights->ficheinter->creer) { - $result=$object->setStatut(2); + $result = $object->setStatut(2); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -561,7 +561,7 @@ if (empty($reshook)) // Classify unbilled elseif ($action == 'classifyunbilled' && $user->rights->ficheinter->creer) { - $result=$object->setStatut(1); + $result = $object->setStatut(1); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -569,14 +569,14 @@ if (empty($reshook)) } else { - $mesg='
        '.$object->error.'
        '; + $mesg = '
        '.$object->error.'
        '; } } // Classify Done elseif ($action == 'classifydone' && $user->rights->ficheinter->creer) { - $result=$object->setStatut(3); + $result = $object->setStatut(3); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -606,13 +606,13 @@ if (empty($reshook)) } $object->fetch_thirdparty(); - $desc = GETPOST('np_desc'); - $date_inter = dol_mktime(GETPOST('dihour', 'int'), GETPOST('dimin', 'int'), 0, GETPOST('dimonth', 'int'), GETPOST('diday', 'int'), GETPOST('diyear', 'int')); - $duration = convertTime2Seconds(GETPOST('durationhour', 'int'), GETPOST('durationmin', 'int')); + $desc = GETPOST('np_desc'); + $date_inter = dol_mktime(GETPOST('dihour', 'int'), GETPOST('dimin', 'int'), 0, GETPOST('dimonth', 'int'), GETPOST('diday', 'int'), GETPOST('diyear', 'int')); + $duration = convertTime2Seconds(GETPOST('durationhour', 'int'), GETPOST('durationmin', 'int')); - $objectline->datei = $date_inter; - $objectline->desc = $desc; - $objectline->duration = $duration; + $objectline->datei = $date_inter; + $objectline->desc = $desc; + $objectline->duration = $duration; // Extrafields $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -628,10 +628,10 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -653,7 +653,7 @@ if (empty($reshook)) dol_print_error($db); exit; } - $result=$objectline->deleteline($user); + $result = $objectline->deleteline($user); if ($object->fetch($objectline->fk_fichinter) <= 0) { @@ -663,10 +663,10 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -683,10 +683,10 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -703,10 +703,10 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -721,9 +721,9 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='FICHINTER_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_FICHINTER_TO'; - $trackid='int'.$object->id; + $trigger_name = 'FICHINTER_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_FICHINTER_TO'; + $trackid = 'int'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc @@ -752,7 +752,7 @@ if (empty($reshook)) if ($error) $action = 'edit_extras'; } - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer) { if ($action == 'addcontact') { @@ -784,7 +784,7 @@ if (empty($reshook)) // bascule du statut d'un contact elseif ($action == 'swapstatut') { - $result=$object->swapContactStatus(GETPOST('ligne', 'int')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } // Efface un contact @@ -812,7 +812,7 @@ if (empty($reshook)) $form = new Form($db); $formfile = new FormFile($db); if ($conf->contrat->enabled) $formcontract = new FormContract($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } llxHeader('', $langs->trans("Intervention")); @@ -823,13 +823,13 @@ if ($action == 'create') * Creation d'une nouvelle fiche d'intervention */ - $soc=new Societe($db); + $soc = new Societe($db); print load_fiche_titre($langs->trans("AddIntervention"), '', 'title_commercial'); dol_htmloutput_mesg($mesg); - if ($socid) $res=$soc->fetch($socid); + if ($socid) $res = $soc->fetch($socid); if (GETPOST('origin') && GETPOST('originid')) { @@ -843,15 +843,15 @@ if ($action == 'create') if ($element == 'project') { - $projectid=GETPOST('originid'); + $projectid = GETPOST('originid'); } else { // For compatibility - if ($element == 'order' || $element == 'commande') { + if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; } - if ($element == 'propal') { + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'contract') { @@ -870,12 +870,12 @@ if ($action == 'create') } $objectsrc->fetch_thirdparty(); - $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); + $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); $soc = $objectsrc->thirdparty; - $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private', 'none'))); - $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public', 'none')); + $note_private = (!empty($objectsrc->note) ? $objectsrc->note : (!empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private', 'none'))); + $note_public = (!empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public', 'none')); // Object source contacts list $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); @@ -885,7 +885,7 @@ if ($action == 'create') $projectid = GETPOST('projectid', 'int'); } - if (! $conf->global->FICHEINTER_ADDON) + if (!$conf->global->FICHEINTER_ADDON) { dol_print_error($db, $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined")); exit; @@ -901,7 +901,7 @@ if ($action == 'create') if ($socid > 0) { - $soc=new Societe($db); + $soc = new Societe($db); $soc->fetch($socid); print '
        '; @@ -926,9 +926,9 @@ if ($action == 'create') print '
        '.$langs->trans("Contract").''; - $numcontrat=$formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1); - if ($numcontrat==0) + $numcontrat = $formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1); + if ($numcontrat == 0) { print '   '.$langs->trans("AddContract").''; } @@ -964,7 +964,7 @@ if ($action == 'create') print '
        '.$langs->trans("DefaultModel").''; - $liste=ModelePDFFicheinter::liste_modeles($db); + $liste = ModelePDFFicheinter::liste_modeles($db); print $form->selectarray('model', $liste, $conf->global->FICHEINTER_ADDON_PDF); print "
        '.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
        '; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -1409,16 +1409,16 @@ elseif ($id > 0 || ! empty($ref)) print dol_htmlentitiesbr($objp->description); // Date - print ''; + print ''; // Duration - print ''; + print ''; print "\n"; // Icone d'edition et suppression - if ($object->statut == 0 && $user->rights->ficheinter->creer) + if ($object->statut == 0 && $user->rights->ficheinter->creer) { print ''; @@ -1517,7 +1517,7 @@ elseif ($id > 0 || ! empty($ref)) // Add new line if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline' && empty($conf->global->FICHINTER_DISABLE_DETAILS)) { - if (! $num) + if (!$num) { print '
        '.$langs->trans("ThirdParty").''; @@ -1086,13 +1086,13 @@ if ($action == 'create') print ''; print ''; print '     '; - print ''; + print ''; print ''; print ''; } } -elseif ($id > 0 || ! empty($ref)) +elseif ($id > 0 || !empty($ref)) { /* * Affichage en mode visu @@ -1101,7 +1101,7 @@ elseif ($id > 0 || ! empty($ref)) $object->fetch($id, $ref); $object->fetch_thirdparty(); - $soc=new Societe($db); + $soc = new Societe($db); $soc->fetch($object->socid); dol_htmloutput_mesg($mesg); @@ -1110,7 +1110,7 @@ elseif ($id > 0 || ! empty($ref)) dol_fiche_head($head, 'card', $langs->trans("InterventionCard"), -1, 'intervention'); - $formconfirm=''; + $formconfirm = ''; // Confirm deletion of intervention if ($action == 'delete') @@ -1136,7 +1136,7 @@ elseif ($id > 0 || ! empty($ref)) { $numref = $object->ref; } - $text=$langs->trans('ConfirmValidateIntervention', $numref); + $text = $langs->trans('ConfirmValidateIntervention', $numref); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateIntervention'), $text, 'confirm_validate', '', 1, 1); } @@ -1162,17 +1162,17 @@ elseif ($id > 0 || ! empty($ref)) // 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' // => 1), - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '', '', 0, 0, null, 0, 'minwidth200'))); + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '', '', 0, 0, null, 0, 'minwidth200'))); // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } if (!$formconfirm) { - $parameters=array('lineid'=>$lineid); + $parameters = array('lineid'=>$lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; } // Print form confirm @@ -1233,7 +1233,7 @@ elseif ($id > 0 || ! empty($ref)) print ''; - if (! empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES)) + if (!empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES)) { // Date Start print ''; @@ -1285,7 +1285,7 @@ elseif ($id > 0 || ! empty($ref)) print '
        '.$langs->trans("Dateo").''; if ($action == 'contrat') { - $formcontract= new Formcontract($db); + $formcontract = new Formcontract($db); $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1); } else @@ -1308,7 +1308,7 @@ elseif ($id > 0 || ! empty($ref)) // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
        '; @@ -1336,14 +1336,14 @@ elseif ($id > 0 || ! empty($ref)) print '

        '; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); @@ -1368,12 +1368,12 @@ elseif ($id > 0 || ! empty($ref)) // Intervention lines $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,'; - $sql.= ' ft.date as date_intervention'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; - $sql.= ' WHERE ft.fk_fichinter = '.$object->id; + $sql .= ' ft.date as date_intervention'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; + $sql .= ' WHERE ft.fk_fichinter = '.$object->id; if (!empty($conf->global->FICHINTER_HIDE_EMPTY_DURATION)) - $sql.= ' AND ft.duree <> 0'; - $sql.= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid'; + $sql .= ' AND ft.duree <> 0'; + $sql .= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid'; $resql = $db->query($sql); if ($resql) @@ -1389,7 +1389,7 @@ elseif ($id > 0 || ! empty($ref)) print '
        '.$langs->trans('Description').''.$langs->trans('Date').''.(empty($conf->global->FICHINTER_WITHOUT_DURATION)?$langs->trans('Duration'):'').''.(empty($conf->global->FICHINTER_WITHOUT_DURATION) ? $langs->trans('Duration') : '').'   '.(empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)?dol_print_date($db->jdate($objp->date_intervention), 'dayhour'):dol_print_date($db->jdate($objp->date_intervention), 'day')).''.(empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR) ?dol_print_date($db->jdate($objp->date_intervention), 'dayhour') : dol_print_date($db->jdate($objp->date_intervention), 'day')).''.(empty($conf->global->FICHINTER_WITHOUT_DURATION)?convertSecondToTime($objp->duree):'').''.(empty($conf->global->FICHINTER_WITHOUT_DURATION) ?convertSecondToTime($objp->duree) : '').''; print 'rowid.'#'.$objp->rowid.'">'; @@ -1438,7 +1438,7 @@ elseif ($id > 0 || ! empty($ref)) print img_up(); print ''; } - if ($i < $num-1) + if ($i < $num - 1) { print 'rowid.'">'; print img_down(); @@ -1473,7 +1473,7 @@ elseif ($id > 0 || ! empty($ref)) // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('np_desc', $objp->description, '', 164, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%'); + $doleditor = new DolEditor('np_desc', $objp->description, '', 164, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%'); $doleditor->Create(); print '
        '; @@ -1526,7 +1526,7 @@ elseif ($id > 0 || ! empty($ref)) print ''; // ancre print $langs->trans('Description').''; print ''; - print ''; + print ''; print ''; print "\n"; } @@ -1535,7 +1535,7 @@ elseif ($id > 0 || ! empty($ref)) 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 ''; @@ -168,14 +168,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) } print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print '"; @@ -346,18 +346,18 @@ if (count($tasksarray)>0) //if ($s) $tasks[$taskcursor]['task_resources']=implode(',',$idofusers); $tasks[$taskcursor]['task_resources'] = $s; //print "xxx".$val->id.$tasks[$taskcursor]['task_resources']; - $tasks[$taskcursor]['note']=$task->note_public; + $tasks[$taskcursor]['note'] = $task->note_public; $taskcursor++; } // Search parent to set task_parent_alternate_id (requird by ganttchart) - foreach($tasks as $tmpkey => $tmptask) + foreach ($tasks as $tmpkey => $tmptask) { - foreach($tasks as $tmptask2) + foreach ($tasks as $tmptask2) { if ($tmptask2['task_id'] == $tmptask['task_parent']) { - $tasks[$tmpkey]['task_parent_alternate_id']=$tmptask2['task_alternate_id']; + $tasks[$tmpkey]['task_parent_alternate_id'] = $tmptask2['task_alternate_id']; break; } } @@ -366,14 +366,14 @@ if (count($tasksarray)>0) print "\n"; - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { //var_dump($_SESSION); // How the date for data are formated (format used bu jsgantt) - $dateformatinput='yyyy-mm-dd'; + $dateformatinput = 'yyyy-mm-dd'; // How the date for data are formated (format used by dol_print_date) - $dateformatinput2='standard'; + $dateformatinput2 = 'standard'; //var_dump($dateformatinput); //var_dump($dateformatinput2); diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index ff361e75d3d..e6d35f5ee9e 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -73,15 +73,15 @@ if (!$user->rights->projet->lire) accessforbidden(); * Actions */ -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid); +$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'); // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $actioncode=''; - $search_agenda_label=''; + $actioncode = ''; + $search_agenda_label = ''; } @@ -93,43 +93,43 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $form = new Form($db); $object = new Project($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); - if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $object->info($object->id); } -$title=$langs->trans("Project").' - '.$object->ref.' '.$object->name; -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Info"); -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$title = $langs->trans("Project").' - '.$object->ref.' '.$object->name; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); $head = project_prepare_head($object); -dol_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); +dol_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); // Project card $linkback = ''.$langs->trans("BackToList").''; -$morehtmlref='
        '; +$morehtmlref = '
        '; // Title -$morehtmlref.=$object->title; +$morehtmlref .= $object->title; // Thirdparty if ($object->thirdparty->id > 0) { - $morehtmlref.='
        '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= '
        '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } -$morehtmlref.='
        '; +$morehtmlref .= '
        '; // Define a complementary filter for search of next/prev ref. -if (! $user->rights->projet->all->lire) +if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")"; + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -171,15 +171,15 @@ if (!empty($object->id)) { print '
        '; - $param='&id='.$object->id; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $param = '&id='.$object->id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); // List of all actions - $filters=array(); - $filters['search_agenda_label']=$search_agenda_label; + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 54736ebc40f..6d47b582df2 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -147,7 +147,7 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) $error++; } - if (! $error) + if (!$error) { if ($id || $ref) { @@ -155,10 +155,10 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) } else { - if (! GETPOST('taskid', 'int') || GETPOST('taskid', 'int') < 0) + if (!GETPOST('taskid', 'int') || GETPOST('taskid', 'int') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), null, 'errors'); - $action='createtime'; + $action = 'createtime'; $error++; } else @@ -167,22 +167,22 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) } } - if (! $error) + if (!$error) { $object->fetch_projet(); if (empty($object->project->statut)) { setEventMessages($langs->trans("ProjectMustBeValidatedFirst"), null, 'errors'); - $action='createtime'; + $action = 'createtime'; $error++; } else { $object->timespent_note = $_POST["timespent_note"]; - if (GETPOST('progress', 'int') > 0) $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value - $object->timespent_duration = $_POST["timespent_durationhour"]*60*60; // We store duration in seconds - $object->timespent_duration+= ($_POST["timespent_durationmin"]?$_POST["timespent_durationmin"]:0)*60; // We store duration in seconds + if (GETPOST('progress', 'int') > 0) $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value + $object->timespent_duration = $_POST["timespent_durationhour"] * 60 * 60; // We store duration in seconds + $object->timespent_duration += ($_POST["timespent_durationmin"] ? $_POST["timespent_durationmin"] : 0) * 60; // We store duration in seconds if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered { $object->timespent_date = dol_mktime(GETPOST("timehour"), GETPOST("timemin"), 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); @@ -193,7 +193,7 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); } $object->timespent_fk_user = $_POST["userid"]; - $result=$object->addTimeSpent($user); + $result = $object->addTimeSpent($user); if ($result >= 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -208,14 +208,14 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) } else { - if (empty($id)) $action='createtime'; - else $action='createtime'; + if (empty($id)) $action = 'createtime'; + else $action = 'createtime'; } } -if (($action == 'updateline' || $action == 'updatesplitline') && ! $_POST["cancel"] && $user->rights->projet->lire) +if (($action == 'updateline' || $action == 'updatesplitline') && !$_POST["cancel"] && $user->rights->projet->lire) { - $error=0; + $error = 0; if (empty($_POST["new_durationhour"]) && empty($_POST["new_durationmin"])) { @@ -223,7 +223,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && ! $_POST["cance $error++; } - if (! $error) + if (!$error) { $object->fetch($id, $ref); // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) @@ -231,8 +231,8 @@ if (($action == 'updateline' || $action == 'updatesplitline') && ! $_POST["cance $object->timespent_id = $_POST["lineid"]; $object->timespent_note = $_POST["timespent_note_line"]; $object->timespent_old_duration = $_POST["old_duration"]; - $object->timespent_duration = $_POST["new_durationhour"]*60*60; // We store duration in seconds - $object->timespent_duration+= $_POST["new_durationmin"]*60; // We store duration in seconds + $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds + $object->timespent_duration += $_POST["new_durationmin"] * 60; // We store duration in seconds if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered { $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); @@ -244,7 +244,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && ! $_POST["cance } $object->timespent_fk_user = $_POST["userid_line"]; - $result=$object->updateTimeSpent($user); + $result = $object->updateTimeSpent($user); if ($result >= 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -257,7 +257,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && ! $_POST["cance } else { - $action=''; + $action = ''; } } @@ -272,7 +272,7 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->l $langs->load("errors"); setEventMessages($langs->trans($object->error), null, 'errors'); $error++; - $action=''; + $action = ''; } else { @@ -281,51 +281,51 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->l } // Retreive First Task ID of Project if withprojet is on to allow project prev next to work -if (! empty($project_ref) && ! empty($withproject)) +if (!empty($project_ref) && !empty($withproject)) { if ($projectstatic->fetch(0, $project_ref) > 0) { - $tasksarray=$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); + $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); if (count($tasksarray) > 0) { - $id=$tasksarray[0]->id; + $id = $tasksarray[0]->id; } else { - header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.($withproject?'&withproject=1':'').(empty($mode)?'':'&mode='.$mode)); + header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.($withproject ? '&withproject=1' : '').(empty($mode) ? '' : '&mode='.$mode)); exit; } } } // To show all time lines for project -$projectidforalltimes=0; +$projectidforalltimes = 0; if (GETPOST('projectid', 'int') > 0) { - $projectidforalltimes=GETPOST('projectid', 'int'); + $projectidforalltimes = GETPOST('projectid', 'int'); - $result=$projectstatic->fetch($projectidforalltimes); - if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - $res=$projectstatic->fetch_optionals(); + $result = $projectstatic->fetch($projectidforalltimes); + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + $res = $projectstatic->fetch_optionals(); } elseif (GETPOST('project_ref', 'alpha')) { $projectstatic->fetch(0, GETPOST('project_ref', 'alpha')); - $projectidforalltimes=$projectstatic->id; - $withproject=1; + $projectidforalltimes = $projectstatic->id; + $withproject = 1; } elseif ($id > 0) { $object->fetch($id); - $result=$projectstatic->fetch($object->fk_project); + $result = $projectstatic->fetch($object->fk_project); } if ($action == 'confirm_generateinvoice') { - if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - if (! ($projectstatic->thirdparty->id > 0)) + if (!($projectstatic->thirdparty->id > 0)) { setEventMessages($langs->trans("ThirdPartyRequiredToGenerateInvoice"), null, 'errors'); } @@ -336,8 +336,8 @@ if ($action == 'confirm_generateinvoice') include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $tmpinvoice = new Facture($db); - $tmptimespent=new Task($db); - $tmpproduct=new Product($db); + $tmptimespent = new Task($db); + $tmpproduct = new Product($db); $fuser = new User($db); $db->begin(); @@ -347,7 +347,7 @@ if ($action == 'confirm_generateinvoice') $tmpproduct->fetch($idprod); $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); - $pu_ht = empty($dataforprice['pu_ht'])?0:$dataforprice['pu_ht']; + $pu_ht = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht']; $txtva = $dataforprice['tva_tx']; $localtax1 = $dataforprice['localtax1']; $localtax2 = $dataforprice['localtax2']; @@ -371,18 +371,18 @@ if ($action == 'confirm_generateinvoice') setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors'); } - if (! $error) + if (!$error) { - $arrayoftasks=array(); - foreach($toselect as $key => $value) + $arrayoftasks = array(); + foreach ($toselect as $key => $value) { // Get userid, timepent $object->fetchTimeSpent($value); - $arrayoftasks[$object->timespent_fk_user]['timespent']+=$object->timespent_duration; - $arrayoftasks[$object->timespent_fk_user]['totalvaluetodivideby3600']+=($object->timespent_duration * $object->timespent_thm); + $arrayoftasks[$object->timespent_fk_user]['timespent'] += $object->timespent_duration; + $arrayoftasks[$object->timespent_fk_user]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); } - foreach($arrayoftasks as $userid => $value) + foreach ($arrayoftasks as $userid => $value) { $fuser->fetch($userid); //$pu_ht = $value['timespent'] * $fuser->thm; @@ -402,10 +402,10 @@ if ($action == 'confirm_generateinvoice') $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent - $sql ='UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; - $sql.=' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; + $sql .= ' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid; $result = $db->query($sql); - if (! $result) + if (!$result) { $error++; setEventMessages($db->lasterror(), null, 'errors'); @@ -414,7 +414,7 @@ if ($action == 'confirm_generateinvoice') } } - if (! $error) + if (!$error) { $urltoinvoice = $tmpinvoice->getNomUrl(0); setEventMessages($langs->trans("InvoiceGeneratedFromTimeSpent", $urltoinvoice), null, 'mesgs'); @@ -434,7 +434,7 @@ if ($action == 'confirm_generateinvoice') * View */ -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); llxHeader("", $langs->trans("Task")); @@ -443,24 +443,24 @@ $formother = new FormOther($db); $formproject = new FormProjets($db); $userstatic = new User($db); -if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) +if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { /* * Fiche projet en mode visu */ if ($projectidforalltimes > 0) { - $result=$projectstatic->fetch($projectidforalltimes); - if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - $res=$projectstatic->fetch_optionals(); + $result = $projectstatic->fetch($projectidforalltimes); + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + $res = $projectstatic->fetch_optionals(); } elseif ($object->fetch($id, $ref) >= 0) { - if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); - $result=$projectstatic->fetch($object->fk_project); - if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); - if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - $res=$projectstatic->fetch_optionals(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + $result = $projectstatic->fetch($object->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + $res = $projectstatic->fetch_optionals(); $object->project = clone $projectstatic; } @@ -473,32 +473,32 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($withproject) { // Tabs for project - if (empty($id)) $tab='timespent'; - else $tab='tasks'; - $head=project_prepare_head($projectstatic); - dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); + if (empty($id)) $tab = 'timespent'; + else $tab = 'tasks'; + $head = project_prepare_head($projectstatic); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); - $param=($mode=='mine'?'&mode=mine':''); + $param = ($mode == 'mine' ? '&mode=mine' : ''); // Project card $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
        '; + $morehtmlref = '
        '; // Title - $morehtmlref.=$projectstatic->title; + $morehtmlref .= $projectstatic->title; // Thirdparty if ($projectstatic->thirdparty->id > 0) { - $morehtmlref.='
        '.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= '
        '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; // Define a complementary filter for search of next/prev ref. - if (! $user->rights->projet->all->lire) + if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")"; + $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -546,10 +546,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Date start - end print ''; @@ -577,7 +577,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; // Bill time - if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print ''; @@ -729,8 +729,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; print ''; - if (! empty($arrayfields['t.ref']['checked'])) + if (!empty($arrayfields['t.ref']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['ty.label']['checked'])) + if (!empty($arrayfields['ty.label']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields $obj = (Object) $resource->array_options; @@ -270,15 +270,15 @@ if ($ret) print img_delete(); print ''; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; } } else { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index ae2622d7f93..7b2e6ead2cc 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -58,8 +58,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='a.datep,a.id'; -if (! $sortorder) $sortorder='DESC,DESC'; +if (!$sortfield) $sortfield = 'a.datep,a.id'; +if (!$sortorder) $sortorder = 'DESC,DESC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendathirdparty')); @@ -69,14 +69,14 @@ $hookmanager->initHooks(array('agendathirdparty')); * Actions */ -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid); +$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)) { // Cancel - if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -85,8 +85,8 @@ if (empty($reshook)) // 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 { - $actioncode=''; - $search_agenda_label=''; + $actioncode = ''; + $search_agenda_label = ''; } } @@ -134,16 +134,16 @@ if ($socid > 0) // Actions buttons - $objthirdparty=$object; - $objcon=new stdClass(); + $objthirdparty = $object; + $objcon = new stdClass(); - $out=''; - $permok=$user->rights->agenda->myactions->create; - if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok) + $out = ''; + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='trans("AddAnAction"),'filenew'); //$out.=""; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 8e0c36aa451..f907bd210f6 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -34,9 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $langs->loadLangs(array("companies", "other")); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm'); -$id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); +$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); // Security check @@ -80,7 +80,7 @@ $hookmanager->initHooks(array('thirdpartydocument','globalcard')); * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -89,9 +89,9 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title=$langs->trans("ThirdParty").' - '.$langs->trans("Files"); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Files"); -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = $langs->trans("ThirdParty").' - '.$langs->trans("Files"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Files"); +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); if ($object->id) @@ -125,7 +125,7 @@ if ($object->id) print '
        '.$langs->trans('Date').''.(empty($conf->global->FICHINTER_WITHOUT_DURATION)?$langs->trans('Duration'):'').''.(empty($conf->global->FICHINTER_WITHOUT_DURATION) ? $langs->trans('Duration') : '').' 
        '; // editeur wysiwyg if (empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'alpha'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%'); $doleditor->Create(); } @@ -1543,12 +1543,12 @@ elseif ($id > 0 || ! empty($ref)) // Date intervention print ''; - $now=dol_now(); - $timearray=dol_getdate($now); - if (! GETPOST('diday', 'int')) { - $timewithnohour=dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']); + $now = dol_now(); + $timearray = dol_getdate($now); + if (!GETPOST('diday', 'int')) { + $timewithnohour = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']); } else { - $timewithnohour=dol_mktime(GETPOST('dihour', 'int'), GETPOST('dimin', 'int'), 0, GETPOST('dimonth', 'int'), GETPOST('diday', 'int'), GETPOST('diyear', 'int')); + $timewithnohour = dol_mktime(GETPOST('dihour', 'int'), GETPOST('dimin', 'int'), 0, GETPOST('dimonth', 'int'), GETPOST('diday', 'int'), GETPOST('diyear', 'int')); } if (!empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) { print $form->selectDate($timewithnohour, 'di', 0, 0, 0, "addinter"); @@ -1614,8 +1614,8 @@ elseif ($id > 0 || ! empty($ref)) // Validate if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->validate)) { - print ''; + print ''; } } @@ -1646,7 +1646,7 @@ elseif ($id > 0 || ! empty($ref)) } // Proposal - if ($conf->service->enabled && ! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT) + if ($conf->service->enabled && !empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("propal"); if ($object->statut < Fichinter::STATUS_BILLED) @@ -1657,7 +1657,7 @@ elseif ($id > 0 || ! empty($ref)) } // Invoicing - if (! empty($conf->facture->enabled) && $object->statut > Fichinter::STATUS_DRAFT) + if (!empty($conf->facture->enabled) && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("bills"); if ($object->statut < Fichinter::STATUS_BILLED) @@ -1666,7 +1666,7 @@ elseif ($id > 0 || ! empty($ref)) else print ''; } - if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 + if (!empty($conf->global->FICHINTER_CLASSIFY_BILLED)) // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 { if ($object->statut != Fichinter::STATUS_BILLED) { @@ -1687,7 +1687,7 @@ elseif ($id > 0 || ! empty($ref)) // Clone if ($user->rights->ficheinter->creer) { - print ''; + print ''; } // Delete @@ -1709,11 +1709,11 @@ elseif ($id > 0 || ! empty($ref)) /* * Built documents */ - $filename=dol_sanitizeFileName($object->ref); - $filedir=$conf->ficheinter->dir_output . "/".$filename; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$user->rights->ficheinter->lire; - $delallowed=$user->rights->ficheinter->creer; + $filename = dol_sanitizeFileName($object->ref); + $filedir = $conf->ficheinter->dir_output."/".$filename; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->ficheinter->lire; + $delallowed = $user->rights->ficheinter->creer; print $formfile->showdocuments('ficheinter', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); // Show links to link elements @@ -1725,7 +1725,7 @@ elseif ($id > 0 || ! empty($ref)) // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); + $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'fichinter', $socid, 1); print ''; @@ -1738,8 +1738,8 @@ elseif ($id > 0 || ! empty($ref)) } // Presend form - $modelmail='fichinter_send'; - $defaulttopic='SendInterventionRef'; + $modelmail = 'fichinter_send'; + $defaulttopic = 'SendInterventionRef'; $diroutput = $conf->ficheinter->dir_output; $trackid = 'int'.$object->id; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b46077ee930..e09f99942dd 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -34,7 +34,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/commonorder.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; +if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; /** @@ -45,12 +45,12 @@ class CommandeFournisseur extends CommonOrder /** * @var string ID to identify managed object */ - public $element='order_supplier'; + public $element = 'order_supplier'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='commande_fournisseur'; + public $table_element = 'commande_fournisseur'; /** * @var int Name of subtable line @@ -97,19 +97,19 @@ class CommandeFournisseur extends CommonOrder public $ref_supplier; public $brouillon; - public $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Ordered/Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially + public $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Ordered/Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially // -> 7=Canceled/Never received -> (reopen) 3=Process runing // -> 6=Canceled -> (reopen) 2=Approved // -> 9=Refused -> (reopen) 1=Validated // Note: billed or not is on another field "billed" - public $statuts; // List of status + public $statuts; // List of status public $socid; public $fourn_id; public $date; public $date_valid; public $date_approve; - public $date_approve2; // Used when SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set + public $date_approve2; // Used when SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set public $date_commande; /** @@ -119,8 +119,8 @@ class CommandeFournisseur extends CommonOrder public $total_ht; public $total_tva; - public $total_localtax1; // Total Local tax 1 - public $total_localtax2; // Total Local tax 2 + public $total_localtax1; // Total Local tax 1 + public $total_localtax2; // Total Local tax 2 public $total_ttc; public $source; @@ -169,7 +169,7 @@ class CommandeFournisseur extends CommonOrder //Add for supplier_proposal public $origin; public $origin_id; - public $linked_objects=array(); + public $linked_objects = array(); // Multicurrency /** @@ -342,13 +342,13 @@ class CommandeFournisseur extends CommonOrder // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_code = $obj->multicurrency_code; $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); $this->db->free($resql); @@ -361,7 +361,7 @@ class CommandeFournisseur extends CommonOrder /* * Lines */ - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { return -1; @@ -373,7 +373,7 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; return -1; } } @@ -389,21 +389,21 @@ class CommandeFournisseur extends CommonOrder { // phpcs:enable //$result=$this->fetch_lines(); - $this->lines=array(); + $this->lines = array(); $sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description, l.qty,"; - $sql.= " l.vat_src_code, l.tva_tx, l.remise_percent, l.subprice,"; - $sql.= " l.localtax1_tx, l. localtax2_tx, l.localtax1_type, l. localtax2_type, l.total_localtax1, l.total_localtax2,"; - $sql.= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,"; - $sql.= " l.fk_unit,"; - $sql.= " l.date_start, l.date_end,"; - $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc'; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql.= " WHERE l.fk_commande = ".$this->id; + $sql .= " l.vat_src_code, l.tva_tx, l.remise_percent, l.subprice,"; + $sql .= " l.localtax1_tx, l. localtax2_tx, l.localtax1_type, l. localtax2_type, l.total_localtax1, l.total_localtax2,"; + $sql .= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,"; + $sql .= " l.fk_unit,"; + $sql .= " l.date_start, l.date_end,"; + $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc'; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql .= " WHERE l.fk_commande = ".$this->id; if ($only_product) $sql .= ' AND p.fk_product_type = 0'; - $sql.= " ORDER BY l.rang, l.rowid"; + $sql .= " ORDER BY l.rang, l.rowid"; //print $sql; dol_syslog(get_class($this)."::fetch get lines", LOG_DEBUG); @@ -415,9 +415,9 @@ class CommandeFournisseur extends CommonOrder while ($i < $num) { - $objp = $this->db->fetch_object($result); + $objp = $this->db->fetch_object($result); - $line = new CommandeFournisseurLigne($this->db); + $line = new CommandeFournisseurLigne($this->db); $line->id = $objp->rowid; $line->desc = $objp->description; @@ -429,7 +429,7 @@ class CommandeFournisseur extends CommonOrder $line->localtax1_type = $objp->localtax1_type; $line->localtax2_type = $objp->localtax2_type; $line->subprice = $objp->subprice; - $line->pu_ht = $objp->subprice; + $line->pu_ht = $objp->subprice; $line->remise_percent = $objp->remise_percent; $line->vat_src_code = $objp->vat_src_code; @@ -446,18 +446,18 @@ class CommandeFournisseur extends CommonOrder $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; - $line->ref = $objp->product_ref; // Ref of product - $line->product_ref = $objp->product_ref; // Ref of product - $line->ref_fourn = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since - $line->ref_supplier = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since + $line->ref = $objp->product_ref; // Ref of product + $line->product_ref = $objp->product_ref; // Ref of product + $line->ref_fourn = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since + $line->ref_supplier = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since $line->date_start = $this->db->jdate($objp->date_start); $line->date_end = $this->db->jdate($objp->date_end); $line->fk_unit = $objp->fk_unit; // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; $line->multicurrency_subprice = $objp->multicurrency_subprice; $line->multicurrency_total_ht = $objp->multicurrency_total_ht; $line->multicurrency_total_tva = $objp->multicurrency_total_tva; @@ -472,7 +472,7 @@ class CommandeFournisseur extends CommonOrder // fetch optionals attributes and labels $line->fetch_optionals(); - $this->lines[$i] = $line; + $this->lines[$i] = $line; $i++; } @@ -482,7 +482,7 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; return -1; } } @@ -497,15 +497,15 @@ class CommandeFournisseur extends CommonOrder */ public function valid($user, $idwarehouse = 0, $notrigger = 0) { - global $langs,$conf; + global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; dol_syslog(get_class($this)."::valid"); $result = 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))) { $this->db->begin(); @@ -525,29 +525,29 @@ class CommandeFournisseur extends CommonOrder $this->newref = $num; $sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " SET ref='".$this->db->escape($num)."',"; - $sql.= " fk_statut = ".self::STATUS_VALIDATED.","; - $sql.= " date_valid='".$this->db->idate(dol_now())."',"; - $sql.= " fk_user_valid = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND fk_statut = ".self::STATUS_DRAFT; + $sql .= " SET ref='".$this->db->escape($num)."',"; + $sql .= " fk_statut = ".self::STATUS_VALIDATED.","; + $sql .= " date_valid='".$this->db->idate(dol_now())."',"; + $sql .= " fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND fk_statut = ".self::STATUS_DRAFT; - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { dol_print_error($this->db); $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_VALIDATE', $user); + $result = $this->call_trigger('ORDER_SUPPLIER_VALIDATE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -573,13 +573,13 @@ class CommandeFournisseur extends CommonOrder { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->fournisseur->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->fournisseur->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -587,14 +587,14 @@ class CommandeFournisseur extends CommonOrder } } - if (! $error) + if (!$error) { $result = 1; $this->statut = self::STATUS_VALIDATED; $this->ref = $num; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -607,7 +607,7 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error='NotAuthorized'; + $this->error = 'NotAuthorized'; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); return -1; } @@ -707,49 +707,49 @@ class CommandeFournisseur extends CommonOrder { global $langs, $conf; - $result=''; - $label = '' . $langs->trans("ShowOrder") . ''; - if (! empty($this->ref)) - $label .= '
        ' . $langs->trans('Ref') . ': ' . $this->ref; - if (! empty($this->ref_supplier)) - $label.= '
        ' . $langs->trans('RefSupplier') . ': ' . $this->ref_supplier; - if (! empty($this->total_ht)) - $label.= '
        ' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_tva)) - $label.= '
        ' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_ttc)) - $label.= '
        ' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + $result = ''; + $label = ''.$langs->trans("ShowOrder").''; + if (!empty($this->ref)) + $label .= '
        '.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->ref_supplier)) + $label .= '
        '.$langs->trans('RefSupplier').': '.$this->ref_supplier; + if (!empty($this->total_ht)) + $label .= '
        '.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_tva)) + $label .= '
        '.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_ttc)) + $label .= '
        '.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - $picto='order'; + $picto = 'order'; $url = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$this->id; if ($option !== 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowOrder"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowOrder"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; return $result; @@ -768,12 +768,12 @@ class CommandeFournisseur extends CommonOrder global $db, $langs, $conf; $langs->load("orders"); - if (! empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER)) + if (!empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER)) { $mybool = false; $file = $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER.'.php'; - $classname=$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER; + $classname = $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER; // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -782,7 +782,7 @@ class CommandeFournisseur extends CommonOrder $dir = dol_buildpath($reldir."core/modules/supplier_order/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } if ($mybool === false) { @@ -793,7 +793,7 @@ class CommandeFournisseur extends CommonOrder $obj = new $classname(); $numref = $obj->getNextValue($soc, $this); - if ( $numref != "") + if ($numref != "") { return $numref; } @@ -817,24 +817,24 @@ class CommandeFournisseur extends CommonOrder */ public function classifyBilled(User $user) { - $error=0; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur SET billed = 1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; if ($this->db->query($sql)) { - if (! $error) + if (!$error) { // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_CLASSIFY_BILLED', $user); + $result = $this->call_trigger('ORDER_SUPPLIER_CLASSIFY_BILLED', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { - $this->billed=1; + $this->billed = 1; $this->db->commit(); return 1; @@ -864,10 +864,10 @@ class CommandeFournisseur extends CommonOrder */ public function approve($user, $idwarehouse = 0, $secondlevel = 0) { - global $langs,$conf; + global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; dol_syslog(get_class($this)."::approve"); @@ -893,42 +893,42 @@ class CommandeFournisseur extends CommonOrder $this->newref = $num; // Do we have to change status now ? (If double approval is required and first approval, we keep status to 1 = validated) - $movetoapprovestatus=true; - $comment=''; + $movetoapprovestatus = true; + $comment = ''; $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " SET ref='".$this->db->escape($num)."',"; + $sql .= " SET ref='".$this->db->escape($num)."',"; if (empty($secondlevel)) // standard or first level approval { - $sql.= " date_approve='".$this->db->idate($now)."',"; - $sql.= " fk_user_approve = ".$user->id; - if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $this->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) + $sql .= " date_approve='".$this->db->idate($now)."',"; + $sql .= " fk_user_approve = ".$user->id; + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $this->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { if (empty($this->user_approve_id2)) { - $movetoapprovestatus=false; // second level approval not done - $comment=' (first level)'; + $movetoapprovestatus = false; // second level approval not done + $comment = ' (first level)'; } } } else // request a second level approval { - $sql.= " date_approve2='".$this->db->idate($now)."',"; - $sql.= " fk_user_approve2 = ".$user->id; - if (empty($this->user_approve_id)) $movetoapprovestatus=false; // first level approval not done - $comment=' (second level)'; + $sql .= " date_approve2='".$this->db->idate($now)."',"; + $sql .= " fk_user_approve2 = ".$user->id; + if (empty($this->user_approve_id)) $movetoapprovestatus = false; // first level approval not done + $comment = ' (second level)'; } // If double approval is required and first approval, we keep status to 1 = validated - if ($movetoapprovestatus) $sql.= ", fk_statut = ".self::STATUS_ACCEPTED; - else $sql.= ", fk_statut = ".self::STATUS_VALIDATED; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND fk_statut = ".self::STATUS_VALIDATED; + if ($movetoapprovestatus) $sql .= ", fk_statut = ".self::STATUS_ACCEPTED; + else $sql .= ", fk_statut = ".self::STATUS_VALIDATED; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND fk_statut = ".self::STATUS_VALIDATED; if ($this->db->query($sql)) { - if (! empty($conf->global->SUPPLIER_ORDER_AUTOADD_USER_CONTACT)) + if (!empty($conf->global->SUPPLIER_ORDER_AUTOADD_USER_CONTACT)) { - $result=$this->add_contact($user->id, 'SALESREPFOLL', 'internal', 1); + $result = $this->add_contact($user->id, 'SALESREPFOLL', 'internal', 1); if ($result < 0 && $result != -2) // -2 means already exists { $error++; @@ -936,12 +936,12 @@ class CommandeFournisseur extends CommonOrder } // If stock is incremented on validate order, we must increment it - if (! $error && $movetoapprovestatus && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) + if (!$error && $movetoapprovestatus && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); - $cpt=count($this->lines); + $cpt = count($this->lines); for ($i = 0; $i < $cpt; $i++) { // Product with reference @@ -951,24 +951,24 @@ class CommandeFournisseur extends CommonOrder $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrement stock of product (and sub-products) - $up_ht_disc=$this->lines[$i]->subprice; - if (! empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc=price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU'); - $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("OrderApprovedInDolibarr", $this->ref)); + $up_ht_disc = $this->lines[$i]->subprice; + if (!empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc = price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU'); + $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("OrderApprovedInDolibarr", $this->ref)); if ($result < 0) { $error++; } unset($this->line); } } } - if (! $error) + if (!$error) { // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_APPROVE', $user); + $result = $this->call_trigger('ORDER_SUPPLIER_APPROVE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->ref = $this->newref; @@ -997,7 +997,7 @@ class CommandeFournisseur extends CommonOrder else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1018,7 +1018,7 @@ class CommandeFournisseur extends CommonOrder { global $conf, $langs; - $error=0; + $error = 0; dol_syslog(get_class($this)."::refuse"); $result = 0; @@ -1036,7 +1036,7 @@ class CommandeFournisseur extends CommonOrder if ($error == 0) { // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_REFUSE', $user); + $result = $this->call_trigger('ORDER_SUPPLIER_REFUSE', $user); if ($result < 0) { $error++; @@ -1050,7 +1050,7 @@ class CommandeFournisseur extends CommonOrder else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this)."::refuse Error -1"); $result = -1; } @@ -1059,7 +1059,7 @@ class CommandeFournisseur extends CommonOrder { dol_syslog(get_class($this)."::refuse Not Authorized"); } - return $result ; + return $result; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1074,9 +1074,9 @@ class CommandeFournisseur extends CommonOrder public function Cancel($user, $idwarehouse = -1) { // phpcs:enable - global $langs,$conf; + global $langs, $conf; - $error=0; + $error = 0; //dol_syslog("CommandeFournisseur::Cancel"); $result = 0; @@ -1094,7 +1094,7 @@ class CommandeFournisseur extends CommonOrder $result = 0; // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_CANCEL', $user); + $result = $this->call_trigger('ORDER_SUPPLIER_CANCEL', $user); if ($result < 0) $error++; // End call triggers @@ -1112,7 +1112,7 @@ class CommandeFournisseur extends CommonOrder else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this)."::cancel ".$this->error); return -1; } @@ -1153,7 +1153,7 @@ class CommandeFournisseur extends CommonOrder $this->date_commande = $date; // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_SUBMIT', $user); + $result = $this->call_trigger('ORDER_SUPPLIER_SUBMIT', $user); if ($result < 0) $error++; // End call triggers } @@ -1164,7 +1164,7 @@ class CommandeFournisseur extends CommonOrder $this->errors[] = $this->db->lasterror(); } - if (! $error) + if (!$error) { $this->db->commit(); } @@ -1193,18 +1193,18 @@ class CommandeFournisseur extends CommonOrder */ public function create($user, $notrigger = 0) { - global $langs,$conf,$hookmanager; + global $langs, $conf, $hookmanager; $this->db->begin(); - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Clean parameters if (empty($this->source)) $this->source = 0; // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) { @@ -1217,50 +1217,50 @@ class CommandeFournisseur extends CommonOrder $this->brouillon = 1; $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur ("; - $sql.= "ref"; - $sql.= ", ref_supplier"; - $sql.= ", note_private"; - $sql.= ", note_public"; - $sql.= ", entity"; - $sql.= ", fk_soc"; - $sql.= ", fk_projet"; - $sql.= ", date_creation"; - $sql.= ", date_livraison"; - $sql.= ", fk_user_author"; - $sql.= ", fk_statut"; - $sql.= ", source"; - $sql.= ", model_pdf"; - $sql.= ", fk_mode_reglement"; - $sql.= ", fk_cond_reglement"; - $sql.= ", fk_account"; - $sql.= ", fk_incoterms, location_incoterms"; - $sql.= ", fk_multicurrency"; - $sql.= ", multicurrency_code"; - $sql.= ", multicurrency_tx"; - $sql.= ") "; - $sql.= " VALUES ("; - $sql.= "''"; - $sql.= ", '".$this->db->escape($this->ref_supplier)."'"; - $sql.= ", '".$this->db->escape($this->note_private)."'"; - $sql.= ", '".$this->db->escape($this->note_public)."'"; - $sql.= ", ".$conf->entity; - $sql.= ", ".$this->socid; - $sql.= ", ".($this->fk_project > 0 ? $this->fk_project : "null"); - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null"); - $sql.= ", ".$user->id; - $sql.= ", ".self::STATUS_DRAFT; - $sql.= ", ".$this->db->escape($this->source); - $sql.= ", '".$conf->global->COMMANDE_SUPPLIER_ADDON_PDF."'"; - $sql.= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'null'); - $sql.= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'null'); - $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); - $sql.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".(double) $this->multicurrency_tx; - $sql.= ")"; + $sql .= "ref"; + $sql .= ", ref_supplier"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", entity"; + $sql .= ", fk_soc"; + $sql .= ", fk_projet"; + $sql .= ", date_creation"; + $sql .= ", date_livraison"; + $sql .= ", fk_user_author"; + $sql .= ", fk_statut"; + $sql .= ", source"; + $sql .= ", model_pdf"; + $sql .= ", fk_mode_reglement"; + $sql .= ", fk_cond_reglement"; + $sql .= ", fk_account"; + $sql .= ", fk_incoterms, location_incoterms"; + $sql .= ", fk_multicurrency"; + $sql .= ", multicurrency_code"; + $sql .= ", multicurrency_tx"; + $sql .= ") "; + $sql .= " VALUES ("; + $sql .= "''"; + $sql .= ", '".$this->db->escape($this->ref_supplier)."'"; + $sql .= ", '".$this->db->escape($this->note_private)."'"; + $sql .= ", '".$this->db->escape($this->note_public)."'"; + $sql .= ", ".$conf->entity; + $sql .= ", ".$this->socid; + $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : "null"); + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".($this->date_livraison ? "'".$this->db->idate($this->date_livraison)."'" : "null"); + $sql .= ", ".$user->id; + $sql .= ", ".self::STATUS_DRAFT; + $sql .= ", ".$this->db->escape($this->source); + $sql .= ", '".$conf->global->COMMANDE_SUPPLIER_ADDON_PDF."'"; + $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'null'); + $sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'null'); + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".(double) $this->multicurrency_tx; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); if ($this->db->query($sql)) @@ -1268,10 +1268,10 @@ class CommandeFournisseur extends CommonOrder $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."commande_fournisseur"); if ($this->id) { - $num=count($this->lines); + $num = count($this->lines); // insert products details into database - for ($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { $this->special_code = $this->lines[$i]->special_code; // TODO : remove this in 9.0 and add special_code param to addline() @@ -1285,7 +1285,7 @@ class CommandeFournisseur extends CommonOrder $this->lines[$i]->localtax2_tx, $this->lines[$i]->fk_product, 0, - $this->lines[$i]->ref_fourn, // $this->lines[$i]->ref_fourn comes from field ref into table of lines. Value may ba a ref that does not exists anymore, so we first try with value of product + $this->lines[$i]->ref_fourn, // $this->lines[$i]->ref_fourn comes from field ref into table of lines. Value may ba a ref that does not exists anymore, so we first try with value of product $this->lines[$i]->remise_percent, 'HT', 0, @@ -1299,39 +1299,39 @@ class CommandeFournisseur extends CommonOrder ); if ($result < 0) { - dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); // do not use dol_print_error here as it may be a functionnal error + dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); // do not use dol_print_error here as it may be a functionnal error $this->db->rollback(); return -1; } } $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " SET ref='(PROV".$this->id.")'"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " SET ref='(PROV".$this->id.")'"; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::create", LOG_DEBUG); if ($this->db->query($sql)) { // Add link with price request and supplier order if ($this->id) { - $this->ref="(PROV".$this->id.")"; + $this->ref = "(PROV".$this->id.")"; - if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) { - foreach($this->linked_objects as $origin => $tmp_origin_id) + foreach ($this->linked_objects as $origin => $tmp_origin_id) { if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) { - foreach($tmp_origin_id as $origin_id) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { dol_print_error($this->db); $error++; @@ -1342,7 +1342,7 @@ class CommandeFournisseur extends CommonOrder { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { dol_print_error($this->db); $error++; @@ -1352,16 +1352,16 @@ class CommandeFournisseur extends CommonOrder } } - if (! $error) + if (!$error) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_CREATE', $user); + $result = $this->call_trigger('ORDER_SUPPLIER_CREATE', $user); if ($result < 0) { $this->db->rollback(); @@ -1375,7 +1375,7 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } @@ -1383,7 +1383,7 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -1444,17 +1444,17 @@ class CommandeFournisseur extends CommonOrder // Create clone $this->context['createfromclone'] = 'createfromclone'; - $result=$this->create($user); + $result = $this->create($user); if ($result < 0) $error++; - if (! $error) + if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters=array('objFrom'=>$objFrom); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('objFrom'=>$objFrom); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } } @@ -1462,7 +1462,7 @@ class CommandeFournisseur extends CommonOrder unset($this->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -1503,7 +1503,7 @@ class CommandeFournisseur extends CommonOrder */ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $type = 0, $info_bits = 0, $notrigger = false, $date_start = null, $date_end = null, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0) { - global $langs,$mysoc,$conf; + global $langs, $mysoc, $conf; $error = 0; @@ -1560,7 +1560,7 @@ class CommandeFournisseur extends CommonOrder if ($fk_product > 0) { - if (! empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) + if (!empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) { // Check quantity is enough dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." ref_supplier=".$ref_supplier); @@ -1572,20 +1572,20 @@ class CommandeFournisseur extends CommonOrder // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. - $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc + $result = $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc ? $this->fk_soc : $this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc // If supplier order created from customer order, we take best supplier price // If $pu (defined previously from pu_ht or pu_ttc) is not defined at all, we also take the best supplier price if ($result > 0 && ($origin == 'commande' || $pu === '')) { - $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice - $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice // is remise percent not keyed but present for the product we add it - if ($remise_percent == 0 && $prod->remise_percent !=0) $remise_percent =$prod->remise_percent; + if ($remise_percent == 0 && $prod->remise_percent != 0) $remise_percent = $prod->remise_percent; } if ($result == 0) // If result == 0, we failed to found the supplier reference price { $langs->load("errors"); - $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->error = "Ref ".$prod->ref." ".$langs->trans("ErrorQtyTooLowForThisSupplier"); $this->db->rollback(); dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); //$pu = $prod->fourn_pu; // We do not overwrite unit price @@ -1595,14 +1595,14 @@ class CommandeFournisseur extends CommonOrder if ($result == -1) { $langs->load("errors"); - $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->error = "Ref ".$prod->ref." ".$langs->trans("ErrorQtyTooLowForThisSupplier"); $this->db->rollback(); dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); return -1; } if ($result < -1) { - $this->error=$prod->error; + $this->error = $prod->error; $this->db->rollback(); dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); return -1; @@ -1610,7 +1610,7 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error=$prod->error; + $this->error = $prod->error; $this->db->rollback(); return -1; } @@ -1625,14 +1625,14 @@ class CommandeFournisseur extends CommonOrder $pu = 0; } - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } // Calcul du total TTC et de la TVA pour la ligne a partir de @@ -1650,13 +1650,13 @@ class CommandeFournisseur extends CommonOrder $pu = $pu_ht = $tabprice[3]; // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; - $localtax1_type=$localtaxes_type[0]; - $localtax2_type=$localtaxes_type[2]; + $localtax1_type = $localtaxes_type[0]; + $localtax2_type = $localtaxes_type[2]; $subprice = price2num($pu, 'MU'); @@ -1664,68 +1664,68 @@ class CommandeFournisseur extends CommonOrder $rang = $rangmax + 1; // Insert line - $this->line=new CommandeFournisseurLigne($this->db); + $this->line = new CommandeFournisseurLigne($this->db); $this->line->context = $this->context; - $this->line->fk_commande=$this->id; - $this->line->label=$label; + $this->line->fk_commande = $this->id; + $this->line->label = $label; $this->line->ref_fourn = $ref_supplier; $this->line->ref_supplier = $ref_supplier; - $this->line->desc=$desc; - $this->line->qty=$qty; - $this->line->tva_tx=$txtva; - $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); - $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); + $this->line->desc = $desc; + $this->line->qty = $qty; + $this->line->tva_tx = $txtva; + $this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0); + $this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0); $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; - $this->line->fk_product=$fk_product; - $this->line->product_type=$product_type; - $this->line->remise_percent=$remise_percent; - $this->line->subprice=$pu_ht; - $this->line->rang=$rang; - $this->line->info_bits=$info_bits; + $this->line->fk_product = $fk_product; + $this->line->product_type = $product_type; + $this->line->remise_percent = $remise_percent; + $this->line->subprice = $pu_ht; + $this->line->rang = $rang; + $this->line->info_bits = $info_bits; - $this->line->vat_src_code=$vat_src_code; - $this->line->total_ht=$total_ht; - $this->line->total_tva=$total_tva; - $this->line->total_localtax1=$total_localtax1; - $this->line->total_localtax2=$total_localtax2; - $this->line->total_ttc=$total_ttc; - $this->line->product_type=$type; - $this->line->special_code=$this->special_code; - $this->line->origin=$origin; - $this->line->origin_id=$origin_id; - $this->line->fk_unit=$fk_unit; + $this->line->vat_src_code = $vat_src_code; + $this->line->total_ht = $total_ht; + $this->line->total_tva = $total_tva; + $this->line->total_localtax1 = $total_localtax1; + $this->line->total_localtax2 = $total_localtax2; + $this->line->total_ttc = $total_ttc; + $this->line->product_type = $type; + $this->line->special_code = $this->special_code; + $this->line->origin = $origin; + $this->line->origin_id = $origin_id; + $this->line->fk_unit = $fk_unit; - $this->line->date_start=$date_start; - $this->line->date_end=$date_end; + $this->line->date_start = $date_start; + $this->line->date_end = $date_end; // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - $this->line->subprice=$pu_ht; - $this->line->price=$this->line->subprice; + $this->line->subprice = $pu_ht; + $this->line->price = $this->line->subprice; - $this->line->remise_percent=$remise_percent; + $this->line->remise_percent = $remise_percent; - if (is_array($array_options) && count($array_options)>0) { - $this->line->array_options=$array_options; + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; } - $result=$this->line->insert($notrigger); + $result = $this->line->insert($notrigger); if ($result > 0) { // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); // Mise a jour informations denormalisees au niveau de la commande meme - $result=$this->update_price(1, 'auto', 0, $this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. + $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. if ($result > 0) { $this->db->commit(); @@ -1739,8 +1739,8 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error=$this->line->error; - $this->errors=$this->line->errors; + $this->error = $this->line->error; + $this->errors = $this->line->errors; dol_syslog(get_class($this)."::addline error=".$this->error, LOG_ERR); $this->db->rollback(); return -1; @@ -1770,44 +1770,44 @@ class CommandeFournisseur extends CommonOrder global $conf, $langs; $error = 0; - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; // Check parameters (if test are wrong here, there is bug into caller) if ($entrepot <= 0) { - $this->error='ErrorBadValueForParameterWarehouse'; + $this->error = 'ErrorBadValueForParameterWarehouse'; return -1; } if ($qty == 0) { - $this->error='ErrorBadValueForParameterQty'; + $this->error = 'ErrorBadValueForParameterQty'; return -1; } $dispatchstatus = 1; - if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $dispatchstatus = 0; // Setting dispatch status (a validation step after receiving products) will be done manually to 1 or 2 if this option is on + if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $dispatchstatus = 0; // Setting dispatch status (a validation step after receiving products) will be done manually to 1 or 2 if this option is on - $now=dol_now(); + $now = dol_now(); if (($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY || $this->statut == self::STATUS_RECEIVED_COMPLETELY)) { $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur_dispatch"; - $sql.= " (fk_commande, fk_product, qty, fk_entrepot, fk_user, datec, fk_commandefourndet, status, comment, eatby, sellby, batch) VALUES"; - $sql.= " ('".$this->id."','".$product."','".$qty."',".($entrepot>0?"'".$entrepot."'":"null").",'".$user->id."','".$this->db->idate($now)."','".$fk_commandefourndet."', ".$dispatchstatus.", '".$this->db->escape($comment)."', "; - $sql.= ($eatby?"'".$this->db->idate($eatby)."'":"null").", ".($sellby?"'".$this->db->idate($sellby)."'":"null").", ".($batch?"'".$batch."'":"null"); - $sql.= ")"; + $sql .= " (fk_commande, fk_product, qty, fk_entrepot, fk_user, datec, fk_commandefourndet, status, comment, eatby, sellby, batch) VALUES"; + $sql .= " ('".$this->id."','".$product."','".$qty."',".($entrepot > 0 ? "'".$entrepot."'" : "null").",'".$user->id."','".$this->db->idate($now)."','".$fk_commandefourndet."', ".$dispatchstatus.", '".$this->db->escape($comment)."', "; + $sql .= ($eatby ? "'".$this->db->idate($eatby)."'" : "null").", ".($sellby ? "'".$this->db->idate($sellby)."'" : "null").", ".($batch ? "'".$batch."'" : "null"); + $sql .= ")"; dol_syslog(get_class($this)."::dispatchProduct", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - if (! $notrigger) + if (!$notrigger) { global $conf, $langs, $user; // Call trigger - $result=$this->call_trigger('LINEORDER_SUPPLIER_DISPATCH', $user); + $result = $this->call_trigger('LINEORDER_SUPPLIER_DISPATCH', $user); if ($result < 0) { $error++; @@ -1830,11 +1830,11 @@ class CommandeFournisseur extends CommonOrder { // $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on) $mouv->origin = &$this; - $result=$mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch); + $result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch); if ($result < 0) { - $this->error=$mouv->error; - $this->errors=$mouv->errors; + $this->error = $mouv->error; + $this->errors = $mouv->errors; dol_syslog(get_class($this)."::dispatchProduct ".$this->error." ".join(',', $this->errors), LOG_ERR); $error++; } @@ -1854,7 +1854,7 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error='BadStatusForObject'; + $this->error = 'BadStatusForObject'; return -2; } } @@ -1904,7 +1904,7 @@ class CommandeFournisseur extends CommonOrder */ public function delete(User $user, $notrigger = 0) { - global $langs,$conf; + global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; @@ -1914,51 +1914,51 @@ class CommandeFournisseur extends CommonOrder if (empty($notrigger)) { // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_DELETE', $user); + $result = $this->call_trigger('ORDER_SUPPLIER_DELETE', $user); if ($result < 0) { - $this->errors[]='ErrorWhenRunningTrigger'; + $this->errors[] = 'ErrorWhenRunningTrigger'; dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); return -1; } // End call triggers } - $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande =". $this->id ; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande =".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { - $this->error=$this->db->lasterror(); - $this->errors[]=$this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE rowid =".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if ($resql = $this->db->query($sql) ) + if ($resql = $this->db->query($sql)) { if ($this->db->affected_rows($resql) < 1) { - $this->error=$this->db->lasterror(); - $this->errors[]=$this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } } else { - $this->error=$this->db->lasterror(); - $this->errors[]=$this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } // Remove 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(); + $result = $this->deleteExtraFields(); if ($result < 0) { - $this->error='FailToDeleteExtraFields'; - $this->errors[]='FailToDeleteExtraFields'; + $this->error = 'FailToDeleteExtraFields'; + $this->errors[] = 'FailToDeleteExtraFields'; $error++; dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); } @@ -1967,42 +1967,42 @@ class CommandeFournisseur extends CommonOrder // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) { - $this->error='FailToDeleteObjectLinked'; - $this->errors[]='FailToDeleteObjectLinked'; + $this->error = 'FailToDeleteObjectLinked'; + $this->errors[] = 'FailToDeleteObjectLinked'; $error++; } - if (! $error) + if (!$error) { // We remove directory $ref = dol_sanitizeFileName($this->ref); if ($conf->fournisseur->commande->dir_output) { - $dir = $conf->fournisseur->commande->dir_output . "/" . $ref ; - $file = $dir . "/" . $ref . ".pdf"; + $dir = $conf->fournisseur->commande->dir_output."/".$ref; + $file = $dir."/".$ref.".pdf"; if (file_exists($file)) { - if (! dol_delete_file($file, 0, 0, 0, $this)) // For triggers + if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers { - $this->error='ErrorFailToDeleteFile'; - $this->errors[]='ErrorFailToDeleteFile'; + $this->error = 'ErrorFailToDeleteFile'; + $this->errors[] = 'ErrorFailToDeleteFile'; $error++; } } if (file_exists($dir)) { - $res=@dol_delete_dir_recursive($dir); - if (! $res) + $res = @dol_delete_dir_recursive($dir); + if (!$res) { - $this->error='ErrorFailToDeleteDir'; - $this->errors[]='ErrorFailToDeleteDir'; + $this->error = 'ErrorFailToDeleteDir'; + $this->errors[] = 'ErrorFailToDeleteDir'; $error++; } } } } - if (! $error) + if (!$error) { dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG); $this->db->commit(); @@ -2026,10 +2026,10 @@ class CommandeFournisseur extends CommonOrder { // phpcs:enable $sql = "SELECT rowid, libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_input_method"; - $sql.= " WHERE active = 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_input_method"; + $sql .= " WHERE active = 1"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $i = 0; @@ -2065,15 +2065,15 @@ class CommandeFournisseur extends CommonOrder // List of already dispatched lines $sql = "SELECT p.ref, p.label,"; - $sql.= " e.rowid as warehouse_id, e.ref as entrepot,"; - $sql.= " cfd.rowid as dispatchedlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p,"; - $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid"; - $sql.= " WHERE cfd.fk_commande = ".$this->id; - $sql.= " AND cfd.fk_product = p.rowid"; - if ($status >= 0) $sql.=" AND cfd.status = ".$status; - $sql.= " ORDER BY cfd.rowid ASC"; + $sql .= " e.rowid as warehouse_id, e.ref as entrepot,"; + $sql .= " cfd.rowid as dispatchedlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p,"; + $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid"; + $sql .= " WHERE cfd.fk_commande = ".$this->id; + $sql .= " AND cfd.fk_product = p.rowid"; + if ($status >= 0) $sql .= " AND cfd.status = ".$status; + $sql .= " ORDER BY cfd.rowid ASC"; $resql = $this->db->query($sql); if ($resql) @@ -2137,28 +2137,28 @@ class CommandeFournisseur extends CommonOrder } // Some checks to accept the record - if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) + if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) { // If option SUPPLIER_ORDER_USE_DISPATCH_STATUS is on, we check all reception are approved to allow status "total/done" - if (! $error && ($type == 'tot')) + if (!$error && ($type == 'tot')) { - $dispatchedlinearray=$this->getDispachedLines(0); + $dispatchedlinearray = $this->getDispachedLines(0); if (count($dispatchedlinearray) > 0) { - $result=-1; + $result = -1; $error++; - $this->errors[]='ErrorCantSetReceptionToTotalDoneWithReceptionToApprove'; + $this->errors[] = 'ErrorCantSetReceptionToTotalDoneWithReceptionToApprove'; dol_syslog('ErrorCantSetReceptionToTotalDoneWithReceptionToApprove', LOG_DEBUG); } } - if (! $error && ! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS_NEED_APPROVE) && ($type == 'tot')) // Accept to move to reception done, only if status of all line are ok (refuse denied) + if (!$error && !empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS_NEED_APPROVE) && ($type == 'tot')) // Accept to move to reception done, only if status of all line are ok (refuse denied) { - $dispatcheddenied=$this->getDispachedLines(2); + $dispatcheddenied = $this->getDispachedLines(2); if (count($dispatchedlinearray) > 0) { - $result=-1; + $result = -1; $error++; - $this->errors[]='ErrorCantSetReceptionToTotalDoneWithReceptionDenied'; + $this->errors[] = 'ErrorCantSetReceptionToTotalDoneWithReceptionDenied'; dol_syslog('ErrorCantSetReceptionToTotalDoneWithReceptionDenied', LOG_DEBUG); } } @@ -2167,17 +2167,17 @@ class CommandeFournisseur extends CommonOrder // TODO LDR01 Add a control test to accept only if ALL predefined products are received (same qty). - if (! $error) + if (!$error) { $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " SET fk_statut = ".$statut; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND fk_statut IN (".self::STATUS_ORDERSENT.",".self::STATUS_RECEIVED_PARTIALLY.")"; // Process running or Partially received + $sql .= " SET fk_statut = ".$statut; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND fk_statut IN (".self::STATUS_ORDERSENT.",".self::STATUS_RECEIVED_PARTIALLY.")"; // Process running or Partially received dol_syslog(get_class($this)."::Livraison", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $result = 0; @@ -2186,11 +2186,11 @@ class CommandeFournisseur extends CommonOrder $this->actionmsg2 = $comment; // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_RECEIVE', $user); + $result = $this->call_trigger('ORDER_SUPPLIER_RECEIVE', $user); if ($result < 0) $error++; // End call triggers - if (! $error) + if (!$error) { $this->db->commit(); } @@ -2198,14 +2198,14 @@ class CommandeFournisseur extends CommonOrder { $this->statut = $old_statut; $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $result = -1; } } else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $result = -1; } } @@ -2217,7 +2217,7 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::Livraison Not Authorized"); $result = -3; } - return $result ; + return $result; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2234,50 +2234,50 @@ class CommandeFournisseur extends CommonOrder // phpcs:enable if ($user->rights->fournisseur->commande->creer) { - $error=0; + $error = 0; $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; $this->date_livraison = $date_livraison; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_MODIFY', $user); + $result = $this->call_trigger('ORDER_SUPPLIER_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else @@ -2300,51 +2300,51 @@ class CommandeFournisseur extends CommonOrder // phpcs:enable if ($user->rights->fournisseur->commande->creer) { - $error=0; + $error = 0; $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql.= " SET fk_projet = ".($id_projet > 0 ? (int) $id_projet : 'null'); - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET fk_projet = ".($id_projet > 0 ? (int) $id_projet : 'null'); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $error++; } - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; $this->fk_projet = $id_projet; $this->fk_project = $id_projet; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_MODIFY', $user); + $result = $this->call_trigger('ORDER_SUPPLIER_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else @@ -2370,7 +2370,7 @@ class CommandeFournisseur extends CommonOrder $this->lines = array(); - $num=count($comclient->lines); + $num = count($comclient->lines); for ($i = 0; $i < $num; $i++) { $prod = new Product($this->db); @@ -2406,14 +2406,14 @@ class CommandeFournisseur extends CommonOrder */ public function setStatus($user, $status) { - global $conf,$langs; - $error=0; + global $conf, $langs; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; - $sql.= ' SET fk_statut='.$status; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET fk_statut='.$status; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setStatus", LOG_DEBUG); $resql = $this->db->query($sql); @@ -2423,7 +2423,7 @@ class CommandeFournisseur extends CommonOrder $trigger_name[0] = 'DRAFT'; $trigger_name[1] = 'VALIDATED'; $trigger_name[2] = 'APPROVED'; - $trigger_name[3] = 'ORDERED'; // Ordered + $trigger_name[3] = 'ORDERED'; // Ordered $trigger_name[4] = 'RECEIVED_PARTIALLY'; $trigger_name[5] = 'RECEIVED_COMPLETELY'; $trigger_name[6] = 'CANCELED'; @@ -2431,18 +2431,18 @@ class CommandeFournisseur extends CommonOrder $trigger_name[9] = 'REFUSED'; // Call trigger - $result=$this->call_trigger("ORDER_SUPPLIER_STATUS_".$trigger_name[$status], $user); + $result = $this->call_trigger("ORDER_SUPPLIER_STATUS_".$trigger_name[$status], $user); if ($result < 0) { $error++; } // End call triggers } else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this)."::setStatus ".$this->error); } - if (! $error) + if (!$error) { $this->statut = $status; $this->db->commit(); @@ -2489,28 +2489,28 @@ class CommandeFournisseur extends CommonOrder if ($this->brouillon) { // Clean parameters - if (empty($qty)) $qty=0; - if (empty($info_bits)) $info_bits=0; - if (empty($txtva)) $txtva=0; - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; - if (empty($remise)) $remise=0; - if (empty($remise_percent)) $remise_percent=0; + if (empty($qty)) $qty = 0; + if (empty($info_bits)) $info_bits = 0; + if (empty($txtva)) $txtva = 0; + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; + if (empty($remise)) $remise = 0; + if (empty($remise_percent)) $remise_percent = 0; - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - if (! $qty) $qty=1; + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + if (!$qty) $qty = 1; $pu = price2num($pu); - $pu_ht_devise=price2num($pu_ht_devise); - $txtva=price2num($txtva); - $txlocaltax1=price2num($txlocaltax1); - $txlocaltax2=price2num($txlocaltax2); + $pu_ht_devise = price2num($pu_ht_devise); + $txtva = price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); // Check parameters if ($type < 0) return -1; if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } @@ -2521,17 +2521,17 @@ class CommandeFournisseur extends CommonOrder // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -2542,31 +2542,31 @@ class CommandeFournisseur extends CommonOrder $pu_ttc = $tabprice[5]; // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; - $localtax1_type=$localtaxes_type[0]; - $localtax2_type=$localtaxes_type[2]; + $localtax1_type = $localtaxes_type[0]; + $localtax2_type = $localtaxes_type[2]; $subprice = price2num($pu_ht, 'MU'); //Fetch current line from the database and then clone the object and set it in $oldline property - $this->line=new CommandeFournisseurLigne($this->db); + $this->line = new CommandeFournisseurLigne($this->db); $this->line->fetch($rowid); $oldline = clone $this->line; $this->line->oldline = $oldline; $this->line->context = $this->context; - $this->line->fk_commande=$this->id; + $this->line->fk_commande = $this->id; //$this->line->label=$label; - $this->line->desc=$desc; - $this->line->qty=$qty; - $this->line->ref_supplier=$ref_supplier; + $this->line->desc = $desc; + $this->line->qty = $qty; + $this->line->ref_supplier = $ref_supplier; - $this->line->vat_src_code = $vat_src_code; + $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; @@ -2578,8 +2578,8 @@ class CommandeFournisseur extends CommonOrder $this->line->info_bits = $info_bits; $this->line->total_ht = $total_ht; $this->line->total_tva = $total_tva; - $this->line->total_localtax1= $total_localtax1; - $this->line->total_localtax2= $total_localtax2; + $this->line->total_localtax1 = $total_localtax1; + $this->line->total_localtax2 = $total_localtax2; $this->line->total_ttc = $total_ttc; $this->line->product_type = $type; $this->line->special_code = $this->special_code; @@ -2590,23 +2590,23 @@ class CommandeFournisseur extends CommonOrder $this->line->date_end = $date_end; // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - $this->line->subprice=$pu_ht; - $this->line->price=$this->line->subprice; + $this->line->subprice = $pu_ht; + $this->line->price = $this->line->subprice; - $this->line->remise_percent=$remise_percent; + $this->line->remise_percent = $remise_percent; - if (is_array($array_options) && count($array_options)>0) { - $this->line->array_options=$array_options; + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; } - $result=$this->line->update($notrigger); + $result = $this->line->update($notrigger); // Mise a jour info denormalisees au niveau facture @@ -2618,14 +2618,14 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } } else { - $this->error="Order status makes operation forbidden"; + $this->error = "Order status makes operation forbidden"; dol_syslog(get_class($this)."::updateline ".$this->error, LOG_ERR); return -2; } @@ -2665,49 +2665,49 @@ class CommandeFournisseur extends CommonOrder } // Initialise parametres - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->socid = 1; $this->date = $now; $this->date_commande = $now; - $this->date_lim_reglement=$this->date+3600*24*30; + $this->date_lim_reglement = $this->date + 3600 * 24 * 30; $this->cond_reglement_code = 'RECEP'; $this->mode_reglement_code = 'CHQ'; - $this->note_public='This is a comment (public)'; - $this->note_private='This is a comment (private)'; - $this->statut=0; + $this->note_public = 'This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; + $this->statut = 0; // Lines $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { - $line=new CommandeFournisseurLigne($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->qty=1; - $line->subprice=100; - $line->price=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; + $line = new CommandeFournisseurLigne($this->db); + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->qty = 1; + $line->subprice = 100; + $line->price = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; if ($xnbp == 2) { - $line->total_ht=50; - $line->total_ttc=59.8; - $line->total_tva=9.8; - $line->remise_percent=50; + $line->total_ht = 50; + $line->total_ttc = 59.8; + $line->total_tva = 9.8; + $line->remise_percent = 50; } else { - $line->total_ht=100; - $line->total_ttc=119.6; - $line->total_tva=19.6; - $line->remise_percent=00; + $line->total_ht = 100; + $line->total_ttc = 119.6; + $line->total_tva = 19.6; + $line->remise_percent = 00; } - $line->fk_product=$prodid; + $line->fk_product = $prodid; - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $this->total_ht += $line->total_ht; $this->total_tva += $line->total_tva; @@ -2726,11 +2726,11 @@ class CommandeFournisseur extends CommonOrder public function info($id) { $sql = 'SELECT c.rowid, date_creation as datec, tms as datem, date_valid as date_validation, date_approve as datea, date_approve2 as datea2,'; - $sql.= ' fk_user_author, fk_user_modif, fk_user_valid, fk_user_approve, fk_user_approve2'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseur as c'; - $sql.= ' WHERE c.rowid = '.$id; + $sql .= ' fk_user_author, fk_user_modif, fk_user_valid, fk_user_approve, fk_user_approve2'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseur as c'; + $sql .= ' WHERE c.rowid = '.$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -2739,7 +2739,7 @@ class CommandeFournisseur extends CommonOrder $this->id = $obj->rowid; if ($obj->fk_user_author) $this->user_creation_id = $obj->fk_user_author; if ($obj->fk_user_valid) $this->user_validation_id = $obj->fk_user_valid; - if ($obj->fk_user_modif) $this->user_modification_id =$obj->fk_user_modif; + if ($obj->fk_user_modif) $this->user_modification_id = $obj->fk_user_modif; if ($obj->fk_user_approve) $this->user_approve_id = $obj->fk_user_approve; if ($obj->fk_user_approve2) $this->user_approve_id2 = $obj->fk_user_approve2; @@ -2795,7 +2795,7 @@ class CommandeFournisseur extends CommonOrder else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2867,7 +2867,7 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2885,8 +2885,8 @@ class CommandeFournisseur extends CommonOrder if ($this->methode_commande_id > 0) { $sql = "SELECT rowid, code, libelle as label"; - $sql.= " FROM ".MAIN_DB_PREFIX.'c_input_method'; - $sql.= " WHERE active=1 AND rowid = ".$db->escape($this->methode_commande_id); + $sql .= " FROM ".MAIN_DB_PREFIX.'c_input_method'; + $sql .= " WHERE active=1 AND rowid = ".$db->escape($this->methode_commande_id); $resql = $db->query($sql); if ($resql) @@ -3009,7 +3009,7 @@ class CommandeFournisseur extends CommonOrder { global $conf; - if (empty($this->date_delivery) && ! empty($this->date_livraison)) $this->date_delivery = $this->date_livraison; // For backward compatibility + if (empty($this->date_delivery) && !empty($this->date_livraison)) $this->date_delivery = $this->date_livraison; // For backward compatibility $now = dol_now(); $date_to_test = empty($this->date_delivery) ? $this->date_commande : $this->date_delivery; @@ -3026,11 +3026,11 @@ class CommandeFournisseur extends CommonOrder { global $conf, $langs; - if (empty($this->date_delivery) && ! empty($this->date_livraison)) $this->date_delivery = $this->date_livraison; // For backward compatibility + if (empty($this->date_delivery) && !empty($this->date_livraison)) $this->date_delivery = $this->date_livraison; // For backward compatibility - if (empty($this->date_delivery)) $text=$langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day'); - else $text=$text=$langs->trans("DeliveryDate").' '.dol_print_date($this->date_delivery, 'day'); - $text.=' '.($conf->commande->fournisseur->warning_delay>0?'+':'-').' '.round(abs($conf->commande->fournisseur->warning_delay)/3600/24, 1).' '.$langs->trans("days").' < '.$langs->trans("Today"); + if (empty($this->date_delivery)) $text = $langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day'); + else $text = $text = $langs->trans("DeliveryDate").' '.dol_print_date($this->date_delivery, 'day'); + $text .= ' '.($conf->commande->fournisseur->warning_delay > 0 ? '+' : '-').' '.round(abs($conf->commande->fournisseur->warning_delay) / 3600 / 24, 1).' '.$langs->trans("days").' < '.$langs->trans("Today"); return $text; } @@ -3048,42 +3048,42 @@ class CommandeFournisseur extends CommonOrder { global $conf, $langs; - if (! empty($conf->fournisseur->enabled)) + if (!empty($conf->fournisseur->enabled)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; - $qtydelivered=array(); - $qtywished=array(); + $qtydelivered = array(); + $qtywished = array(); $supplierorderdispatch = new CommandeFournisseurDispatch($this->db); - $filter=array('t.fk_commande'=>$this->id); - if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) { - $filter['t.status']=1; // Restrict to lines with status validated + $filter = array('t.fk_commande'=>$this->id); + if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) { + $filter['t.status'] = 1; // Restrict to lines with status validated } - $ret=$supplierorderdispatch->fetchAll('', '', 0, 0, $filter); - if ($ret<0) + $ret = $supplierorderdispatch->fetchAll('', '', 0, 0, $filter); + if ($ret < 0) { - $this->error=$supplierorderdispatch->error; $this->errors=$supplierorderdispatch->errors; + $this->error = $supplierorderdispatch->error; $this->errors = $supplierorderdispatch->errors; return $ret; } else { - if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0) + if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines) > 0) { $date_liv = dol_now(); // Build array with quantity deliverd by product - foreach($supplierorderdispatch->lines as $line) { - $qtydelivered[$line->fk_product]+=$line->qty; + foreach ($supplierorderdispatch->lines as $line) { + $qtydelivered[$line->fk_product] += $line->qty; } - foreach($this->lines as $line) { - $qtywished[$line->fk_product]+=$line->qty; + foreach ($this->lines as $line) { + $qtywished[$line->fk_product] += $line->qty; } //Compare array - $diff_array=array_diff_assoc($qtydelivered, $qtywished); // Warning: $diff_array is done only on common keys. - $keysinwishednotindelivered=array_diff(array_keys($qtywished), array_keys($qtydelivered)); // To check we also have same number of keys - $keysindeliverednotinwished=array_diff(array_keys($qtydelivered), array_keys($qtywished)); // To check we also have same number of keys + $diff_array = array_diff_assoc($qtydelivered, $qtywished); // Warning: $diff_array is done only on common keys. + $keysinwishednotindelivered = array_diff(array_keys($qtywished), array_keys($qtydelivered)); // To check we also have same number of keys + $keysindeliverednotinwished = array_diff(array_keys($qtydelivered), array_keys($qtywished)); // To check we also have same number of keys /*var_dump(array_keys($qtydelivered)); var_dump(array_keys($qtywished)); var_dump($diff_array); @@ -3091,13 +3091,13 @@ class CommandeFournisseur extends CommonOrder var_dump($keysindeliverednotinwished); exit;*/ - if (count($diff_array)==0 && count($keysinwishednotindelivered)==0 && count($keysindeliverednotinwished)==0) //No diff => mean everythings is received + if (count($diff_array) == 0 && count($keysinwishednotindelivered) == 0 && count($keysindeliverednotinwished) == 0) //No diff => mean everythings is received { if ($closeopenorder) { //$ret=$this->setStatus($user,5); - $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' - if ($ret<0) { + $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret < 0) { return -1; } return 5; @@ -3106,26 +3106,26 @@ class CommandeFournisseur extends CommonOrder { //Diff => received partially //$ret=$this->setStatus($user,4); - $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' - if ($ret<0) { + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret < 0) { return -1; } return 4; } - } elseif (! empty($conf->global->SUPPLIER_ORDER_MORE_THAN_WISHED) ) { + } 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 ) + if (count($diff_array) > 0) { //there are some difference between the two arrays //scan the array of results - foreach($diff_array as $key => $value) + foreach ($diff_array as $key => $value) { //if the quantity delivered is greater or equal to wish quantity - if($qtydelivered[$key] >= $qtywished[$key] ) + if ($qtydelivered[$key] >= $qtywished[$key]) { $close++; } @@ -3133,11 +3133,11 @@ class CommandeFournisseur extends CommonOrder } - if($close == count($diff_array)) { + 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) { + $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret < 0) { return -1; } return 5; @@ -3145,8 +3145,8 @@ class CommandeFournisseur extends CommonOrder else { //Diff => received partially - $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' - if ($ret<0) { + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret < 0) { return -1; } return 4; @@ -3155,8 +3155,8 @@ class CommandeFournisseur extends CommonOrder 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) { + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret < 0) { return -1; } return 4; @@ -3165,8 +3165,8 @@ class CommandeFournisseur extends CommonOrder else { //Diff => received partially - $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' - if ($ret<0) { + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret < 0) { return -1; } return 4; @@ -3190,17 +3190,17 @@ class CommandeFournisseur extends CommonOrder $this->receptions = array(); $sql = 'SELECT cd.rowid, cd.fk_product,'; - $sql.= ' sum(cfd.qty) as qty'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as cfd,'; - if ($filtre_statut >= 0) $sql.= ' '.MAIN_DB_PREFIX.'reception as e,'; - $sql.= ' '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; - $sql.= ' WHERE'; - if ($filtre_statut >= 0) $sql.= ' cfd.fk_reception = e.rowid AND'; - $sql.= ' cfd.fk_commandefourndet = cd.rowid'; - $sql.= ' AND cd.fk_commande =' .$this->id; - 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'; + $sql .= ' sum(cfd.qty) as qty'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as cfd,'; + if ($filtre_statut >= 0) $sql .= ' '.MAIN_DB_PREFIX.'reception as e,'; + $sql .= ' '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; + $sql .= ' WHERE'; + if ($filtre_statut >= 0) $sql .= ' cfd.fk_reception = e.rowid AND'; + $sql .= ' cfd.fk_commandefourndet = cd.rowid'; + $sql .= ' AND cd.fk_commande ='.$this->id; + 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); @@ -3212,7 +3212,7 @@ class CommandeFournisseur extends CommonOrder while ($i < $num) { $obj = $this->db->fetch_object($result); - empty($this->receptions[$obj->rowid])?$this->receptions[$obj->rowid] = $obj->qty:$this->receptions[$obj->rowid] += $obj->qty; + empty($this->receptions[$obj->rowid]) ? $this->receptions[$obj->rowid] = $obj->qty : $this->receptions[$obj->rowid] += $obj->qty; $i++; } $this->db->free(); @@ -3221,7 +3221,7 @@ class CommandeFournisseur extends CommonOrder } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -3237,12 +3237,12 @@ class CommandeFournisseurLigne extends CommonOrderLine /** * @var string ID to identify managed object */ - public $element='commande_fournisseurdet'; + public $element = 'commande_fournisseurdet'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='commande_fournisseurdet'; + public $table_element = 'commande_fournisseurdet'; public $oldline; @@ -3298,7 +3298,7 @@ class CommandeFournisseurLigne extends CommonOrderLine */ public function __construct($db) { - $this->db= $db; + $this->db = $db; } /** @@ -3310,16 +3310,16 @@ class CommandeFournisseurLigne extends CommonOrderLine public function fetch($rowid) { $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx, cd.special_code,'; - $sql.= ' cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.ref,'; - $sql.= ' cd.remise, cd.remise_percent, cd.subprice,'; - $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; - $sql.= ' cd.total_localtax1, cd.total_localtax2,'; - $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,'; - $sql.= ' cd.date_start, cd.date_end, cd.fk_unit,'; - $sql.= ' cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; - $sql.= ' WHERE cd.rowid = '.$rowid; + $sql .= ' cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.ref,'; + $sql .= ' cd.remise, cd.remise_percent, cd.subprice,'; + $sql .= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; + $sql .= ' cd.total_localtax1, cd.total_localtax2,'; + $sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,'; + $sql .= ' cd.date_start, cd.date_end, cd.fk_unit,'; + $sql .= ' cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; + $sql .= ' WHERE cd.rowid = '.$rowid; $result = $this->db->query($sql); if ($result) { @@ -3327,7 +3327,7 @@ class CommandeFournisseurLigne extends CommonOrderLine if (!empty($objp)) { - $this->rowid = $objp->rowid; + $this->rowid = $objp->rowid; $this->id = $objp->rowid; $this->fk_commande = $objp->fk_commande; $this->desc = $objp->description; @@ -3352,14 +3352,14 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->product_type = $objp->product_type; $this->special_code = $objp->special_code; - $this->ref = $objp->product_ref; + $this->ref = $objp->product_ref; $this->product_ref = $objp->product_ref; $this->product_libelle = $objp->product_libelle; $this->product_desc = $objp->product_desc; $this->date_start = $this->db->jdate($objp->date_start); $this->date_end = $this->db->jdate($objp->date_end); - $this->fk_unit = $objp->fk_unit; + $this->fk_unit = $objp->fk_unit; $this->multicurrency_subprice = $objp->multicurrency_subprice; $this->multicurrency_total_ht = $objp->multicurrency_total_ht; @@ -3373,7 +3373,7 @@ class CommandeFournisseurLigne extends CommonOrderLine } else { - $this->error='Supplier order line with id='.$rowid.' not found'; + $this->error = 'Supplier order line with id='.$rowid.' not found'; dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); return 0; } @@ -3395,28 +3395,28 @@ class CommandeFournisseurLigne extends CommonOrderLine { global $conf, $user; - $error=0; + $error = 0; dol_syslog(get_class($this)."::insert rang=".$this->rang); // Clean parameters - if (empty($this->tva_tx)) $this->tva_tx=0; - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; - if (empty($this->localtax1_type)) $this->localtax1_type='0'; - if (empty($this->localtax2_type)) $this->localtax2_type='0'; - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->rang)) $this->rang=0; - if (empty($this->remise)) $this->remise=0; - if (empty($this->remise_percent)) $this->remise_percent=0; - if (empty($this->info_bits)) $this->info_bits=0; - if (empty($this->special_code)) $this->special_code=0; - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; - if (empty($this->pa_ht)) $this->pa_ht=0; + if (empty($this->tva_tx)) $this->tva_tx = 0; + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; + if (empty($this->localtax1_type)) $this->localtax1_type = '0'; + if (empty($this->localtax2_type)) $this->localtax2_type = '0'; + if (empty($this->total_localtax1)) $this->total_localtax1 = 0; + if (empty($this->total_localtax2)) $this->total_localtax2 = 0; + if (empty($this->rang)) $this->rang = 0; + if (empty($this->remise)) $this->remise = 0; + if (empty($this->remise_percent)) $this->remise_percent = 0; + if (empty($this->info_bits)) $this->info_bits = 0; + if (empty($this->special_code)) $this->special_code = 0; + if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; + if (empty($this->pa_ht)) $this->pa_ht = 0; // Multicurrency - if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + if (!empty($this->multicurrency_code)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) { $this->multicurrency_code = $conf->currency; @@ -3431,62 +3431,62 @@ class CommandeFournisseurLigne extends CommonOrderLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " (fk_commande, label, description, date_start, date_end,"; - $sql.= " fk_product, product_type, special_code, rang,"; - $sql.= " qty, vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice, ref,"; - $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_unit,"; - $sql.= " fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc"; - $sql.= ")"; - $sql.= " VALUES (".$this->fk_commande.", '" . $this->db->escape($this->label) . "','" . $this->db->escape($this->desc) . "',"; - $sql.= " ".($this->date_start?"'".$this->db->idate($this->date_start)."'":"null").","; - $sql.= " ".($this->date_end?"'".$this->db->idate($this->date_end)."'":"null").","; - if ($this->fk_product) { $sql.= $this->fk_product.","; } - else { $sql.= "null,"; } - $sql.= "'".$this->db->escape($this->product_type)."',"; - $sql.= "'".$this->db->escape($this->special_code)."',"; - $sql.= "'".$this->db->escape($this->rang)."',"; - $sql.= "'".$this->db->escape($this->qty)."', "; - $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").","; - $sql.= " ".$this->tva_tx.", "; - $sql.= " ".$this->localtax1_tx.","; - $sql.= " ".$this->localtax2_tx.","; - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; - $sql.= " ".$this->remise_percent.", ".price2num($this->subprice, 'MU').", '".$this->db->escape($this->ref_supplier)."',"; - $sql.= " ".price2num($this->total_ht).","; - $sql.= " ".price2num($this->total_tva).","; - $sql.= " ".price2num($this->total_localtax1).","; - $sql.= " ".price2num($this->total_localtax2).","; - $sql.= " ".price2num($this->total_ttc).","; - $sql.= ($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'":"null"); - $sql.= ", ".($this->fk_multicurrency ? $this->fk_multicurrency : "null"); - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".($this->multicurrency_subprice ? price2num($this->multicurrency_subprice) : '0'); - $sql.= ", ".($this->multicurrency_total_ht ? price2num($this->multicurrency_total_ht) : '0'); - $sql.= ", ".($this->multicurrency_total_tva ? price2num($this->multicurrency_total_tva) : '0'); - $sql.= ", ".($this->multicurrency_total_ttc ? price2num($this->multicurrency_total_ttc) : '0'); - $sql.= ")"; + $sql .= " (fk_commande, label, description, date_start, date_end,"; + $sql .= " fk_product, product_type, special_code, rang,"; + $sql .= " qty, vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice, ref,"; + $sql .= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_unit,"; + $sql .= " fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc"; + $sql .= ")"; + $sql .= " VALUES (".$this->fk_commande.", '".$this->db->escape($this->label)."','".$this->db->escape($this->desc)."',"; + $sql .= " ".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : "null").","; + $sql .= " ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null").","; + if ($this->fk_product) { $sql .= $this->fk_product.","; } + else { $sql .= "null,"; } + $sql .= "'".$this->db->escape($this->product_type)."',"; + $sql .= "'".$this->db->escape($this->special_code)."',"; + $sql .= "'".$this->db->escape($this->rang)."',"; + $sql .= "'".$this->db->escape($this->qty)."', "; + $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; + $sql .= " ".$this->tva_tx.", "; + $sql .= " ".$this->localtax1_tx.","; + $sql .= " ".$this->localtax2_tx.","; + $sql .= " '".$this->db->escape($this->localtax1_type)."',"; + $sql .= " '".$this->db->escape($this->localtax2_type)."',"; + $sql .= " ".$this->remise_percent.", ".price2num($this->subprice, 'MU').", '".$this->db->escape($this->ref_supplier)."',"; + $sql .= " ".price2num($this->total_ht).","; + $sql .= " ".price2num($this->total_tva).","; + $sql .= " ".price2num($this->total_localtax1).","; + $sql .= " ".price2num($this->total_localtax2).","; + $sql .= " ".price2num($this->total_ttc).","; + $sql .= ($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : "null"); + $sql .= ", ".($this->fk_multicurrency ? $this->fk_multicurrency : "null"); + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".($this->multicurrency_subprice ? price2num($this->multicurrency_subprice) : '0'); + $sql .= ", ".($this->multicurrency_total_ht ? price2num($this->multicurrency_total_ht) : '0'); + $sql .= ", ".($this->multicurrency_total_tva ? price2num($this->multicurrency_total_tva) : '0'); + $sql .= ", ".($this->multicurrency_total_ttc ? price2num($this->multicurrency_total_ttc) : '0'); + $sql .= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - $this->rowid =$this->id; + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + $this->rowid = $this->id; if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINEORDER_SUPPLIER_CREATE', $user); + $result = $this->call_trigger('LINEORDER_SUPPLIER_CREATE', $user); if ($result < 0) $error++; // End call triggers } @@ -3496,17 +3496,17 @@ class CommandeFournisseurLigne extends CommonOrderLine return 1; } - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->errors[]=($this->errors?', '.$errmsg:$errmsg); + $this->errors[] = ($this->errors ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { - $this->errors[]=$this->db->error(); + $this->errors[] = $this->db->error(); $this->db->rollback(); return -2; } @@ -3566,18 +3566,18 @@ class CommandeFournisseurLigne extends CommonOrderLine { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { global $user; // Call trigger - $result=$this->call_trigger('LINEORDER_SUPPLIER_UPDATE', $user); + $result = $this->call_trigger('LINEORDER_SUPPLIER_UPDATE', $user); if ($result < 0) { $this->db->rollback(); @@ -3586,7 +3586,7 @@ class CommandeFournisseurLigne extends CommonOrderLine // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return $result; @@ -3599,7 +3599,7 @@ class CommandeFournisseurLigne extends CommonOrderLine } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -3639,17 +3639,17 @@ class CommandeFournisseurLigne extends CommonOrderLine return 1; } - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 4cc39f781df..7ec271c84ec 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -148,16 +148,16 @@ class FactureFournisseur extends CommonInvoice */ public $date_echeance; - public $amount=0; - public $remise=0; - public $tva=0; + public $amount = 0; + public $remise = 0; + public $tva = 0; public $localtax1; public $localtax2; - public $total_ht=0; - public $total_tva=0; - public $total_localtax1=0; - public $total_localtax2=0; - public $total_ttc=0; + public $total_ht = 0; + public $total_tva = 0; + public $total_localtax1 = 0; + public $total_localtax2 = 0; + public $total_ttc = 0; /** * @deprecated @@ -290,15 +290,15 @@ class FactureFournisseur extends CommonInvoice */ public function create($user) { - global $langs,$conf,$hookmanager; + global $langs, $conf, $hookmanager; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Clean parameters - if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier); + if (isset($this->ref_supplier)) $this->ref_supplier = trim($this->ref_supplier); if (empty($this->type)) $this->type = self::TYPE_STANDARD; - if (empty($this->date)) $this->date=$now; + if (empty($this->date)) $this->date = $now; $socid = $this->socid; $ref_supplier = $this->ref_supplier; @@ -306,7 +306,7 @@ class FactureFournisseur extends CommonInvoice $remise = $this->remise; // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) { @@ -407,7 +407,7 @@ class FactureFournisseur extends CommonInvoice { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { dol_print_error($this->db); $error++; @@ -424,7 +424,7 @@ class FactureFournisseur extends CommonInvoice $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn, special_code)'; $sql .= ' VALUES ('.$this->id.','.intval($this->lines[$i]->special_code).')'; - $resql_insert=$this->db->query($sql); + $resql_insert = $this->db->query($sql); if ($resql_insert) { $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det'); @@ -439,7 +439,7 @@ class FactureFournisseur extends CommonInvoice $this->lines[$i]->qty, $this->lines[$i]->fk_product, 'HT', - (! empty($this->lines[$i]->info_bits)?$this->lines[$i]->info_bits:''), + (!empty($this->lines[$i]->info_bits) ? $this->lines[$i]->info_bits : ''), $this->lines[$i]->product_type, $this->lines[$i]->remise_percent, false, @@ -452,7 +452,7 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -5; } @@ -467,12 +467,12 @@ class FactureFournisseur extends CommonInvoice // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. - if (! is_object($line)) $line = (object) $line; + if (!is_object($line)) $line = (object) $line; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn, special_code)'; $sql .= ' VALUES ('.$this->id.','.intval($this->lines[$i]->special_code).')'; - $resql_insert=$this->db->query($sql); + $resql_insert = $this->db->query($sql); if ($resql_insert) { $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det'); @@ -487,13 +487,13 @@ class FactureFournisseur extends CommonInvoice $line->qty, $line->fk_product, 'HT', - (! empty($line->info_bits)?$line->info_bits:''), + (!empty($line->info_bits) ? $line->info_bits : ''), $line->product_type ); } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -5; } @@ -535,7 +535,7 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error=$langs->trans('FailedToUpdatePrice'); + $this->error = $langs->trans('FailedToUpdatePrice'); $this->db->rollback(); return -3; } @@ -544,13 +544,13 @@ class FactureFournisseur extends CommonInvoice { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$langs->trans('ErrorRefAlreadyExists'); + $this->error = $langs->trans('ErrorRefAlreadyExists'); $this->db->rollback(); return -1; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } @@ -653,26 +653,26 @@ class FactureFournisseur extends CommonInvoice $this->total_ttc = $obj->total_ttc; $this->fk_statut = $obj->fk_statut; $this->statut = $obj->fk_statut; - $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_author = $obj->fk_user_author; $this->author = $obj->fk_user_author; - $this->fk_user_valid = $obj->fk_user_valid; + $this->fk_user_valid = $obj->fk_user_valid; $this->fk_facture_source = $obj->fk_facture_source; $this->fk_project = $obj->fk_project; $this->cond_reglement_id = $obj->fk_cond_reglement; - $this->cond_reglement_code = $obj->cond_reglement_code; + $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; - $this->cond_reglement_doc = $obj->cond_reglement_libelle; - $this->fk_account = $obj->fk_account; + $this->cond_reglement_doc = $obj->cond_reglement_libelle; + $this->fk_account = $obj->fk_account; $this->mode_reglement_id = $obj->fk_mode_reglement; - $this->mode_reglement_code = $obj->mode_reglement_code; - $this->mode_reglement = $obj->mode_reglement_libelle; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement_libelle; $this->date_echeance = $this->db->jdate($obj->date_lim_reglement); - $this->note = $obj->note_private; // deprecated + $this->note = $obj->note_private; // deprecated $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; - $this->model_pdf = $obj->model_pdf; + $this->note_public = $obj->note_public; + $this->model_pdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf; - $this->import_key = $obj->import_key; + $this->import_key = $obj->import_key; //Incoterms $this->fk_incoterms = $obj->fk_incoterms; @@ -681,13 +681,13 @@ class FactureFournisseur extends CommonInvoice // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_code = $obj->multicurrency_code; $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); $this->socid = $obj->socid; $this->socnom = $obj->socnom; @@ -698,16 +698,16 @@ class FactureFournisseur extends CommonInvoice if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -3; } } else { - $this->error='Bill with id '.$id.' not found'; + $this->error = 'Bill with id '.$id.' not found'; dol_syslog(get_class($this).'::fetch '.$this->error); return 0; } @@ -717,7 +717,7 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -735,14 +735,14 @@ class FactureFournisseur extends CommonInvoice $this->lines = array(); $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.date_start, f.date_end, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx'; - $sql.= ', f.localtax1_tx, f.localtax2_tx, f.localtax1_type, f.localtax2_type, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn '; - $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit'; - $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; - $sql.= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid'; - $sql.= ' WHERE fk_facture_fourn='.$this->id; - $sql.= ' ORDER BY f.rang, f.rowid'; + $sql .= ', f.localtax1_tx, f.localtax2_tx, f.localtax1_type, f.localtax2_type, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn '; + $sql .= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit'; + $sql .= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; + $sql .= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid'; + $sql .= ' WHERE fk_facture_fourn='.$this->id; + $sql .= ' ORDER BY f.rang, f.rowid'; dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $resql_rows = $this->db->query($sql); @@ -816,7 +816,7 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -3; } } @@ -921,12 +921,12 @@ class FactureFournisseur extends CommonInvoice } } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('BILL_SUPPLIER_UPDATE', $user); + $result = $this->call_trigger('BILL_SUPPLIER_UPDATE', $user); if ($result < 0) $error++; // End call triggers } @@ -935,13 +935,13 @@ class FactureFournisseur extends CommonInvoice // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -967,41 +967,41 @@ class FactureFournisseur extends CommonInvoice $this->db->begin(); - $remise=new DiscountAbsolute($this->db); - $result=$remise->fetch($idremise); + $remise = new DiscountAbsolute($this->db); + $result = $remise->fetch($idremise); if ($result > 0) { if ($remise->fk_invoice_supplier) // Protection against multiple submission { - $this->error=$langs->trans("ErrorDiscountAlreadyUsed"); + $this->error = $langs->trans("ErrorDiscountAlreadyUsed"); $this->db->rollback(); return -5; } - $facligne=new SupplierInvoiceLine($this->db); - $facligne->fk_facture_fourn=$this->id; - $facligne->fk_remise_except=$remise->id; - $facligne->desc=$remise->description; // Description ligne - $facligne->vat_src_code=$remise->vat_src_code; - $facligne->tva_tx=$remise->tva_tx; + $facligne = new SupplierInvoiceLine($this->db); + $facligne->fk_facture_fourn = $this->id; + $facligne->fk_remise_except = $remise->id; + $facligne->desc = $remise->description; // Description ligne + $facligne->vat_src_code = $remise->vat_src_code; + $facligne->tva_tx = $remise->tva_tx; $facligne->subprice = -$remise->amount_ht; - $facligne->fk_product=0; // Id produit predefini - $facligne->product_type=0; - $facligne->qty=1; - $facligne->remise_percent=0; - $facligne->rang=-1; - $facligne->info_bits=2; + $facligne->fk_product = 0; // Id produit predefini + $facligne->product_type = 0; + $facligne->qty = 1; + $facligne->remise_percent = 0; + $facligne->rang = -1; + $facligne->info_bits = 2; // Get buy/cost price of invoice that is source of discount if ($remise->fk_invoice_supplier_source > 0) { - $srcinvoice=new FactureFournisseur($this->db); + $srcinvoice = new FactureFournisseur($this->db); $srcinvoice->fetch($remise->fk_invoice_supplier_source); - $totalcostpriceofinvoice=0; - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject - $formmargin=new FormMargin($this->db); - $arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false); + $totalcostpriceofinvoice = 0; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject + $formmargin = new FormMargin($this->db); + $arraytmp = $formmargin->getMarginInfosArray($srcinvoice, false); $facligne->pa_ht = $arraytmp['pa_total']; } @@ -1014,17 +1014,17 @@ class FactureFournisseur extends CommonInvoice $facligne->multicurrency_total_tva = -$remise->multicurrency_total_tva; $facligne->multicurrency_total_ttc = -$remise->multicurrency_total_ttc; - $lineid=$facligne->insert(); + $lineid = $facligne->insert(); if ($lineid > 0) { - $result=$this->update_price(1); + $result = $this->update_price(1); if ($result > 0) { // Create link between discount and invoice line - $result=$remise->link_to_invoice($lineid, 0, 'supplier'); + $result = $remise->link_to_invoice($lineid, 0, 'supplier'); if ($result < 0) { - $this->error=$remise->error; + $this->error = $remise->error; $this->db->rollback(); return -4; } @@ -1034,14 +1034,14 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error=$facligne->error; + $this->error = $facligne->error; $this->db->rollback(); return -1; } } else { - $this->error=$facligne->error; + $this->error = $facligne->error; $this->db->rollback(); return -2; } @@ -1063,21 +1063,21 @@ class FactureFournisseur extends CommonInvoice */ public function delete(User $user, $notrigger = 0) { - global $langs,$conf; + global $langs, $conf; - $rowid=$this->id; + $rowid = $this->id; dol_syslog("FactureFournisseur::delete rowid=".$rowid, LOG_DEBUG); // TODO Test if there is at least on payment. If yes, refuse to delete. - $error=0; + $error = 0; $this->db->begin(); - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BILL_SUPPLIER_DELETE', $user); + $result = $this->call_trigger('BILL_SUPPLIER_DELETE', $user); if ($result < 0) { $this->db->rollback(); @@ -1086,34 +1086,34 @@ class FactureFournisseur extends CommonInvoice // Fin appel triggers } - if (! $error) { + if (!$error) { // If invoice was converted into a discount not yet consumed, we remove discount - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'societe_remise_except'; - $sql .= ' WHERE fk_invoice_supplier_source = ' . $rowid; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except'; + $sql .= ' WHERE fk_invoice_supplier_source = '.$rowid; $sql .= ' AND fk_invoice_supplier_line IS NULL'; $resql = $this->db->query($sql); // If invoice has consumned discounts $this->fetch_lines(); - $list_rowid_det = array (); + $list_rowid_det = array(); foreach ($this->lines as $key => $invoiceline) { $list_rowid_det[] = $invoiceline->rowid; } // Consumned discounts are freed if (count($list_rowid_det)) { - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql .= ' SET fk_invoice_supplier = NULL, fk_invoice_supplier_line = NULL'; - $sql .= ' WHERE fk_invoice_supplier_line IN (' . join(',', $list_rowid_det) . ')'; + $sql .= ' WHERE fk_invoice_supplier_line IN ('.join(',', $list_rowid_det).')'; - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); - if (! $this->db->query($sql)) { - $error ++; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + if (!$this->db->query($sql)) { + $error++; } } } - if (! $error) + if (!$error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';'; dol_syslog(get_class($this)."::delete", LOG_DEBUG); @@ -1123,7 +1123,7 @@ class FactureFournisseur extends CommonInvoice $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql2 = $this->db->query($sql); - if (! $resql2) { + if (!$resql2) { $error++; } } @@ -1132,21 +1132,21 @@ class FactureFournisseur extends CommonInvoice } } - if (! $error) + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; } - if (! $error) + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; } - if (! $error) + if (!$error) { // We remove directory if ($conf->fournisseur->facture->dir_output) @@ -1155,22 +1155,22 @@ class FactureFournisseur extends CommonInvoice $ref = dol_sanitizeFileName($this->ref); $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoive_supplier').$ref; - $file = $dir . "/" . $ref . ".pdf"; + $file = $dir."/".$ref.".pdf"; if (file_exists($file)) { - if (! dol_delete_file($file, 0, 0, 0, $this)) // For triggers + if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers { - $this->error='ErrorFailToDeleteFile'; + $this->error = 'ErrorFailToDeleteFile'; $error++; } } if (file_exists($dir)) { - $res=@dol_delete_dir_recursive($dir); + $res = @dol_delete_dir_recursive($dir); - if (! $res) + if (!$res) { - $this->error='ErrorFailToDeleteDir'; + $this->error = 'ErrorFailToDeleteDir'; $error++; } } @@ -1178,9 +1178,9 @@ class FactureFournisseur extends CommonInvoice } // Remove 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(); + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -1188,7 +1188,7 @@ class FactureFournisseur extends CommonInvoice } } - if (! $error) + if (!$error) { dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG); $this->db->commit(); @@ -1196,7 +1196,7 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -$error; } @@ -1215,32 +1215,32 @@ class FactureFournisseur extends CommonInvoice public function set_paid($user, $close_code = '', $close_note = '') { // phpcs:enable - global $conf,$langs; - $error=0; + global $conf, $langs; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn'; - $sql.= ' SET paye = 1, fk_statut=2'; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET paye = 1, fk_statut=2'; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog("FactureFournisseur::set_paid", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('BILL_SUPPLIER_PAYED', $user); + $result = $this->call_trigger('BILL_SUPPLIER_PAYED', $user); if ($result < 0) $error++; // End call triggers } else { $error++; - $this->error=$this->db->error(); + $this->error = $this->db->error(); dol_print_error($this->db); } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1265,32 +1265,32 @@ class FactureFournisseur extends CommonInvoice public function set_unpaid($user) { // phpcs:enable - global $conf,$langs; - $error=0; + global $conf, $langs; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn'; - $sql.= ' SET paye=0, fk_statut=1, close_code=null, close_note=null'; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET paye=0, fk_statut=1, close_code=null, close_note=null'; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog("FactureFournisseur::set_unpaid", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('BILL_SUPPLIER_UNPAYED', $user); + $result = $this->call_trigger('BILL_SUPPLIER_UNPAYED', $user); if ($result < 0) $error++; // End call triggers } else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog("FactureFournisseur::set_unpaid ".$this->error); } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1335,13 +1335,13 @@ class FactureFournisseur extends CommonInvoice if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->ref_supplier)) { $langs->load("errors"); - $this->error=$langs->trans("ErrorFieldFormat", $langs->transnoentities("RefSupplier")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf")); + $this->error = $langs->trans("ErrorFieldFormat", $langs->transnoentities("RefSupplier")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf")); return -1; } if (count($this->lines) <= 0) { $langs->load("errors"); - $this->error=$langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); + $this->error = $langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); return -1; } @@ -1363,20 +1363,20 @@ class FactureFournisseur extends CommonInvoice $this->newref = $num; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; - $sql.= " SET ref='".$num."', fk_statut = 1, fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET ref='".$num."', fk_statut = 1, fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // Si on incrémente le produit principal et ses composants à la validation de facture fournisseur - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); - $cpt=count($this->lines); + $cpt = count($this->lines); for ($i = 0; $i < $cpt; $i++) { if ($this->lines[$i]->fk_product > 0) @@ -1396,15 +1396,15 @@ class FactureFournisseur extends CommonInvoice } // Triggers call - if (! $error && empty($notrigger)) + if (!$error && empty($notrigger)) { // Call trigger - $result=$this->call_trigger('BILL_SUPPLIER_VALIDATE', $user); + $result = $this->call_trigger('BILL_SUPPLIER_VALIDATE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -1430,13 +1430,13 @@ class FactureFournisseur extends CommonInvoice { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -1445,14 +1445,14 @@ class FactureFournisseur extends CommonInvoice } // Set new ref and define current statut - if (! $error) + if (!$error) { $this->ref = $num; - $this->statut=self::STATUS_VALIDATED; + $this->statut = self::STATUS_VALIDATED; //$this->date_validation=$now; this is stored into log table } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1465,7 +1465,7 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -1481,9 +1481,9 @@ class FactureFournisseur extends CommonInvoice public function setDraft($user, $idwarehouse = -1) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; - $error=0; + $error = 0; if ($this->statut == self::STATUS_DRAFT) { @@ -1496,24 +1496,24 @@ class FactureFournisseur extends CommonInvoice $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; - $sql.= " SET fk_statut = ".self::STATUS_DRAFT; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET fk_statut = ".self::STATUS_DRAFT; + $sql .= " WHERE rowid = ".$this->id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; + $this->oldcopy = clone $this; } // Si on incremente le produit principal et ses composants a la validation de facture fournisseur, on decremente - if ($result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) + if ($result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); - $cpt=count($this->lines); + $cpt = count($this->lines); for ($i = 0; $i < $cpt; $i++) { if ($this->lines[$i]->fk_product > 0) @@ -1547,7 +1547,7 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -1623,7 +1623,7 @@ class FactureFournisseur extends CommonInvoice if ($fk_product > 0) { - if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) + if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) { // Check quantity is enough dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." qty=".$qty." ref_supplier=".$ref_supplier); @@ -1636,19 +1636,19 @@ class FactureFournisseur extends CommonInvoice // We use 'none' instead of $ref_supplier, because $ref_supplier may not exists anymore. So we will take the first supplier price ok. // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. - $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc + $result = $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc ? $this->fk_soc : $this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc if ($result > 0) { - $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice - $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice // is remise percent not keyed but present for the product we add it - if ($remise_percent == 0 && $prod->remise_percent !=0) - $remise_percent =$prod->remise_percent; + if ($remise_percent == 0 && $prod->remise_percent != 0) + $remise_percent = $prod->remise_percent; } if ($result == 0) // If result == 0, we failed to found the supplier reference price { $langs->load("errors"); - $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->error = "Ref ".$prod->ref." ".$langs->trans("ErrorQtyTooLowForThisSupplier"); $this->db->rollback(); dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); //$pu = $prod->fourn_pu; // We do not overwrite unit price @@ -1658,14 +1658,14 @@ class FactureFournisseur extends CommonInvoice if ($result == -1) { $langs->load("errors"); - $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->error = "Ref ".$prod->ref." ".$langs->trans("ErrorQtyTooLowForThisSupplier"); $this->db->rollback(); dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); return -1; } if ($result < -1) { - $this->error=$prod->error; + $this->error = $prod->error; $this->db->rollback(); dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); return -1; @@ -1673,7 +1673,7 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error=$prod->error; + $this->error = $prod->error; $this->db->rollback(); return -1; } @@ -1688,14 +1688,14 @@ class FactureFournisseur extends CommonInvoice $pu = 0; } - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } // Calcul du total TTC et de la TVA pour la ligne a partir de @@ -1727,66 +1727,66 @@ class FactureFournisseur extends CommonInvoice } // Insert line - $this->line=new SupplierInvoiceLine($this->db); + $this->line = new SupplierInvoiceLine($this->db); $this->line->context = $this->context; - $this->line->fk_facture_fourn=$this->id; + $this->line->fk_facture_fourn = $this->id; //$this->line->label=$label; // deprecated - $this->line->desc=$desc; - $this->line->ref_supplier=$ref_supplier; + $this->line->desc = $desc; + $this->line->ref_supplier = $ref_supplier; - $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative - $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise - $this->line->vat_src_code=$vat_src_code; - $this->line->tva_tx=$txtva; - $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); - $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); + $this->line->vat_src_code = $vat_src_code; + $this->line->tva_tx = $txtva; + $this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0); + $this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0); $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; - $this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_tva= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); - $this->line->total_localtax1=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax1):$total_localtax1); - $this->line->total_localtax2=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax2):$total_localtax2); - $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); + $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax1) : $total_localtax1); + $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax2) : $total_localtax2); + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); - $this->line->fk_product=$fk_product; - $this->line->product_type=$type; - $this->line->remise_percent=$remise_percent; - $this->line->date_start=$date_start; - $this->line->date_end=$date_end; - $this->line->ventil=$ventil; - $this->line->rang=$rang; - $this->line->info_bits=$info_bits; + $this->line->fk_product = $fk_product; + $this->line->product_type = $type; + $this->line->remise_percent = $remise_percent; + $this->line->date_start = $date_start; + $this->line->date_end = $date_end; + $this->line->ventil = $ventil; + $this->line->rang = $rang; + $this->line->info_bits = $info_bits; - $this->line->special_code=((string) $special_code != '' ? $special_code : $this->special_code); - $this->line->fk_parent_line=$this->fk_parent_line; - $this->line->origin=$this->origin; - $this->line->origin_id=$origin_id; - $this->line->fk_unit=$fk_unit; + $this->line->special_code = ((string) $special_code != '' ? $special_code : $this->special_code); + $this->line->fk_parent_line = $this->fk_parent_line; + $this->line->origin = $this->origin; + $this->line->origin_id = $origin_id; + $this->line->fk_unit = $fk_unit; // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - if (is_array($array_options) && count($array_options)>0) { - $this->line->array_options=$array_options; + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; } - $result=$this->line->insert($notrigger); + $result = $this->line->insert($notrigger); if ($result > 0) { // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); // Mise a jour informations denormalisees au niveau de la facture meme - $result=$this->update_price(1, 'auto', 0, $this->thirdparty); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. + $result = $this->update_price(1, 'auto', 0, $this->thirdparty); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. if ($result > 0) { $this->db->commit(); @@ -1794,15 +1794,15 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } } else { - $this->error=$this->line->error; - $this->errors=$this->line->errors; + $this->error = $this->line->error; + $this->errors = $this->line->errors; $this->db->rollback(); return -2; } @@ -1844,8 +1844,8 @@ class FactureFournisseur extends CommonInvoice include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $pu = price2num($pu); - $qty = price2num($qty); - $remise_percent=price2num($remise_percent); + $qty = price2num($qty); + $remise_percent = price2num($remise_percent); $pu_ht_devise = price2num($pu_ht_devise); // Check parameters @@ -1854,33 +1854,33 @@ class FactureFournisseur extends CommonInvoice if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } // Clean parameters - if (empty($vatrate)) $vatrate=0; - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; + if (empty($vatrate)) $vatrate = 0; + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; - $txlocaltax1=price2num($txlocaltax1); - $txlocaltax2=price2num($txlocaltax2); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); - $localtaxes_type = array($txlocaltax1,$txlocaltax2); + $localtaxes_type = array($txlocaltax1, $txlocaltax2); // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($vatrate, 0, $mysoc, $this->thirdparty); + $localtaxes_type = getLocalTaxesFromRate($vatrate, 0, $mysoc, $this->thirdparty); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $vatrate, $reg)) { $vat_src_code = $reg[1]; - $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. + $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. } $tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); @@ -1894,17 +1894,17 @@ class FactureFournisseur extends CommonInvoice $total_localtax2 = $tabprice[10]; // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; - if (empty($info_bits)) $info_bits=0; + if (empty($info_bits)) $info_bits = 0; if ($idproduct) { - $product=new Product($this->db); - $result=$product->fetch($idproduct); + $product = new Product($this->db); + $result = $product->fetch($idproduct); $product_type = $product->type; } else @@ -1929,17 +1929,17 @@ class FactureFournisseur extends CommonInvoice $line->date_start = $date_start; $line->date_end = $date_end; - $line->vat_src_code=$vat_src_code; + $line->vat_src_code = $vat_src_code; $line->tva_tx = $vatrate; $line->localtax1_tx = $txlocaltax1; $line->localtax2_tx = $txlocaltax2; $line->localtax1_type = $localtaxes_type[0]; $line->localtax2_type = $localtaxes_type[2]; - $line->total_ht = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); - $line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); + $line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); + $line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); $line->total_localtax1 = $total_localtax1; $line->total_localtax2 = $total_localtax2; - $line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); + $line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); $line->fk_product = $idproduct; $line->product_type = $product_type; $line->info_bits = $info_bits; @@ -1947,8 +1947,8 @@ class FactureFournisseur extends CommonInvoice $line->array_options = $array_options; // Multicurrency - $line->multicurrency_subprice = $pu_ht_devise; - $line->multicurrency_total_ht = $multicurrency_total_ht; + $line->multicurrency_subprice = $pu_ht_devise; + $line->multicurrency_total_ht = $multicurrency_total_ht; $line->multicurrency_total_tva = $multicurrency_total_tva; $line->multicurrency_total_ttc = $multicurrency_total_ttc; @@ -1980,17 +1980,17 @@ class FactureFournisseur extends CommonInvoice $this->db->begin(); // Libere remise liee a ligne de facture - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql .= ' SET fk_invoice_supplier_line = NULL'; - $sql .= ' WHERE fk_invoice_supplier_line = ' . $rowid; + $sql .= ' WHERE fk_invoice_supplier_line = '.$rowid; - dol_syslog(get_class($this) . "::deleteline", LOG_DEBUG); + dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) + if (!$result) { $this->error = $this->db->error(); $this->db->rollback(); - return - 2; + return -2; } $line = new SupplierInvoiceLine($this->db); @@ -2004,7 +2004,7 @@ class FactureFournisseur extends CommonInvoice if ($res < 1) { $this->errors[] = $line->error; $this->db->rollback(); - return - 3; + return -3; } else { $res = $this->update_price(); @@ -2017,7 +2017,7 @@ class FactureFournisseur extends CommonInvoice { $this->db->rollback(); $this->error = $this->db->lasterror(); - return - 4; + return -4; } } } @@ -2032,11 +2032,11 @@ class FactureFournisseur extends CommonInvoice public function info($id) { $sql = 'SELECT c.rowid, datec, tms as datem, '; - $sql.= ' fk_user_author, fk_user_modif, fk_user_valid'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as c'; - $sql.= ' WHERE c.rowid = '.$id; + $sql .= ' fk_user_author, fk_user_modif, fk_user_valid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as c'; + $sql .= ' WHERE c.rowid = '.$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -2047,7 +2047,7 @@ class FactureFournisseur extends CommonInvoice { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) { @@ -2090,25 +2090,25 @@ class FactureFournisseur extends CommonInvoice $return = array(); $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut,"; - $sql.= " ff.rowid as rowidnext"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid = pf.fk_facturefourn"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON f.rowid = ff.fk_facture_source"; - $sql.= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.paye = 0"; // Pas classee payee completement - $sql.= " AND pf.fk_paiementfourn IS NULL"; // Aucun paiement deja fait - $sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; - $sql.= " ORDER BY f.ref"; + $sql .= " ff.rowid as rowidnext"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid = pf.fk_facturefourn"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON f.rowid = ff.fk_facture_source"; + $sql .= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; + $sql .= " AND f.entity = ".$conf->entity; + $sql .= " AND f.paye = 0"; // Pas classee payee completement + $sql .= " AND pf.fk_paiementfourn IS NULL"; // Aucun paiement deja fait + $sql .= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement + if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + $sql .= " ORDER BY f.ref"; dol_syslog(get_class($this)."::list_replacable_supplier_invoices", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $return[$obj->rowid]=array( + $return[$obj->rowid] = array( 'id' => $obj->rowid, 'ref' => $obj->ref, 'status' => $obj->fk_statut @@ -2119,7 +2119,7 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2142,29 +2142,29 @@ class FactureFournisseur extends CommonInvoice $return = array(); $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut, f.type, f.paye, pf.fk_paiementfourn"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid = pf.fk_facturefourn"; - $sql.= " WHERE f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; - $sql.= " AND NOT EXISTS (SELECT rowid from ".MAIN_DB_PREFIX."facture_fourn as ff WHERE f.rowid = ff.fk_facture_source"; - $sql.= " AND ff.type=".self::TYPE_REPLACEMENT.")"; - $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir - if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; - $sql.= " ORDER BY f.ref"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid = pf.fk_facturefourn"; + $sql .= " WHERE f.entity = ".$conf->entity; + $sql .= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; + $sql .= " AND NOT EXISTS (SELECT rowid from ".MAIN_DB_PREFIX."facture_fourn as ff WHERE f.rowid = ff.fk_facture_source"; + $sql .= " AND ff.type=".self::TYPE_REPLACEMENT.")"; + $sql .= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir + if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; + $sql .= " ORDER BY f.ref"; dol_syslog(get_class($this)."::list_qualified_avoir_supplier_invoices", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $qualified=0; - if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified=1; - if ($obj->fk_statut == self::STATUS_CLOSED) $qualified=1; + $qualified = 0; + if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified = 1; + if ($obj->fk_statut == self::STATUS_CLOSED) $qualified = 1; if ($qualified) { - $paymentornot=($obj->fk_paiementfourn?1:0); - $return[$obj->rowid]=array('ref'=>$obj->ref,'status'=>$obj->fk_statut,'type'=>$obj->type,'paye'=>$obj->paye,'paymentornot'=>$paymentornot); + $paymentornot = ($obj->fk_paiementfourn ? 1 : 0); + $return[$obj->rowid] = array('ref'=>$obj->ref, 'status'=>$obj->fk_statut, 'type'=>$obj->type, 'paye'=>$obj->paye, 'paymentornot'=>$paymentornot); } } @@ -2172,7 +2172,7 @@ class FactureFournisseur extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2231,7 +2231,7 @@ class FactureFournisseur extends CommonInvoice else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2253,7 +2253,7 @@ class FactureFournisseur extends CommonInvoice { global $langs, $conf; - $result=''; + $result = ''; if ($option == 'document') $url = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$this->id; else $url = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$this->id; @@ -2334,9 +2334,9 @@ class FactureFournisseur extends CommonInvoice $langs->load("orders"); // Clean parameters (if not defined or using deprecated value) - if (empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER)) $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER='mod_facture_fournisseur_cactus'; + if (empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER)) $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER = 'mod_facture_fournisseur_cactus'; - $mybool=false; + $mybool = false; $file = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER.".php"; $classname = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER; @@ -2348,7 +2348,7 @@ class FactureFournisseur extends CommonInvoice $dir = dol_buildpath($reldir."core/modules/supplier_invoice/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } if ($mybool === false) { @@ -2383,7 +2383,7 @@ class FactureFournisseur extends CommonInvoice */ public function initAsSpecimen($option = '') { - global $langs,$conf; + global $langs, $conf; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $now = dol_now(); @@ -2393,8 +2393,8 @@ class FactureFournisseur extends CommonInvoice $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) @@ -2410,17 +2410,17 @@ class FactureFournisseur extends CommonInvoice } // Initialise parametres - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; $this->ref_supplier = 'SUPPLIER_REF_SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->socid = 1; $this->date = $now; - $this->date_lim_reglement=$this->date+3600*24*30; + $this->date_lim_reglement = $this->date + 3600 * 24 * 30; $this->cond_reglement_code = 'RECEP'; $this->mode_reglement_code = 'CHQ'; - $this->note_public='This is a comment (public)'; - $this->note_private='This is a comment (private)'; + $this->note_public = 'This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; if (empty($option) || $option != 'nolines') { @@ -2429,38 +2429,38 @@ class FactureFournisseur extends CommonInvoice $xnbp = 0; while ($xnbp < $nbp) { - $line=new FactureLigne($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->qty=1; - $line->subprice=100; - $line->pu_ht=100; // the canelle template use pu_ht and not subprice - $line->price=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; + $line = new FactureLigne($this->db); + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->qty = 1; + $line->subprice = 100; + $line->pu_ht = 100; // the canelle template use pu_ht and not subprice + $line->price = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; if ($xnbp == 2) { - $line->total_ht=50; - $line->total_ttc=59.8; - $line->total_tva=9.8; - $line->remise_percent=50; + $line->total_ht = 50; + $line->total_ttc = 59.8; + $line->total_tva = 9.8; + $line->remise_percent = 50; } else { - $line->total_ht=100; - $line->total_ttc=119.6; - $line->total_tva=19.6; - $line->remise_percent=0; + $line->total_ht = 100; + $line->total_ttc = 119.6; + $line->total_tva = 19.6; + $line->remise_percent = 0; } if ($num_prods > 0) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + $line->fk_product = $prodids[$prodid]; } - $line->product_type=0; + $line->product_type = 0; - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $this->total_ht += $line->total_ht; $this->total_tva += $line->total_tva; @@ -2470,10 +2470,10 @@ class FactureFournisseur extends CommonInvoice } } - $this->amount_ht = $xnbp*100; - $this->total_ht = $xnbp*100; - $this->total_tva = $xnbp*19.6; - $this->total_ttc = $xnbp*119.6; + $this->amount_ht = $xnbp * 100; + $this->total_ht = $xnbp * 100; + $this->total_tva = $xnbp * 19.6; + $this->total_ttc = $xnbp * 119.6; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2515,7 +2515,7 @@ class FactureFournisseur extends CommonInvoice else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2557,7 +2557,7 @@ class FactureFournisseur extends CommonInvoice $object->close_note = ''; // Loop on each line of new invoice - foreach($object->lines as $i => $line) + foreach ($object->lines as $i => $line) { if (isset($object->lines[$i]->info_bits) && ($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts { @@ -2567,23 +2567,23 @@ class FactureFournisseur extends CommonInvoice // Create clone $object->context['createfromclone'] = 'createfromclone'; - $result=$object->create($user); + $result = $object->create($user); // Other options if ($result < 0) { - $this->error=$object->error; + $this->error = $object->error; $error++; } - if (! $error) + if (!$error) { } unset($object->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $object->id; @@ -2615,13 +2615,13 @@ class FactureFournisseur extends CommonInvoice // Set the model on the model name to use if (empty($modele)) { - if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) + if (!empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) { $modele = $conf->global->INVOICE_SUPPLIER_ADDON_PDF; } else { - $modele = ''; // No default value. For supplier invoice, we allow to disable all PDF generation + $modele = ''; // No default value. For supplier invoice, we allow to disable all PDF generation } } @@ -2715,12 +2715,12 @@ class SupplierInvoiceLine extends CommonObjectLine /** * @var string ID to identify managed object */ - public $element='facture_fourn_det'; + public $element = 'facture_fourn_det'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='facture_fourn_det'; + public $table_element = 'facture_fourn_det'; public $oldline; @@ -2853,7 +2853,7 @@ class SupplierInvoiceLine extends CommonObjectLine */ public function __construct($db) { - $this->db= $db; + $this->db = $db; } /** @@ -2887,18 +2887,18 @@ class SupplierInvoiceLine extends CommonObjectLine $obj = $this->db->fetch_object($query); - $this->id = $obj->rowid; - $this->rowid = $obj->rowid; - $this->fk_facture_fourn = $obj->fk_facture_fourn; + $this->id = $obj->rowid; + $this->rowid = $obj->rowid; + $this->fk_facture_fourn = $obj->fk_facture_fourn; $this->description = $obj->description; - $this->date_start = $obj->date_start; - $this->date_end = $obj->date_end; + $this->date_start = $obj->date_start; + $this->date_end = $obj->date_end; $this->product_ref = $obj->product_ref; $this->ref_supplier = $obj->ref_supplier; $this->libelle = $obj->label; $this->label = $obj->label; $this->product_desc = $obj->product_desc; - $this->subprice = $obj->pu_ht; + $this->subprice = $obj->pu_ht; $this->pu_ht = $obj->pu_ht; $this->pu_ttc = $obj->pu_ttc; $this->tva_tx = $obj->tva_tx; @@ -2970,7 +2970,7 @@ class SupplierInvoiceLine extends CommonObjectLine } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -2993,10 +2993,10 @@ class SupplierInvoiceLine extends CommonObjectLine global $conf; $pu = price2num($this->pu_ht); - $qty = price2num($this->qty); + $qty = price2num($this->qty); // Check parameters - if (empty($this->qty)) $this->qty=0; + if (empty($this->qty)) $this->qty = 0; if ($this->product_type < 0) { return -1; @@ -3024,37 +3024,37 @@ class SupplierInvoiceLine extends CommonObjectLine } $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; - $sql.= " description ='".$this->db->escape($this->description)."'"; - $sql.= ", ref ='".$this->db->escape($this->ref_supplier ? $this->ref_supplier : $this->ref)."'"; - $sql.= ", date_start = ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : "null"); - $sql.= ", date_end = ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : "null"); - $sql.= ", pu_ht = ".price2num($this->pu_ht); - $sql.= ", pu_ttc = ".price2num($this->pu_ttc); - $sql.= ", qty = ".price2num($this->qty); - $sql.= ", remise_percent = ".price2num($this->remise_percent); - $sql.= ", vat_src_code = '".$this->db->escape(empty($this->vat_src_code)?'':$this->vat_src_code)."'"; - $sql.= ", tva_tx = ".price2num($this->tva_tx); - $sql.= ", localtax1_tx = ".price2num($this->localtax1_tx); - $sql.= ", localtax2_tx = ".price2num($this->localtax2_tx); - $sql.= ", localtax1_type = '".$this->db->escape($this->localtax1_type)."'"; - $sql.= ", localtax2_type = '".$this->db->escape($this->localtax2_type)."'"; - $sql.= ", total_ht = ".price2num($this->total_ht); - $sql.= ", tva= ".price2num($this->total_tva); - $sql.= ", total_localtax1= ".price2num($this->total_localtax1); - $sql.= ", total_localtax2= ".price2num($this->total_localtax2); - $sql.= ", total_ttc = ".price2num($this->total_ttc); - $sql.= ", fk_product = ".$fk_product; - $sql.= ", product_type = ".$this->product_type; - $sql.= ", info_bits = ".$this->info_bits; - $sql.= ", fk_unit = ".$fk_unit; + $sql .= " description ='".$this->db->escape($this->description)."'"; + $sql .= ", ref ='".$this->db->escape($this->ref_supplier ? $this->ref_supplier : $this->ref)."'"; + $sql .= ", date_start = ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : "null"); + $sql .= ", date_end = ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : "null"); + $sql .= ", pu_ht = ".price2num($this->pu_ht); + $sql .= ", pu_ttc = ".price2num($this->pu_ttc); + $sql .= ", qty = ".price2num($this->qty); + $sql .= ", remise_percent = ".price2num($this->remise_percent); + $sql .= ", vat_src_code = '".$this->db->escape(empty($this->vat_src_code) ? '' : $this->vat_src_code)."'"; + $sql .= ", tva_tx = ".price2num($this->tva_tx); + $sql .= ", localtax1_tx = ".price2num($this->localtax1_tx); + $sql .= ", localtax2_tx = ".price2num($this->localtax2_tx); + $sql .= ", localtax1_type = '".$this->db->escape($this->localtax1_type)."'"; + $sql .= ", localtax2_type = '".$this->db->escape($this->localtax2_type)."'"; + $sql .= ", total_ht = ".price2num($this->total_ht); + $sql .= ", tva= ".price2num($this->total_tva); + $sql .= ", total_localtax1= ".price2num($this->total_localtax1); + $sql .= ", total_localtax2= ".price2num($this->total_localtax2); + $sql .= ", total_ttc = ".price2num($this->total_ttc); + $sql .= ", fk_product = ".$fk_product; + $sql .= ", product_type = ".$this->product_type; + $sql .= ", info_bits = ".$this->info_bits; + $sql .= ", fk_unit = ".$fk_unit; // Multicurrency - $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; + $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; + $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; + $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); @@ -3077,7 +3077,7 @@ class SupplierInvoiceLine extends CommonObjectLine } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { global $langs, $user; @@ -3158,70 +3158,70 @@ class SupplierInvoiceLine extends CommonObjectLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' (fk_facture_fourn, fk_parent_line, label, description, ref, qty,'; - $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; - $sql.= ' fk_product, product_type, remise_percent, pu_ht, pu_ttc,'; - $sql.= ' date_start, date_end, fk_code_ventilation, rang, special_code,'; - $sql.= ' info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit'; - $sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; - $sql.= ')'; - $sql.= " VALUES (".$this->fk_facture_fourn.","; - $sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").","; - $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; - $sql.= " '".$this->db->escape($this->desc ? $this->desc : $this->description)."',"; - $sql.= " '".$this->db->escape($this->ref_supplier)."',"; - $sql.= " ".price2num($this->qty).","; + $sql .= ' (fk_facture_fourn, fk_parent_line, label, description, ref, qty,'; + $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql .= ' fk_product, product_type, remise_percent, pu_ht, pu_ttc,'; + $sql .= ' date_start, date_end, fk_code_ventilation, rang, special_code,'; + $sql .= ' info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit'; + $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; + $sql .= ')'; + $sql .= " VALUES (".$this->fk_facture_fourn.","; + $sql .= " ".($this->fk_parent_line > 0 ? "'".$this->db->escape($this->fk_parent_line)."'" : "null").","; + $sql .= " ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; + $sql .= " '".$this->db->escape($this->desc ? $this->desc : $this->description)."',"; + $sql .= " '".$this->db->escape($this->ref_supplier)."',"; + $sql .= " ".price2num($this->qty).","; - $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").","; - $sql.= " ".price2num($this->tva_tx).","; - $sql.= " ".price2num($this->localtax1_tx).","; - $sql.= " ".price2num($this->localtax2_tx).","; - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; - $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").','; - $sql.= " ".$this->product_type.","; - $sql.= " ".price2num($this->remise_percent).","; - $sql.= " ".price2num($this->subprice).","; - $sql.= " ".(! empty($this->qty)?price2num($this->total_ttc / $this->qty):price2num($this->total_ttc)).","; - $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").","; - $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").","; - $sql.= ' '.(! empty($this->fk_code_ventilation)?$this->fk_code_ventilation:0).','; - $sql.= ' '.$this->rang.','; - $sql.= ' '.$this->special_code.','; - $sql.= " '".$this->db->escape($this->info_bits)."',"; - $sql.= " ".price2num($this->total_ht).","; - $sql.= " ".price2num($this->total_tva).","; - $sql.= " ".price2num($this->total_ttc).","; - $sql.= " ".price2num($this->total_localtax1).","; - $sql.= " ".price2num($this->total_localtax2); + $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; + $sql .= " ".price2num($this->tva_tx).","; + $sql .= " ".price2num($this->localtax1_tx).","; + $sql .= " ".price2num($this->localtax2_tx).","; + $sql .= " '".$this->db->escape($this->localtax1_type)."',"; + $sql .= " '".$this->db->escape($this->localtax2_type)."',"; + $sql .= ' '.(!empty($this->fk_product) ? $this->fk_product : "null").','; + $sql .= " ".$this->product_type.","; + $sql .= " ".price2num($this->remise_percent).","; + $sql .= " ".price2num($this->subprice).","; + $sql .= " ".(!empty($this->qty) ?price2num($this->total_ttc / $this->qty) : price2num($this->total_ttc)).","; + $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").","; + $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").","; + $sql .= ' '.(!empty($this->fk_code_ventilation) ? $this->fk_code_ventilation : 0).','; + $sql .= ' '.$this->rang.','; + $sql .= ' '.$this->special_code.','; + $sql .= " '".$this->db->escape($this->info_bits)."',"; + $sql .= " ".price2num($this->total_ht).","; + $sql .= " ".price2num($this->total_tva).","; + $sql .= " ".price2num($this->total_ttc).","; + $sql .= " ".price2num($this->total_localtax1).","; + $sql .= " ".price2num($this->total_localtax2); $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".price2num($this->multicurrency_subprice); - $sql.= ", ".price2num($this->multicurrency_total_ht); - $sql.= ", ".price2num($this->multicurrency_total_tva); - $sql.= ", ".price2num($this->multicurrency_total_ttc); - $sql.= ')'; + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".price2num($this->multicurrency_subprice); + $sql .= ", ".price2num($this->multicurrency_total_ht); + $sql .= ", ".price2num($this->multicurrency_total_tva); + $sql .= ", ".price2num($this->multicurrency_total_ttc); + $sql .= ')'; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - $this->rowid=$this->id; // backward compatibility + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + $this->rowid = $this->id; // backward compatibility if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINEBILL_SUPPLIER_CREATE', $user); + $result = $this->call_trigger('LINEBILL_SUPPLIER_CREATE', $user); if ($result < 0) { $this->db->rollback(); @@ -3235,7 +3235,7 @@ class SupplierInvoiceLine extends CommonObjectLine } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -2; } @@ -3254,16 +3254,16 @@ class SupplierInvoiceLine extends CommonObjectLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; - $sql.= " total_ht='".price2num($this->total_ht)."'"; - $sql.= ", tva='".price2num($this->total_tva)."'"; - $sql.= ", total_localtax1='".price2num($this->total_localtax1)."'"; - $sql.= ", total_localtax2='".price2num($this->total_localtax2)."'"; - $sql.= ", total_ttc='".price2num($this->total_ttc)."'"; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " total_ht='".price2num($this->total_ht)."'"; + $sql .= ", tva='".price2num($this->total_tva)."'"; + $sql .= ", total_localtax1='".price2num($this->total_localtax1)."'"; + $sql .= ", total_localtax2='".price2num($this->total_localtax2)."'"; + $sql .= ", total_ttc='".price2num($this->total_ttc)."'"; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog("FactureFournisseurLigne.class.php::update_total", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); @@ -3271,7 +3271,7 @@ class SupplierInvoiceLine extends CommonObjectLine } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -2; } diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index b9961f56206..543dada0138 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -47,19 +47,19 @@ $optioncss = GETPOST('optioncss', 'alpha'); $facid = GETPOST('facid', 'int'); $socid = GETPOST('socid', 'int'); -$accountid = GETPOST('accountid', 'int'); -$day = GETPOST('day', 'int'); +$accountid = GETPOST('accountid', 'int'); +$day = GETPOST('day', 'int'); $month = GETPOST('month', 'int'); -$year = GETPOST('year', 'int'); +$year = GETPOST('year', 'int'); -$search_ref=GETPOST("search_ref", "alpha"); -$search_account=GETPOST("search_account", "int"); -$search_paymenttype=GETPOST("search_paymenttype"); -$search_amount=GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x" -$search_company=GETPOST("search_company", 'alpha'); -$search_payment_num=GETPOST('search_payment_num', 'alpha'); +$search_ref = GETPOST("search_ref", "alpha"); +$search_account = GETPOST("search_account", "int"); +$search_paymenttype = GETPOST("search_paymenttype"); +$search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be able to search on "< x" +$search_company = GETPOST("search_company", 'alpha'); +$search_payment_num = GETPOST('search_payment_num', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -67,15 +67,15 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="p.rowid"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "p.rowid"; $amounts = array(); -$amountsresttopay=array(); -$addwarning=0; +$amountsresttopay = array(); +$addwarning = 0; -$multicurrency_amounts=array(); -$multicurrency_amountsresttopay=array(); +$multicurrency_amounts = array(); +$multicurrency_amountsresttopay = array(); // Security check if ($user->socid > 0) @@ -104,25 +104,25 @@ $arrayfields=array(); 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_ref=""; - $search_account=""; - $search_amount=""; - $search_paymenttype=""; - $search_payment_num=""; - $search_company=""; - $day=''; - $year=''; - $month=''; - $search_array_options=array(); + $search_ref = ""; + $search_account = ""; + $search_amount = ""; + $search_paymenttype = ""; + $search_payment_num = ""; + $search_company = ""; + $day = ''; + $year = ''; + $month = ''; + $search_array_options = array(); } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) { - if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) { $error = 0; @@ -132,7 +132,7 @@ if (empty($reshook)) $atleastonepaymentnotnull = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new FactureFournisseur($db); + $tmpinvoice = new FactureFournisseur($db); foreach ($_POST as $key => $value) { if (substr($key, 0, 7) == 'amount_') @@ -140,16 +140,16 @@ if (empty($reshook)) $cursorfacid = substr($key, 7); $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); if ($amounts[$cursorfacid]) { // Check amount if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier"); } // Check date @@ -161,23 +161,23 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; - if (! empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $multicurrency_amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(1)); + $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(1)); if ($multicurrency_amounts[$cursorfacid]) { // Check amount if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier"); } // Check date @@ -189,7 +189,7 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => GETPOST($key, 'int')); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int')); } } @@ -200,7 +200,7 @@ if (empty($reshook)) $error++; } - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // If bank module is on, account is required to enter a payment if (GETPOST('accountid') <= 0) @@ -248,7 +248,7 @@ if (empty($reshook)) */ if ($action == 'confirm_paiement' && $confirm == 'yes') { - $error=0; + $error = 0; $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); @@ -279,7 +279,7 @@ if (empty($reshook)) //var_dump($multicurrency_amounts); //exit; - if (! $error) + if (!$error) { $db->begin(); @@ -289,14 +289,14 @@ if (empty($reshook)) // Creation de la ligne paiement $paiement = new PaiementFourn($db); $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array of amounts + $paiement->amounts = $amounts; // Array of amounts $paiement->multicurrency_amounts = $multicurrency_amounts; $paiement->paiementid = $_POST['paiementid']; $paiement->num_paiement = $_POST['num_paiement']; $paiement->note = $_POST['comment']; - if (! $error) + if (!$error) { - $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0), $thirdparty); + $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -304,9 +304,9 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { - $result=$paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, '', ''); + $result = $paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, '', ''); if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -314,19 +314,19 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $db->commit(); // If payment dispatching on more than one invoice, we stay on summary page, otherwise go on invoice card - $invoiceid=0; + $invoiceid = 0; foreach ($paiement->amounts as $key => $amount) { $facid = $key; if (is_numeric($amount) && $amount <> 0) { - if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment - else $invoiceid=$facid; + if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment + else $invoiceid = $facid; } } if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$invoiceid; @@ -347,10 +347,10 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$formother=new FormOther($db); +$form = new Form($db); +$formother = new FormOther($db); -$supplierstatic=new Societe($db); +$supplierstatic = new Societe($db); $invoicesupplierstatic = new FactureFournisseur($db); llxHeader('', $langs->trans('ListPayment')); @@ -360,17 +360,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $object = new FactureFournisseur($db); $result = $object->fetch($facid); - $datefacture=dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datefacture); + $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $dateinvoice = ($datefacture == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datefacture); $sql = 'SELECT s.nom as name, s.rowid as socid,'; - $sql.= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total, f.fk_mode_reglement, f.fk_account'; + $sql .= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total, f.fk_mode_reglement, f.fk_account'; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; - $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f'; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ' WHERE f.fk_soc = s.rowid'; - $sql.= ' AND f.rowid = '.$facid; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= ' WHERE f.fk_soc = s.rowid'; + $sql .= ' AND f.rowid = '.$facid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $resql = $db->query($sql); if ($resql) { @@ -383,7 +383,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print load_fiche_titre($langs->trans('DoPayment')); // Add realtime total information - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print "\n".''."\n"; + print ''."\n"; } // Wrapper to add log when clicking on download or preview - if (! empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0) + if (!empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0) { if (in_array($object->element, array('facture'))) // Restrict for the moment to element 'facture' { diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index b0138b65cbf..41150e913d5 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -32,7 +32,7 @@ * This script reads the conf file, init $lang, $db and and empty $user */ -require_once 'filefunc.inc.php'; // May have been already require by main.inc.php. But may not by scripts. +require_once 'filefunc.inc.php'; // May have been already require by main.inc.php. But may not by scripts. @@ -51,32 +51,32 @@ $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; $conf->db->type = $dolibarr_main_db_type; -$conf->db->prefix = $dolibarr_main_db_prefix; -$conf->db->character_set = $dolibarr_main_db_character_set; -$conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation; -$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; -$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; -if (defined('TEST_DB_FORCE_TYPE')) $conf->db->type=constant('TEST_DB_FORCE_TYPE'); // Force db type (for test purpose, by PHP unit for example) +$conf->db->prefix = $dolibarr_main_db_prefix; +$conf->db->character_set = $dolibarr_main_db_character_set; +$conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation; +$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; +$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; +if (defined('TEST_DB_FORCE_TYPE')) $conf->db->type = constant('TEST_DB_FORCE_TYPE'); // Force db type (for test purpose, by PHP unit for example) // Set properties specific to conf file -$conf->file->main_limit_users = $dolibarr_main_limit_users; +$conf->file->main_limit_users = $dolibarr_main_limit_users; $conf->file->mailing_limit_sendbyweb = $dolibarr_mailing_limit_sendbyweb; $conf->file->mailing_limit_sendbycli = $dolibarr_mailing_limit_sendbycli; -$conf->file->main_authentication = empty($dolibarr_main_authentication)?'':$dolibarr_main_authentication; // Identification mode -$conf->file->main_force_https = empty($dolibarr_main_force_https)?'':$dolibarr_main_force_https; // Force https -$conf->file->strict_mode = empty($dolibarr_strict_mode)?'':$dolibarr_strict_mode; // Force php strict mode (for debug) -$conf->file->instance_unique_id = empty($dolibarr_main_instance_unique_id)?(empty($dolibarr_main_cookie_cryptkey)?'':$dolibarr_main_cookie_cryptkey):$dolibarr_main_instance_unique_id; // Unique id of instance -$conf->file->dol_document_root = array('main' => (string) DOL_DOCUMENT_ROOT); // Define array of document root directories ('/home/htdocs') -$conf->file->dol_url_root = array('main' => (string) DOL_URL_ROOT); // Define array of url root path ('' or '/dolibarr') -if (! empty($dolibarr_main_document_root_alt)) +$conf->file->main_authentication = empty($dolibarr_main_authentication) ? '' : $dolibarr_main_authentication; // Identification mode +$conf->file->main_force_https = empty($dolibarr_main_force_https) ? '' : $dolibarr_main_force_https; // Force https +$conf->file->strict_mode = empty($dolibarr_strict_mode) ? '' : $dolibarr_strict_mode; // Force php strict mode (for debug) +$conf->file->instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ? '' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id; // Unique id of instance +$conf->file->dol_document_root = array('main' => (string) DOL_DOCUMENT_ROOT); // Define array of document root directories ('/home/htdocs') +$conf->file->dol_url_root = array('main' => (string) DOL_URL_ROOT); // Define array of url root path ('' or '/dolibarr') +if (!empty($dolibarr_main_document_root_alt)) { // dolibarr_main_document_root_alt can contains several directories - $values=preg_split('/[;,]/', $dolibarr_main_document_root_alt); - $i=0; - foreach($values as $value) $conf->file->dol_document_root['alt'.($i++)]=(string) $value; - $values=preg_split('/[;,]/', $dolibarr_main_url_root_alt); - $i=0; - foreach($values as $value) + $values = preg_split('/[;,]/', $dolibarr_main_document_root_alt); + $i = 0; + foreach ($values as $value) $conf->file->dol_document_root['alt'.($i++)] = (string) $value; + $values = preg_split('/[;,]/', $dolibarr_main_url_root_alt); + $i = 0; + foreach ($values as $value) { if (preg_match('/^http(s)?:/', $value)) { @@ -94,30 +94,30 @@ if (! empty($dolibarr_main_document_root_alt)) print "\"/custom\"
        \n"; exit; } - $conf->file->dol_url_root['alt'.($i++)]=(string) $value; + $conf->file->dol_url_root['alt'.($i++)] = (string) $value; } } // Chargement des includes principaux de librairies communes -if (! defined('NOREQUIREUSER')) require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; // Need 500ko memory -if (! defined('NOREQUIRETRAN')) require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php'; -if (! defined('NOREQUIRESOC')) require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; +if (!defined('NOREQUIREUSER')) require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Need 500ko memory +if (!defined('NOREQUIRETRAN')) require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; +if (!defined('NOREQUIRESOC')) require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; /* * Creation objet $langs (must be before all other code) */ -if (! defined('NOREQUIRETRAN')) +if (!defined('NOREQUIRETRAN')) { - $langs = new Translate('', $conf); // Must be after reading conf + $langs = new Translate('', $conf); // Must be after reading conf } /* * Object $db */ -if (! defined('NOREQUIREDB')) +if (!defined('NOREQUIREDB')) { - $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->error) { @@ -147,12 +147,12 @@ if (! defined('NOREQUIREDB')) // Now database connexion is known, so we can forget password //unset($dolibarr_main_db_pass); // We comment this because this constant is used in a lot of pages -unset($conf->db->pass); // This is to avoid password to be shown in memory/swap dump +unset($conf->db->pass); // This is to avoid password to be shown in memory/swap dump /* * Object $user */ -if (! defined('NOREQUIREUSER')) { +if (!defined('NOREQUIREUSER')) { $user = new User($db); } @@ -162,11 +162,11 @@ if (! defined('NOREQUIREUSER')) { */ // By default conf->entity is 1, but we change this if we ask another value. -if (session_id() && ! empty($_SESSION["dol_entity"])) // Entity inside an opened session +if (session_id() && !empty($_SESSION["dol_entity"])) // Entity inside an opened session { $conf->entity = $_SESSION["dol_entity"]; } -elseif (! empty($_ENV["dol_entity"])) // Entity inside a CLI script +elseif (!empty($_ENV["dol_entity"])) // Entity inside a CLI script { $conf->entity = $_ENV["dol_entity"]; } @@ -180,9 +180,9 @@ elseif (defined('DOLENTITY') && is_numeric(DOLENTITY)) // For public page with } // Sanitize entity -if (! is_numeric($conf->entity)) $conf->entity=1; +if (!is_numeric($conf->entity)) $conf->entity = 1; -if (! defined('NOREQUIREDB')) +if (!defined('NOREQUIREDB')) { //print "Will work with data into entity instance number '".$conf->entity."'"; @@ -191,7 +191,7 @@ if (! defined('NOREQUIREDB')) } // Overwrite database value -if (! empty($conf->file->mailing_limit_sendbyweb)) +if (!empty($conf->file->mailing_limit_sendbyweb)) { $conf->global->MAILING_LIMIT_SENDBYWEB = $conf->file->mailing_limit_sendbyweb; } @@ -199,7 +199,7 @@ if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) { $conf->global->MAILING_LIMIT_SENDBYWEB = 25; } -if (! empty($conf->file->mailing_limit_sendbycli)) +if (!empty($conf->file->mailing_limit_sendbycli)) { $conf->global->MAILING_LIMIT_SENDBYCLI = $conf->file->mailing_limit_sendbycli; } @@ -209,27 +209,27 @@ if (empty($conf->global->MAILING_LIMIT_SENDBYCLI)) } // If software has been locked. Only login $conf->global->MAIN_ONLY_LOGIN_ALLOWED is allowed. -if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) +if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { - $ok=0; - if ((! session_id() || ! isset($_SESSION["dol_login"])) && ! isset($_POST["username"]) && ! empty($_SERVER["GATEWAY_INTERFACE"])) $ok=1; // We let working pages if not logged and inside a web browser (login form, to allow login by admin) - elseif (isset($_POST["username"]) && $_POST["username"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) $ok=1; // We let working pages that is a login submission (login submit, to allow login by admin) - elseif (defined('NOREQUIREDB')) $ok=1; // We let working pages that don't need database access (xxx.css.php) - elseif (defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) $ok=1; // We let working pages that ask to work even if only login enabled (logout.php) - elseif (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) $ok=1; // We let working if user is allowed admin - if (! $ok) + $ok = 0; + if ((!session_id() || !isset($_SESSION["dol_login"])) && !isset($_POST["username"]) && !empty($_SERVER["GATEWAY_INTERFACE"])) $ok = 1; // We let working pages if not logged and inside a web browser (login form, to allow login by admin) + elseif (isset($_POST["username"]) && $_POST["username"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) $ok = 1; // We let working pages that is a login submission (login submit, to allow login by admin) + elseif (defined('NOREQUIREDB')) $ok = 1; // We let working pages that don't need database access (xxx.css.php) + elseif (defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) $ok = 1; // We let working pages that ask to work even if only login enabled (logout.php) + elseif (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] == $conf->global->MAIN_ONLY_LOGIN_ALLOWED) $ok = 1; // We let working if user is allowed admin + if (!$ok) { if (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] != $conf->global->MAIN_ONLY_LOGIN_ALLOWED) { print 'Sorry, your application is offline.'."\n"; print 'You are logged with user "'.$_SESSION["dol_login"].'" and only administrator user "'.$conf->global->MAIN_ONLY_LOGIN_ALLOWED.'" is allowed to connect for the moment.'."\n"; - $nexturl=DOL_URL_ROOT.'/user/logout.php'; + $nexturl = DOL_URL_ROOT.'/user/logout.php'; print 'Please try later or click here to disconnect and change login user...'."\n"; } else { print 'Sorry, your application is offline. Only administrator user "'.$conf->global->MAIN_ONLY_LOGIN_ALLOWED.'" is allowed to connect for the moment.'."\n"; - $nexturl=DOL_URL_ROOT.'/'; + $nexturl = DOL_URL_ROOT.'/'; print 'Please try later or click here to change login user...'."\n"; } exit; diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php index e696be779d0..a99a4d4a4dd 100644 --- a/htdocs/modulebuilder/admin/setup.php +++ b/htdocs/modulebuilder/admin/setup.php @@ -21,9 +21,9 @@ * \brief Page setup for modulebuilder module */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -global $conf,$langs,$user, $db; +global $conf, $langs, $user, $db; $langs->loadLangs(array("admin", "other", "modulebuilder")); if (!$user->admin || empty($conf->modulebuilder->enabled)) @@ -35,16 +35,16 @@ $backtopage = GETPOST('backtopage', 'alpha'); /* * Actions */ -if ($action=="update") +if ($action == "update") { - $res1=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'none'), 'chaine', 0, '', $conf->entity); - $res2=dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res3=dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res4=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_NAME', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_NAME', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res5=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_URL', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_URL', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res6=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_FAMILY', GETPOST('MODULEBUILDER_SPECIFIC_FAMILY', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res7=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_AUTHOR', GETPOST('MODULEBUILDER_SPECIFIC_AUTHOR', 'html'), 'chaine', 0, '', $conf->entity); - $res8=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_VERSION', GETPOST('MODULEBUILDER_SPECIFIC_VERSION', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res1 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'none'), 'chaine', 0, '', $conf->entity); + $res2 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res3 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res4 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_NAME', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_NAME', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res5 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_URL', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_URL', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res6 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_FAMILY', GETPOST('MODULEBUILDER_SPECIFIC_FAMILY', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res7 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_AUTHOR', GETPOST('MODULEBUILDER_SPECIFIC_AUTHOR', 'html'), 'chaine', 0, '', $conf->entity); + $res8 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_VERSION', GETPOST('MODULEBUILDER_SPECIFIC_VERSION', 'nohtml'), 'chaine', 0, '', $conf->entity); if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0 || $res7 < 0 || $res8 < 0) { setEventMessages('ErrorFailedToSaveDate', null, 'errors'); $db->rollback(); @@ -63,7 +63,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) { $values = implode(',', $values); if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); @@ -73,7 +73,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) { if (preg_match('/del_(.*)/', $action, $reg)) { $code = $reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { - Header("Location: " . $_SERVER["PHP_SELF"]); + Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); @@ -118,49 +118,49 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is use cas of this 2 options ? print '
        ' . $langs->trans("UseAboutPage") . ''.$langs->trans("UseAboutPage").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('MODULEBUILDER_USE_ABOUT'); } else { if (empty($conf->global->MODULEBUILDER_USE_ABOUT)) { - print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { - print '' . img_picto($langs->trans("Enabled"), 'on') . ''; + print ''.img_picto($langs->trans("Enabled"), 'on').''; } } print '
        ' . $langs->trans("UseSpecificEditorName") . ''.$langs->trans("UseSpecificEditorName").''; print ''; print '
        ' . $langs->trans("UseSpecificEditorURL") . ''.$langs->trans("UseSpecificEditorURL").''; print ''; print '
        ' . $langs->trans("UseSpecificFamily") . ''.$langs->trans("UseSpecificFamily").''; print ''; print '
        ' . $langs->trans("UseSpecificAuthor") . ''.$langs->trans("UseSpecificAuthor").''; print ''; print '
        ' . $langs->trans("UseSpecificVersion") . ''.$langs->trans("UseSpecificVersion").''; print ''; print '
        ' . $langs->trans("UseSpecificReadme") . ''.$langs->trans("UseSpecificReadme").''; print ''; print '
        ' . $langs->trans("AsciiToHtmlConverter") . ''.$langs->trans("AsciiToHtmlConverter").''; print ''; print ' '.$langs->trans("Example").': asciidoc, asciidoctor'; @@ -183,7 +183,7 @@ print '
        ' . $langs->trans("AsciiToPdfConverter") . ''.$langs->trans("AsciiToPdfConverter").''; print ''; print ' '.$langs->trans("Example").': asciidoctor-pdf'; diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 3879efa2030..68eec5513a9 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -27,7 +27,7 @@ * into the dirins directory. */ -if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti SQL+XSS injection attack test +if (!defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti SQL+XSS injection attack test require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -40,54 +40,54 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "modulebuilder", "other", "cron", "errors")); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); -$module=GETPOST('module', 'alpha'); -$tab=GETPOST('tab', 'aZ09'); -$tabobj=GETPOST('tabobj', 'alpha'); -$propertykey=GETPOST('propertykey', 'alpha'); -if (empty($module)) $module='initmodule'; -if (empty($tab)) $tab='description'; -if (empty($tabobj)) $tabobj='newobjectifnoobj'; -$file=GETPOST('file', 'alpha'); +$module = GETPOST('module', 'alpha'); +$tab = GETPOST('tab', 'aZ09'); +$tabobj = GETPOST('tabobj', 'alpha'); +$propertykey = GETPOST('propertykey', 'alpha'); +if (empty($module)) $module = 'initmodule'; +if (empty($tab)) $tab = 'description'; +if (empty($tabobj)) $tabobj = 'newobjectifnoobj'; +$file = GETPOST('file', 'alpha'); -$modulename=dol_sanitizeFileName(GETPOST('modulename', 'alpha')); -$objectname=dol_sanitizeFileName(GETPOST('objectname', 'alpha')); +$modulename = dol_sanitizeFileName(GETPOST('modulename', 'alpha')); +$objectname = dol_sanitizeFileName(GETPOST('objectname', 'alpha')); // Security check if (empty($conf->modulebuilder->enabled)) accessforbidden('ModuleBuilderNotAllowed'); -if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden('ModuleBuilderNotAllowed'); +if (!$user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden('ModuleBuilderNotAllowed'); // Dir for custom dirs -$tmp=explode(',', $dolibarr_main_document_root_alt); +$tmp = explode(',', $dolibarr_main_document_root_alt); $dirins = $tmp[0]; $dirread = $dirins; $forceddirread = 0; $tmpdir = explode('@', $module); -if (! empty($tmpdir[1])) +if (!empty($tmpdir[1])) { - $module=$tmpdir[0]; - $dirread=$tmpdir[1]; - $forceddirread=1; + $module = $tmpdir[0]; + $dirread = $tmpdir[1]; + $forceddirread = 1; } if (GETPOST('dirins', 'alpha')) { $dirread = $dirins = GETPOST('dirins', 'alpha'); - $forceddirread=1; + $forceddirread = 1; } -$FILEFLAG='modulebuilder.txt'; +$FILEFLAG = 'modulebuilder.txt'; -$now=dol_now(); +$now = dol_now(); $newmask = 0; -if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; +if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; if (empty($newmask)) // This should no happen { - $newmask='0664'; + $newmask = '0664'; } @@ -97,7 +97,7 @@ if (empty($newmask)) // This should no happen if ($dirins && $action == 'initmodule' && $modulename) { - $modulename = ucfirst($modulename); // Force first letter in uppercase + $modulename = ucfirst($modulename); // Force first letter in uppercase if (preg_match('/[^a-z0-9_]/i', $modulename)) { @@ -105,12 +105,12 @@ if ($dirins && $action == 'initmodule' && $modulename) setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - if (! $error) + if (!$error) { $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $destdir = $dirins.'/'.strtolower($modulename); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename ); @@ -131,7 +131,7 @@ if ($dirins && $action == 'initmodule' && $modulename) } } - if (! empty($conf->global->MODULEBUILDER_USE_ABOUT)) + if (!empty($conf->global->MODULEBUILDER_USE_ABOUT)) { dol_delete_file($destdir.'/admin/about.php'); } @@ -182,13 +182,13 @@ if ($dirins && $action == 'initmodule' && $modulename) } // Edit PHP files - if (! $error) + if (!$error) { $listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.(php|MD|js|sql|txt|xml|lang)$', '', 'fullname', SORT_ASC, 0, 1); - foreach($listofphpfilestoedit as $phpfileval) + foreach ($listofphpfilestoedit as $phpfileval) { //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), @@ -225,10 +225,10 @@ if ($dirins && $action == 'initmodule' && $modulename) } } - if (! $error) + if (!$error) { setEventMessages('ModuleInitialized', null); - $module=$modulename; + $module = $modulename; $modulename = ''; } } @@ -366,10 +366,10 @@ if ($dirins && $action == 'inithook' && !empty($module)) if ($result > 0) { - $modulename = ucfirst($module); // Force first letter in uppercase + $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), @@ -378,7 +378,7 @@ if ($dirins && $action == 'inithook' && !empty($module)) 'Mon module'=>$modulename, 'mon module'=>$modulename, 'htdocs/modulebuilder/template'=>strtolower($modulename), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); dolReplaceInFile($destfile, $arrayreplacement); @@ -400,10 +400,10 @@ if ($dirins && $action == 'inittrigger' && !empty($module)) if ($result > 0) { - $modulename = ucfirst($module); // Force first letter in uppercase + $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), @@ -412,7 +412,7 @@ if ($dirins && $action == 'inittrigger' && !empty($module)) 'Mon module'=>$modulename, 'mon module'=>$modulename, 'htdocs/modulebuilder/template'=>strtolower($modulename), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); dolReplaceInFile($destfile, $arrayreplacement); @@ -434,10 +434,10 @@ if ($dirins && $action == 'initwidget' && !empty($module)) if ($result > 0) { - $modulename = ucfirst($module); // Force first letter in uppercase + $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), @@ -563,7 +563,7 @@ if ($dirins && $action == 'initcli' && !empty($module)) '__USER_FULLNAME__'=>$user->getFullName($langs), '__USER_EMAIL__'=>$user->email, '__YYYY-MM-DD__'=>dol_print_date($now, 'dayrfc'), - '---Put here your own copyright and developer email---'=>dol_print_date($now, 'dayrfc').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '---Put here your own copyright and developer email---'=>dol_print_date($now, 'dayrfc').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); dolReplaceInFile($destfile, $arrayreplacement); @@ -585,11 +585,11 @@ if ($dirins && $action == 'initdoc' && !empty($module)) if ($result > 0) { - $modulename = ucfirst($module); // Force first letter in uppercase + $modulename = ucfirst($module); // Force first letter in uppercase $modulelowercase = strtolower($module); //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), @@ -603,14 +603,14 @@ if ($dirins && $action == 'initdoc' && !empty($module)) '__USER_FULLNAME__'=>$user->getFullName($langs), '__USER_EMAIL__'=>$user->email, '__YYYY-MM-DD__'=>dol_print_date($now, 'dayrfc'), - '---Put here your own copyright and developer email---'=>dol_print_date($now, 'dayrfc').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '---Put here your own copyright and developer email---'=>dol_print_date($now, 'dayrfc').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); dolReplaceInFile($destfile, $arrayreplacement); // Delete old documentation files - $FILENAMEDOC=$modulelowercase.'.html'; - $FILENAMEDOCPDF=$modulelowercase.'.pdf'; + $FILENAMEDOC = $modulelowercase.'.html'; + $FILENAMEDOCPDF = $modulelowercase.'.pdf'; $outputfiledoc = dol_buildpath($modulelowercase, 0).'/doc/'.$FILENAMEDOC; $outputfiledocurl = dol_buildpath($modulelowercase, 1).'/doc/'.$FILENAMEDOC; $outputfiledocpdf = dol_buildpath($modulelowercase, 0).'/doc/'.$FILENAMEDOCPDF; @@ -628,7 +628,7 @@ if ($dirins && $action == 'initdoc' && !empty($module)) if ($dirins && $action == 'addlanguage' && !empty($module)) { - $newlangcode=GETPOST('newlangcode', 'aZ09'); + $newlangcode = GETPOST('newlangcode', 'aZ09'); $srcfile = $dirins.'/'.strtolower($module).'/langs/en_US'; $destfile = $dirins.'/'.strtolower($module).'/langs/'.$newlangcode; $result = dolCopyDir($srcfile, $destfile, 0, 0); @@ -636,7 +636,7 @@ if ($dirins && $action == 'addlanguage' && !empty($module)) if ($dirins && $action == 'confirm_removefile' && !empty($module)) { - $relativefilename=dol_sanitizePathName(GETPOST('file', 'none')); + $relativefilename = dol_sanitizePathName(GETPOST('file', 'none')); if ($relativefilename) { $dirnametodelete = dirname($relativefilename); @@ -758,7 +758,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); - $tabobj='newobject'; + $tabobj = 'newobject'; } $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; @@ -772,16 +772,16 @@ if ($dirins && $action == 'initobject' && $module && $objectname) dol_mkdir($destdir.'/sql'); // Scan dir class to find if an object with same name already exists. - if (! $error) + if (!$error) { - $dirlist=dol_dir_list($destdir.'/class', 'files', 0, '\.txt$'); - $alreadyfound=false; - foreach($dirlist as $key => $val) + $dirlist = dol_dir_list($destdir.'/class', 'files', 0, '\.txt$'); + $alreadyfound = false; + foreach ($dirlist as $key => $val) { - $filefound=preg_replace('/\.txt$/', '', $val['name']); + $filefound = preg_replace('/\.txt$/', '', $val['name']); if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) { - $alreadyfound=true; + $alreadyfound = true; $error++; setEventMessages($langs->trans("AnObjectAlreadyExistWithThisNameAndDiffCase"), null, 'errors'); break; @@ -789,7 +789,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) } } - if (! $error) + if (!$error) { // Copy some files $filetogenerate = array( @@ -830,7 +830,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) ); } - foreach($filetogenerate as $srcfile => $destfile) + foreach ($filetogenerate as $srcfile => $destfile) { $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); if ($result <= 0) @@ -960,7 +960,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) 'MYOBJECT'=>strtoupper($objectname) ); - $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); + $result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); //var_dump($result); if ($result < 0) { @@ -1023,7 +1023,7 @@ if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && } if ($nb == 0) { - $resql=$db->DDLDropTable($tabletodrop); + $resql = $db->DDLDropTable($tabletodrop); //var_dump($resql); setEventMessages($langs->trans("TableDropped", $tabletodrop), null, 'mesgs'); } @@ -1034,7 +1034,7 @@ if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && } } -if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj)) +if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) { $error = 0; @@ -1128,20 +1128,20 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) dol_mkdir($destdir); // Edit the class file to write properties - if (! $error) + if (!$error) { - $object=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, array(), $propertykey); + $object = rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, array(), $propertykey); if (is_numeric($object) && $object <= 0) $error++; } // Edit sql with new properties - if (! $error) + if (!$error) { - $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); + $result = rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); if ($result <= 0) $error++; } - if (! $error) + if (!$error) { setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); @@ -1162,9 +1162,9 @@ if ($dirins && $action == 'confirm_deletemodule') setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - if (! $error) + if (!$error) { - $modulelowercase=strtolower($module); + $modulelowercase = strtolower($module); // Dir for module $dir = $dirins.'/'.$modulelowercase; @@ -1193,10 +1193,10 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - if (! $error) + if (!$error) { - $modulelowercase=strtolower($module); - $objectlowercase=strtolower($objectname); + $modulelowercase = strtolower($module); + $objectlowercase = strtolower($objectname); // Dir for module $dir = $dirins.'/'.$modulelowercase; @@ -1248,23 +1248,23 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) if ($dirins && $action == 'generatepackage') { - $modulelowercase=strtolower($module); + $modulelowercase = strtolower($module); // Dir for module $dir = $dirins.'/'.$modulelowercase; // Zip file to build - $FILENAMEZIP=''; + $FILENAMEZIP = ''; // Load module dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); - $class='mod'.$module; + $class = 'mod'.$module; if (class_exists($class)) { try { $moduleobj = new $class($db); } - catch(Exception $e) + catch (Exception $e) { $error++; dol_print_error($e->getMessage()); @@ -1278,16 +1278,16 @@ if ($dirins && $action == 'generatepackage') exit; } - $arrayversion=explode('.', $moduleobj->version, 3); + $arrayversion = explode('.', $moduleobj->version, 3); if (count($arrayversion)) { - $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; + $FILENAMEZIP = "module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2] ? ".".$arrayversion[2] : "").".zip"; $dirofmodule = dol_buildpath($modulelowercase, 0).'/bin'; $outputfilezip = $dirofmodule.'/'.$FILENAMEZIP; if ($dirofmodule) { - if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule); + if (!dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule); $result = dol_compress_dir($dir, $outputfilezip, 'zip'); } else @@ -1316,7 +1316,7 @@ if ($dirins && $action == 'generatepackage') if ($dirins && $action == 'generatedoc') { - $FILENAMEDOC=strtolower($module).'.html'; + $FILENAMEDOC = strtolower($module).'.html'; $dirofmodule = dol_buildpath(strtolower($module), 0).'/doc'; $util = new Utils($db); @@ -1341,10 +1341,10 @@ if ($action == 'savefile' && empty($cancel)) if ($relofcustom) { // Check that relative path ($file) start with name 'custom' - if (! preg_match('/^'.$relofcustom.'/', $file)) $file=$relofcustom.'/'.$file; + if (!preg_match('/^'.$relofcustom.'/', $file)) $file = $relofcustom.'/'.$file; - $pathoffile=dol_buildpath($file, 0); - $pathoffilebackup=dol_buildpath($file.'.back', 0); + $pathoffile = dol_buildpath($file, 0); + $pathoffilebackup = dol_buildpath($file.'.back', 0); // Save old version if (dol_is_file($pathoffile)) @@ -1439,11 +1439,11 @@ $form = new Form($db); $formadmin = new FormAdmin($db); // Set dir where external modules are installed -if (! dol_is_dir($dirins)) +if (!dol_is_dir($dirins)) { dol_mkdir($dirins); } -$dirins_ok=(dol_is_dir($dirins)); +$dirins_ok = (dol_is_dir($dirins)); llxHeader('', $langs->trans("ModuleBuilder"), '', '', 0, 0, array( @@ -1566,24 +1566,24 @@ $infomodulesfound = '
        '.$form->textwithpicto( // Load module descriptor -$error=0; +$error = 0; $moduleobj = null; -if (! empty($module) && $module != 'initmodule' && $module != 'deletemodule') +if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') { - $modulelowercase=strtolower($module); + $modulelowercase = strtolower($module); // Load module $fullpathdirtodescriptor = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($fullpathdirtodescriptor); - $class='mod'.$module; + $class = 'mod'.$module; if (class_exists($class)) { try { $moduleobj = new $class($db); } - catch(Exception $e) + catch (Exception $e) { $error++; print $e->getMessage(); @@ -1602,16 +1602,16 @@ print '
        '; // Tabs for all modules $head = array(); -$h=0; +$h = 0; $head[$h][0] = $_SERVER["PHP_SELF"].'?module=initmodule'; $head[$h][1] = ''.$langs->trans("NewModule").''; $head[$h][2] = 'initmodule'; $h++; -foreach($listofmodules as $tmpmodule => $tmpmodulearray) +foreach ($listofmodules as $tmpmodule => $tmpmodulearray) { - $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulearray['modulenamewithcase'].($forceddirread?'@'.$dirread:''); + $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulearray['modulenamewithcase'].($forceddirread ? '@'.$dirread : ''); $head[$h][1] = $tmpmodulearray['modulenamewithcase']; $head[$h][2] = $tmpmodulearray['modulenamewithcase']; $h++; @@ -1623,7 +1623,7 @@ $head[$h][2] = 'deletemodule'; $h++; -dol_fiche_head($head, $module, $langs->trans("Modules"), -1, 'generic', 0, $infomodulesfound); // Modules +dol_fiche_head($head, $module, $langs->trans("Modules"), -1, 'generic', 0, $infomodulesfound); // Modules if ($module == 'initmodule') { @@ -1786,7 +1786,7 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { - dol_fiche_head($head2, $tab, '', -1, ''); // Description - level 2 + dol_fiche_head($head2, $tab, '', -1, ''); // Description - level 2 print ''.$langs->trans("ModuleBuilderDesc".$tab).''; $infoonmodulepath = ''; @@ -1817,7 +1817,7 @@ elseif (! empty($module)) print load_fiche_titre($langs->trans("DescriptorFile"), '', ''); - if (! empty($moduleobj)) + if (!empty($moduleobj)) { print '
        '; print '
        '; @@ -1906,7 +1906,7 @@ elseif (! empty($module)) } else { - $fullpathoffile=dol_buildpath($file, 0, 1); // Description - level 2 + $fullpathoffile = dol_buildpath($file, 0, 1); // Description - level 2 if ($fullpathoffile) { @@ -1923,8 +1923,8 @@ elseif (! empty($module)) dol_fiche_head($head2, $tab, '', -1, ''); - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', ''); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', ''); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); dol_fiche_end(); @@ -1939,7 +1939,7 @@ elseif (! empty($module)) } else { - dol_fiche_head($head2, $tab, '', -1, ''); // Level 2 + dol_fiche_head($head2, $tab, '', -1, ''); // Level 2 } if ($tab == 'languages') @@ -1963,7 +1963,7 @@ elseif (! empty($module)) print '
        '; print '
        '; - $langfiles=dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); + $langfiles = dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); print ''; foreach ($langfiles as $langfile) @@ -1982,7 +1982,7 @@ elseif (! empty($module)) //print $langs->trans("UseAsciiDocFormat").'
        '; - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -1994,8 +1994,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'text')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'text')); print '
        '; print '
        '; print ''; @@ -2159,27 +2159,27 @@ elseif (! empty($module)) // Scan for object class files $listofobject = dol_dir_list($dir, 'files', 0, '\.class\.php$'); - $firstobjectname=''; - foreach($listofobject as $fileobj) + $firstobjectname = ''; + foreach ($listofobject as $fileobj) { if (preg_match('/^api_/', $fileobj['name'])) continue; if (preg_match('/^actions_/', $fileobj['name'])) continue; - $tmpcontent=file_get_contents($fileobj['fullname']); + $tmpcontent = file_get_contents($fileobj['fullname']); if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) { //$objectname = preg_replace('/\.txt$/', '', $fileobj['name']); $objectname = $reg[1]; if (empty($firstobjectname)) $firstobjectname = $objectname; - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname; + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj='.$objectname; $head3[$h][1] = $objectname; $head3[$h][2] = $objectname; $h++; } } - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=deleteobject'; + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj=deleteobject'; $head3[$h][1] = $langs->trans("DangerZone"); $head3[$h][2] = 'deleteobject'; $h++; @@ -2187,11 +2187,11 @@ elseif (! empty($module)) // If tabobj was not defined, then we check if there is one obj. If yes, we force on it, if no, we will show tab to create new objects. if ($tabobj == 'newobjectifnoobj') { - if ($firstobjectname) $tabobj=$firstobjectname; + if ($firstobjectname) $tabobj = $firstobjectname; else $tabobj = 'newobject'; } - dol_fiche_head($head3, $tabobj, '', -1, ''); // Level 3 + dol_fiche_head($head3, $tabobj, '', -1, ''); // Level 3 if ($tabobj == 'newobject') { @@ -2217,7 +2217,7 @@ elseif (! empty($module)) //print ' '; print $langs->trans("InitStructureFromExistingTable"); print ''; - print ''; + print ''; print '
        '; print ''; @@ -2234,7 +2234,7 @@ elseif (! empty($module)) print $langs->trans("EnterNameOfObjectToDeleteDesc").'

        '; print ''; - print ''; + print ''; print ''; } else @@ -2434,7 +2434,7 @@ elseif (! empty($module)) print '


        '; - if(function_exists('opcache_invalidate')) opcache_invalidate($dirread.'/'.$pathtoclass, true); // remove the include cache hell ! + if (function_exists('opcache_invalidate')) opcache_invalidate($dirread.'/'.$pathtoclass, true); // remove the include cache hell ! if (empty($forceddirread)) { @@ -2449,17 +2449,17 @@ elseif (! empty($module)) try { $tmpobjet = @new $tabobj($db); } - catch(Exception $e) + catch (Exception $e) { dol_syslog('Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING); } } - if (! empty($tmpobjet)) + if (!empty($tmpobjet)) { $reflector = new ReflectionClass($tabobj); - $reflectorproperties = $reflector->getProperties(); // Can also use get_object_vars - $reflectorpropdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars + $reflectorproperties = $reflector->getProperties(); // Can also use get_object_vars + $reflectorpropdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars //$propstat = $reflector->getStaticProperties(); //var_dump($reflectorpropdefault); @@ -2467,7 +2467,7 @@ elseif (! empty($module)) print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -2511,7 +2511,7 @@ elseif (! empty($module)) //$properties = dol_sort_array($tmpobjet->fields, 'position'); $properties = dol_sort_array($reflectorpropdefault['fields'], 'position'); - if (! empty($properties)) + if (!empty($properties)) { // Line to add a property print '
        '; @@ -2538,7 +2538,7 @@ elseif (! empty($module)) print ''; print ''; - foreach($properties as $propkey => $propval) + foreach ($properties as $propkey => $propval) { /* If from Reflection if ($propval->class == $tabobj) @@ -2654,13 +2654,13 @@ elseif (! empty($module)) print ''.$langs->trans("SpecDefDesc").'
        '; print '
        '; - $specs=dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); + $specs = dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); foreach ($specs as $spec) { $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; - $format='asciidoc'; - if (preg_match('/\.md$/i', $spec['name'])) $format='markdown'; + $format = 'asciidoc'; + if (preg_match('/\.md$/i', $spec['name'])) $format = 'markdown'; print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
        '; @@ -2672,7 +2672,7 @@ elseif (! empty($module)) //print $langs->trans("UseAsciiDocFormat").'
        '; - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -2684,8 +2684,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
        '; print '
        '; print ''; @@ -2708,7 +2708,7 @@ elseif (! empty($module)) print '
        '; } } - catch(Exception $e) + catch (Exception $e) { print $e->getMessage(); } @@ -2717,11 +2717,11 @@ elseif (! empty($module)) { if (empty($forceddirread)) { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); } else { - $fullpathoffile=$dirread.'/'.$file; + $fullpathoffile = $dirread.'/'.$file; } $content = file_get_contents($fullpathoffile); @@ -2733,10 +2733,10 @@ elseif (! empty($module)) print ''; print ''; print ''; - print ''; + print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
        '; print '
        '; print ''; @@ -2748,7 +2748,7 @@ elseif (! empty($module)) } } - dol_fiche_end(); // Level 3 + dol_fiche_end(); // Level 3 } if ($tab == 'menus') @@ -2866,7 +2866,7 @@ elseif (! empty($module)) } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -2878,8 +2878,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
        '; print '
        '; print ''; @@ -2966,7 +2966,7 @@ elseif (! empty($module)) } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -2978,8 +2978,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
        '; print '
        '; print ''; @@ -3024,7 +3024,7 @@ elseif (! empty($module)) } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -3036,8 +3036,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
        '; print '
        '; print ''; @@ -3062,7 +3062,7 @@ elseif (! empty($module)) print '
        '; print '
        '.$langs->trans('Failed to init the object with the new.').'
        '; - if (! empty($triggers)) + if (!empty($triggers)) { foreach ($triggers as $trigger) { @@ -3086,7 +3086,7 @@ elseif (! empty($module)) } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -3098,8 +3098,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
        '; print '
        '; print ''; @@ -3227,7 +3227,7 @@ elseif (! empty($module)) print '
        '; print '
        '; - if (! empty($widgets)) + if (!empty($widgets)) { foreach ($widgets as $widget) { @@ -3249,7 +3249,7 @@ elseif (! empty($module)) } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -3261,8 +3261,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
        '; print '
        '; print ''; @@ -3279,20 +3279,20 @@ elseif (! empty($module)) $clifiles = array(); $i = 0; - $dircli=array('/'.strtolower($module).'/scripts'); + $dircli = array('/'.strtolower($module).'/scripts'); - foreach($dircli as $reldir) + foreach ($dircli as $reldir) { - $dir=dol_buildpath($reldir, 0); - $newdir=dol_osencode($dir); + $dir = dol_buildpath($reldir, 0); + $newdir = dol_osencode($dir); // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) - if (! is_dir($newdir)) continue; + if (!is_dir($newdir)) continue; - $handle=opendir($newdir); + $handle = opendir($newdir); if (is_resource($handle)) { - while (($tmpfile = readdir($handle))!==false) + while (($tmpfile = readdir($handle)) !== false) { if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $tmpfile, $reg)) { @@ -3313,7 +3313,7 @@ elseif (! empty($module)) print '
        '; print '
        '; - if (! empty($clifiles)) + if (!empty($clifiles)) { foreach ($clifiles as $clifile) { @@ -3335,7 +3335,7 @@ elseif (! empty($module)) } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -3347,8 +3347,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
        '; print '
        '; print ''; @@ -3407,31 +3407,31 @@ elseif (! empty($module)) print ''; print '
        '; print ''; print ''; print ''; print ''; @@ -3457,7 +3457,7 @@ elseif (! empty($module)) } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -3469,8 +3469,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
        '; print '
        '; print ''; @@ -3484,7 +3484,7 @@ elseif (! empty($module)) if ($tab == 'specifications') { - $specs=dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); + $specs = dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); if ($action != 'editfile' || empty($file)) { @@ -3492,13 +3492,13 @@ elseif (! empty($module)) print '
        '; print '
        '; - if ($cron['jobtype']=='method') + if ($cron['jobtype'] == 'method') { - $text=$langs->trans("CronClass"); - $texttoshow=$langs->trans('CronModule').': '.$module.'
        '; - $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'
        '; - $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'
        '; - $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; - $texttoshow.='
        '.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
        '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + $text = $langs->trans("CronClass"); + $texttoshow = $langs->trans('CronModule').': '.$module.'
        '; + $texttoshow .= $langs->trans('CronClass').': '.$cron['class'].'
        '; + $texttoshow .= $langs->trans('CronObject').': '.$cron['objectname'].'
        '; + $texttoshow .= $langs->trans('CronMethod').': '.$cron['method']; + $texttoshow .= '
        '.$langs->trans('CronArgs').': '.$cron['parameters']; + $texttoshow .= '
        '.$langs->trans('Comment').': '.$langs->trans($cron['comment']); } - elseif ($cron['jobtype']=='command') + elseif ($cron['jobtype'] == 'command') { - $text=$langs->trans('CronCommand'); - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); - $texttoshow.='
        '.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
        '.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + $text = $langs->trans('CronCommand'); + $texttoshow = $langs->trans('CronCommand').': '.dol_trunc($cron['command']); + $texttoshow .= '
        '.$langs->trans('CronArgs').': '.$cron['parameters']; + $texttoshow .= '
        '.$langs->trans('Comment').': '.$langs->trans($cron['comment']); } print $form->textwithpicto($text, $texttoshow, 1); print '
        '; - if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); - if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); - if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); - if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); + if ($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); + if ($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); + if ($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); + if ($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); print ''; @@ -3439,7 +3439,7 @@ elseif (! empty($module)) print ''; - if (!empty($cron['comment'])) {print $cron['comment'];} + if (!empty($cron['comment'])) {print $cron['comment']; } print '
        '; - if (is_array($specs) && ! empty($specs)) + if (is_array($specs) && !empty($specs)) { foreach ($specs as $spec) { $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; - $format='asciidoc'; - if (preg_match('/\.md$/i', $spec['name'])) $format='markdown'; + $format = 'asciidoc'; + if (preg_match('/\.md$/i', $spec['name'])) $format = 'markdown'; print ''; @@ -3521,7 +3521,7 @@ elseif (! empty($module)) //print $langs->trans("UseAsciiDocFormat").'
        '; - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -3533,8 +3533,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
        '; print '
        '; print ''; @@ -3547,16 +3547,16 @@ elseif (! empty($module)) print '


        '; - $FILENAMEDOC=$modulelowercase.'.html'; - $FILENAMEDOCPDF=$modulelowercase.'.pdf'; + $FILENAMEDOC = $modulelowercase.'.html'; + $FILENAMEDOCPDF = $modulelowercase.'.pdf'; $outputfiledoc = dol_buildpath($modulelowercase, 0).'/doc/'.$FILENAMEDOC; $outputfiledocurl = dol_buildpath($modulelowercase, 1).'/doc/'.$FILENAMEDOC; $outputfiledocpdf = dol_buildpath($modulelowercase, 0).'/doc/'.$FILENAMEDOCPDF; $outputfiledocurlpdf = dol_buildpath($modulelowercase, 1).'/doc/'.$FILENAMEDOCPDF; // HTML - print ' '. $langs->trans("PathToModuleDocumentation", "HTML") . ' : '; - if (! dol_is_file($outputfiledoc)) print ''.$langs->trans("FileNotYetGenerated").''; + print ' '.$langs->trans("PathToModuleDocumentation", "HTML").' : '; + if (!dol_is_file($outputfiledoc)) print ''.$langs->trans("FileNotYetGenerated").''; else { print ''; print ''; @@ -3568,8 +3568,8 @@ elseif (! empty($module)) print '
        '; // PDF - print ' '. $langs->trans("PathToModuleDocumentation", "PDF") . ' : '; - if (! dol_is_file($outputfiledocpdf)) print ''.$langs->trans("FileNotYetGenerated").''; + print ' '.$langs->trans("PathToModuleDocumentation", "PDF").' : '; + if (!dol_is_file($outputfiledocpdf)) print ''.$langs->trans("FileNotYetGenerated").''; else { print ''; print '
        '; @@ -3633,17 +3633,17 @@ elseif (! empty($module)) exit; } - $arrayversion=explode('.', $moduleobj->version, 3); + $arrayversion = explode('.', $moduleobj->version, 3); if (count($arrayversion)) { - $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; + $FILENAMEZIP = "module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2] ? ".".$arrayversion[2] : "").".zip"; $outputfilezip = dol_buildpath($modulelowercase, 0).'/bin/'.$FILENAMEZIP; } print '
        '; - print ' '. $langs->trans("PathToModulePackage") . ' : '; - if (! dol_is_file($outputfilezip)) print ''.$langs->trans("FileNotYetGenerated").''; + print ' '.$langs->trans("PathToModulePackage").' : '; + if (!dol_is_file($outputfilezip)) print ''.$langs->trans("FileNotYetGenerated").''; else { $relativepath = $modulelowercase.'/bin/'.$FILENAMEZIP; print '
        '.$outputfilezip.''; diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index 23729f8e0de..8f893f832bf 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -36,10 +36,10 @@ $hookmanager = new HookManager($db); $hookmanager->initHooks(array('mrpindex')); // Load translation files required by the page -$langs->loadLangs(array("companies","mrp")); +$langs->loadLangs(array("companies", "mrp")); // Security check -$result=restrictedArea($user, 'bom|mrp'); +$result = restrictedArea($user, 'bom|mrp'); /* diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 017779b74f7..264a4a7efe1 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -65,28 +65,28 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $erreur_prenom = false; $nouveauchoix = ''; - for ($i=0;$i<$nbcolonnes;$i++) + for ($i = 0; $i < $nbcolonnes; $i++) { if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { - $nouveauchoix.="1"; + $nouveauchoix .= "1"; } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { - $nouveauchoix.="2"; + $nouveauchoix .= "2"; } else { // sinon c'est 0 - $nouveauchoix.="0"; + $nouveauchoix .= "0"; } } - $nom=substr(GETPOST("nom", 'nohtml'), 0, 64); + $nom = substr(GETPOST("nom", 'nohtml'), 0, 64); // Check if vote already exists $sql = 'SELECT id_users, nom as name'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql.= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."'"; - $sql.= ' ORDER BY id_users'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; + $sql .= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."'"; + $sql .= ' ORDER BY id_users'; $resql = $db->query($sql); $num_rows = $db->num_rows($resql); if ($num_rows > 0) @@ -97,9 +97,9 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout else { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)'; - $sql.= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); + $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); } } } @@ -134,24 +134,24 @@ if ($testmodifier) //var_dump($_POST["choix$i"]); if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { - $nouveauchoix.="1"; + $nouveauchoix .= "1"; } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { - $nouveauchoix.="2"; + $nouveauchoix .= "2"; } else { // sinon c'est 0 - $nouveauchoix.="0"; + $nouveauchoix .= "0"; } } - $idtomodify=$_POST["idtomodify".$modifier]; + $idtomodify = $_POST["idtomodify".$modifier]; $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.= " SET reponses = '".$db->escape($nouveauchoix)."'"; - $sql.= " WHERE id_users = '".$db->escape($idtomodify)."'"; + $sql .= " SET reponses = '".$db->escape($nouveauchoix)."'"; + $sql .= " WHERE id_users = '".$db->escape($idtomodify)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } // Add column (not for date) @@ -160,18 +160,18 @@ if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format = // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - $nouveauxsujets=$object->sujet; + $nouveauxsujets = $object->sujet; //on rajoute la valeur a la fin de tous les sujets deja entrés - $nouveauxsujets.=','; - $nouveauxsujets.=str_replace(array(",","@"), " ", $_POST["nouvellecolonne"]).(empty($_POST["typecolonne"])?'':'@'.$_POST["typecolonne"]); + $nouveauxsujets .= ','; + $nouveauxsujets .= str_replace(array(",", "@"), " ", $_POST["nouvellecolonne"]).(empty($_POST["typecolonne"]) ? '' : '@'.$_POST["typecolonne"]); //mise a jour avec les nouveaux sujets dans la base $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " SET sujet = '".$db->escape($nouveauxsujets)."'"; - $sql.= " WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."'"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); else { header('Location: results.php?id='.$object->id_sondage); } @@ -223,10 +223,10 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") //recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau if ($nouvelledate < $datesbase[0]) { $cleinsertion = 0; - } elseif ($nouvelledate > $datesbase[$taillebase-1]) { + } elseif ($nouvelledate > $datesbase[$taillebase - 1]) { $cleinsertion = count($datesbase); } else { - $nbdatesbase=count($datesbase); + $nbdatesbase = count($datesbase); for ($i = 0; $i < $nbdatesbase; $i++) { $j = $i + 1; @@ -239,10 +239,10 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") array_splice($datesbase, $cleinsertion, 0, $nouvelledate); $cle = array_search($nouvelledate, $datesbase); $dateinsertion = ''; - $nbofdates=count($datesbase); + $nbofdates = count($datesbase); for ($i = 0; $i < $nbofdates; $i++) { - $dateinsertion.=","; - $dateinsertion.=$datesbase[$i]; + $dateinsertion .= ","; + $dateinsertion .= $datesbase[$i]; } $dateinsertion = substr("$dateinsertion", 1); @@ -251,10 +251,10 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) { $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " SET sujet = '".$db->escape($dateinsertion)."'"; - $sql.= " WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql .= " SET sujet = '".$db->escape($dateinsertion)."'"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); else { header('Location: results.php?id='.$object->id_sondage); } @@ -264,7 +264,7 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") } else { - $erreur_ajout_date="yes"; + $erreur_ajout_date = "yes"; } } @@ -276,24 +276,24 @@ for ($i = 0; $i < $nblines; $i++) // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - $compteur=0; + $compteur = 0; // Loop on each answer $compteur = 0; - $sql ="SELECT id_users, nom as name, id_sondage, reponses"; - $sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'"; - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); - $num=$db->num_rows($resql); + $sql = "SELECT id_users, nom as name, id_sondage, reponses"; + $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); + $num = $db->num_rows($resql); while ($compteur < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); - if ($compteur==$i) + if ($compteur == $i) { $sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql2.= ' WHERE id_users = '.$db->escape($obj->id_users); + $sql2 .= ' WHERE id_users = '.$db->escape($obj->id_users); $resql2 = $db->query($sql2); } @@ -323,7 +323,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) //si le sujet n'est pas celui qui a été effacé alors on concatene if ($i != $j) { - if (! empty($nouveauxsujets)) $nouveauxsujets .= ','; + if (!empty($nouveauxsujets)) $nouveauxsujets .= ','; $nouveauxsujets .= $toutsujet[$j]; } @@ -332,26 +332,26 @@ for ($i = 0; $i < $nbcolonnes; $i++) // Mise a jour des sujets dans la base $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); // Clean current answer to remove deleted columns $compteur = 0; - $sql ="SELECT id_users, nom as name, id_sondage, reponses"; - $sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql = "SELECT id_users, nom as name, id_sondage, reponses"; + $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; dol_syslog('sql='.$sql); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; } - $num=$db->num_rows($resql); + $num = $db->num_rows($resql); while ($compteur < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $newcar = ''; $ensemblereponses = $obj->reponses; @@ -359,7 +359,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) // parcours de toutes les réponses actuelles for ($j = 0; $j < $nbcolonnes; $j++) { - $car=substr($ensemblereponses, $j, 1); + $car = substr($ensemblereponses, $j, 1); //si les reponses ne concerne pas la colonne effacée, on concatene if ($i != $j) { $newcar .= $car; @@ -368,8 +368,8 @@ for ($i = 0; $i < $nbcolonnes; $i++) // mise a jour des reponses utilisateurs dans la base $sql2 = 'UPDATE '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql2.= " SET reponses = '".$db->escape($newcar)."'"; - $sql2.= " WHERE id_users = '".$db->escape($obj->id_users)."'"; + $sql2 .= " SET reponses = '".$db->escape($newcar)."'"; + $sql2 .= " WHERE id_users = '".$db->escape($obj->id_users)."'"; //print $sql2; dol_syslog('sql='.$sql2); $resql2 = $db->query($sql2); @@ -387,14 +387,14 @@ for ($i = 0; $i < $nbcolonnes; $i++) * View */ -$form=new Form($db); +$form = new Form($db); if ($object->fk_user_creat) { $userstatic = new User($db); $userstatic->fetch($object->fk_user_creat); } -$result=$object->fetch(0, $numsondage); +$result = $object->fetch(0, $numsondage); if ($result <= 0) { dol_print_error($db, $object->error); @@ -403,21 +403,21 @@ if ($result <= 0) $title = $object->titre." - ".$langs->trans('Card'); $helpurl = ''; -$arrayofjs=array(); -$arrayofcss=array('/opensurvey/css/style.css'); +$arrayofjs = array(); +$arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices -$toutsujet=explode(",", $object->sujet); -$listofanswers=array(); +$toutsujet = explode(",", $object->sujet); +$listofanswers = array(); foreach ($toutsujet as $value) { - $tmp=explode('@', $value); - $listofanswers[]=array('label'=>$tmp[0],'format'=>($tmp[1]?$tmp[1]:'checkbox')); + $tmp = explode('@', $value); + $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } -$toutsujet=str_replace("@", "
        ", $toutsujet); -$toutsujet=str_replace("°", "'", $toutsujet); +$toutsujet = str_replace("@", "
        ", $toutsujet); +$toutsujet = str_replace("°", "'", $toutsujet); print '
        '."\n"; @@ -439,15 +439,15 @@ print '
        '; print '
        '; print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').'
        '; // Type -$type=($object->format=="A")?'classic':'date'; +$type = ($object->format == "A") ? 'classic' : 'date'; print ''; +print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1); +print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate").''; // Title print ''; // Expire date print ''; // Author print ''; print ''; // Bill time -if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_BILL_TIME_SPENT)) +if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print '"; @@ -275,7 +275,7 @@ print '
        '; * Referers types */ -$listofreferent=array( +$listofreferent = array( 'propal'=>array( 'name'=>"Proposals", 'title'=>"ListProposalsAssociatedProject", @@ -327,7 +327,7 @@ $listofreferent=array( 'class'=>'SupplierProposal', 'table'=>'supplier_proposal', 'datefieldname'=>'date_valid', - 'urlnew'=>DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object + 'urlnew'=>DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'supplier_proposal', 'buttonnew'=>'AddSupplierProposal', 'testnew'=>$user->rights->supplier_proposal->creer, @@ -338,7 +338,7 @@ $listofreferent=array( 'class'=>'CommandeFournisseur', 'table'=>'commande_fournisseur', 'datefieldname'=>'date_commande', - 'urlnew'=>DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object + 'urlnew'=>DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'suppliers', 'buttonnew'=>'AddSupplierOrder', 'testnew'=>$user->rights->fournisseur->commande->creer, @@ -350,7 +350,7 @@ $listofreferent=array( 'margin'=>'minus', 'table'=>'facture_fourn', 'datefieldname'=>'datef', - 'urlnew'=>DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object + 'urlnew'=>DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'suppliers', 'buttonnew'=>'AddSupplierInvoice', 'testnew'=>$user->rights->fournisseur->facture->creer, @@ -475,7 +475,7 @@ $listofreferent=array( 'table'=>'stock_mouvement', 'datefieldname'=>'datem', 'disableamount'=>0, - 'test'=>($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))), + 'test'=>($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))), 'salaries'=>array( 'name'=>"Salaries", 'title'=>"ListSalariesAssociatedProject", @@ -552,9 +552,9 @@ $elementuser = new User($db); -$showdatefilter=0; +$showdatefilter = 0; // Show the filter on date on top of element list -if (! $showdatefilter) +if (!$showdatefilter) { print '
        '; print ''; @@ -658,18 +658,18 @@ foreach ($listofreferent as $key => $value) $total_ht_by_line = price2num($tmp['amount'], 'MT'); } } - else $total_ht_by_line=$element->total_ht; + else $total_ht_by_line = $element->total_ht; // Define $total_ttc_by_line - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ttc_by_line=$element->amount; - elseif ($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount(); - elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty); + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ttc_by_line = $element->amount; + elseif ($tablename == 'fichinter') $total_ttc_by_line = $element->getAmount(); + elseif ($tablename == 'stock_mouvement') $total_ttc_by_line = $element->price * abs($element->qty); elseif ($tablename == 'projet_task') { $defaultvat = get_default_tva($mysoc, $mysoc); $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); } - else $total_ttc_by_line=$element->total_ttc; + else $total_ttc_by_line = $element->total_ttc; // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases if ($tablename == 'payment_various') @@ -690,8 +690,8 @@ foreach ($listofreferent as $key => $value) } // Each element with at least one line is output - $qualifiedforfinalprofit=true; - if ($key == 'intervention' && empty($conf->global->PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT)) $qualifiedforfinalprofit=false; + $qualifiedforfinalprofit = true; + if ($key == 'intervention' && empty($conf->global->PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT)) $qualifiedforfinalprofit = false; //var_dump($key); // Calculate margin @@ -714,12 +714,12 @@ foreach ($listofreferent as $key => $value) print '
        '; // Amount HT print ''; // Amount TTC print ''; print ''; @@ -744,16 +744,16 @@ print '
        '; // Detail foreach ($listofreferent as $key => $value) { - $title=$value['title']; - $classname=$value['class']; - $tablename=$value['table']; - $datefieldname=$value['datefieldname']; - $qualified=$value['test']; - $langtoload=$value['lang']; - $urlnew=$value['urlnew']; - $buttonnew=$value['buttonnew']; - $testnew=$value['testnew']; - $project_field=$value['project_field']; + $title = $value['title']; + $classname = $value['class']; + $tablename = $value['table']; + $datefieldname = $value['datefieldname']; + $qualified = $value['test']; + $langtoload = $value['lang']; + $urlnew = $value['urlnew']; + $buttonnew = $value['buttonnew']; + $testnew = $value['testnew']; + $project_field = $value['project_field']; $exclude_select_element = array('payment_various'); if (!empty($value['exclude_select_element'])) $exclude_select_element[] = $value['exclude_select_element']; @@ -821,17 +821,17 @@ foreach ($listofreferent as $key => $value) // Remove link column print '
        '; // Ref - print ''.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; // Date - print ''; + print ''; if (in_array($tablename, array('projet_task'))) print $langs->trans("TimeSpent"); - if (! in_array($tablename, array('projet_task'))) print $langs->trans("Date"); + if (!in_array($tablename, array('projet_task'))) print $langs->trans("Date"); print ''; // Thirdparty or user print ''; // Amount HT @@ -848,8 +848,8 @@ foreach ($listofreferent as $key => $value) else print ''; print ''; - $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field)?$project_field:'fk_projet'); - if (is_array($elementarray) && count($elementarray)>0) + $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field : 'fk_projet'); + if (is_array($elementarray) && count($elementarray) > 0) { $total_ht = 0; $total_ttc = 0; @@ -866,12 +866,12 @@ foreach ($listofreferent as $key => $value) $elementarray = sortElementsByClientName($elementarray); } - $num=count($elementarray); + $num = count($elementarray); for ($i = 0; $i < $num; $i++) { - $tmp=explode('_', $elementarray[$i]); - $idofelement=$tmp[0]; - $idofelementuser=$tmp[1]; + $tmp = explode('_', $elementarray[$i]); + $idofelement = $tmp[0]; + $idofelementuser = $tmp[1]; $element->fetch($idofelement); if ($idofelementuser) $elementuser->fetch($idofelementuser); @@ -879,11 +879,11 @@ foreach ($listofreferent as $key => $value) // Special cases if ($tablename != 'expensereport_det') { - if(method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); + if (method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); } else { - $expensereport=new ExpenseReport($db); + $expensereport = new ExpenseReport($db); $expensereport->fetch($element->fk_expensereport); } @@ -896,15 +896,15 @@ foreach ($listofreferent as $key => $value) $saved_third_id = $element->thirdparty->id; $breakline = ''; - $total_ht_by_third=0; - $total_ttc_by_third=0; + $total_ht_by_third = 0; + $total_ttc_by_third = 0; } $saved_third_id = $element->thirdparty->id; - $qualifiedfortotal=true; + $qualifiedfortotal = true; if ($key == 'invoice') { - if (! empty($element->close_code) && $element->close_code == 'replaced') $qualifiedfortotal=false; // Replacement invoice, do not include into total + if (!empty($element->close_code) && $element->close_code == 'replaced') $qualifiedfortotal = false; // Replacement invoice, do not include into total } print ''; @@ -939,15 +939,15 @@ foreach ($listofreferent as $key => $value) else print $element->getNomUrl(1); $element_doc = $element->element; - $filename=dol_sanitizeFileName($element->ref); - $filedir=$conf->{$element_doc}->multidir_output[$element->entity] . '/' . dol_sanitizeFileName($element->ref); + $filename = dol_sanitizeFileName($element->ref); + $filedir = $conf->{$element_doc}->multidir_output[$element->entity].'/'.dol_sanitizeFileName($element->ref); if ($element_doc === 'order_supplier') { - $element_doc='commande_fournisseur'; + $element_doc = 'commande_fournisseur'; $filedir = $conf->fournisseur->commande->multidir_output[$element->entity].'/'.dol_sanitizeFileName($element->ref); } elseif ($element_doc === 'invoice_supplier') { - $element_doc='facture_fournisseur'; + $element_doc = 'facture_fournisseur'; $filename = get_exdir($element->id, 2, 0, 0, $element, 'product').dol_sanitizeFileName($element->ref); $filedir = $conf->fournisseur->facture->multidir_output[$element->entity].'/'.get_exdir($element->id, 2, 0, 0, $element, 'invoice_supplier').dol_sanitizeFileName($element->ref); } @@ -955,34 +955,34 @@ foreach ($listofreferent as $key => $value) print '
        '.$formfile->getDocumentsLink($element_doc, $filename, $filedir).'
        '; // Show supplier ref - if (! empty($element->ref_supplier)) print ' - '.$element->ref_supplier; + if (!empty($element->ref_supplier)) print ' - '.$element->ref_supplier; // Show customer ref - if (! empty($element->ref_customer)) print ' - '.$element->ref_customer; + if (!empty($element->ref_customer)) print ' - '.$element->ref_customer; } print "\n"; // Date or TimeSpent - $date=''; $total_time_by_line = null; - if ($tablename == 'expensereport_det') $date = $element->date; // No draft status on lines + $date = ''; $total_time_by_line = null; + if ($tablename == 'expensereport_det') $date = $element->date; // No draft status on lines elseif ($tablename == 'stock_mouvement') $date = $element->datem; elseif ($tablename == 'payment_salary') $date = $element->datev; elseif ($tablename == 'payment_various') $date = $element->datev; elseif ($tablename == 'chargesociales') $date = $element->date_ech; - elseif (! empty($element->status) || ! empty($element->statut) || ! empty($element->fk_status)) + elseif (!empty($element->status) || !empty($element->statut) || !empty($element->fk_status)) { if ($tablename == 'don') $date = $element->datedon; if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') { - $date=($element->date_commande?$element->date_commande:$element->date_valid); + $date = ($element->date_commande ? $element->date_commande : $element->date_valid); } - elseif ($tablename == 'supplier_proposal') $date=$element->date_validation; // There is no other date for this - elseif ($tablename == 'fichinter') $date=$element->datev; // There is no other date for this - elseif ($tablename == 'projet_task') $date=''; // We show no date. Showing date of beginning of task make user think it is date of time consumed + elseif ($tablename == 'supplier_proposal') $date = $element->date_validation; // There is no other date for this + elseif ($tablename == 'fichinter') $date = $element->datev; // There is no other date for this + elseif ($tablename == 'projet_task') $date = ''; // We show no date. Showing date of beginning of task make user think it is date of time consumed else { - $date=$element->date; // invoice, ... - if (empty($date)) $date=$element->date_contrat; - if (empty($date)) $date=$element->datev; + $date = $element->date; // invoice, ... + if (empty($date)) $date = $element->date_contrat; + if (empty($date)) $date = $element->datev; } } print '
        '; // Amount without tax - $warning=''; + $warning = ''; if (empty($value['disableamount'])) { - $total_ht_by_line=null; - $othermessage=''; - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ht_by_line=$element->amount; - elseif($tablename == 'fichinter') $total_ht_by_line=$element->getAmount(); - elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty); + $total_ht_by_line = null; + $othermessage = ''; + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ht_by_line = $element->amount; + elseif ($tablename == 'fichinter') $total_ht_by_line = $element->getAmount(); + elseif ($tablename == 'stock_mouvement') $total_ht_by_line = $element->price * abs($element->qty); elseif (in_array($tablename, array('projet_task'))) { - if (! empty($conf->salaries->enabled)) + if (!empty($conf->salaries->enabled)) { // TODO Permission to read daily rate to show value $total_ht_by_line = price2num($tmpprojtime['amount'], 'MT'); if ($tmpprojtime['nblinesnull'] > 0) { $langs->load("errors"); - $warning=$langs->trans("WarningSomeLinesWithNullHourlyRate", $conf->currency); + $warning = $langs->trans("WarningSomeLinesWithNullHourlyRate", $conf->currency); } } else { - $othermessage=$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); + $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } else { - $total_ht_by_line=$element->total_ht; + $total_ht_by_line = $element->total_ht; } // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases @@ -1088,13 +1088,13 @@ foreach ($listofreferent as $key => $value) // Amount inc tax if (empty($value['disableamount'])) { - $total_ttc_by_line=null; - if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ttc_by_line=$element->amount; - elseif($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount(); - elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty); + $total_ttc_by_line = null; + if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ttc_by_line = $element->amount; + elseif ($tablename == 'fichinter') $total_ttc_by_line = $element->getAmount(); + elseif ($tablename == 'stock_mouvement') $total_ttc_by_line = $element->price * abs($element->qty); elseif ($tablename == 'projet_task') { - if (! empty($conf->salaries->enabled)) + if (!empty($conf->salaries->enabled)) { // TODO Permission to read daily rate $defaultvat = get_default_tva($mysoc, $mysoc); @@ -1102,12 +1102,12 @@ foreach ($listofreferent as $key => $value) } else { - $othermessage=$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); + $othermessage = $form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } else { - $total_ttc_by_line=$element->total_ttc; + $total_ttc_by_line = $element->total_ttc; } // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases @@ -1175,19 +1175,19 @@ foreach ($listofreferent as $key => $value) if (canApplySubtotalOn($tablename)) { - $breakline=''; - $breakline.=''; - $breakline.=''; - $breakline.=''; - $breakline.=''; - $breakline.=''; - $breakline.=''; - $breakline.=''; + $breakline = ''; + $breakline .= ''; + $breakline .= ''; + $breakline .= ''; + $breakline .= ''; + $breakline .= ''; + $breakline .= ''; + $breakline .= ''; } //var_dump($element->thirdparty->name.' - '.$saved_third_id.' - '.$element->thirdparty->id); @@ -1196,8 +1196,8 @@ foreach ($listofreferent as $key => $value) if ($breakline) print $breakline; // Total - $colspan=4; - if (in_array($tablename, array('projet_task'))) $colspan=2; + $colspan = 4; + if (in_array($tablename, array('projet_task'))) $colspan = 2; print ''; if (in_array($tablename, array('projet_task'))) { @@ -1212,7 +1212,7 @@ foreach ($listofreferent as $key => $value) print ''; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''; @@ -1220,7 +1220,7 @@ foreach ($listofreferent as $key => $value) print ''; print ''; @@ -1228,7 +1228,7 @@ foreach ($listofreferent as $key => $value) } else { - if (! is_array($elementarray)) // error + if (!is_array($elementarray)) // error { print $elementarray; } @@ -1241,9 +1241,9 @@ foreach ($listofreferent as $key => $value) // Enhance with select2 if ($conf->use_javascript_ajax) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox('.elementselect'); - $out.=$comboenhancement; + $out .= $comboenhancement; print $comboenhancement; } @@ -1293,7 +1293,7 @@ function sortElementsByClientName($elementarray) } //var_dump($clientname); - asort($clientname); // sort on name + asort($clientname); // sort on name $elementarray = array(); foreach ($clientname as $id => $name) diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 725d99fb673..80bd0252916 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -32,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -$id=GETPOST('id', 'intcomma'); -$ref=GETPOST('ref', 'alpha'); +$id = GETPOST('id', 'intcomma'); +$ref = GETPOST('ref', 'alpha'); $mode = GETPOST('mode', 'alpha'); $mine = ($mode == 'mine' ? 1 : 0); @@ -64,43 +64,43 @@ $langs->loadlangs(array('users', 'projects')); * View */ -$form=new Form($db); -$formother=new FormOther($db); -$userstatic=new User($db); -$companystatic=new Societe($db); -$contactstatic=new Contact($db); +$form = new Form($db); +$formother = new FormOther($db); +$userstatic = new User($db); +$companystatic = new Societe($db); +$contactstatic = new Contact($db); $task = new Task($db); -$arrayofcss=array('/includes/jsgantt/jsgantt.css'); +$arrayofcss = array('/includes/jsgantt/jsgantt.css'); -if (! empty($conf->use_javascript_ajax)) +if (!empty($conf->use_javascript_ajax)) { - $arrayofjs=array( + $arrayofjs = array( '/includes/jsgantt/jsgantt.js', '/projet/jsgantt_language.js.php?lang='.$langs->defaultlang ); } //$title=$langs->trans("Gantt").($object->ref?' - '.$object->ref.' '.$object->name:''); -$title=$langs->trans("Gantt"); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=($object->ref?$object->ref.' '.$object->name.' - ':'').$langs->trans("Gantt"); -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$title = $langs->trans("Gantt"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = ($object->ref ? $object->ref.' '.$object->name.' - ' : '').$langs->trans("Gantt"); +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss); -if (($id > 0 && is_numeric($id)) || ! empty($ref)) +if (($id > 0 && is_numeric($id)) || !empty($ref)) { // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); - $userWrite = $object->restrictedProjectArea($user, 'write'); + $userWrite = $object->restrictedProjectArea($user, 'write'); //$userDelete = $object->restrictedProjectArea($user,'delete'); //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; - $tab='tasks'; + $tab = 'tasks'; - $head=project_prepare_head($object); - dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); + $head = project_prepare_head($object); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); - $param=($mode=='mine'?'&mode=mine':''); + $param = ($mode == 'mine' ? '&mode=mine' : ''); @@ -108,21 +108,21 @@ if (($id > 0 && is_numeric($id)) || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
        '; + $morehtmlref = '
        '; // Title - $morehtmlref.=$object->title; + $morehtmlref .= $object->title; // Thirdparty if ($object->thirdparty->id > 0) { - $morehtmlref.='
        '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= '
        '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; // Define a complementary filter for search of next/prev ref. - if (! $user->rights->projet->all->lire) + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")"; + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -171,10 +171,10 @@ if (($id > 0 && is_numeric($id)) || ! empty($ref)) // Date start - end print '
        '; @@ -185,7 +185,7 @@ if (($id > 0 && is_numeric($id)) || ! empty($ref)) // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
        '.$langs->trans("Type").''; -print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'), 1), 'width="16"', 1); -print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate").'
        '; -$adresseadmin=$object->mail_admin; -print $langs->trans("Title") .''; +$adresseadmin = $object->mail_admin; +print $langs->trans("Title").''; if ($action == 'edit') { print ''; @@ -457,13 +457,13 @@ print '
        '.$langs->trans('ExpireDate').''; -if ($action == 'edit') print $form->selectDate($expiredate?$expiredate:$object->date_fin, 'expire', 0, 0, 0, '', 1, 0); +if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); else print dol_print_date($object->date_fin, 'day'); print '
        '; -print $langs->trans("Author") .''; +print $langs->trans("Author").''; if ($object->fk_user_creat) { print $userstatic->getLoginUrl(1); } else { @@ -475,12 +475,12 @@ print '
        '.img_picto('', 'globe').' '.$langs->trans("UrlForSurvey", '').''; // Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current -$url=$urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage; -$urllink=''; +$url = $urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage; +$urllink = ''; print $urllink; if ($action != 'edit') { @@ -505,7 +505,7 @@ print ''."\n"; print ''; @@ -523,11 +523,11 @@ if (GETPOST('ajoutsujet')) print "

        "."\n"; // Add new column - if ($object->format=="A") + if ($object->format == "A") { - print $langs->trans("AddNewColumn") .':

        '; + print $langs->trans("AddNewColumn").':

        '; print $langs->trans("Title").'
        '; - $tmparray=array('checkbox'=>$langs->trans("CheckBox"),'yesno'=>$langs->trans("YesNoList"),'foragainst'=>$langs->trans("PourContreList")); + $tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList")); print $langs->trans("Type").' '.$form->selectarray("typecolonne", $tmparray, GETPOST('typecolonne')).'

        '; print ''; print '     '; @@ -538,12 +538,12 @@ if (GETPOST('ajoutsujet')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - $formother=new FormOther($db); + $formother = new FormOther($db); //ajout d'une date avec creneau horaire - print $langs->trans("AddADate") .':

        '."\n"; + print $langs->trans("AddADate").':

        '."\n"; print ''."\n"; @@ -554,7 +554,7 @@ if (GETPOST('ajoutsujet')) print $formother->select_year('', 'nouvelleannee', 1, 0, 5, 0, 1); - print '

        '. $langs->trans("AddStartHour") .':

        '."\n"; + print '

        '.$langs->trans("AddStartHour").':

        '."\n"; print ''."\n"; - print '

        '. $langs->trans("AddEndHour") .':

        '."\n"; + print '

        '.$langs->trans("AddEndHour").':

        '."\n"; print ''."\n"; //reformatage des données des sujets du sondage -$toutsujet=explode(",", $object->sujet); -$toutsujet=str_replace("°", "'", $toutsujet); +$toutsujet = explode(",", $object->sujet); +$toutsujet = str_replace("°", "'", $toutsujet); print ''."\n"; print ''."\n"; @@ -628,7 +628,7 @@ print ''."\n"; // Show choice titles -if ($object->format=="D") +if ($object->format == "D") { //affichage des sujets du sondage print ''."\n"; @@ -636,9 +636,9 @@ if ($object->format=="D") print ''."\n"; //affichage des années - $colspan=1; - $nbofsujet=count($toutsujet); - for ($i=0;$i<$nbofsujet;$i++) + $colspan = 1; + $nbofsujet = count($toutsujet); + for ($i = 0; $i < $nbofsujet; $i++) { $current = $toutsujet[$i]; @@ -646,24 +646,24 @@ if ($object->format=="D") $current = substr($toutsujet[$i], 0, strpos($toutsujet[$i], '@')); } - if (isset($toutsujet[$i+1]) && strpos($toutsujet[$i+1], '@') !== false) { - $next = substr($toutsujet[$i+1], 0, strpos($toutsujet[$i+1], '@')); - } elseif (isset($toutsujet[$i+1])) { - $next = $toutsujet[$i+1]; + if (isset($toutsujet[$i + 1]) && strpos($toutsujet[$i + 1], '@') !== false) { + $next = substr($toutsujet[$i + 1], 0, strpos($toutsujet[$i + 1], '@')); + } elseif (isset($toutsujet[$i + 1])) { + $next = $toutsujet[$i + 1]; } $currenty = 0; - if ($current) $currenty=strftime("%Y", $current); + if ($current) $currenty = strftime("%Y", $current); $next = 0; - if ($next) $nexty=strftime("%Y", $next); - if (isset($toutsujet[$i+1]) && ($currenty == $nexty)) + if ($next) $nexty = strftime("%Y", $next); + if (isset($toutsujet[$i + 1]) && ($currenty == $nexty)) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -680,20 +680,20 @@ if ($object->format=="D") //affichage des mois $colspan = 1; for ($i = 0; $i < $nbofsujet; $i++) { - $cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime() + $cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime() - if (isset($toutsujet[$i+1]) === false) { + if (isset($toutsujet[$i + 1]) === false) { $next = false; } else { - $next = intval($toutsujet[$i+1]); + $next = intval($toutsujet[$i + 1]); } - if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")){ + if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -710,17 +710,17 @@ if ($object->format=="D") $colspan = 1; for ($i = 0; $i < $nbofsujet; $i++) { $cur = intval($toutsujet[$i]); - if (isset($toutsujet[$i+1]) === false) { + if (isset($toutsujet[$i + 1]) === false) { $next = false; } else { - $next = intval($toutsujet[$i+1]); + $next = intval($toutsujet[$i + 1]); } if ($next && dol_print_date($cur, "%a %e") == dol_print_date($next, "%a %e") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -736,7 +736,7 @@ if ($object->format=="D") print ''."\n"; for ($i = 0; isset($toutsujet[$i]); $i++) { - $heures=explode('@', $toutsujet[$i]); + $heures = explode('@', $toutsujet[$i]); if (isset($heures[1])) { print ''."\n"; } else { @@ -760,7 +760,7 @@ else for ($i = 0; isset($toutsujet[$i]); $i++) { - $tmp=explode('@', $toutsujet[$i]); + $tmp = explode('@', $toutsujet[$i]); print ''."\n"; } @@ -773,20 +773,20 @@ else $sumfor = array(); $sumagainst = array(); $compteur = 0; -$sql ="SELECT id_users, nom as name, id_sondage, reponses"; -$sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; -$sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'"; +$sql = "SELECT id_users, nom as name, id_sondage, reponses"; +$sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; +$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; dol_syslog('sql='.$sql); -$resql=$db->query($sql); -if (! $resql) +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); exit; } -$num=$db->num_rows($resql); +$num = $db->num_rows($resql); while ($compteur < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $ensemblereponses = $obj->reponses; @@ -800,40 +800,40 @@ while ($compteur < $num) print ''."\n"; // si la ligne n'est pas a changer, on affiche les données - if (! $testligneamodifier) + if (!$testligneamodifier) { for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); //print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz'; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { if (((string) $car) == "1") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } @@ -848,20 +848,20 @@ while ($compteur < $num) { $car = substr($ensemblereponses, $i, 1); print ''."\n"; @@ -872,33 +872,33 @@ while ($compteur < $num) for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { if (((string) $car) == "1") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } @@ -943,23 +943,23 @@ if (empty($testligneamodifier)) for ($i = 0; $i < $nbcolonnes; $i++) { print ''."\n"; @@ -971,10 +971,10 @@ if (empty($testligneamodifier)) } // Select value of best choice (for checkbox columns only) -$nbofcheckbox=0; -for ($i=0; $i < $nbcolonnes + 1; $i++) +$nbofcheckbox = 0; +for ($i = 0; $i < $nbcolonnes + 1; $i++) { - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) $nbofcheckbox++; if (isset($sumfor[$i])) { @@ -993,18 +993,18 @@ for ($i=0; $i < $nbcolonnes + 1; $i++) // Show line total print ''."\n"; print ''."\n"; -print ''."\n"; +print ''."\n"; for ($i = 0; $i < $nbcolonnes; $i++) { - $showsumfor = isset($sumfor[$i])?$sumfor[$i]:''; - $showsumagainst = isset($sumagainst[$i])?$sumagainst[$i]:''; + $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] : ''; + $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] : ''; if (empty($showsumfor)) $showsumfor = 0; if (empty($showsumagainst)) $showsumagainst = 0; print ''."\n"; } print ''; @@ -1015,7 +1015,7 @@ if ($nbofcheckbox >= 2) print ''."\n"; print ''."\n"; for ($i = 0; $i < $nbcolonnes; $i++) { - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) { print ''."\n"; } else { @@ -1043,7 +1043,7 @@ print '
        '; if ($current) print strftime("%Y", $current); print ''.dol_print_date($cur, "%B").''.dol_print_date($cur, "%a %e").''.dol_htmlentities($heures[1]).''.dol_htmlentities($tmp[0]).''.dol_htmlentities($obj->name).'OKKO'.$langs->trans("Yes").''.$langs->trans("No").' '.$langs->trans("For").''.$langs->trans("Against").' '; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print ''; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice, $car); } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("Against"),'1'=>$langs->trans("For")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice, $car); } print 'OKKO'.$langs->trans("For").''.$langs->trans("Against").' '.$langs->trans("For").''.$langs->trans("Against").' '; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print ''; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice); } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("Against"),'1'=>$langs->trans("For")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice); } print '
        '. $langs->trans("Total") .''.$langs->trans("Total").''; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) print $showsumfor; - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'
        '.$langs->trans("No").': '.$showsumagainst; - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'
        '.$langs->trans("Against").': '.$showsumagainst; + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) print $showsumfor; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'
        '.$langs->trans("No").': '.$showsumagainst; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'
        '.$langs->trans("Against").': '.$showsumagainst; print '
        '."\n"; print ''."\n"; -$toutsujet = explode(",", $object->sujet); // With old versions, this field was not set +$toutsujet = explode(",", $object->sujet); // With old versions, this field was not set $compteursujet = 0; $meilleursujet = ''; @@ -1051,21 +1051,21 @@ for ($i = 0; $i < $nbcolonnes; $i++) { if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) { - $meilleursujet.=", "; + $meilleursujet .= ", "; if ($object->format == "D") { $meilleursujetexport = $toutsujet[$i]; //var_dump($toutsujet); if (strpos($toutsujet[$i], '@') !== false) { $toutsujetdate = explode("@", $toutsujet[$i]); - $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext'). ($toutsujetdate[0] ? ' ('.dol_print_date($toutsujetdate[0], '%A').')' : '') . ' - ' . $toutsujetdate[1]; + $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext').($toutsujetdate[0] ? ' ('.dol_print_date($toutsujetdate[0], '%A').')' : '').' - '.$toutsujetdate[1]; } else { - $meilleursujet .= dol_print_date($toutsujet[$i], 'daytext'). ($toutsujet[$i] ? ' ('.dol_print_date($toutsujet[$i], '%A').')' : ''); + $meilleursujet .= dol_print_date($toutsujet[$i], 'daytext').($toutsujet[$i] ? ' ('.dol_print_date($toutsujet[$i], '%A').')' : ''); } } else { - $tmps=explode('@', $toutsujet[$i]); + $tmps = explode('@', $toutsujet[$i]); $meilleursujet .= dol_htmlentities($tmps[0]); } @@ -1082,9 +1082,9 @@ if ($nbofcheckbox >= 2) print '

        '."\n"; if (isset($meilleurecolonne) && $compteursujet == "1") { - print " " . $langs->trans('TheBestChoice') . ": ".$meilleursujet." " . $langs->trans("with") . " ".$meilleurecolonne." " . $vote_str . ".\n"; + print " ".$langs->trans('TheBestChoice').": ".$meilleursujet." ".$langs->trans("with")." ".$meilleurecolonne." ".$vote_str.".\n"; } elseif (isset($meilleurecolonne)) { - print " " . $langs->trans('TheBestChoices') . ": ".$meilleursujet." " . $langs->trans("with") . " ".$meilleurecolonne." " . $vote_str . ".\n"; + print " ".$langs->trans('TheBestChoices').": ".$meilleursujet." ".$langs->trans("with")." ".$meilleurecolonne." ".$vote_str.".\n"; } print '


        '."\n"; } diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index c6585f5e590..33eec8c5375 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -61,8 +61,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='a.datep,a.id'; -if (! $sortorder) $sortorder='DESC,DESC'; +if (!$sortfield) $sortfield = 'a.datep,a.id'; +if (!$sortorder) $sortorder = 'DESC,DESC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendathirdparty')); @@ -72,14 +72,14 @@ $hookmanager->initHooks(array('agendathirdparty')); * Actions */ -$parameters=array('id'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id); +$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)) { // Cancel - if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -88,8 +88,8 @@ if (empty($reshook)) // 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 { - $actioncode=''; - $search_agenda_label=''; + $actioncode = ''; + $search_agenda_label = ''; } } @@ -151,16 +151,16 @@ if ($id > 0 || $ref) // Actions buttons - $objproduct=$object; - $objcon=new stdClass(); + $objproduct = $object; + $objcon = new stdClass(); - $out=''; - $permok=$user->rights->agenda->myactions->create; - if ((! empty($objproduct->id) || ! empty($objcon->id)) && $permok) + $out = ''; + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objproduct->id) || !empty($objcon->id)) && $permok) { //$out.='trans("AddAnAction"),'filenew'); //$out.=""; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5f290900de8..745b4be9c4b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -76,7 +76,7 @@ class Product extends CommonObject */ protected $table_ref_field = 'ref'; - public $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into images.lib.php + public $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into images.lib.php /* * @deprecated @@ -116,7 +116,7 @@ class Product extends CommonObject * * @var float */ - public $price; // Price net + public $price; // Price net /** * Price with tax @@ -146,19 +146,19 @@ class Product extends CommonObject public $price_base_type; //! Arrays for multiprices - public $multiprices=array(); - public $multiprices_ttc=array(); - public $multiprices_base_type=array(); - public $multiprices_min=array(); - public $multiprices_min_ttc=array(); - public $multiprices_tva_tx=array(); - public $multiprices_recuperableonly=array(); + public $multiprices = array(); + public $multiprices_ttc = array(); + public $multiprices_base_type = array(); + public $multiprices_min = array(); + public $multiprices_min_ttc = array(); + public $multiprices_tva_tx = array(); + public $multiprices_recuperableonly = array(); //! Price by quantity arrays public $price_by_qty; - public $prices_by_qty=array(); - public $prices_by_qty_id=array(); - public $prices_by_qty_list=array(); + public $prices_by_qty = array(); + public $prices_by_qty_id = array(); + public $prices_by_qty_list = array(); //! Default VAT code for product (link to code into llx_c_tva but without foreign keys) public $default_vat_code; @@ -167,7 +167,7 @@ class Product extends CommonObject public $tva_tx; //! French VAT NPR (0 or 1) - public $tva_npr=0; + public $tva_npr = 0; //! Other local taxes public $localtax1_tx; @@ -204,12 +204,12 @@ class Product extends CommonObject * * @var int */ - public $seuil_stock_alerte=0; + public $seuil_stock_alerte = 0; /** * Ask for replenishment when $desiredstock < $stock_reel */ - public $desiredstock=0; + public $desiredstock = 0; /* * Service expiration @@ -226,14 +226,14 @@ class Product extends CommonObject * * @var int */ - public $status=0; + public $status = 0; /** * Status indicate whether the product is available for purchase '1' or not '0' * * @var int */ - public $status_buy=0; + public $status_buy = 0; /** * Status indicates whether the product is a finished product '1' or a raw material '0' @@ -247,7 +247,7 @@ class Product extends CommonObject * * @var int */ - public $status_batch=0; + public $status_batch = 0; /** * Customs code @@ -311,15 +311,15 @@ class Product extends CommonObject * * @var array */ - public $barcodes_extra=array(); + public $barcodes_extra = array(); - public $stats_propale=array(); - public $stats_commande=array(); - public $stats_contrat=array(); - public $stats_facture=array(); - public $stats_commande_fournisseur=array(); + public $stats_propale = array(); + public $stats_commande = array(); + public $stats_contrat = array(); + public $stats_facture = array(); + public $stats_commande_fournisseur = array(); - public $multilangs=array(); + public $multilangs = array(); //! Size of image public $imgWidth; @@ -341,10 +341,10 @@ class Product extends CommonObject //! Product ID already linked to a reference supplier public $product_id_already_linked; - public $nbphoto=0; + public $nbphoto = 0; //! Contains detail of stock of product into each warehouse - public $stock_warehouse=array(); + public $stock_warehouse = array(); public $oldcopy; @@ -511,10 +511,10 @@ class Product extends CommonObject $this->status_buy = 0; } - $price_ht=0; - $price_ttc=0; - $price_min_ht=0; - $price_min_ttc=0; + $price_ht = 0; + $price_ttc = 0; + $price_min_ht = 0; + $price_min_ttc = 0; // if ($this->price_base_type == 'TTC' && $this->price_ttc > 0) { @@ -541,44 +541,44 @@ class Product extends CommonObject } $this->accountancy_code_buy = trim($this->accountancy_code_buy); - $this->accountancy_code_sell= trim($this->accountancy_code_sell); - $this->accountancy_code_sell_intra= trim($this->accountancy_code_sell_intra); - $this->accountancy_code_sell_export= trim($this->accountancy_code_sell_export); + $this->accountancy_code_sell = trim($this->accountancy_code_sell); + $this->accountancy_code_sell_intra = trim($this->accountancy_code_sell_intra); + $this->accountancy_code_sell_export = trim($this->accountancy_code_sell_export); // Barcode value - $this->barcode=trim($this->barcode); + $this->barcode = trim($this->barcode); // Check parameters if (empty($this->label)) { - $this->error='ErrorMandatoryParametersNotProvided'; + $this->error = 'ErrorMandatoryParametersNotProvided'; return -1; } if (empty($this->ref)) { // Load object modCodeProduct - $module=(! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON)?$conf->global->PRODUCT_CODEPRODUCT_ADDON:'mod_codeproduct_leopard'); + $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard'); if ($module != 'mod_codeproduct_leopard') // Do not load module file for leopard { if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module)-4); + $module = substr($module, 0, dol_strlen($module) - 4); } dol_include_once('/core/modules/product/'.$module.'.php'); $modCodeProduct = new $module; - if (! empty($modCodeProduct->code_auto)) { + if (!empty($modCodeProduct->code_auto)) { $this->ref = $modCodeProduct->getNextValue($this, $this->type); } unset($modCodeProduct); } if (empty($this->ref)) { - $this->error='ProductModuleNotSetupForAutoRef'; + $this->error = 'ProductModuleNotSetupForAutoRef'; return -2; } } dol_syslog(get_class($this)."::create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type, LOG_DEBUG); - $now=dol_now(); + $now = dol_now(); $this->db->begin(); @@ -593,9 +593,9 @@ class Product extends CommonObject if ($result >= 0) { $sql = "SELECT count(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; - $sql.= " AND ref = '" .$this->db->escape($this->ref)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; + $sql .= " AND ref = '".$this->db->escape($this->ref)."'"; $result = $this->db->query($sql); if ($result) { @@ -603,56 +603,56 @@ class Product extends CommonObject if ($obj->nb == 0) { // Produit non deja existant $sql = "INSERT INTO ".MAIN_DB_PREFIX."product ("; - $sql.= "datec"; - $sql.= ", entity"; - $sql.= ", ref"; - $sql.= ", ref_ext"; - $sql.= ", price_min"; - $sql.= ", price_min_ttc"; - $sql.= ", label"; - $sql.= ", fk_user_author"; - $sql.= ", fk_product_type"; - $sql.= ", price"; - $sql.= ", price_ttc"; - $sql.= ", price_base_type"; - $sql.= ", tobuy"; - $sql.= ", tosell"; - $sql.= ", accountancy_code_buy"; - $sql.= ", accountancy_code_sell"; - $sql.= ", accountancy_code_sell_intra"; - $sql.= ", accountancy_code_sell_export"; - $sql.= ", canvas"; - $sql.= ", finished"; - $sql.= ", tobatch"; - $sql.= ", fk_unit"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."'"; - $sql.= ", ".$conf->entity; - $sql.= ", '".$this->db->escape($this->ref)."'"; - $sql.= ", ".(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null"); - $sql.= ", ".price2num($price_min_ht); - $sql.= ", ".price2num($price_min_ttc); - $sql.= ", ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); - $sql.= ", ".$user->id; - $sql.= ", ".$this->type; - $sql.= ", ".price2num($price_ht); - $sql.= ", ".price2num($price_ttc); - $sql.= ", '".$this->db->escape($this->price_base_type)."'"; - $sql.= ", ".$this->status; - $sql.= ", ".$this->status_buy; - $sql.= ", '".$this->db->escape($this->accountancy_code_buy)."'"; - $sql.= ", '".$this->db->escape($this->accountancy_code_sell)."'"; - $sql.= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'"; - $sql.= ", '".$this->db->escape($this->accountancy_code_sell_export)."'"; - $sql.= ", '".$this->db->escape($this->canvas)."'"; - $sql.= ", ".((! isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : (int) $this->finished); - $sql.= ", ".((empty($this->status_batch) || $this->status_batch < 0)? '0':$this->status_batch); - $sql.= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ")"; + $sql .= "datec"; + $sql .= ", entity"; + $sql .= ", ref"; + $sql .= ", ref_ext"; + $sql .= ", price_min"; + $sql .= ", price_min_ttc"; + $sql .= ", label"; + $sql .= ", fk_user_author"; + $sql .= ", fk_product_type"; + $sql .= ", price"; + $sql .= ", price_ttc"; + $sql .= ", price_base_type"; + $sql .= ", tobuy"; + $sql .= ", tosell"; + $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_sell"; + $sql .= ", accountancy_code_sell_intra"; + $sql .= ", accountancy_code_sell_export"; + $sql .= ", canvas"; + $sql .= ", finished"; + $sql .= ", tobatch"; + $sql .= ", fk_unit"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($now)."'"; + $sql .= ", ".$conf->entity; + $sql .= ", '".$this->db->escape($this->ref)."'"; + $sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); + $sql .= ", ".price2num($price_min_ht); + $sql .= ", ".price2num($price_min_ttc); + $sql .= ", ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", ".$user->id; + $sql .= ", ".$this->type; + $sql .= ", ".price2num($price_ht); + $sql .= ", ".price2num($price_ttc); + $sql .= ", '".$this->db->escape($this->price_base_type)."'"; + $sql .= ", ".$this->status; + $sql .= ", ".$this->status_buy; + $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_export)."'"; + $sql .= ", '".$this->db->escape($this->canvas)."'"; + $sql .= ", ".((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : (int) $this->finished); + $sql .= ", ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); + $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= ")"; dol_syslog(get_class($this)."::Create", LOG_DEBUG); $result = $this->db->query($sql); - if ($result ) { + if ($result) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."product"); if ($id > 0) { @@ -671,19 +671,19 @@ class Product extends CommonObject else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } else { $error++; - $this->error='ErrorFailedToGetInsertedId'; + $this->error = 'ErrorFailedToGetInsertedId'; } } else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } else @@ -697,18 +697,18 @@ class Product extends CommonObject else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } - if (! $error && ! $notrigger) { + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('PRODUCT_CREATE', $user); + $result = $this->call_trigger('PRODUCT_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) { + if (!$error) { $this->db->commit(); return $this->id; } @@ -735,12 +735,12 @@ class Product extends CommonObject */ public function verify() { - $this->errors=array(); + $this->errors = array(); $result = 0; $this->ref = trim($this->ref); - if (! $this->ref) { + if (!$this->ref) { $this->errors[] = 'ErrorBadRef'; $result = -2; } @@ -779,13 +779,13 @@ class Product extends CommonObject { // phpcs:enable global $conf; - if (! empty($conf->barcode->enabled) && ! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { - $module=strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); + if (!empty($conf->barcode->enabled) && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { + $module = strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); - $dirsociete=array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); + $dirsociete = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) { break; } } @@ -817,10 +817,10 @@ class Product extends CommonObject { global $langs, $conf, $hookmanager; - $error=0; + $error = 0; // Check parameters - if (! $this->label) { $this->label = 'MISSING LABEL'; + if (!$this->label) { $this->label = 'MISSING LABEL'; } // Clean parameters @@ -839,9 +839,9 @@ class Product extends CommonObject $this->height = price2num($this->height); $this->height_units = trim($this->height_units); // set unit not defined - if ($this->length_units) { $this->width_units = $this->length_units; // Not used yet + if ($this->length_units) { $this->width_units = $this->length_units; // Not used yet } - if ($this->length_units) { $this->height_units = $this->length_units; // Not used yet + if ($this->length_units) { $this->height_units = $this->length_units; // Not used yet } // Automated compute surface and volume if not filled if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units) { @@ -849,7 +849,7 @@ class Product extends CommonObject $this->surface_units = measuring_units_squared($this->length_units); } if (empty($this->volume) && !empty($this->surface_units) && !empty($this->height) && $this->length_units == $this->height_units) { - $this->volume = $this->surface * $this->height; + $this->volume = $this->surface * $this->height; $this->volume_units = measuring_units_cubed($this->height_units); } @@ -887,12 +887,12 @@ class Product extends CommonObject } // Barcode value - $this->barcode=trim($this->barcode); + $this->barcode = trim($this->barcode); $this->accountancy_code_buy = trim($this->accountancy_code_buy); - $this->accountancy_code_sell= trim($this->accountancy_code_sell); - $this->accountancy_code_sell_intra= trim($this->accountancy_code_sell_intra); - $this->accountancy_code_sell_export= trim($this->accountancy_code_sell_export); + $this->accountancy_code_sell = trim($this->accountancy_code_sell); + $this->accountancy_code_sell_intra = trim($this->accountancy_code_sell_intra); + $this->accountancy_code_sell_export = trim($this->accountancy_code_sell_export); $this->db->begin(); @@ -900,14 +900,14 @@ class Product extends CommonObject // Check name is required and codes are ok or unique. // If error, this->errors[] is filled if ($action != 'add') { - $result = $this->verify(); // We don't check when update called during a create because verify was already done + $result = $this->verify(); // We don't check when update called during a create because verify was already done } if ($result >= 0) { if (empty($this->oldcopy)) { - $org=new self($this->db); + $org = new self($this->db); $org->fetch($this->id); - $this->oldcopy=$org; + $this->oldcopy = $org; } // Test if batch management is activated on existing product @@ -926,9 +926,9 @@ class Product extends CommonObject { if ($detail->batch == $valueforundefinedlot || $detail->batch == 'Undefined') { // We discard this line, we will create it later - $sqlclean="DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE batch in('Undefined', '".$valueforundefinedlot."') AND fk_product_stock = ".$ObjW->id; + $sqlclean = "DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE batch in('Undefined', '".$valueforundefinedlot."') AND fk_product_stock = ".$ObjW->id; $result = $this->db->query($sqlclean); - if (! $result) { + if (!$result) { dol_print_error($this->db); exit; } @@ -947,7 +947,7 @@ class Product extends CommonObject if ($ObjBatch->create($user, 1) < 0) { $error++; - $this->errors=$ObjBatch->errors; + $this->errors = $ObjBatch->errors; } } } @@ -1093,18 +1093,18 @@ class Product extends CommonObject if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); if (empty($conf->barcode->enabled) || empty($this->barcode)) { - $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists", $this->ref); + $this->error = $langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists", $this->ref); } else { - $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductBarCodeAlreadyExists", $this->barcode); + $this->error = $langs->trans("Error")." : ".$langs->trans("ErrorProductBarCodeAlreadyExists", $this->barcode); } - $this->errors[]=$this->error; + $this->errors[] = $this->error; $this->db->rollback(); return -1; } else { - $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; - $this->errors[]=$this->error; + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; + $this->errors[] = $this->error; $this->db->rollback(); return -2; } @@ -1129,17 +1129,17 @@ class Product extends CommonObject { // Deprecation warning if ($id > 0) { - dol_syslog(__METHOD__ . " with parameter is deprecated", LOG_WARNING); + dol_syslog(__METHOD__." with parameter is deprecated", LOG_WARNING); } global $conf, $langs; - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; // Clean parameters if (empty($id)) { - $id=$this->id; + $id = $this->id; } else { $this->fetch($id); } @@ -1158,39 +1158,39 @@ class Product extends CommonObject if (empty($objectisused)) { $this->db->begin(); - if (! $error && empty($notrigger)) { + if (!$error && empty($notrigger)) { // Call trigger - $result=$this->call_trigger('PRODUCT_DELETE', $user); + $result = $this->call_trigger('PRODUCT_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } // Delete from product_batch on product delete - if (! $error) { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch'; - $sql.= " WHERE fk_product_stock IN ("; - $sql.= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock'; - $sql.= " WHERE fk_product = ".$id.")"; + $sql .= " WHERE fk_product_stock IN ("; + $sql .= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock'; + $sql .= " WHERE fk_product = ".$id.")"; $result = $this->db->query($sql); - if (! $result) { + if (!$result) { $error++; $this->errors[] = $this->db->lasterror(); } } // Delete all child tables - if (! $error) { - $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price','product_lot'); // product_batch is done before - foreach($elements as $table) + if (!$error) { + $elements = array('product_fournisseur_price', 'product_price', 'product_lang', 'categorie_product', 'product_stock', 'product_customer_price', 'product_lot'); // product_batch is done before + foreach ($elements as $table) { - if (! $error) { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; - $sql.= " WHERE fk_product = ".$id; + $sql .= " WHERE fk_product = ".$id; $result = $this->db->query($sql); - if (! $result) { + if (!$result) { $error++; $this->errors[] = $this->db->lasterror(); } @@ -1220,35 +1220,35 @@ class Product extends CommonObject // Delete from product_association if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association"; - $sql.= " WHERE fk_product_pere = ".$id." OR fk_product_fils = ".$id; + $sql .= " WHERE fk_product_pere = ".$id." OR fk_product_fils = ".$id; $result = $this->db->query($sql); - if (! $result) { + if (!$result) { $error++; $this->errors[] = $this->db->lasterror(); } } // Delete product - if (! $error) { + if (!$error) { $sqlz = "DELETE FROM ".MAIN_DB_PREFIX."product"; - $sqlz.= " WHERE rowid = ".$id; + $sqlz .= " WHERE rowid = ".$id; $resultz = $this->db->query($sqlz); - if (! $resultz ) { + if (!$resultz) { $error++; $this->errors[] = $this->db->lasterror(); } } - if (! $error) { + if (!$error) { // We remove directory $ref = dol_sanitizeFileName($this->ref); if ($conf->product->dir_output) { - $dir = $conf->product->dir_output . "/" . $ref; + $dir = $conf->product->dir_output."/".$ref; if (file_exists($dir)) { - $res=@dol_delete_dir_recursive($dir); - if (! $res) { + $res = @dol_delete_dir_recursive($dir); + if (!$res) { $this->errors[] = 'ErrorFailToDeleteDir'; $error++; } @@ -1257,25 +1257,25 @@ class Product extends CommonObject } // Remove 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(); + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); } } - if (! $error) { + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -$error; @@ -1305,75 +1305,75 @@ class Product extends CommonObject { if ($key == $current_lang) { $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$this->id; - $sql.= " AND lang='".$key."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$this->id; + $sql .= " AND lang='".$key."'"; $result = $this->db->query($sql); if ($this->db->num_rows($result)) // if there is already a description line for this language { $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang"; - $sql2.= " SET "; - $sql2.= " label='".$this->db->escape($this->label)."',"; - $sql2.= " description='".$this->db->escape($this->description)."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", note='".$this->db->escape($this->other)."'"; + $sql2 .= " SET "; + $sql2 .= " label='".$this->db->escape($this->label)."',"; + $sql2 .= " description='".$this->db->escape($this->description)."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", note='".$this->db->escape($this->other)."'"; } - $sql2.= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; + $sql2 .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", note"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", note"; } - $sql2.= ")"; - $sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->label)."',"; - $sql2.= " '".$this->db->escape($this->description)."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->other)."'"; + $sql2 .= ")"; + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',"; + $sql2 .= " '".$this->db->escape($this->description)."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->other)."'"; } - $sql2.= ")"; + $sql2 .= ")"; } dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key); - if (! $this->db->query($sql2)) { - $this->error=$this->db->lasterror(); + if (!$this->db->query($sql2)) { + $this->error = $this->db->lasterror(); return -1; } } elseif (isset($this->multilangs[$key])) { $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$this->id; - $sql.= " AND lang='".$key."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$this->id; + $sql .= " AND lang='".$key."'"; $result = $this->db->query($sql); if ($this->db->num_rows($result)) // if there is already a description line for this language { $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang"; - $sql2.= " SET "; - $sql2.= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", note='".$this->db->escape($this->multilangs["$key"]["other"])."'"; + $sql2 .= " SET "; + $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", note='".$this->db->escape($this->multilangs["$key"]["other"])."'"; } - $sql2.= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; + $sql2 .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", note"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", note"; } - $sql2.= ")"; - $sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2.= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; + $sql2 .= ")"; + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; } - $sql2.= ")"; + $sql2 .= ")"; } // We do not save if main fields are empty if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) { - if (! $this->db->query($sql2)) { - $this->error=$this->db->lasterror(); + if (!$this->db->query($sql2)) { + $this->error = $this->db->lasterror(); return -1; } } @@ -1406,7 +1406,7 @@ class Product extends CommonObject public function delMultiLangs($langtodelete, $user) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; + $sql .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG); $result = $this->db->query($sql); @@ -1423,7 +1423,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); return -1; } @@ -1456,19 +1456,19 @@ class Product extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET "; - $sql.= "$field = '".$this->db->escape($value)."'"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= "$field = '".$this->db->escape($value)."'"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::".__FUNCTION__." sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PRODUCT_MODIFY', $this, $user, $langs, $conf); + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interface = new Interfaces($this->db); + $result = $interface->run_triggers('PRODUCT_MODIFY', $this, $user, $langs, $conf); if ($result < 0) { - $this->errors=$interface->errors; + $this->errors = $interface->errors; $this->db->rollback(); return -1; } @@ -1481,7 +1481,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -1499,8 +1499,8 @@ class Product extends CommonObject $current_lang = $langs->getDefaultLang(); $sql = "SELECT lang, label, description, note as other"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$this->id; $result = $this->db->query($sql); if ($result) { @@ -1510,18 +1510,18 @@ class Product extends CommonObject if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. { $this->label = $obj->label; - $this->description = $obj->description; + $this->description = $obj->description; $this->other = $obj->other; } $this->multilangs["$obj->lang"]["label"] = $obj->label; - $this->multilangs["$obj->lang"]["description"] = $obj->description; + $this->multilangs["$obj->lang"]["description"] = $obj->description; $this->multilangs["$obj->lang"]["other"] = $obj->other; } return 1; } else { - $this->error="Error: ".$this->db->lasterror()." - ".$sql; + $this->error = "Error: ".$this->db->lasterror()." - ".$sql; return -1; } } @@ -1541,24 +1541,24 @@ class Product extends CommonObject // phpcs:enable global $conf; - $now=dol_now(); + $now = dol_now(); // Clean parameters if (empty($this->price_by_qty)) { - $this->price_by_qty=0; + $this->price_by_qty = 0; } // Add new price $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price, fk_product, fk_user_author, price, price_ttc, price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,"; - $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) "; - $sql.= " VALUES(".($level?$level:1).", '".$this->db->idate($now)."',".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->db->escape($this->price_base_type)."',".$this->status.",".$this->tva_tx.", ".($this->default_vat_code?("'".$this->db->escape($this->default_vat_code)."'"):"null").",".$this->tva_npr.","; - $sql.= " ".$this->localtax1_tx.", ".$this->localtax2_tx.", '".$this->db->escape($this->localtax1_type)."', '".$this->db->escape($this->localtax2_type)."', ".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty.",".$conf->entity.",".($this->fk_price_expression > 0?$this->fk_price_expression:'null'); - $sql.= ")"; + $sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) "; + $sql .= " VALUES(".($level ? $level : 1).", '".$this->db->idate($now)."',".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->db->escape($this->price_base_type)."',".$this->status.",".$this->tva_tx.", ".($this->default_vat_code ? ("'".$this->db->escape($this->default_vat_code)."'") : "null").",".$this->tva_npr.","; + $sql .= " ".$this->localtax1_tx.", ".$this->localtax2_tx.", '".$this->db->escape($this->localtax1_type)."', '".$this->db->escape($this->localtax2_type)."', ".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty.",".$conf->entity.",".($this->fk_price_expression > 0 ? $this->fk_price_expression : 'null'); + $sql .= ")"; dol_syslog(get_class($this)."::_log_price", LOG_DEBUG); - $resql=$this->db->query($sql); - if(! $resql) { - $this->error=$this->db->lasterror(); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = $this->db->lasterror(); dol_print_error($this->db); return -1; } @@ -1581,18 +1581,18 @@ class Product extends CommonObject { // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql.= " WHERE fk_product_price=".$rowid; - $resql=$this->db->query($sql); + $sql .= " WHERE fk_product_price=".$rowid; + $resql = $this->db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price"; - $sql.= " WHERE rowid=".$rowid; - $resql=$this->db->query($sql); + $sql .= " WHERE rowid=".$rowid; + $resql = $this->db->query($sql); if ($resql) { return 1; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1614,7 +1614,7 @@ class Product extends CommonObject // Update if prices fields are defined $tva_tx = get_default_tva($thirdparty_seller, $thirdparty_buyer, $this->id); $tva_npr = get_default_npr($thirdparty_seller, $thirdparty_buyer, $this->id); - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; $pu_ht = $this->price; $pu_ttc = $this->price_ttc; @@ -1727,14 +1727,14 @@ class Product extends CommonObject // We do a first seach with a select by searching with couple prodfournprice and qty only (later we will search on triplet qty/product_id/fourn_ref) $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.remise_percent,"; - $sql.= " pfp.fk_product, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression"; - $sql.= " ,pfp.default_vat_code"; - $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " WHERE pfp.rowid = ".$prodfournprice; - if ($qty > 0) { $sql.= " AND pfp.quantity <= ".$qty; + $sql .= " pfp.fk_product, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression"; + $sql .= " ,pfp.default_vat_code"; + $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql .= " WHERE pfp.rowid = ".$prodfournprice; + if ($qty > 0) { $sql .= " AND pfp.quantity <= ".$qty; } - $sql.= " ORDER BY pfp.quantity DESC"; + $sql .= " ORDER BY pfp.quantity DESC"; dol_syslog(get_class($this)."::get_buyprice first search by prodfournprice/qty", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1757,41 +1757,41 @@ class Product extends CommonObject } } $this->product_fourn_price_id = $obj->rowid; - $this->buyprice = $obj->price; // deprecated - $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product of supplier - $this->fourn_price_base_type = 'HT'; // Price base type - $this->fourn_socid = $obj->fk_soc; // Company that offer this price - $this->ref_fourn = $obj->ref_fourn; // deprecated - $this->ref_supplier = $obj->ref_fourn; // Ref supplier - $this->desc_supplier = $obj->desc_fourn; // desc supplier - $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed - $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier - $this->default_vat_code = $obj->default_vat_code; // Vat code supplier + $this->buyprice = $obj->price; // deprecated + $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product of supplier + $this->fourn_price_base_type = 'HT'; // Price base type + $this->fourn_socid = $obj->fk_soc; // Company that offer this price + $this->ref_fourn = $obj->ref_fourn; // deprecated + $this->ref_supplier = $obj->ref_fourn; // Ref supplier + $this->desc_supplier = $obj->desc_fourn; // desc supplier + $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed + $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier + $this->default_vat_code = $obj->default_vat_code; // Vat code supplier $this->fourn_multicurrency_price = $obj->multicurrency_price; $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; $this->fourn_multicurrency_tx = $obj->multicurrency_tx; $this->fourn_multicurrency_id = $obj->fk_multicurrency; $this->fourn_multicurrency_code = $obj->multicurrency_code; - $result=$obj->fk_product; + $result = $obj->fk_product; return $result; } else // If not found { // We do a second search by doing a select again but searching with less reliable criteria: couple qty/id product, and if set fourn_ref or fk_soc. $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; - $sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.desc_fourn as desc_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; - $sql.= " ,pfp.default_vat_code"; - $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " WHERE pfp.fk_product = ".$product_id; - if ($fourn_ref != 'none') { $sql.= " AND pfp.ref_fourn = '".$fourn_ref."'"; + $sql .= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.desc_fourn as desc_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; + $sql .= " ,pfp.default_vat_code"; + $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql .= " WHERE pfp.fk_product = ".$product_id; + if ($fourn_ref != 'none') { $sql .= " AND pfp.ref_fourn = '".$fourn_ref."'"; } - if ($fk_soc > 0) { $sql.= " AND pfp.fk_soc = ".$fk_soc; + if ($fk_soc > 0) { $sql .= " AND pfp.fk_soc = ".$fk_soc; } - if ($qty > 0) { $sql.= " AND pfp.quantity <= ".$qty; + if ($qty > 0) { $sql .= " AND pfp.quantity <= ".$qty; } - $sql.= " ORDER BY pfp.quantity DESC"; - $sql.= " LIMIT 1"; + $sql .= " ORDER BY pfp.quantity DESC"; + $sql .= " LIMIT 1"; dol_syslog(get_class($this)."::get_buyprice second search from qty/ref/product_id", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1814,40 +1814,40 @@ class Product extends CommonObject } } $this->product_fourn_price_id = $obj->rowid; - $this->buyprice = $obj->price; // deprecated - $this->fourn_qty = $obj->quantity; // min quantity for price for a virtual supplier - $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product for a virtual supplier - $this->fourn_price_base_type = 'HT'; // Price base type for a virtual supplier - $this->fourn_socid = $obj->fk_soc; // Company that offer this price - $this->ref_fourn = $obj->ref_supplier; // deprecated - $this->ref_supplier = $obj->ref_supplier; // Ref supplier - $this->desc_supplier = $obj->desc_supplier; // desc supplier - $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed - $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier - $this->default_vat_code = $obj->default_vat_code; // Vat code supplier + $this->buyprice = $obj->price; // deprecated + $this->fourn_qty = $obj->quantity; // min quantity for price for a virtual supplier + $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product for a virtual supplier + $this->fourn_price_base_type = 'HT'; // Price base type for a virtual supplier + $this->fourn_socid = $obj->fk_soc; // Company that offer this price + $this->ref_fourn = $obj->ref_supplier; // deprecated + $this->ref_supplier = $obj->ref_supplier; // Ref supplier + $this->desc_supplier = $obj->desc_supplier; // desc supplier + $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed + $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier + $this->default_vat_code = $obj->default_vat_code; // Vat code supplier $this->fourn_multicurrency_price = $obj->multicurrency_price; $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; $this->fourn_multicurrency_tx = $obj->multicurrency_tx; $this->fourn_multicurrency_id = $obj->fk_multicurrency; $this->fourn_multicurrency_code = $obj->multicurrency_code; - $result=$obj->fk_product; + $result = $obj->fk_product; return $result; } else { - return -1; // Ce produit n'existe pas avec cet id tarif fournisseur ou existe mais qte insuffisante, ni pour le couple produit/ref fournisseur dans la quantité. + return -1; // Ce produit n'existe pas avec cet id tarif fournisseur ou existe mais qte insuffisante, ni pour le couple produit/ref fournisseur dans la quantité. } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -3; } } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -2; } } @@ -1871,33 +1871,33 @@ class Product extends CommonObject */ public function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '') { - global $conf,$langs; + global $conf, $langs; - $id=$this->id; + $id = $this->id; dol_syslog(get_class($this)."::update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase." newminprice=".$newminprice." level=".$level." npr=".$newnpr." newdefaultvatcode=".$newdefaultvatcode); // Clean parameters if (empty($this->tva_tx)) { - $this->tva_tx=0; + $this->tva_tx = 0; } if (empty($newnpr)) { - $newnpr=0; + $newnpr = 0; } // Check parameters if ($newvat == '') { - $newvat=$this->tva_tx; + $newvat = $this->tva_tx; } // If multiprices are enabled, then we check if the current product is subject to price autogeneration // Price will be modified ONLY when the first one is the one that is being modified - if ((!empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !$ignore_autogen && $this->price_autogen && ($level == 1)) { + if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !$ignore_autogen && $this->price_autogen && ($level == 1)) { return $this->generateMultiprices($user, $newprice, $newpricebase, $newvat, $newnpr, $newpbq); } - if (! empty($newminprice) && ($newminprice > $newprice)) { - $this->error='ErrorPriceCantBeLowerThanMinPrice'; + if (!empty($newminprice) && ($newminprice > $newprice)) { + $this->error = 'ErrorPriceCantBeLowerThanMinPrice'; return -1; } @@ -1914,14 +1914,14 @@ class Product extends CommonObject } else { - $price_min=0; - $price_min_ttc=0; + $price_min = 0; + $price_min_ttc = 0; } } else { $price = price2num($newprice, 'MU'); - $price_ttc = ( $newnpr != 1 ) ? price2num($newprice) * (1 + ($newvat / 100)) : $price; + $price_ttc = ($newnpr != 1) ? price2num($newprice) * (1 + ($newvat / 100)) : $price; $price_ttc = price2num($price_ttc, 'MU'); if ($newminprice !== '' || $newminprice === 0) { @@ -1932,30 +1932,30 @@ class Product extends CommonObject } else { - $price_min=0; - $price_min_ttc=0; + $price_min = 0; + $price_min_ttc = 0; } } //print 'x'.$id.'-'.$newprice.'-'.$newpricebase.'-'.$price.'-'.$price_ttc.'-'.$price_min.'-'.$price_min_ttc; if (count($localtaxes_array) > 0) { - $localtaxtype1=$localtaxes_array['0']; - $localtax1=$localtaxes_array['1']; - $localtaxtype2=$localtaxes_array['2']; - $localtax2=$localtaxes_array['3']; + $localtaxtype1 = $localtaxes_array['0']; + $localtax1 = $localtaxes_array['1']; + $localtaxtype2 = $localtaxes_array['2']; + $localtax2 = $localtaxes_array['3']; } else // old method. deprecated because ot can't retreive type { - $localtaxtype1='0'; - $localtax1=get_localtax($newvat, 1); - $localtaxtype2='0'; - $localtax2=get_localtax($newvat, 2); + $localtaxtype1 = '0'; + $localtax1 = get_localtax($newvat, 1); + $localtaxtype2 = '0'; + $localtax2 = get_localtax($newvat, 2); } if (empty($localtax1)) { - $localtax1=0; // If = '' then = 0 + $localtax1 = 0; // If = '' then = 0 } if (empty($localtax2)) { - $localtax2=0; // If = '' then = 0 + $localtax2 = 0; // If = '' then = 0 } $this->db->begin(); @@ -1963,31 +1963,31 @@ class Product extends CommonObject // Ne pas mettre de quote sur les numeriques decimaux. // Ceci provoque des stockages avec arrondis en base au lieu des valeurs exactes. $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; - $sql.= " price_base_type='".$newpricebase."',"; - $sql.= " price=".$price.","; - $sql.= " price_ttc=".$price_ttc.","; - $sql.= " price_min=".$price_min.","; - $sql.= " price_min_ttc=".$price_min_ttc.","; - $sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; - $sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; - $sql.= " localtax1_type=".($localtaxtype1!=''?"'".$localtaxtype1."'":"'0'").","; - $sql.= " localtax2_type=".($localtaxtype2!=''?"'".$localtaxtype2."'":"'0'").","; - $sql.= " default_vat_code=".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; - $sql.= " tva_tx='".price2num($newvat)."',"; - $sql.= " recuperableonly='".$newnpr."'"; - $sql.= " WHERE rowid = ".$id; + $sql .= " price_base_type='".$newpricebase."',"; + $sql .= " price=".$price.","; + $sql .= " price_ttc=".$price_ttc.","; + $sql .= " price_min=".$price_min.","; + $sql .= " price_min_ttc=".$price_min_ttc.","; + $sql .= " localtax1_tx=".($localtax1 >= 0 ? $localtax1 : 'NULL').","; + $sql .= " localtax2_tx=".($localtax2 >= 0 ? $localtax2 : 'NULL').","; + $sql .= " localtax1_type=".($localtaxtype1 != '' ? "'".$localtaxtype1."'" : "'0'").","; + $sql .= " localtax2_type=".($localtaxtype2 != '' ? "'".$localtaxtype2."'" : "'0'").","; + $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; + $sql .= " tva_tx='".price2num($newvat)."',"; + $sql .= " recuperableonly='".$newnpr."'"; + $sql .= " WHERE rowid = ".$id; dol_syslog(get_class($this)."::update_price", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->multiprices[$level] = $price; $this->multiprices_ttc[$level] = $price_ttc; - $this->multiprices_min[$level]= $price_min; - $this->multiprices_min_ttc[$level]= $price_min_ttc; - $this->multiprices_base_type[$level]= $newpricebase; - $this->multiprices_default_vat_code[$level]= $newdefaultvatcode; - $this->multiprices_tva_tx[$level]= $newvat; - $this->multiprices_recuperableonly[$level]= $newnpr; + $this->multiprices_min[$level] = $price_min; + $this->multiprices_min_ttc[$level] = $price_min_ttc; + $this->multiprices_base_type[$level] = $newpricebase; + $this->multiprices_default_vat_code[$level] = $newdefaultvatcode; + $this->multiprices_tva_tx[$level] = $newvat; + $this->multiprices_recuperableonly[$level] = $newnpr; $this->price = $price; $this->price_ttc = $price_ttc; @@ -2006,12 +2006,12 @@ class Product extends CommonObject // Price by quantity $this->price_by_qty = $newpbq; - $this->_log_price($user, $level); // Save price for level into table product_price + $this->_log_price($user, $level); // Save price for level into table product_price - $this->level = $level; // Store level of price edited for trigger + $this->level = $level; // Store level of price edited for trigger // Call trigger - $result=$this->call_trigger('PRODUCT_PRICE_MODIFY', $user); + $result = $this->call_trigger('PRODUCT_PRICE_MODIFY', $user); if ($result < 0) { $this->db->rollback(); return -1; @@ -2116,18 +2116,18 @@ class Product extends CommonObject $this->customcode = $obj->customcode; $this->country_id = $obj->fk_country; - $this->country_code = getCountry($this->country_id, 2, $this->db); + $this->country_code = getCountry($this->country_id, 2, $this->db); $this->price = $obj->price; $this->price_ttc = $obj->price_ttc; $this->price_min = $obj->price_min; $this->price_min_ttc = $obj->price_min_ttc; - $this->price_base_type = $obj->price_base_type; + $this->price_base_type = $obj->price_base_type; $this->cost_price = $obj->cost_price; - $this->default_vat_code = $obj->default_vat_code; + $this->default_vat_code = $obj->default_vat_code; $this->tva_tx = $obj->tva_tx; //! French VAT NPR $this->tva_npr = $obj->tva_npr; - $this->recuperableonly = $obj->tva_npr; // For backward compatibility + $this->recuperableonly = $obj->tva_npr; // For backward compatibility //! Local taxes $this->localtax1_tx = $obj->localtax1_tx; $this->localtax2_tx = $obj->localtax2_tx; @@ -2176,7 +2176,7 @@ class Product extends CommonObject $this->ref_ext = $obj->ref_ext; $this->fk_price_expression = $obj->fk_price_expression; $this->fk_unit = $obj->fk_unit; - $this->price_autogen = $obj->price_autogen; + $this->price_autogen = $obj->price_autogen; $this->db->free($resql); @@ -2185,35 +2185,35 @@ class Product extends CommonObject $this->fetch_optionals(); // multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $this->getMultiLangs(); } // Load multiprices array - if (! empty($conf->global->PRODUIT_MULTIPRICES)) // prices per segment + if (!empty($conf->global->PRODUIT_MULTIPRICES)) // prices per segment { - for ($i=1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; - $sql.= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_price"; - $sql.= " WHERE entity IN (".getEntity('productprice').")"; - $sql.= " AND price_level=".$i; - $sql.= " AND fk_product = ".$this->id; - $sql.= " ORDER BY date_price DESC, rowid DESC"; - $sql.= " LIMIT 1"; + $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; + $sql .= " WHERE entity IN (".getEntity('productprice').")"; + $sql .= " AND price_level=".$i; + $sql .= " AND fk_product = ".$this->id; + $sql .= " ORDER BY date_price DESC, rowid DESC"; + $sql .= " LIMIT 1"; $resql = $this->db->query($sql); if ($resql) { $result = $this->db->fetch_array($resql); - $this->multiprices[$i]=$result["price"]; - $this->multiprices_ttc[$i]=$result["price_ttc"]; - $this->multiprices_min[$i]=$result["price_min"]; - $this->multiprices_min_ttc[$i]=$result["price_min_ttc"]; - $this->multiprices_base_type[$i]=$result["price_base_type"]; + $this->multiprices[$i] = $result["price"]; + $this->multiprices_ttc[$i] = $result["price_ttc"]; + $this->multiprices_min[$i] = $result["price_min"]; + $this->multiprices_min_ttc[$i] = $result["price_min_ttc"]; + $this->multiprices_base_type[$i] = $result["price_base_type"]; // Next two fields are used only if PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on - $this->multiprices_tva_tx[$i]=$result["tva_tx"]; // TODO Add ' ('.$result['default_vat_code'].')' - $this->multiprices_recuperableonly[$i]=$result["recuperableonly"]; + $this->multiprices_tva_tx[$i] = $result["tva_tx"]; // TODO Add ' ('.$result['default_vat_code'].')' + $this->multiprices_recuperableonly[$i] = $result["recuperableonly"]; // Price by quantity /* @@ -2258,47 +2258,47 @@ class Product extends CommonObject } } } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // prices per customers + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // prices per customers { // Nothing loaded by default. List may be very long. } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) // prices per quantity + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) // prices per quantity { $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; - $sql.= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_price"; - $sql.= " WHERE fk_product = ".$this->id; - $sql.= " ORDER BY date_price DESC, rowid DESC"; - $sql.= " LIMIT 1"; + $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; + $sql .= " WHERE fk_product = ".$this->id; + $sql .= " ORDER BY date_price DESC, rowid DESC"; + $sql .= " LIMIT 1"; $resql = $this->db->query($sql); if ($resql) { $result = $this->db->fetch_array($resql); // Price by quantity - $this->prices_by_qty[0]=$result["price_by_qty"]; - $this->prices_by_qty_id[0]=$result["rowid"]; + $this->prices_by_qty[0] = $result["price_by_qty"]; + $this->prices_by_qty_id[0] = $result["rowid"]; // Récuperation de la liste des prix selon qty si flag positionné if ($this->prices_by_qty[0] == 1) { $sql = "SELECT rowid,price, unitprice, quantity, remise_percent, remise, remise, price_base_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql.= " WHERE fk_product_price = ".$this->prices_by_qty_id[0]; - $sql.= " ORDER BY quantity ASC"; - $resultat=array(); + $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; + $sql .= " WHERE fk_product_price = ".$this->prices_by_qty_id[0]; + $sql .= " ORDER BY quantity ASC"; + $resultat = array(); $resql = $this->db->query($sql); if ($resql) { - $ii=0; - while ($result= $this->db->fetch_array($resql)) { - $resultat[$ii]=array(); - $resultat[$ii]["rowid"]=$result["rowid"]; - $resultat[$ii]["price"]= $result["price"]; - $resultat[$ii]["unitprice"]= $result["unitprice"]; - $resultat[$ii]["quantity"]= $result["quantity"]; - $resultat[$ii]["remise_percent"]= $result["remise_percent"]; + $ii = 0; + while ($result = $this->db->fetch_array($resql)) { + $resultat[$ii] = array(); + $resultat[$ii]["rowid"] = $result["rowid"]; + $resultat[$ii]["price"] = $result["price"]; + $resultat[$ii]["unitprice"] = $result["unitprice"]; + $resultat[$ii]["quantity"] = $result["quantity"]; + $resultat[$ii]["remise_percent"] = $result["remise_percent"]; //$resultat[$ii]["remise"]= $result["remise"]; // deprecated - $resultat[$ii]["price_base_type"]= $result["price_base_type"]; + $resultat[$ii]["price_base_type"] = $result["price_base_type"]; $ii++; } - $this->prices_by_qty_list[0]=$resultat; + $this->prices_by_qty_list[0] = $resultat; } else { @@ -2313,56 +2313,56 @@ class Product extends CommonObject return -1; } } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) // prices per customer and quantity + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) // prices per customer and quantity { - for ($i=1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; - $sql.= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_price"; - $sql.= " WHERE entity IN (".getEntity('productprice').")"; - $sql.= " AND price_level=".$i; - $sql.= " AND fk_product = ".$this->id; - $sql.= " ORDER BY date_price DESC, rowid DESC"; - $sql.= " LIMIT 1"; + $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; + $sql .= " WHERE entity IN (".getEntity('productprice').")"; + $sql .= " AND price_level=".$i; + $sql .= " AND fk_product = ".$this->id; + $sql .= " ORDER BY date_price DESC, rowid DESC"; + $sql .= " LIMIT 1"; $resql = $this->db->query($sql); if ($resql) { $result = $this->db->fetch_array($resql); - $this->multiprices[$i]=$result["price"]; - $this->multiprices_ttc[$i]=$result["price_ttc"]; - $this->multiprices_min[$i]=$result["price_min"]; - $this->multiprices_min_ttc[$i]=$result["price_min_ttc"]; - $this->multiprices_base_type[$i]=$result["price_base_type"]; + $this->multiprices[$i] = $result["price"]; + $this->multiprices_ttc[$i] = $result["price_ttc"]; + $this->multiprices_min[$i] = $result["price_min"]; + $this->multiprices_min_ttc[$i] = $result["price_min_ttc"]; + $this->multiprices_base_type[$i] = $result["price_base_type"]; // Next two fields are used only if PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on - $this->multiprices_tva_tx[$i]=$result["tva_tx"]; // TODO Add ' ('.$result['default_vat_code'].')' - $this->multiprices_recuperableonly[$i]=$result["recuperableonly"]; + $this->multiprices_tva_tx[$i] = $result["tva_tx"]; // TODO Add ' ('.$result['default_vat_code'].')' + $this->multiprices_recuperableonly[$i] = $result["recuperableonly"]; // Price by quantity - $this->prices_by_qty[$i]=$result["price_by_qty"]; - $this->prices_by_qty_id[$i]=$result["rowid"]; + $this->prices_by_qty[$i] = $result["price_by_qty"]; + $this->prices_by_qty_id[$i] = $result["rowid"]; // Récuperation de la liste des prix selon qty si flag positionné if ($this->prices_by_qty[$i] == 1) { $sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql.= " WHERE fk_product_price = ".$this->prices_by_qty_id[$i]; - $sql.= " ORDER BY quantity ASC"; - $resultat=array(); + $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; + $sql .= " WHERE fk_product_price = ".$this->prices_by_qty_id[$i]; + $sql .= " ORDER BY quantity ASC"; + $resultat = array(); $resql = $this->db->query($sql); if ($resql) { - $ii=0; - while ($result= $this->db->fetch_array($resql)) { - $resultat[$ii]=array(); - $resultat[$ii]["rowid"]=$result["rowid"]; - $resultat[$ii]["price"]= $result["price"]; - $resultat[$ii]["unitprice"]= $result["unitprice"]; - $resultat[$ii]["quantity"]= $result["quantity"]; - $resultat[$ii]["remise_percent"]= $result["remise_percent"]; - $resultat[$ii]["remise"]= $result["remise"]; // deprecated - $resultat[$ii]["price_base_type"]= $result["price_base_type"]; + $ii = 0; + while ($result = $this->db->fetch_array($resql)) { + $resultat[$ii] = array(); + $resultat[$ii]["rowid"] = $result["rowid"]; + $resultat[$ii]["price"] = $result["price"]; + $resultat[$ii]["unitprice"] = $result["unitprice"]; + $resultat[$ii]["quantity"] = $result["quantity"]; + $resultat[$ii]["remise_percent"] = $result["remise_percent"]; + $resultat[$ii]["remise"] = $result["remise"]; // deprecated + $resultat[$ii]["price_base_type"] = $result["price_base_type"]; $ii++; } - $this->prices_by_qty_list[$i]=$resultat; + $this->prices_by_qty_list[$i] = $resultat; } else { @@ -2496,34 +2496,34 @@ class Product extends CommonObject global $user; $sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_suppliers, COUNT(DISTINCT p.rowid) as nb,"; - $sql.= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as pd"; - $sql.= ", ".MAIN_DB_PREFIX."supplier_proposal as p"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as pd"; + $sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE p.rowid = pd.fk_supplier_proposal"; - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; - $sql.= " AND pd.fk_product = ".$this->id; - if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " WHERE p.rowid = pd.fk_supplier_proposal"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; + $sql .= " AND pd.fk_product = ".$this->id; + if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } //$sql.= " AND pr.fk_statut != 0"; - if ($socid > 0) { $sql.= " AND p.fk_soc = ".$socid; + if ($socid > 0) { $sql .= " AND p.fk_soc = ".$socid; } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_proposal_supplier['suppliers']=$obj->nb_suppliers; - $this->stats_proposal_supplier['nb']=$obj->nb; - $this->stats_proposal_supplier['rows']=$obj->nb_rows; - $this->stats_proposal_supplier['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_proposal_supplier['suppliers'] = $obj->nb_suppliers; + $this->stats_proposal_supplier['nb'] = $obj->nb; + $this->stats_proposal_supplier['rows'] = $obj->nb_rows; + $this->stats_proposal_supplier['qty'] = $obj->qty ? $obj->qty : 0; return 1; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2585,10 +2585,10 @@ class Product extends CommonObject if ($fatherData['incdec']) { $pFather->load_stats_commande($socid, $filtrestatut); - $this->stats_commande['customers']+=$pFather->stats_commande['customers']; - $this->stats_commande['nb']+=$pFather->stats_commande['nb']; - $this->stats_commande['rows']+=$pFather->stats_commande['rows']; - $this->stats_commande['qty']+=$pFather->stats_commande['qty'] * $qtyCoef; + $this->stats_commande['customers'] += $pFather->stats_commande['customers']; + $this->stats_commande['nb'] += $pFather->stats_commande['nb']; + $this->stats_commande['rows'] += $pFather->stats_commande['rows']; + $this->stats_commande['qty'] += $pFather->stats_commande['qty'] * $qtyCoef; } } } @@ -2597,8 +2597,8 @@ class Product extends CommonObject // If stock decrease is on invoice validation, the theorical stock continue to // count the orders to ship in theorical stock when some are already removed b invoice validation. // If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation. - if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) { - if (! empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) { + if (!empty($conf->global->STOCK_CALCULATE_ON_BILL)) { + if (!empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) { $adeduire = 0; $sql = "SELECT sum(fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet fd "; $sql .= " JOIN ".MAIN_DB_PREFIX."facture f ON fd.fk_facture = f.rowid "; @@ -2608,7 +2608,7 @@ class Product extends CommonObject dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE); $resql = $this->db->query($sql); - if ($resql ) { + if ($resql) { if ($this->db->num_rows($resql) > 0) { $obj = $this->db->fetch_object($resql); $adeduire += $obj->count; @@ -2623,7 +2623,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2640,42 +2640,42 @@ class Product extends CommonObject public function load_stats_commande_fournisseur($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable - global $conf,$user; + global $conf, $user; $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_suppliers, COUNT(DISTINCT c.rowid) as nb,"; - $sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; - $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE c.rowid = cd.fk_commande"; - $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('supplier_order').")"; - $sql.= " AND cd.fk_product = ".$this->id; + $sql .= " WHERE c.rowid = cd.fk_commande"; + $sql .= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; + $sql .= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { - $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_soc = ".$socid; } if ($filtrestatut != '') { - $sql.= " AND c.fk_statut in (".$filtrestatut.")"; // Peut valoir 0 + $sql .= " AND c.fk_statut in (".$filtrestatut.")"; // Peut valoir 0 } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_commande_fournisseur['suppliers']=$obj->nb_suppliers; - $this->stats_commande_fournisseur['nb']=$obj->nb; - $this->stats_commande_fournisseur['rows']=$obj->nb_rows; - $this->stats_commande_fournisseur['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_commande_fournisseur['suppliers'] = $obj->nb_suppliers; + $this->stats_commande_fournisseur['nb'] = $obj->nb; + $this->stats_commande_fournisseur['rows'] = $obj->nb_rows; + $this->stats_commande_fournisseur['qty'] = $obj->qty ? $obj->qty : 0; return 1; } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error = $this->db->error().' sql='.$sql; return -1; } } @@ -2769,38 +2769,38 @@ class Product extends CommonObject public function load_stats_reception($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable - global $conf,$user; + global $conf, $user; $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; - $sql.= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd"; - $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE cf.rowid = fd.fk_commande"; - $sql.= " AND cf.fk_soc = s.rowid"; - $sql.= " AND cf.entity IN (".getEntity('supplier_order').")"; - $sql.= " AND fd.fk_product = ".$this->id; - if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { $sql.= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " WHERE cf.rowid = fd.fk_commande"; + $sql .= " AND cf.fk_soc = s.rowid"; + $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; + $sql .= " AND fd.fk_product = ".$this->id; + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } - if ($socid > 0) { $sql.= " AND cf.fk_soc = ".$socid; + if ($socid > 0) { $sql .= " AND cf.fk_soc = ".$socid; } - if ($filtrestatut <> '') { $sql.= " AND cf.fk_statut in (".$filtrestatut.")"; + if ($filtrestatut <> '') { $sql .= " AND cf.fk_statut in (".$filtrestatut.")"; } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_reception['suppliers']=$obj->nb_customers; - $this->stats_reception['nb']=$obj->nb; - $this->stats_reception['rows']=$obj->nb_rows; - $this->stats_reception['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_reception['suppliers'] = $obj->nb_customers; + $this->stats_reception['nb'] = $obj->nb; + $this->stats_reception['rows'] = $obj->nb_rows; + $this->stats_reception['qty'] = $obj->qty ? $obj->qty : 0; return 1; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2958,19 +2958,19 @@ class Product extends CommonObject global $user; $sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_suppliers, COUNT(DISTINCT f.rowid) as nb,"; - $sql.= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; - $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; + $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE f.rowid = fd.fk_facture_fourn"; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('facture_fourn').")"; - $sql.= " AND fd.fk_product = ".$this->id; + $sql .= " WHERE f.rowid = fd.fk_facture_fourn"; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; + $sql .= " AND fd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } //$sql.= " AND f.fk_statut != 0"; if ($socid > 0) { @@ -2978,17 +2978,17 @@ class Product extends CommonObject } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_facture_fournisseur['suppliers']=$obj->nb_suppliers; - $this->stats_facture_fournisseur['nb']=$obj->nb; - $this->stats_facture_fournisseur['rows']=$obj->nb_rows; - $this->stats_facture_fournisseur['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_facture_fournisseur['suppliers'] = $obj->nb_suppliers; + $this->stats_facture_fournisseur['nb'] = $obj->nb; + $this->stats_facture_fournisseur['rows'] = $obj->nb_rows; + $this->stats_facture_fournisseur['qty'] = $obj->qty ? $obj->qty : 0; return 1; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -3013,17 +3013,17 @@ class Product extends CommonObject { $arr = $this->db->fetch_array($resql); if ($mode == 'byunit') { - $tab[$arr[1]] = $arr[0]; // 1st field + $tab[$arr[1]] = $arr[0]; // 1st field } if ($mode == 'bynumber') { - $tab[$arr[1]] = $arr[2]; // 3rd field + $tab[$arr[1]] = $arr[2]; // 3rd field } $i++; } } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error = $this->db->error().' sql='.$sql; return -1; } @@ -3033,16 +3033,16 @@ class Product extends CommonObject } else { - $month=12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. + $month = 12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. } $result = array(); - for ($j = 0 ; $j < 12 ; $j++) + for ($j = 0; $j < 12; $j++) { - $idx=ucfirst(dol_trunc(dol_print_date(dol_mktime(12, 0, 0, $month, 1, $year), "%b"), 3, 'right', 'UTF-8', 1)); - $monthnum=sprintf("%02s", $month); + $idx = ucfirst(dol_trunc(dol_print_date(dol_mktime(12, 0, 0, $month, 1, $year), "%b"), 3, 'right', 'UTF-8', 1)); + $monthnum = sprintf("%02s", $month); - $result[$j] = array($idx,isset($tab[$year.$month])?$tab[$year.$month]:0); + $result[$j] = array($idx, isset($tab[$year.$month]) ? $tab[$year.$month] : 0); // $result[$j] = array($monthnum,isset($tab[$year.$month])?$tab[$year.$month]:0); $month = "0".($month - 1); @@ -3078,35 +3078,35 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')"; if ($mode == 'bynumber') { - $sql.= ", count(DISTINCT f.rowid)"; + $sql .= ", count(DISTINCT f.rowid)"; } - $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; if ($filteronproducttype >= 0) { - $sql.=", ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; } if (!$user->rights->societe->client->voir && !$socid) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE f.rowid = d.fk_facture"; + $sql .= " WHERE f.rowid = d.fk_facture"; if ($this->id > 0) { - $sql.= " AND d.fk_product =".$this->id; + $sql .= " AND d.fk_product =".$this->id; } else { - $sql.=" AND d.fk_product > 0"; + $sql .= " AND d.fk_product > 0"; } if ($filteronproducttype >= 0) { - $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; + $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; } - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND f.fk_soc = $socid"; + $sql .= " AND f.fk_soc = $socid"; } - $sql.=$morefilter; - $sql.= " GROUP BY date_format(f.datef,'%Y%m')"; - $sql.= " ORDER BY date_format(f.datef,'%Y%m') DESC"; + $sql .= $morefilter; + $sql .= " GROUP BY date_format(f.datef,'%Y%m')"; + $sql .= " ORDER BY date_format(f.datef,'%Y%m') DESC"; return $this->_get_stats($sql, $mode, $year); } @@ -3131,35 +3131,35 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')"; if ($mode == 'bynumber') { - $sql.= ", count(DISTINCT f.rowid)"; + $sql .= ", count(DISTINCT f.rowid)"; } - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; if ($filteronproducttype >= 0) { - $sql.=", ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; } if (!$user->rights->societe->client->voir && !$socid) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE f.rowid = d.fk_facture_fourn"; + $sql .= " WHERE f.rowid = d.fk_facture_fourn"; if ($this->id > 0) { - $sql.= " AND d.fk_product =".$this->id; + $sql .= " AND d.fk_product =".$this->id; } else { - $sql.=" AND d.fk_product > 0"; + $sql .= " AND d.fk_product > 0"; } if ($filteronproducttype >= 0) { - $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; + $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; } - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('facture_fourn').")"; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND f.fk_soc = $socid"; + $sql .= " AND f.fk_soc = $socid"; } - $sql.=$morefilter; - $sql.= " GROUP BY date_format(f.datef,'%Y%m')"; - $sql.= " ORDER BY date_format(f.datef,'%Y%m') DESC"; + $sql .= $morefilter; + $sql .= " GROUP BY date_format(f.datef,'%Y%m')"; + $sql .= " ORDER BY date_format(f.datef,'%Y%m') DESC"; return $this->_get_stats($sql, $mode, $year); } @@ -3183,35 +3183,35 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')"; if ($mode == 'bynumber') { - $sql.= ", count(DISTINCT p.rowid)"; + $sql .= ", count(DISTINCT p.rowid)"; } - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; if ($filteronproducttype >= 0) { - $sql.=", ".MAIN_DB_PREFIX."product as prod"; + $sql .= ", ".MAIN_DB_PREFIX."product as prod"; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE p.rowid = d.fk_propal"; + $sql .= " WHERE p.rowid = d.fk_propal"; if ($this->id > 0) { - $sql.= " AND d.fk_product =".$this->id; + $sql .= " AND d.fk_product =".$this->id; } else { - $sql.=" AND d.fk_product > 0"; + $sql .= " AND d.fk_product > 0"; } if ($filteronproducttype >= 0) { - $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; + $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; } - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND p.fk_soc = ".$socid; + $sql .= " AND p.fk_soc = ".$socid; } - $sql.=$morefilter; - $sql.= " GROUP BY date_format(p.datep,'%Y%m')"; - $sql.= " ORDER BY date_format(p.datep,'%Y%m') DESC"; + $sql .= $morefilter; + $sql .= " GROUP BY date_format(p.datep,'%Y%m')"; + $sql .= " ORDER BY date_format(p.datep,'%Y%m') DESC"; return $this->_get_stats($sql, $mode, $year); } @@ -3235,35 +3235,35 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(p.date_valid, '%Y%m')"; if ($mode == 'bynumber') { - $sql.= ", count(DISTINCT p.rowid)"; + $sql .= ", count(DISTINCT p.rowid)"; } - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."societe as s"; if ($filteronproducttype >= 0) { - $sql.=", ".MAIN_DB_PREFIX."product as prod"; + $sql .= ", ".MAIN_DB_PREFIX."product as prod"; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE p.rowid = d.fk_supplier_proposal"; + $sql .= " WHERE p.rowid = d.fk_supplier_proposal"; if ($this->id > 0) { - $sql.= " AND d.fk_product =".$this->id; + $sql .= " AND d.fk_product =".$this->id; } else { - $sql.=" AND d.fk_product > 0"; + $sql .= " AND d.fk_product > 0"; } if ($filteronproducttype >= 0) { - $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; + $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; } - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND p.fk_soc = ".$socid; + $sql .= " AND p.fk_soc = ".$socid; } - $sql.=$morefilter; - $sql.= " GROUP BY date_format(p.date_valid,'%Y%m')"; - $sql.= " ORDER BY date_format(p.date_valid,'%Y%m') DESC"; + $sql .= $morefilter; + $sql .= " GROUP BY date_format(p.date_valid,'%Y%m')"; + $sql .= " ORDER BY date_format(p.date_valid,'%Y%m') DESC"; return $this->_get_stats($sql, $mode, $year); } @@ -3286,35 +3286,35 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; if ($mode == 'bynumber') { - $sql.= ", count(DISTINCT c.rowid)"; + $sql .= ", count(DISTINCT c.rowid)"; } - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; if ($filteronproducttype >= 0) { - $sql.=", ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE c.rowid = d.fk_commande"; + $sql .= " WHERE c.rowid = d.fk_commande"; if ($this->id > 0) { - $sql.= " AND d.fk_product =".$this->id; + $sql .= " AND d.fk_product =".$this->id; } else { - $sql.=" AND d.fk_product > 0"; + $sql .= " AND d.fk_product > 0"; } if ($filteronproducttype >= 0) { - $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; + $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; } - $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_soc = ".$socid; } - $sql.=$morefilter; - $sql.= " GROUP BY date_format(c.date_commande,'%Y%m')"; - $sql.= " ORDER BY date_format(c.date_commande,'%Y%m') DESC"; + $sql .= $morefilter; + $sql .= " GROUP BY date_format(c.date_commande,'%Y%m')"; + $sql .= " ORDER BY date_format(c.date_commande,'%Y%m') DESC"; return $this->_get_stats($sql, $mode, $year); } @@ -3337,35 +3337,35 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; if ($mode == 'bynumber') { - $sql.= ", count(DISTINCT c.rowid)"; + $sql .= ", count(DISTINCT c.rowid)"; } - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; if ($filteronproducttype >= 0) { - $sql.=", ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE c.rowid = d.fk_commande"; + $sql .= " WHERE c.rowid = d.fk_commande"; if ($this->id > 0) { - $sql.= " AND d.fk_product =".$this->id; + $sql .= " AND d.fk_product =".$this->id; } else { - $sql.=" AND d.fk_product > 0"; + $sql .= " AND d.fk_product > 0"; } if ($filteronproducttype >= 0) { - $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; + $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; } - $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('supplier_order').")"; + $sql .= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_soc = ".$socid; } - $sql.=$morefilter; - $sql.= " GROUP BY date_format(c.date_commande,'%Y%m')"; - $sql.= " ORDER BY date_format(c.date_commande,'%Y%m') DESC"; + $sql .= $morefilter; + $sql .= " GROUP BY date_format(c.date_commande,'%Y%m')"; + $sql .= " ORDER BY date_format(c.date_commande,'%Y%m') DESC"; return $this->_get_stats($sql, $mode, $year); } @@ -3438,17 +3438,17 @@ class Product extends CommonObject { // phpcs:enable // Clean parameters - if (! is_numeric($id_pere)) { - $id_pere=0; + if (!is_numeric($id_pere)) { + $id_pere = 0; } - if (! is_numeric($id_fils)) { - $id_fils=0; + if (!is_numeric($id_fils)) { + $id_fils = 0; } - if (! is_numeric($incdec)) { - $incdec=0; + if (!is_numeric($incdec)) { + $incdec = 0; } - $result=$this->del_sousproduit($id_pere, $id_fils); + $result = $this->del_sousproduit($id_pere, $id_fils); if ($result < 0) { return $result; } @@ -3456,7 +3456,7 @@ class Product extends CommonObject // Check not already father of id_pere (to avoid father -> child -> father links) $sql = 'SELECT fk_product_pere from '.MAIN_DB_PREFIX.'product_association'; $sql .= ' WHERE fk_product_pere = '.$id_fils.' AND fk_product_fils = '.$id_pere; - if (! $this->db->query($sql)) { + if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; } @@ -3465,15 +3465,15 @@ class Product extends CommonObject $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - if($num > 0) { - $this->error="isFatherOfThis"; + if ($num > 0) { + $this->error = "isFatherOfThis"; return -1; } else { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec)'; $sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$qty.', '.$incdec.')'; - if (! $this->db->query($sql)) { + if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; } @@ -3500,22 +3500,22 @@ class Product extends CommonObject { // phpcs:enable // Clean parameters - if (! is_numeric($id_pere)) { - $id_pere=0; + if (!is_numeric($id_pere)) { + $id_pere = 0; } - if (! is_numeric($id_fils)) { - $id_fils=0; + if (!is_numeric($id_fils)) { + $id_fils = 0; } - if (! is_numeric($incdec)) { - $incdec=1; + if (!is_numeric($incdec)) { + $incdec = 1; } - if (! is_numeric($qty)) { - $qty=1; + if (!is_numeric($qty)) { + $qty = 1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_association SET '; - $sql.= 'qty='.$qty; - $sql.= ',incdec='.$incdec; + $sql .= 'qty='.$qty; + $sql .= ',incdec='.$incdec; $sql .= ' WHERE fk_product_pere='.$id_pere.' AND fk_product_fils='.$id_fils; if (!$this->db->query($sql)) { @@ -3539,19 +3539,19 @@ class Product extends CommonObject public function del_sousproduit($fk_parent, $fk_child) { // phpcs:enable - if (! is_numeric($fk_parent)) { - $fk_parent=0; + if (!is_numeric($fk_parent)) { + $fk_parent = 0; } - if (! is_numeric($fk_child)) { - $fk_child=0; + if (!is_numeric($fk_child)) { + $fk_child = 0; } $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association"; - $sql.= " WHERE fk_product_pere = ".$fk_parent; - $sql.= " AND fk_product_fils = ".$fk_child; + $sql .= " WHERE fk_product_pere = ".$fk_parent; + $sql .= " AND fk_product_fils = ".$fk_child; dol_syslog(get_class($this).'::del_sousproduit', LOG_DEBUG); - if (! $this->db->query($sql)) { + if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; } @@ -3571,15 +3571,15 @@ class Product extends CommonObject { // phpcs:enable $sql = "SELECT fk_product_pere, qty, incdec"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_association"; - $sql.= " WHERE fk_product_pere = '".$fk_parent."'"; - $sql.= " AND fk_product_fils = '".$fk_child."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_association"; + $sql .= " WHERE fk_product_pere = '".$fk_parent."'"; + $sql .= " AND fk_product_fils = '".$fk_child."'"; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - if($num > 0) { + if ($num > 0) { $obj = $this->db->fetch_object($result); $this->is_sousproduit_qty = $obj->qty; $this->is_sousproduit_incdec = $obj->incdec; @@ -3684,7 +3684,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -3697,7 +3697,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -2; } } @@ -3717,14 +3717,14 @@ class Product extends CommonObject $list = array(); $sql = "SELECT DISTINCT p.fk_soc"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p"; - $sql.= " WHERE p.fk_product = ".$this->id; - $sql.= " AND p.entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p"; + $sql .= " WHERE p.fk_product = ".$this->id; + $sql .= " AND p.entity = ".$conf->entity; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($result); @@ -3838,11 +3838,11 @@ class Product extends CommonObject $this->db->begin(); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association (fk_product_pere, fk_product_fils, qty)'; - $sql.= " SELECT ".$toId.", fk_product_fils, qty FROM ".MAIN_DB_PREFIX."product_association"; - $sql.= " WHERE fk_product_pere = ".$fromId; + $sql .= " SELECT ".$toId.", fk_product_fils, qty FROM ".MAIN_DB_PREFIX."product_association"; + $sql .= " WHERE fk_product_pere = ".$fromId; dol_syslog(get_class($this).'::clone_association', LOG_DEBUG); - if (! $this->db->query($sql)) { + if (!$this->db->query($sql)) { $this->db->rollback(); return -1; } @@ -3864,7 +3864,7 @@ class Product extends CommonObject // phpcs:enable $this->db->begin(); - $now=dol_now(); + $now = dol_now(); // les fournisseurs /*$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur (" @@ -3881,14 +3881,14 @@ class Product extends CommonObject // les prix de fournisseurs. $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price ("; - $sql.= " datec, fk_product, fk_soc, price, quantity, fk_user)"; - $sql.= " SELECT '".$this->db->idate($now)."', ".$toId. ", fk_soc, price, quantity, fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE fk_product = ".$fromId; + $sql .= " datec, fk_product, fk_soc, price, quantity, fk_user)"; + $sql .= " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, price, quantity, fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; + $sql .= " WHERE fk_product = ".$fromId; dol_syslog(get_class($this).'::clone_fournisseurs', LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { + $resql = $this->db->query($sql); + if (!$resql) { $this->db->rollback(); return -1; } @@ -3957,7 +3957,7 @@ class Product extends CommonObject // Recursive call if there is childs to child if (is_array($desc_pere['childs'])) { //print 'YYY We go down for '.$desc_pere[3]." -> \n"; - $this->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", $desc_pere[1]*$multiply, $level+1, $id); + $this->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", $desc_pere[1] * $multiply, $level + 1, $id); } } } @@ -3976,7 +3976,7 @@ class Product extends CommonObject // phpcs:enable $this->res = array(); if (isset($this->sousprods) && is_array($this->sousprods)) { - foreach($this->sousprods as $prod_name => $desc_product) + foreach ($this->sousprods as $prod_name => $desc_product) { if (is_array($desc_product)) { $this->fetch_prod_arbo($desc_product, "", $multiply, 1, $this->id); } @@ -3996,8 +3996,8 @@ class Product extends CommonObject $nb = 0; $sql = "SELECT COUNT(pa.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa"; - $sql.= " WHERE pa.fk_product_fils = ".$this->id." OR pa.fk_product_pere = ".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa"; + $sql .= " WHERE pa.fk_product_fils = ".$this->id." OR pa.fk_product_pere = ".$this->id; $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -4021,7 +4021,7 @@ class Product extends CommonObject { $nb = 0; $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".$this->id; - $sql.= " AND entity IN (".getEntity('product').")"; + $sql .= " AND entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -4043,7 +4043,7 @@ class Product extends CommonObject { global $conf; if (!empty($conf->variants->enabled)) { - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "product_attribute_combination WHERE fk_product_child = " . $this->id . " AND entity IN (" . getEntity('product') . ")"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".$this->id." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); @@ -4069,14 +4069,14 @@ class Product extends CommonObject public function getFather() { $sql = "SELECT p.rowid, p.label as label, p.ref as ref, pa.fk_product_pere as id, p.fk_product_type, pa.qty, pa.incdec, p.entity"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa,"; - $sql.= " ".MAIN_DB_PREFIX."product as p"; - $sql.= " WHERE p.rowid = pa.fk_product_pere"; - $sql.= " AND pa.fk_product_fils = ".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa,"; + $sql .= " ".MAIN_DB_PREFIX."product as p"; + $sql .= " WHERE p.rowid = pa.fk_product_pere"; + $sql .= " AND pa.fk_product_fils = ".$this->id; $res = $this->db->query($sql); if ($res) { - $prods = array (); + $prods = array(); while ($record = $this->db->fetch_array($res)) { // $record['id'] = $record['rowid'] = id of father @@ -4085,8 +4085,8 @@ class Product extends CommonObject $prods[$record['id']]['label'] = $record['label']; $prods[$record['id']]['qty'] = $record['qty']; $prods[$record['id']]['incdec'] = $record['incdec']; - $prods[$record['id']]['fk_product_type'] = $record['fk_product_type']; - $prods[$record['id']]['entity'] = $record['entity']; + $prods[$record['id']]['fk_product_type'] = $record['fk_product_type']; + $prods[$record['id']]['entity'] = $record['entity']; } return $prods; } @@ -4111,31 +4111,31 @@ class Product extends CommonObject global $alreadyfound; $sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id, p.fk_product_type, pa.incdec"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ", ".MAIN_DB_PREFIX."product_association as pa"; - $sql.= " WHERE p.rowid = pa.fk_product_fils"; - $sql.= " AND pa.fk_product_pere = ".$id; - $sql.= " AND pa.fk_product_fils != ".$id; // This should not happens, it is to avoid infinite loop if it happens + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."product_association as pa"; + $sql .= " WHERE p.rowid = pa.fk_product_fils"; + $sql .= " AND pa.fk_product_pere = ".$id; + $sql .= " AND pa.fk_product_fils != ".$id; // This should not happens, it is to avoid infinite loop if it happens dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level, LOG_DEBUG); - if ($level == 1) { $alreadyfound=array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly + if ($level == 1) { $alreadyfound = array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly } // Protection against infinite loop if ($level > 30) { return array(); } - $res = $this->db->query($sql); + $res = $this->db->query($sql); if ($res) { $prods = array(); while ($rec = $this->db->fetch_array($res)) { - if (! empty($alreadyfound[$rec['rowid']])) { + if (!empty($alreadyfound[$rec['rowid']])) { dol_syslog(get_class($this).'::getChildsArbo the product id='.$rec['rowid'].' was already found at a higher level in tree. We discard to avoid infinite loop', LOG_WARNING); continue; } - $alreadyfound[$rec['rowid']]=1; - $prods[$rec['rowid']]= array( + $alreadyfound[$rec['rowid']] = 1; + $prods[$rec['rowid']] = array( 0=>$rec['rowid'], 1=>$rec['qty'], 2=>$rec['fk_product_type'], @@ -4145,8 +4145,8 @@ class Product extends CommonObject //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); if (empty($firstlevelonly)) { - $listofchilds=$this->getChildsArbo($rec['rowid'], 0, $level + 1); - foreach($listofchilds as $keyChild => $valueChild) + $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1); + foreach ($listofchilds as $keyChild => $valueChild) { $prods[$rec['rowid']]['childs'][$keyChild] = $valueChild; } @@ -4172,13 +4172,13 @@ class Product extends CommonObject public function get_sousproduits_arbo() { // phpcs:enable - $parent=array(); + $parent = array(); - foreach($this->getChildsArbo($this->id) as $keyChild => $valueChild) // Warning. getChildsArbo can call getChildsArbo recursively. Starting point is $value[0]=id of product + foreach ($this->getChildsArbo($this->id) as $keyChild => $valueChild) // Warning. getChildsArbo can call getChildsArbo recursively. Starting point is $value[0]=id of product { $parent[$this->label][$keyChild] = $valueChild; } - foreach($parent as $key => $value) // key=label, value is array of childs + foreach ($parent as $key => $value) // key=label, value is array of childs { $this->sousprods[$key] = $value; } @@ -4342,13 +4342,13 @@ class Product extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf,$user,$langs; + global $conf, $user, $langs; $langs->load("products"); // Positionne le modele sur le nom du modele a utiliser - if (! dol_strlen($modele)) { - if (! empty($conf->global->PRODUCT_ADDON_PDF)) { + if (!dol_strlen($modele)) { + if (!empty($conf->global->PRODUCT_ADDON_PDF)) { $modele = $conf->global->PRODUCT_ADDON_PDF; } else @@ -4402,7 +4402,7 @@ class Product extends CommonObject $labelStatus = $labelStatusShort = ''; $langs->load('products'); - if (! empty($conf->productbatch->enabled)) { $langs->load("productbatch"); + if (!empty($conf->productbatch->enabled)) { $langs->load("productbatch"); } if ($type == 2) { @@ -4417,7 +4417,7 @@ class Product extends CommonObject case 2: return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 1, 2); case 3: - return dolGetStatus($langs->trans('ProductStatusNotOnBatch'), '', '', empty($status)?'status5':'status4', 3, 'dot'); + return dolGetStatus($langs->trans('ProductStatusNotOnBatch'), '', '', empty($status) ? 'status5' : 'status4', 3, 'dot'); case 4: return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 0, 2); case 5: @@ -4508,14 +4508,14 @@ class Product extends CommonObject if ($id_entrepot) { $this->db->begin(); - include_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $op[0] = "+".trim($nbpiece); $op[1] = "-".trim($nbpiece); - $movementstock=new MouvementStock($this->db); + $movementstock = new MouvementStock($this->db); $movementstock->setOrigin($origin_element, $origin_id); - $result=$movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode); + $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode); if ($result >= 0) { $this->db->commit(); @@ -4523,8 +4523,8 @@ class Product extends CommonObject } else { - $this->error=$movementstock->error; - $this->errors=$movementstock->errors; + $this->error = $movementstock->error; + $this->errors = $movementstock->errors; $this->db->rollback(); return -1; @@ -4556,14 +4556,14 @@ class Product extends CommonObject if ($id_entrepot) { $this->db->begin(); - include_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $op[0] = "+".trim($nbpiece); $op[1] = "-".trim($nbpiece); - $movementstock=new MouvementStock($this->db); + $movementstock = new MouvementStock($this->db); $movementstock->setOrigin($origin_element, $origin_id); - $result=$movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', $dlc, $dluo, $lot); + $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', $dlc, $dluo, $lot); if ($result >= 0) { $this->db->commit(); @@ -4571,8 +4571,8 @@ class Product extends CommonObject } else { - $this->error=$movementstock->error; - $this->errors=$movementstock->errors; + $this->error = $movementstock->error; + $this->errors = $movementstock->errors; $this->db->rollback(); return -1; @@ -4612,19 +4612,19 @@ class Product extends CommonObject } $sql = "SELECT ps.rowid, ps.reel, ps.fk_entrepot"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; - $sql.= ", ".MAIN_DB_PREFIX."entrepot as w"; - $sql.= " WHERE w.entity IN (".getEntity('stock').")"; - $sql.= " AND w.rowid = ps.fk_entrepot"; - $sql.= " AND ps.fk_product = ".$this->id; - if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) { $sql.= " AND w.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= ", ".MAIN_DB_PREFIX."entrepot as w"; + $sql .= " WHERE w.entity IN (".getEntity('stock').")"; + $sql .= " AND w.rowid = ps.fk_entrepot"; + $sql .= " AND ps.fk_product = ".$this->id; + if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) { $sql .= " AND w.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")"; } dol_syslog(get_class($this)."::load_stock", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $i=0; + $i = 0; if ($num > 0) { while ($i < $num) { @@ -4632,23 +4632,23 @@ class Product extends CommonObject $this->stock_warehouse[$row->fk_entrepot] = new stdClass(); $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; $this->stock_warehouse[$row->fk_entrepot]->id = $row->rowid; - if ((! preg_match('/nobatch/', $option)) && $this->hasbatch()) { $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db, $row->rowid, 1, $this->id); + if ((!preg_match('/nobatch/', $option)) && $this->hasbatch()) { $this->stock_warehouse[$row->fk_entrepot]->detail_batch = Productbatch::findAll($this->db, $row->rowid, 1, $this->id); } - $this->stock_reel+=$row->reel; + $this->stock_reel += $row->reel; $i++; } } $this->db->free($result); - if (! preg_match('/novirtual/', $option)) { - $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... + if (!preg_match('/novirtual/', $option)) { + $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... } return 1; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -4667,66 +4667,66 @@ class Product extends CommonObject // phpcs:enable global $conf, $hookmanager, $action; - $stock_commande_client=0; - $stock_commande_fournisseur=0; - $stock_sending_client=0; - $stock_reception_fournisseur=0; + $stock_commande_client = 0; + $stock_commande_fournisseur = 0; + $stock_sending_client = 0; + $stock_reception_fournisseur = 0; - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { - $result=$this->load_stats_commande(0, '1,2', 1); + $result = $this->load_stats_commande(0, '1,2', 1); if ($result < 0) dol_print_error($this->db, $this->error); - $stock_commande_client=$this->stats_commande['qty']; + $stock_commande_client = $this->stats_commande['qty']; } - if (! empty($conf->expedition->enabled)) + if (!empty($conf->expedition->enabled)) { - $result=$this->load_stats_sending(0, '1,2', 1); + $result = $this->load_stats_sending(0, '1,2', 1); if ($result < 0) dol_print_error($this->db, $this->error); - $stock_sending_client=$this->stats_expedition['qty']; + $stock_sending_client = $this->stats_expedition['qty']; } - if (! empty($conf->fournisseur->enabled)) + if (!empty($conf->fournisseur->enabled)) { - $result=$this->load_stats_commande_fournisseur(0, '1,2,3,4', 1); + $result = $this->load_stats_commande_fournisseur(0, '1,2,3,4', 1); if ($result < 0) dol_print_error($this->db, $this->error); - $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; + $stock_commande_fournisseur = $this->stats_commande_fournisseur['qty']; - $result=$this->load_stats_reception(0, '4', 1); + $result = $this->load_stats_reception(0, '4', 1); if ($result < 0) dol_print_error($this->db, $this->error); - $stock_reception_fournisseur=$this->stats_reception['qty']; + $stock_reception_fournisseur = $this->stats_reception['qty']; } // Stock decrease mode - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { - $this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + $this->stock_theorique = $this->stock_reel - $stock_commande_client + $stock_sending_client; } - if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { - $this->stock_theorique=$this->stock_reel; + if (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { + $this->stock_theorique = $this->stock_reel; } - if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) { - $this->stock_theorique=$this->stock_reel-$stock_commande_client; + if (!empty($conf->global->STOCK_CALCULATE_ON_BILL)) { + $this->stock_theorique = $this->stock_reel - $stock_commande_client; } // Stock Increase mode - if (! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { - $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; + if (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { + $this->stock_theorique += $stock_commande_fournisseur - $stock_reception_fournisseur; } - if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { - $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; + if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { + $this->stock_theorique += $stock_commande_fournisseur - $stock_reception_fournisseur; } - if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { - $this->stock_theorique-=$stock_reception_fournisseur; + if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { + $this->stock_theorique -= $stock_reception_fournisseur; } - if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { - $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; + if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { + $this->stock_theorique += $stock_commande_fournisseur - $stock_reception_fournisseur; } - if (! is_object($hookmanager)) { + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('productdao')); - $parameters=array('id'=>$this->id); + $parameters = array('id'=>$this->id); // Note that $action and $object may have been modified by some hooks - $reshook=$hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action); + $reshook = $hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action); if ($reshook > 0) $this->stock_theorique = $hookmanager->resArray['stock_theorique']; return 1; @@ -4742,20 +4742,20 @@ class Product extends CommonObject */ public function loadBatchInfo($batch) { - $result=array(); + $result = array(); $sql = "SELECT pb.batch, pb.eatby, pb.sellby, SUM(pb.qty) AS qty FROM ".MAIN_DB_PREFIX."product_batch as pb, ".MAIN_DB_PREFIX."product_stock as ps"; - $sql.= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = ".$this->id." AND pb.batch = '".$this->db->escape($batch)."'"; - $sql.= " GROUP BY pb.batch, pb.eatby, pb.sellby"; + $sql .= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = ".$this->id." AND pb.batch = '".$this->db->escape($batch)."'"; + $sql .= " GROUP BY pb.batch, pb.eatby, pb.sellby"; dol_syslog(get_class($this)."::loadBatchInfo load first entry found for lot/serial = ".$batch, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - $result[]=array('batch'=>$batch, 'eatby'=>$this->db->jdate($obj->eatby), 'sellby'=>$this->db->jdate($obj->sellby), 'qty'=>$obj->qty); + $result[] = array('batch'=>$batch, 'eatby'=>$this->db->jdate($obj->eatby), 'sellby'=>$this->db->jdate($obj->sellby), 'qty'=>$obj->qty); $i++; } return $result; @@ -4786,21 +4786,21 @@ class Product extends CommonObject $result = 0; $dir = $sdir; - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $dir .= '/'. get_exdir($this->id, 2, 0, 0, $this, 'product') . $this->id ."/photos"; + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { + $dir .= '/'.get_exdir($this->id, 2, 0, 0, $this, 'product').$this->id."/photos"; } else { $dir .= '/'.get_exdir(0, 0, 0, 0, $this, 'product').dol_sanitizeFileName($this->ref); } dol_mkdir($dir); - $dir_osencoded=$dir; + $dir_osencoded = $dir; if (is_dir($dir_osencoded)) { - $originImage = $dir . '/' . $file['name']; + $originImage = $dir.'/'.$file['name']; // Cree fichier en taille origine - $result=dol_move_uploaded_file($file['tmp_name'], $originImage, 1); + $result = dol_move_uploaded_file($file['tmp_name'], $originImage, 1); if (file_exists(dol_osencode($originImage))) { // Create thumbs @@ -4825,25 +4825,25 @@ class Product extends CommonObject public function is_photo_available($sdir) { // phpcs:enable - include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; - include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; global $conf; $dir = $sdir; - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { $dir .= '/'. get_exdir($this->id, 2, 0, 0, $this, 'product') . $this->id ."/photos/"; + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { $dir .= '/'.get_exdir($this->id, 2, 0, 0, $this, 'product').$this->id."/photos/"; } else { $dir .= '/'.get_exdir(0, 0, 0, 0, $this, 'product').dol_sanitizeFileName($this->ref).'/'; } - $nbphoto=0; + $nbphoto = 0; - $dir_osencoded=dol_osencode($dir); + $dir_osencoded = dol_osencode($dir); if (file_exists($dir_osencoded)) { - $handle=opendir($dir_osencoded); + $handle = opendir($dir_osencoded); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (! utf8_check($file)) { $file=utf8_encode($file); // To be sure data is stored in UTF8 in memory + if (!utf8_check($file)) { $file = utf8_encode($file); // To be sure data is stored in UTF8 in memory } if (dol_is_file($dir.$file) && image_format_supported($file) > 0) { return true; } @@ -4867,36 +4867,36 @@ class Product extends CommonObject include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $nbphoto=0; - $tabobj=array(); + $nbphoto = 0; + $tabobj = array(); - $dir_osencoded=dol_osencode($dir); - $handle=@opendir($dir_osencoded); + $dir_osencoded = dol_osencode($dir); + $handle = @opendir($dir_osencoded); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (! utf8_check($file)) { $file=utf8_encode($file); // readdir returns ISO + if (!utf8_check($file)) { $file = utf8_encode($file); // readdir returns ISO } if (dol_is_file($dir.$file) && image_format_supported($file) >= 0) { $nbphoto++; // On determine nom du fichier vignette - $photo=$file; - $photo_vignette=''; + $photo = $file; + $photo_vignette = ''; if (preg_match('/('.$this->regeximgext.')$/i', $photo, $regs)) { - $photo_vignette=preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; + $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; } $dirthumb = $dir.'thumbs/'; // Objet - $obj=array(); - $obj['photo']=$photo; - if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) { $obj['photo_vignette']='thumbs/' . $photo_vignette; - } else { $obj['photo_vignette']=""; + $obj = array(); + $obj['photo'] = $photo; + if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) { $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; + } else { $obj['photo_vignette'] = ""; } - $tabobj[$nbphoto-1]=$obj; + $tabobj[$nbphoto - 1] = $obj; // On continue ou on arrete de boucler ? if ($nbmax && $nbphoto >= $nbmax) { break; @@ -4932,12 +4932,12 @@ class Product extends CommonObject // Si elle existe, on efface la vignette if (preg_match('/('.$this->regeximgext.')$/i', $filename, $regs)) { - $photo_vignette=preg_replace('/'.$regs[0].'/i', '', $filename).'_small'.$regs[0]; + $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $filename).'_small'.$regs[0]; if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { dol_delete_file($dirthumb.$photo_vignette); } - $photo_vignette=preg_replace('/'.$regs[0].'/i', '', $filename).'_mini'.$regs[0]; + $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $filename).'_mini'.$regs[0]; if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { dol_delete_file($dirthumb.$photo_vignette); } @@ -4954,7 +4954,7 @@ class Product extends CommonObject public function get_image_size($file) { // phpcs:enable - $file_osencoded=dol_osencode($file); + $file_osencoded = dol_osencode($file); $infoImg = getimagesize($file_osencoded); // Get information on image $this->imgWidth = $infoImg[0]; // Largeur de l'image $this->imgHeight = $infoImg[1]; // Hauteur de l'image @@ -4971,25 +4971,25 @@ class Product extends CommonObject // phpcs:enable global $conf, $user, $hookmanager; - $this->nb=array(); + $this->nb = array(); $sql = "SELECT count(p.rowid) as nb, fk_product_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ' WHERE p.entity IN ('.getEntity($this->element, 1).')'; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ' WHERE p.entity IN ('.getEntity($this->element, 1).')'; // Add where from hooks if (is_object($hookmanager)) { - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } - $sql.= ' GROUP BY fk_product_type'; + $sql .= ' GROUP BY fk_product_type'; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - if ($obj->fk_product_type == 1) { $this->nb["services"]=$obj->nb; - } else { $this->nb["products"]=$obj->nb; + if ($obj->fk_product_type == 1) { $this->nb["services"] = $obj->nb; + } else { $this->nb["products"] = $obj->nb; } } $this->db->free($resql); @@ -4998,7 +4998,7 @@ class Product extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -5037,19 +5037,19 @@ class Product extends CommonObject // phpcs:enable global $conf; - $result=''; - if (! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { - $dirsociete=array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); + $result = ''; + if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { + $dirsociete = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$conf->global->BARCODE_PRODUCT_ADDON_NUM.'.php'); + $res = dol_include_once($dirroot.$conf->global->BARCODE_PRODUCT_ADDON_NUM.'.php'); if ($res) { break; } } $var = $conf->global->BARCODE_PRODUCT_ADDON_NUM; $mod = new $var; - $result=$mod->getNextValue($object, $type); + $result = $mod->getNextValue($object, $type); dol_syslog(get_class($this)."::get_barcode barcode=".$result." module=".$var); } @@ -5065,22 +5065,22 @@ class Product extends CommonObject */ public function initAsSpecimen() { - global $user,$langs,$conf,$mysoc; + global $user, $langs, $conf, $mysoc; - $now=dol_now(); + $now = dol_now(); // Initialize parameters - $this->specimen=1; - $this->id=0; + $this->specimen = 1; + $this->id = 0; $this->ref = 'PRODUCT_SPEC'; $this->label = 'PRODUCT SPECIMEN'; $this->description = 'This is description of this product specimen that was created the '.dol_print_date($now, 'dayhourlog').'.'; - $this->specimen=1; - $this->country_id=1; - $this->tosell=1; - $this->tobuy=1; - $this->tobatch=0; - $this->note='This is a comment (private)'; + $this->specimen = 1; + $this->country_id = 1; + $this->tosell = 1; + $this->tobuy = 1; + $this->tobatch = 0; + $this->note = 'This is a comment (private)'; $this->date_creation = $now; $this->date_modification = $now; @@ -5099,7 +5099,7 @@ class Product extends CommonObject $this->volume = 300; $this->volume_unit = 0; - $this->barcode=-1; // Create barcode automatically + $this->barcode = -1; // Create barcode automatically } /** @@ -5126,7 +5126,7 @@ class Product extends CommonObject $sql = 'select '.$label_type.' from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit; $resql = $this->db->query($sql); - if($resql && $this->db->num_rows($resql) > 0) { + if ($resql && $this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); $label = $res[$label_type]; $this->db->free($resql); @@ -5134,7 +5134,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error = $this->db->error().' sql='.$sql; dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR); return -1; } @@ -5162,15 +5162,15 @@ class Product extends CommonObject // phpcs:enable global $conf; - $maxpricesupplier=0; + $maxpricesupplier = 0; - if (! empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $product_fourn = new ProductFournisseur($this->db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($this->id, '', ''); - if (is_array($product_fourn_list) && count($product_fourn_list)>0) { - foreach($product_fourn_list as $productfourn) + if (is_array($product_fourn_list) && count($product_fourn_list) > 0) { + foreach ($product_fourn_list as $productfourn) { if ($productfourn->fourn_unitprice > $maxpricesupplier) { $maxpricesupplier = $productfourn->fourn_unitprice; @@ -5198,12 +5198,12 @@ class Product extends CommonObject public function setCategories($categories) { // Handle single category - if (! is_array($categories)) { + if (!is_array($categories)) { $categories = array($categories); } // Get current categories - include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, Categorie::TYPE_PRODUCT, 'id'); @@ -5217,7 +5217,7 @@ class Product extends CommonObject } // Process - foreach($to_del as $del) { + foreach ($to_del as $del) { if ($c->fetch($del) > 0) { $c->del_type($this, Categorie::TYPE_PRODUCT); } @@ -5285,14 +5285,14 @@ class Product extends CommonObject //We have to make sure it does exist and it is > 0 //First price level only allows changing min_price if ($i > 1 && isset($rules[$i]->var_percent) && $rules[$i]->var_percent) { - $price = $prices[$rules[$i]->fk_level] * (1 + ($rules[$i]->var_percent/100)); + $price = $prices[$rules[$i]->fk_level] * (1 + ($rules[$i]->var_percent / 100)); } $prices[$i] = $price; //We have to make sure it does exist and it is > 0 if (isset($rules[$i]->var_min_percent) && $rules[$i]->var_min_percent) { - $price_min = $price * (1 - ($rules[$i]->var_min_percent/100)); + $price_min = $price * (1 - ($rules[$i]->var_min_percent / 100)); } //Little check to make sure the price is modified before triggering generation @@ -5336,11 +5336,11 @@ class Product extends CommonObject public function info($id) { $sql = "SELECT p.rowid, p.ref, p.datec as date_creation, p.tms as date_modification,"; - $sql.= " p.fk_user_author, p.fk_user_modif"; - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p"; - $sql.= " WHERE p.rowid = ".$id; + $sql .= " p.fk_user_author, p.fk_user_modif"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p"; + $sql .= " WHERE p.rowid = ".$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); @@ -5350,7 +5350,7 @@ class Product extends CommonObject if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_modif) { @@ -5359,7 +5359,7 @@ class Product extends CommonObject $this->user_modification = $muser; } - $this->ref = $obj->ref; + $this->ref = $obj->ref; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); } diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 54ceff8eb9d..a0a85bbec94 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -33,15 +33,15 @@ class Productbatch extends CommonObject /** * @var string ID to identify managed object */ - public $element='productbatch'; + public $element = 'productbatch'; - private static $_table_element='product_batch'; //!< Name of table without prefix where object is stored + private static $_table_element = 'product_batch'; //!< Name of table without prefix where object is stored - public $tms=''; + public $tms = ''; public $fk_product_stock; - public $sellby=''; - public $eatby=''; - public $batch=''; + public $sellby = ''; + public $eatby = ''; + public $batch = ''; public $qty; public $warehouseid; @@ -73,7 +73,7 @@ class Productbatch extends CommonObject public function create($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters $this->cleanParam(); @@ -83,32 +83,32 @@ class Productbatch extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_batch ("; - $sql.= "fk_product_stock,"; - $sql.= "sellby,"; - $sql.= "eatby,"; - $sql.= "batch,"; - $sql.= "qty,"; - $sql.= "import_key"; - $sql.= ") VALUES ("; - $sql.= " ".(! isset($this->fk_product_stock)?'NULL':$this->fk_product_stock).","; - $sql.= " ".(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':"'".$this->db->idate($this->sellby)."'").","; - $sql.= " ".(! isset($this->eatby) || dol_strlen($this->eatby)==0?'NULL':"'".$this->db->idate($this->eatby)."'").","; - $sql.= " ".(! isset($this->batch)?'NULL':"'".$this->db->escape($this->batch)."'").","; - $sql.= " ".(! isset($this->qty)?'NULL':$this->qty).","; - $sql.= " ".(! isset($this->import_key)?'NULL':"'".$this->db->escape($this->import_key)."'").""; + $sql .= "fk_product_stock,"; + $sql .= "sellby,"; + $sql .= "eatby,"; + $sql .= "batch,"; + $sql .= "qty,"; + $sql .= "import_key"; + $sql .= ") VALUES ("; + $sql .= " ".(!isset($this->fk_product_stock) ? 'NULL' : $this->fk_product_stock).","; + $sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'".$this->db->idate($this->sellby)."'").","; + $sql .= " ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'".$this->db->idate($this->eatby)."'").","; + $sql .= " ".(!isset($this->batch) ? 'NULL' : "'".$this->db->escape($this->batch)."'").","; + $sql .= " ".(!isset($this->qty) ? 'NULL' : $this->qty).","; + $sql .= " ".(!isset($this->import_key) ? 'NULL' : "'".$this->db->escape($this->import_key)."'").""; - $sql.= ")"; + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.self::$_table_element); - if (! $notrigger) + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -126,7 +126,7 @@ class Productbatch extends CommonObject if ($error) { $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -146,23 +146,23 @@ class Productbatch extends CommonObject { global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; + $sql .= " t.rowid,"; - $sql.= " t.tms,"; - $sql.= " t.fk_product_stock,"; - $sql.= " t.sellby as oldsellby,"; - $sql.= " t.eatby as oldeatby,"; - $sql.= " t.batch,"; - $sql.= " t.qty,"; - $sql.= " t.import_key,"; - $sql.= " w.fk_entrepot,"; - $sql.= " w.fk_product,"; - $sql.= " pl.eatby,"; - $sql.= " pl.sellby"; + $sql .= " t.tms,"; + $sql .= " t.fk_product_stock,"; + $sql .= " t.sellby as oldsellby,"; + $sql .= " t.eatby as oldeatby,"; + $sql .= " t.batch,"; + $sql .= " t.qty,"; + $sql .= " t.import_key,"; + $sql .= " w.fk_entrepot,"; + $sql .= " w.fk_product,"; + $sql .= " pl.eatby,"; + $sql .= " pl.sellby"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as t INNER JOIN ".MAIN_DB_PREFIX."product_stock w on t.fk_product_stock = w.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl on pl.fk_product = w.fk_product and pl.batch = t.batch"; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as t INNER JOIN ".MAIN_DB_PREFIX."product_stock w on t.fk_product_stock = w.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl on pl.fk_product = w.fk_product and pl.batch = t.batch"; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); @@ -172,16 +172,16 @@ class Productbatch extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->tms = $this->db->jdate($obj->tms); $this->fk_product_stock = $obj->fk_product_stock; - $this->sellby = $this->db->jdate($obj->sellby?$obj->sellby:$obj->oldsellby); - $this->eatby = $this->db->jdate($obj->eatby?$obj->eatby:$obj->oldeatby); + $this->sellby = $this->db->jdate($obj->sellby ? $obj->sellby : $obj->oldsellby); + $this->eatby = $this->db->jdate($obj->eatby ? $obj->eatby : $obj->oldeatby); $this->batch = $obj->batch; $this->qty = $obj->qty; $this->import_key = $obj->import_key; - $this->warehouseid= $obj->fk_entrepot; - $this->fk_product= $obj->fk_product; + $this->warehouseid = $obj->fk_entrepot; + $this->fk_product = $obj->fk_product; } $this->db->free($resql); @@ -204,7 +204,7 @@ class Productbatch extends CommonObject public function update($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters $this->cleanParam(); @@ -248,13 +248,13 @@ class Productbatch extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -273,13 +273,13 @@ class Productbatch extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; $this->db->begin(); - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -293,26 +293,26 @@ class Productbatch extends CommonObject } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.self::$_table_element.""; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -365,7 +365,7 @@ class Productbatch extends CommonObject unset($object->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $object->id; @@ -386,14 +386,14 @@ class Productbatch extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->tms=''; - $this->fk_product_stock=''; - $this->sellby=''; - $this->eatby=''; - $this->batch=''; - $this->import_key=''; + $this->tms = ''; + $this->fk_product_stock = ''; + $this->sellby = ''; + $this->eatby = ''; + $this->batch = ''; + $this->import_key = ''; } /** @@ -403,10 +403,10 @@ class Productbatch extends CommonObject */ private function cleanParam() { - if (isset($this->fk_product_stock)) $this->fk_product_stock=(int) trim($this->fk_product_stock); - if (isset($this->batch)) $this->batch=trim($this->batch); - if (isset($this->qty)) $this->qty=(float) trim($this->qty); - if (isset($this->import_key)) $this->import_key=trim($this->import_key); + if (isset($this->fk_product_stock)) $this->fk_product_stock = (int) trim($this->fk_product_stock); + if (isset($this->batch)) $this->batch = trim($this->batch); + if (isset($this->qty)) $this->qty = (float) trim($this->qty); + if (isset($this->import_key)) $this->import_key = trim($this->import_key); } /** @@ -424,33 +424,33 @@ class Productbatch extends CommonObject $where = array(); $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.tms,"; - $sql.= " t.fk_product_stock,"; - $sql.= " t.sellby,"; // deprecated - $sql.= " t.eatby,"; // deprecated - $sql.= " t.batch,"; - $sql.= " t.qty,"; - $sql.= " t.import_key"; - $sql.= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as t"; - $sql.= " WHERE fk_product_stock=".$fk_product_stock; + $sql .= " t.rowid,"; + $sql .= " t.tms,"; + $sql .= " t.fk_product_stock,"; + $sql .= " t.sellby,"; // deprecated + $sql .= " t.eatby,"; // deprecated + $sql .= " t.batch,"; + $sql .= " t.qty,"; + $sql .= " t.import_key"; + $sql .= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as t"; + $sql .= " WHERE fk_product_stock=".$fk_product_stock; - if (! empty($eatby)) array_push($where, " eatby = '".$this->db->idate($eatby)."'"); // deprecated - if (! empty($sellby)) array_push($where, " sellby = '".$this->db->idate($sellby)."'"); // deprecated + if (!empty($eatby)) array_push($where, " eatby = '".$this->db->idate($eatby)."'"); // deprecated + if (!empty($sellby)) array_push($where, " sellby = '".$this->db->idate($sellby)."'"); // deprecated - if (! empty($batch_number)) $sql.= " AND batch = '".$this->db->escape($batch_number)."'"; + if (!empty($batch_number)) $sql .= " AND batch = '".$this->db->escape($batch_number)."'"; - if (! empty($where)) $sql.= " AND (".implode(" OR ", $where).")"; + if (!empty($where)) $sql .= " AND (".implode(" OR ", $where).")"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->tms = $this->db->jdate($obj->tms); $this->fk_product_stock = $obj->fk_product_stock; @@ -466,7 +466,7 @@ class Productbatch extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -485,33 +485,33 @@ class Productbatch extends CommonObject $ret = array(); $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.tms,"; - $sql.= " t.fk_product_stock,"; - $sql.= " t.sellby as oldsellby,"; // deprecated but may not be migrated into new table - $sql.= " t.eatby as oldeatby,"; // deprecated but may not be migrated into new table - $sql.= " t.batch,"; - $sql.= " t.qty,"; - $sql.= " t.import_key"; + $sql .= " t.rowid,"; + $sql .= " t.tms,"; + $sql .= " t.fk_product_stock,"; + $sql .= " t.sellby as oldsellby,"; // deprecated but may not be migrated into new table + $sql .= " t.eatby as oldeatby,"; // deprecated but may not be migrated into new table + $sql .= " t.batch,"; + $sql .= " t.qty,"; + $sql .= " t.import_key"; if ($fk_product > 0) { - $sql.= ", pl.rowid as lotid, pl.eatby as eatby, pl.sellby as sellby"; + $sql .= ", pl.rowid as lotid, pl.eatby as eatby, pl.sellby as sellby"; // TODO May add extrafields to ? } - $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as t"; if ($fk_product > 0) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON pl.fk_product = ".$fk_product." AND pl.batch = t.batch"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON pl.fk_product = ".$fk_product." AND pl.batch = t.batch"; // TODO May add extrafields to ? } - $sql.= " WHERE fk_product_stock=".$fk_product_stock; - if ($with_qty) $sql.= " AND t.qty <> 0"; + $sql .= " WHERE fk_product_stock=".$fk_product_stock; + if ($with_qty) $sql .= " AND t.qty <> 0"; dol_syslog("productbatch::findAll", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); @@ -527,7 +527,7 @@ class Productbatch extends CommonObject $tmp->qty = $obj->qty; $tmp->import_key = $obj->import_key; - $ret[$tmp->batch] = $tmp; // $ret is for a $fk_product_stock and unique key is on $fk_product_stock+batch + $ret[$tmp->batch] = $tmp; // $ret is for a $fk_product_stock and unique key is on $fk_product_stock+batch $i++; } $db->free($resql); @@ -536,7 +536,7 @@ class Productbatch extends CommonObject } else { - $error="Error ".$db->lasterror(); + $error = "Error ".$db->lasterror(); return -1; } } diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 7f893faad19..ca3a0c114d8 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -25,7 +25,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -83,7 +83,7 @@ class Inventory extends CommonObject /** * @var array Array with all fields and their property */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), 'ref' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Reference of object', 'css'=>'maxwidth200'), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), @@ -208,8 +208,8 @@ class Inventory extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0; } @@ -344,37 +344,37 @@ class Inventory extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; $companylink = ''; - $label = '' . $langs->trans("Inventory") . ''; - $label.= '
        '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("Inventory").''; + $label .= '
        '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/product/inventory/card.php', 1).'?id='.$this->id; - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowInventory"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowInventory"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -422,10 +422,10 @@ class Inventory extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -436,7 +436,7 @@ class Inventory extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -450,7 +450,7 @@ class Inventory extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index cea14170602..37cf5fe31a2 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -54,36 +54,36 @@ $langs->load("projects"); */ $now = dol_now(); -$tmp=dol_getdate($now); -$day=$tmp['mday']; -$month=$tmp['mon']; -$year=$tmp['year']; +$tmp = dol_getdate($now); +$day = $tmp['mday']; +$month = $tmp['mon']; +$year = $tmp['year']; -$projectstatic=new Project($db); -$taskstatic=new Task($db); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project -$taskstatic=new Task($db); -$tasktmp=new Task($db); +$projectstatic = new Project($db); +$taskstatic = new Task($db); +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project +$taskstatic = new Task($db); +$tasktmp = new Task($db); -$title=$langs->trans("Activities"); +$title = $langs->trans("Activities"); //if ($mine) $title=$langs->trans("MyActivities"); llxHeader("", $title); // Title for combo list see all projects -$titleall=$langs->trans("AllAllowedProjects"); -if (! empty($user->rights->projet->all->lire) && ! $socid) $titleall=$langs->trans("AllProjects"); -else $titleall=$langs->trans("AllAllowedProjects").'

        '; +$titleall = $langs->trans("AllAllowedProjects"); +if (!empty($user->rights->projet->all->lire) && !$socid) $titleall = $langs->trans("AllProjects"); +else $titleall = $langs->trans("AllAllowedProjects").'

        '; -$morehtml=''; -$morehtml.='
        '; -$morehtml.=''; -$morehtml.=''; +$morehtml = ''; +$morehtml .= ''; +$morehtml .= ''; +$morehtml .= ''; print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'project', 0, $morehtml); //print load_fiche_titre($title, '', 'project'); @@ -91,7 +91,7 @@ print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'proje if ($mine) print $langs->trans("MyTasksDesc").'

        '; else { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("TasksDesc").'

        '; + if ($user->rights->projet->all->lire && !$socid) print $langs->trans("TasksDesc").'

        '; else print $langs->trans("TasksPublicDesc").'

        '; } @@ -99,12 +99,12 @@ else print '
        '; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search project - if (! empty($conf->projet->enabled) && $user->rights->projet->lire) + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { - $listofsearchfields['search_task']=array('text'=>'Task'); + $listofsearchfields['search_task'] = array('text'=>'Task'); } if (count($listofsearchfields)) @@ -113,8 +113,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; print '
        '; print ''; - $i=0; - foreach($listofsearchfields as $key => $value) + $i = 0; + foreach ($listofsearchfields as $key => $value) { if ($i == 0) print ''; print ''; @@ -140,30 +140,30 @@ print ''; print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; -$sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; -$sql.= " WHERE t.fk_projet = p.rowid"; -$sql.= " AND p.entity = ".$conf->entity; -$sql.= " AND tt.fk_task = t.rowid"; -$sql.= " AND tt.fk_user = ".$user->id; -$sql.= " AND task_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; -$sql.= " AND p.rowid in (".$projectsListId.")"; -$sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; +$sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; +$sql .= " WHERE t.fk_projet = p.rowid"; +$sql .= " AND p.entity = ".$conf->entity; +$sql .= " AND tt.fk_task = t.rowid"; +$sql .= " AND tt.fk_user = ".$user->id; +$sql .= " AND task_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; +$sql .= " AND p.rowid in (".$projectsListId.")"; +$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); -if ( $resql ) +if ($resql) { - $total=0; + $total = 0; while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -197,30 +197,30 @@ print ''; print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; -$sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; -$sql.= " WHERE t.fk_projet = p.rowid"; -$sql.= " AND p.entity = ".$conf->entity; -$sql.= " AND tt.fk_task = t.rowid"; -$sql.= " AND tt.fk_user = ".$user->id; -$sql.= " AND task_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'"; -$sql.= " AND p.rowid in (".$projectsListId.")"; -$sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; +$sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; +$sql .= " WHERE t.fk_projet = p.rowid"; +$sql .= " AND p.entity = ".$conf->entity; +$sql .= " AND tt.fk_task = t.rowid"; +$sql .= " AND tt.fk_user = ".$user->id; +$sql .= " AND task_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'"; +$sql .= " AND p.rowid in (".$projectsListId.")"; +$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); -if ( $resql ) +if ($resql) { - $total=0; + $total = 0; while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -304,7 +304,7 @@ if ($db->type != 'pgsql') */ /* Affichage de la liste des projets du mois */ -if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) +if (!empty($conf->global->PROJECT_TASK_TIME_MONTH)) { print '
        '; print '
        '.$langs->trans("Search").'
        '.$langs->trans("Time").'
        '; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - $projectstatic->public=$row->public; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; + $projectstatic->public = $row->public; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').''.$langs->trans("Time").'
        '; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - $projectstatic->public=$row->public; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; + $projectstatic->public = $row->public; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').'
        '; @@ -314,27 +314,27 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; - $sql.= " WHERE t.fk_projet = p.rowid"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND tt.fk_task = t.rowid"; - $sql.= " AND tt.fk_user = ".$user->id; - $sql.= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'"; - $sql.= " AND p.rowid in (".$projectsListId.")"; - $sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; + $sql .= " WHERE t.fk_projet = p.rowid"; + $sql .= " AND p.entity = ".$conf->entity; + $sql .= " AND tt.fk_task = t.rowid"; + $sql .= " AND tt.fk_user = ".$user->id; + $sql .= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'"; + $sql .= " AND p.rowid in (".$projectsListId.")"; + $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -355,7 +355,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) } /* Affichage de la liste des projets de l'annee */ -if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) +if (!empty($conf->global->PROJECT_TASK_TIME_YEAR)) { print '
        '; print '
        '; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').'
        '; @@ -365,28 +365,28 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; - $sql.= " WHERE t.fk_projet = p.rowid"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND tt.fk_task = t.rowid"; - $sql.= " AND tt.fk_user = ".$user->id; - $sql.= " AND YEAR(task_date) = '".strftime("%Y", $now)."'"; - $sql.= " AND p.rowid in (".$projectsListId.")"; - $sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; + $sql .= " WHERE t.fk_projet = p.rowid"; + $sql .= " AND p.entity = ".$conf->entity; + $sql .= " AND tt.fk_task = t.rowid"; + $sql .= " AND tt.fk_user = ".$user->id; + $sql .= " AND YEAR(task_date) = '".strftime("%Y", $now)."'"; + $sql .= " AND p.rowid in (".$projectsListId.")"; + $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -406,72 +406,72 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) print ''; } -if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA)) +if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA)) { // Get id of types of contacts for projects (This list never contains a lot of elements) - $listofprojectcontacttype=array(); + $listofprojectcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sql.= " WHERE ctc.element = '" . $projectstatic->element . "'"; - $sql.= " AND ctc.source = 'internal'"; + $sql .= " WHERE ctc.element = '".$projectstatic->element."'"; + $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listofprojectcontacttype[$obj->rowid]=$obj->code; + $listofprojectcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); - if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found + if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found // Get id of types of contacts for tasks (This list never contains a lot of elements) - $listoftaskcontacttype=array(); + $listoftaskcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sql.= " WHERE ctc.element = '" . $taskstatic->element . "'"; - $sql.= " AND ctc.source = 'internal'"; + $sql .= " WHERE ctc.element = '".$taskstatic->element."'"; + $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listoftaskcontacttype[$obj->rowid]=$obj->code; + $listoftaskcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); - if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found + if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found // Tasks for all resources of all opened projects and time spent for each task/resource // This list can be very long, so we don't show it by default on task area. We prefer to use the list page. // Add constant PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA to show this list - $max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA); + $max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA) ? 1000 : $conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA); $sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdateo, p.datee as projdatee,"; - $sql.= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid"; + $sql .= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid"; if ($mine) { - $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ect"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect"; } - $sql.= " WHERE p.entity IN (".getEntity('project').")"; - if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; // project i have permission on + $sql .= " WHERE p.entity IN (".getEntity('project').")"; + if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; // project i have permission on if ($mine) // this may duplicate record if we are contact twice { - $sql.= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id; + $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id; } - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - $sql.= " AND p.fk_statut=1"; - $sql.= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee"; - $sql.= " ORDER BY t.dateo desc, t.rowid desc, t.datee"; - $sql.= $db->plimit($max+1); // We want more to know if we have more than limit + if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + $sql .= " AND p.fk_statut=1"; + $sql .= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee"; + $sql .= " ORDER BY t.dateo desc, t.rowid desc, t.datee"; + $sql .= $db->plimit($max + 1); // We want more to know if we have more than limit dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG); $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -483,7 +483,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print ''; //print ''; print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print ''; print ''; print ''; print ''; @@ -511,11 +511,11 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S $taskstatic->dateo = $db->jdate($obj->dateo); $taskstatic->datee = $db->jdate($obj->datee); - $username=''; + $username = ''; if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user { - $result=$userstatic->fetch($obj->userid); - if (! $result) $userstatic->id=0; + $result = $userstatic->fetch($obj->userid); + if (!$result) $userstatic->id = 0; } if ($userstatic->id) $username = $userstatic->getNomUrl(0, 0); @@ -524,7 +524,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print ''; } print ''; print ''; print ''; print "\n"; @@ -572,8 +572,8 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S if ($num > $max) { - $colspan=6; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++; + $colspan = 6; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++; print ''; } diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 77dcaa641d2..7d581622bd6 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -115,9 +115,9 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Definition of fields for list -$arrayfields=array(); -$arrayfields['t.planned_workload']=array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); -$arrayfields['t.progress']=array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields = array(); +$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); /*$arrayfields=array( // Project 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), @@ -151,7 +151,7 @@ $search_array_options_task=$extrafields->getOptionalsFromPost($object->table_ele 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 { $action = ''; - $search_categ=''; + $search_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -163,7 +163,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_array_options_task = array(); // We redefine $usertoprocess - $usertoprocess=$user; + $usertoprocess = $user; } if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) { @@ -196,35 +196,35 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors'); $error++; } - if (! GETPOST('type')) + if (!GETPOST('type')) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } - if (! $error) + if (!$error) { - $idfortaskuser=$usertoprocess->id; + $idfortaskuser = $usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); if ($result >= 0 || $result == -2) // Contact add ok or already contact of task { // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) - $sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; - $sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; - $resql=$db->query($sql); + $sql = 'SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; + $sql .= ' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); - if (! $obj) // User is not already linked to project, so we will create link to first type + $obj = $db->fetch_object($resql); + if (!$obj) // User is not already linked to project, so we will create link to first type { $project = new Project($db); $project->fetch($object->fk_project); // Get type - $listofprojcontact=$project->liste_type_contact('internal'); + $listofprojcontact = $project->liste_type_contact('internal'); if (count($listofprojcontact)) { - $typeforprojectcontact=reset(array_keys($listofprojcontact)); + $typeforprojectcontact = reset(array_keys($listofprojcontact)); $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal'); } } @@ -250,22 +250,22 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if (! $error) + if (!$error) { setEventMessages("TaskAssignedToEnterTime", null); - $taskid=0; + $taskid = 0; } - $action=''; + $action = ''; } if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { - $timespent_duration=array(); + $timespent_duration = array(); if (is_array($_POST)) { - foreach($_POST as $key => $time) + foreach ($_POST as $key => $time) { if (intval($time) > 0) { @@ -276,10 +276,10 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac if ($id > 0) { // We store HOURS in seconds - if($matches[2]=='hour') $timespent_duration[$id] += $time*60*60; + if ($matches[2] == 'hour') $timespent_duration[$id] += $time * 60 * 60; // We store MINUTES in seconds - if($matches[2]=='min') $timespent_duration[$id] += $time*60; + if ($matches[2] == 'min') $timespent_duration[$id] += $time * 60; } } } @@ -288,11 +288,11 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac if (count($timespent_duration) > 0) { - foreach($timespent_duration as $key => $val) + foreach ($timespent_duration as $key => $val) { $object->fetch($key); - if (GETPOSTISSET($taskid . 'progress')) $object->progress = GETPOST($taskid . 'progress', 'int'); + if (GETPOSTISSET($taskid.'progress')) $object->progress = GETPOST($taskid.'progress', 'int'); else unset($object->progress); $object->timespent_duration = $val; @@ -311,7 +311,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac if ($object->timespent_date > 0) { - $result=$object->addTimeSpent($user); + $result = $object->addTimeSpent($user); } else { @@ -328,12 +328,12 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); // Redirect to avoid submit twice on back - header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday); + header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid ? 'id='.$projectid : '').($search_usertoprocessid ? '&search_usertoprocessid='.$search_usertoprocessid : '').($mode ? '&mode='.$mode : '').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday); exit; } } @@ -349,11 +349,11 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac * View */ -$form=new Form($db); +$form = new Form($db); $formother = new FormOther($db); -$formcompany=new FormCompany($db); -$formproject=new FormProjets($db); -$projectstatic=new Project($db); +$formcompany = new FormCompany($db); +$formproject = new FormProjets($db); +$projectstatic = new Project($db); $project = new Project($db); $taskstatic = new Task($db); $thirdpartystatic = new Societe($db); @@ -369,9 +369,9 @@ $next_year = $next['year']; $next_month = $next['mon']; $next_day = $next['mday']; -$title=$langs->trans("TimeSpent"); +$title = $langs->trans("TimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id)?2:0), 1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project if ($id) { @@ -379,14 +379,14 @@ if ($id) $project->fetch_thirdparty(); } -$onlyopenedproject=1; // or -1 -$morewherefilter=''; +$onlyopenedproject = 1; // or -1 +$morewherefilter = ''; -if ($search_project_ref) $morewherefilter.=natural_search(array("p.ref", "p.title"), $search_project_ref); -if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); -if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label"), $search_task_label); -if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); -if ($search_declared_progress) $morewherefilter.=natural_search("t.progress", $search_declared_progress, 1); +if ($search_project_ref) $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); +if ($search_task_ref) $morewherefilter .= natural_search("t.ref", $search_task_ref); +if ($search_task_label) $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); +if ($search_thirdparty) $morewherefilter .= natural_search("s.nom", $search_thirdparty); +if ($search_declared_progress) $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); $sql = &$morewherefilter; @@ -397,18 +397,18 @@ $extrafieldsobjectkey='projet'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; */ $search_array_options = $search_array_options_task; -$extrafieldsobjectprefix='efpt.'; -$search_options_pattern='search_task_options_'; -$extrafieldsobjectkey='projet_task'; +$extrafieldsobjectprefix = 'efpt.'; +$search_options_pattern = 'search_task_options_'; +$extrafieldsobjectkey = 'projet_task'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0), 0, $extrafields); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +$tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks { - $tasksarraywithoutfilter=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. + $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } -$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); -$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); +$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject); +$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject); //var_dump($usertoprocess); //var_dump($projectsrole); //var_dump($taskrole); @@ -417,33 +417,33 @@ llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js')); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'project'); -$param=''; -$param.=($mode?'&mode='.urlencode($mode):''); -$param.=($search_project_ref?'&search_project_ref='.urlencode($search_project_ref):''); -$param.=($search_usertoprocessid?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); -$param.=($search_thirdparty?'&search_thirdparty='.urlencode($search_thirdparty):''); -$param.=($search_task_ref?'&search_task_ref='.urlencode($search_task_ref):''); -$param.=($search_task_label?'&search_task_label='.urlencode($search_task_label):''); +$param = ''; +$param .= ($mode ? '&mode='.urlencode($mode) : ''); +$param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : ''); +$param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); +$param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : ''); +$param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : ''); +$param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); /*$search_array_options=$search_array_options_project; $search_options_pattern='search_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ -$search_array_options=$search_array_options_task; -$search_options_pattern='search_task_options_'; +$search_array_options = $search_array_options_task; +$search_options_pattern = 'search_task_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Show navigation bar -$nav =''.img_previous($langs->trans("Previous"))."\n"; -$nav.=dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "%A").' '; -$nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "day")." \n"; -$nav.=''.img_next($langs->trans("Next"))."\n"; -$nav.="   (".$langs->trans("Today").")"; -$nav.='
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; -$nav.=' '; +$nav = ''.img_previous($langs->trans("Previous"))."\n"; +$nav .= dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "%A").' '; +$nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "day")." \n"; +$nav .= ''.img_next($langs->trans("Next"))."\n"; +$nav .= "   (".$langs->trans("Today").")"; +$nav .= '
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; +$nav .= ' '; -$picto='calendarweek'; +$picto = 'calendarweek'; print 'id > 0 ? '?id='.$project->id : '').'">'; print ''; @@ -456,18 +456,18 @@ print ''; print ''; print ''; -$head=project_timesheet_prepare_head($mode, $usertoprocess); +$head = project_timesheet_prepare_head($mode, $usertoprocess); dol_fiche_head($head, 'inputperday', $langs->trans('TimeSpent'), -1, 'task'); // Show description of content print '
        '; -if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; else { if (empty($usertoprocess->id) || $usertoprocess->id < 0) { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; - else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; + if ($user->rights->projet->all->lire && !$socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; + else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; } } if ($mine || ($usertoprocess->id == $user->id)) @@ -482,13 +482,13 @@ print '
        '; dol_fiche_end(); -print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. +print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. print '
        '; $titleassigntask = $langs->transnoentities("AssignTaskToMe"); if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); print '
        '; -$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); +$formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); print '
        '; print ' '; print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); @@ -498,7 +498,7 @@ print '
        '; print '
        '; -$moreforfilter=''; +$moreforfilter = ''; // Filter on categories /*if (! empty($conf->categorie->enabled)) @@ -724,10 +724,10 @@ if (count($tasksarray) > 0) $isdiff = 0; if (count($totalforeachday)) { - $timeonothertasks=($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); + $timeonothertasks = ($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); if ($timeonothertasks) { - $isdiff=1; + $isdiff = 1; } } @@ -735,12 +735,12 @@ if (count($tasksarray) > 0) if ($isdiff) { print ''; - print ''; print ''; print ''; print ''; - $tmparray = dol_getdate($daytoparse, true); // detail of current day + $tmparray = dol_getdate($daytoparse, true); // detail of current day $idw = $tmparray['wday']; - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - $cssonholiday=''; - if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$daytoparse]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayafternoon '; - print ''; + print ''; print ' @@ -794,12 +794,12 @@ print ''; print ''."\n"; print '
        '; -print ''; +print ''; print '
        '; print ''; -$modeinput='hours'; +$modeinput = 'hours'; if ($conf->use_javascript_ajax) { diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 8af733394bf..854e24ee450 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -97,26 +97,26 @@ $next_month = $next['month']; $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) -$firstdaytoshow=dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); -$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); +$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); +$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { - $usertoprocess=$user; - $search_usertoprocessid=$usertoprocess->id; + $usertoprocess = $user; + $search_usertoprocessid = $usertoprocess->id; } elseif ($search_usertoprocessid > 0) { - $usertoprocess=new User($db); + $usertoprocess = new User($db); $usertoprocess->fetch($search_usertoprocessid); - $search_usertoprocessid=$usertoprocess->id; + $search_usertoprocessid = $usertoprocess->id; } else { - $usertoprocess=new User($db); + $usertoprocess = new User($db); } -$object=new Task($db); +$object = new Task($db); // Extra fields $extrafields = new ExtraFields($db); @@ -125,7 +125,7 @@ $extrafields = new ExtraFields($db); //$extrafields->fetch_name_optionals_label('projet'); $extrafields->fetch_name_optionals_label('projet_task'); -$arrayfields=array(); +$arrayfields = array(); /*$arrayfields=array( // Project 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), @@ -134,8 +134,8 @@ $arrayfields=array(); 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115), );*/ -$arrayfields['t.planned_workload']=array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); -$arrayfields['t.progress']=array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); /*foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field @@ -145,17 +145,17 @@ $arrayfields['t.progress']=array('label'=>'ProgressDeclared', 'checked'=>1, 'ena // Extra fields if (is_array($extrafields->attributes['projet_task']['label']) && count($extrafields->attributes['projet_task']['label']) > 0) { - foreach($extrafields->attributes['projet_task']['label'] as $key => $val) + foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { - if (! empty($extrafields->attributes['projet_task']['list'][$key])) - $arrayfields["efpt.".$key]=array('label'=>$extrafields->attributes['projet_task']['label'][$key], 'checked'=>(($extrafields->attributes['projet_task']['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes['projet_task']['pos'][$key], 'enabled'=>(abs($extrafields->attributes['projet_task']['list'][$key])!=3 && $extrafields->attributes['projet_task']['perms'][$key])); + if (!empty($extrafields->attributes['projet_task']['list'][$key])) + $arrayfields["efpt.".$key] = array('label'=>$extrafields->attributes['projet_task']['label'][$key], 'checked'=>(($extrafields->attributes['projet_task']['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes['projet_task']['pos'][$key], 'enabled'=>(abs($extrafields->attributes['projet_task']['list'][$key]) != 3 && $extrafields->attributes['projet_task']['perms'][$key])); } } $arrayfields = dol_sort_array($arrayfields, 'position'); -$search_array_options=array(); -$search_array_options_project=$extrafields->getOptionalsFromPost('projet', '', 'search_'); -$search_array_options_task=$extrafields->getOptionalsFromPost('projet_task', '', 'search_task_'); +$search_array_options = array(); +$search_array_options_project = $extrafields->getOptionalsFromPost('projet', '', 'search_'); +$search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', '', 'search_task_'); @@ -167,7 +167,7 @@ $search_array_options_task=$extrafields->getOptionalsFromPost('projet_task', '', 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 { $action = ''; - $search_categ=''; + $search_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -179,7 +179,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_array_options_task = array(); // We redefine $usertoprocess - $usertoprocess=$user; + $usertoprocess = $user; } if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) { @@ -209,36 +209,36 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors'); $error++; } - if (! GETPOST('type')) + if (!GETPOST('type')) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } - if (! $error) + if (!$error) { - $idfortaskuser=$usertoprocess->id; + $idfortaskuser = $usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); if ($result >= 0 || $result == -2) // Contact add ok or already contact of task { // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) - $sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; - $sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; - $resql=$db->query($sql); + $sql = 'SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; + $sql .= ' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); - if (! $obj) // User is not already linked to project, so we will create link to first type + $obj = $db->fetch_object($resql); + if (!$obj) // User is not already linked to project, so we will create link to first type { $project = new Project($db); $project->fetch($object->fk_project); // Get type - $listofprojcontact=$project->liste_type_contact('internal'); + $listofprojcontact = $project->liste_type_contact('internal'); if (count($listofprojcontact)) { - $typeforprojectcontact=reset(array_keys($listofprojcontact)); + $typeforprojectcontact = reset(array_keys($listofprojcontact)); $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal'); } } @@ -264,43 +264,43 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if (! $error) + if (!$error) { setEventMessages("TaskAssignedToEnterTime", null); - $taskid=0; + $taskid = 0; } - $action=''; + $action = ''; } if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { - $timetoadd=$_POST['task']; + $timetoadd = $_POST['task']; if (empty($timetoadd)) { setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); } else { - foreach($timetoadd as $taskid => $value) // Loop on each task + foreach ($timetoadd as $taskid => $value) // Loop on each task { - $updateoftaskdone=0; - foreach($value as $key => $val) // Loop on each day + $updateoftaskdone = 0; + foreach ($value as $key => $val) // Loop on each day { - $amountoadd=$timetoadd[$taskid][$key]; - if (! empty($amountoadd)) + $amountoadd = $timetoadd[$taskid][$key]; + if (!empty($amountoadd)) { - $tmpduration=explode(':', $amountoadd); - $newduration=0; - if (! empty($tmpduration[0])) $newduration+=($tmpduration[0] * 3600); - if (! empty($tmpduration[1])) $newduration+=($tmpduration[1] * 60); - if (! empty($tmpduration[2])) $newduration+=($tmpduration[2]); + $tmpduration = explode(':', $amountoadd); + $newduration = 0; + if (!empty($tmpduration[0])) $newduration += ($tmpduration[0] * 3600); + if (!empty($tmpduration[1])) $newduration += ($tmpduration[1] * 60); + if (!empty($tmpduration[2])) $newduration += ($tmpduration[2]); if ($newduration > 0) { $object->fetch($taskid); - if (GETPOSTISSET($taskid . 'progress')) $object->progress = GETPOST($taskid . 'progress', 'int'); + if (GETPOSTISSET($taskid.'progress')) $object->progress = GETPOST($taskid.'progress', 'int'); else unset($object->progress); $object->timespent_duration = $newduration; @@ -308,7 +308,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac $object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd'); $object->timespent_datehour = $object->timespent_date; - $result=$object->addTimeSpent($user); + $result = $object->addTimeSpent($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -321,14 +321,14 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } } - if (! $updateoftaskdone) // Check to update progress if no update were done on task. + if (!$updateoftaskdone) // Check to update progress if no update were done on task. { $object->fetch($taskid); //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit; - if ($object->progress != GETPOST($taskid . 'progress', 'int')) + if ($object->progress != GETPOST($taskid.'progress', 'int')) { - $object->progress = GETPOST($taskid . 'progress', 'int'); - $result=$object->update($user); + $object->progress = GETPOST($taskid.'progress', 'int'); + $result = $object->update($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -339,29 +339,29 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $param=''; - $param.=($mode?'&mode='.urlencode($mode):''); - $param.=($projectid?'id='.urlencode($projectid):''); - $param.=($search_usertoprocessid?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); - $param.=($day?'&day='.urlencode($day):'').($month?'&month='.urlencode($month):'').($year?'&year='.urlencode($year):''); - $param.=($search_project_ref?'&search_project_ref='.urlencode($search_project_ref):''); - $param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); - $param.=($search_thirdparty?'&search_thirdparty='.urlencode($search_thirdparty):''); - $param.=($search_declared_progress?'&search_declared_progress='.urlencode($search_declared_progress):''); - $param.=($search_task_ref?'&search_task_ref='.urlencode($search_task_ref):''); - $param.=($search_task_label?'&search_task_label='.urlencode($search_task_label):''); + $param = ''; + $param .= ($mode ? '&mode='.urlencode($mode) : ''); + $param .= ($projectid ? 'id='.urlencode($projectid) : ''); + $param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); + $param .= ($day ? '&day='.urlencode($day) : '').($month ? '&month='.urlencode($month) : '').($year ? '&year='.urlencode($year) : ''); + $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : ''); + $param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); + $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : ''); + $param .= ($search_declared_progress ? '&search_declared_progress='.urlencode($search_declared_progress) : ''); + $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : ''); + $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); /*$search_array_options=$search_array_options_project; $search_options_pattern='search_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ - $search_array_options=$search_array_options_task; - $search_options_pattern='search_task_options_'; + $search_array_options = $search_array_options_task; + $search_options_pattern = 'search_task_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Redirect to avoid submit twice on back @@ -377,19 +377,19 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac * View */ -$form=new Form($db); -$formother=new FormOther($db); -$formcompany=new FormCompany($db); -$formproject=new FormProjets($db); -$projectstatic=new Project($db); +$form = new Form($db); +$formother = new FormOther($db); +$formcompany = new FormCompany($db); +$formproject = new FormProjets($db); +$projectstatic = new Project($db); $project = new Project($db); $taskstatic = new Task($db); $thirdpartystatic = new Societe($db); $holiday = new Holiday($db); -$title=$langs->trans("TimeSpent"); +$title = $langs->trans("TimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id)?2:0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project //var_dump($projectsListId); if ($id) { @@ -397,14 +397,14 @@ if ($id) $project->fetch_thirdparty(); } -$onlyopenedproject=1; // or -1 -$morewherefilter=''; +$onlyopenedproject = 1; // or -1 +$morewherefilter = ''; -if ($search_project_ref) $morewherefilter.=natural_search(array("p.ref", "p.title"), $search_project_ref); -if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); -if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label"), $search_task_label); -if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); -if ($search_declared_progress) $morewherefilter.=natural_search("t.progress", $search_declared_progress, 1); +if ($search_project_ref) $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); +if ($search_task_ref) $morewherefilter .= natural_search("t.ref", $search_task_ref); +if ($search_task_label) $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); +if ($search_thirdparty) $morewherefilter .= natural_search("s.nom", $search_thirdparty); +if ($search_declared_progress) $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); $sql = &$morewherefilter; @@ -415,18 +415,18 @@ $extrafieldsobjectkey='projet'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; */ $search_array_options = $search_array_options_task; -$extrafieldsobjectprefix='efpt.'; -$search_options_pattern='search_task_options_'; -$extrafieldsobjectkey='projet_task'; +$extrafieldsobjectprefix = 'efpt.'; +$search_options_pattern = 'search_task_options_'; +$extrafieldsobjectkey = 'projet_task'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +$tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks { - $tasksarraywithoutfilter=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. + $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } -$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); -$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); +$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject); +$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject); //var_dump($tasksarray); //var_dump($projectsrole); //var_dump($taskrole); @@ -436,31 +436,31 @@ llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js')); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'project'); -$param=''; -$param.=($mode?'&mode='.urlencode($mode):''); -$param.=($search_project_ref?'&search_project_ref='.urlencode($search_project_ref):''); -$param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); -$param.=($search_thirdparty?'&search_thirdparty='.urlencode($search_thirdparty):''); -$param.=($search_task_ref?'&search_task_ref='.urlencode($search_task_ref):''); -$param.=($search_task_label?'&search_task_label='.urlencode($search_task_label):''); +$param = ''; +$param .= ($mode ? '&mode='.urlencode($mode) : ''); +$param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : ''); +$param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); +$param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : ''); +$param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : ''); +$param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); -$search_array_options=$search_array_options_project; -$search_options_pattern='search_options_'; +$search_array_options = $search_array_options_project; +$search_options_pattern = 'search_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -$search_array_options=$search_array_options_task; -$search_options_pattern='search_task_options_'; +$search_array_options = $search_array_options_task; +$search_options_pattern = 'search_task_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Show navigation bar -$nav =''.img_previous($langs->trans("Previous"))."\n"; -$nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; -$nav.=''.img_next($langs->trans("Next"))."\n"; -$nav.="   (".$langs->trans("Today").")"; -$nav.='
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; -$nav.=' '; +$nav = ''.img_previous($langs->trans("Previous"))."\n"; +$nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; +$nav .= ''.img_next($langs->trans("Next"))."\n"; +$nav .= "   (".$langs->trans("Today").")"; +$nav .= '
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; +$nav .= ' '; -$picto='calendarweek'; +$picto = 'calendarweek'; print ''; print ''; @@ -472,18 +472,18 @@ print ''; print ''; print ''; -$head=project_timesheet_prepare_head($mode, $usertoprocess); +$head = project_timesheet_prepare_head($mode, $usertoprocess); dol_fiche_head($head, 'inputperweek', $langs->trans('TimeSpent'), -1, 'task'); // Show description of content print '
        '; -if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; else { if (empty($usertoprocess->id) || $usertoprocess->id < 0) { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; - else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; + if ($user->rights->projet->all->lire && !$socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; + else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; } } if ($mine || ($usertoprocess->id == $user->id)) @@ -498,13 +498,13 @@ print '
        '; dol_fiche_end(); -print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. +print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. print '
        '; $titleassigntask = $langs->transnoentities("AssignTaskToMe"); if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); print '
        '; -$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); +$formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); print '
        '; print ' '; print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); @@ -514,13 +514,13 @@ print '
        '; print '
        '; -$startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); +$startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); // Get if user is available or not for each day -$isavailable=array(); -if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) +$isavailable = array(); +if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { - $tmparray=explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); + $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); if (count($tmparray) >= 2) { $numstartworkingday = $tmparray[0]; @@ -528,9 +528,9 @@ if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) } } -for ($idw=0; $idw<7; $idw++) +for ($idw = 0; $idw < 7; $idw++) { - $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 + $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow @@ -543,11 +543,11 @@ for ($idw=0; $idw<7; $idw++) $statusofholidaytocheck = '3'; $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck); - $isavailable[$dayinloopfromfirstdaytoshow]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day + $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day } -$moreforfilter=''; +$moreforfilter = ''; // Filter on categories /* @@ -686,32 +686,32 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print "\n"; -$colspan=3+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2); +$colspan = 3 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); if ($conf->use_javascript_ajax) { print ''; - print ''; for ($idw = 0; $idw < 7; $idw++) { - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $cssonholiday=''; - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; - print ''; + print ''; } print ''; print ''; @@ -765,11 +765,11 @@ if (count($tasksarray) > 0) { for ($idw = 0; $idw < 7; $idw++) { - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); if ($timeonothertasks) { - $isdiff=1; + $isdiff = 1; break; } } @@ -779,20 +779,20 @@ if (count($tasksarray) > 0) if ($isdiff) { print ''; - print ''; for ($idw = 0; $idw < 7; $idw++) { - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - print ''; -if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity status print ''; @@ -228,7 +228,7 @@ print ''; // Other attributes $cols = 2; -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
        '; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - $projectstatic->public=$row->public; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; + $projectstatic->public = $row->public; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').'
        '.$langs->trans('TaskRessourceLinks').''.$langs->trans('OpenedProjects').''.$langs->trans('OpportunityStatus').''.$langs->trans('OpportunityStatus').''.$langs->trans('Task').''.$langs->trans('DateStart').''.$langs->trans('DateEnd').''; print $projectstatic->getNomUrl(1, '', 0, '', '
        '); print '
        '; $code = dol_getIdFromCode($db, $obj->opp_status, 'c_lead_status', 'rowid', 'code'); @@ -532,7 +532,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print ''; - if (! empty($obj->taskid)) + if (!empty($obj->taskid)) { $tasktmp->id = $obj->taskid; $tasktmp->ref = $obj->ref; @@ -552,18 +552,18 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print convertSecondToTime($obj->timespent, 'allhourmin'); print ''; - if (! empty($obj->taskid)) + if (!empty($obj->taskid)) { if (empty($obj->planned_workload) > 0) { $percentcompletion = $langs->trans("WorkloadNotDefined"); } else { - $percentcompletion = intval($obj->duration_effective*100/$obj->planned_workload).'%'; + $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).'%'; } } print $percentcompletion; print ''; - print ($obj->taskid>0)?$obj->progress.'%':''; + print ($obj->taskid > 0) ? $obj->progress.'%' : ''; print '
        '.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").'
        '; + print ''; print $langs->trans("OtherFilteredTasks"); print ''; - $timeonothertasks=($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); + $timeonothertasks = ($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); //if ($timeonothertasks) //{ print ''; - print ''; + print ''; print $langs->trans("Total"); print ''; //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print '
         
         
        '; + print ''; print $langs->trans("Total"); print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print '
         
         
         
        '; + print ''; print $langs->trans("OtherFilteredTasks"); print ''; - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); + print ''; + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); if ($timeonothertasks) { print 'use_javascript_ajax) { @@ -865,7 +865,7 @@ if ($conf->use_javascript_ajax) } });'."\n"; - $idw=0; + $idw = 0; while ($idw < 7) { print ' updateTotal('.$idw.',\''.$modeinput.'\');'; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 79647e53691..d54e54135e1 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -26,7 +26,7 @@ * \ingroup projet * \brief File of class to manage projects */ -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** * Class to manage projects @@ -209,7 +209,7 @@ class Project extends CommonObject $error = 0; $ret = 0; - $now=dol_now(); + $now = dol_now(); // Clean parameters $this->note_private = dol_substr($this->note_private, 0, 65535); @@ -301,10 +301,10 @@ class Project extends CommonObject } // Update extrafield - if (! $error) { + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -312,13 +312,13 @@ class Project extends CommonObject } } - if (! $error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) + if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) { $res = $this->setValid($user); if ($res < 0) $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return $ret; @@ -341,19 +341,19 @@ class Project extends CommonObject { global $langs, $conf; - $error=0; + $error = 0; // Clean parameters $this->title = trim($this->title); $this->description = trim($this->description); - if ($this->opp_amount < 0) $this->opp_amount=''; - if ($this->opp_percent < 0) $this->opp_percent=''; + if ($this->opp_amount < 0) $this->opp_amount = ''; + if ($this->opp_percent < 0) $this->opp_percent = ''; if ($this->date_end && $this->date_end < $this->date_start) { $this->error = $langs->trans("ErrorDateEndLowerThanDateStart"); $this->errors[] = $this->error; $this->db->rollback(); - dol_syslog(get_class($this)."::update error -3 " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::update error -3 ".$this->error, LOG_ERR); return -3; } @@ -401,35 +401,35 @@ class Project extends CommonObject } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('PROJECT_MODIFY', $user); + $result = $this->call_trigger('PROJECT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) + if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { // We remove directory if ($conf->projet->dir_output) { - $olddir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); - $newdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->ref); + $olddir = $conf->projet->dir_output."/".dol_sanitizeFileName($this->oldcopy->ref); + $newdir = $conf->projet->dir_output."/".dol_sanitizeFileName($this->ref); if (file_exists($olddir)) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $res=@rename($olddir, $newdir); - if (! $res) + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $res = @rename($olddir, $newdir); + if (!$res) { $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToRenameDir', $olddir, $newdir); + $this->error = $langs->trans('ErrorFailToRenameDir', $olddir, $newdir); $error++; } } } } - if (! $error ) + if (!$error) { $this->db->commit(); $result = 1; @@ -453,7 +453,7 @@ class Project extends CommonObject { $result = -2; } - dol_syslog(get_class($this)."::update error " . $result . " " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::update error ".$result." ".$this->error, LOG_ERR); } } else @@ -509,7 +509,7 @@ class Project extends CommonObject $this->date_c = $this->db->jdate($obj->datec); $this->datec = $this->db->jdate($obj->datec); // TODO deprecated $this->date_m = $this->db->jdate($obj->tms); - $this->datem = $this->db->jdate($obj->tms); // TODO deprecated + $this->datem = $this->db->jdate($obj->tms); // TODO deprecated $this->date_start = $this->db->jdate($obj->dateo); $this->date_end = $this->db->jdate($obj->datee); $this->date_close = $this->db->jdate($obj->date_close); @@ -625,7 +625,7 @@ class Project extends CommonObject { $obj = $this->db->fetch_object($result); - $elements[$i] = $obj->rowid.(empty($obj->fk_user)?'':'_'.$obj->fk_user); + $elements[$i] = $obj->rowid.(empty($obj->fk_user) ? '' : '_'.$obj->fk_user); $i++; } @@ -651,7 +651,7 @@ class Project extends CommonObject public function delete($user, $notrigger = 0) { global $langs, $conf; - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; @@ -671,15 +671,15 @@ class Project extends CommonObject } // Set fk_projet into elements to null - $listoftables=array( + $listoftables = array( 'propal'=>'fk_projet', 'commande'=>'fk_projet', 'facture'=>'fk_projet', 'supplier_proposal'=>'fk_projet', 'commande_fournisseur'=>'fk_projet', 'facture_fourn'=>'fk_projet', 'expensereport_det'=>'fk_projet', 'contrat'=>'fk_projet', 'fichinter'=>'fk_projet', 'don'=>'fk_projet', 'actioncomm'=>'fk_project' ); - foreach($listoftables as $key => $value) + foreach ($listoftables as $key => $value) { - $sql = "UPDATE " . MAIN_DB_PREFIX . $key . " SET ".$value." = NULL where ".$value." = ". $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$key." SET ".$value." = NULL where ".$value." = ".$this->id; $resql = $this->db->query($sql); if (!$resql) { @@ -730,10 +730,10 @@ class Project extends CommonObject // Delete project - if (! $error) + if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet"; - $sql.= " WHERE rowid=" . $this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet"; + $sql .= " WHERE rowid=".$this->id; $resql = $this->db->query($sql); if (!$resql) @@ -743,13 +743,13 @@ class Project extends CommonObject } } - if (! $error) + if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_extrafields"; - $sql.= " WHERE fk_object=" . $this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_extrafields"; + $sql .= " WHERE fk_object=".$this->id; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $this->errors[] = $this->db->lasterror(); $error++; @@ -760,7 +760,7 @@ class Project extends CommonObject // We remove directory $projectref = dol_sanitizeFileName($this->ref); if ($conf->projet->dir_output) { - $dir = $conf->projet->dir_output . "/" . $projectref; + $dir = $conf->projet->dir_output."/".$projectref; if (file_exists($dir)) { $res = @dol_delete_dir_recursive($dir); if (!$res) { @@ -773,7 +773,7 @@ class Project extends CommonObject if (!$notrigger) { // Call trigger - $result=$this->call_trigger('PROJECT_DELETE', $user); + $result = $this->call_trigger('PROJECT_DELETE', $user); if ($result < 0) { $error++; @@ -791,10 +791,10 @@ class Project extends CommonObject { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } - dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); $this->db->rollback(); return -1; } @@ -812,7 +812,7 @@ class Project extends CommonObject $deleted = false; if ($countTasks) { - foreach($this->lines as $task) + foreach ($this->lines as $task) { if ($task->hasChildren() <= 0) { // If there is no children (or error to detect them) $deleted = true; @@ -845,23 +845,23 @@ class Project extends CommonObject { global $langs, $conf; - $error=0; + $error = 0; if ($this->statut != 1) { // Check parameters if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) { - $this->error=$langs->trans("ErrorFieldFormat", $langs->transnoentities("Label")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf")); + $this->error = $langs->trans("ErrorFieldFormat", $langs->transnoentities("Label")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf")); return -1; } $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "projet"; - $sql.= " SET fk_statut = 1"; - $sql.= " WHERE rowid = " . $this->id; - $sql.= " AND entity = " . $conf->entity; + $sql = "UPDATE ".MAIN_DB_PREFIX."projet"; + $sql .= " SET fk_statut = 1"; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::setValid", LOG_DEBUG); $resql = $this->db->query($sql); @@ -870,14 +870,14 @@ class Project extends CommonObject // Call trigger if (empty($notrigger)) { - $result=$this->call_trigger('PROJECT_VALIDATE', $user); + $result = $this->call_trigger('PROJECT_VALIDATE', $user); if ($result < 0) { $error++; } // End call triggers } if (!$error) { - $this->statut=1; + $this->statut = 1; $this->db->commit(); return 1; } @@ -885,7 +885,7 @@ class Project extends CommonObject { $this->db->rollback(); $this->error = join(',', $this->errors); - dol_syslog(get_class($this)."::setValid " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::setValid ".$this->error, LOG_ERR); return -1; } } @@ -910,19 +910,19 @@ class Project extends CommonObject $now = dol_now(); - $error=0; + $error = 0; if ($this->statut != 2) { $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "projet"; - $sql.= " SET fk_statut = 2, fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'"; - $sql.= " WHERE rowid = " . $this->id; - $sql.= " AND entity = " . $conf->entity; - $sql.= " AND fk_statut = 1"; + $sql = "UPDATE ".MAIN_DB_PREFIX."projet"; + $sql .= " SET fk_statut = 2, fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'"; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND entity = ".$conf->entity; + $sql .= " AND fk_statut = 1"; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // TODO What to do if fk_opp_status is not code 'WON' or 'LOST' } @@ -932,7 +932,7 @@ class Project extends CommonObject if ($resql) { // Call trigger - $result=$this->call_trigger('PROJECT_CLOSE', $user); + $result = $this->call_trigger('PROJECT_CLOSE', $user); if ($result < 0) { $error++; } // End call triggers @@ -946,7 +946,7 @@ class Project extends CommonObject { $this->db->rollback(); $this->error = join(',', $this->errors); - dol_syslog(get_class($this)."::setClose " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::setClose ".$this->error, LOG_ERR); return -1; } } @@ -1015,52 +1015,52 @@ class Project extends CommonObject { global $conf, $langs, $user, $hookmanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label=''; - if ($option != 'nolink') $label = '' . $langs->trans("ShowProject") . ''; - $label .= ($label?'
        ':'').'' . $langs->trans('Ref') . ': ' . $this->ref; // The space must be after the : to not being explode when showing the title in img_picto - $label .= ($label?'
        ':'').'' . $langs->trans('Label') . ': ' . $this->title; // The space must be after the : to not being explode when showing the title in img_picto - if (! empty($this->thirdparty_name)) - $label .= ($label?'
        ':'').'' . $langs->trans('ThirdParty') . ': ' . $this->thirdparty_name; // The space must be after the : to not being explode when showing the title in img_picto - if (! empty($this->dateo)) - $label .= ($label?'
        ':'').'' . $langs->trans('DateStart') . ': ' . dol_print_date($this->dateo, 'day'); // The space must be after the : to not being explode when showing the title in img_picto - if (! empty($this->datee)) - $label .= ($label?'
        ':'').'' . $langs->trans('DateEnd') . ': ' . dol_print_date($this->datee, 'day'); // The space must be after the : to not being explode when showing the title in img_picto - if ($moreinpopup) $label.='
        '.$moreinpopup; + $label = ''; + if ($option != 'nolink') $label = ''.$langs->trans("ShowProject").''; + $label .= ($label ? '
        ' : '').''.$langs->trans('Ref').': '.$this->ref; // The space must be after the : to not being explode when showing the title in img_picto + $label .= ($label ? '
        ' : '').''.$langs->trans('Label').': '.$this->title; // The space must be after the : to not being explode when showing the title in img_picto + if (!empty($this->thirdparty_name)) + $label .= ($label ? '
        ' : '').''.$langs->trans('ThirdParty').': '.$this->thirdparty_name; // The space must be after the : to not being explode when showing the title in img_picto + if (!empty($this->dateo)) + $label .= ($label ? '
        ' : '').''.$langs->trans('DateStart').': '.dol_print_date($this->dateo, 'day'); // The space must be after the : to not being explode when showing the title in img_picto + if (!empty($this->datee)) + $label .= ($label ? '
        ' : '').''.$langs->trans('DateEnd').': '.dol_print_date($this->datee, 'day'); // The space must be after the : to not being explode when showing the title in img_picto + if ($moreinpopup) $label .= '
        '.$moreinpopup; - $url=''; + $url = ''; if ($option != 'nolink') { if (preg_match('/\.php$/', $option)) { - $url = dol_buildpath($option, 1) . '?id=' . $this->id; + $url = dol_buildpath($option, 1).'?id='.$this->id; } elseif ($option == 'task') { - $url = DOL_URL_ROOT . '/projet/tasks.php?id=' . $this->id; + $url = DOL_URL_ROOT.'/projet/tasks.php?id='.$this->id; } else { - $url = DOL_URL_ROOT . '/projet/card.php?id=' . $this->id; + $url = DOL_URL_ROOT.'/projet/card.php?id='.$this->id; } // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip) && $user->rights->projet->lire) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowProject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowProject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; /* $hookmanager->initHooks(array('projectdao')); @@ -1073,22 +1073,22 @@ class Project extends CommonObject } $picto = 'projectpub'; - if (! $this->public) $picto = 'project'; + if (!$this->public) $picto = 'project'; $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; - if ($withpicto != 2) $result.=(($addlabel && $this->title) ? $sep . dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); + if ($withpicto != 2) $result .= (($addlabel && $this->title) ? $sep.dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); global $action; $hookmanager->initHooks(array('projectdao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -1106,7 +1106,7 @@ class Project extends CommonObject { global $user, $langs, $conf; - $now=dol_now(); + $now = dol_now(); // Initialise parameters $this->id = 0; @@ -1154,11 +1154,11 @@ class Project extends CommonObject { // To verify role of users $userAccess = 0; - if (($mode == 'read' && ! empty($user->rights->projet->all->lire)) || ($mode == 'write' && ! empty($user->rights->projet->all->creer)) || ($mode == 'delete' && ! empty($user->rights->projet->all->supprimer))) + if (($mode == 'read' && !empty($user->rights->projet->all->lire)) || ($mode == 'write' && !empty($user->rights->projet->all->creer)) || ($mode == 'delete' && !empty($user->rights->projet->all->supprimer))) { $userAccess = 1; } - elseif ($this->public && (($mode == 'read' && ! empty($user->rights->projet->lire)) || ($mode == 'write' && ! empty($user->rights->projet->creer)) || ($mode == 'delete' && ! empty($user->rights->projet->supprimer)))) + elseif ($this->public && (($mode == 'read' && !empty($user->rights->projet->lire)) || ($mode == 'write' && !empty($user->rights->projet->creer)) || ($mode == 'delete' && !empty($user->rights->projet->supprimer)))) { $userAccess = 1; } @@ -1174,8 +1174,8 @@ class Project extends CommonObject { if ($source == 'internal' && preg_match('/^PROJECT/', $userRole[$nblinks]['code']) && $user->id == $userRole[$nblinks]['id']) { - if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; - if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; + if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; + if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++; } $nblinks++; @@ -1190,7 +1190,7 @@ class Project extends CommonObject //} } - return ($userAccess?$userAccess:-1); + return ($userAccess ? $userAccess : -1); } /** @@ -1326,10 +1326,10 @@ class Project extends CommonObject if ($newthirdpartyid > 0) $clone_project->socid = $newthirdpartyid; $clone_project->fetch_thirdparty(); - $orign_dt_start=$clone_project->date_start; - $orign_project_ref=$clone_project->ref; + $orign_dt_start = $clone_project->date_start; + $orign_project_ref = $clone_project->ref; - $clone_project->id=0; + $clone_project->id = 0; if ($move_date) { $clone_project->date_start = $now; if (!(empty($clone_project->date_end))) @@ -1340,63 +1340,63 @@ class Project extends CommonObject $clone_project->datec = $now; - if (! $clone_note) + if (!$clone_note) { - $clone_project->note_private=''; - $clone_project->note_public=''; + $clone_project->note_private = ''; + $clone_project->note_public = ''; } //Generate next ref - $defaultref=''; - $obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; + $defaultref = ''; + $obj = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON; // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/project/".$obj.'.php', 0); + $file = dol_buildpath($reldir."core/modules/project/".$obj.'.php', 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; dol_include_once($reldir."core/modules/project/".$obj.'.php'); $modProject = new $obj; - $defaultref = $modProject->getNextValue(is_object($clone_project->thirdparty)?$clone_project->thirdparty:null, $clone_project); + $defaultref = $modProject->getNextValue(is_object($clone_project->thirdparty) ? $clone_project->thirdparty : null, $clone_project); break; } } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; - $clone_project->ref=$defaultref; - $clone_project->title=$langs->trans("CopyOf").' '.$clone_project->title; + $clone_project->ref = $defaultref; + $clone_project->title = $langs->trans("CopyOf").' '.$clone_project->title; // Create clone - $result=$clone_project->create($user, $notrigger); + $result = $clone_project->create($user, $notrigger); // Other options if ($result < 0) { - $this->error.=$clone_project->error; + $this->error .= $clone_project->error; $error++; } - if (! $error) + if (!$error) { //Get the new project id - $clone_project_id=$clone_project->id; + $clone_project_id = $clone_project->id; //Note Update if (!$clone_note) { - $clone_project->note_private=''; - $clone_project->note_public=''; + $clone_project->note_private = ''; + $clone_project->note_public = ''; } else { $this->db->begin(); - $res=$clone_project->update_note(dol_html_entity_decode($clone_project->note_public, ENT_QUOTES), '_public'); + $res = $clone_project->update_note(dol_html_entity_decode($clone_project->note_public, ENT_QUOTES), '_public'); if ($res < 0) { - $this->error.=$clone_project->error; + $this->error .= $clone_project->error; $error++; $this->db->rollback(); } @@ -1406,10 +1406,10 @@ class Project extends CommonObject } $this->db->begin(); - $res=$clone_project->update_note(dol_html_entity_decode($clone_project->note_private, ENT_QUOTES), '_private'); + $res = $clone_project->update_note(dol_html_entity_decode($clone_project->note_private, ENT_QUOTES), '_private'); if ($res < 0) { - $this->error.=$clone_project->error; + $this->error .= $clone_project->error; $error++; $this->db->rollback(); } @@ -1425,7 +1425,7 @@ class Project extends CommonObject $origin_project = new Project($this->db); $origin_project->fetch($fromid); - foreach(array('internal','external') as $source) + foreach (array('internal', 'external') as $source) { $tab = $origin_project->liste_contact(-1, $source); @@ -1435,14 +1435,14 @@ class Project extends CommonObject if ($clone_project->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - $this->error.=$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); + $this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); $error++; } else { - if ($clone_project->error!='') + if ($clone_project->error != '') { - $this->error.=$clone_project->error; + $this->error .= $clone_project->error; $error++; } } @@ -1455,25 +1455,25 @@ class Project extends CommonObject { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $clone_project_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($defaultref); - $ori_project_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($orign_project_ref); + $clone_project_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($defaultref); + $ori_project_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($orign_project_ref); if (dol_mkdir($clone_project_dir) >= 0) { - $filearray=dol_dir_list($ori_project_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); - foreach($filearray as $key => $file) + $filearray = dol_dir_list($ori_project_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); + foreach ($filearray as $key => $file) { - $rescopy = dol_copy($ori_project_dir . '/' . $file['name'], $clone_project_dir . '/' . $file['name'], 0, 1); + $rescopy = dol_copy($ori_project_dir.'/'.$file['name'], $clone_project_dir.'/'.$file['name'], 0, 1); if (is_numeric($rescopy) && $rescopy < 0) { - $this->error.=$langs->trans("ErrorFailToCopyFile", $ori_project_dir . '/' . $file['name'], $clone_project_dir . '/' . $file['name']); + $this->error .= $langs->trans("ErrorFailToCopyFile", $ori_project_dir.'/'.$file['name'], $clone_project_dir.'/'.$file['name']); $error++; } } } else { - $this->error.=$langs->trans('ErrorInternalErrorDetected').':dol_mkdir'; + $this->error .= $langs->trans('ErrorInternalErrorDetected').':dol_mkdir'; $error++; } } @@ -1499,36 +1499,36 @@ class Project extends CommonObject $result_clone = $taskstatic->createFromClone($user, $tasktoclone->id, $clone_project_id, $tasktoclone->fk_parent, $move_date, true, false, $clone_task_file, true, false); if ($result_clone <= 0) { - $this->error.=$result_clone->error; + $this->error .= $result_clone->error; $error++; } else { - $new_task_id=$result_clone; + $new_task_id = $result_clone; $taskstatic->fetch($tasktoclone->id); //manage new parent clone task id // if the current task has child we store the original task id and the equivalent clone task id if (($taskstatic->hasChildren()) && !array_key_exists($tasktoclone->id, $tab_conv_child_parent)) { - $tab_conv_child_parent[$tasktoclone->id] = $new_task_id; + $tab_conv_child_parent[$tasktoclone->id] = $new_task_id; } } } //Parse all clone node to be sure to update new parent - $tasksarray=$taskstatic->getTasksArray(0, 0, $clone_project_id, $socid, 0); + $tasksarray = $taskstatic->getTasksArray(0, 0, $clone_project_id, $socid, 0); foreach ($tasksarray as $task_cloned) { $taskstatic->fetch($task_cloned->id); - if ($taskstatic->fk_task_parent!=0) + if ($taskstatic->fk_task_parent != 0) { - $taskstatic->fk_task_parent=$tab_conv_child_parent[$taskstatic->fk_task_parent]; + $taskstatic->fk_task_parent = $tab_conv_child_parent[$taskstatic->fk_task_parent]; } - $res=$taskstatic->update($user, $notrigger); + $res = $taskstatic->update($user, $notrigger); if ($result_clone <= 0) { - $this->error.=$taskstatic->error; + $this->error .= $taskstatic->error; $error++; } } @@ -1537,7 +1537,7 @@ class Project extends CommonObject unset($clone_project->context['createfromclone']); - if (! $error) + if (!$error) { $this->db->commit(); return $clone_project_id; @@ -1545,7 +1545,7 @@ class Project extends CommonObject else { $this->db->rollback(); - dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : ".$this->error, LOG_ERR); return -1; } } @@ -1607,11 +1607,11 @@ class Project extends CommonObject if (!$result) { $error++; - $this->error.=$task->error; + $this->error .= $task->error; } } } - if ($error!=0) + if ($error != 0) { return -1; } @@ -1630,23 +1630,23 @@ class Project extends CommonObject public function update_element($tableName, $elementSelectId) { // phpcs:enable - $sql="UPDATE ".MAIN_DB_PREFIX.$tableName; + $sql = "UPDATE ".MAIN_DB_PREFIX.$tableName; if ($tableName == "actioncomm") { - $sql.= " SET fk_project=".$this->id; - $sql.= " WHERE id=".$elementSelectId; + $sql .= " SET fk_project=".$this->id; + $sql .= " WHERE id=".$elementSelectId; } else { - $sql.= " SET fk_projet=".$this->id; - $sql.= " WHERE rowid=".$elementSelectId; + $sql .= " SET fk_projet=".$this->id; + $sql .= " WHERE rowid=".$elementSelectId; } dol_syslog(get_class($this)."::update_element", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if (!$resql) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } else { return 1; @@ -1778,7 +1778,7 @@ class Project extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; } @@ -1849,7 +1849,7 @@ class Project extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1884,24 +1884,24 @@ class Project extends CommonObject // phpcs:enable global $user; - $this->nb=array(); + $this->nb = array(); $sql = "SELECT count(p.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " WHERE"; - $sql.= " p.entity IN (".getEntity('project').")"; - if (! $user->rights->projet->all->lire) + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " WHERE"; + $sql .= " p.entity IN (".getEntity('project').")"; + if (!$user->rights->projet->all->lire) { $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1); $sql .= "AND p.rowid IN (".$projectsListId.")"; } - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["projects"]=$obj->nb; + $this->nb["projects"] = $obj->nb; } $this->db->free($resql); return 1; @@ -1909,7 +1909,7 @@ class Project extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1924,8 +1924,8 @@ class Project extends CommonObject { global $conf; - if (! ($this->statut == 1)) return false; - if (! $this->datee && ! $this->date_end) return false; + if (!($this->statut == 1)) return false; + if (!$this->datee && !$this->date_end) return false; $now = dol_now(); @@ -1942,11 +1942,11 @@ class Project extends CommonObject public function info($id) { $sql = 'SELECT c.rowid, datec as datec, tms as datem,'; - $sql.= ' date_close as datecloture,'; - $sql.= ' fk_user_creat as fk_user_author, fk_user_close as fk_use_cloture'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'projet as c'; - $sql.= ' WHERE c.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' date_close as datecloture,'; + $sql .= ' fk_user_creat as fk_user_author, fk_user_close as fk_use_cloture'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as c'; + $sql .= ' WHERE c.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -1957,14 +1957,14 @@ class Project extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); @@ -2000,7 +2000,7 @@ class Project extends CommonObject } // Get current categories - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, $type_categ, 'id'); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 56d01faa342..777c0dcb360 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -110,43 +110,43 @@ $hookmanager->initHooks(array('projectOverview')); * View */ -$title=$langs->trans("ProjectReferers").' - '.$object->ref.' '.$object->name; -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("ProjectReferers"); -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$title = $langs->trans("ProjectReferers").' - '.$object->ref.' '.$object->name; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("ProjectReferers"); +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $langs->trans("Referers"), $help_url); $form = new Form($db); -$formproject=new FormProjets($db); +$formproject = new FormProjets($db); $formfile = new FormFile($db); -$userstatic=new User($db); +$userstatic = new User($db); // To verify role of users $userAccess = $object->restrictedProjectArea($user); -$head=project_prepare_head($object); -dol_fiche_head($head, 'element', $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); +$head = project_prepare_head($object); +dol_fiche_head($head, 'element', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); // Project card $linkback = ''.$langs->trans("BackToList").''; -$morehtmlref='
        '; +$morehtmlref = '
        '; // Title -$morehtmlref.=$object->title; +$morehtmlref .= $object->title; // Thirdparty if ($object->thirdparty->id > 0) { - $morehtmlref.='
        '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= '
        '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } -$morehtmlref.='
        '; +$morehtmlref .= '
        '; // Define a complementary filter for search of next/prev ref. -if (! $user->rights->projet->all->lire) +if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter=" te.rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")"; + $object->next_prev_filter = " te.rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -192,7 +192,7 @@ if ($object->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print '
        '.$langs->trans("OpportunityStatus").''; @@ -214,10 +214,10 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) // Date start - end print '
        '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start, 'day'); -print ($start?$start:'?'); +print ($start ? $start : '?'); $end = dol_print_date($object->date_end, 'day'); print ' - '; -print ($end?$end:'?'); +print ($end ? $end : '?'); if ($object->hasDelay()) print img_warning("Late"); print '
        '; @@ -245,7 +245,7 @@ print nl2br($object->description); print '
        '.$langs->trans("BillTime").''; print yn($object->usage_bill_time); @@ -253,7 +253,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_B } // Categories -if($conf->categorie->enabled) { +if ($conf->categorie->enabled) { print '
        '.$langs->trans("Categories").''; print $form->showCategories($object->id, 'project', 1); print "
        '.$i.''; - if (! $qualifiedforfinalprofit) print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; + if (!$qualifiedforfinalprofit) print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; else print price($total_ht); print ''; - if (! $qualifiedforfinalprofit) print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; + if (!$qualifiedforfinalprofit) print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; else print price($total_ttc); print '
        '; - if (in_array($tablename, array('projet_task')) && $key == 'project_task') print ''; // if $key == 'project_task', we don't want details per user - elseif (in_array($tablename, array('payment_various'))) print ''; // if $key == 'payment_various', we don't have any thirdparty - elseif (in_array($tablename, array('expensereport_det','don','projet_task','stock_mouvement','payment_salary'))) print $langs->trans("User"); + if (in_array($tablename, array('projet_task')) && $key == 'project_task') print ''; // if $key == 'project_task', we don't want details per user + elseif (in_array($tablename, array('payment_various'))) print ''; // if $key == 'payment_various', we don't have any thirdparty + elseif (in_array($tablename, array('expensereport_det', 'don', 'projet_task', 'stock_mouvement', 'payment_salary'))) print $langs->trans("User"); else print $langs->trans("ThirdParty"); print ''.$langs->trans("Status").'
        '; @@ -993,7 +993,7 @@ foreach ($listofreferent as $key => $value) } elseif (in_array($tablename, array('projet_task'))) { - $tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty + $tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty print ''; print convertSecondToTime($tmpprojtime['nbseconds'], 'allhourmin'); print ''; @@ -1007,13 +1007,13 @@ foreach ($listofreferent as $key => $value) if (is_object($element->thirdparty)) { print $element->thirdparty->getNomUrl(1, '', 48); } elseif ($tablename == 'expensereport_det') { - $tmpuser=new User($db); + $tmpuser = new User($db); $tmpuser->fetch($expensereport->fk_user_author); print $tmpuser->getNomUrl(1, '', 48); } elseif ($tablename == 'payment_salary') { - $tmpuser=new User($db); + $tmpuser = new User($db); $tmpuser->fetch($element->fk_user); print $tmpuser->getNomUrl(1, '', 48); } @@ -1021,7 +1021,7 @@ foreach ($listofreferent as $key => $value) { if ($element->fk_user_author > 0) { - $tmpuser2=new User($db); + $tmpuser2 = new User($db); $tmpuser2->fetch($element->fk_user_author); print $tmpuser2->getNomUrl(1, '', 48); } @@ -1033,34 +1033,34 @@ foreach ($listofreferent as $key => $value) print '
        '; - $breakline.=''; - $breakline.=''; - $breakline.=$langs->trans('SubTotal').' : '; - if (is_object($element->thirdparty)) $breakline.=$element->thirdparty->getNomUrl(0, '', 48); - $breakline.=''.price($total_ht_by_third).''.price($total_ttc_by_third).'
        '; + $breakline .= ''; + $breakline .= ''; + $breakline .= $langs->trans('SubTotal').' : '; + if (is_object($element->thirdparty)) $breakline .= $element->thirdparty->getNomUrl(0, '', 48); + $breakline .= ''.price($total_ht_by_third).''.price($total_ttc_by_third).'
        '.$langs->trans("Number").': '.$i.''; if (empty($value['disableamount'])) { - if ($tablename != 'projet_task' || ! empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); + if ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); } print ''.$langs->trans("TotalTTC").' : '.price($total_ttc).''; if (empty($value['disableamount'])) { - if ($tablename != 'projet_task' || ! empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); + if ($tablename != 'projet_task' || !empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); } print ' 
        '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start, 'day'); - print ($start?$start:'?'); + print ($start ? $start : '?'); $end = dol_print_date($object->date_end, 'day'); print ' - '; - print ($end?$end:'?'); + print ($end ? $end : '?'); if ($object->hasDelay()) print img_warning("Late"); print '
        '; @@ -210,7 +210,7 @@ if (($id > 0 && is_numeric($id)) || ! empty($ref)) } // Categories - if($conf->categorie->enabled) { + if ($conf->categorie->enabled) { print '
        '.$langs->trans("Categories").''; print $form->showCategories($object->id, 'project', 1); print "
        '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($projectstatic->date_start, 'day'); - print ($start?$start:'?'); + print ($start ? $start : '?'); $end = dol_print_date($projectstatic->date_end, 'day'); print ' - '; - print ($end?$end:'?'); + print ($end ? $end : '?'); if ($projectstatic->hasDelay()) print img_warning("Late"); print '
        '.$langs->trans("BillTime").''; print yn($projectstatic->usage_bill_time); @@ -697,10 +697,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Date start - Date end print '
        '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start, 'dayhour'); - print ($start?$start:'?'); + print ($start ? $start : '?'); $end = dol_print_date($object->date_end, 'dayhour'); print ' - '; - print ($end?$end:'?'); + print ($end ? $end : '?'); if ($object->hasDelay()) print img_warning("Late"); print '
        '.$langs->trans("ProgressCalculated").''; if ($object->planned_workload) { - $tmparray=$object->getSummaryOfTimeSpent(); - if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration']/$object->planned_workload*100, 2).' %'; + $tmparray = $object->getSummaryOfTimeSpent(); + if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; else print '0 %'; } else print ''.$langs->trans("WorkloadNotDefined").''; @@ -752,9 +752,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($projectstatic->id > 0) { - if ($action == 'deleteline' && ! empty($projectidforalltimes)) + if ($action == 'deleteline' && !empty($projectidforalltimes)) { - print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id>0?"id=".$object->id:'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid', 'int').($withproject?'&withproject=1':''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_delete", '', '', 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid', 'int').($withproject ? '&withproject=1' : ''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_delete", '', '', 1); } // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array @@ -839,7 +839,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print $langs->trans('Mode'); print ''; - $tmparray=array( + $tmparray = array( 'onelineperuser'=>'OneLinePerUser', //'onelinepertask'=>'OneLinePerTask', ); @@ -890,7 +890,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $sql .= " ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; if (empty($projectidforalltimes)) $sql .= " AND t.fk_task =".$object->id; - else $sql.= " AND pt.fk_projet IN (".$projectidforalltimes.")"; + else $sql .= " AND pt.fk_projet IN (".$projectidforalltimes.")"; if ($search_ref) $sql .= natural_search('c.ref', $search_ref); if ($search_note) $sql .= natural_search('t.note', $search_note); if ($search_task_ref) $sql .= natural_search('pt.ref', $search_task_ref); @@ -920,10 +920,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -934,11 +934,11 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($num >= 0) { - if (! empty($projectidforalltimes)) + if (!empty($projectidforalltimes)) { print ''."\n"; - $title=$langs->trans("ListTaskTimeUserProject"); + $title = $langs->trans("ListTaskTimeUserProject"); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $linktocreatetime, '', $limit); } @@ -946,7 +946,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { print ''."\n"; - $title=$langs->trans("ListTaskTimeForTask"); + $title = $langs->trans("ListTaskTimeForTask"); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $linktocreatetime, '', $limit); } @@ -971,7 +971,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($action == 'createtime' && $user->rights->projet->lire) { print ''."\n"; - if (! empty($id)) print ''; + if (!empty($id)) print ''; print '
        '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; @@ -983,7 +983,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; print ''; print ''; - if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print ''; } @@ -995,8 +995,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Date print ''; // Task @@ -1159,40 +1159,40 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $total = 0; $totalvalue = 0; - $totalarray=array(); + $totalarray = array(); foreach ($tasks as $task_time) { if ($i >= $limit) break; print ''; - $date1=$db->jdate($task_time->task_date); - $date2=$db->jdate($task_time->task_datehour); + $date1 = $db->jdate($task_time->task_date); + $date2 = $db->jdate($task_time->task_datehour); // Date - if (! empty($arrayfields['t.task_date']['checked'])) + if (!empty($arrayfields['t.task_date']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Task ref - if (! empty($arrayfields['t.task_ref']['checked'])) + if (!empty($arrayfields['t.task_ref']['checked'])) { - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } } // Task label - if (! empty($arrayfields['t.task_label']['checked'])) + if (!empty($arrayfields['t.task_label']['checked'])) { - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } } // User - if (! empty($arrayfields['author']['checked'])) + if (!empty($arrayfields['author']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Note - if (! empty($arrayfields['t.note']['checked'])) + if (!empty($arrayfields['t.note']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } elseif ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { @@ -1268,7 +1268,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Time spent - if (! empty($arrayfields['t.task_duration']['checked'])) + if (!empty($arrayfields['t.task_duration']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalvaluebilledfield']=$totalarray['nbfield']; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['totalvaluebilledfield'] = $totalarray['nbfield']; $totalarray['totalvaluebilled'] += $valuebilled; } @@ -1340,8 +1340,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) */ // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$task_time); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -1377,15 +1377,15 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($task_time->rowid, $arrayofselected)) $selected=1; + $selected = 0; + if (in_array($task_time->rowid, $arrayofselected)) $selected = 1; print ' '; - print ''; + print ''; } } } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; @@ -1396,28 +1396,28 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; // Date - if (! empty($arrayfields['t.task_date']['checked'])) + if (!empty($arrayfields['t.task_date']['checked'])) { print ''; } // Task ref - if (! empty($arrayfields['t.task_ref']['checked'])) + if (!empty($arrayfields['t.task_ref']['checked'])) { - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task { print ''; // Date - if (! empty($arrayfields['t.task_date']['checked'])) + if (!empty($arrayfields['t.task_date']['checked'])) { print ''; } // Task ref - if (! empty($arrayfields['t.task_ref']['checked'])) + if (!empty($arrayfields['t.task_ref']['checked'])) { - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task { print ''; } @@ -620,20 +620,20 @@ if ($action == "view_ticketlist") } if (!empty($arrayfields['t.tms']['checked'])) { - print ''; + print ''; } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (!empty($arrayfields["ef." . $key]['checked'])) { + if (!empty($arrayfields["ef.".$key]['checked'])) { print 'getAlignFlag($key); if ($align) { - print ' align="' . $align . '"'; + print ' align="'.$align.'"'; } print '>'; - $tmpkey = 'options_' . $key; + $tmpkey = 'options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; } @@ -657,8 +657,8 @@ if ($action == "view_ticketlist") print '
        '.$langs->trans("Note").''.$langs->trans("NewTimeSpent").''.$langs->trans("ProgressDeclared").''; //$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]); - $newdate=''; - print $form->selectDate($newdate, 'time', ($conf->browser->layout == 'phone'?2:1), 1, 2, "timespent_date", 1, 0); + $newdate = ''; + print $form->selectDate($newdate, 'time', ($conf->browser->layout == 'phone' ? 2 : 1), 1, 2, "timespent_date", 1, 0); print '
        '; if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { if (empty($task_time->task_date_withhour)) { - print $form->selectDate(($date2?$date2:$date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); + print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); } - else print $form->selectDate(($date2?$date2:$date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); + else print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); } else { - print dol_print_date(($date2?$date2:$date1), ($task_time->task_date_withhour?'dayhour':'day')); + print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); } print ''; $tasktmp->id = $task_time->fk_task; @@ -1200,55 +1200,55 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $tasktmp->label = $task_time->label; print $tasktmp->getNomUrl(1, 'withproject', 'time'); print ''; print $task_time->label; print ''; if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { if (empty($object->id)) $object->fetch($id); - $contactsoftask=$object->getListContactId('internal'); + $contactsoftask = $object->getListContactId('internal'); if (!in_array($task_time->fk_user, $contactsoftask)) { - $contactsoftask[]=$task_time->fk_user; + $contactsoftask[] = $task_time->fk_user; } - if (count($contactsoftask)>0) { + if (count($contactsoftask) > 0) { print img_object('', 'user', 'class="hideonsmartphone"'); print $form->select_dolusers($task_time->fk_user, 'userid_line', 0, '', 0, '', $contactsoftask); - }else { + } else { print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); } } else { $userstatic->id = $task_time->fk_user; - $userstatic->lastname = $task_time->lastname; + $userstatic->lastname = $task_time->lastname; $userstatic->firstname = $task_time->firstname; $userstatic->photo = $task_time->photo; $userstatic->statut = $task_time->user_status; print $userstatic->getNomUrl(-1); } print ''; if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) @@ -1260,7 +1260,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print dol_nl2br($task_time->note); } print ''; if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) @@ -1329,8 +1329,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } } print '
        '; if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { if (empty($task_time->task_date_withhour)) { - print $form->selectDate(($date2?$date2:$date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); + print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); } - else print $form->selectDate(($date2?$date2:$date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); + else print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); } else { - print dol_print_date(($date2?$date2:$date1), ($task_time->task_date_withhour?'dayhour':'day')); + print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); } print ''; $tasktmp->id = $task_time->fk_task; @@ -1429,9 +1429,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Task label - if (! empty($arrayfields['t.task_label']['checked'])) + if (!empty($arrayfields['t.task_label']['checked'])) { - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task { print ''; print $task_time->label; @@ -1440,27 +1440,27 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // User - if (! empty($arrayfields['author']['checked'])) + if (!empty($arrayfields['author']['checked'])) { print ''; if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { if (empty($object->id)) $object->fetch($id); - $contactsoftask=$object->getListContactId('internal'); + $contactsoftask = $object->getListContactId('internal'); if (!in_array($task_time->fk_user, $contactsoftask)) { - $contactsoftask[]=$task_time->fk_user; + $contactsoftask[] = $task_time->fk_user; } - if (count($contactsoftask)>0) { + if (count($contactsoftask) > 0) { print img_object('', 'user', 'class="hideonsmartphone"'); print $form->select_dolusers($task_time->fk_user, 'userid_line', 0, '', 0, '', $contactsoftask); - }else { + } else { print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); } } else { $userstatic->id = $task_time->fk_user; - $userstatic->lastname = $task_time->lastname; + $userstatic->lastname = $task_time->lastname; $userstatic->firstname = $task_time->firstname; $userstatic->photo = $task_time->photo; $userstatic->statut = $task_time->user_status; @@ -1470,7 +1470,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Note - if (! empty($arrayfields['t.note']['checked'])) + if (!empty($arrayfields['t.note']['checked'])) { print ''; if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) @@ -1489,7 +1489,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Time spent - if (! empty($arrayfields['t.task_duration']['checked'])) + if (!empty($arrayfields['t.task_duration']['checked'])) { print ''; if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) @@ -1505,7 +1505,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Value spent - if (! empty($arrayfields['value']['checked'])) + if (!empty($arrayfields['value']['checked'])) { print ''; $value = price2num($task_time->thm * $task_time->task_duration / 3600); @@ -1514,7 +1514,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Value billed - if (! empty($arrayfields['valuebilled']['checked'])) + if (!empty($arrayfields['valuebilled']['checked'])) { print ''; $valuebilled = price2num($task_time->total_ht); @@ -1528,8 +1528,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) */ // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$task_time); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -1544,28 +1544,28 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
        '; if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { if (empty($task_time->task_date_withhour)) { - print $form->selectDate(($date2?$date2:$date1), 'timeline_2', 3, 3, 2, "timespent_date", 1, 0); + print $form->selectDate(($date2 ? $date2 : $date1), 'timeline_2', 3, 3, 2, "timespent_date", 1, 0); } - else print $form->selectDate(($date2?$date2:$date1), 'timeline_2', 1, 1, 2, "timespent_date", 1, 0); + else print $form->selectDate(($date2 ? $date2 : $date1), 'timeline_2', 1, 1, 2, "timespent_date", 1, 0); } else { - print dol_print_date(($date2?$date2:$date1), ($task_time->task_date_withhour?'dayhour':'day')); + print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); } print ''; $tasktmp->id = $task_time->fk_task; @@ -1577,9 +1577,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Task label - if (! empty($arrayfields['t.task_label']['checked'])) + if (!empty($arrayfields['t.task_label']['checked'])) { - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task { print ''; print $task_time->label; @@ -1588,27 +1588,27 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // User - if (! empty($arrayfields['author']['checked'])) + if (!empty($arrayfields['author']['checked'])) { print ''; if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { if (empty($object->id)) $object->fetch($id); - $contactsoftask=$object->getListContactId('internal'); + $contactsoftask = $object->getListContactId('internal'); if (!in_array($task_time->fk_user, $contactsoftask)) { - $contactsoftask[]=$task_time->fk_user; + $contactsoftask[] = $task_time->fk_user; } - if (count($contactsoftask)>0) { + if (count($contactsoftask) > 0) { print img_object('', 'user', 'class="hideonsmartphone"'); print $form->select_dolusers($task_time->fk_user, 'userid_line_2', 0, '', 0, '', $contactsoftask); - }else { + } else { print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); } } else { $userstatic->id = $task_time->fk_user; - $userstatic->lastname = $task_time->lastname; + $userstatic->lastname = $task_time->lastname; $userstatic->firstname = $task_time->firstname; $userstatic->photo = $task_time->photo; $userstatic->statut = $task_time->user_status; @@ -1618,7 +1618,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Note - if (! empty($arrayfields['t.note']['checked'])) + if (!empty($arrayfields['t.note']['checked'])) { print ''; if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) @@ -1637,7 +1637,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Time spent - if (! empty($arrayfields['t.task_duration']['checked'])) + if (!empty($arrayfields['t.task_duration']['checked'])) { print ''; if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) @@ -1653,7 +1653,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Value spent - if (! empty($arrayfields['value']['checked'])) + if (!empty($arrayfields['value']['checked'])) { print ''; $value = 0; @@ -1662,7 +1662,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Value billed - if (! empty($arrayfields['valuebilled']['checked'])) + if (!empty($arrayfields['valuebilled']['checked'])) { print ''; $valuebilled = price2num($task_time->total_ht); @@ -1676,8 +1676,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) */ // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$task_time); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index 9bfd6d1736c..2c8b23396c7 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -25,20 +25,20 @@ * This token can be used to get more informations. */ -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +define("NOLOGIN", 1); // This means this output page does not require to be logged. +define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php // TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['e']) ? (int) $_GET['e'] : (! empty($_POST['e']) ? (int) $_POST['e'] : 1)); +$entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; -if (! empty($conf->paypal->enabled)) +if (!empty($conf->paypal->enabled)) { require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; @@ -46,31 +46,31 @@ if (! empty($conf->paypal->enabled)) $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal", "stripe")); -if (! empty($conf->paypal->enabled)) +if (!empty($conf->paypal->enabled)) { - $PAYPALTOKEN=GETPOST('TOKEN'); - if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); - $PAYPALPAYERID=GETPOST('PAYERID'); - if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); + $PAYPALTOKEN = GETPOST('TOKEN'); + if (empty($PAYPALTOKEN)) $PAYPALTOKEN = GETPOST('token'); + $PAYPALPAYERID = GETPOST('PAYERID'); + if (empty($PAYPALPAYERID)) $PAYPALPAYERID = GETPOST('PayerID'); } -if (! empty($conf->paybox->enabled)) +if (!empty($conf->paybox->enabled)) { } -if (! empty($conf->stripe->enabled)) +if (!empty($conf->stripe->enabled)) { } -$FULLTAG=GETPOST('FULLTAG'); -if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); +$FULLTAG = GETPOST('FULLTAG'); +if (empty($FULLTAG)) $FULLTAG = GETPOST('fulltag'); -$suffix=GETPOST("suffix", 'aZ09'); +$suffix = GETPOST("suffix", 'aZ09'); // Detect $paymentmethod -$paymentmethod=''; +$paymentmethod = ''; if (preg_match('/PM=([^\.]+)/', $FULLTAG, $reg)) { - $paymentmethod=$reg[1]; + $paymentmethod = $reg[1]; } if (empty($paymentmethod)) { @@ -83,17 +83,17 @@ else } -$validpaymentmethod=array(); -if (! empty($conf->paypal->enabled)) $validpaymentmethod['paypal']='paypal'; -if (! empty($conf->paybox->enabled)) $validpaymentmethod['paybox']='paybox'; -if (! empty($conf->stripe->enabled)) $validpaymentmethod['stripe']='stripe'; +$validpaymentmethod = array(); +if (!empty($conf->paypal->enabled)) $validpaymentmethod['paypal'] = 'paypal'; +if (!empty($conf->paybox->enabled)) $validpaymentmethod['paybox'] = 'paybox'; +if (!empty($conf->stripe->enabled)) $validpaymentmethod['stripe'] = 'stripe'; // Security check if (empty($validpaymentmethod)) accessforbidden('', 0, 0, 1); -$object = new stdClass(); // For triggers +$object = new stdClass(); // For triggers /* @@ -107,19 +107,19 @@ $object = new stdClass(); // For triggers * View */ -dol_syslog("Callback url when an online payment is refused or canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_payment'); +dol_syslog("Callback url when an online payment is refused or canceled. query_string=".(empty($_SERVER["QUERY_STRING"]) ? '' : $_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"]) ? '' : $_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_payment'); $tracepost = ""; -foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; +foreach ($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); -if (! empty($_SESSION['ipaddress'])) // To avoid to make action twice +if (!empty($_SESSION['ipaddress'])) // To avoid to make action twice { // Get on url call $fulltag = $FULLTAG; - $onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN; - $payerID = empty($PAYPALPAYERID)?$_SESSION['payerID']:$PAYPALPAYERID; + $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION['onlinetoken'] : $PAYPALTOKEN; + $payerID = empty($PAYPALPAYERID) ? $_SESSION['payerID'] : $PAYPALPAYERID; // Set by newpayment.php $paymentType = $_SESSION['PaymentType']; $currencyCodeType = $_SESSION['currencyCodeType']; @@ -129,15 +129,15 @@ if (! empty($_SESSION['ipaddress'])) // To avoid to make action twice $errormessage = $_SESSION['errormessage']; // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('PAYMENTONLINE_PAYMENT_KO', $object, $user, $langs, $conf); - if ($result < 0) { $error++; $errors=$interface->errors; } + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interface = new Interfaces($db); + $result = $interface->run_triggers('PAYMENTONLINE_PAYMENT_KO', $object, $user, $langs, $conf); + if ($result < 0) { $error++; $errors = $interface->errors; } // Fin appel triggers // Send an email $sendemail = ''; - if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) + if (!empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) { $sendemail = $conf->global->ONLINE_PAYMENT_SENDEMAIL; } @@ -147,43 +147,43 @@ if (! empty($_SESSION['ipaddress'])) // To avoid to make action twice { $companylangs = new Translate('', $conf); $companylangs->setDefaultLang($mysoc->default_lang); - $companylangs->loadLangs(array('main','members','bills','paypal','paybox')); + $companylangs->loadLangs(array('main', 'members', 'bills', 'paypal', 'paybox')); - $from=$conf->global->MAILING_EMAIL_FROM; - $sendto=$sendemail; + $from = $conf->global->MAILING_EMAIL_FROM; + $sendto = $sendemail; // Define link to login card - $appli=constant('DOL_APPLICATION_TITLE'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) + $appli = constant('DOL_APPLICATION_TITLE'); + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { - $appli=$conf->global->MAIN_APPLICATION_TITLE; + $appli = $conf->global->MAIN_APPLICATION_TITLE; if (preg_match('/\d\.\d/', $appli)) { - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core + if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core } - else $appli.=" ".DOL_VERSION; + else $appli .= " ".DOL_VERSION; } - else $appli.=" ".DOL_VERSION; + else $appli .= " ".DOL_VERSION; - $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$companylangs->transnoentitiesnoconv("NewOnlinePaymentFailed"); - $content=""; - $content.=''.$companylangs->transnoentitiesnoconv("ValidationOfOnlinePaymentFailed")."\n"; + $urlback = $_SERVER["REQUEST_URI"]; + $topic = '['.$appli.'] '.$companylangs->transnoentitiesnoconv("NewOnlinePaymentFailed"); + $content = ""; + $content .= ''.$companylangs->transnoentitiesnoconv("ValidationOfOnlinePaymentFailed")."\n"; - $content.="

        \n"; - $content.=''.$companylangs->transnoentitiesnoconv("TechnicalInformation").":
        \n"; - $content.=$companylangs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
        \n"; - $content.=$companylangs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
        \n"; - $content.=$companylangs->transnoentitiesnoconv("Error").': '.$errormessage."
        \n"; - $content.="
        \n"; - $content.="tag=".$fulltag." token=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + $content .= "

        \n"; + $content .= ''.$companylangs->transnoentitiesnoconv("TechnicalInformation").":
        \n"; + $content .= $companylangs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
        \n"; + $content .= $companylangs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
        \n"; + $content .= $companylangs->transnoentitiesnoconv("Error").': '.$errormessage."
        \n"; + $content .= "
        \n"; + $content .= "tag=".$fulltag." token=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; - $ishtml=dol_textishtml($content); // May contain urls + $ishtml = dol_textishtml($content); // May contain urls require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); @@ -197,11 +197,11 @@ if (! empty($_SESSION['ipaddress'])) // To avoid to make action twice unset($_SESSION['ipaddress']); } -$head=''; -if (! empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head=''."\n"; +$head = ''; +if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head = ''."\n"; -$conf->dol_hide_topmenu=1; -$conf->dol_hide_leftmenu=1; +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); @@ -212,25 +212,25 @@ print '
        '."\n"; // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) -$width=0; +$width = 0; // Define logo and logosmall -$logosmall=$mysoc->logo_small; -$logo=$mysoc->logo; -$paramlogo='ONLINE_PAYMENT_LOGO_'.$suffix; -if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo; -elseif (! empty($conf->global->ONLINE_PAYMENT_LOGO)) $logosmall=$conf->global->ONLINE_PAYMENT_LOGO; +$logosmall = $mysoc->logo_small; +$logo = $mysoc->logo; +$paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix; +if (!empty($conf->global->$paramlogo)) $logosmall = $conf->global->$paramlogo; +elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) $logosmall = $conf->global->ONLINE_PAYMENT_LOGO; //print ''."\n"; // Define urllogo -$urllogo=''; -if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) +$urllogo = ''; +if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$logosmall); - $width=150; + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$logosmall); + $width = 150; } -elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) +elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$logo); - $width=150; + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$logo); + $width = 150; } // Output html code for logo if ($urllogo) @@ -243,8 +243,8 @@ if ($urllogo) print $langs->trans("YourPaymentHasNotBeenRecorded")."

        "; -$key='ONLINE_PAYMENT_MESSAGE_KO'; -if (! empty($conf->global->$key)) print $conf->global->$key; +$key = 'ONLINE_PAYMENT_MESSAGE_KO'; +if (!empty($conf->global->$key)) print $conf->global->$key; $type = GETPOST('s', 'alpha'); $ref = GETPOST('ref', 'none'); diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 9829aa03f7b..8d5d07ec374 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","other","ticket")); +$langs->loadLangs(array("companies", "other", "ticket")); // Get parameters $track_id = GETPOST('track_id', 'alpha'); @@ -278,7 +278,7 @@ if ($action == "view_ticketlist") $param .= '&search_fk_status=non_closed'; } - require DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; + require DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -325,54 +325,54 @@ if ($action == "view_ticketlist") // Add fields for extrafields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key . ' as options_' . $key : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } - $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_type as type ON type.code=t.type_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_category as category ON category.code=t.category_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid=t.fk_soc"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as uc ON uc.rowid=t.fk_user_create"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as ua ON ua.rowid=t.fk_user_assign"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON ec.element_id=t.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON ec.fk_c_type_contact=tc.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople sp ON ec.fk_socpeople=sp.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as uc ON uc.rowid=t.fk_user_create"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON ua.rowid=t.fk_user_assign"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id=t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON ec.fk_c_type_contact=tc.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople sp ON ec.fk_socpeople=sp.rowid"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "ticket_extrafields as ef on (t.rowid = ef.fk_object)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields as ef on (t.rowid = ef.fk_object)"; } - $sql .= " WHERE t.entity IN (" . getEntity('ticket') . ")"; + $sql .= " WHERE t.entity IN (".getEntity('ticket').")"; $sql .= " AND ((tc.source = 'external'"; - $sql .= " AND tc.element='" . $db->escape($object->dao->element) . "'"; + $sql .= " AND tc.element='".$db->escape($object->dao->element)."'"; $sql .= " AND tc.active=1)"; - $sql .= " OR (sp.email='" . $db->escape($_SESSION['email_customer']) . "'"; - $sql .= " OR s.email='" . $db->escape($_SESSION['email_customer']) . "'"; - $sql .= " OR t.origin_email='" . $db->escape($_SESSION['email_customer']) . "'))"; + $sql .= " OR (sp.email='".$db->escape($_SESSION['email_customer'])."'"; + $sql .= " OR s.email='".$db->escape($_SESSION['email_customer'])."'"; + $sql .= " OR t.origin_email='".$db->escape($_SESSION['email_customer'])."'))"; // Manage filter if (!empty($filter)) { foreach ($filter as $key => $value) { if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year - $sql .= ' AND ' . $key . ' = \'' . $value . '\''; + $sql .= ' AND '.$key.' = \''.$value.'\''; } elseif (($key == 't.fk_user_assign') || ($key == 't.type_code') || ($key == 't.category_code') || ($key == 't.severity_code')) { - $sql .= " AND " . $key . " = '" . $db->escape($value) ."'"; + $sql .= " AND ".$key." = '".$db->escape($value)."'"; } elseif ($key == 't.fk_statut') { if (is_array($value) && count($value) > 0) { - $sql .= 'AND ' . $key . ' IN (' . implode(',', $value) . ')'; + $sql .= 'AND '.$key.' IN ('.implode(',', $value).')'; } else { - $sql .= ' AND ' . $key . ' = ' . $db->escape($value); + $sql .= ' AND '.$key.' = '.$db->escape($value); } } else { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } } } //$sql .= " GROUP BY t.track_id"; - $sql .= " ORDER BY " . $sortfield . ' ' . $sortorder; + $sql .= " ORDER BY ".$sortfield.' '.$sortorder; $resql = $db->query($sql); if ($resql) { $num_total = $db->num_rows($resql); if (!empty($limit)) { - $sql .= ' ' . $db->plimit($limit + 1, $offset); + $sql .= ' '.$db->plimit($limit + 1, $offset); } $resql = $db->query($sql); @@ -561,7 +561,7 @@ if ($action == "view_ticketlist") // Subject if (!empty($arrayfields['t.subject']['checked'])) { print '
        '; - print '' . $obj->subject . ''; + print ''.$obj->subject.''; print '' . dol_print_date($db->jdate($obj->tms), 'dayhour') . ''.dol_print_date($db->jdate($obj->tms), 'dayhour').'
        '; print ''; - print '
        '; print $resource->getNomUrl(5); print ''; print $resource->type_label; print '
        '.$langs->trans("NoRecordFound").'
        '; // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } @@ -163,8 +163,8 @@ if ($object->id) $modulepart = 'societe'; $permission = $user->rights->societe->creer; $permtoedit = $user->rights->societe->creer; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 132b9db3cf5..947cee547b0 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -45,13 +45,13 @@ $langs->loadLangs(array("admin", "cashdesk")); global $db; $sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement"; -$sql.= " WHERE entity IN (".getEntity('c_paiement').")"; -$sql.= " AND active = 1"; -$sql.= " ORDER BY libelle"; +$sql .= " WHERE entity IN (".getEntity('c_paiement').")"; +$sql .= " AND active = 1"; +$sql .= " ORDER BY libelle"; $resql = $db->query($sql); $paiements = array(); -if($resql){ - while ($obj = $db->fetch_object($resql)){ +if ($resql) { + while ($obj = $db->fetch_object($resql)) { array_push($paiements, $obj); } } @@ -82,7 +82,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_CUSTOM_RECEIPT", GETPOST('TAKEPOS_CUSTOM_RECEIPT', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); - if ($conf->global->TAKEPOS_ORDER_NOTES==1) + if ($conf->global->TAKEPOS_ORDER_NOTES == 1) { $extrafields = new ExtraFields($db); $extrafields->addExtraField('order_notes', 'Order notes', 'varchar', 0, 255, 'facturedet', 0, 0, '', '', 0, '', 0, 1); @@ -90,9 +90,9 @@ if (GETPOST('action', 'alpha') == 'set') dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -108,12 +108,12 @@ if (GETPOST('action', 'alpha') == 'set') * View */ -$form=new Form($db); -$formproduct=new FormProduct($db); +$form = new Form($db); +$formproduct = new FormProduct($db); llxHeader('', $langs->trans("CashDeskSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup'); $head = takepos_prepare_head(); dol_fiche_head($head, 'setup', 'TakePOS', -1); @@ -197,7 +197,7 @@ print '\n"; -if ($conf->global->TAKEPOS_BAR_RESTAURANT && $conf->global->TAKEPOSCONNECTOR){ +if ($conf->global->TAKEPOS_BAR_RESTAURANT && $conf->global->TAKEPOSCONNECTOR) { print ''; print ''; print "\n"; -$url='https://www.dolistore.com/45-pos'; +$url = 'https://www.dolistore.com/45-pos'; print ''; print ''; print ''; @@ -308,7 +308,7 @@ print ''; print ''; print "\n"; -$url='http://www.takepos.com'; +$url = 'http://www.takepos.com'; print ''; print ''; print ''; diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index cd45d0c1792..7fcd7a5f9d0 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -115,7 +115,7 @@ function updateplace(idplace, left, top) { url: "floors.php", data: { action: "update", left: left, top: top, place: idplace } }).done(function( msg ) { - window.location.href='floors.php?mode=edit&floor='; + window.location.href='floors.php?mode=edit&floor='; }); } @@ -127,7 +127,7 @@ function updatename(rowid) { url: "floors.php", data: { action: "updatename", place: rowid, newname: after } }).done(function( msg ) { - window.location.href='floors.php?mode=edit&floor='; + window.location.href='floors.php?mode=edit&floor='; }); } @@ -139,7 +139,7 @@ function LoadPlace(place){ $( document ).ready(function() { $.getJSON('./floors.php?action=getTables&floor=', function(data) { $.each(data, function(key, val) { - + $('body').append('
        '+val.label+'
        '); $( "#tablename"+val.rowid ).draggable( { @@ -181,8 +181,8 @@ $( document ).ready(function() {

        - 1) { ?> - ';"> + 1) { ?> + ';"> trans("Floor")." ".$floor; ?> diff --git a/htdocs/takepos/freezone.php b/htdocs/takepos/freezone.php index aa86f1d66a8..4de8dd8b85f 100644 --- a/htdocs/takepos/freezone.php +++ b/htdocs/takepos/freezone.php @@ -50,7 +50,7 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); ?> '; // Checkbox to select from free text -print ' '.$langs->trans("FillBarCodeTypeAndValueManually").'   '; +print ' '.$langs->trans("FillBarCodeTypeAndValueManually").'   '; print '
        '; -if (! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)) +if (!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)) { - print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; print '
        '; print '
        '; $form->select_produits(GETPOST('productid'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); @@ -385,9 +385,9 @@ if (! empty($user->rights->produit->lire) || ! empty($user->rights->service->lir print '
        '; } -if (! empty($user->rights->societe->lire)) +if (!empty($user->rights->societe->lire)) { - print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; print '
        '; print '
        '; print $form->select_company(GETPOST('socid'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); @@ -435,7 +435,7 @@ print '
        '; print '
        '; -print '
        '; +print '
        '; print ''; print '
        '; diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index cec6410b7b6..234aeceb2a6 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -67,12 +67,12 @@ class BlockedLogAuthority $this->signature = $block_static->getSignature(); - $blocks = $block_static->getLog('all', 0, 0, 'rowid', 'ASC') ; + $blocks = $block_static->getLog('all', 0, 0, 'rowid', 'ASC'); $this->blockchain = ''; - foreach($blocks as &$b) { - $this->blockchain.=$b->signature; + foreach ($blocks as &$b) { + $this->blockchain .= $b->signature; } return $this->blockchain; @@ -98,7 +98,7 @@ class BlockedLogAuthority public function checkBlockchain($hash) { - return ($hash === $this->getBlockchainHash() ); + return ($hash === $this->getBlockchainHash()); } /** @@ -110,7 +110,7 @@ class BlockedLogAuthority public function addBlock($block) { - $this->blockchain.=$block; + $this->blockchain .= $block; } /** @@ -122,14 +122,14 @@ class BlockedLogAuthority public function checkBlock($block) { - if(strlen($block)!=64) return false; + if (strlen($block) != 64) return false; $blocks = str_split($this->blockchain, 64); - if(!in_array($block, $blocks)) { + if (!in_array($block, $blocks)) { return true; } - else{ + else { return false; } } @@ -151,44 +151,44 @@ class BlockedLogAuthority if (empty($id) && empty($signature)) { - $this->error='BadParameter'; + $this->error = 'BadParameter'; return -1; } $langs->load("blockedlog"); $sql = "SELECT b.rowid, b.signature, b.blockchain, b.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog_authority as b"; + $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog_authority as b"; - if ($id) $sql.= " WHERE b.rowid = ". $id; - elseif($signature)$sql.= " WHERE b.signature = '". $this->db->escape($signature) ."'" ; + if ($id) $sql .= " WHERE b.rowid = ".$id; + elseif ($signature)$sql .= " WHERE b.signature = '".$this->db->escape($signature)."'"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; - $this->signature = $obj->signature; - $this->blockchain = $obj->blockchain; + $this->signature = $obj->signature; + $this->blockchain = $obj->blockchain; - $this->tms = $this->db->jdate($obj->tms); + $this->tms = $this->db->jdate($obj->tms); return 1; } else { - $this->error=$langs->trans("RecordNotFound"); + $this->error = $langs->trans("RecordNotFound"); return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -202,23 +202,23 @@ class BlockedLogAuthority public function create($user) { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; $langs->load('blockedlog'); - $error=0; + $error = 0; dol_syslog(get_class($this).'::create', LOG_DEBUG); $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog_authority ("; - $sql.= " signature,"; - $sql.= " blockchain"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->signature)."',"; - $sql.= "'".$this->db->escape($this->blockchain)."'"; - $sql.= ")"; + $sql .= " signature,"; + $sql .= " blockchain"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->signature)."',"; + $sql .= "'".$this->db->escape($this->blockchain)."'"; + $sql .= ")"; $res = $this->db->query($sql); if ($res) @@ -241,7 +241,7 @@ class BlockedLogAuthority } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -256,19 +256,19 @@ class BlockedLogAuthority public function update($user) { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; $langs->load('blockedlog'); - $error=0; + $error = 0; dol_syslog(get_class($this).'::create', LOG_DEBUG); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."blockedlog_authority SET "; - $sql.= " blockchain='".$this->db->escape($this->blockchain)."'"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " blockchain='".$this->db->escape($this->blockchain)."'"; + $sql .= " WHERE rowid=".$this->id; $res = $this->db->query($sql); if ($res) @@ -279,7 +279,7 @@ class BlockedLogAuthority } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -296,7 +296,7 @@ class BlockedLogAuthority //TODO create cron task on activation - if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL) || empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { + if (empty($conf->global->BLOCKEDLOG_AUTHORITY_URL) || empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { $this->error = $langs->trans('NoAuthorityURLDefined'); return -2; } @@ -307,14 +307,14 @@ class BlockedLogAuthority $blocks = $block_static->getLog('not_certified', 0, 0, 'rowid', 'ASC'); - $signature=$block_static->getSignature(); + $signature = $block_static->getSignature(); - foreach($blocks as &$block) { + foreach ($blocks as &$block) { $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$signature.'&b='.$block->signature; $res = file_get_contents($url); - echo $block->signature.' '.$url. ' '.$res.'
        '; - if($res === 'blockalreadyadded' || $res === 'blockadded') { + echo $block->signature.' '.$url.' '.$res.'
        '; + if ($res === 'blockalreadyadded' || $res === 'blockadded') { $block->setCertified(); } else { diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 14dbd9941b7..3c6f7563590 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -115,7 +115,7 @@ class BlockedLog public $ref_object = ''; public $object_data = null; - public $user_fullname=''; + public $user_fullname = ''; /** * Array of tracked event codes @@ -138,14 +138,14 @@ class BlockedLog $this->trackedevents = array(); - if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE']='logBILL_VALIDATE'; - if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE']='logBILL_DELETE'; - if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL']='logBILL_SENTBYMAIL'; - if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD']='BlockedLogBillDownload'; - if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW']='BlockedLogBillPreview'; + if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE'] = 'logBILL_VALIDATE'; + if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE'] = 'logBILL_DELETE'; + if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL'] = 'logBILL_SENTBYMAIL'; + if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD'] = 'BlockedLogBillDownload'; + if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW'] = 'BlockedLogBillPreview'; - if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE']='logPAYMENT_CUSTOMER_CREATE'; - if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE']='logPAYMENT_CUSTOMER_DELETE'; + if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE'] = 'logPAYMENT_CUSTOMER_CREATE'; + if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE'] = 'logPAYMENT_CUSTOMER_DELETE'; /* Supplier if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate'; @@ -158,12 +158,12 @@ class BlockedLog if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='BlockedLogsupplierBillPaymentCreate'; */ - if ($conf->don->enabled) $this->trackedevents['DON_VALIDATE']='logDON_VALIDATE'; - if ($conf->don->enabled) $this->trackedevents['DON_DELETE']='logDON_DELETE'; + if ($conf->don->enabled) $this->trackedevents['DON_VALIDATE'] = 'logDON_VALIDATE'; + if ($conf->don->enabled) $this->trackedevents['DON_DELETE'] = 'logDON_DELETE'; //if ($conf->don->enabled) $this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL'; - if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_CREATE']='logDONATION_PAYMENT_CREATE'; - if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_DELETE']='logDONATION_PAYMENT_DELETE'; + if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_CREATE'] = 'logDONATION_PAYMENT_CREATE'; + if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_DELETE'] = 'logDONATION_PAYMENT_DELETE'; /* if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate'; @@ -171,18 +171,18 @@ class BlockedLog if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate'; */ - if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE']='logMEMBER_SUBSCRIPTION_CREATE'; - if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY']='logMEMBER_SUBSCRIPTION_MODIFY'; - if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE']='logMEMBER_SUBSCRIPTION_DELETE'; + if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE'] = 'logMEMBER_SUBSCRIPTION_CREATE'; + if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY'] = 'logMEMBER_SUBSCRIPTION_MODIFY'; + if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE'] = 'logMEMBER_SUBSCRIPTION_DELETE'; - if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE']='logPAYMENT_VARIOUS_CREATE'; - if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY']='logPAYMENT_VARIOUS_MODIFY'; - if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE']='logPAYMENT_VARIOUS_DELETE'; + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE'] = 'logPAYMENT_VARIOUS_CREATE'; + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY'] = 'logPAYMENT_VARIOUS_MODIFY'; + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE'] = 'logPAYMENT_VARIOUS_DELETE'; // $conf->global->BANK_ENABLE_POS_CASHCONTROL must be set to 1 by all POS modules - $moduleposenabled = ($conf->cashdesk->enabled || $conf->takepos->enabled || ! empty($conf->global->BANK_ENABLE_POS_CASHCONTROL)); - if ($moduleposenabled) $this->trackedevents['CASHCONTROL_VALIDATE']='logCASHCONTROL_VALIDATE'; + $moduleposenabled = ($conf->cashdesk->enabled || $conf->takepos->enabled || !empty($conf->global->BANK_ENABLE_POS_CASHCONTROL)); + if ($moduleposenabled) $this->trackedevents['CASHCONTROL_VALIDATE'] = 'logCASHCONTROL_VALIDATE'; } /** @@ -193,102 +193,102 @@ class BlockedLog { global $langs; - if($this->element === 'facture') { + if ($this->element === 'facture') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - if($this->element === 'invoice_supplier') { + if ($this->element === 'invoice_supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $object = new FactureFournisseur($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment') { + elseif ($this->element === 'payment') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; $object = new Paiement($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment_supplier') { + elseif ($this->element === 'payment_supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; $object = new PaiementFourn($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment_donation') { + elseif ($this->element === 'payment_donation') { require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; $object = new PaymentDonation($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment_various') { + elseif ($this->element === 'payment_various') { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; $object = new PaymentVarious($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'don' || $this->element === 'donation') { + elseif ($this->element === 'don' || $this->element === 'donation') { require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $object = new Don($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'subscription') { + elseif ($this->element === 'subscription') { require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $object = new Subscription($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'cashcontrol') { + elseif ($this->element === 'cashcontrol') { require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; $object = new CashControl($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } @@ -318,16 +318,16 @@ class BlockedLog { global $langs, $cachedUser; - if(empty($cachedUser))$cachedUser=array(); + if (empty($cachedUser))$cachedUser = array(); - if(empty($cachedUser[$this->fk_user])) { - $u=new User($this->db); - if($u->fetch($this->fk_user)>0) { + if (empty($cachedUser[$this->fk_user])) { + $u = new User($this->db); + if ($u->fetch($this->fk_user) > 0) { $cachedUser[$this->fk_user] = $u; } } - if(!empty($cachedUser[$this->fk_user])) { + if (!empty($cachedUser[$this->fk_user])) { return $cachedUser[$this->fk_user]->getNomUrl(1); } @@ -354,25 +354,25 @@ class BlockedLog // action $this->action = $action; // amount - $this->amounts= $amounts; + $this->amounts = $amounts; // date if ($object->element == 'payment' || $object->element == 'payment_supplier') { $this->date_object = $object->datepaye; } - elseif ($object->element=='payment_salary') + elseif ($object->element == 'payment_salary') { $this->date_object = $object->datev; } elseif ($object->element == 'payment_donation' || $object->element == 'payment_various') { - $this->date_object = $object->datepaid?$object->datepaid:$object->datep; + $this->date_object = $object->datepaid ? $object->datepaid : $object->datep; } - elseif ($object->element=='subscription') + elseif ($object->element == 'subscription') { $this->date_object = $object->dateh; } - elseif ($object->element=='cashcontrol') + elseif ($object->element == 'cashcontrol') { $this->date_object = $object->date_creation; } @@ -380,7 +380,7 @@ class BlockedLog $this->date_object = $object->date; } // ref - $this->ref_object = ((! empty($object->newref)) ? $object->newref : $object->ref); // newref is set when validating a draft, ref is set in other cases + $this->ref_object = ((!empty($object->newref)) ? $object->newref : $object->ref); // newref is set when validating a draft, ref is set in other cases // type of object $this->element = $object->element; // id of object @@ -388,11 +388,11 @@ class BlockedLog // Set object_data - $this->object_data=new stdClass(); + $this->object_data = new stdClass(); // Add fields to exclude $arrayoffieldstoexclude = array( - 'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf','last_main_doc','civility_id','contact','contact_id', - 'table_element_line','ismultientitymanaged','isextrafieldmanaged', + 'table_element', 'fields', 'ref_previous', 'ref_next', 'origin', 'origin_id', 'oldcopy', 'picto', 'error', 'errors', 'modelpdf', 'last_main_doc', 'civility_id', 'contact', 'contact_id', + 'table_element_line', 'ismultientitymanaged', 'isextrafieldmanaged', 'linkedObjectsIds', 'linkedObjects', 'fk_delivery_address', @@ -402,48 +402,48 @@ class BlockedLog // Add more fields to exclude depending on object type if ($this->element == 'cashcontrol') { $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array( - 'name','lastname','firstname','region','region_id','region_code','state','state_id','state_code','country','country_id','country_code', - 'total_ht','total_tva','total_ttc','total_localtax1','total_localtax2', - 'barcode_type','barcode_type_code','barcode_type_label','barcode_type_coder','mode_reglement_id','cond_reglement_id','mode_reglement','cond_reglement','shipping_method_id', - 'fk_incoterms','label_incoterms','location_incoterms','lines') + 'name', 'lastname', 'firstname', 'region', 'region_id', 'region_code', 'state', 'state_id', 'state_code', 'country', 'country_id', 'country_code', + 'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2', + 'barcode_type', 'barcode_type_code', 'barcode_type_label', 'barcode_type_coder', 'mode_reglement_id', 'cond_reglement_id', 'mode_reglement', 'cond_reglement', 'shipping_method_id', + 'fk_incoterms', 'label_incoterms', 'location_incoterms', 'lines') ); } // Add thirdparty info if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) $object->fetch_thirdparty(); - if (! empty($object->thirdparty)) + if (!empty($object->thirdparty)) { $this->object_data->thirdparty = new stdClass(); - foreach($object->thirdparty as $key=>$value) + foreach ($object->thirdparty as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' - ))) continue; // Discard if not into a dedicated list + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->thirdparty->{$key} = $value; } } // Add company info - if (! empty($mysoc)) + if (!empty($mysoc)) { $this->object_data->mycompany = new stdClass(); - foreach($mysoc as $key=>$value) + foreach ($mysoc as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' - ))) continue; // Discard if not into a dedicated list + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->mycompany->{$key} = $value; } } // Add user info - if (! empty($user)) + if (!empty($user)) { $this->fk_user = $user->id; $this->user_fullname = $user->getFullName($langs); @@ -452,25 +452,25 @@ class BlockedLog // Field specific to object if ($this->element == 'facture') { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'ref','ref_client','ref_supplier','date','datef','datev','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public','lines' - ))) continue; // Discard if not into a dedicated list + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'datev', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public', 'lines' + ))) continue; // Discard if not into a dedicated list if ($key == 'lines') { - $lineid=0; - foreach($value as $tmpline) // $tmpline is object FactureLine + $lineid = 0; + foreach ($value as $tmpline) // $tmpline is object FactureLine { $lineid++; - foreach($tmpline as $keyline => $valueline) + foreach ($tmpline as $keyline => $valueline) { - if (! in_array($keyline, array( - 'ref','multicurrency_code','multicurrency_total_ht','multicurrency_total_tva','multicurrency_total_ttc','qty','product_type','vat_src_code','tva_tx','info_bits','localtax1_tx','localtax2_tx','total_ht','total_tva','total_ttc','total_localtax1','total_localtax2' - ))) continue; // Discard if not into a dedicated list + if (!in_array($keyline, array( + 'ref', 'multicurrency_code', 'multicurrency_total_ht', 'multicurrency_total_tva', 'multicurrency_total_ttc', 'qty', 'product_type', 'vat_src_code', 'tva_tx', 'info_bits', 'localtax1_tx', 'localtax2_tx', 'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2' + ))) continue; // Discard if not into a dedicated list - if (! is_object($this->object_data->invoiceline[$lineid])) $this->object_data->invoiceline[$lineid] = new stdClass(); + if (!is_object($this->object_data->invoiceline[$lineid])) $this->object_data->invoiceline[$lineid] = new stdClass(); $this->object_data->invoiceline[$lineid]->{$keyline} = $valueline; } @@ -479,43 +479,43 @@ class BlockedLog elseif (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } elseif ($this->element == 'invoice_supplier') { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'ref','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public' - ))) continue; // Discard if not into a dedicated list + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public' + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation' || $this->element == 'payment_various') { - $datepayment = $object->datepaye?$object->datepaye:($object->datepaid?$object->datepaid:$object->datep); - $paymenttypeid = $object->paiementid?$object->paiementid:($object->paymenttype?$object->paymenttype:$object->type_payment); + $datepayment = $object->datepaye ? $object->datepaye : ($object->datepaid ? $object->datepaid : $object->datep); + $paymenttypeid = $object->paiementid ? $object->paiementid : ($object->paymenttype ? $object->paymenttype : $object->type_payment); $this->object_data->ref = $object->ref; $this->object_data->date = $datepayment; $this->object_data->type_code = dol_getIdFromCode($this->db, $paymenttypeid, 'c_paiement', 'id', 'code'); - $this->object_data->payment_num = ($object->num_paiement?$object->num_paiement:$object->num_payment); + $this->object_data->payment_num = ($object->num_paiement ? $object->num_paiement : $object->num_payment); //$this->object_data->fk_account = $object->fk_account; $this->object_data->note = $object->note; //var_dump($this->object_data);exit; - $totalamount=0; + $totalamount = 0; - if (! is_array($object->amounts) && $object->amount) + if (!is_array($object->amounts) && $object->amount) { - $object->amounts=array($object->id => $object->amount); + $object->amounts = array($object->id => $object->amount); } - $paymentpartnumber=0; - foreach($object->amounts as $objid => $amount) + $paymentpartnumber = 0; + foreach ($object->amounts as $objid => $amount) { if (empty($amount)) continue; @@ -543,7 +543,7 @@ class BlockedLog $tmpobject = new PaymentVarious($this->db); } - if (! is_object($tmpobject)) + if (!is_object($tmpobject)) { continue; } @@ -561,12 +561,12 @@ class BlockedLog $paymentpart = new stdClass(); $paymentpart->amount = $amount; - if (! in_array($this->element, array('payment_donation', 'payment_various'))) + if (!in_array($this->element, array('payment_donation', 'payment_various'))) { $result = $tmpobject->fetch_thirdparty(); if ($result == 0) { - $this->error='Failed to fetch thirdparty for object with id '.$tmpobject->id; + $this->error = 'Failed to fetch thirdparty for object with id '.$tmpobject->id; $this->errors[] = $this->error; dol_syslog("Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR); return -1; @@ -610,43 +610,43 @@ class BlockedLog } } - $paymentpartnumber++; // first payment will be 1 + $paymentpartnumber++; // first payment will be 1 $this->object_data->payment_part[$paymentpartnumber] = $paymentpart; } } $this->object_data->amount = $totalamount; - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } - elseif($this->element == 'payment_salary') + elseif ($this->element == 'payment_salary') { $this->object_data->amounts = array($object->amount); - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } - elseif($this->element == 'subscription') + elseif ($this->element == 'subscription') { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'id','datec','dateh','datef','fk_adherent','amount','import_key','statut','note' - ))) continue; // Discard if not into a dedicated list + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'id', 'datec', 'dateh', 'datef', 'fk_adherent', 'amount', 'import_key', 'statut', 'note' + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } else // Generic case { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } return 1; @@ -667,59 +667,59 @@ class BlockedLog if (empty($id)) { - $this->error='BadParameter'; + $this->error = 'BadParameter'; return -1; } $langs->load("blockedlog"); $sql = "SELECT b.rowid, b.date_creation, b.signature, b.signature_line, b.amounts, b.action, b.element, b.fk_object, b.entity,"; - $sql.= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data"; - $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; - if ($id) $sql.= " WHERE b.rowid = ". $id; + $sql .= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data"; + $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; + if ($id) $sql .= " WHERE b.rowid = ".$id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->entity = $obj->entity; + $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->ref = $obj->rowid; - $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_creation = $this->db->jdate($obj->date_creation); $this->tms = $this->db->jdate($obj->tms); $this->amounts = (double) $obj->amounts; - $this->action = $obj->action; + $this->action = $obj->action; $this->element = $obj->element; - $this->fk_object = $obj->fk_object; - $this->date_object = $this->db->jdate($obj->date_object); - $this->ref_object = $obj->ref_object; + $this->fk_object = $obj->fk_object; + $this->date_object = $this->db->jdate($obj->date_object); + $this->ref_object = $obj->ref_object; - $this->fk_user = $obj->fk_user; - $this->user_fullname = $obj->user_fullname; + $this->fk_user = $obj->fk_user; + $this->user_fullname = $obj->user_fullname; - $this->object_data = $this->dolDecodeBlockedData($obj->object_data); + $this->object_data = $this->dolDecodeBlockedData($obj->object_data); $this->signature = $obj->signature; - $this->signature_line = $obj->signature_line; + $this->signature_line = $obj->signature_line; $this->certified = ($obj->certified == 1); return 1; } else { - $this->error=$langs->trans("RecordNotFound"); + $this->error = $langs->trans("RecordNotFound"); return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -739,7 +739,7 @@ class BlockedLog //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $aaa = unserialize($data); //$aaa = unserialize($data); - } catch(Exception $e) { + } catch (Exception $e) { //print $e->getErrs); } return $aaa; @@ -755,7 +755,7 @@ class BlockedLog { $res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id); - if($res===false) return false; + if ($res === false) return false; return true; } @@ -770,82 +770,82 @@ class BlockedLog public function create($user, $forcesignature = '') { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; $langs->load('blockedlog'); - $error=0; + $error = 0; // Clean data - $this->amounts=(double) $this->amounts; + $this->amounts = (double) $this->amounts; dol_syslog(get_class($this).'::create action='.$this->action.' fk_user='.$this->fk_user.' user_fullname='.$this->user_fullname, LOG_DEBUG); // Check parameters/properties - if (! isset($this->amounts)) // amount can be 0 for some events (like when module is disabled) + if (!isset($this->amounts)) // amount can be 0 for some events (like when module is disabled) { - $this->error=$langs->trans("BlockLogNeedAmountsValue"); + $this->error = $langs->trans("BlockLogNeedAmountsValue"); dol_syslog($this->error, LOG_WARNING); return -1; } if (empty($this->element)) { - $this->error=$langs->trans("BlockLogNeedElement"); + $this->error = $langs->trans("BlockLogNeedElement"); dol_syslog($this->error, LOG_WARNING); return -2; } if (empty($this->action)) { - $this->error=$langs->trans("BadParameterWhenCallingCreateOfBlockedLog"); + $this->error = $langs->trans("BadParameterWhenCallingCreateOfBlockedLog"); dol_syslog($this->error, LOG_WARNING); return -3; } - if (empty($this->fk_user)) $this->user_fullname='(Anonymous)'; + if (empty($this->fk_user)) $this->user_fullname = '(Anonymous)'; $this->date_creation = dol_now(); $this->db->begin(); - $previoushash = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done + $previoushash = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done $keyforsignature = $this->buildKeyForSignature(); - $this->signature_line = dol_hash($keyforsignature, '5'); // Not really usefull - $this->signature = dol_hash($previoushash . $keyforsignature, '5'); + $this->signature_line = dol_hash($keyforsignature, '5'); // Not really usefull + $this->signature = dol_hash($previoushash.$keyforsignature, '5'); if ($forcesignature) $this->signature = $forcesignature; //var_dump($keyforsignature);var_dump($previoushash);var_dump($this->signature_line);var_dump($this->signature); $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog ("; - $sql.= " date_creation,"; - $sql.= " action,"; - $sql.= " amounts,"; - $sql.= " signature,"; - $sql.= " signature_line,"; - $sql.= " element,"; - $sql.= " fk_object,"; - $sql.= " date_object,"; - $sql.= " ref_object,"; - $sql.= " object_data,"; - $sql.= " certified,"; - $sql.= " fk_user,"; - $sql.= " user_fullname,"; - $sql.= " entity"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($this->date_creation)."',"; - $sql.= "'".$this->db->escape($this->action)."',"; - $sql.= $this->amounts.","; - $sql.= "'".$this->db->escape($this->signature)."',"; - $sql.= "'".$this->db->escape($this->signature_line)."',"; - $sql.= "'".$this->db->escape($this->element)."',"; - $sql.= $this->fk_object.","; - $sql.= "'".$this->db->idate($this->date_object)."',"; - $sql.= "'".$this->db->escape($this->ref_object)."',"; - $sql.= "'".$this->db->escape(serialize($this->object_data))."',"; - $sql.= "0,"; - $sql.= $this->fk_user.","; - $sql.= "'".$this->db->escape($this->user_fullname)."',"; - $sql.= ($this->entity ? $this->entity : $conf->entity); - $sql.= ")"; + $sql .= " date_creation,"; + $sql .= " action,"; + $sql .= " amounts,"; + $sql .= " signature,"; + $sql .= " signature_line,"; + $sql .= " element,"; + $sql .= " fk_object,"; + $sql .= " date_object,"; + $sql .= " ref_object,"; + $sql .= " object_data,"; + $sql .= " certified,"; + $sql .= " fk_user,"; + $sql .= " user_fullname,"; + $sql .= " entity"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($this->date_creation)."',"; + $sql .= "'".$this->db->escape($this->action)."',"; + $sql .= $this->amounts.","; + $sql .= "'".$this->db->escape($this->signature)."',"; + $sql .= "'".$this->db->escape($this->signature_line)."',"; + $sql .= "'".$this->db->escape($this->element)."',"; + $sql .= $this->fk_object.","; + $sql .= "'".$this->db->idate($this->date_object)."',"; + $sql .= "'".$this->db->escape($this->ref_object)."',"; + $sql .= "'".$this->db->escape(serialize($this->object_data))."',"; + $sql .= "0,"; + $sql .= $this->fk_user.","; + $sql .= "'".$this->db->escape($this->user_fullname)."',"; + $sql .= ($this->entity ? $this->entity : $conf->entity); + $sql .= ")"; $res = $this->db->query($sql); if ($res) @@ -868,7 +868,7 @@ class BlockedLog } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -891,8 +891,8 @@ class BlockedLog // Recalculate hash $keyforsignature = $this->buildKeyForSignature(); - $signature_line = dol_hash($keyforsignature, '5'); // Not really usefull - $signature = dol_hash($previoushash . $keyforsignature, '5'); + $signature_line = dol_hash($keyforsignature, '5'); // Not really usefull + $signature = dol_hash($previoushash.$keyforsignature, '5'); //var_dump($previoushash); var_dump($keyforsignature); var_dump($signature_line); var_dump($signature); $res = ($signature === $this->signature); @@ -929,13 +929,13 @@ class BlockedLog { global $conf; - $previoussignature=''; + $previoussignature = ''; $sql = "SELECT rowid, signature FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql.= " WHERE entity=".$conf->entity; - if ($beforeid) $sql.= " AND rowid < ".(int) $beforeid; - $sql.=" ORDER BY rowid DESC LIMIT 1"; - $sql.=($withlock ? " FOR UPDATE ": ""); + $sql .= " WHERE entity=".$conf->entity; + if ($beforeid) $sql .= " AND rowid < ".(int) $beforeid; + $sql .= " ORDER BY rowid DESC LIMIT 1"; + $sql .= ($withlock ? " FOR UPDATE " : ""); $resql = $this->db->query($sql); if ($resql) { @@ -981,38 +981,38 @@ class BlockedLog global $conf, $cachedlogs; /* $cachedlogs allow fastest search */ - if (empty($cachedlogs)) $cachedlogs=array(); + if (empty($cachedlogs)) $cachedlogs = array(); - if ($element=='all') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + if ($element == 'all') { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity; } - elseif ($element=='not_certified') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + elseif ($element == 'not_certified') { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 0"; } - elseif ($element=='just_certified') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + elseif ($element == 'just_certified') { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 1"; } - else{ - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + else { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND element='".$element."' AND fk_object=".(int) $fk_object; } - if ($search_fk_user > 0) $sql.=natural_search("fk_user", $search_fk_user, 2); - if ($search_start > 0) $sql.=" AND date_creation >= '".$this->db->idate($search_start)."'"; - if ($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'"; - if ($search_ref != '') $sql.=natural_search("ref_object", $search_ref); - if ($search_amount != '') $sql.=natural_search("amounts", $search_amount, 1); - if ($search_code != '' && $search_code != '-1') $sql.=natural_search("action", $search_code, 3); + if ($search_fk_user > 0) $sql .= natural_search("fk_user", $search_fk_user, 2); + if ($search_start > 0) $sql .= " AND date_creation >= '".$this->db->idate($search_start)."'"; + if ($search_end > 0) $sql .= " AND date_creation <= '".$this->db->idate($search_end)."'"; + if ($search_ref != '') $sql .= natural_search("ref_object", $search_ref); + if ($search_amount != '') $sql .= natural_search("amounts", $search_amount, 1); + if ($search_code != '' && $search_code != '-1') $sql .= natural_search("action", $search_code, 3); - $sql.=$this->db->order($sortfield, $sortorder); - $sql.=$this->db->plimit($limit+1); // We want more, because we will stop into loop later with error if we reach max + $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit + 1); // We want more, because we will stop into loop later with error if we reach max $res = $this->db->query($sql); - if($res) { - $results=array(); + if ($res) { + $results = array(); $i = 0; while ($obj = $this->db->fetch_object($res)) @@ -1026,7 +1026,7 @@ class BlockedLog if (!isset($cachedlogs[$obj->rowid])) { - $b=new BlockedLog($this->db); + $b = new BlockedLog($this->db); $b->fetch($obj->rowid); $cachedlogs[$obj->rowid] = $b; @@ -1048,7 +1048,7 @@ class BlockedLog */ public function getSignature() { - global $db,$conf,$mysoc; + global $db, $conf, $mysoc; if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -1059,7 +1059,7 @@ class BlockedLog dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine', 0, 'Numeric Unique Fingerprint', $conf->entity); - $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT=$fingerprint; + $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT = $fingerprint; } return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT; @@ -1079,12 +1079,12 @@ class BlockedLog $result = false; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql.= " WHERE entity = ".$conf->entity; - if ($ignoresystem) $sql.=" AND action not in ('MODULE_SET','MODULE_RESET')"; - $sql.= $this->db->plimit(1); + $sql .= " WHERE entity = ".$conf->entity; + if ($ignoresystem) $sql .= " AND action not in ('MODULE_SET','MODULE_RESET')"; + $sql .= $this->db->plimit(1); $res = $this->db->query($sql); - if ($res!==false) + if ($res !== false) { $obj = $this->db->fetch_object($res); if ($obj) $result = true; diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index d892c1df0e6..6fffbd3ed52 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -18,7 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($langs) || ! is_object($langs)) +if (empty($langs) || !is_object($langs)) { print "Error, template page can't be called as URL"; exit; @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; // Load translation files required by the page -$langs->loadLangs(array("main","bills","cashdesk")); +$langs->loadLangs(array("main", "bills", "cashdesk")); ?> @@ -45,18 +45,18 @@ $societe = new Societe($db); $societe->fetch($thirdpartyid); /** end add Ditto */ -$tab = (! empty($_SESSION['poscart'])?$_SESSION['poscart']:array()); +$tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); -$tab_size=count($tab); +$tab_size = count($tab); if ($tab_size <= 0) print '
        '.$langs->trans("NoArticle").'

        '; else { - for ($i=0;$i < $tab_size;$i++) + for ($i = 0; $i < $tab_size; $i++) { echo ('
        '."\n"); echo ('

        '.$tab[$i]['ref'].' - '.$tab[$i]['label'].'

        '."\n"); - if ( $tab[$i]['remise_percent'] > 0 ) { + if ($tab[$i]['remise_percent'] > 0) { $remise_percent = ' -'.$tab[$i]['remise_percent'].'%'; } else { $remise_percent = ''; diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index fcbd95e8f29..4bc66eff4ad 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -17,14 +17,14 @@ */ // Protection to avoid direct call of template -if (empty($langs) || ! is_object($langs)) +if (empty($langs) || !is_object($langs)) { print "Error, template page can't be called as URL"; exit; } // Load translation files required by the page -$langs->loadLangs(array("main","bills","banks")); +$langs->loadLangs(array("main", "bills", "banks")); // Object $form must de defined @@ -53,30 +53,30 @@ else { case 'ESP': echo $langs->trans("Cash"); - $filtre='courant=2'; + $filtre = 'courant=2'; if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]; break; case 'CB': echo $langs->trans("CreditCard"); - $filtre='courant=1'; + $filtre = 'courant=1'; if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]; break; case 'CHQ': echo $langs->trans("Cheque"); - $filtre='courant=1'; + $filtre = 'courant=1'; if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]; break; case 'DIF': echo $langs->trans("Reported"); - $filtre='courant=1 OR courant=2'; - $selected=''; + $filtre = 'courant=1 OR courant=2'; + $selected = ''; break; default: - $filtre='courant=1 OR courant=2'; - $selected=''; + $filtre = 'courant=1 OR courant=2'; + $selected = ''; } ?> @@ -103,7 +103,7 @@ if ( $obj_facturation->montantRendu() ) {

        trans("BankToPay"). "
        "; + echo $langs->trans("BankToPay")."
        "; $form->select_comptes($selected, 'cashdeskbank', 0, $filtre); ?>

        diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 25cf0287292..033f3f38100 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -107,7 +107,7 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'socpeople', 'user' => 'user', - 'account' => 'account', // old key for bank_account + 'account' => 'account', // old key for bank_account 'bank_account' => 'account', 'project' => 'project', 'warehouse'=> 'warehouse', @@ -125,7 +125,7 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'contact', 'user' => 'user', - 'account' => 'account', // old key for bank_account + 'account' => 'account', // old key for bank_account 'bank_account'=> 'account', 'project' => 'project', 'warehouse'=> 'warehouse', @@ -853,29 +853,29 @@ class Categorie extends CommonObject $sub_type = $type; $subcol_name = "fk_".$type; - if ($type=="customer") { - $sub_type="societe"; - $subcol_name="fk_soc"; + if ($type == "customer") { + $sub_type = "societe"; + $subcol_name = "fk_soc"; } - if ($type=="supplier") { - $sub_type="fournisseur"; - $subcol_name="fk_soc"; + if ($type == "supplier") { + $sub_type = "fournisseur"; + $subcol_name = "fk_soc"; } - if ($type=="contact") { - $subcol_name="fk_socpeople"; + if ($type == "contact") { + $subcol_name = "fk_socpeople"; } $idoftype = array_search($type, self::$MAP_ID_TO_CODE); $sql = "SELECT s.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie as s"; - $sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub "; - $sql.= ' WHERE s.entity IN ('.getEntity('category').')'; - $sql.= ' AND s.type='.$idoftype; - $sql.= ' AND s.rowid = sub.fk_categorie'; - $sql.= ' AND sub.'.$subcol_name.' = '.$id; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as s"; + $sql .= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub "; + $sql .= ' WHERE s.entity IN ('.getEntity('category').')'; + $sql .= ' AND s.type='.$idoftype; + $sql .= ' AND s.rowid = sub.fk_categorie'; + $sql .= ' AND sub.'.$subcol_name.' = '.$id; - $sql.= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); $offset = 0; $nbtotalofrecords = ''; @@ -897,13 +897,13 @@ class Categorie extends CommonObject } $offset = $limit * $page; - $sql.= $this->db->plimit($limit + 1, $offset); + $sql .= $this->db->plimit($limit + 1, $offset); } $result = $this->db->query($sql); if ($result) { - $i=0; + $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) @@ -1636,8 +1636,8 @@ class Categorie extends CommonObject if (is_array($file['name']) && count($file['name']) > 0) { $nbfile = count($file['name']); - for ($i = 0; $i <= $nbfile; $i ++) { - $originImage = $dir . $file['name'][$i]; + for ($i = 0; $i <= $nbfile; $i++) { + $originImage = $dir.$file['name'][$i]; // Cree fichier en taille origine dol_move_uploaded_file($file['tmp_name'][$i], $originImage, 1, 0, 0); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 5dbd6e68c47..2556c2d2084 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -36,13 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; $langs->loadlangs(array('categories', 'bills')); -$id=GETPOST('id', 'int'); -$ref=GETPOST('ref'); -$type=GETPOST('type'); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref'); +$type = GETPOST('type'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); -if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility if ($id == "") { @@ -66,7 +66,7 @@ if ($id > 0) * Actions */ -if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->id) { $file = $_FILES['userfile']; @@ -74,15 +74,15 @@ if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sen { foreach ($file['name'] as $i => $name) { - if(empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i]) ) + if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i])) { - setEventMessage($file['name'][$i] .' : '. $langs->trans(empty($file['tmp_name'][$i])? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles')); + setEventMessage($file['name'][$i].' : '.$langs->trans(empty($file['tmp_name'][$i]) ? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles')); unset($file['name'][$i], $file['type'][$i], $file['tmp_name'][$i], $file['error'][$i], $file['size'][$i]); } } } - if(!empty($file['tmp_name'])) { + if (!empty($file['tmp_name'])) { $object->add_photo($upload_dir, $file); } } @@ -110,15 +110,15 @@ $formother = new FormOther($db); if ($object->id) { - if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort"); - elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort"); - elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); - elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); - elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); - elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); - elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort"); - elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort"); - else $title=$langs->trans("Category"); + if ($type == Categorie::TYPE_PRODUCT) $title = $langs->trans("ProductsCategoryShort"); + elseif ($type == Categorie::TYPE_SUPPLIER) $title = $langs->trans("SuppliersCategoryShort"); + elseif ($type == Categorie::TYPE_CUSTOMER) $title = $langs->trans("CustomersCategoryShort"); + elseif ($type == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoryShort"); + elseif ($type == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort"); + elseif ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans("AccountsCategoriesShort"); + elseif ($type == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort"); + elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("UsersCategoriesShort"); + else $title = $langs->trans("Category"); $head = categories_prepare_head($object, $type); @@ -181,7 +181,7 @@ if ($object->id) if ($action != 'ajout_photo' && $user->rights->categorie->creer) { - if (! empty($conf->global->MAIN_UPLOAD_DOC)) + if (!empty($conf->global->MAIN_UPLOAD_DOC)) { print ''; print $langs->trans("AddPhoto").''; @@ -198,23 +198,23 @@ if ($object->id) /* * Ajouter une photo */ - if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC)) + if ($action == 'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC)) { // Affiche formulaire upload - $formfile=new FormFile($db); + $formfile = new FormFile($db); $formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&type='.$type, $langs->trans("AddPhoto"), 1, '', $user->rights->categorie->creer, 50, $object, '', false, '', 0); } // Affiche photos if ($action != 'ajout_photo') { - $nbphoto=0; - $nbbyrow=5; + $nbphoto = 0; + $nbbyrow = 5; $maxWidth = 160; $maxHeight = 120; - $pdir = get_exdir($object->id, 2, 0, 0, $object, 'category') . $object->id ."/photos/"; + $pdir = get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/"; $dir = $upload_dir.'/'.$pdir; $listofphoto = $object->liste_photos($dir); @@ -229,22 +229,22 @@ if ($object->id) $nbphoto++; if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '

        '; - if ($nbbyrow) print ''; + print ''; $nbphoto++; } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 442e1b8bdd9..69f748412a1 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -38,7 +38,7 @@ class ActionComm extends CommonObject /** * @var string ID to identify managed object */ - public $element='action'; + public $element = 'action'; /** * @var string Name of table without prefix where object is stored @@ -364,174 +364,174 @@ class ActionComm extends CommonObject */ public function create(User $user, $notrigger = 0) { - global $langs,$conf,$hookmanager; + global $langs, $conf, $hookmanager; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Check parameters - if (! isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 + if (!isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 { dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); - $this->errors[]='ErrorPropertyUserowneridNotDefined'; + $this->errors[] = 'ErrorPropertyUserowneridNotDefined'; return -1; } // Clean parameters - $this->label=dol_trunc(trim($this->label), 128); - $this->location=dol_trunc(trim($this->location), 128); - $this->note=dol_htmlcleanlastbr(trim($this->note)); + $this->label = dol_trunc(trim($this->label), 128); + $this->location = dol_trunc(trim($this->location), 128); + $this->note = dol_htmlcleanlastbr(trim($this->note)); if (empty($this->percentage)) $this->percentage = 0; - if (empty($this->priority) || ! is_numeric($this->priority)) $this->priority = 0; + if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; if (empty($this->fulldayevent)) $this->fulldayevent = 0; if (empty($this->punctual)) $this->punctual = 0; if (empty($this->transparency)) $this->transparency = 0; if ($this->percentage > 100) $this->percentage = 100; //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; - if (! empty($this->datep) && ! empty($this->datef)) $this->durationp=($this->datef - $this->datep); // deprecated + if (!empty($this->datep) && !empty($this->datef)) $this->durationp = ($this->datef - $this->datep); // deprecated //if (! empty($this->date) && ! empty($this->dateend)) $this->durationa=($this->dateend - $this->date); - if (! empty($this->datep) && ! empty($this->datef) && $this->datep > $this->datef) $this->datef=$this->datep; + if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) $this->datef = $this->datep; //if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; - if (! isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; + if (!isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; // For backward compatibility - if ($this->elementtype=='facture') $this->elementtype='invoice'; - if ($this->elementtype=='commande') $this->elementtype='order'; - if ($this->elementtype=='contrat') $this->elementtype='contract'; + if ($this->elementtype == 'facture') $this->elementtype = 'invoice'; + if ($this->elementtype == 'commande') $this->elementtype = 'order'; + if ($this->elementtype == 'contrat') $this->elementtype = 'contract'; - if (! is_array($this->userassigned) && ! empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array + if (!is_array($this->userassigned) && !empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array { - $tmpid=$this->userassigned; - $this->userassigned=array(); - $this->userassigned[$tmpid]=array('id'=>$tmpid, 'transparency'=>$this->transparency); + $tmpid = $this->userassigned; + $this->userassigned = array(); + $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); } - $userownerid=$this->userownerid; - $userdoneid=$this->userdoneid; + $userownerid = $this->userownerid; + $userdoneid = $this->userdoneid; // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). - if (empty($this->userassigned) || count($this->userassigned) == 0 || ! is_array($this->userassigned)) + if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) $this->userassigned = array($userownerid=>array('id'=>$userownerid, 'transparency'=>$this->transparency)); - if (! $this->type_id || ! $this->type_code) + if (!$this->type_id || !$this->type_code) { - $key=empty($this->type_id)?$this->type_code:$this->type_id; + $key = empty($this->type_id) ? $this->type_code : $this->type_id; // Get id from code - $cactioncomm=new CActionComm($this->db); - $result=$cactioncomm->fetch($key); + $cactioncomm = new CActionComm($this->db); + $result = $cactioncomm->fetch($key); if ($result > 0) { - $this->type_id=$cactioncomm->id; - $this->type_code=$cactioncomm->code; + $this->type_id = $cactioncomm->id; + $this->type_code = $cactioncomm->code; } elseif ($result == 0) { - $this->error='Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; + $this->error = 'Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; return -1; } else { - $this->error=$cactioncomm->error; + $this->error = $cactioncomm->error; return -1; } } - $code = empty($this->code)?$this->type_code:$this->code; + $code = empty($this->code) ? $this->type_code : $this->code; // Check parameters - if (! $this->type_id) + if (!$this->type_id) { - $this->error="ErrorWrongParameters"; + $this->error = "ErrorWrongParameters"; return -1; } $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm"; - $sql.= "(datec,"; - $sql.= "datep,"; - $sql.= "datep2,"; - $sql.= "durationp,"; // deprecated - $sql.= "fk_action,"; - $sql.= "code,"; - $sql.= "fk_soc,"; - $sql.= "fk_project,"; - $sql.= "note,"; - $sql.= "fk_contact,"; - $sql.= "fk_user_author,"; - $sql.= "fk_user_action,"; - $sql.= "fk_user_done,"; - $sql.= "label,percent,priority,fulldayevent,location,punctual,"; - $sql.= "transparency,"; - $sql.= "fk_element,"; - $sql.= "elementtype,"; - $sql.= "entity,"; - $sql.= "extraparams,"; + $sql .= "(datec,"; + $sql .= "datep,"; + $sql .= "datep2,"; + $sql .= "durationp,"; // deprecated + $sql .= "fk_action,"; + $sql .= "code,"; + $sql .= "fk_soc,"; + $sql .= "fk_project,"; + $sql .= "note,"; + $sql .= "fk_contact,"; + $sql .= "fk_user_author,"; + $sql .= "fk_user_action,"; + $sql .= "fk_user_done,"; + $sql .= "label,percent,priority,fulldayevent,location,punctual,"; + $sql .= "transparency,"; + $sql .= "fk_element,"; + $sql .= "elementtype,"; + $sql .= "entity,"; + $sql .= "extraparams,"; // Fields emails - $sql.= "email_msgid,"; - $sql.= "email_from,"; - $sql.= "email_sender,"; - $sql.= "email_to,"; - $sql.= "email_tocc,"; - $sql.= "email_tobcc,"; - $sql.= "email_subject,"; - $sql.= "errors_to"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."', "; - $sql.= (strval($this->datep)!=''?"'".$this->db->idate($this->datep)."'":"null").", "; - $sql.= (strval($this->datef)!=''?"'".$this->db->idate($this->datef)."'":"null").", "; - $sql.= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '')?"'".$this->db->escape($this->durationp)."'":"null").", "; // deprecated - $sql.= (isset($this->type_id)?$this->type_id:"null").","; - $sql.= ($code?("'".$code."'"):"null").", "; - $sql.= ((isset($this->socid) && $this->socid > 0) ? $this->socid:"null").", "; - $sql.= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project:"null").", "; - $sql.= " '".$this->db->escape($this->note_private?$this->note_private:$this->note)."', "; - $sql.= ((isset($this->contactid) && $this->contactid > 0) ? $this->contactid:"null").", "; - $sql.= (isset($user->id) && $user->id > 0 ? $user->id:"null").", "; - $sql.= ($userownerid>0 ? $userownerid:"null").", "; - $sql.= ($userdoneid>0 ? $userdoneid:"null").", "; - $sql.= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."','".$this->db->escape($this->punctual)."', "; - $sql.= "'".$this->db->escape($this->transparency)."', "; - $sql.= (! empty($this->fk_element)?$this->fk_element:"null").", "; - $sql.= (! empty($this->elementtype)?"'".$this->db->escape($this->elementtype)."'":"null").", "; - $sql.= $conf->entity.","; - $sql.= (! empty($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").", "; + $sql .= "email_msgid,"; + $sql .= "email_from,"; + $sql .= "email_sender,"; + $sql .= "email_to,"; + $sql .= "email_tocc,"; + $sql .= "email_tobcc,"; + $sql .= "email_subject,"; + $sql .= "errors_to"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($now)."', "; + $sql .= (strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : "null").", "; + $sql .= (strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : "null").", "; + $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '') ? "'".$this->db->escape($this->durationp)."'" : "null").", "; // deprecated + $sql .= (isset($this->type_id) ? $this->type_id : "null").","; + $sql .= ($code ? ("'".$code."'") : "null").", "; + $sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", "; + $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", "; + $sql .= " '".$this->db->escape($this->note_private ? $this->note_private : $this->note)."', "; + $sql .= ((isset($this->contactid) && $this->contactid > 0) ? $this->contactid : "null").", "; + $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; + $sql .= ($userownerid > 0 ? $userownerid : "null").", "; + $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; + $sql .= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."','".$this->db->escape($this->punctual)."', "; + $sql .= "'".$this->db->escape($this->transparency)."', "; + $sql .= (!empty($this->fk_element) ? $this->fk_element : "null").", "; + $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; + $sql .= $conf->entity.","; + $sql .= (!empty($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").", "; // Fields emails - $sql.= (! empty($this->email_msgid)?"'".$this->db->escape($this->email_msgid)."'":"null").", "; - $sql.= (! empty($this->email_from)?"'".$this->db->escape($this->email_from)."'":"null").", "; - $sql.= (! empty($this->email_sender)?"'".$this->db->escape($this->email_sender)."'":"null").", "; - $sql.= (! empty($this->email_to)?"'".$this->db->escape($this->email_to)."'":"null").", "; - $sql.= (! empty($this->email_tocc)?"'".$this->db->escape($this->email_tocc)."'":"null").", "; - $sql.= (! empty($this->email_tobcc)?"'".$this->db->escape($this->email_tobcc)."'":"null").", "; - $sql.= (! empty($this->email_subject)?"'".$this->db->escape($this->email_subject)."'":"null").", "; - $sql.= (! empty($this->errors_to)?"'".$this->db->escape($this->errors_to)."'":"null"); - $sql.= ")"; + $sql .= (!empty($this->email_msgid) ? "'".$this->db->escape($this->email_msgid)."'" : "null").", "; + $sql .= (!empty($this->email_from) ? "'".$this->db->escape($this->email_from)."'" : "null").", "; + $sql .= (!empty($this->email_sender) ? "'".$this->db->escape($this->email_sender)."'" : "null").", "; + $sql .= (!empty($this->email_to) ? "'".$this->db->escape($this->email_to)."'" : "null").", "; + $sql .= (!empty($this->email_tocc) ? "'".$this->db->escape($this->email_tocc)."'" : "null").", "; + $sql .= (!empty($this->email_tobcc) ? "'".$this->db->escape($this->email_tobcc)."'" : "null").", "; + $sql .= (!empty($this->email_subject) ? "'".$this->db->escape($this->email_subject)."'" : "null").", "; + $sql .= (!empty($this->errors_to) ? "'".$this->db->escape($this->errors_to)."'" : "null"); + $sql .= ")"; dol_syslog(get_class($this)."::add", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); // Now insert assignedusers - if (! $error) + if (!$error) { - foreach($this->userassigned as $key => $val) + foreach ($this->userassigned as $key => $val) { - if (! is_array($val)) // For backward compatibility when val=id + if (!is_array($val)) // For backward compatibility when val=id { - $val=array('id'=>$val); + $val = array('id'=>$val); } - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory'])?'0':$val['mandatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } //var_dump($sql);exit; } @@ -543,27 +543,27 @@ class ActionComm extends CommonObject { foreach ($this->socpeopleassigned as $id => $Tab) { - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } } } - if (! $error) + if (!$error) { - $action='create'; + $action = 'create'; // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -571,15 +571,15 @@ class ActionComm extends CommonObject } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ACTION_CREATE', $user); + $result = $this->call_trigger('ACTION_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -593,7 +593,7 @@ class ActionComm extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -609,8 +609,8 @@ class ActionComm extends CommonObject { global $db, $conf, $hookmanager; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); $this->db->begin(); @@ -624,26 +624,26 @@ class ActionComm extends CommonObject //$this->fetch_userassigned(); $this->fetchResources(); - $this->id=0; + $this->id = 0; // Create clone - $this->context['createfromclone']='createfromclone'; - $result=$this->create($fuser); + $this->context['createfromclone'] = 'createfromclone'; + $result = $this->create($fuser); if ($result < 0) $error++; - if (! $error) + if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters=array('objFrom'=>$objFrom); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('objFrom'=>$objFrom); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } // Call trigger - $result=$this->call_trigger('ACTION_CLONE', $fuser); + $result = $this->call_trigger('ACTION_CLONE', $fuser); if ($result < 0) { $error++; } // End call triggers } @@ -651,7 +651,7 @@ class ActionComm extends CommonObject unset($this->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -676,38 +676,38 @@ class ActionComm extends CommonObject global $langs; $sql = "SELECT a.id,"; - $sql.= " a.id as ref,"; - $sql.= " a.ref_ext,"; - $sql.= " a.datep,"; - $sql.= " a.datep2,"; - $sql.= " a.durationp,"; // deprecated - $sql.= " a.datec,"; - $sql.= " a.tms as datem,"; - $sql.= " a.code, a.label, a.note,"; - $sql.= " a.fk_soc,"; - $sql.= " a.fk_project,"; - $sql.= " a.fk_user_author, a.fk_user_mod,"; - $sql.= " a.fk_user_action, a.fk_user_done,"; - $sql.= " a.fk_contact, a.percent as percentage,"; - $sql.= " a.fk_element as elementid, a.elementtype,"; - $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; - $sql.= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; - $sql.= " s.nom as socname,"; - $sql.= " u.firstname, u.lastname as lastname"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; - $sql.= " WHERE "; - if ($ref) $sql.= " a.id=".$ref; // No field ref, we use id - elseif ($ref_ext) $sql.= " a.ref_ext='".$this->db->escape($ref_ext)."'"; - else $sql.= " a.id=".$id; + $sql .= " a.id as ref,"; + $sql .= " a.ref_ext,"; + $sql .= " a.datep,"; + $sql .= " a.datep2,"; + $sql .= " a.durationp,"; // deprecated + $sql .= " a.datec,"; + $sql .= " a.tms as datem,"; + $sql .= " a.code, a.label, a.note,"; + $sql .= " a.fk_soc,"; + $sql .= " a.fk_project,"; + $sql .= " a.fk_user_author, a.fk_user_mod,"; + $sql .= " a.fk_user_action, a.fk_user_done,"; + $sql .= " a.fk_contact, a.percent as percentage,"; + $sql .= " a.fk_element as elementid, a.elementtype,"; + $sql .= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; + $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; + $sql .= " s.nom as socname,"; + $sql .= " u.firstname, u.lastname as lastname"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; + $sql .= " WHERE "; + if ($ref) $sql .= " a.id=".$ref; // No field ref, we use id + elseif ($ref_ext) $sql .= " a.ref_ext='".$this->db->escape($ref_ext)."'"; + else $sql .= " a.id=".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); + $num = $this->db->num_rows($resql); if ($num) { $obj = $this->db->fetch_object($resql); @@ -721,12 +721,12 @@ class ActionComm extends CommonObject $this->type_code = $obj->type_code; $this->type_color = $obj->type_color; $this->type_picto = $obj->type_picto; - $transcode=$langs->trans("Action".$obj->type_code); - $this->type = (($transcode!="Action".$obj->type_code) ? $transcode : $obj->type_label); - $transcode=$langs->trans("Action".$obj->type_code.'Short'); - $this->type_short = (($transcode!="Action".$obj->type_code.'Short') ? $transcode : ''); + $transcode = $langs->trans("Action".$obj->type_code); + $this->type = (($transcode != "Action".$obj->type_code) ? $transcode : $obj->type_label); + $transcode = $langs->trans("Action".$obj->type_code.'Short'); + $this->type_short = (($transcode != "Action".$obj->type_code.'Short') ? $transcode : ''); - $this->code = $obj->code; + $this->code = $obj->code; $this->label = $obj->label; $this->datep = $this->db->jdate($obj->datep); $this->datef = $this->db->jdate($obj->datep2); @@ -734,38 +734,38 @@ class ActionComm extends CommonObject $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); - $this->note = $obj->note; - $this->note_private = $obj->note; - $this->percentage = $obj->percentage; + $this->note = $obj->note; + $this->note_private = $obj->note; + $this->percentage = $obj->percentage; - $this->authorid = $obj->fk_user_author; - $this->usermodid = $obj->fk_user_mod; + $this->authorid = $obj->fk_user_author; + $this->usermodid = $obj->fk_user_mod; if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning - $this->author->id = $obj->fk_user_author; // deprecated - $this->author->firstname = $obj->firstname; // deprecated - $this->author->lastname = $obj->lastname; // deprecated + $this->author->id = $obj->fk_user_author; // deprecated + $this->author->firstname = $obj->firstname; // deprecated + $this->author->lastname = $obj->lastname; // deprecated if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning - $this->usermod->id = $obj->fk_user_mod; // deprecated + $this->usermod->id = $obj->fk_user_mod; // deprecated - $this->userownerid = $obj->fk_user_action; - $this->userdoneid = $obj->fk_user_done; + $this->userownerid = $obj->fk_user_action; + $this->userdoneid = $obj->fk_user_done; $this->priority = $obj->priority; $this->fulldayevent = $obj->fulldayevent; $this->location = $obj->location; $this->transparency = $obj->transparency; - $this->punctual = $obj->punctual; // deprecated + $this->punctual = $obj->punctual; // deprecated - $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working - $this->contactid = $obj->fk_contact; // To have fetch_contact method working - $this->fk_project = $obj->fk_project; // To have fetch_projet method working + $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working + $this->contactid = $obj->fk_contact; // To have fetch_contact method working + $this->fk_project = $obj->fk_project; // To have fetch_projet method working //$this->societe->id = $obj->fk_soc; // deprecated //$this->contact->id = $obj->fk_contact; // deprecated - $this->fk_element = $obj->elementid; - $this->elementid = $obj->elementid; - $this->elementtype = $obj->elementtype; + $this->fk_element = $obj->elementid; + $this->elementid = $obj->elementid; + $this->elementtype = $obj->elementtype; $this->fetchResources(); } @@ -773,7 +773,7 @@ class ActionComm extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } @@ -787,18 +787,18 @@ class ActionComm extends CommonObject */ public function fetchResources() { - $sql ='SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; - $sql.=' FROM '.MAIN_DB_PREFIX.'actioncomm_resources'; - $sql.=' WHERE fk_actioncomm = '.$this->id; - $sql.=" AND element_type IN ('user', 'socpeople')"; - $resql=$this->db->query($sql); + $sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm_resources'; + $sql .= ' WHERE fk_actioncomm = '.$this->id; + $sql .= " AND element_type IN ('user', 'socpeople')"; + $resql = $this->db->query($sql); if ($resql) { - $this->userassigned=array(); - $this->socpeopleassigned=array(); + $this->userassigned = array(); + $this->socpeopleassigned = array(); // If owner is known, we must but id first into list - if ($this->userownerid > 0) $this->userassigned[$this->userownerid]=array('id'=>$this->userownerid); // Set first so will be first into list. + if ($this->userownerid > 0) $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); // Set first so will be first into list. while ($obj = $this->db->fetch_object($resql)) { @@ -806,11 +806,11 @@ class ActionComm extends CommonObject { switch ($obj->element_type) { case 'user': - $this->userassigned[$obj->fk_element]=array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); - if (empty($this->userownerid)) $this->userownerid=$obj->fk_element; // If not defined (should not happened, we fix this) + $this->userassigned[$obj->fk_element] = array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); + if (empty($this->userownerid)) $this->userownerid = $obj->fk_element; // If not defined (should not happened, we fix this) break; case 'socpeople': - $this->socpeopleassigned[$obj->fk_element]=array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); + $this->socpeopleassigned[$obj->fk_element] = array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); break; } } @@ -928,15 +928,15 @@ class ActionComm extends CommonObject if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('ACTION_DELETE', $user); + $result = $this->call_trigger('ACTION_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -950,7 +950,7 @@ class ActionComm extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -965,70 +965,70 @@ class ActionComm extends CommonObject */ public function update($user, $notrigger = 0) { - global $langs,$conf,$hookmanager; + global $langs, $conf, $hookmanager; - $error=0; + $error = 0; // Clean parameters - $this->label=trim($this->label); - $this->note=trim($this->note); + $this->label = trim($this->label); + $this->note = trim($this->note); if (empty($this->percentage)) $this->percentage = 0; - if (empty($this->priority) || ! is_numeric($this->priority)) $this->priority = 0; + if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; if (empty($this->transparency)) $this->transparency = 0; if (empty($this->fulldayevent)) $this->fulldayevent = 0; if ($this->percentage > 100) $this->percentage = 100; //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; - if ($this->datep && $this->datef) $this->durationp=($this->datef - $this->datep); // deprecated + if ($this->datep && $this->datef) $this->durationp = ($this->datef - $this->datep); // deprecated //if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date); - if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef=$this->datep; + if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef = $this->datep; //if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date; if ($this->fk_project < 0) $this->fk_project = 0; // Check parameters if ($this->percentage == 0 && $this->userdoneid > 0) { - $this->error="ErrorCantSaveADoneUserWithZeroPercentage"; + $this->error = "ErrorCantSaveADoneUserWithZeroPercentage"; return -1; } - $socid=(($this->socid > 0)?$this->socid:0); - $contactid=(($this->contactid > 0)?$this->contactid:0); - $userownerid=($this->userownerid?$this->userownerid:0); - $userdoneid=($this->userdoneid?$this->userdoneid:0); + $socid = (($this->socid > 0) ? $this->socid : 0); + $contactid = (($this->contactid > 0) ? $this->contactid : 0); + $userownerid = ($this->userownerid ? $this->userownerid : 0); + $userdoneid = ($this->userdoneid ? $this->userdoneid : 0); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; - $sql.= " SET percent = '".$this->db->escape($this->percentage)."'"; - if ($this->type_id > 0) $sql.= ", fk_action = '".$this->db->escape($this->type_id)."'"; - $sql.= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'":"null"); - $sql.= ", datep = ".(strval($this->datep)!='' ? "'".$this->db->idate($this->datep)."'" : 'null'); - $sql.= ", datep2 = ".(strval($this->datef)!='' ? "'".$this->db->idate($this->datef)."'" : 'null'); - $sql.= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->db->escape($this->durationp)."'":"null"); // deprecated - $sql.= ", note = '".$this->db->escape($this->note_private?$this->note_private:$this->note)."'"; - $sql.= ", fk_project =". ($this->fk_project > 0 ? $this->fk_project:"null"); - $sql.= ", fk_soc =". ($socid > 0 ? $socid:"null"); - $sql.= ", fk_contact =". ($contactid > 0 ? $contactid:"null"); - $sql.= ", priority = '".$this->db->escape($this->priority)."'"; - $sql.= ", fulldayevent = '".$this->db->escape($this->fulldayevent)."'"; - $sql.= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'":"null"); - $sql.= ", transparency = '".$this->db->escape($this->transparency)."'"; - $sql.= ", fk_user_mod = ".$user->id; - $sql.= ", fk_user_action=".($userownerid > 0 ? "'".$userownerid."'":"null"); - $sql.= ", fk_user_done=".($userdoneid > 0 ? "'".$userdoneid."'":"null"); - if (! empty($this->fk_element)) $sql.= ", fk_element=".($this->fk_element?$this->db->escape($this->fk_element):"null"); - if (! empty($this->elementtype)) $sql.= ", elementtype=".($this->elementtype?"'".$this->db->escape($this->elementtype)."'":"null"); - $sql.= " WHERE id=".$this->id; + $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; + if ($this->type_id > 0) $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; + $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); + $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null'); + $sql .= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '' ? "'".$this->db->escape($this->durationp)."'" : "null"); // deprecated + $sql .= ", note = '".$this->db->escape($this->note_private ? $this->note_private : $this->note)."'"; + $sql .= ", fk_project =".($this->fk_project > 0 ? $this->fk_project : "null"); + $sql .= ", fk_soc =".($socid > 0 ? $socid : "null"); + $sql .= ", fk_contact =".($contactid > 0 ? $contactid : "null"); + $sql .= ", priority = '".$this->db->escape($this->priority)."'"; + $sql .= ", fulldayevent = '".$this->db->escape($this->fulldayevent)."'"; + $sql .= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'" : "null"); + $sql .= ", transparency = '".$this->db->escape($this->transparency)."'"; + $sql .= ", fk_user_mod = ".$user->id; + $sql .= ", fk_user_action=".($userownerid > 0 ? "'".$userownerid."'" : "null"); + $sql .= ", fk_user_done=".($userdoneid > 0 ? "'".$userdoneid."'" : "null"); + if (!empty($this->fk_element)) $sql .= ", fk_element=".($this->fk_element ? $this->db->escape($this->fk_element) : "null"); + if (!empty($this->elementtype)) $sql .= ", elementtype=".($this->elementtype ? "'".$this->db->escape($this->elementtype)."'" : "null"); + $sql .= " WHERE id=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); if ($this->db->query($sql)) { - $action='update'; + $action = 'update'; // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -1036,25 +1036,25 @@ class ActionComm extends CommonObject } // Now insert assignedusers - if (! $error) + if (!$error) { - $sql ="DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'user'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'user'"; $resql = $this->db->query($sql); - foreach($this->userassigned as $key => $val) + foreach ($this->userassigned as $key => $val) { - if (! is_array($val)) // For backward compatibility when val=id + if (!is_array($val)) // For backward compatibility when val=id { - $val=array('id'=>$val); + $val = array('id'=>$val); } - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory'])?'0':$val['mandatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } //var_dump($sql);exit; } @@ -1062,35 +1062,35 @@ class ActionComm extends CommonObject if (!$error) { - $sql ="DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'socpeople'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'socpeople'"; $resql = $this->db->query($sql); if (!empty($this->socpeopleassigned)) { foreach (array_keys($this->socpeopleassigned) as $id) { - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ACTION_MODIFY', $user); + $result = $this->call_trigger('ACTION_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1105,7 +1105,7 @@ class ActionComm extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1128,31 +1128,31 @@ class ActionComm extends CommonObject { global $conf, $langs; - $resarray=array(); + $resarray = array(); dol_syslog(get_class()."::getActions", LOG_DEBUG); $sql = "SELECT a.id"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; - if (! empty($socid)) $sql.= " AND a.fk_soc = ".$socid; - if (! empty($elementtype)) + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; + if (!empty($socid)) $sql .= " AND a.fk_soc = ".$socid; + if (!empty($elementtype)) { - if ($elementtype == 'project') $sql.= ' AND a.fk_project = '.$fk_element; - else $sql.= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$elementtype."'"; + if ($elementtype == 'project') $sql .= ' AND a.fk_project = '.$fk_element; + else $sql .= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$elementtype."'"; } - if (! empty($filter)) $sql.= $filter; - if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder); - $sql.=$db->plimit($limit, 0); + if (!empty($filter)) $sql .= $filter; + if ($sortorder && $sortfield) $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($limit, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { - for($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { $obj = $db->fetch_object($resql); $actioncommstatic = new ActionComm($db); @@ -1242,16 +1242,16 @@ class ActionComm extends CommonObject public function info($id) { $sql = 'SELECT '; - $sql.= ' a.id,'; - $sql.= ' datec,'; - $sql.= ' tms as datem,'; - $sql.= ' fk_user_author,'; - $sql.= ' fk_user_mod'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - $sql.= ' WHERE a.id = '.$id; + $sql .= ' a.id,'; + $sql .= ' datec,'; + $sql .= ' tms as datem,'; + $sql .= ' fk_user_author,'; + $sql .= ' fk_user_mod'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; + $sql .= ' WHERE a.id = '.$id; dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -1262,7 +1262,7 @@ class ActionComm extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_mod) { @@ -1271,8 +1271,8 @@ class ActionComm extends CommonObject $this->user_modification = $muser; } - $this->date_creation = $this->db->jdate($obj->datec); - if (! empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); + $this->date_creation = $this->db->jdate($obj->datec); + if (!empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); } $this->db->free($result); } @@ -1312,57 +1312,57 @@ class ActionComm extends CommonObject if ($mode == 0) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%)'; + if ($percent == -1 && !$hidenastatus) return $langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return $langs->trans('StatusActionToDo').' (0%)'; elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)'; } elseif ($mode == 1) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - elseif ($percent==0) return $langs->trans('StatusActionToDo'); + if ($percent == -1 && !$hidenastatus) return $langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return $langs->trans('StatusActionToDo'); elseif ($percent > 0 && $percent < 100) return $percent.'%'; elseif ($percent >= 100) return $langs->trans('StatusActionDone'); } elseif ($mode == 2) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); - elseif ($percent==0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo'); - elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'), 'statut3').' '. $percent.'%'; + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo'); + elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'), 'statut3').' '.$percent.'%'; elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'), 'statut6').' '.$langs->trans('StatusActionDone'); } elseif ($mode == 3) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans("Status").': '.$langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo').' (0%)', 'statut1'); + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans("Status").': '.$langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo').' (0%)', 'statut1'); elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)', 'statut3'); elseif ($percent >= 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionDone').' (100%)', 'statut6'); } elseif ($mode == 4) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); - elseif ($percent==0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo').' (0%)'; + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo').' (0%)'; elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'), 'statut3').' '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)'; elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'), 'statut6').' '.$langs->trans('StatusActionDone').' (100%)'; } elseif ($mode == 5) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); elseif ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%', 'statut3'); elseif ($percent >= 100) return $langs->trans('StatusActionDone').' '.img_picto($langs->trans('StatusActionDone'), 'statut6'); } elseif ($mode == 6) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable').' '.img_picto($langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%) '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); + if ($percent == -1 && !$hidenastatus) return $langs->trans('StatusNotApplicable').' '.img_picto($langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return $langs->trans('StatusActionToDo').' (0%) '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%) '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%', 'statut3'); elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%) '.img_picto($langs->trans('StatusActionDone'), 'statut6'); } elseif ($mode == 7) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); elseif ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%', 'statut3'); elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'), 'statut6'); } @@ -1387,7 +1387,7 @@ class ActionComm extends CommonObject { global $conf, $langs, $user, $hookmanager, $action; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if ((!$user->rights->agenda->allactions->read && $this->authorid != $user->id) || (!$user->rights->agenda->myactions->read && $this->authorid == $user->id)) { @@ -1395,45 +1395,45 @@ class ActionComm extends CommonObject } $label = $this->label; - if (empty($label)) $label=$this->libelle; // For backward compatibility + if (empty($label)) $label = $this->libelle; // For backward compatibility - $result=''; + $result = ''; // Set label of type $labeltype = ''; if ($this->type_code) { - $labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label; + $labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code) ? $langs->transnoentities("Action".$this->type_code) : $this->type_label; } if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); } - $tooltip = '' . $langs->trans('ShowAction') . ''; - if (! empty($this->ref)) - $tooltip .= '
        ' . $langs->trans('Ref') . ': ' . $this->ref; - if (! empty($label)) - $tooltip .= '
        ' . $langs->trans('Title') . ': ' . $label; - if (! empty($labeltype)) - $tooltip .= '
        ' . $langs->trans('Type') . ': ' . $labeltype; - 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)); - $linkclose=''; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) + $tooltip = ''.$langs->trans('ShowAction').''; + if (!empty($this->ref)) + $tooltip .= '
        '.$langs->trans('Ref').': '.$this->ref; + if (!empty($label)) + $tooltip .= '
        '.$langs->trans('Title').': '.$label; + if (!empty($labeltype)) + $tooltip .= '
        '.$langs->trans('Type').': '.$labeltype; + 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)); + $linkclose = ''; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) $linkclose = ' style="background-color:#'.$this->type_color.'"'; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowAction"); - $linkclose.=' alt="'.dol_escape_htmltag($tooltip, 1).'"'; + $label = $langs->trans("ShowAction"); + $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($tooltip, 1).'"'; - $linkclose.=' class="'.$classname.' classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1).'"'; + $linkclose .= ' class="'.$classname.' classfortooltip"'; /* $hookmanager->initHooks(array('actiondao')); @@ -1442,24 +1442,24 @@ class ActionComm extends CommonObject $linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose); */ } - else $linkclose.=' class="'.$classname.'"'; + else $linkclose .= ' class="'.$classname.'"'; - $url=''; - if ($option=='birthday') + $url = ''; + if ($option == 'birthday') $url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id; else $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; if ($option !== 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; if ($option == 'nolink') { $linkstart = ''; @@ -1468,38 +1468,38 @@ class ActionComm extends CommonObject if ($withpicto == 2) { - $libelle=$label; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$labeltype; - $libelleshort=''; + $libelle = $label; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle = $labeltype; + $libelleshort = ''; } else { - $libelle=(empty($this->libelle)?$label:$this->libelle.(($label && $label != $this->libelle)?' '.$label:'')); - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle=$labeltype; - if ($maxlength < 0) $libelleshort=$this->ref; - else $libelleshort=dol_trunc($libelle, $maxlength); + $libelle = (empty($this->libelle) ? $label : $this->libelle.(($label && $label != $this->libelle) ? ' '.$label : '')); + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle = $labeltype; + if ($maxlength < 0) $libelleshort = $this->ref; + else $libelleshort = dol_trunc($libelle, $maxlength); } if ($withpicto) { - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () { if ($labeltype) { - $libelle.=(preg_match('/'.preg_quote($labeltype, '/').'/', $libelle)?'':' ('.$langs->transnoentities("Action".$this->type_code).')'); + $libelle .= (preg_match('/'.preg_quote($labeltype, '/').'/', $libelle) ? '' : ' ('.$langs->transnoentities("Action".$this->type_code).')'); } } } - $result.=$linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$langs->trans("ShowAction").': '.$libelle), ($overwritepicto?$overwritepicto:'action'), ($notooltip?'class="'.(($withpicto != 2) ? 'paddingright ' : '').'valigntextbottom"':'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1); - $result.=$libelleshort; - $result.=$linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$libelle), ($overwritepicto ? $overwritepicto : 'action'), ($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'valigntextbottom"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip ? 0 : 1); + $result .= $libelleshort; + $result .= $linkend; global $action; $hookmanager->initHooks(array('actiondao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -1523,11 +1523,11 @@ class ActionComm extends CommonObject global $hookmanager; // phpcs:enable - global $conf,$langs,$dolibarr_main_url_root,$mysoc; + global $conf, $langs, $dolibarr_main_url_root, $mysoc; - require_once DOL_DOCUMENT_ROOT ."/core/lib/xcal.lib.php"; - require_once DOL_DOCUMENT_ROOT ."/core/lib/date.lib.php"; - require_once DOL_DOCUMENT_ROOT ."/core/lib/files.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/xcal.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; dol_syslog(get_class($this)."::build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG); @@ -1535,21 +1535,21 @@ class ActionComm extends CommonObject if (empty($format)) return -1; // Clean parameters - if (! $filename) + if (!$filename) { - $extension='vcs'; - if ($format == 'ical') $extension='ics'; - $filename=$format.'.'.$extension; + $extension = 'vcs'; + if ($format == 'ical') $extension = 'ics'; + $filename = $format.'.'.$extension; } // Create dir and define output file (definitive and temporary) - $result=dol_mkdir($conf->agenda->dir_temp); - $outputfile=$conf->agenda->dir_temp.'/'.$filename; + $result = dol_mkdir($conf->agenda->dir_temp); + $outputfile = $conf->agenda->dir_temp.'/'.$filename; - $result=0; + $result = 0; - $buildfile=true; - $login='';$logina='';$logind='';$logint=''; + $buildfile = true; + $login = ''; $logina = ''; $logind = ''; $logint = ''; $now = dol_now(); @@ -1774,7 +1774,7 @@ class ActionComm extends CommonObject dol_syslog(get_class($this)."::build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR); dol_delete_file($outputfiletmp, 0, 1); $langs->load("errors"); - $this->error=$langs->trans("ErrorFailToCreateFile", $outputfile); + $this->error = $langs->trans("ErrorFailToCreateFile", $outputfile); } } @@ -1792,32 +1792,32 @@ class ActionComm extends CommonObject { global $user; - $now=dol_now(); + $now = dol_now(); // Initialise parametres - $this->id=0; - $this->specimen=1; + $this->id = 0; + $this->specimen = 1; - $this->type_code='AC_OTH'; - $this->code='AC_SPECIMEN_CODE'; - $this->label='Label of event Specimen'; - $this->datec=$now; - $this->datem=$now; - $this->datep=$now; - $this->datef=$now; - $this->author=$user; - $this->usermod=$user; - $this->usertodo=$user; - $this->fulldayevent=0; - $this->punctual=0; - $this->percentage=0; - $this->location='Location'; - $this->transparency=1; // 1 means opaque - $this->priority=1; + $this->type_code = 'AC_OTH'; + $this->code = 'AC_SPECIMEN_CODE'; + $this->label = 'Label of event Specimen'; + $this->datec = $now; + $this->datem = $now; + $this->datep = $now; + $this->datef = $now; + $this->author = $user; + $this->usermod = $user; + $this->usertodo = $user; + $this->fulldayevent = 0; + $this->punctual = 0; + $this->percentage = 0; + $this->location = 'Location'; + $this->transparency = 1; // 1 means opaque + $this->priority = 1; $this->note = 'Note'; - $this->userownerid=$user->id; - $this->userassigned[$user->id]=array('id'=>$user->id, 'transparency'=> 1); + $this->userownerid = $user->id; + $this->userassigned[$user->id] = array('id'=>$user->id, 'transparency'=> 1); return 1; } @@ -1865,7 +1865,7 @@ class ActionComm extends CommonObject $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible. { diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 67ec7414e7c..9c589c4ae3d 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -35,7 +35,7 @@ class FormAdvTargetEmailing extends Form /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * Constructor @@ -62,15 +62,15 @@ class FormAdvTargetEmailing extends Form $options_array = array(); $sql = "SELECT code, label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_prospectlevel"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; - dol_syslog(get_class($this) . '::multiselectProspectionStatus sql=' . $sql, LOG_DEBUG); + dol_syslog(get_class($this).'::multiselectProspectionStatus sql='.$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ( $i < $num ) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $level = $langs->trans($obj->code); @@ -78,7 +78,7 @@ class FormAdvTargetEmailing extends Form $level = $langs->trans($obj->label); $options_array[$obj->code] = $level; - $i ++; + $i++; } } else { dol_print_error($this->db); @@ -102,16 +102,16 @@ class FormAdvTargetEmailing extends Form $out = ''; $countryArray = array(); - $label = array (); + $label = array(); $options_array = array(); $sql = "SELECT rowid, code as code_iso, label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_country"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_country"; $sql .= " WHERE active = 1 AND code<>''"; $sql .= " ORDER BY code ASC"; - dol_syslog(get_class($this) . "::select_country sql=" . $sql); + dol_syslog(get_class($this)."::select_country sql=".$sql); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -123,9 +123,9 @@ class FormAdvTargetEmailing extends Form $obj = $this->db->fetch_object($resql); $countryArray [$i] ['rowid'] = $obj->rowid; $countryArray [$i] ['code_iso'] = $obj->code_iso; - $countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country" . $obj->code_iso) != "Country" . $obj->code_iso ? $langs->transnoentitiesnoconv("Country" . $obj->code_iso) : ($obj->label != '-' ? $obj->label : '')); + $countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso) != "Country".$obj->code_iso ? $langs->transnoentitiesnoconv("Country".$obj->code_iso) : ($obj->label != '-' ? $obj->label : '')); $label[$i] = $countryArray[$i]['label']; - $i ++; + $i++; } array_multisort($label, SORT_ASC, $countryArray); @@ -133,7 +133,7 @@ class FormAdvTargetEmailing extends Form foreach ($countryArray as $row) { $label = dol_trunc($row['label'], $maxlength, 'middle'); if ($row['code_iso']) - $label .= ' (' . $row['code_iso'] . ')'; + $label .= ' ('.$row['code_iso'].')'; $options_array[$row['rowid']] = $label; } @@ -158,23 +158,23 @@ class FormAdvTargetEmailing extends Form global $conf; - $options_array = array (); + $options_array = array(); - $sql_usr = ''; + $sql_usr = ''; $sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login"; - $sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u2, " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; - $sql_usr .= " WHERE u2.entity IN (0," . $conf->entity . ")"; + $sql_usr .= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql_usr .= " WHERE u2.entity IN (0,".$conf->entity.")"; $sql_usr .= " AND u2.rowid = sc.fk_user "; - if (! empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) + if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) $sql_usr .= " AND u2.statut<>0 "; $sql_usr .= " ORDER BY name ASC"; // print $sql_usr;exit; $resql_usr = $this->db->query($sql_usr); if ($resql_usr) { - while ( $obj_usr = $this->db->fetch_object($resql_usr) ) { - $label = $obj_usr->firstname . " " . $obj_usr->name . " (" . $obj_usr->login . ')'; + while ($obj_usr = $this->db->fetch_object($resql_usr)) { + $label = $obj_usr->firstname." ".$obj_usr->name." (".$obj_usr->login.')'; $options_array [$obj_usr->rowid] = $label; } @@ -196,11 +196,11 @@ class FormAdvTargetEmailing extends Form public function multiselectselectLanguage($htmlname = '', $selected_array = array()) { - global $conf,$langs; + global $conf, $langs; - $options_array = array (); + $options_array = array(); - $langs_available=$langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); + $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); foreach ($langs_available as $key => $value) { @@ -222,7 +222,7 @@ class FormAdvTargetEmailing extends Form */ public function advMultiselectarraySelllist($htmlname, $sqlqueryparam = array(), $selected_array = array()) { - $options_array=array(); + $options_array = array(); if (is_array($sqlqueryparam)) { @@ -238,39 +238,39 @@ class FormAdvTargetEmailing extends Form if (count($InfoFieldList) >= 3) { if (strpos($InfoFieldList [3], 'extra.') !== false) { - $keyList = 'main.' . $InfoFieldList [2] . ' as rowid'; + $keyList = 'main.'.$InfoFieldList [2].' as rowid'; } else { - $keyList = $InfoFieldList [2] . ' as rowid'; + $keyList = $InfoFieldList [2].' as rowid'; } } - $sql = 'SELECT ' . $keyList . ', ' . $InfoFieldList [1]; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList [0]; - if (! empty($InfoFieldList [3])) { + $sql = 'SELECT '.$keyList.', '.$InfoFieldList [1]; + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList [0]; + if (!empty($InfoFieldList [3])) { // We have to join on extrafield table if (strpos($InfoFieldList [3], 'extra') !== false) { - $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList [0] . '_extrafields as extra'; - $sql .= ' WHERE extra.fk_object=main.' . $InfoFieldList [2] . ' AND ' . $InfoFieldList [3]; + $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList [0].'_extrafields as extra'; + $sql .= ' WHERE extra.fk_object=main.'.$InfoFieldList [2].' AND '.$InfoFieldList [3]; } else { - $sql .= ' WHERE ' . $InfoFieldList [3]; + $sql .= ' WHERE '.$InfoFieldList [3]; } } - if (! empty($InfoFieldList[1])) { + if (!empty($InfoFieldList[1])) { $sql .= " ORDER BY nom"; } // $sql.= ' WHERE entity = '.$conf->entity; - dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; if ($num) { - while ( $i < $num ) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $labeltoshow = dol_trunc($obj->$InfoFieldList [1], 90); - $options_array[$obj->rowid]=$labeltoshow; - $i ++; + $options_array[$obj->rowid] = $labeltoshow; + $i++; } } $this->db->free($resql); @@ -289,17 +289,17 @@ class FormAdvTargetEmailing extends Form */ public function multiselectCivility($htmlname = 'civilite_id', $selected_array = array()) { - global $conf,$langs,$user; + global $conf, $langs, $user; $langs->load("dict"); - $options_array=array(); + $options_array = array(); $sql = "SELECT rowid, code, label as civilite, active FROM ".MAIN_DB_PREFIX."c_civility"; - $sql.= " WHERE active = 1"; + $sql .= " WHERE active = 1"; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -310,10 +310,10 @@ class FormAdvTargetEmailing extends Form { $obj = $this->db->fetch_object($resql); // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $label= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:'')); + $label = ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite != '-' ? $obj->civilite : '')); - $options_array[$obj->code]=$label; + $options_array[$obj->code] = $label; $i++; } @@ -340,7 +340,7 @@ class FormAdvTargetEmailing extends Form { global $conf, $langs; - $form=new Form($this->db); + $form = new Form($this->db); $return = $form->multiselectarray($htmlname, $options_array, $selected_array, 0, 0, '', 0, 295); return $return; } @@ -379,16 +379,16 @@ class FormAdvTargetEmailing extends Form */ public function multiselectCategories($htmlname = '', $selected_array = array(), $type = 0) { - global $conf,$langs,$user; + global $conf, $langs, $user; $langs->load("dict"); - $options_array=array(); + $options_array = array(); $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE type=".$type; + $sql .= " WHERE type=".$type; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -399,7 +399,7 @@ class FormAdvTargetEmailing extends Form { $obj = $this->db->fetch_object($resql); - $options_array[$obj->rowid]=$obj->label; + $options_array[$obj->rowid] = $obj->label; $i++; } @@ -429,32 +429,32 @@ class FormAdvTargetEmailing extends Form $out = ''; $sql = "SELECT c.rowid, c.name, c.fk_element"; - $sql .= " FROM " . MAIN_DB_PREFIX . "advtargetemailing as c"; + $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as c"; $sql .= " WHERE type_element='$type_element'"; $sql .= " ORDER BY c.name"; - dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $out .= ''; if ($showempty) $out .= ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) { - while ( $i < $num ) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $label = $obj->name; if (empty($label)) { - $label=$obj->fk_element; + $label = $obj->fk_element; } if ($selected > 0 && $selected == $obj->rowid) { - $out .= ''; + $out .= ''; } else { - $out .= ''; + $out .= ''; } - $i ++; + $i++; } } $out .= ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 57cff121010..ec29e4e5240 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -28,7 +28,7 @@ * \ingroup bank * \brief File of class to manage bank accounts */ -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** @@ -92,7 +92,7 @@ class Account extends CommonObject * Does it need to be conciliated? * @var int */ - public $rappro=1; + public $rappro = 1; /** * Webpage @@ -315,18 +315,18 @@ class Account extends CommonObject { // phpcs:enable $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; - $sql.= "fk_bank"; - $sql.= ", url_id"; - $sql.= ", url"; - $sql.= ", label"; - $sql.= ", type"; - $sql.= ") VALUES ("; - $sql.= "'".$line_id."'"; - $sql.= ", '".$url_id."'"; - $sql.= ", '".$url."'"; - $sql.= ", '".$this->db->escape($label)."'"; - $sql.= ", '".$type."'"; - $sql.= ")"; + $sql .= "fk_bank"; + $sql .= ", url_id"; + $sql .= ", url"; + $sql .= ", label"; + $sql .= ", type"; + $sql .= ") VALUES ("; + $sql .= "'".$line_id."'"; + $sql .= ", '".$url_id."'"; + $sql .= ", '".$url."'"; + $sql .= ", '".$this->db->escape($label)."'"; + $sql .= ", '".$type."'"; + $sql .= ")"; dol_syslog(get_class($this)."::add_url_line", LOG_DEBUG); if ($this->db->query($sql)) @@ -336,7 +336,7 @@ class Account extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -357,20 +357,20 @@ class Account extends CommonObject $lines = array(); // Check parameters - if (! empty($fk_bank) && (! empty($url_id) || ! empty($type))) + if (!empty($fk_bank) && (!empty($url_id) || !empty($type))) { - $this->error="ErrorBadParameter"; + $this->error = "ErrorBadParameter"; return -1; } $sql = "SELECT fk_bank, url_id, url, label, type"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_url"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_url"; if ($fk_bank > 0) { - $sql.= " WHERE fk_bank = ".$fk_bank; + $sql .= " WHERE fk_bank = ".$fk_bank; } - else { $sql.= " WHERE url_id = ".$url_id." AND type = '".$type."'"; + else { $sql .= " WHERE url_id = ".$url_id." AND type = '".$type."'"; } - $sql.= " ORDER BY type, label"; + $sql .= " ORDER BY type, label"; dol_syslog(get_class($this)."::get_url", LOG_DEBUG); $result = $this->db->query($sql); @@ -420,25 +420,25 @@ class Account extends CommonObject { // Deprecation warning if (is_numeric($oper)) { - dol_syslog(__METHOD__ . ": using numeric operations is deprecated", LOG_WARNING); + dol_syslog(__METHOD__.": using numeric operations is deprecated", LOG_WARNING); } // Clean parameters - $emetteur=trim($emetteur); - $banque=trim($banque); + $emetteur = trim($emetteur); + $banque = trim($banque); - $now=dol_now(); + $now = dol_now(); if (is_numeric($oper)) // Clean operation to have a code instead of a rowid { $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; - $sql.= " WHERE id=".$oper; - $sql.= " AND entity IN (".getEntity('c_paiement').")"; - $resql=$this->db->query($sql); + $sql .= " WHERE id=".$oper; + $sql .= " AND entity IN (".getEntity('c_paiement').")"; + $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - $oper=$obj->code; + $obj = $this->db->fetch_object($resql); + $oper = $obj->code; } else { @@ -448,19 +448,19 @@ class Account extends CommonObject } // Check parameters - if (! $oper) + if (!$oper) { - $this->error="oper not defined"; + $this->error = "oper not defined"; return -1; } - if (! $this->rowid) + if (!$this->rowid) { - $this->error="this->rowid not defined"; + $this->error = "this->rowid not defined"; return -2; } if ($this->courant == Account::TYPE_CASH && $oper != 'LIQ') { - $this->error="ErrorCashAccountAcceptsOnlyCashMoney"; + $this->error = "ErrorCashAccountAcceptsOnlyCashMoney"; return -3; } @@ -492,7 +492,7 @@ class Account extends CommonObject } if ($accline->insert() > 0) { - if ($categorie>0) { + if ($categorie > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; $sql .= "lineid, fk_categ"; $sql .= ") VALUES ("; @@ -525,32 +525,32 @@ class Account extends CommonObject */ public function create(User $user, $notrigger = 0) { - global $langs,$conf, $hookmanager; + global $langs, $conf, $hookmanager; - $error=0; + $error = 0; // Clean parameters - if (! $this->min_allowed) $this->min_allowed=0; - if (! $this->min_desired) $this->min_desired=0; - $this->state_id = ($this->state_id?$this->state_id:$this->state_id); - $this->country_id = ($this->country_id?$this->country_id:$this->country_id); + if (!$this->min_allowed) $this->min_allowed = 0; + if (!$this->min_desired) $this->min_desired = 0; + $this->state_id = ($this->state_id ? $this->state_id : $this->state_id); + $this->country_id = ($this->country_id ? $this->country_id : $this->country_id); // Check parameters if (empty($this->country_id)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } if (empty($this->ref)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } if (empty($this->date_solde)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateInitialBalance")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateInitialBalance")); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } @@ -558,67 +558,67 @@ class Account extends CommonObject // Chargement librairie pour acces fonction controle RIB require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; - $now=dol_now(); + $now = dol_now(); $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account ("; - $sql.= "datec"; - $sql.= ", ref"; - $sql.= ", label"; - $sql.= ", entity"; - $sql.= ", account_number"; - $sql.= ", fk_accountancy_journal"; - $sql.= ", bank"; - $sql.= ", code_banque"; - $sql.= ", code_guichet"; - $sql.= ", number"; - $sql.= ", cle_rib"; - $sql.= ", bic"; - $sql.= ", iban_prefix"; - $sql.= ", domiciliation"; - $sql.= ", proprio"; - $sql.= ", owner_address"; - $sql.= ", currency_code"; - $sql.= ", rappro"; - $sql.= ", min_allowed"; - $sql.= ", min_desired"; - $sql.= ", comment"; - $sql.= ", state_id"; - $sql.= ", fk_pays"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."'"; - $sql.= ", '".$this->db->escape($this->ref)."'"; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", ".$conf->entity; - $sql.= ", '".$this->db->escape($this->account_number)."'"; - $sql.= ", ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); - $sql.= ", '".$this->db->escape($this->bank)."'"; - $sql.= ", '".$this->db->escape($this->code_banque)."'"; - $sql.= ", '".$this->db->escape($this->code_guichet)."'"; - $sql.= ", '".$this->db->escape($this->number)."'"; - $sql.= ", '".$this->db->escape($this->cle_rib)."'"; - $sql.= ", '".$this->db->escape($this->bic)."'"; - $sql.= ", '".$this->db->escape($this->iban)."'"; - $sql.= ", '".$this->db->escape($this->domiciliation)."'"; - $sql.= ", '".$this->db->escape($this->proprio)."'"; - $sql.= ", '".$this->db->escape($this->owner_address)."'"; - $sql.= ", '".$this->db->escape($this->currency_code)."'"; - $sql.= ", ".$this->rappro; - $sql.= ", ".price2num($this->min_allowed); - $sql.= ", ".price2num($this->min_desired); - $sql.= ", '".$this->db->escape($this->comment)."'"; - $sql.= ", ".($this->state_id>0?$this->state_id:"null"); - $sql.= ", ".$this->country_id; - $sql.= ")"; + $sql .= "datec"; + $sql .= ", ref"; + $sql .= ", label"; + $sql .= ", entity"; + $sql .= ", account_number"; + $sql .= ", fk_accountancy_journal"; + $sql .= ", bank"; + $sql .= ", code_banque"; + $sql .= ", code_guichet"; + $sql .= ", number"; + $sql .= ", cle_rib"; + $sql .= ", bic"; + $sql .= ", iban_prefix"; + $sql .= ", domiciliation"; + $sql .= ", proprio"; + $sql .= ", owner_address"; + $sql .= ", currency_code"; + $sql .= ", rappro"; + $sql .= ", min_allowed"; + $sql .= ", min_desired"; + $sql .= ", comment"; + $sql .= ", state_id"; + $sql .= ", fk_pays"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($now)."'"; + $sql .= ", '".$this->db->escape($this->ref)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", ".$conf->entity; + $sql .= ", '".$this->db->escape($this->account_number)."'"; + $sql .= ", ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); + $sql .= ", '".$this->db->escape($this->bank)."'"; + $sql .= ", '".$this->db->escape($this->code_banque)."'"; + $sql .= ", '".$this->db->escape($this->code_guichet)."'"; + $sql .= ", '".$this->db->escape($this->number)."'"; + $sql .= ", '".$this->db->escape($this->cle_rib)."'"; + $sql .= ", '".$this->db->escape($this->bic)."'"; + $sql .= ", '".$this->db->escape($this->iban)."'"; + $sql .= ", '".$this->db->escape($this->domiciliation)."'"; + $sql .= ", '".$this->db->escape($this->proprio)."'"; + $sql .= ", '".$this->db->escape($this->owner_address)."'"; + $sql .= ", '".$this->db->escape($this->currency_code)."'"; + $sql .= ", ".$this->rappro; + $sql .= ", ".price2num($this->min_allowed); + $sql .= ", ".price2num($this->min_desired); + $sql .= ", '".$this->db->escape($this->comment)."'"; + $sql .= ", ".($this->state_id > 0 ? $this->state_id : "null"); + $sql .= ", ".$this->country_id; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account"); - $result=$this->update($user, 1); + $result = $this->update($user, 1); if ($result > 0) { $accline = new AccountLine($this->db); @@ -637,16 +637,16 @@ class Account extends CommonObject $this->errors = $accline->errors; } - if (! $error) + if (!$error) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BANKACCOUNT_CREATE', $user); + $result = $this->call_trigger('BANKACCOUNT_CREATE', $user); if ($result < 0) $error++; // End call triggers } @@ -660,16 +660,16 @@ class Account extends CommonObject { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$langs->trans("ErrorBankLabelAlreadyExists"); + $this->error = $langs->trans("ErrorBankLabelAlreadyExists"); $error++; } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $error++; } } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -677,7 +677,7 @@ class Account extends CommonObject else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -690,63 +690,63 @@ class Account extends CommonObject */ public function update(User $user, $notrigger = 0) { - global $langs,$conf, $hookmanager; + global $langs, $conf, $hookmanager; - $error=0; + $error = 0; $this->db->begin(); // Clean parameters - $this->state_id = ($this->state_id?$this->state_id:$this->state_id); - $this->country_id = ($this->country_id?$this->country_id:$this->country_id); + $this->state_id = ($this->state_id ? $this->state_id : $this->state_id); + $this->country_id = ($this->country_id ? $this->country_id : $this->country_id); // Check parameters if (empty($this->country_id)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); return -1; } if (empty($this->ref)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); return -1; } - if (! $this->label) $this->label = "???"; + if (!$this->label) $this->label = "???"; $sql = "UPDATE ".MAIN_DB_PREFIX."bank_account SET "; - $sql.= " ref = '".$this->db->escape($this->ref)."'"; - $sql.= ",label = '".$this->db->escape($this->label)."'"; + $sql .= " ref = '".$this->db->escape($this->ref)."'"; + $sql .= ",label = '".$this->db->escape($this->label)."'"; - $sql.= ",courant = ".$this->courant; - $sql.= ",clos = ".$this->clos; - $sql.= ",rappro = ".$this->rappro; - $sql.= ",url = ".($this->url?"'".$this->db->escape($this->url)."'":"null"); - $sql.= ",account_number = '".$this->db->escape($this->account_number)."'"; - $sql.= ",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); - $sql.= ",bank = '".$this->db->escape($this->bank)."'"; - $sql.= ",code_banque='".$this->db->escape($this->code_banque)."'"; - $sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; - $sql.= ",number='".$this->db->escape($this->number)."'"; - $sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; - $sql.= ",bic='".$this->db->escape($this->bic)."'"; - $sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'"; - $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; - $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; - $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; + $sql .= ",courant = ".$this->courant; + $sql .= ",clos = ".$this->clos; + $sql .= ",rappro = ".$this->rappro; + $sql .= ",url = ".($this->url ? "'".$this->db->escape($this->url)."'" : "null"); + $sql .= ",account_number = '".$this->db->escape($this->account_number)."'"; + $sql .= ",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); + $sql .= ",bank = '".$this->db->escape($this->bank)."'"; + $sql .= ",code_banque='".$this->db->escape($this->code_banque)."'"; + $sql .= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; + $sql .= ",number='".$this->db->escape($this->number)."'"; + $sql .= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; + $sql .= ",bic='".$this->db->escape($this->bic)."'"; + $sql .= ",iban_prefix = '".$this->db->escape($this->iban)."'"; + $sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; + $sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; + $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - $sql.= ",currency_code = '".$this->db->escape($this->currency_code)."'"; + $sql .= ",currency_code = '".$this->db->escape($this->currency_code)."'"; - $sql.= ",min_allowed = ".($this->min_allowed != '' ? price2num($this->min_allowed) : "null"); - $sql.= ",min_desired = ".($this->min_desired != '' ? price2num($this->min_desired) : "null"); - $sql.= ",comment = '".$this->db->escape($this->comment)."'"; + $sql .= ",min_allowed = ".($this->min_allowed != '' ? price2num($this->min_allowed) : "null"); + $sql .= ",min_desired = ".($this->min_desired != '' ? price2num($this->min_desired) : "null"); + $sql .= ",comment = '".$this->db->escape($this->comment)."'"; - $sql.= ",state_id = ".($this->state_id>0?$this->state_id:"null"); - $sql.= ",fk_pays = ".$this->country_id; + $sql .= ",state_id = ".($this->state_id > 0 ? $this->state_id : "null"); + $sql .= ",fk_pays = ".$this->country_id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $result = $this->db->query($sql); @@ -755,17 +755,17 @@ class Account extends CommonObject // Actions on extra fields (by external module or standard code) if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (! $error) + if (!$error) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BANKACCOUNT_UPDATE', $user); + $result = $this->call_trigger('BANKACCOUNT_UPDATE', $user); if ($result < 0) $error++; // End call triggers } @@ -773,11 +773,11 @@ class Account extends CommonObject else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_print_error($this->db); } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -785,7 +785,7 @@ class Account extends CommonObject else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -800,11 +800,11 @@ class Account extends CommonObject public function update_bban(User $user = null) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; // Clean parameters - $this->state_id = ($this->state_id?$this->state_id:$this->state_id); - $this->country_id = ($this->country_id?$this->country_id:$this->country_id); + $this->state_id = ($this->state_id ? $this->state_id : $this->state_id); + $this->country_id = ($this->country_id ? $this->country_id : $this->country_id); // Chargement librairie pour acces fonction controle RIB require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; @@ -812,27 +812,27 @@ class Account extends CommonObject dol_syslog(get_class($this)."::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban"); // Check parameters - if (! $this->ref) + if (!$this->ref) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->trans("Ref")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->trans("Ref")); return -2; } $sql = "UPDATE ".MAIN_DB_PREFIX."bank_account SET "; - $sql.= " bank = '".$this->db->escape($this->bank)."'"; - $sql.= ",code_banque='".$this->db->escape($this->code_banque)."'"; - $sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; - $sql.= ",number='".$this->db->escape($this->number)."'"; - $sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; - $sql.= ",bic='".$this->db->escape($this->bic)."'"; - $sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'"; - $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; - $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; - $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - $sql.= ",state_id = ".($this->state_id>0?$this->state_id:"null"); - $sql.= ",fk_pays = ".$this->country_id; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND entity = ".$conf->entity; + $sql .= " bank = '".$this->db->escape($this->bank)."'"; + $sql .= ",code_banque='".$this->db->escape($this->code_banque)."'"; + $sql .= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; + $sql .= ",number='".$this->db->escape($this->number)."'"; + $sql .= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; + $sql .= ",bic='".$this->db->escape($this->bic)."'"; + $sql .= ",iban_prefix = '".$this->db->escape($this->iban)."'"; + $sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; + $sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; + $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; + $sql .= ",state_id = ".($this->state_id > 0 ? $this->state_id : "null"); + $sql .= ",fk_pays = ".$this->country_id; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::update_bban", LOG_DEBUG); @@ -843,7 +843,7 @@ class Account extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_print_error($this->db); return -1; } @@ -863,26 +863,26 @@ class Account extends CommonObject if (empty($id) && empty($ref)) { - $this->error="ErrorBadParameters"; + $this->error = "ErrorBadParameters"; return -1; } $sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,"; - $sql.= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,"; - $sql.= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,"; - $sql.= " ba.account_number, ba.fk_accountancy_journal, ba.currency_code,"; - $sql.= " ba.min_allowed, ba.min_desired, ba.comment,"; - $sql.= " ba.datec as date_creation, ba.tms as date_update,"; - $sql.= ' c.code as country_code, c.label as country,'; - $sql.= ' d.code_departement as state_code, d.nom as state'; - $sql.= ' , aj.code as accountancy_journal'; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON ba.fk_pays = c.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ba.state_id = d.rowid'; - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal'; - $sql.= " WHERE ba.entity IN (".getEntity($this->element).")"; - if ($id) $sql.= " AND ba.rowid = ".$id; - if ($ref) $sql.= " AND ba.ref = '".$this->db->escape($ref)."'"; + $sql .= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,"; + $sql .= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,"; + $sql .= " ba.account_number, ba.fk_accountancy_journal, ba.currency_code,"; + $sql .= " ba.min_allowed, ba.min_desired, ba.comment,"; + $sql .= " ba.datec as date_creation, ba.tms as date_update,"; + $sql .= ' c.code as country_code, c.label as country,'; + $sql .= ' d.code_departement as state_code, d.nom as state'; + $sql .= ' , aj.code as accountancy_journal'; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON ba.fk_pays = c.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ba.state_id = d.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal'; + $sql .= " WHERE ba.entity IN (".getEntity($this->element).")"; + if ($id) $sql .= " AND ba.rowid = ".$id; + if ($ref) $sql .= " AND ba.ref = '".$this->db->escape($ref)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -926,7 +926,7 @@ class Account extends CommonObject $this->accountancy_journal = $obj->accountancy_journal; $this->currency_code = $obj->currency_code; - $this->account_currency_code = $obj->currency_code; + $this->account_currency_code = $obj->currency_code; $this->min_allowed = $obj->min_allowed; $this->min_desired = $obj->min_desired; $this->comment = $obj->comment; @@ -947,8 +947,8 @@ class Account extends CommonObject } else { - $this->error=$this->db->lasterror; - $this->errors[]=$this->error; + $this->error = $this->db->lasterror; + $this->errors[] = $this->error; return -1; } } @@ -966,12 +966,12 @@ class Account extends CommonObject public function setCategories($categories) { // Handle single category - if (! is_array($categories)) { + if (!is_array($categories)) { $categories = array($categories); } // Get current categories - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, Categorie::TYPE_ACCOUNT, 'id'); @@ -985,7 +985,7 @@ class Account extends CommonObject } // Process - foreach($to_del as $del) { + foreach ($to_del as $del) { if ($c->fetch($del) > 0) { $c->del_type($this, Categorie::TYPE_ACCOUNT); } @@ -1009,15 +1009,15 @@ class Account extends CommonObject { global $conf; - $error=0; + $error = 0; $this->db->begin(); // Delete link between tag and bank account - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; - $sql.= " WHERE fk_account = ".$this->id; + $sql .= " WHERE fk_account = ".$this->id; $resql = $this->db->query($sql); if (!$resql) @@ -1027,10 +1027,10 @@ class Account extends CommonObject } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); @@ -1039,7 +1039,7 @@ class Account extends CommonObject // Remove extrafields if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $result=$this->deleteExtraFields(); + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -1054,7 +1054,7 @@ class Account extends CommonObject } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1115,16 +1115,16 @@ class Account extends CommonObject public function can_be_deleted() { // phpcs:enable - $can_be_deleted=false; + $can_be_deleted = false; $sql = "SELECT COUNT(rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."bank"; + $sql .= " WHERE fk_account=".$this->id; $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - if ($obj->nb <= 1) $can_be_deleted=true; // Juste le solde + $obj = $this->db->fetch_object($resql); + if ($obj->nb <= 1) $can_be_deleted = true; // Juste le solde } else { dol_print_error($this->db); @@ -1151,24 +1151,24 @@ class Account extends CommonObject */ public function solde($option = 0) { - $solde=0; + $solde = 0; $sql = "SELECT sum(amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account = ".$this->id; - if ($option == 1) $sql.= " AND dateo <= '".$this->db->idate(dol_now())."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank"; + $sql .= " WHERE fk_account = ".$this->id; + if ($option == 1) $sql .= " AND dateo <= '".$this->db->idate(dol_now())."'"; $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { - $obj=$this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); $solde = $obj->amount; } $this->db->free($resql); } else { - $this->errors[]=$this->db->lasterror; + $this->errors[] = $this->db->lasterror; return -1; } @@ -1228,7 +1228,7 @@ class Account extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1287,14 +1287,14 @@ class Account extends CommonObject return 0; } - $nb=0; + $nb = 0; $sql = "SELECT COUNT(ba.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE ba.rappro > 0 and ba.clos = 0"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql.= " AND ba.courant != 2"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE ba.rappro > 0 and ba.clos = 0"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql .= " AND ba.courant != 2"; + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -1319,23 +1319,23 @@ class Account extends CommonObject { global $conf, $langs, $user; - $result=''; - $label = '' . $langs->trans("ShowAccount") . ''; - $label .= '
        ' . $langs->trans('BankAccount') . ': ' . $this->label; - $label .= '
        ' . $langs->trans('AccountNumber') . ': ' . $this->number; - $label .= '
        ' . $langs->trans("AccountCurrency") . ': ' . $this->currency_code; + $result = ''; + $label = ''.$langs->trans("ShowAccount").''; + $label .= '
        '.$langs->trans('BankAccount').': '.$this->label; + $label .= '
        '.$langs->trans('AccountNumber').': '.$this->number; + $label .= '
        '.$langs->trans("AccountCurrency").': '.$this->currency_code; if (empty($user->rights->banque->lire) || !empty($user->socid)) { $option = 'nolink'; } - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $langs->load("accountancy"); - $label .= '
        ' . $langs->trans('AccountAccounting') . ': ' . length_accountg($this->account_number); - $label .= '
        ' . $langs->trans('AccountancyJournal') . ': ' . $this->accountancy_journal; + $label .= '
        '.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); + $label .= '
        '.$langs->trans('AccountancyJournal').': '.$this->accountancy_journal; } $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; @@ -1352,9 +1352,9 @@ class Account extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } $linkstart = 'ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); $result .= $linkend; return $result; @@ -1384,13 +1384,13 @@ class Account extends CommonObject */ public function verif() { - require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; $this->error_number = 0; // Call function to check BAN - if (! checkIbanForAccount($this) || ! checkSwiftForAccount($this)) + if (!checkIbanForAccount($this) || !checkSwiftForAccount($this)) { $this->error_number = 12; $this->error_message = 'IBANSWIFTControlError'; @@ -1421,26 +1421,26 @@ class Account extends CommonObject global $mysoc; // We return country code of bank account - if (! empty($this->country_code)) return $this->country_code; + if (!empty($this->country_code)) return $this->country_code; // For backward compatibility, we try to guess country from other information - if (! empty($this->iban)) + if (!empty($this->iban)) { // If IBAN defined, we can know country of account from it if (preg_match("/^([a-zA-Z][a-zA-Z])/i", $this->iban, $reg)) return $reg[1]; } // If this class is linked to a third party - if (! empty($this->socid)) + if (!empty($this->socid)) { - require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; - $company=new Societe($this->db); - $result=$company->fetch($this->socid); - if (! empty($company->country_code)) return $company->country_code; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $company = new Societe($this->db); + $result = $company->fetch($this->socid); + if (!empty($company->country_code)) return $company->country_code; } // We return country code of managed company - if (! empty($mysoc->country_code)) return $mysoc->country_code; + if (!empty($mysoc->country_code)) return $mysoc->country_code; return ''; } @@ -1455,10 +1455,10 @@ class Account extends CommonObject */ public function useDetailedBBAN() { - $country_code=$this->getCountryCode(); + $country_code = $this->getCountryCode(); - if (in_array($country_code, array('FR','ES','GA','IT','NC'))) return 1; // France, Spain, Gabon, ... - Not valid for CH - if (in_array($country_code, array('AU','BE','CA','DE','DK','GR','GB','ID','IE','IR','KR','NL','NZ','UK','US'))) return 2; // Australia, England... + if (in_array($country_code, array('FR', 'ES', 'GA', 'IT', 'NC'))) return 1; // France, Spain, Gabon, ... - Not valid for CH + if (in_array($country_code, array('AU', 'BE', 'CA', 'DE', 'DK', 'GR', 'GB', 'ID', 'IE', 'IR', 'KR', 'NL', 'NZ', 'UK', 'US'))) return 2; // Australia, England... return 0; } @@ -1469,41 +1469,41 @@ class Account extends CommonObject */ public function needIBAN() { - $country_code=$this->getCountryCode(); + $country_code = $this->getCountryCode(); - $country_code_in_EEC=array( - 'AT', // Austria - 'BE', // Belgium - 'BG', // Bulgaria - 'CY', // Cyprus - 'CZ', // Czech republic - 'DE', // Germany - 'DK', // Danemark - 'EE', // Estonia - 'ES', // Spain - 'FI', // Finland - 'FR', // France - 'GB', // United Kingdom - 'GR', // Greece - 'HR', // Croatia - 'NL', // Holland - 'HU', // Hungary - 'IE', // Ireland - 'IM', // Isle of Man - Included in UK - 'IT', // Italy - 'LT', // Lithuania - 'LU', // Luxembourg - 'LV', // Latvia - 'MC', // Monaco - Included in France - 'MT', // Malta + $country_code_in_EEC = array( + 'AT', // Austria + 'BE', // Belgium + 'BG', // Bulgaria + 'CY', // Cyprus + 'CZ', // Czech republic + 'DE', // Germany + 'DK', // Danemark + 'EE', // Estonia + 'ES', // Spain + 'FI', // Finland + 'FR', // France + 'GB', // United Kingdom + 'GR', // Greece + 'HR', // Croatia + 'NL', // Holland + 'HU', // Hungary + 'IE', // Ireland + 'IM', // Isle of Man - Included in UK + 'IT', // Italy + 'LT', // Lithuania + 'LU', // Luxembourg + 'LV', // Latvia + 'MC', // Monaco - Included in France + 'MT', // Malta //'NO', // Norway - 'PL', // Poland - 'PT', // Portugal - 'RO', // Romania - 'SE', // Sweden - 'SK', // Slovakia - 'SI', // Slovenia - 'UK', // United Kingdom + 'PL', // Poland + 'PT', // Portugal + 'RO', // Romania + 'SE', // Sweden + 'SK', // Slovakia + 'SI', // Slovenia + 'UK', // United Kingdom //'CH', // Switzerland - No. Swizerland in not in EEC ); @@ -1541,23 +1541,23 @@ class Account extends CommonObject $detailedBBAN = $this->useDetailedBBAN(); if ($detailedBBAN == 0) { - $fieldarray= array( + $fieldarray = array( 'BankAccountNumber' ); } elseif ($detailedBBAN == 2) { - $fieldarray= array( + $fieldarray = array( 'BankCode', 'BankAccountNumber' ); } else { - $fieldarray=self::getAccountNumberOrder(); + $fieldarray = self::getAccountNumberOrder(); } //if ($this->needIBAN()) { // return always IBAN and BIC (this was old behaviour) if ($includeibanbic) { - $fieldarray[]='IBAN'; - $fieldarray[]='BIC'; + $fieldarray[] = 'IBAN'; + $fieldarray[] = 'BIC'; } //} @@ -1647,7 +1647,7 @@ class AccountLine extends CommonObject /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var DoliDB Database handler. @@ -1657,12 +1657,12 @@ class AccountLine extends CommonObject /** * @var string ID to identify managed object */ - public $element='bank'; + public $element = 'bank'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='bank'; + public $table_element = 'bank'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -1724,10 +1724,10 @@ class AccountLine extends CommonObject */ public $fk_type; - public $rappro; // Is it conciliated - public $num_releve; // If conciliated, what is bank statement - public $num_chq; // Num of cheque - public $bank_chq; // Bank of cheque + public $rappro; // Is it conciliated + public $num_releve; // If conciliated, what is bank statement + public $num_chq; // Num of cheque + public $bank_chq; // Bank of cheque /** * @var int ID of cheque receipt @@ -1739,7 +1739,7 @@ class AccountLine extends CommonObject */ public $fk_account; - public $bank_account_label; // Label of bank account + public $bank_account_label; // Label of bank account /** * Issuer @@ -1773,55 +1773,55 @@ class AccountLine extends CommonObject if (empty($rowid) && empty($ref) && empty($num)) return -1; $sql = "SELECT b.rowid, b.datec, b.datev, b.dateo, b.amount, b.label as label, b.fk_account,"; - $sql.= " b.fk_user_author, b.fk_user_rappro,"; - $sql.= " b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,"; - $sql.= " b.fk_bordereau, b.banque, b.emetteur,"; + $sql .= " b.fk_user_author, b.fk_user_rappro,"; + $sql .= " b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,"; + $sql .= " b.fk_bordereau, b.banque, b.emetteur,"; //$sql.= " b.author"; // Is this used ? - $sql.= " ba.ref as bank_account_ref, ba.label as bank_account_label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; - $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($num) $sql.= " AND b.num_chq='".$this->db->escape($num)."'"; - elseif ($ref) $sql.= " AND b.rowid='".$this->db->escape($ref)."'"; - else $sql.= " AND b.rowid=".$rowid; + $sql .= " ba.ref as bank_account_ref, ba.label as bank_account_label"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b,"; + $sql .= " ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if ($num) $sql .= " AND b.num_chq='".$this->db->escape($num)."'"; + elseif ($ref) $sql .= " AND b.rowid='".$this->db->escape($ref)."'"; + else $sql .= " AND b.rowid=".$rowid; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $ret=0; + $ret = 0; $obj = $this->db->fetch_object($result); if ($obj) { - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->rowid = $obj->rowid; - $this->ref = $obj->rowid; + $this->ref = $obj->rowid; $this->datec = $obj->datec; $this->datev = $obj->datev; $this->dateo = $obj->dateo; - $this->amount = $obj->amount; + $this->amount = $obj->amount; $this->label = $obj->label; $this->note = $obj->note; $this->fk_user_author = $obj->fk_user_author; $this->fk_user_rappro = $obj->fk_user_rappro; - $this->fk_type = $obj->fk_type; // Type of transaction - $this->rappro = $obj->rappro; - $this->num_releve = $obj->num_releve; + $this->fk_type = $obj->fk_type; // Type of transaction + $this->rappro = $obj->rappro; + $this->num_releve = $obj->num_releve; - $this->num_chq = $obj->num_chq; - $this->bank_chq = $obj->banque; - $this->fk_bordereau = $obj->fk_bordereau; + $this->num_chq = $obj->num_chq; + $this->bank_chq = $obj->banque; + $this->fk_bordereau = $obj->fk_bordereau; - $this->fk_account = $obj->fk_account; + $this->fk_account = $obj->fk_account; $this->bank_account_ref = $obj->bank_account_ref; $this->bank_account_label = $obj->bank_account_label; - $ret=1; + $ret = 1; } $this->db->free($result); return $ret; @@ -1858,7 +1858,7 @@ class AccountLine extends CommonObject $sql .= ", '".$this->db->idate($this->datev)."'"; $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", ".price2num($this->amount); - $sql .= ", ".($this->fk_user_author > 0 ? $this->fk_user_author :"null"); + $sql .= ", ".($this->fk_user_author > 0 ? $this->fk_user_author : "null"); $sql .= ", ".($this->num_chq ? "'".$this->db->escape($this->num_chq)."'" : "null"); $sql .= ", '".$this->db->escape($this->fk_account)."'"; $sql .= ", '".$this->db->escape($this->fk_type)."'"; @@ -1889,19 +1889,19 @@ class AccountLine extends CommonObject */ public function delete(User $user = null) { - $nbko=0; + $nbko = 0; if ($this->rappro) { // Protection to avoid any delete of consolidated lines - $this->error="ErrorDeleteNotPossibleLineIsConsolidated"; + $this->error = "ErrorDeleteNotPossibleLineIsConsolidated"; return -1; } $this->db->begin(); // Delete urls - $result=$this->delete_urls($user); + $result = $this->delete_urls($user); if ($result < 0) { $nbko++; @@ -1910,14 +1910,14 @@ class AccountLine extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".(int) $this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) $nbko++; + if (!$result) $nbko++; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".(int) $this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) $nbko++; + if (!$result) $nbko++; - if (! $nbko) + if (!$nbko) { $this->db->commit(); return 1; @@ -1940,12 +1940,12 @@ class AccountLine extends CommonObject public function delete_urls(User $user = null) { // phpcs:enable - $nbko=0; + $nbko = 0; if ($this->rappro) { // Protection to avoid any delete of consolidated lines - $this->error="ErrorDeleteNotPossibleLineIsConsolidated"; + $this->error = "ErrorDeleteNotPossibleLineIsConsolidated"; return -1; } @@ -1954,9 +1954,9 @@ class AccountLine extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".(int) $this->rowid; dol_syslog(get_class($this)."::delete_urls", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) $nbko++; + if (!$result) $nbko++; - if (! $nbko) + if (!$nbko) { $this->db->commit(); return 1; @@ -1981,10 +1981,10 @@ class AccountLine extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " amount = ".price2num($this->amount).","; - $sql.= " datev='".$this->db->idate($this->datev)."',"; - $sql.= " dateo='".$this->db->idate($this->dateo)."'"; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " amount = ".price2num($this->amount).","; + $sql .= " datev='".$this->db->idate($this->datev)."',"; + $sql .= " dateo='".$this->db->idate($this->dateo)."'"; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1996,7 +1996,7 @@ class AccountLine extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2014,39 +2014,39 @@ class AccountLine extends CommonObject public function update_conciliation(User $user, $cat, $conciliated = 1) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $this->db->begin(); // Check statement field - if (! empty($conf->global->BANK_STATEMENT_REGEX_RULE)) + if (!empty($conf->global->BANK_STATEMENT_REGEX_RULE)) { - if (! preg_match('/'.$conf->global->BANK_STATEMENT_REGEX_RULE.'/', $this->num_releve)) + if (!preg_match('/'.$conf->global->BANK_STATEMENT_REGEX_RULE.'/', $this->num_releve)) { - $this->errors[]=$langs->trans("ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE); + $this->errors[] = $langs->trans("ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE); return -1; } } $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " rappro = ".$conciliated; - $sql.= ", num_releve = '".$this->db->escape($this->num_releve)."'"; - if ($conciliated) $sql.= ", fk_user_rappro = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " rappro = ".$conciliated; + $sql .= ", num_releve = '".$this->db->escape($this->num_releve)."'"; + if ($conciliated) $sql .= ", fk_user_rappro = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_conciliation", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - if (! empty($cat)) + if (!empty($cat)) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; - $sql.= "lineid"; - $sql.= ", fk_categ"; - $sql.= ") VALUES ("; - $sql.= $this->id; - $sql.= ", ".$cat; - $sql.= ")"; + $sql .= "lineid"; + $sql .= ", fk_categ"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", ".$cat; + $sql .= ")"; dol_syslog(get_class($this)."::update_conciliation", LOG_DEBUG); $this->db->query($sql); @@ -2054,7 +2054,7 @@ class AccountLine extends CommonObject // No error check. Can fail if category already affected } - $this->rappro=1; + $this->rappro = 1; $this->db->commit(); return 1; @@ -2082,12 +2082,12 @@ class AccountLine extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - $newdate=$this->db->jdate($obj->datev)+(3600*24*$sign); + $obj = $this->db->fetch_object($resql); + $newdate = $this->db->jdate($obj->datev) + (3600 * 24 * $sign); $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " datev = '".$this->db->idate($newdate)."'"; - $sql.= " WHERE rowid = ".$rowid; + $sql .= " datev = '".$this->db->idate($newdate)."'"; + $sql .= " WHERE rowid = ".$rowid; $result = $this->db->query($sql); if ($result) @@ -2149,12 +2149,12 @@ class AccountLine extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - $newdate=$this->db->jdate($obj->dateo)+(3600*24*$sign); + $obj = $this->db->fetch_object($resql); + $newdate = $this->db->jdate($obj->dateo) + (3600 * 24 * $sign); $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " dateo = '".$this->db->idate($newdate)."'"; - $sql.= " WHERE rowid = ".$rowid; + $sql .= " dateo = '".$this->db->idate($newdate)."'"; + $sql .= " WHERE rowid = ".$rowid; $result = $this->db->query($sql); if ($result) @@ -2210,11 +2210,11 @@ class AccountLine extends CommonObject public function info($id) { $sql = 'SELECT b.rowid, b.datec, b.tms as datem,'; - $sql.= ' b.fk_user_author, b.fk_user_rappro'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'bank as b'; - $sql.= ' WHERE b.rowid = '.$id; + $sql .= ' b.fk_user_author, b.fk_user_rappro'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'bank as b'; + $sql .= ' WHERE b.rowid = '.$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -2226,7 +2226,7 @@ class AccountLine extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_rappro) { @@ -2261,32 +2261,32 @@ class AccountLine extends CommonObject { global $langs; - $result=''; - $label=$langs->trans("ShowTransaction").': '.$this->rowid; + $result = ''; + $label = $langs->trans("ShowTransaction").': '.$this->rowid; $linkstart = ''; - $linkend=''; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'account'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.=($this->ref?$this->ref:$this->rowid); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'account'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($this->ref ? $this->ref : $this->rowid); $result .= $linkend; - if ($option == 'showall' || $option == 'showconciliated') $result.=' ('; + if ($option == 'showall' || $option == 'showconciliated') $result .= ' ('; if ($option == 'showall') { - $result.=$langs->trans("BankAccount").': '; - $accountstatic=new Account($this->db); - $accountstatic->id=$this->fk_account; - $accountstatic->ref=$this->bank_account_ref; - $accountstatic->label=$this->bank_account_label; - $result.=$accountstatic->getNomUrl(0).', '; + $result .= $langs->trans("BankAccount").': '; + $accountstatic = new Account($this->db); + $accountstatic->id = $this->fk_account; + $accountstatic->ref = $this->bank_account_ref; + $accountstatic->label = $this->bank_account_label; + $result .= $accountstatic->getNomUrl(0).', '; } if ($option == 'showall' || $option == 'showconciliated') { - $result.=$langs->trans("BankLineConciliated").': '; - $result.=yn($this->rappro); + $result .= $langs->trans("BankLineConciliated").': '; + $result .= yn($this->rappro); } - if ($option == 'showall' || $option == 'showconciliated') $result.=')'; + if ($option == 'showall' || $option == 'showconciliated') $result .= ')'; return $result; } diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index a58d7a7c6ea..47b251b788b 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -63,18 +63,18 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { $db->begin(); - $datev=dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); - $datep=dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); + $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); + $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); - $object->accountid=GETPOST("accountid"); - $object->paymenttype=GETPOST("paiementtype"); - $object->datev=$datev; - $object->datep=$datep; - $object->amount=price2num(GETPOST("amount")); - $object->label=GETPOST("label"); - $object->ltt=$lttype; + $object->accountid = GETPOST("accountid"); + $object->paymenttype = GETPOST("paiementtype"); + $object->datev = $datev; + $object->datep = $datep; + $object->amount = price2num(GETPOST("amount")); + $object->label = GETPOST("label"); + $object->ltt = $lttype; - $ret=$object->addPayment($user); + $ret = $object->addPayment($user); if ($ret > 0) { $db->commit(); @@ -85,27 +85,27 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); - $_GET["action"]="create"; + $_GET["action"] = "create"; } } //delete payment of localtax if ($action == 'delete') { - $result=$object->fetch($id); + $result = $object->fetch($id); if ($object->rappro == 0) { $db->begin(); - $ret=$object->delete($user); + $ret = $object->delete($user); if ($ret > 0) { if ($object->fk_bank) { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); - if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + $accountline = new AccountLine($db); + $result = $accountline->fetch($object->fk_bank); + if ($result > 0) $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) } if ($result >= 0) @@ -116,7 +116,7 @@ if ($action == 'delete') } else { - $object->error=$accountline->error; + $object->error = $accountline->error; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } @@ -129,7 +129,7 @@ if ($action == 'delete') } else { - $mesg='Error try do delete a line linked to a conciliated bank transaction'; + $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; setEventMessages($mesg, null, 'errors'); } } @@ -151,13 +151,13 @@ if ($id) $form = new Form($db); -$title=$langs->trans("LT".$object->ltt) . " - " . $langs->trans("Card"); -$help_url=''; +$title = $langs->trans("LT".$object->ltt)." - ".$langs->trans("Card"); +$help_url = ''; llxHeader("", $title, $helpurl); if ($action == 'create') { - print load_fiche_titre($langs->transcountry($lttype==2?"newLT2Payment":"newLT1Payment", $mysoc->country_code)); + print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); print ''."\n"; print ''; @@ -178,15 +178,15 @@ if ($action == 'create') print ''; // Label - print ''; + print ''; // Amount print ''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''; print ''."\n"; } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
        '.$langs->trans('Prefix').''.$object->prefix_comm.'
        '; print $form->selectyesno("TAKEPOS_BAR_RESTAURANT", $conf->global->TAKEPOS_BAR_RESTAURANT, 1); print "
        '; print $langs->trans("OrderPrinters").' ('.$langs->trans("Setup").')'; print ''; @@ -291,7 +291,7 @@ print ''.$langs->trans("URL").'
        '.$langs->trans("DolistorePosCategory").''.$url.''.$langs->trans("URL").'
        TakePOS original developers'.$url.'
        '; + if ($nbbyrow) print ''; print ''; // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine if ($obj['photo_vignette']) { - $filename=$obj['photo_vignette']; + $filename = $obj['photo_vignette']; } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } // Nom affiche - $viewfilename=$obj['photo']; + $viewfilename = $obj['photo']; // Taille de l'image $object->get_image_size($dir.$filename); @@ -274,7 +274,7 @@ if ($object->id) // Ferme tableau while ($nbphoto % $nbbyrow) { - print '  
        '.$langs->trans("Label").'transcountry(($lttype==2?"LT2Payment":"LT1Payment"), $mysoc->country_code)).'">
        '.$langs->trans("Label").'transcountry(($lttype == 2 ? "LT2Payment" : "LT1Payment"), $mysoc->country_code)).'">
        '.$langs->trans("Amount").'
        '.$langs->trans("Account").''; - $form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 1); // Affiche liste des comptes courant + $form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 1); // Affiche liste des comptes courant print '
        '.$langs->trans("PaymentMode").''; @@ -200,8 +200,8 @@ if ($action == 'create') print '
        '; @@ -254,11 +254,11 @@ if ($id) print '
        '.$langs->trans("Amount").''.price($object->amount).'
        '; diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index bb57e796ef6..ebf87b91693 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -46,9 +46,9 @@ if ($user->socid > 0) * Actions */ -if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes')) +if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes')) { - $error=0; + $error = 0; if ($_POST["cancel"]) { @@ -59,7 +59,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - if (! $_POST["paiementtype"] > 0) + if (!$_POST["paiementtype"] > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; @@ -71,14 +71,14 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes $error++; $action = 'create'; } - if (! empty($conf->banque->enabled) && ! ($_POST["accountid"] > 0)) + if (!empty($conf->banque->enabled) && !($_POST["accountid"] > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); $error++; $action = 'create'; } - if (! $error) + if (!$error) { $paymentid = 0; @@ -96,10 +96,10 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes { $error++; setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors'); - $action='create'; + $action = 'create'; } - if (! $error) + if (!$error) { $db->begin(); @@ -107,34 +107,34 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes $paiement = new PaymentSocialContribution($db); $paiement->chid = $chid; $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Tableau de montant + $paiement->amounts = $amounts; // Tableau de montant $paiement->paiementtype = $_POST["paiementtype"]; $paiement->num_paiement = $_POST["num_paiement"]; $paiement->note = $_POST["note"]; - if (! $error) + if (!$error) { - $paymentid = $paiement->create($user, (GETPOST('closepaidcontrib')=='on'?1:0)); + $paymentid = $paiement->create($user, (GETPOST('closepaidcontrib') == 'on' ? 1 : 0)); if ($paymentid < 0) { $error++; setEventMessages($paiement->error, null, 'errors'); - $action='create'; + $action = 'create'; } } - if (! $error) + if (!$error) { - $result=$paiement->addPaymentToBank($user, 'payment_sc', '(SocialContributionPayment)', GETPOST('accountid', 'int'), '', ''); - if (! ($result > 0)) + $result = $paiement->addPaymentToBank($user, 'payment_sc', '(SocialContributionPayment)', GETPOST('accountid', 'int'), '', ''); + if (!($result > 0)) { $error++; setEventMessages($paiement->error, null, 'errors'); - $action='create'; + $action = 'create'; } } - if (! $error) + if (!$error) { $db->commit(); $loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid; @@ -156,7 +156,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes llxHeader(); -$form=new Form($db); +$form = new Form($db); // Formulaire de creation d'un paiement de charge @@ -209,12 +209,12 @@ if ($action == 'create') print ''.$langs->trans("Amount")."".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'';*/ $sql = "SELECT sum(p.amount) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; - $sql.= " WHERE p.fk_charge = ".$chid; + $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; + $sql .= " WHERE p.fk_charge = ".$chid; $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $sumpaid = $obj->total; $db->free(); } @@ -223,20 +223,20 @@ if ($action == 'create') print ''.$langs->trans("Date").''; $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0; + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : 0; print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1); print ""; print ''; print ''.$langs->trans("PaymentMode").''; - $form->select_types_paiements(isset($_POST["paiementtype"])?$_POST["paiementtype"]:$charge->paiementtype, "paiementtype"); + $form->select_types_paiements(isset($_POST["paiementtype"]) ? $_POST["paiementtype"] : $charge->paiementtype, "paiementtype"); print "\n"; print ''; print ''; print ''.$langs->trans('AccountToDebit').''; print ''; - $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '', 1); // Show opend bank account list + $form->select_comptes(isset($_POST["accountid"]) ? $_POST["accountid"] : $charge->accountid, "accountid", 0, '', 1); // Show opend bank account list print ''; // Number @@ -270,8 +270,8 @@ if ($action == 'create') print ''.$langs->trans("Amount").''; print "\n"; - $total=0; - $totalrecu=0; + $total = 0; + $totalrecu = 0; while ($i < $num) { @@ -301,7 +301,7 @@ if ($action == 'create') $nameRemain = "remain_".$objp->id; if (!empty($conf->use_javascript_ajax)) print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'"); - $remaintopay=$objp->amount - $sumpaid; + $remaintopay = $objp->amount - $sumpaid; print ''; print ''; } @@ -312,9 +312,9 @@ if ($action == 'create') print ""; print "\n"; - $total+=$objp->total; - $total_ttc+=$objp->total_ttc; - $totalrecu+=$objp->am; + $total += $objp->total; + $total_ttc += $objp->total_ttc; + $totalrecu += $objp->am; $i++; } if ($i > 1) diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 4fb2f27b53f..a5279ecbeae 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -34,12 +34,12 @@ class PaymentSocialContribution extends CommonObject /** * @var string ID to identify managed object */ - public $element='paiementcharge'; + public $element = 'paiementcharge'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='paiementcharge'; + public $table_element = 'paiementcharge'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -51,9 +51,9 @@ class PaymentSocialContribution extends CommonObject */ public $fk_charge; - public $datec=''; - public $tms=''; - public $datep=''; + public $datec = ''; + public $tms = ''; + public $datep = ''; /** * @deprecated @@ -61,8 +61,8 @@ class PaymentSocialContribution extends CommonObject */ public $total; - public $amount; // Total amount of payment - public $amounts=array(); // Array of amounts + public $amount; // Total amount of payment + public $amounts = array(); // Array of amounts /** * @var int ID @@ -108,28 +108,28 @@ class PaymentSocialContribution extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); dol_syslog(get_class($this)."::create", LOG_DEBUG); // Validate parametres - if (! $this->datepaye) + if (!$this->datepaye) { - $this->error='ErrorBadValueForParameterCreatePaymentSocialContrib'; + $this->error = 'ErrorBadValueForParameterCreatePaymentSocialContrib'; return -1; } // Clean parameters - if (isset($this->fk_charge)) $this->fk_charge= (int) $this->fk_charge; - if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepaiement)) $this->fk_typepaiement= (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement); - if (isset($this->note)) $this->note=trim($this->note); - if (isset($this->fk_bank)) $this->fk_bank= (int) $this->fk_bank; - if (isset($this->fk_user_creat)) $this->fk_user_creat= (int) $this->fk_user_creat; - if (isset($this->fk_user_modif)) $this->fk_user_modif= (int) $this->fk_user_modif; + if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge; + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; + if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); + if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; + if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; + if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; $totalamount = 0; foreach ($this->amounts as $key => $value) // How payment is dispatch @@ -149,14 +149,14 @@ class PaymentSocialContribution extends CommonObject if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,"; - $sql.= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; - $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->idate($this->datepaye)."',"; - $sql.= " ".$totalamount.","; - $sql.= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.","; - $sql.= " 0)"; + $sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; + $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->idate($this->datepaye)."',"; + $sql .= " ".$totalamount.","; + $sql .= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.","; + $sql .= " 0)"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementcharge"); @@ -172,18 +172,18 @@ class PaymentSocialContribution extends CommonObject // If we want to closed payed invoices if ($closepaidcontrib) { - $contrib=new ChargeSociales($this->db); + $contrib = new ChargeSociales($this->db); $contrib->fetch($contribid); $paiement = $contrib->getSommePaiement(); //$creditnotes=$contrib->getSumCreditNotesUsed(); - $creditnotes=0; + $creditnotes = 0; //$deposits=$contrib->getSumDepositsUsed(); - $deposits=0; - $alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT'); - $remaintopay=price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); + $deposits = 0; + $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); + $remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); if ($remaintopay == 0) { - $result=$contrib->set_paid($user); + $result = $contrib->set_paid($user); } else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); } @@ -197,18 +197,18 @@ class PaymentSocialContribution extends CommonObject } $result = $this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE', $user); - if($result < 0) $error++; + if ($result < 0) $error++; - if ($totalamount != 0 && ! $error) + if ($totalamount != 0 && !$error) { - $this->amount=$totalamount; - $this->total=$totalamount; // deprecated + $this->amount = $totalamount; + $this->total = $totalamount; // deprecated $this->db->commit(); return $this->id; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -278,7 +278,7 @@ class PaymentSocialContribution extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -294,18 +294,18 @@ class PaymentSocialContribution extends CommonObject public function update($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->fk_charge)) $this->fk_charge= (int) $this->fk_charge; - if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepaiement)) $this->fk_typepaiement= (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement); - if (isset($this->note)) $this->note=trim($this->note); - if (isset($this->fk_bank)) $this->fk_bank= (int) $this->fk_bank; - if (isset($this->fk_user_creat)) $this->fk_user_creat= (int) $this->fk_user_creat; - if (isset($this->fk_user_modif)) $this->fk_user_modif= (int) $this->fk_user_modif; + if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge; + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; + if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); + if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; + if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; + if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; @@ -315,26 +315,26 @@ class PaymentSocialContribution extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET"; - $sql.= " fk_charge=".(isset($this->fk_charge)?$this->fk_charge:"null").","; - $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; - $sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; - $sql.= " amount=".(isset($this->amount)?$this->amount:"null").","; - $sql.= " fk_typepaiement=".(isset($this->fk_typepaiement)?$this->fk_typepaiement:"null").","; - $sql.= " num_paiement=".(isset($this->num_paiement)?"'".$this->db->escape($this->num_paiement)."'":"null").","; - $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; - $sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").","; - $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").","; - $sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null").""; + $sql .= " fk_charge=".(isset($this->fk_charge) ? $this->fk_charge : "null").","; + $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; + $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; + $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").","; + $sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").","; + $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; + $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; + $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } //if (! $error) //{ @@ -355,13 +355,13 @@ class PaymentSocialContribution extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -381,7 +381,7 @@ class PaymentSocialContribution extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; dol_syslog(get_class($this)."::delete"); @@ -392,20 +392,20 @@ class PaymentSocialContribution extends CommonObject $accline = new AccountLine($this->db); $accline->fetch($this->bank_line); $result = $accline->delete(); - if($result < 0) { + if ($result < 0) { $this->errors[] = $accline->error; $error++; } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } //if (! $error) @@ -427,13 +427,13 @@ class PaymentSocialContribution extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -453,35 +453,35 @@ class PaymentSocialContribution extends CommonObject */ public function createFromClone(User $user, $fromid) { - $error=0; + $error = 0; - $object=new PaymentSocialContribution($this->db); + $object = new PaymentSocialContribution($this->db); $this->db->begin(); // Load source object $object->fetch($fromid); - $object->id=0; - $object->statut=0; + $object->id = 0; + $object->statut = 0; // Clear fields // ... // Create clone $object->context['createfromclone'] = 'createfromclone'; - $result=$object->create($user); + $result = $object->create($user); // Other options if ($result < 0) { - $this->error=$object->error; + $this->error = $object->error; $error++; } unset($object->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $object->id; @@ -503,19 +503,19 @@ class PaymentSocialContribution extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->fk_charge=''; - $this->datec=''; - $this->tms=''; - $this->datep=''; - $this->amount=''; - $this->fk_typepaiement=''; - $this->num_paiement=''; - $this->note=''; - $this->fk_bank=''; - $this->fk_user_creat=''; - $this->fk_user_modif=''; + $this->fk_charge = ''; + $this->datec = ''; + $this->tms = ''; + $this->datep = ''; + $this->amount = ''; + $this->fk_typepaiement = ''; + $this->num_paiement = ''; + $this->note = ''; + $this->fk_bank = ''; + $this->fk_user_creat = ''; + $this->fk_user_modif = ''; } @@ -535,22 +535,22 @@ class PaymentSocialContribution extends CommonObject { global $conf; - $error=0; + $error = 0; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); $acc->fetch($accountid); - $total=$this->total; - if ($mode == 'payment_sc') $total=-$total; + $total = $this->total; + if ($mode == 'payment_sc') $total = -$total; // Insert payment into llx_bank $bank_line_id = $acc->addline( $this->datepaye, - $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") + $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") $label, $total, $this->num_paiement, @@ -564,7 +564,7 @@ class PaymentSocialContribution extends CommonObject // On connait ainsi le paiement qui a genere l'ecriture bancaire if ($bank_line_id > 0) { - $result=$this->update_fk_bank($bank_line_id); + $result = $this->update_fk_bank($bank_line_id); if ($result <= 0) { $error++; @@ -572,11 +572,11 @@ class PaymentSocialContribution extends CommonObject } // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction - $url=''; - if ($mode == 'payment_sc') $url=DOL_URL_ROOT.'/compta/payment_sc/card.php?id='; + $url = ''; + if ($mode == 'payment_sc') $url = DOL_URL_ROOT.'/compta/payment_sc/card.php?id='; if ($url) { - $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); + $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); if ($result <= 0) { $error++; @@ -635,7 +635,7 @@ class PaymentSocialContribution extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return 0; } } @@ -663,7 +663,7 @@ class PaymentSocialContribution extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage $langs->load('compta'); /*if ($mode == 0) @@ -715,18 +715,18 @@ class PaymentSocialContribution extends CommonObject { global $langs; - $result=''; + $result = ''; - if (empty($this->ref)) $this->ref=$this->lib; + if (empty($this->ref)) $this->ref = $this->lib; $label = $langs->trans("ShowPayment").': '.$this->ref; if (!empty($this->id)) { $link = ''; - $linkend=''; + $linkend = ''; - if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref, $maxlen):$this->ref).$linkend; + if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend; } return $result; diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index ee9dc5352c1..79eb6f9ab8e 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -33,9 +33,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_goodcustomers extends ModeleBoxes { - public $boxcode="goodcustomers"; - public $boximg="object_company"; - public $boxlabel="BoxGoodCustomers"; + public $boxcode = "goodcustomers"; + public $boximg = "object_company"; + public $boxlabel = "BoxGoodCustomers"; public $depends = array("societe"); /** @@ -62,10 +62,10 @@ class box_goodcustomers extends ModeleBoxes $this->db = $db; // disable box for such cases - if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option - if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database + if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option + if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled = 0; // not enabled by default. Very slow on large database - $this->hidden = ! ($user->rights->societe->lire); + $this->hidden = !($user->rights->societe->lire); } /** @@ -79,23 +79,23 @@ class box_goodcustomers extends ModeleBoxes global $user, $langs, $conf; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic=new Societe($this->db); + $thirdpartystatic = new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; - $sql.= " count(*) as nbfact, sum(". $this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; - $sql.= ' AND s.rowid = f.fk_soc'; - $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; - $sql.= $this->db->order("nbfact", "DESC"); - $sql.= $this->db->plimit($max, 0); + $sql .= " count(*) as nbfact, sum(".$this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + $sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; + $sql .= ' AND s.rowid = f.fk_soc'; + $sql .= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; + $sql .= $this->db->order("nbfact", "DESC"); + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); @@ -107,7 +107,7 @@ class box_goodcustomers extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->rowid; $thirdpartystatic->name = $objp->name; $thirdpartystatic->code_client = $objp->code_client; @@ -131,7 +131,7 @@ class box_goodcustomers extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'') + 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') ); $this->info_box_contents[$line][] = array( @@ -142,7 +142,7 @@ class box_goodcustomers extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedCustomers")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedCustomers")); $this->db->free($result); } diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 1039ea74385..193bcdae2d6 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; */ class box_task extends ModeleBoxes { - public $boxcode="projettask"; - public $boximg="object_projecttask"; + public $boxcode = "projettask"; + public $boximg = "object_projecttask"; public $boxlabel; public $depends = array("projet"); @@ -42,7 +42,7 @@ class box_task extends ModeleBoxes public $db; public $param; - public $enabled = 1; // enable because fixed ;-). + public $enabled = 1; // enable because fixed ;-). public $info_box_head = array(); public $info_box_contents = array(); @@ -61,10 +61,10 @@ class box_task extends ModeleBoxes // Load translation files required by the page $langs->loadLangs(array('boxes', 'projects')); - $this->boxlabel="Tasks"; + $this->boxlabel = "Tasks"; $this->db = $db; - $this->hidden = ! ($user->rights->projet->lire); + $this->hidden = !($user->rights->projet->lire); } /** @@ -77,32 +77,32 @@ class box_task extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT."/projet/class/task.class.php"; include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"; $projectstatic = new Project($this->db); - $taskstatic=new Task($this->db); - $form= new Form($this->db); - $cookie_name='boxfilter_task'; - $boxcontent=''; + $taskstatic = new Task($this->db); + $form = new Form($this->db); + $cookie_name = 'boxfilter_task'; + $boxcontent = ''; $textHead = $langs->trans("CurentlyOpenedTasks"); - $filterValue='all'; - if(in_array(GETPOST($cookie_name), array('all','im_project_contact','im_task_contact'))){ + $filterValue = 'all'; + if (in_array(GETPOST($cookie_name), array('all', 'im_project_contact', 'im_task_contact'))) { $filterValue = GETPOST($cookie_name); } - elseif(!empty($_COOKIE[$cookie_name])){ + elseif (!empty($_COOKIE[$cookie_name])) { $filterValue = $_COOKIE[$cookie_name]; } - if($filterValue == 'im_task_contact'){ - $textHead.= ' : '.$langs->trans("WhichIamLinkedTo"); + if ($filterValue == 'im_task_contact') { + $textHead .= ' : '.$langs->trans("WhichIamLinkedTo"); } - elseif($filterValue == 'im_project_contact'){ - $textHead.= ' : '.$langs->trans("WhichIamLinkedToProject"); + elseif ($filterValue == 'im_project_contact') { + $textHead .= ' : '.$langs->trans("WhichIamLinkedToProject"); } @@ -135,7 +135,7 @@ class box_task extends ModeleBoxes }); '; // set cookie by js - $boxcontent.=''; + $boxcontent .= ''; $this->info_box_contents[0][] = array( 'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"', 'td' => 'class="nohover"', @@ -144,43 +144,43 @@ class box_task extends ModeleBoxes $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; - $sql.= ", p.rowid project_id, p.ref project_ref, p.title project_title"; + $sql .= ", p.rowid project_id, p.ref project_ref, p.title project_title"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; - $sql.= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; + $sql .= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)"; - if($filterValue === 'im_task_contact') { - $sql .= " JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = '" . $user->id . "' )"; - $sql .= " JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )"; + if ($filterValue === 'im_task_contact') { + $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = '".$user->id."' )"; + $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )"; } - elseif($filterValue === 'im_project_contact') { - $sql .= " JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = '" . $user->id . "' )"; - $sql .= " JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )"; + elseif ($filterValue === 'im_project_contact') { + $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = '".$user->id."' )"; + $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )"; } - $sql.= " WHERE "; - $sql.= " pt.entity = ".$conf->entity; - $sql.= " AND p.fk_statut = ".Project::STATUS_VALIDATED; - $sql.= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed - $sql.= " AND p.usage_task = 1 "; + $sql .= " WHERE "; + $sql .= " pt.entity = ".$conf->entity; + $sql .= " AND p.fk_statut = ".Project::STATUS_VALIDATED; + $sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed + $sql .= " AND p.usage_task = 1 "; - $sql.= " ORDER BY pt.datee ASC, pt.dateo ASC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " ORDER BY pt.datee ASC, pt.dateo ASC"; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); $i = 1; if ($result) { $num = $this->db->num_rows($result); while ($objp = $this->db->fetch_object($result)) { - $taskstatic->id=$objp->rowid; - $taskstatic->ref=$objp->ref; - $taskstatic->label=$objp->label; + $taskstatic->id = $objp->rowid; + $taskstatic->ref = $objp->ref; + $taskstatic->label = $objp->label; $taskstatic->progress = $objp->progress; $taskstatic->fk_statut = $objp->fk_statut; $taskstatic->date_end = $objp->datee; - $taskstatic->planned_workload= $objp->planned_workload; - $taskstatic->duration_effective= $objp->duration_effective; + $taskstatic->planned_workload = $objp->planned_workload; + $taskstatic->duration_effective = $objp->duration_effective; $projectstatic->id = $objp->project_id; $projectstatic->ref = $objp->project_ref; diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index cdc5b283c44..1a844f86f2b 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -74,9 +74,9 @@ class Link extends CommonObject */ public function create($user = '') { - global $langs,$conf; + global $langs, $conf; - $error=0; + $error = 0; $langs->load("errors"); // Clean parameters if (empty($this->label)) { @@ -99,34 +99,34 @@ class Link extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."links (entity, datea, url, label, objecttype, objectid)"; $sql .= " VALUES ('".$conf->entity."', '".$this->db->idate($this->datea)."'"; - $sql .= ", '" . $this->db->escape($this->url) . "'"; - $sql .= ", '" . $this->db->escape($this->label) . "'"; - $sql .= ", '" . $this->db->escape($this->objecttype) . "'"; - $sql .= ", " . $this->objectid . ")"; + $sql .= ", '".$this->db->escape($this->url)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->escape($this->objecttype)."'"; + $sql .= ", ".$this->objectid.")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "links"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."links"); if ($this->id > 0) { // Call trigger - $result=$this->call_trigger('LINK_CREATE', $user); + $result = $this->call_trigger('LINK_CREATE', $user); if ($result < 0) $error++; // End call triggers } else { $error++; } - if (! $error) + if (!$error) { - dol_syslog(get_class($this)."::Create success id=" . $this->id); + dol_syslog(get_class($this)."::Create success id=".$this->id); $this->db->commit(); return $this->id; } else { - dol_syslog(get_class($this)."::Create echec update " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::Create echec update ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } @@ -135,13 +135,13 @@ class Link extends CommonObject { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$langs->trans("ErrorCompanyNameAlreadyExists", $this->name); - $result=-1; + $this->error = $langs->trans("ErrorCompanyNameAlreadyExists", $this->name); + $result = -1; } else { - $this->error=$this->db->lasterror(); - $result=-2; + $this->error = $this->db->lasterror(); + $result = -2; } $this->db->rollback(); return $result; @@ -157,13 +157,13 @@ class Link extends CommonObject */ public function update($user = '', $call_trigger = 1) { - global $langs,$conf; + global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("errors"); - $error=0; + $error = 0; - dol_syslog(get_class($this)."::Update id = " . $this->id . " call_trigger = " . $call_trigger); + dol_syslog(get_class($this)."::Update id = ".$this->id." call_trigger = ".$call_trigger); // Check parameters if (empty($this->url)) @@ -180,30 +180,30 @@ class Link extends CommonObject $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "links SET "; - $sql .= "entity = '" . $conf->entity ."'"; - $sql .= ", datea = '" . $this->db->idate(dol_now()) . "'"; - $sql .= ", url = '" . $this->db->escape($this->url) . "'"; - $sql .= ", label = '" . $this->db->escape($this->label) . "'"; - $sql .= ", objecttype = '" . $this->db->escape($this->objecttype) . "'"; - $sql .= ", objectid = " . $this->objectid; - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."links SET "; + $sql .= "entity = '".$conf->entity."'"; + $sql .= ", datea = '".$this->db->idate(dol_now())."'"; + $sql .= ", url = '".$this->db->escape($this->url)."'"; + $sql .= ", label = '".$this->db->escape($this->label)."'"; + $sql .= ", objecttype = '".$this->db->escape($this->objecttype)."'"; + $sql .= ", objectid = ".$this->objectid; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update sql = " .$sql); + dol_syslog(get_class($this)."::update sql = ".$sql); $resql = $this->db->query($sql); if ($resql) { if ($call_trigger) { // Call trigger - $result=$this->call_trigger('LINK_MODIFY', $user); + $result = $this->call_trigger('LINK_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { - dol_syslog(get_class($this) . "::Update success"); + dol_syslog(get_class($this)."::Update success"); $this->db->commit(); return 1; } else { @@ -218,12 +218,12 @@ class Link extends CommonObject { // Doublon $this->error = $langs->trans("ErrorDuplicateField"); - $result = -1; + $result = -1; } else { - $this->error = $langs->trans("Error sql = " . $sql); - $result = -2; + $this->error = $langs->trans("Error sql = ".$sql); + $result = -2; } $this->db->rollback(); return $result; @@ -244,14 +244,14 @@ class Link extends CommonObject { global $conf; - $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links"; - $sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid; - if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE objecttype = '".$objecttype."' AND objectid = ".$objectid; + if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity; if ($sortfield) { if (empty($sortorder)) { $sortorder = "ASC"; } - $sql .= " ORDER BY " . $sortfield . " " . $sortorder; + $sql .= " ORDER BY ".$sortfield." ".$sortorder; } dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); @@ -259,7 +259,7 @@ class Link extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); - dol_syslog(get_class($this)."::fetchAll " . $num . "records", LOG_DEBUG); + dol_syslog(get_class($this)."::fetchAll ".$num."records", LOG_DEBUG); if ($num > 0) { while ($obj = $this->db->fetch_object($resql)) @@ -295,9 +295,9 @@ class Link extends CommonObject { global $conf; - $sql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "links"; - $sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid; - if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE objecttype = '".$objecttype."' AND objectid = ".$objectid; + if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) @@ -322,15 +322,15 @@ class Link extends CommonObject $rowid = $this->id; } - $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links"; - $sql .= " WHERE rowid = " . $rowid; - if($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE rowid = ".$rowid; + if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - if($this->db->num_rows($resql) > 0) + if ($this->db->num_rows($resql) > 0) { $obj = $this->db->fetch_object($resql); @@ -348,7 +348,7 @@ class Link extends CommonObject return 0; } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -367,7 +367,7 @@ class Link extends CommonObject $this->db->begin(); // Call trigger - $result=$this->call_trigger('LINK_DELETE', $user); + $result = $this->call_trigger('LINK_DELETE', $user); if ($result < 0) { $this->db->rollback(); @@ -376,17 +376,17 @@ class Link extends CommonObject // End call triggers // Remove link - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "links"; - $sql.= " WHERE rowid = " . $this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); } - if (! $error) { + if (!$error) { $this->db->commit(); return 1; diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 53f46ccc861..f2b96b2bea0 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -118,27 +118,27 @@ class pdf_merou extends ModelePdfExpedition */ public function __construct($db = 0) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; $this->db = $db; $this->name = "merou"; $this->description = $langs->trans("DocumentModelMerou"); $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; - $this->page_hauteur = round($formatarray['height']/2); - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->page_hauteur = round($formatarray['height'] / 2); + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Display logo + $this->option_logo = 1; // Display logo // Get source company - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -157,13 +157,13 @@ class pdf_merou extends ModelePdfExpedition public function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$conf,$langs,$mysoc,$hookmanager; + global $user, $conf, $langs, $mysoc, $hookmanager; $object->fetch_thirdparty(); - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); @@ -180,31 +180,31 @@ class pdf_merou extends ModelePdfExpedition //Create recipient $idcontact = $object->$origin->getIdContact('external', 'SHIPPING'); $this->destinataire = new Contact($this->db); - if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]); + if (!empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]); //Create deliverer $idcontact = $object->$origin->getIdContact('internal', 'LIVREUR'); $this->livreur = new User($this->db); - if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]); + if (!empty($idcontact[0])) $this->livreur->fetch($idcontact[0]); // Definition of $dir and $file if ($object->specimen) { $dir = $conf->expedition->dir_output."/sending"; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $expref = dol_sanitizeFileName($object->ref); - $dir = $conf->expedition->dir_output . "/sending/" . $expref; - $file = $dir . "/" . $expref . ".pdf"; + $dir = $conf->expedition->dir_output."/sending/".$expref; + $file = $dir."/".$expref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -212,24 +212,24 @@ class pdf_merou extends ModelePdfExpedition if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $nblines = count($object->lines); - $pdf=pdf_getInstance($this->format, 'mm', 'l'); + $pdf = pdf_getInstance($this->format, 'mm', 'l'); $default_font_size = pdf_getPDFFontSize($outputlangs); - $heightforinfotot = 0; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; + $heightforinfotot = 0; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -239,14 +239,14 @@ class pdf_merou extends ModelePdfExpedition } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -256,41 +256,41 @@ class pdf_merou extends ModelePdfExpedition $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment")); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 3); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 52; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); $tab_height = $this->page_hauteur - $tab_top - $heightforfooter; $tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter; // Display notes - if (! empty($object->note_public)) + if (!empty($object->note_public)) { $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1); $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } else { - $height_note=0; + $height_note = 0; } @@ -302,7 +302,7 @@ class pdf_merou extends ModelePdfExpedition $curY = $tab_top + 7; $nexY = $tab_top + 7; - $num=count($object->lines); + $num = count($object->lines); // Loop on each lines for ($i = 0; $i < $num; $i++) { @@ -311,17 +311,17 @@ class pdf_merou extends ModelePdfExpedition $pdf->SetTextColor(0, 0, 0); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); // Description of product line $libelleproduitservice = pdf_writelinedesc($pdf, $object, $i, $outputlangs, 90, 3, 50, $curY, 0, 1); $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $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. + $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) { @@ -332,8 +332,8 @@ class pdf_merou extends ModelePdfExpedition // Check boxes $pdf->SetDrawColor(120, 120, 120); - $pdf->Rect(10+3, $curY, 3, 3); - $pdf->Rect(20+3, $curY, 3, 3); + $pdf->Rect(10 + 3, $curY, 3, 3); + $pdf->Rect(20 + 3, $curY, 3, 3); //Inserting the product reference $pdf->SetXY(30, $curY); @@ -347,16 +347,16 @@ class pdf_merou extends ModelePdfExpedition $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0); // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -373,9 +373,9 @@ class pdf_merou extends ModelePdfExpedition $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -396,12 +396,12 @@ class pdf_merou extends ModelePdfExpedition if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Pagefoot @@ -413,22 +413,22 @@ class pdf_merou extends ModelePdfExpedition $pdf->Output($file, 'F'); // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); @@ -437,13 +437,13 @@ class pdf_merou extends ModelePdfExpedition } else { - $this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $outputlangs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); + $this->error = $outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); return 0; } } @@ -531,20 +531,20 @@ class pdf_merou extends ModelePdfExpedition */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf, $langs,$hookmanager; + global $conf, $langs, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); //Affiche le filigrane brouillon - Print Draft Watermark - if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->SENDING_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK); } - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-100; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; $Xoff = 90; $Yoff = 0; @@ -556,13 +556,13 @@ class pdf_merou extends ModelePdfExpedition //*********************LOGO**************************** $pdf->SetXY(11, 7); - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto) } else { @@ -574,7 +574,7 @@ class pdf_merou extends ModelePdfExpedition } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L'); } @@ -583,9 +583,9 @@ class pdf_merou extends ModelePdfExpedition $pdf->SetXY($Xoff, 7); $pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetTextColor(0, 0, 0); - $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet + $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet //Num Expedition - $Yoff = $Yoff+7; + $Yoff = $Yoff + 7; $Xoff = 142; //$pdf->Rect($Xoff, $Yoff, 85, 8); $pdf->SetXY($Xoff, $Yoff); @@ -594,8 +594,8 @@ class pdf_merou extends ModelePdfExpedition $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R'); //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); - $origin = $object->origin; - $origin_id = $object->origin_id; + $origin = $object->origin; + $origin_id = $object->origin_id; // Add list of linked elements $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager); @@ -603,15 +603,15 @@ class pdf_merou extends ModelePdfExpedition //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); //Definition Location of the Company block $Xoff = 110; - $blSocX=90; - $blSocY=24; - $blSocW=50; - $blSocX2=$blSocW+$blSocX; + $blSocX = 90; + $blSocY = 24; + $blSocW = 50; + $blSocX2 = $blSocW + $blSocX; // Sender name $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', 'B', $default_font_size - 3); - $pdf->SetXY($blSocX, $blSocY+1); + $pdf->SetXY($blSocX, $blSocY + 1); $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); $pdf->SetTextColor(0, 0, 0); @@ -619,54 +619,54 @@ class pdf_merou extends ModelePdfExpedition $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); $pdf->SetFont('', '', $default_font_size - 3); - $pdf->SetXY($blSocX, $blSocY+4); + $pdf->SetXY($blSocX, $blSocY + 4); $pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L'); if ($object->thirdparty->code_client) { - $Yoff+=3; - $posy=$Yoff; + $Yoff += 3; + $posy = $Yoff; $pdf->SetXY(100, $posy); $pdf->SetTextColor(0, 0, 0); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } // Date delivery - $Yoff = $Yoff+7; - $pdf->SetXY($blSocX-80, $blSocY+17); + $Yoff = $Yoff + 7; + $pdf->SetXY($blSocX - 80, $blSocY + 17); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetTextColor(0, 0, 0); - $pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L'); + $pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L'); - $pdf->SetXY($blSocX-80, $blSocY+20); + $pdf->SetXY($blSocX - 80, $blSocY + 20); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetTextColor(0, 0, 0); - $pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, '', 'L'); + $pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L'); // Deliverer - $pdf->SetXY($blSocX-80, $blSocY+23); + $pdf->SetXY($blSocX - 80, $blSocY + 23); $pdf->SetFont('', '', $default_font_size - 3); $pdf->SetTextColor(0, 0, 0); - if (! empty($object->tracking_number)) + if (!empty($object->tracking_number)) { $object->getUrlTrackingStatus($object->tracking_number); - if (! empty($object->tracking_url)) + if (!empty($object->tracking_url)) { if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code=$outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); - $label=''; - $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); + $label = ''; + $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); //var_dump($object->tracking_url != $object->tracking_number);exit; if ($object->tracking_url != $object->tracking_number) { - $label.=" : "; - $label.=$object->tracking_url; + $label .= " : "; + $label .= $object->tracking_url; } $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L'); @@ -681,20 +681,20 @@ class pdf_merou extends ModelePdfExpedition // Shipping company (My Company) $Yoff = $blSocY; - $blExpX=$Xoff-20; - $blW=52; + $blExpX = $Xoff - 20; + $blW = 52; $Ydef = $Yoff; $pdf->Rect($blExpX, $Yoff, $blW, 26); $object->fetch_thirdparty(); // If SHIPPING contact defined on order, we use it - $usecontact=false; - $arrayidcontact=$object->$origin->getIdContact('external', 'SHIPPING'); + $usecontact = false; + $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name @@ -705,19 +705,19 @@ class pdf_merou extends ModelePdfExpedition $thirdparty = $object->thirdparty; } - $carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact))?$object->contact:null), $usecontact, 'targetwithdetails', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'targetwithdetails', $object); - $blDestX=$blExpX+55; - $blW=54; - $Yoff = $Ydef +1; + $blDestX = $blExpX + 55; + $blW = 54; + $Yoff = $Ydef + 1; // Show Recipient frame $pdf->SetFont('', 'B', $default_font_size - 3); - $pdf->SetXY($blDestX, $Yoff-4); + $pdf->SetXY($blDestX, $Yoff - 4); $pdf->MultiCell($blW, 3, $outputlangs->transnoentities("Recipient"), 0, 'L'); - $pdf->Rect($blDestX, $Yoff-1, $blW, 26); + $pdf->Rect($blDestX, $Yoff - 1, $blW, 26); // Show recipient name $pdf->SetFont('', 'B', $default_font_size - 3); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index a79c17b47ca..a398fbf23a4 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -127,7 +127,7 @@ class pdf_azur extends ModelePDFPropales */ public function __construct($db) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Translations $langs->loadLangs(array("main", "bills")); @@ -135,72 +135,72 @@ class pdf_azur extends ModelePDFPropales $this->db = $db; $this->name = "azur"; $this->description = $langs->trans('DocModelAzurDescription'); - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Dimension page $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Display logo - $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - $this->option_modereg = 1; // Display payment mode - $this->option_condreg = 1; // Display payment terms - $this->option_codeproduitservice = 1; // Display product-service code - $this->option_multilang = 1; // Available in several languages - $this->option_escompte = 0; // Displays if there has been a discount - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->option_logo = 1; // Display logo + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 1; // Display payment mode + $this->option_condreg = 1; // Display payment terms + $this->option_codeproduitservice = 1; // Display product-service code + $this->option_multilang = 1; // Available in several languages + $this->option_escompte = 0; // Displays if there has been a discount + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->franchise=!$mysoc->tva_assuj; + $this->franchise = !$mysoc->tva_assuj; // Get source company - $this->emetteur=$mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; - if($conf->global->PRODUCT_USE_UNITS) + $this->posxdesc = $this->marge_gauche + 1; + if ($conf->global->PRODUCT_USE_UNITS) { - $this->posxtva=101; - $this->posxup=118; - $this->posxqty=135; - $this->posxunit=151; + $this->posxtva = 101; + $this->posxup = 118; + $this->posxqty = 135; + $this->posxunit = 151; } else { - $this->posxtva=110; - $this->posxup=126; - $this->posxqty=145; - $this->posxunit=162; + $this->posxtva = 110; + $this->posxup = 126; + $this->posxqty = 145; + $this->posxunit = 162; } - $this->posxdiscount=162; - $this->postotalht=174; - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + $this->posxdiscount = 162; + $this->postotalht = 174; + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup; + $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { - $this->posxpicture-=20; - $this->posxtva-=20; - $this->posxup-=20; - $this->posxqty-=20; - $this->posxunit-=20; - $this->posxdiscount-=20; - $this->postotalht-=20; + $this->posxpicture -= 20; + $this->posxtva -= 20; + $this->posxup -= 20; + $this->posxqty -= 20; + $this->posxunit -= 20; + $this->posxdiscount -= 20; + $this->postotalht -= 20; } - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -218,11 +218,11 @@ class pdf_azur extends ModelePDFPropales public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines; + global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "propal", "products")); @@ -230,32 +230,32 @@ class pdf_azur extends ModelePDFPropales $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); - if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) + $realpatharray = array(); + if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) { $objphoto = new Product($this->db); - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if (empty($object->lines[$i]->fk_product)) continue; $objphoto->fetch($object->lines[$i]->fk_product); //var_dump($objphoto->ref);exit; - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; - $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; + $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; } else { - $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default - $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; // alternative + $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default + $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative } $arephoto = false; foreach ($pdir as $midir) { - if (! $arephoto) + if (!$arephoto) { $dir = $conf->product->dir_output.'/'.$midir; @@ -265,16 +265,16 @@ class pdf_azur extends ModelePDFPropales { if ($obj['photo_vignette']) { - $filename= $obj['photo_vignette']; + $filename = $obj['photo_vignette']; } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } $realpath = $dir.$filename; @@ -283,11 +283,11 @@ class pdf_azur extends ModelePDFPropales } } - if ($realpath && $arephoto) $realpatharray[$i]=$realpath; + if ($realpath && $arephoto) $realpatharray[$i] = $realpath; } } - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; + if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva; if ($conf->propal->multidir_output[$conf->entity]) { @@ -299,20 +299,20 @@ class pdf_azur extends ModelePDFPropales if ($object->specimen) { $dir = $conf->propal->multidir_output[$conf->entity]; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + $dir = $conf->propal->multidir_output[$object->entity]."/".$objectref; + $file = $dir."/".$objectref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -320,19 +320,19 @@ class pdf_azur extends ModelePDFPropales if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Create pdf instance - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -342,14 +342,14 @@ class pdf_azur extends ModelePDFPropales } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -357,12 +357,12 @@ class pdf_azur extends ModelePDFPropales $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Positionne $this->atleastonediscount si on a au moins une remise - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if ($object->lines[$i]->remise_percent) { @@ -372,35 +372,35 @@ class pdf_azur extends ModelePDFPropales if (empty($this->atleastonediscount)) { $delta = ($this->postotalht - $this->posxdiscount); - $this->posxpicture+=$delta; - $this->posxtva+=$delta; - $this->posxup+=$delta; - $this->posxqty+=$delta; - $this->posxunit+=$delta; - $this->posxdiscount+=$delta; + $this->posxpicture += $delta; + $this->posxtva += $delta; + $this->posxup += $delta; + $this->posxqty += $delta; + $this->posxunit += $delta; + $this->posxdiscount += $delta; // post of fields after are not modified, stay at same position } // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $heightforinfotot = 40; // Height reserved to output the info and total part - $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0; - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; + $heightforinfotot = 40; // Height reserved to output the info and total part + $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0; + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90+$top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); + $tab_top = 90 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); // Incoterm if ($conf->incoterm->enabled) @@ -411,58 +411,58 @@ class pdf_azur extends ModelePDFPropales $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } } // Affiche notes - $notetoshow=empty($object->note_public)?'':$object->note_public; - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep if (is_object($object->thirdparty)) { - $salereparray=$object->thirdparty->getSalesRepresentatives($user); - $salerepobj=new User($this->db); + $salereparray = $object->thirdparty->getSalesRepresentatives($user); + $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } - if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0) + if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0) { - $tmpuser=new User($this->db); + $tmpuser = new User($this->db); $tmpuser->fetch($object->user_author_id); - $notetoshow.=$langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs); - if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email; - if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone; + $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs); + if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email; + if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone; } if ($notetoshow) { $tab_top -= 2; - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } $iniY = $tab_top + 7; @@ -473,183 +473,183 @@ class pdf_azur extends ModelePDFPropales for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $imglinesize = array(); + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // If photo too high, we moved completely on new page + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore+1); + $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } if (isset($imglinesize['width']) && isset($imglinesize['height'])) { - $curX = $this->posxpicture-1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $curX = $this->posxpicture - 1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; + $posYAfterImage = $curY + $imglinesize['height']; } // Description of product line - $curX = $this->posxdesc-1; + $curX = $this->posxdesc - 1; $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 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($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak { $pdf->commitTransaction(); } - $posYAfterDescription=$pdf->GetY(); + $posYAfterDescription = $pdf->GetY(); $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $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. + $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 or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxtva-5, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R'); + $pdf->SetXY($this->posxtva - 5, $curY); + $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0, 'R'); } // Unit price before discount $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); + $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0); // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); - $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); // Enough for 6 chars + $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if($conf->global->PRODUCT_USE_UNITS) + if ($conf->global->PRODUCT_USE_UNITS) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); } // Discount on line $pdf->SetXY($this->posxdiscount, $curY); if ($object->lines[$i]->remise_percent) { - $pdf->SetXY($this->posxdiscount-2, $curY); + $pdf->SetXY($this->posxdiscount - 2, $curY); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); - $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); + $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R'); } // Total HT line $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; - else $tvaligne=$object->lines[$i]->total_tva; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; + else $tvaligne = $object->lines[$i]->total_tva; - $localtax1ligne=$object->lines[$i]->total_localtax1; - $localtax2ligne=$object->lines[$i]->total_localtax2; - $localtax1_rate=$object->lines[$i]->localtax1_tx; - $localtax2_rate=$object->lines[$i]->localtax2_tx; - $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; + $localtax1ligne = $object->lines[$i]->total_localtax1; + $localtax2ligne = $object->lines[$i]->total_localtax2; + $localtax1_rate = $object->lines[$i]->localtax1_tx; + $localtax2_rate = $object->lines[$i]->localtax2_tx; + $localtax1_type = $object->lines[$i]->localtax1_type; + $localtax2_type = $object->lines[$i]->localtax2_type; - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; - $vatrate=(string) $object->lines[$i]->tva_tx; + $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined + && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax { - $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); + $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; if ($localtax2_type && $localtax2ligne != 0) - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; + if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; $this->tva[$vatrate] += $tvaligne; - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; + if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -666,10 +666,10 @@ class pdf_azur extends ModelePDFPropales $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -682,7 +682,7 @@ class pdf_azur extends ModelePDFPropales $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -692,19 +692,19 @@ class pdf_azur extends ModelePDFPropales if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; } // Affiche zone infos - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); // Affiche zone versements /* @@ -717,7 +717,7 @@ class pdf_azur extends ModelePDFPropales // Customer signature area if (empty($conf->global->PROPAL_DISABLE_SIGNATURE)) { - $posy=$this->_signature_area($pdf, $object, $posy, $outputlangs); + $posy = $this->_signature_area($pdf, $object, $posy, $outputlangs); } // Pied de page @@ -729,9 +729,9 @@ class pdf_azur extends ModelePDFPropales { require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php'; - $already_merged = array (); + $already_merged = array(); foreach ($object->lines as $line) { - if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) { + if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) { // Find the desire PDF $filetomerge = new Propalmergepdfproduct($this->db); @@ -746,41 +746,41 @@ class pdf_azur extends ModelePDFPropales $product = new Product($this->db); $product->fetch($line->fk_product); - if ($product->entity!=$conf->entity) { - $entity_product_file=$product->entity; + if ($product->entity != $conf->entity) { + $entity_product_file = $product->entity; } else { - $entity_product_file=$conf->entity; + $entity_product_file = $conf->entity; } // If PDF is selected and file is not empty if (count($filetomerge->lines) > 0) { foreach ($filetomerge->lines as $linefile) { - if (! empty($linefile->id) && ! empty($linefile->file_name)) { - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + if (!empty($linefile->id) && !empty($linefile->file_name)) { + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - if (! empty($conf->product->enabled)) { - $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id, 2, 0, 0, $product, 'product') . $product->id ."/photos"; - } elseif (! empty($conf->service->enabled)) { - $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id, 2, 0, 0, $product, 'product') . $product->id ."/photos"; + if (!empty($conf->product->enabled)) { + $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos"; + } elseif (!empty($conf->service->enabled)) { + $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos"; } } else { - if (! empty($conf->product->enabled)) { - $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0, 0, 0, 0, $product, 'product') . dol_sanitizeFileName($product->ref); - } elseif (! empty($conf->service->enabled)) { - $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0, 0, 0, 0, $product, 'product') . dol_sanitizeFileName($product->ref); + if (!empty($conf->product->enabled)) { + $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref); + } elseif (!empty($conf->service->enabled)) { + $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref); } } - dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG); + dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, LOG_DEBUG); - $infile = $filetomerge_dir . '/' . $linefile->file_name; + $infile = $filetomerge_dir.'/'.$linefile->file_name; if (file_exists($infile) && is_readable($infile)) { $pagecount = $pdf->setSourceFile($infile); - for($i = 1; $i <= $pagecount; $i ++) { + for ($i = 1; $i <= $pagecount; $i++) { $tplIdx = $pdf->importPage($i); - if ($tplIdx!==false) { + if ($tplIdx !== false) { $s = $pdf->getTemplatesize($tplIdx); $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); $pdf->useTemplate($tplIdx); @@ -802,31 +802,31 @@ class pdf_azur extends ModelePDFPropales //Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR"); + $this->error = $langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR"); return 0; } } @@ -873,13 +873,13 @@ class pdf_azur extends ModelePDFPropales $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - $posy=$pdf->GetY()+4; + $posy = $pdf->GetY() + 4; } - $posxval=52; + $posxval = 52; // Show shipping date - if (! empty($object->date_livraison)) + if (!empty($object->date_livraison)) { $outputlangs->load("sendings"); $pdf->SetFont('', 'B', $default_font_size - 2); @@ -888,10 +888,10 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $dlp=dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true); + $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true); $pdf->MultiCell(80, 4, $dlp, 0, 'L'); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; } elseif ($object->availability_code || $object->availability) // Show availability conditions { @@ -902,11 +902,11 @@ class pdf_azur extends ModelePDFPropales $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability); - $lib_availability=str_replace('\n', "\n", $lib_availability); + $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability); + $lib_availability = str_replace('\n', "\n", $lib_availability); $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; } // Show payments conditions @@ -919,11 +919,11 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); - $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L'); - $posy=$pdf->GetY()+3; + $posy = $pdf->GetY() + 3; } if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMMODE)) @@ -955,19 +955,19 @@ class pdf_azur extends ModelePDFPropales $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); + $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') { // Si mode reglement non force ou si force a CHQ - if (! empty($conf->global->FACTURE_CHQ_NUMBER)) + if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); if ($conf->global->FACTURE_CHQ_NUMBER > 0) { @@ -977,14 +977,14 @@ class pdf_azur extends ModelePDFPropales $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } if ($conf->global->FACTURE_CHQ_NUMBER == -1) @@ -992,14 +992,14 @@ class pdf_azur extends ModelePDFPropales $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } } @@ -1008,19 +1008,19 @@ class pdf_azur extends ModelePDFPropales // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { - if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) + if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) { - $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account); - if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank + $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); + if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank $account = new Account($this->db); $account->fetch($bankid); - $curx=$this->marge_gauche; - $cury=$posy; + $curx = $this->marge_gauche; + $cury = $posy; - $posy=pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); + $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); - $posy+=2; + $posy += 2; } } } @@ -1043,7 +1043,7 @@ class pdf_azur extends ModelePDFPropales protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $tab2_top = $posy; @@ -1054,32 +1054,32 @@ class pdf_azur extends ModelePDFPropales $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { - $col2x-=20; + $col2x -= 20; } $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - $useborder=0; + $useborder = 0; $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248, 248, 248); $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; - $this->atleastoneratenotnull=0; + $this->atleastoneratenotnull = 0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) + $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) { // Nothing to do } @@ -1152,7 +1152,7 @@ class pdf_azur extends ModelePDFPropales } //} // VAT - foreach($this->tva as $tvakey => $tvaval) + foreach ($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1161,15 +1161,15 @@ class pdf_azur extends ModelePDFPropales $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat.=vatrate($tvakey, 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat .= vatrate($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); @@ -1248,7 +1248,7 @@ class pdf_azur extends ModelePDFPropales $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); @@ -1267,7 +1267,7 @@ class pdf_azur extends ModelePDFPropales $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0); @@ -1292,7 +1292,7 @@ class pdf_azur extends ModelePDFPropales $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); @@ -1324,8 +1324,8 @@ class pdf_azur extends ModelePDFPropales global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1337,30 +1337,30 @@ class pdf_azur extends ModelePDFPropales if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter - $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); } - if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) + if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) { - $pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height); + $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height); if (empty($hidetop)) { //$pdf->SetXY($this->posxpicture-1, $tab_top+1); @@ -1370,30 +1370,30 @@ class pdf_azur extends ModelePDFPropales if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); + $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height); if (empty($hidetop)) { // Not do -3 and +3 instead of -1 -1 to have more space for text 'Sales tax' - $pdf->SetXY($this->posxtva-3, $tab_top+1); - $pdf->MultiCell($this->posxup-$this->posxtva+3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); + $pdf->SetXY($this->posxtva - 3, $tab_top + 1); + $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); } } - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxup-1, $tab_top+1); - $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); + $pdf->SetXY($this->posxup - 1, $tab_top + 1); + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); } - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqty-1, $tab_top+1); - $pdf->MultiCell($this->posxunit-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); + $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if($conf->global->PRODUCT_USE_UNITS) { + if ($conf->global->PRODUCT_USE_UNITS) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); @@ -1402,13 +1402,13 @@ class pdf_azur extends ModelePDFPropales } } - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); + $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height); if (empty($hidetop)) { if ($this->atleastonediscount) { - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); - $pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); + $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); + $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); } } if ($this->atleastonediscount) @@ -1417,7 +1417,7 @@ class pdf_azur extends ModelePDFPropales } if (empty($hidetop)) { - $pdf->SetXY($this->postotalht-1, $tab_top+1); + $pdf->SetXY($this->postotalht - 1, $tab_top + 1); $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); } } @@ -1434,7 +1434,7 @@ class pdf_azur extends ModelePDFPropales */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs; + global $conf, $langs; // Load traductions files required by page $outputlangs->loadLangs(array("main", "propal", "companies", "bills")); @@ -1444,7 +1444,7 @@ class pdf_azur extends ModelePDFPropales pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK); } @@ -1452,21 +1452,21 @@ class pdf_azur extends ModelePDFPropales $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-100; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; $pdf->SetXY($this->marge_gauche, $posy); // Logo if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -1478,7 +1478,7 @@ class pdf_azur extends ModelePDFPropales } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } @@ -1486,61 +1486,61 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("PdfCommercialProposalTitle"); + $title = $outputlangs->transnoentities("PdfCommercialProposalTitle"); $pdf->MultiCell(100, 4, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); - $posy+=1; + $posy += 1; $pdf->SetFont('', '', $default_font_size - 2); if ($object->ref_client) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : ".dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R'); if ($object->thirdparty->code_client) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } // Get contact if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { - $usertmp=new User($this->db); + $usertmp = new User($this->db); $usertmp->fetch($arrayidcontact[0]); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - $posy+=2; + $posy += 2; $top_shift = 0; // Show list of linked objects @@ -1554,28 +1554,28 @@ class pdf_azur extends ModelePDFPropales if ($showaddress) { // Sender properties - $carac_emetteur=''; + $carac_emetteur = ''; // Add internal contact of proposal if defined - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name")); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy=42+$top_shift; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; - $hautcadre=40; + $posy = 42 + $top_shift; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; + $hautcadre = 40; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -1583,24 +1583,24 @@ class pdf_azur extends ModelePDFPropales $pdf->SetTextColor(0, 0, 60); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); // If CUSTOMER contact defined, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -1611,26 +1611,26 @@ class pdf_azur extends ModelePDFPropales $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox=100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=42+$top_shift; - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = 42 + $top_shift; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); @@ -1638,7 +1638,7 @@ class pdf_azur extends ModelePDFPropales // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } @@ -1659,7 +1659,7 @@ class pdf_azur extends ModelePDFPropales protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } @@ -1684,7 +1684,7 @@ class pdf_azur extends ModelePDFPropales $posx = 120; $largcol = ($this->page_largeur - $this->marge_droite - $posx); - $useborder=0; + $useborder = 0; $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); @@ -1693,11 +1693,11 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1); $pdf->SetXY($posx, $tab_top + $tab_hl); - $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R'); - if (! empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) { - $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl*3); + $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R'); + if (!empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) { + $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl * 3); } - return ($tab_hl*7); + return ($tab_hl * 7); } } diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 9dffb0eee69..125c56960ca 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_squille extends ModelePdfReception { - public $emetteur; // Objet societe qui emet + public $emetteur; // Objet societe qui emet /** @@ -42,54 +42,54 @@ class pdf_squille extends ModelePdfReception */ public function __construct($db = 0) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; $this->db = $db; $this->name = "squille"; $this->description = $langs->trans("DocumentModelStandardPDF"); $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; $this->option_logo = 1; // Get source company - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; - $this->posxpuht=$this->page_largeur - $this->marge_droite; + $this->posxdesc = $this->marge_gauche + 1; + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 78; + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56; + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28; + $this->posxpuht = $this->page_largeur - $this->marge_droite; if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; - $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; - $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 118; + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96; + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68; + $this->posxpuht = $this->page_largeur - $this->marge_droite - 40; + $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20; } - $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { - $this->posxweightvol-=20; - $this->posxpicture-=20; - $this->posxqtyordered-=20; - $this->posxqtytoship-=20; + $this->posxweightvol -= 20; + $this->posxpicture -= 20; + $this->posxqtyordered -= 20; + $this->posxqtytoship -= 20; } - if (! empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) + if (!empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) { $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); @@ -112,35 +112,35 @@ class pdf_squille extends ModelePdfReception public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$conf,$langs,$hookmanager; + global $user, $conf, $langs, $hookmanager; $object->fetch_thirdparty(); - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; - $outputlangs->loadLangs(array("main","dict","companies","bills","products","propal","deliveries","receptions","productbatch","sendings")); + $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal", "deliveries", "receptions", "productbatch", "sendings")); $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); - if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) + $realpatharray = array(); + if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) { $objphoto = new Product($this->db); - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if (empty($object->lines[$i]->fk_product)) continue; $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/"; + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; - $realpath=''; + $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { @@ -175,20 +175,20 @@ class pdf_squille extends ModelePdfReception if ($object->specimen) { $dir = $conf->reception->dir_output; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $rcpref = dol_sanitizeFileName($object->ref); - $dir = $conf->reception->dir_output."/" . $rcpref; - $file = $dir . "/" . $rcpref . ".pdf"; + $dir = $conf->reception->dir_output."/".$rcpref; + $file = $dir."/".$rcpref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -196,24 +196,24 @@ class pdf_squille extends ModelePdfReception if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Set nblines with the new facture lines content after hook $nblines = count($object->lines); - $pdf=pdf_getInstance($this->format); + $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); - $heightforinfotot = 8; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + $heightforinfotot = 8; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -223,14 +223,14 @@ class pdf_squille extends ModelePdfReception } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -240,21 +240,21 @@ class pdf_squille extends ModelePdfReception $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception")); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 90; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); $tab_height = 130; $tab_height_newpage = 150; @@ -268,51 +268,51 @@ class pdf_squille extends ModelePdfReception $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; $height_incoterms += 4; } } - if (! empty($object->note_public) || ! empty($object->tracking_number)) + if (!empty($object->note_public) || !empty($object->tracking_number)) { $tab_top = 88 + $height_incoterms; $tab_top_alt = $tab_top; $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L'); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); $tab_top_alt = $pdf->GetY(); //$tab_top_alt += 1; // Tracking number - if (! empty($object->tracking_number)) + if (!empty($object->tracking_number)) { $object->getUrlTrackingStatus($object->tracking_number); - if (! empty($object->tracking_url)) + if (!empty($object->tracking_url)) { if ($object->reception_method_id > 0) { // Get code using getLabelFromKey - $code=$outputlangs->getLabelFromKey($this->db, $object->shipment_method_id, 'c_shipment_mode', 'rowid', 'code'); - $label=''; - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."
        "; - $label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code)); + $code = $outputlangs->getLabelFromKey($this->db, $object->shipment_method_id, 'c_shipment_mode', 'rowid', 'code'); + $label = ''; + if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."
        "; + $label .= $outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code)); //var_dump($object->tracking_url != $object->tracking_number);exit; if ($object->tracking_url != $object->tracking_number) { - $label.=" : "; - $label.=$object->tracking_url; + $label .= " : "; + $label .= $object->tracking_url; } $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L'); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); $tab_top_alt = $pdf->GetY(); } @@ -320,118 +320,118 @@ class pdf_squille extends ModelePdfReception } // Notes - if (! empty($object->note_public)) + if (!empty($object->note_public)) { - $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); + $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); } $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } else { - $height_note=0; + $height_note = 0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - $fk_commandefourndet=0; - $totalOrdered=0; + $fk_commandefourndet = 0; + $totalOrdered = 0; // Loop on each lines for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $imglinesize = array(); + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); $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->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore+1); + $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } if (isset($imglinesize['width']) && isset($imglinesize['height'])) { - $curX = $this->posxpicture-1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $curX = $this->posxpicture - 1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; + $posYAfterImage = $curY + $imglinesize['height']; } // Description of product line - $curX = $this->posxdesc-1; + $curX = $this->posxdesc - 1; $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 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($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak { $pdf->commitTransaction(); } - $posYAfterDescription=$pdf->GetY(); + $posYAfterDescription = $pdf->GetY(); $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $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. + $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 or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { @@ -472,25 +472,25 @@ class pdf_squille extends ModelePdfReception $pdf->SetXY($this->posxqtytoship, $curY); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty, '', 'C'); - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) + if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $curY); - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R'); + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R'); $pdf->SetXY($this->posxtotalht, $curY); $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R'); } - $nexY+=3; - if ($weighttxt && $voltxt) $nexY+=2; + $nexY += 3; + if ($weighttxt && $voltxt) $nexY += 2; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); + $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1); $pdf->SetLineStyle(array('dash'=>0)); } @@ -509,9 +509,9 @@ class pdf_squille extends ModelePdfReception $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -524,7 +524,7 @@ class pdf_squille extends ModelePdfReception $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; } } @@ -533,16 +533,16 @@ class pdf_squille extends ModelePdfReception if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered); + $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered); // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); @@ -554,29 +554,29 @@ class pdf_squille extends ModelePdfReception // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); return 0; } } @@ -597,9 +597,9 @@ class pdf_squille extends ModelePdfReception protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; - $sign=1; + $sign = 1; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -608,7 +608,7 @@ class pdf_squille extends ModelePdfReception $pdf->SetFont('', 'B', $default_font_size - 1); // Tableau total - $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; + $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol; /*if ($this->page_largeur < 210) // To work with US executive format { $col2x-=20; @@ -616,34 +616,34 @@ class pdf_squille extends ModelePdfReception if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); - $useborder=0; + $useborder = 0; $index = 0; - $totalWeighttoshow=''; - $totalVolumetoshow=''; + $totalWeighttoshow = ''; + $totalVolumetoshow = ''; // Load dim data - $tmparray=$object->getTotalWeightVolume(); - $totalWeight=$tmparray['weight']; - $totalVolume=$tmparray['volume']; - $totalToShip=$tmparray['toship']; + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + $totalToShip = $tmparray['toship']; // Set trueVolume and volume_units not currently stored into database if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $object->trueVolume= ($object->trueWidth * $object->trueHeight * $object->trueDepth); - $object->volume_units=$object->size_units * 3; + $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); + $object->volume_units = $object->size_units * 3; } - if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); - if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); - if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); - if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); + if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); + if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); + if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); + if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) { @@ -654,7 +654,7 @@ class pdf_squille extends ModelePdfReception $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { + if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); @@ -677,7 +677,7 @@ class pdf_squille extends ModelePdfReception $index++; } - if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; + if (!$totalWeighttoshow && !$totalVolumetoshow) $index++; $pdf->SetTextColor(0, 0, 0); @@ -702,8 +702,8 @@ class pdf_squille extends ModelePdfReception global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -712,55 +712,55 @@ class pdf_squille extends ModelePdfReception $pdf->SetFont('', '', $default_font_size - 2); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); - $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L'); } - $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height); + $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxweightvol-1, $tab_top+1); + $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C'); } if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) { - $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); + $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqtyordered-1, $tab_top+1); + $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C'); } } - $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); + $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqtytoship, $tab_top+1); + $pdf->SetXY($this->posxqtytoship, $tab_top + 1); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"), '', 'C'); } - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { - $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); + if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { + $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxpuht-1, $tab_top+1); + $pdf->SetXY($this->posxpuht - 1, $tab_top + 1); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); } - $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); + $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxtotalht-1, $tab_top+1); + $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1); $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); } } @@ -778,7 +778,7 @@ class pdf_squille extends ModelePdfReception */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; $langs->load("orders"); @@ -787,7 +787,7 @@ class pdf_squille extends ModelePdfReception pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->RECEPTION_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECEPTION_DRAFT_WATERMARK); } @@ -798,19 +798,19 @@ class pdf_squille extends ModelePdfReception $w = 110; - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-$w; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - $w; $pdf->SetXY($this->marge_gauche, $posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -822,21 +822,21 @@ class pdf_squille extends ModelePdfReception } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } // Show barcode - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { - $posx=105; + $posx = 105; } else { - $posx=$this->marge_gauche+3; + $posx = $this->marge_gauche + 3; } //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); @@ -844,7 +844,7 @@ class pdf_squille extends ModelePdfReception } $pdf->SetDrawColor(128, 128, 128); - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); @@ -852,67 +852,67 @@ class pdf_squille extends ModelePdfReception } - $posx=$this->page_largeur - $w - $this->marge_droite; - $posy=$this->marge_haute; + $posx = $this->page_largeur - $w - $this->marge_droite; + $posy = $this->marge_haute; $pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("ReceptionSheet"); + $title = $outputlangs->transnoentities("ReceptionSheet"); $pdf->MultiCell($w, 4, $title, '', 'R'); $pdf->SetFont('', '', $default_font_size + 1); - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception") ." : ".$object->ref, '', 'R'); + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception")." : ".$object->ref, '', 'R'); // Date planned delivery - if (! empty($object->date_delivery)) + if (!empty($object->date_delivery)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R'); } - if (! empty($object->thirdparty->code_fournisseur)) + if (!empty($object->thirdparty->code_fournisseur)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); } $pdf->SetFont('', '', $default_font_size + 3); - $Yoff=25; + $Yoff = 25; // Add list of linked orders - $origin = $object->origin; - $origin_id = $object->origin_id; + $origin = $object->origin; + $origin_id = $object->origin_id; // TODO move to external function - if (! empty($conf->fournisseur->enabled)) // commonly $origin='commande' + if (!empty($conf->fournisseur->enabled)) // commonly $origin='commande' { $outputlangs->load('orders'); $classname = 'CommandeFournisseur'; $linkedobject = new $classname($this->db); - $result=$linkedobject->fetch($origin_id); + $result = $linkedobject->fetch($origin_id); if ($result >= 0) { //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects $pdf->SetFont('', '', $default_font_size - 2); - $text=$linkedobject->ref; - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; - $Yoff = $Yoff+8; + $text = $linkedobject->ref; + if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')'; + $Yoff = $Yoff + 8; $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); - $Yoff = $Yoff+3; + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R'); + $Yoff = $Yoff + 3; $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R'); } @@ -921,31 +921,31 @@ class pdf_squille extends ModelePdfReception if ($showaddress) { // Sender properties - $carac_emetteur=''; + $carac_emetteur = ''; // Add internal contact of origin element if defined - $arrayidcontact=array(); - if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal', 'SALESREPFOLL'); - if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal', 'SHIPPING'); + $arrayidcontact = array(); + if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL'); + if (empty($arrayidcontact)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SHIPPING'); if (count($arrayidcontact) > 0) { $object->fetch_user(reset($arrayidcontact)); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show sender - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; - $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; + $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -954,13 +954,13 @@ class pdf_squille extends ModelePdfReception $pdf->SetFillColor(255, 255, 255); // If RECEPTION contact defined, we use it - $usecontact=false; - $arrayidcontact=$object->$origin->getIdContact('external', 'SHIPPING'); + $usecontact = false; + $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -971,46 +971,46 @@ class pdf_squille extends ModelePdfReception $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact)?$object->contact:null), $usecontact, 'targetwithdetails', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell($widthrecbox-2, 4, $carac_client_name, 0, 'L'); + $pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0, 'L'); $posy = $pdf->getY(); // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); - $pdf->MultiCell($widthrecbox-2, 4, $carac_client, 0, 'L'); + $pdf->SetXY($posx + 2, $posy); + $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, 'L'); // Show recipient - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L'); } @@ -1031,7 +1031,7 @@ class pdf_squille extends ModelePdfReception protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'RECEPTION_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } diff --git a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php index 1c634023b80..3a1cf3667aa 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php @@ -22,7 +22,7 @@ * \brief File to manage password generation according to standard rule */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/security/generate/modules_genpassword.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php'; /** @@ -61,10 +61,10 @@ class modGeneratePassStandard extends ModeleGenPassword $this->id = "standard"; $this->length = 8; - $this->db=$db; - $this->conf=$conf; - $this->langs=$langs; - $this->user=$user; + $this->db = $db; + $this->conf = $conf; + $this->langs = $langs; + $this->user = $user; } /** @@ -108,7 +108,7 @@ class modGeneratePassStandard extends ModeleGenPassword while ($i < $this->length) { // pick a random character from the possible ones - $char = substr($possible, mt_rand(0, dol_strlen($possible)-1), 1); + $char = substr($possible, mt_rand(0, dol_strlen($possible) - 1), 1); // we don't want this character if it's already in the password if (!strstr($password, $char)) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 2f4efae770a..d14503a9039 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -22,7 +22,7 @@ */ // Protection to avoid direct call of template -if (empty($object) || ! is_object($object)) +if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; @@ -35,28 +35,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $module = $object->element; // Special cases -if ($module == 'propal') { $permission=$user->rights->propale->creer; } -elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; } -elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; } -elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; } -elseif ($module == 'project') { $permission=$user->rights->projet->creer; } -elseif ($module == 'action') { $permission=$user->rights->agenda->myactions->create; } -elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer; } -elseif ($module == 'reception') { $permission=$user->rights->reception->creer; } -elseif ($module == 'project_task') { $permission=$user->rights->projet->creer; } -elseif (! isset($permission) && isset($user->rights->$module->creer)) +if ($module == 'propal') { $permission = $user->rights->propale->creer; } +elseif ($module == 'fichinter') { $permission = $user->rights->ficheinter->creer; } +elseif ($module == 'order_supplier') { $permission = $user->rights->fournisseur->commande->creer; } +elseif ($module == 'invoice_supplier') { $permission = $user->rights->fournisseur->facture->creer; } +elseif ($module == 'project') { $permission = $user->rights->projet->creer; } +elseif ($module == 'action') { $permission = $user->rights->agenda->myactions->create; } +elseif ($module == 'shipping') { $permission = $user->rights->expedition->creer; } +elseif ($module == 'reception') { $permission = $user->rights->reception->creer; } +elseif ($module == 'project_task') { $permission = $user->rights->projet->creer; } +elseif (!isset($permission) && isset($user->rights->$module->creer)) { - $permission=$user->rights->$module->creer; + $permission = $user->rights->$module->creer; } -elseif (! isset($permission) && isset($user->rights->$module->write)) +elseif (!isset($permission) && isset($user->rights->$module->write)) { - $permission=$user->rights->$module->write; + $permission = $user->rights->$module->write; } -$formcompany= new FormCompany($db); -$companystatic=new Societe($db); -$contactstatic=new Contact($db); -$userstatic=new User($db); +$formcompany = new FormCompany($db); +$companystatic = new Societe($db); +$contactstatic = new Contact($db); +$userstatic = new User($db); ?> @@ -90,11 +90,11 @@ if ($permission) { '; ?>
        trans("Users"); ?>
        global->MAIN_INFO_SOCIETE_NOM; ?>
        -
        select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?>
        +
        select_dolusers($user->id, 'userid', 0, (!empty($userAlreadySelected) ? $userAlreadySelected : null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?>
        element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc; + $tmpobject = $object; + if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc; echo $formcompany->selectTypeContact($tmpobject, '', 'type', 'internal'); ?>
         
        @@ -116,7 +116,7 @@ if ($permission) { '; ?>
        trans("ThirdPartyContacts"); ?>
        - socid; ?> + socid; ?> element, array('facture', 'invoice', 'facture_fou $isNewObject = empty($object->id) && empty($object->rowid); // Relative and absolute discounts -$addrelativediscount = '' . $langs->trans("EditRelativeDiscount") . ''; -$addabsolutediscount = '' . $langs->trans("EditGlobalDiscounts") . ''; -$viewabsolutediscount = '' . $langs->trans("ViewAvailableGlobalDiscounts") . ''; +$addrelativediscount = ''.$langs->trans("EditRelativeDiscount").''; +$addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; +$viewabsolutediscount = ''.$langs->trans("ViewAvailableGlobalDiscounts").''; $fixedDiscount = $thirdparty->remise_percent; -if(! empty($discount_type)) { +if (!empty($discount_type)) { $fixedDiscount = $thirdparty->remise_supplier_percent; } if ($fixedDiscount > 0) { - $translationKey = (! empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount'; + $translationKey = (!empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount'; print $langs->trans($translationKey, $fixedDiscount).'.'; } else { - $translationKey = (! empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount'; + $translationKey = (!empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount'; print $langs->trans($translationKey).'.'; } -if($isNewObject) print ' ('.$addrelativediscount.')'; +if ($isNewObject) print ' ('.$addrelativediscount.')'; // Is there is commercial discount or down payment available ? if ($absolute_discount > 0) { - if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) { - $translationKey = ! empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount'; - $text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)).'.'; + if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) { + $translationKey = !empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount'; + $text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency".$conf->currency)).'.'; - if ($isInvoice && ! $isNewObject && $object->statut > $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) { + if ($isInvoice && !$isNewObject && $object->statut > $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) { $text = $form->textwithpicto($text, $langs->trans('AbsoluteDiscountUse')); } if ($isNewObject) { - $text.= ' ('.$addabsolutediscount.')'; + $text .= ' ('.$addabsolutediscount.')'; } print '
        '.$text; } else { // Discount available of type fixed amount (not credit note) - $more = '(' . $addabsolutediscount . ')'; - $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type); + $more = '('.$addabsolutediscount.')'; + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type); } } // Is there credit notes availables ? if ($absolute_creditnote > 0) { // If validated, we show link "add credit note to payment" - if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) { - $translationKey = ! empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote'; - $text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.'; + if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) { + $translationKey = !empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote'; + $text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency".$conf->currency)).'.'; - if ($isInvoice && ! $isNewObject && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_DEPOSIT) { + if ($isInvoice && !$isNewObject && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_DEPOSIT) { $text = $form->textwithpicto($text, $langs->trans('CreditNoteDepositUse')); } if ($absolute_discount <= 0 || $isNewObject) { - $text.= '('.$addabsolutediscount.')'; + $text .= '('.$addabsolutediscount.')'; } print '
        '.$text; } else { // We can add a credit note on a down payment or standard invoice or situation invoice // There is credit notes discounts available - $more = $isInvoice && ! $isNewObject ? ' (' . $viewabsolutediscount . ')' : ''; - $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher + $more = $isInvoice && !$isNewObject ? ' ('.$viewabsolutediscount.')' : ''; + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher } } -if($absolute_discount <= 0 && $absolute_creditnote <= 0) { - $translationKey = ! empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount'; +if ($absolute_discount <= 0 && $absolute_creditnote <= 0) { + $translationKey = !empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount'; print '
        '.$langs->trans($translationKey).'.'; if ($isInvoice && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) { - print ' (' . $addabsolutediscount . ')'; + print ' ('.$addabsolutediscount.')'; } } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b2ab12041af..29e983a1d2b 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -33,59 +33,59 @@ */ // Protection to avoid direct call of template -if (empty($object) || ! is_object($object)) { +if (empty($object) || !is_object($object)) { print "Error: this template page cannot be called directly as an URL"; exit; } -$usemargins=0; -if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element, array('facture','facturerec','propal','commande'))) +$usemargins = 0; +if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) { - $usemargins=1; + $usemargins = 1; } -if (! isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine) +if (!isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine) global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax; -if (! isset($dateSelector)) $dateSelector=1; // For backward compatibility -elseif (empty($dateSelector)) $dateSelector=0; -if (empty($forceall)) $forceall=0; -if (empty($senderissupplier)) $senderissupplier=0; -if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; +if (!isset($dateSelector)) $dateSelector = 1; // For backward compatibility +elseif (empty($dateSelector)) $dateSelector = 0; +if (empty($forceall)) $forceall = 0; +if (empty($senderissupplier)) $senderissupplier = 0; +if (empty($inputalsopricewithtax)) $inputalsopricewithtax = 0; // Define colspan for the button 'Add' -$colspan = 3; // Columns: total ht + col edit + col delete -if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++;//Add column for Total (currency) if required -if (in_array($object->element, array('propal','commande','order','facture','facturerec','invoice','supplier_proposal','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button +$colspan = 3; // Columns: total ht + col edit + col delete +if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++; //Add column for Total (currency) if required +if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier'))) $colspan++; // With this, there is a column move button //print $object->element; // Lines for extrafield $objectline = null; if (!empty($extrafields)) { - if ($this->table_element_line=='commandedet') { + if ($this->table_element_line == 'commandedet') { $objectline = new OrderLine($this->db); } - elseif ($this->table_element_line=='propaldet') { + elseif ($this->table_element_line == 'propaldet') { $objectline = new PropaleLigne($this->db); } - elseif ($this->table_element_line=='supplier_proposaldet') { + elseif ($this->table_element_line == 'supplier_proposaldet') { $objectline = new SupplierProposalLine($this->db); } - elseif ($this->table_element_line=='facturedet') { + elseif ($this->table_element_line == 'facturedet') { $objectline = new FactureLigne($this->db); } - elseif ($this->table_element_line=='contratdet') { + elseif ($this->table_element_line == 'contratdet') { $objectline = new ContratLigne($this->db); } - elseif ($this->table_element_line=='commande_fournisseurdet') { + elseif ($this->table_element_line == 'commande_fournisseurdet') { $objectline = new CommandeFournisseurLigne($this->db); } - elseif ($this->table_element_line=='facture_fourn_det') { + elseif ($this->table_element_line == 'facture_fourn_det') { $objectline = new SupplierInvoiceLine($this->db); } - elseif ($this->table_element_line=='facturedet_rec') { + elseif ($this->table_element_line == 'facturedet_rec') { $objectline = new FactureLigneRec($this->db); } } diff --git a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php index 009b1b9ea75..43f612ea3f6 100644 --- a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php @@ -18,7 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 8c750f2f425..c56c2a2cb64 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -46,9 +46,9 @@ class ProductFournisseur extends Product /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; - public $product_fourn_price_id; // id of ligne product-supplier + public $product_fourn_price_id; // id of ligne product-supplier /** * @var int ID @@ -61,18 +61,18 @@ class ProductFournisseur extends Product */ public $fourn_ref; public $delivery_time_days; - public $ref_supplier; // ref supplier (can be set by get_buyprice) + public $ref_supplier; // ref supplier (can be set by get_buyprice) public $desc_supplier; - public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) + public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) - public $fourn_id; //supplier id - public $fourn_qty; // quantity for price (can be set by get_buyprice) - public $fourn_pu; // unit price for quantity (can be set by get_buyprice) + public $fourn_id; //supplier id + public $fourn_qty; // quantity for price (can be set by get_buyprice) + public $fourn_pu; // unit price for quantity (can be set by get_buyprice) - public $fourn_price; // price for quantity - public $fourn_remise_percent; // discount for quantity (percent) - public $fourn_remise; // discount for quantity (amount) - public $product_fourn_id; // product-supplier id + public $fourn_price; // price for quantity + public $fourn_remise_percent; // discount for quantity (percent) + public $fourn_remise; // discount for quantity (amount) + public $product_fourn_id; // product-supplier id /** * @var int ID user_id - user who created/updated supplier price @@ -93,8 +93,8 @@ class ProductFournisseur extends Product */ public $fk_supplier_price_expression; - public $supplier_reputation; // reputation of supplier - public $reputations=array(); // list of available supplier reputations + public $supplier_reputation; // reputation of supplier + public $reputations = array(); // list of available supplier reputations // Multicurreny public $fourn_multicurrency_id; @@ -114,7 +114,7 @@ class ProductFournisseur extends Product $this->db = $db; $langs->load("suppliers"); - $this->reputations= array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'),'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); + $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); } @@ -129,19 +129,19 @@ class ProductFournisseur extends Product public function remove_fournisseur($id_fourn) { // phpcs:enable - $ok=1; + $ok = 1; $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; + $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); - $resql2=$this->db->query($sql); - if (! $resql2) + $resql2 = $this->db->query($sql); + if (!$resql2) { - $this->error=$this->db->lasterror(); - $ok=0; + $this->error = $this->db->lasterror(); + $ok = 0; } if ($ok) @@ -169,25 +169,25 @@ class ProductFournisseur extends Product // phpcs:enable global $conf, $user; - $error=0; + $error = 0; $this->db->begin(); // Call trigger - $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); + $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); if ($result < 0) $error++; // End call triggers if (empty($error)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -238,66 +238,66 @@ class ProductFournisseur extends Product //global $mysoc; // Clean parameter - if (empty($qty)) $qty=0; - if (empty($buyprice)) $buyprice=0; - if (empty($charges)) $charges=0; - if (empty($availability)) $availability=0; - if (empty($remise_percent)) $remise_percent=0; - if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation=''; - if ($delivery_time_days != '' && ! is_numeric($delivery_time_days)) $delivery_time_days = ''; + if (empty($qty)) $qty = 0; + if (empty($buyprice)) $buyprice = 0; + if (empty($charges)) $charges = 0; + if (empty($availability)) $availability = 0; + if (empty($remise_percent)) $remise_percent = 0; + if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = ''; + if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = ''; if ($price_base_type == 'TTC') { $ttx = $tva_tx; - $buyprice = $buyprice/(1+($ttx/100)); + $buyprice = $buyprice / (1 + ($ttx / 100)); } // Multicurrency if ($conf->multicurrency->enabled) { - if (empty($multicurrency_tx)) $multicurrency_tx=1; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice=0; + if (empty($multicurrency_tx)) $multicurrency_tx = 1; + if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice=0; + if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; if ($multicurrency_price_base_type == 'TTC') { $ttx = $tva_tx; - $multicurrency_buyprice = $multicurrency_buyprice/(1+($ttx/100)); + $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100)); } - $multicurrency_buyprice=price2num($multicurrency_buyprice, 'MU'); - $multicurrency_unitBuyPrice=price2num($multicurrency_buyprice/$qty, 'MU'); + $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU'); + $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU'); - $buyprice=$multicurrency_buyprice/$multicurrency_tx; + $buyprice = $multicurrency_buyprice / $multicurrency_tx; $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code); } - $buyprice=price2num($buyprice, 'MU'); - $charges=price2num($charges, 'MU'); - $qty=price2num($qty, 'MS'); - $unitBuyPrice = price2num($buyprice/$qty, 'MU'); + $buyprice = price2num($buyprice, 'MU'); + $charges = price2num($charges, 'MU'); + $qty = price2num($qty, 'MS'); + $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); $newvat = $tva_tx; if (count($localtaxes_array) > 0) { - $localtaxtype1=$localtaxes_array['0']; - $localtax1=$localtaxes_array['1']; - $localtaxtype2=$localtaxes_array['2']; - $localtax2=$localtaxes_array['3']; + $localtaxtype1 = $localtaxes_array['0']; + $localtax1 = $localtaxes_array['1']; + $localtaxtype2 = $localtaxes_array['2']; + $localtax2 = $localtaxes_array['3']; } else // old method. deprecated because ot can't retreive type { - $localtaxtype1='0'; - $localtax1=get_localtax($newvat, 1); - $localtaxtype2='0'; - $localtax2=get_localtax($newvat, 2); + $localtaxtype1 = '0'; + $localtax1 = get_localtax($newvat, 1); + $localtaxtype2 = '0'; + $localtax2 = get_localtax($newvat, 2); } - if (empty($localtax1)) $localtax1=0; // If = '' then = 0 - if (empty($localtax2)) $localtax2=0; // If = '' then = 0 + if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 + if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 // Check parameters - if ($buyprice != '' && ! is_numeric($buyprice)) + if ($buyprice != '' && !is_numeric($buyprice)) { } @@ -310,7 +310,7 @@ class ProductFournisseur extends Product if (is_array($logPrices) && count($logPrices) == 0) { $currentPfp = new self($this->db); - $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); + $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); if ($result > 0 && $currentPfp->fourn_price != 0) { $currentPfpUser = new User($this->db); @@ -331,35 +331,35 @@ class ProductFournisseur extends Product } } $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " SET fk_user = " . $user->id." ,"; - $sql.= " ref_fourn = '" . $this->db->escape($ref_fourn) . "',"; - $sql.= " desc_fourn = '" . $this->db->escape($desc_fourn) . "',"; - $sql.= " price = ".$buyprice.","; - $sql.= " quantity = ".$qty.","; - $sql.= " remise_percent = ".$remise_percent.","; - $sql.= " remise = ".$remise.","; - $sql.= " unitprice = ".$unitBuyPrice.","; - $sql.= " fk_availability = ".$availability.","; - $sql.= " multicurrency_price = ".(isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').","; - $sql.= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').","; - $sql.= " multicurrency_tx = ".(isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').","; - $sql.= " fk_multicurrency = ".(isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').","; - $sql.= " multicurrency_code = ".(isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').","; - $sql.= " entity = ".$conf->entity.","; - $sql.= " tva_tx = ".price2num($tva_tx).","; + $sql .= " SET fk_user = ".$user->id." ,"; + $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; + $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; + $sql .= " price = ".$buyprice.","; + $sql .= " quantity = ".$qty.","; + $sql .= " remise_percent = ".$remise_percent.","; + $sql .= " remise = ".$remise.","; + $sql .= " unitprice = ".$unitBuyPrice.","; + $sql .= " fk_availability = ".$availability.","; + $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; + $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; + $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; + $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; + $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; + $sql .= " entity = ".$conf->entity.","; + $sql .= " tva_tx = ".price2num($tva_tx).","; // TODO Add localtax1 and localtax2 //$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; //$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$localtaxtype1."'":"'0'").","; //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$localtaxtype2."'":"'0'").","; - $sql.= " default_vat_code=".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; - $sql.= " info_bits = ".$newnpr.","; - $sql.= " charges = ".$charges.","; // deprecated - $sql.= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql.= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql.= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql.= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - $sql.= " WHERE rowid = ".$this->product_fourn_price_id; + $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; + $sql .= " info_bits = ".$newnpr.","; + $sql .= " charges = ".$charges.","; // deprecated + $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; + $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; + $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; + $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); + $sql .= " WHERE rowid = ".$this->product_fourn_price_id; // TODO Add price_base_type and price_ttc dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); @@ -367,10 +367,10 @@ class ProductFournisseur extends Product if ($resql) { // Call trigger - $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); + $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); if ($result < 0) $error++; // End call triggers - if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) + if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); if ($result < 0) { @@ -390,7 +390,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -2; } @@ -398,57 +398,57 @@ class ProductFournisseur extends Product else { - dol_syslog(get_class($this) . '::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); + dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); // Delete price for this quantity - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_fournisseur_price"; - $sql .= " WHERE fk_soc = " . $fourn->id . " AND ref_fourn = '" . $this->db->escape($ref_fourn) . "' AND quantity = " . $qty . " AND entity = " . $conf->entity; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; + $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { // Add price for this quantity to supplier - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price("; - $sql.= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; + $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; $sql .= " values("; - $sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').","; - $sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').","; - $sql.= (isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').","; - $sql.= (isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').","; - $sql.= (isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').","; - $sql .= " '" . $this->db->idate($now) . "',"; - $sql .= " " . $this->id . ","; - $sql .= " " . $fourn->id . ","; - $sql .= " '" . $this->db->escape($ref_fourn) . "',"; - $sql .= " '" . $this->db->escape($desc_fourn) . "',"; - $sql .= " " . $user->id . ","; - $sql .= " " . $buyprice . ","; - $sql .= " " . $qty . ","; - $sql .= " " . $remise_percent . ","; - $sql .= " " . $remise . ","; - $sql .= " " . $unitBuyPrice . ","; - $sql .= " " . $tva_tx . ","; - $sql .= " " . $charges . ","; - $sql .= " " . $availability . ","; - $sql .= " ".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; - $sql .= " " . $newnpr . ","; - $sql .= $conf->entity . ","; - $sql .= $delivery_time_days . ","; - $sql .= (empty($supplier_reputation) ? 'NULL' : "'" . $this->db->escape($supplier_reputation) . "'") . ","; - $sql .= (empty($barcode) ? 'NULL' : "'" . $this->db->escape($barcode) . "'") . ","; - $sql .= (empty($fk_barcode_type) ? 'NULL' : "'" . $this->db->escape($fk_barcode_type) . "'"); + $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; + $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; + $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; + $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; + $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; + $sql .= " '".$this->db->idate($now)."',"; + $sql .= " ".$this->id.","; + $sql .= " ".$fourn->id.","; + $sql .= " '".$this->db->escape($ref_fourn)."',"; + $sql .= " '".$this->db->escape($desc_fourn)."',"; + $sql .= " ".$user->id.","; + $sql .= " ".$buyprice.","; + $sql .= " ".$qty.","; + $sql .= " ".$remise_percent.","; + $sql .= " ".$remise.","; + $sql .= " ".$unitBuyPrice.","; + $sql .= " ".$tva_tx.","; + $sql .= " ".$charges.","; + $sql .= " ".$availability.","; + $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; + $sql .= " ".$newnpr.","; + $sql .= $conf->entity.","; + $sql .= $delivery_time_days.","; + $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; + $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; + $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); $sql .= ")"; $idinserted = 0; $resql = $this->db->query($sql); if ($resql) { - $idinserted = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_fournisseur_price"); + $idinserted = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); } else { $error++; } - if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { + if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { // Add record into log table $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrenc, $multicurrency_code); if ($result < 0) { @@ -456,7 +456,7 @@ class ProductFournisseur extends Product } } - if (! $error) { + if (!$error) { // Call trigger $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); if ($result < 0) @@ -472,14 +472,14 @@ class ProductFournisseur extends Product return -1; } } else { - $this->error = $this->db->lasterror() . " sql=" . $sql; + $this->error = $this->db->lasterror()." sql=".$sql; $this->db->rollback(); return -2; } } else { - $this->error = $this->db->lasterror() . " sql=" . $sql; + $this->error = $this->db->lasterror()." sql=".$sql; $this->db->rollback(); - return - 1; + return -1; } } } @@ -498,12 +498,12 @@ class ProductFournisseur extends Product global $conf; $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,"; - $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; - $sql.= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; - $sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; - $sql.=" pfp.barcode, pfp.fk_barcode_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " WHERE pfp.rowid = ".$rowid; + $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; + $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; + $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; + $sql .= " pfp.barcode, pfp.fk_barcode_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql .= " WHERE pfp.rowid = ".$rowid; dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); @@ -512,16 +512,16 @@ class ProductFournisseur extends Product $obj = $this->db->fetch_object($resql); if ($obj) { - $this->product_fourn_price_id = $rowid; - $this->id = $obj->fk_product; + $this->product_fourn_price_id = $rowid; + $this->id = $obj->fk_product; $this->fk_product = $obj->fk_product; - $this->product_id = $obj->fk_product; // deprecated + $this->product_id = $obj->fk_product; // deprecated $this->fourn_id = $obj->fk_soc; $this->fourn_ref = $obj->ref_fourn; // deprecated $this->ref_supplier = $obj->ref_fourn; $this->desc_supplier = $obj->desc_fourn; - $this->fourn_price = $obj->price; - $this->fourn_charges = $obj->charges; // deprecated + $this->fourn_price = $obj->price; + $this->fourn_charges = $obj->charges; // deprecated $this->fourn_qty = $obj->quantity; $this->fourn_remise_percent = $obj->remise_percent; $this->fourn_remise = $obj->remise; @@ -529,9 +529,9 @@ class ProductFournisseur extends Product $this->fourn_tva_tx = $obj->tva_tx; $this->fourn_tva_npr = $obj->fourn_tva_npr; // Add also localtaxes - $this->fk_availability = $obj->fk_availability; - $this->delivery_time_days = $obj->delivery_time_days; - $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; + $this->fk_availability = $obj->fk_availability; + $this->delivery_time_days = $obj->delivery_time_days; + $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; $this->supplier_reputation = $obj->supplier_reputation; $this->default_vat_code = $obj->default_vat_code; $this->user_id = $obj->fk_user; @@ -541,7 +541,7 @@ class ProductFournisseur extends Product $this->fourn_multicurrency_tx = $obj->multicurrency_tx; $this->fourn_multicurrency_id = $obj->fk_multicurrency; $this->fourn_multicurrency_code = $obj->multicurrency_code; - if($conf->barcode->enabled) { + if ($conf->barcode->enabled) { $this->fourn_barcode = $obj->barcode; $this->fourn_fk_barcode_type = $obj->fk_barcode_type; } @@ -552,13 +552,13 @@ class ProductFournisseur extends Product if ($price_result >= 0) { $this->fourn_price = $price_result; //recalculation of unitprice, as probably the price changed... - if ($this->fourn_qty!=0) + if ($this->fourn_qty != 0) { - $this->fourn_unitprice = price2num($this->fourn_price/$this->fourn_qty, 'MU'); + $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU'); } else { - $this->fourn_unitprice=""; + $this->fourn_unitprice = ""; } } } @@ -572,7 +572,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -595,18 +595,18 @@ class ProductFournisseur extends Product global $conf; $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; - $sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; - $sql.= " pfp.barcode, pfp.fk_barcode_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; - $sql.= " AND pfp.fk_soc = s.rowid"; - $sql.= " AND s.status=1"; // only enabled company selected - $sql.= " AND pfp.fk_product = ".$prodid; - if (empty($sortfield)) $sql.= " ORDER BY s.nom, pfp.quantity, pfp.price"; - else $sql.= $this->db->order($sortfield, $sortorder); - $sql.=$this->db->plimit($limit, $offset); + $sql .= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; + $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; + $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; + $sql .= " pfp.barcode, pfp.fk_barcode_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; + $sql .= " AND pfp.fk_soc = s.rowid"; + $sql .= " AND s.status=1"; // only enabled company selected + $sql .= " AND pfp.fk_product = ".$prodid; + if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; + else $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit, $offset); dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); @@ -619,26 +619,26 @@ class ProductFournisseur extends Product //define base attribute $prodfourn = new ProductFournisseur($this->db); - $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; - $prodfourn->product_fourn_id = $record["product_fourn_id"]; - $prodfourn->fourn_ref = $record["ref_fourn"]; + $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; + $prodfourn->product_fourn_id = $record["product_fourn_id"]; + $prodfourn->fourn_ref = $record["ref_fourn"]; $prodfourn->ref_supplier = $record["ref_fourn"]; - $prodfourn->desc_supplier = $record["desc_fourn"]; + $prodfourn->desc_supplier = $record["desc_fourn"]; $prodfourn->fourn_price = $record["price"]; - $prodfourn->fourn_qty = $record["quantity"]; - $prodfourn->fourn_remise_percent = $record["remise_percent"]; - $prodfourn->fourn_remise = $record["remise"]; - $prodfourn->fourn_unitprice = $record["unitprice"]; - $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_tva_tx = $record["tva_tx"]; + $prodfourn->fourn_qty = $record["quantity"]; + $prodfourn->fourn_remise_percent = $record["remise_percent"]; + $prodfourn->fourn_remise = $record["remise"]; + $prodfourn->fourn_unitprice = $record["unitprice"]; + $prodfourn->fourn_charges = $record["charges"]; // deprecated + $prodfourn->fourn_tva_tx = $record["tva_tx"]; $prodfourn->fourn_id = $record["fourn_id"]; - $prodfourn->fourn_name = $record["supplier_name"]; + $prodfourn->fourn_name = $record["supplier_name"]; $prodfourn->fk_availability = $record["fk_availability"]; $prodfourn->delivery_time_days = $record["delivery_time_days"]; $prodfourn->id = $prodid; $prodfourn->fourn_tva_npr = $record["info_bits"]; - $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $prodfourn->supplier_reputation = $record["supplier_reputation"]; + $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; + $prodfourn->supplier_reputation = $record["supplier_reputation"]; $prodfourn->fourn_date_creation = $this->db->jdate($record['datec']); $prodfourn->fourn_date_modification = $this->db->jdate($record['tms']); @@ -648,9 +648,9 @@ class ProductFournisseur extends Product $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; - if($conf->barcode->enabled){ - $prodfourn->barcode = $record["barcode"]; - $prodfourn->fk_barcode_type = $record["fk_barcode_type"]; + if ($conf->barcode->enabled) { + $prodfourn->barcode = $record["barcode"]; + $prodfourn->fk_barcode_type = $record["fk_barcode_type"]; } if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { @@ -664,17 +664,17 @@ class ProductFournisseur extends Product if (!isset($prodfourn->fourn_unitprice)) { - if ($prodfourn->fourn_qty!=0) + if ($prodfourn->fourn_qty != 0) { - $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price/$prodfourn->fourn_qty, 'MU'); + $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU'); } else { - $prodfourn->fourn_unitprice=""; + $prodfourn->fourn_unitprice = ""; } } - $retarray[]=$prodfourn; + $retarray[] = $prodfourn; } $this->db->free($resql); @@ -682,7 +682,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -717,7 +717,7 @@ class ProductFournisseur extends Product $this->fourn_unitprice = ''; $this->fourn_id = ''; $this->fourn_name = ''; - $this->delivery_time_days = ''; + $this->delivery_time_days = ''; $this->id = ''; $this->fourn_multicurrency_price = ''; @@ -727,18 +727,18 @@ class ProductFournisseur extends Product $this->fourn_multicurrency_code = ''; $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; - $sql.= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; - $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " WHERE s.entity IN (".getEntity('societe').")"; - $sql.= " AND pfp.entity = ".$conf->entity; // only current entity - $sql.= " AND pfp.fk_product = ".$prodid; - $sql.= " AND pfp.fk_soc = s.rowid"; - $sql.= " AND s.status = 1"; // only enabled society - if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql.= ' AND pfp.fk_soc = '.$socid; + $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; + $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; + $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; + $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; + $sql .= " AND pfp.entity = ".$conf->entity; // only current entity + $sql .= " AND pfp.fk_product = ".$prodid; + $sql .= " AND pfp.fk_soc = s.rowid"; + $sql .= " AND s.status = 1"; // only enabled society + if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; + if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid; dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); @@ -750,7 +750,7 @@ class ProductFournisseur extends Product //Store each record to array for later search of min while ($record = $this->db->fetch_array($resql)) { - $record_array[]=$record; + $record_array[] = $record; } if (count($record_array) == 0) @@ -761,7 +761,7 @@ class ProductFournisseur extends Product else { $min = -1; - foreach($record_array as $record) + foreach ($record_array as $record) { $fourn_price = $record["price"]; // discount calculated buy price @@ -779,7 +779,7 @@ class ProductFournisseur extends Product $fourn_price = price2num($price_result, 'MU'); if ($record["quantity"] != 0) { - $fourn_unitprice = price2num($fourn_price/$record["quantity"], 'MU'); + $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU'); } else { @@ -791,19 +791,19 @@ class ProductFournisseur extends Product { $this->product_fourn_price_id = $record["product_fourn_price_id"]; $this->ref_supplier = $record["ref_fourn"]; - $this->ref_fourn = $record["ref_fourn"]; // deprecated - $this->fourn_ref = $record["ref_fourn"]; // deprecated + $this->ref_fourn = $record["ref_fourn"]; // deprecated + $this->fourn_ref = $record["ref_fourn"]; // deprecated $this->fourn_price = $fourn_price; $this->fourn_qty = $record["quantity"]; $this->fourn_remise_percent = $record["remise_percent"]; $this->fourn_remise = $record["remise"]; $this->fourn_unitprice = $record["unitprice"]; - $this->fourn_charges = $record["charges"]; // deprecated + $this->fourn_charges = $record["charges"]; // deprecated $this->fourn_tva_tx = $record["tva_tx"]; $this->fourn_id = $record["fourn_id"]; $this->fourn_name = $record["supplier_name"]; - $this->delivery_time_days = $record["delivery_time_days"]; - $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; + $this->delivery_time_days = $record["delivery_time_days"]; + $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; $this->id = $prodid; $this->fourn_multicurrency_price = $record["multicurrency_price"]; $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; @@ -820,7 +820,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -840,8 +840,8 @@ class ProductFournisseur extends Product $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " SET fk_supplier_price_expression = ".$expression_id; - $sql.= " WHERE rowid = ".$this->product_fourn_price_id; + $sql .= " SET fk_supplier_price_expression = ".$expression_id; + $sql .= " WHERE rowid = ".$this->product_fourn_price_id; dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); @@ -853,7 +853,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; } @@ -898,19 +898,19 @@ class ProductFournisseur extends Product $langs->load("suppliers"); if (count($productFournList) > 0) { $out .= ''; - $out .= ''; - $out .= ''; + $out .= ''; + $out .= ''; $out .= ''; $out .= ''; foreach ($productFournList as $productFourn) { - $out.= ''; - $out.= ''; - $out.= ''; - $out.= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; } $out .= '
        '.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.($showunitprice?$langs->trans("QtyMin"):'').'
        '.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
        '.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) - $productFourn->fourn_remise):'').''.($showunitprice?$productFourn->fourn_qty:'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
        '.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
        '; } else { - $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); } return $out; } @@ -947,18 +947,18 @@ class ProductFournisseur extends Product global $conf; $sql = "SELECT"; - $sql.= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,"; - $sql.= " pfpl.price, pfpl.quantity"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl"; - $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= ", ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE pfp.entity IN (".getEntity('productprice').")"; - $sql.= " AND pfpl.fk_user = u.rowid"; - $sql.= " AND pfp.rowid = pfpl.fk_product_fournisseur"; - $sql.= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql.= " ORDER BY pfpl.datec"; - else $sql.= $this->db->order($sortfield, $sortorder); - $sql.=$this->db->plimit($limit, $offset); + $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,"; + $sql .= " pfpl.price, pfpl.quantity"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl"; + $sql .= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql .= ", ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")"; + $sql .= " AND pfpl.fk_user = u.rowid"; + $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; + $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; + if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; + else $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit, $offset); dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); $resql = $this->db->query($sql); @@ -968,7 +968,7 @@ class ProductFournisseur extends Product while ($record = $this->db->fetch_array($resql)) { - $retarray[]=$record; + $retarray[] = $record; } $this->db->free($resql); @@ -976,7 +976,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1001,10 +1001,10 @@ class ProductFournisseur extends Product //$out .= ''.$langs->trans("QtyMin").''; $out .= ''.$langs->trans("User").''; foreach ($productFournLogList as $productFournLog) { - $out.= ''.dol_print_date($this->db->jdate($productFournLog['datec']), 'dayhour', 'tzuser').''; - $out.= ''.price($productFournLog['price']).''; + $out .= ''.dol_print_date($this->db->jdate($productFournLog['datec']), 'dayhour', 'tzuser').''; + $out .= ''.price($productFournLog['price']).''; //$out.= ''.$productFournLog['quantity'].''; - $out.= ''.$productFournLog['lastname'].''; + $out .= ''.$productFournLog['lastname'].''; } $out .= ''; } @@ -1027,19 +1027,19 @@ class ProductFournisseur extends Product { global $db, $conf, $langs; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = '' . $langs->trans("SupplierRef") . ''; - $label.= '
        '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref_supplier; + $label = ''.$langs->trans("SupplierRef").''; + $label .= '
        '; + $label .= ''.$langs->trans('Ref').': '.$this->ref_supplier; $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here if (is_array($logPrices) && count($logPrices) > 0) { - $label.= '
        '; - $label.= '' . $langs->trans("History") . ''; - $label.= $this->displayPriceProductFournisseurLog($logPrices); + $label .= '
        '; + $label .= ''.$langs->trans("History").''; + $label .= $this->displayPriceProductFournisseurLog($logPrices); } $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; @@ -1047,31 +1047,31 @@ class ProductFournisseur extends Product if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("SupplierRef"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("SupplierRef"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->fourn_ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->fourn_ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -1096,24 +1096,24 @@ class ProductFournisseur extends Product private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null) { // Add record into log table - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_log("; - $sql.= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; + $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; $sql .= "values("; - $sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').","; - $sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').","; - $sql.= (isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').","; - $sql.= (isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').","; - $sql.= (isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').","; - $sql .= "'" . $this->db->idate($datec) . "',"; - $sql .= " " . $this->product_fourn_price_id . ","; - $sql .= " " . $user->id . ","; - $sql .= " " . price2num($buyprice) . ","; - $sql .= " " . $qty; + $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; + $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; + $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; + $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; + $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; + $sql .= "'".$this->db->idate($datec)."',"; + $sql .= " ".$this->product_fourn_price_id.","; + $sql .= " ".$user->id.","; + $sql .= " ".price2num($buyprice).","; + $sql .= " ".$qty; $sql .= ")"; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { return -1; } else { return 1; diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index aeb945bc220..207133d9cfa 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -40,9 +40,9 @@ $result = restrictedArea($user, 'societe', $socid, ''); * View */ -$commandestatic=new CommandeFournisseur($db); -$facturestatic=new FactureFournisseur($db); -$companystatic=new Societe($db); +$commandestatic = new CommandeFournisseur($db); +$facturestatic = new FactureFournisseur($db); +$companystatic = new Societe($db); llxHeader("", $langs->trans("SuppliersArea")); @@ -56,13 +56,13 @@ print '
        '; // Orders $sql = "SELECT count(cf.rowid), cf.fk_statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; -$sql.= " ".MAIN_DB_PREFIX."societe as s"; +$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; +$sql .= " ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; -$sql.= " WHERE cf.fk_soc = s.rowid "; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id; -$sql.= " AND cf.entity = ".$conf->entity; -$sql.= " GROUP BY cf.fk_statut"; +$sql .= " WHERE cf.fk_soc = s.rowid "; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; +$sql .= " AND cf.entity = ".$conf->entity; +$sql .= " GROUP BY cf.fk_statut"; $resql = $db->query($sql); if ($resql) @@ -97,19 +97,19 @@ else // Draft orders -if (! empty($conf->fournisseur->enabled)) +if (!empty($conf->fournisseur->enabled)) { $langs->load("orders"); $sql = "SELECT cf.rowid, cf.ref, cf.total_ttc,"; - $sql.= " s.nom as name, s.rowid as socid"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " s.nom as name, s.rowid as socid"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE cf.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id; - $sql.= " AND cf.entity = ".$conf->entity; - $sql.= " AND cf.fk_statut = 0"; + $sql .= " WHERE cf.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; + $sql .= " AND cf.entity = ".$conf->entity; + $sql .= " AND cf.fk_statut = 0"; if ($socid) $sql .= " AND cf.fk_soc = ".$socid; $resql = $db->query($sql); @@ -129,21 +129,21 @@ if (! empty($conf->fournisseur->enabled)) $obj = $db->fetch_object($resql); print ''; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; print $commandestatic->getNomUrl(1, '', 16); print ''; print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=0; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = 0; print $companystatic->getNomUrl(1, '', 16); print ''; print ''.price($obj->total_ttc).''; $i++; $total += $obj->total_ttc; } - if ($total>0) + if ($total > 0) { print ''.$langs->trans("Total").''.price($total).""; } @@ -154,22 +154,22 @@ if (! empty($conf->fournisseur->enabled)) } // Draft invoices -if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { $sql = "SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type"; - $sql.= ", s.nom as name, s.rowid as socid"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", s.nom as name, s.rowid as socid"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE s.rowid = ff.fk_soc"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id; - $sql.= " AND ff.entity = ".$conf->entity; - $sql.= " AND ff.fk_statut = 0"; + $sql .= " WHERE s.rowid = ff.fk_soc"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; + $sql .= " AND ff.entity = ".$conf->entity; + $sql .= " AND ff.fk_statut = 0"; if ($socid) $sql .= " AND f.fk_soc = ".$socid; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); if ($num) @@ -185,20 +185,20 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- $obj = $db->fetch_object($resql); print ''; - $facturestatic->ref=$obj->ref; - $facturestatic->id=$obj->rowid; - $facturestatic->type=$obj->type; + $facturestatic->ref = $obj->ref; + $facturestatic->id = $obj->rowid; + $facturestatic->type = $obj->type; print $facturestatic->getNomUrl(1, ''); print ''; print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=0; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = 0; print $companystatic->getNomUrl(1, '', 16); print ''; print ''.price($obj->total_ttc).''; print ''; - $tot_ttc+=$obj->total_ttc; + $tot_ttc += $obj->total_ttc; $i++; } @@ -225,18 +225,18 @@ print '
        '; /* * List last modified supliers */ -$max=10; +$max = 10; $sql = "SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur, s.code_compta_fournisseur"; -$sql.= ", st.libelle as stcomm"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; +$sql .= ", st.libelle as stcomm"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE s.fk_stcomm = st.id"; -$sql.= " AND s.fournisseur = 1"; -$sql.= " AND s.entity IN (".getEntity('societe').")"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql .= " WHERE s.fk_stcomm = st.id"; +$sql .= " AND s.fournisseur = 1"; +$sql .= " AND s.entity IN (".getEntity('societe').")"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND s.rowid = ".$socid; -$sql.= " ORDER BY s.tms DESC"; +$sql .= " ORDER BY s.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); @@ -252,7 +252,7 @@ if ($resql) print ''.$langs->trans("DateModification")."\n"; print "\n"; - while ($obj = $db->fetch_object($resql) ) + while ($obj = $db->fetch_object($resql)) { print ''; print ''.img_object($langs->trans("ShowSupplier"), "company").''; @@ -275,7 +275,7 @@ else * List of suppliers categories */ $companystatic->LoadSupplierCateg(); -$categstatic=new Categorie($db); +$categstatic = new Categorie($db); if (count($companystatic->SupplierCategories)) { @@ -290,9 +290,9 @@ if (count($companystatic->SupplierCategories)) { print ''."\n"; print ''; - $categstatic->id=$rowid; - $categstatic->ref=$label; - $categstatic->label=$label; + $categstatic->id = $rowid; + $categstatic->ref = $label; + $categstatic->label = $label; print $categstatic->getNomUrl(1); print ''."\n"; // TODO this page not exist diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index cac93404a85..c5a88028586 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -911,7 +911,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $ // Si il y a une erreur if (GETPOST('error')) { - switch(GETPOST('error')) { + switch (GETPOST('error')) { case 'datefin' : $errors[] = $langs->trans('ErrorEndDateCP'); break; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 37d38ea69eb..c44c588b335 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -25,7 +25,7 @@ * \ingroup holiday * \brief Class file of the module paid holiday. */ -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** @@ -36,12 +36,12 @@ class Holiday extends CommonObject /** * @var string ID to identify managed object */ - public $element='holiday'; + public $element = 'holiday'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='holiday'; + public $table_element = 'holiday'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -70,47 +70,47 @@ class Holiday extends CommonObject */ public $fk_user; - public $date_create=''; + public $date_create = ''; /** * @var string description */ public $description; - public $date_debut=''; // Date start in PHP server TZ - public $date_fin=''; // Date end in PHP server TZ - public $date_debut_gmt=''; // Date start in GMT - public $date_fin_gmt=''; // Date end in GMT - public $halfday=''; // 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning - public $statut=''; // 1=draft, 2=validated, 3=approved + public $date_debut = ''; // Date start in PHP server TZ + public $date_fin = ''; // Date end in PHP server TZ + public $date_debut_gmt = ''; // Date start in GMT + public $date_fin_gmt = ''; // Date end in GMT + public $halfday = ''; // 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning + public $statut = ''; // 1=draft, 2=validated, 3=approved /** * @var int ID */ public $fk_validator; - public $date_valid=''; + public $date_valid = ''; /** * @var int ID */ public $fk_user_valid; - public $date_refuse=''; + public $date_refuse = ''; /** * @var int ID */ public $fk_user_refuse; - public $date_cancel=''; + public $date_cancel = ''; /** * @var int ID */ public $fk_user_cancel; - public $detail_refuse=''; + public $detail_refuse = ''; /** * @var int ID @@ -175,21 +175,21 @@ class Holiday extends CommonObject $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; } - if (! empty($conf->global->HOLIDAY_ADDON)) + if (!empty($conf->global->HOLIDAY_ADDON)) { - $mybool=false; + $mybool = false; $file = $conf->global->HOLIDAY_ADDON.".php"; $classname = $conf->global->HOLIDAY_ADDON; // Include file with class - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/holiday/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } if ($mybool === false) @@ -207,7 +207,7 @@ class Holiday extends CommonObject } else { - $this->error=$obj->error; + $this->error = $obj->error; //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } @@ -256,58 +256,58 @@ class Holiday extends CommonObject public function create($user, $notrigger = 0) { global $conf; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); // Check parameters - if (empty($this->fk_user) || ! is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error="ErrorBadParameterFkUser"; return -1; } - if (empty($this->fk_validator) || ! is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error="ErrorBadParameterFkValidator"; return -1; } - if (empty($this->fk_type) || ! is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error="ErrorBadParameterFkType"; return -1; } + if (empty($this->fk_user) || !is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error = "ErrorBadParameterFkUser"; return -1; } + if (empty($this->fk_validator) || !is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error = "ErrorBadParameterFkValidator"; return -1; } + if (empty($this->fk_type) || !is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error = "ErrorBadParameterFkType"; return -1; } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday("; - $sql.= "fk_user,"; - $sql.= "date_create,"; - $sql.= "description,"; - $sql.= "date_debut,"; - $sql.= "date_fin,"; - $sql.= "halfday,"; - $sql.= "statut,"; - $sql.= "fk_validator,"; - $sql.= "fk_type,"; - $sql.= "fk_user_create,"; - $sql.= "entity"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->fk_user)."',"; - $sql.= " '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->escape($this->description)."',"; - $sql.= " '".$this->db->idate($this->date_debut)."',"; - $sql.= " '".$this->db->idate($this->date_fin)."',"; - $sql.= " ".$this->halfday.","; - $sql.= " '1',"; - $sql.= " '".$this->db->escape($this->fk_validator)."',"; - $sql.= " ".$this->fk_type.","; - $sql.= " ".$user->id.","; - $sql.= " ".$conf->entity; - $sql.= ")"; + $sql .= "fk_user,"; + $sql .= "date_create,"; + $sql .= "description,"; + $sql .= "date_debut,"; + $sql .= "date_fin,"; + $sql .= "halfday,"; + $sql .= "statut,"; + $sql .= "fk_validator,"; + $sql .= "fk_type,"; + $sql .= "fk_user_create,"; + $sql .= "entity"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->fk_user)."',"; + $sql .= " '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->escape($this->description)."',"; + $sql .= " '".$this->db->idate($this->date_debut)."',"; + $sql .= " '".$this->db->idate($this->date_fin)."',"; + $sql .= " ".$this->halfday.","; + $sql .= " '1',"; + $sql .= " '".$this->db->escape($this->fk_validator)."',"; + $sql .= " ".$this->fk_type.","; + $sql .= " ".$user->id.","; + $sql .= " ".$conf->entity; + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday"); - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_CREATE', $user); + $result = $this->call_trigger('HOLIDAY_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -316,13 +316,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -344,34 +344,34 @@ class Holiday extends CommonObject global $langs; $sql = "SELECT"; - $sql.= " cp.rowid,"; - $sql.= " cp.ref,"; - $sql.= " cp.fk_user,"; - $sql.= " cp.date_create,"; - $sql.= " cp.description,"; - $sql.= " cp.date_debut,"; - $sql.= " cp.date_fin,"; - $sql.= " cp.halfday,"; - $sql.= " cp.statut,"; - $sql.= " cp.fk_validator,"; - $sql.= " cp.date_valid,"; - $sql.= " cp.fk_user_valid,"; - $sql.= " cp.date_refuse,"; - $sql.= " cp.fk_user_refuse,"; - $sql.= " cp.date_cancel,"; - $sql.= " cp.fk_user_cancel,"; - $sql.= " cp.detail_refuse,"; - $sql.= " cp.note_private,"; - $sql.= " cp.note_public,"; - $sql.= " cp.fk_user_create,"; - $sql.= " cp.fk_type,"; - $sql.= " cp.entity"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; - if ($id > 0) $sql.= " WHERE cp.rowid = ".$id; - else $sql.=" WHERE cp.ref = '".$this->db->escape($ref)."'"; + $sql .= " cp.rowid,"; + $sql .= " cp.ref,"; + $sql .= " cp.fk_user,"; + $sql .= " cp.date_create,"; + $sql .= " cp.description,"; + $sql .= " cp.date_debut,"; + $sql .= " cp.date_fin,"; + $sql .= " cp.halfday,"; + $sql .= " cp.statut,"; + $sql .= " cp.fk_validator,"; + $sql .= " cp.date_valid,"; + $sql .= " cp.fk_user_valid,"; + $sql .= " cp.date_refuse,"; + $sql .= " cp.fk_user_refuse,"; + $sql .= " cp.date_cancel,"; + $sql .= " cp.fk_user_cancel,"; + $sql .= " cp.detail_refuse,"; + $sql .= " cp.note_private,"; + $sql .= " cp.note_public,"; + $sql .= " cp.fk_user_create,"; + $sql .= " cp.fk_type,"; + $sql .= " cp.entity"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp"; + if ($id > 0) $sql .= " WHERE cp.rowid = ".$id; + else $sql .= " WHERE cp.ref = '".$this->db->escape($ref)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -379,7 +379,7 @@ class Holiday extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - $this->ref = ($obj->ref?$obj->ref:$obj->rowid); + $this->ref = ($obj->ref ? $obj->ref : $obj->rowid); $this->fk_user = $obj->fk_user; $this->date_create = $this->db->jdate($obj->date_create); $this->description = $obj->description; @@ -411,7 +411,7 @@ class Holiday extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -429,55 +429,55 @@ class Holiday extends CommonObject global $langs, $conf; $sql = "SELECT"; - $sql.= " cp.rowid,"; - $sql.= " cp.ref,"; + $sql .= " cp.rowid,"; + $sql .= " cp.ref,"; - $sql.= " cp.fk_user,"; - $sql.= " cp.fk_type,"; - $sql.= " cp.date_create,"; - $sql.= " cp.description,"; - $sql.= " cp.date_debut,"; - $sql.= " cp.date_fin,"; - $sql.= " cp.halfday,"; - $sql.= " cp.statut,"; - $sql.= " cp.fk_validator,"; - $sql.= " cp.date_valid,"; - $sql.= " cp.fk_user_valid,"; - $sql.= " cp.date_refuse,"; - $sql.= " cp.fk_user_refuse,"; - $sql.= " cp.date_cancel,"; - $sql.= " cp.fk_user_cancel,"; - $sql.= " cp.detail_refuse,"; + $sql .= " cp.fk_user,"; + $sql .= " cp.fk_type,"; + $sql .= " cp.date_create,"; + $sql .= " cp.description,"; + $sql .= " cp.date_debut,"; + $sql .= " cp.date_fin,"; + $sql .= " cp.halfday,"; + $sql .= " cp.statut,"; + $sql .= " cp.fk_validator,"; + $sql .= " cp.date_valid,"; + $sql .= " cp.fk_user_valid,"; + $sql .= " cp.date_refuse,"; + $sql .= " cp.fk_user_refuse,"; + $sql .= " cp.date_cancel,"; + $sql .= " cp.fk_user_cancel,"; + $sql .= " cp.detail_refuse,"; - $sql.= " uu.lastname as user_lastname,"; - $sql.= " uu.firstname as user_firstname,"; - $sql.= " uu.login as user_login,"; - $sql.= " uu.statut as user_statut,"; - $sql.= " uu.photo as user_photo,"; + $sql .= " uu.lastname as user_lastname,"; + $sql .= " uu.firstname as user_firstname,"; + $sql .= " uu.login as user_login,"; + $sql .= " uu.statut as user_statut,"; + $sql .= " uu.photo as user_photo,"; - $sql.= " ua.lastname as validator_lastname,"; - $sql.= " ua.firstname as validator_firstname,"; - $sql.= " ua.login as validator_login,"; - $sql.= " ua.statut as validator_statut,"; - $sql.= " ua.photo as validator_photo"; + $sql .= " ua.lastname as validator_lastname,"; + $sql .= " ua.firstname as validator_firstname,"; + $sql .= " ua.login as validator_login,"; + $sql .= " ua.statut as validator_statut,"; + $sql .= " ua.photo as validator_photo"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; - $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; - $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid"; // Hack pour la recherche sur le tableau - $sql.= " AND cp.fk_user IN (".$user_id.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; + $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; + $sql .= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid"; // Hack pour la recherche sur le tableau + $sql .= " AND cp.fk_user IN (".$user_id.")"; // Selection filter - if(!empty($filter)) { - $sql.= $filter; + if (!empty($filter)) { + $sql .= $filter; } // Order of display of the result - if(!empty($order)) { - $sql.= $order; + if (!empty($order)) { + $sql .= $order; } dol_syslog(get_class($this)."::fetchByUser", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // If no SQL error if ($resql) { @@ -486,16 +486,16 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // If no registration - if(!$num) { + if (!$num) { return 2; } // List the records and add them to the table - while($i < $num) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->rowid; - $tab_result[$i]['ref'] = ($obj->ref?$obj->ref:$obj->rowid); + $tab_result[$i]['ref'] = ($obj->ref ? $obj->ref : $obj->rowid); $tab_result[$i]['fk_user'] = $obj->fk_user; $tab_result[$i]['fk_type'] = $obj->fk_type; @@ -538,7 +538,7 @@ class Holiday extends CommonObject else { // SQL Error - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -555,55 +555,55 @@ class Holiday extends CommonObject global $langs; $sql = "SELECT"; - $sql.= " cp.rowid,"; - $sql.= " cp.ref,"; + $sql .= " cp.rowid,"; + $sql .= " cp.ref,"; - $sql.= " cp.fk_user,"; - $sql.= " cp.fk_type,"; - $sql.= " cp.date_create,"; - $sql.= " cp.tms as date_update,"; - $sql.= " cp.description,"; - $sql.= " cp.date_debut,"; - $sql.= " cp.date_fin,"; - $sql.= " cp.halfday,"; - $sql.= " cp.statut,"; - $sql.= " cp.fk_validator,"; - $sql.= " cp.date_valid,"; - $sql.= " cp.fk_user_valid,"; - $sql.= " cp.date_refuse,"; - $sql.= " cp.fk_user_refuse,"; - $sql.= " cp.date_cancel,"; - $sql.= " cp.fk_user_cancel,"; - $sql.= " cp.detail_refuse,"; + $sql .= " cp.fk_user,"; + $sql .= " cp.fk_type,"; + $sql .= " cp.date_create,"; + $sql .= " cp.tms as date_update,"; + $sql .= " cp.description,"; + $sql .= " cp.date_debut,"; + $sql .= " cp.date_fin,"; + $sql .= " cp.halfday,"; + $sql .= " cp.statut,"; + $sql .= " cp.fk_validator,"; + $sql .= " cp.date_valid,"; + $sql .= " cp.fk_user_valid,"; + $sql .= " cp.date_refuse,"; + $sql .= " cp.fk_user_refuse,"; + $sql .= " cp.date_cancel,"; + $sql .= " cp.fk_user_cancel,"; + $sql .= " cp.detail_refuse,"; - $sql.= " uu.lastname as user_lastname,"; - $sql.= " uu.firstname as user_firstname,"; - $sql.= " uu.login as user_login,"; - $sql.= " uu.statut as user_statut,"; - $sql.= " uu.photo as user_photo,"; + $sql .= " uu.lastname as user_lastname,"; + $sql .= " uu.firstname as user_firstname,"; + $sql .= " uu.login as user_login,"; + $sql .= " uu.statut as user_statut,"; + $sql .= " uu.photo as user_photo,"; - $sql.= " ua.lastname as validator_lastname,"; - $sql.= " ua.firstname as validator_firstname,"; - $sql.= " ua.login as validator_login,"; - $sql.= " ua.statut as validator_statut,"; - $sql.= " ua.photo as validator_photo"; + $sql .= " ua.lastname as validator_lastname,"; + $sql .= " ua.firstname as validator_firstname,"; + $sql .= " ua.login as validator_login,"; + $sql .= " ua.statut as validator_statut,"; + $sql .= " ua.photo as validator_photo"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; - $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; - $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; + $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; + $sql .= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau // Selection filtering - if(!empty($filter)) { - $sql.= $filter; + if (!empty($filter)) { + $sql .= $filter; } // order of display - if(!empty($order)) { - $sql.= $order; + if (!empty($order)) { + $sql .= $order; } dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // If no SQL error if ($resql) { @@ -612,16 +612,16 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // If no registration - if(!$num) { + if (!$num) { return 2; } // List the records and add them to the table - while($i < $num) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->rowid; - $tab_result[$i]['ref'] = ($obj->ref?$obj->ref:$obj->rowid); + $tab_result[$i]['ref'] = ($obj->ref ? $obj->ref : $obj->rowid); $tab_result[$i]['fk_user'] = $obj->fk_user; $tab_result[$i]['fk_type'] = $obj->fk_type; $tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create); @@ -663,7 +663,7 @@ class Holiday extends CommonObject else { // SQL Error - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -679,10 +679,10 @@ class Holiday extends CommonObject public function validate($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) { $num = $this->getNextNumRef(null); } @@ -694,28 +694,28 @@ class Holiday extends CommonObject // Update status $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; - if(!empty($this->statut) && is_numeric($this->statut)) { - $sql.= " statut = ".$this->statut.","; + if (!empty($this->statut) && is_numeric($this->statut)) { + $sql .= " statut = ".$this->statut.","; } else { $error++; } - $sql.= " ref = '".$this->db->escape($num)."'"; - $sql.= " WHERE rowid= ".$this->id; + $sql .= " ref = '".$this->db->escape($num)."'"; + $sql .= " WHERE rowid= ".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_VALIDATE', $user); + $result = $this->call_trigger('HOLIDAY_VALIDATE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -724,13 +724,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::validate ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -750,86 +750,86 @@ class Holiday extends CommonObject public function approve($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; - $sql.= " description= '".$this->db->escape($this->description)."',"; + $sql .= " description= '".$this->db->escape($this->description)."',"; - if(!empty($this->date_debut)) { - $sql.= " date_debut = '".$this->db->idate($this->date_debut)."',"; + if (!empty($this->date_debut)) { + $sql .= " date_debut = '".$this->db->idate($this->date_debut)."',"; } else { $error++; } - if(!empty($this->date_fin)) { - $sql.= " date_fin = '".$this->db->idate($this->date_fin)."',"; + if (!empty($this->date_fin)) { + $sql .= " date_fin = '".$this->db->idate($this->date_fin)."',"; } else { $error++; } - $sql.= " halfday = ".$this->halfday.","; - if(!empty($this->statut) && is_numeric($this->statut)) { - $sql.= " statut = ".$this->statut.","; + $sql .= " halfday = ".$this->halfday.","; + if (!empty($this->statut) && is_numeric($this->statut)) { + $sql .= " statut = ".$this->statut.","; } else { $error++; } - if(!empty($this->fk_validator)) { - $sql.= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; + if (!empty($this->fk_validator)) { + $sql .= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; } else { $error++; } - if(!empty($this->date_valid)) { - $sql.= " date_valid = '".$this->db->idate($this->date_valid)."',"; + if (!empty($this->date_valid)) { + $sql .= " date_valid = '".$this->db->idate($this->date_valid)."',"; } else { - $sql.= " date_valid = NULL,"; + $sql .= " date_valid = NULL,"; } - if(!empty($this->fk_user_valid)) { - $sql.= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; + if (!empty($this->fk_user_valid)) { + $sql .= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; } else { - $sql.= " fk_user_valid = NULL,"; + $sql .= " fk_user_valid = NULL,"; } - if(!empty($this->date_refuse)) { - $sql.= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; + if (!empty($this->date_refuse)) { + $sql .= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; } else { - $sql.= " date_refuse = NULL,"; + $sql .= " date_refuse = NULL,"; } - if(!empty($this->fk_user_refuse)) { - $sql.= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; + if (!empty($this->fk_user_refuse)) { + $sql .= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; } else { - $sql.= " fk_user_refuse = NULL,"; + $sql .= " fk_user_refuse = NULL,"; } - if(!empty($this->date_cancel)) { - $sql.= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; + if (!empty($this->date_cancel)) { + $sql .= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; } else { - $sql.= " date_cancel = NULL,"; + $sql .= " date_cancel = NULL,"; } - if(!empty($this->fk_user_cancel)) { - $sql.= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; + if (!empty($this->fk_user_cancel)) { + $sql .= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; } else { - $sql.= " fk_user_cancel = NULL,"; + $sql .= " fk_user_cancel = NULL,"; } - if(!empty($this->detail_refuse)) { - $sql.= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; + if (!empty($this->detail_refuse)) { + $sql .= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; } else { - $sql.= " detail_refuse = NULL"; + $sql .= " detail_refuse = NULL"; } - $sql.= " WHERE rowid= ".$this->id; + $sql .= " WHERE rowid= ".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::approve", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_APPROVE', $user); + $result = $this->call_trigger('HOLIDAY_APPROVE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -838,13 +838,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::approve ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -863,86 +863,86 @@ class Holiday extends CommonObject public function update($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; - $sql.= " description= '".$this->db->escape($this->description)."',"; + $sql .= " description= '".$this->db->escape($this->description)."',"; - if(!empty($this->date_debut)) { - $sql.= " date_debut = '".$this->db->idate($this->date_debut)."',"; + if (!empty($this->date_debut)) { + $sql .= " date_debut = '".$this->db->idate($this->date_debut)."',"; } else { $error++; } - if(!empty($this->date_fin)) { - $sql.= " date_fin = '".$this->db->idate($this->date_fin)."',"; + if (!empty($this->date_fin)) { + $sql .= " date_fin = '".$this->db->idate($this->date_fin)."',"; } else { $error++; } - $sql.= " halfday = ".$this->halfday.","; - if(!empty($this->statut) && is_numeric($this->statut)) { - $sql.= " statut = ".$this->statut.","; + $sql .= " halfday = ".$this->halfday.","; + if (!empty($this->statut) && is_numeric($this->statut)) { + $sql .= " statut = ".$this->statut.","; } else { $error++; } - if(!empty($this->fk_validator)) { - $sql.= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; + if (!empty($this->fk_validator)) { + $sql .= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; } else { $error++; } - if(!empty($this->date_valid)) { - $sql.= " date_valid = '".$this->db->idate($this->date_valid)."',"; + if (!empty($this->date_valid)) { + $sql .= " date_valid = '".$this->db->idate($this->date_valid)."',"; } else { - $sql.= " date_valid = NULL,"; + $sql .= " date_valid = NULL,"; } - if(!empty($this->fk_user_valid)) { - $sql.= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; + if (!empty($this->fk_user_valid)) { + $sql .= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; } else { - $sql.= " fk_user_valid = NULL,"; + $sql .= " fk_user_valid = NULL,"; } - if(!empty($this->date_refuse)) { - $sql.= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; + if (!empty($this->date_refuse)) { + $sql .= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; } else { - $sql.= " date_refuse = NULL,"; + $sql .= " date_refuse = NULL,"; } - if(!empty($this->fk_user_refuse)) { - $sql.= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; + if (!empty($this->fk_user_refuse)) { + $sql .= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; } else { - $sql.= " fk_user_refuse = NULL,"; + $sql .= " fk_user_refuse = NULL,"; } - if(!empty($this->date_cancel)) { - $sql.= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; + if (!empty($this->date_cancel)) { + $sql .= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; } else { - $sql.= " date_cancel = NULL,"; + $sql .= " date_cancel = NULL,"; } - if(!empty($this->fk_user_cancel)) { - $sql.= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; + if (!empty($this->fk_user_cancel)) { + $sql .= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; } else { - $sql.= " fk_user_cancel = NULL,"; + $sql .= " fk_user_cancel = NULL,"; } - if(!empty($this->detail_refuse)) { - $sql.= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; + if (!empty($this->detail_refuse)) { + $sql .= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; } else { - $sql.= " detail_refuse = NULL"; + $sql .= " detail_refuse = NULL"; } - $sql.= " WHERE rowid= ".$this->id; + $sql .= " WHERE rowid= ".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_MODIFY', $user); + $result = $this->call_trigger('HOLIDAY_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -951,13 +951,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -977,25 +977,25 @@ class Holiday extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_DELETE', $user); + $result = $this->call_trigger('HOLIDAY_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -1004,13 +1004,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -1036,10 +1036,10 @@ class Holiday extends CommonObject { $this->fetchByUser($fk_user, '', ''); - foreach($this->holiday as $infos_CP) + foreach ($this->holiday as $infos_CP) { - if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays - if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays + if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays + if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays /* var_dump("--"); var_dump("old: ".dol_print_date($infos_CP['date_debut'],'dayhour').' '.dol_print_date($infos_CP['date_fin'],'dayhour').' '.$infos_CP['halfday']); @@ -1118,36 +1118,36 @@ class Holiday extends CommonObject { global $langs, $conf; - $isavailablemorning=true; - $isavailableafternoon=true; + $isavailablemorning = true; + $isavailableafternoon = true; $sql = "SELECT cp.rowid, cp.date_debut as date_start, cp.date_fin as date_end, cp.halfday, cp.statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; - $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; - $sql.= " AND cp.fk_user = ".(int) $fk_user; - $sql.= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'"; - if ($status != '-1') $sql.=" AND cp.statut IN (".$this->db->escape($status).")"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp"; + $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; + $sql .= " AND cp.fk_user = ".(int) $fk_user; + $sql .= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'"; + if ($status != '-1') $sql .= " AND cp.statut IN (".$this->db->escape($status).")"; $resql = $this->db->query($sql); if ($resql) { - $num_rows = $this->db->num_rows($resql); // Note, we can have 2 records if on is morning and the other one is afternoon + $num_rows = $this->db->num_rows($resql); // Note, we can have 2 records if on is morning and the other one is afternoon if ($num_rows > 0) { - $arrayofrecord=array(); - $i=0; + $arrayofrecord = array(); + $i = 0; while ($i < $num_rows) { $obj = $this->db->fetch_object($resql); // Note: $obj->halfday is 0:Full days, 2:Sart afternoon end morning, -1:Start afternoon, 1:End morning - $arrayofrecord[$obj->rowid]=array('date_start'=>$this->db->jdate($obj->date_start), 'date_end'=>$this->db->jdate($obj->date_end), 'halfday'=>$obj->halfday); + $arrayofrecord[$obj->rowid] = array('date_start'=>$this->db->jdate($obj->date_start), 'date_end'=>$this->db->jdate($obj->date_end), 'halfday'=>$obj->halfday); $i++; } // We found a record, user is on holiday by default, so is not available is true. $isavailablemorning = true; - foreach($arrayofrecord as $record) + foreach ($arrayofrecord as $record) { if ($timestamp == $record['date_start'] && $record['halfday'] == 2) continue; if ($timestamp == $record['date_start'] && $record['halfday'] == -1) continue; @@ -1155,7 +1155,7 @@ class Holiday extends CommonObject break; } $isavailableafternoon = true; - foreach($arrayofrecord as $record) + foreach ($arrayofrecord as $record) { if ($timestamp == $record['date_end'] && $record['halfday'] == 2) continue; if ($timestamp == $record['date_end'] && $record['halfday'] == 1) continue; @@ -1181,26 +1181,26 @@ class Holiday extends CommonObject { global $langs; - $result=''; + $result = ''; - $label=$langs->trans("Show").': '.$this->ref; + $label = $langs->trans("Show").': '.$this->ref; $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; //if ($option != 'nolink') //{ // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; //} $linkstart = ''; - $linkend=''; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; return $result; @@ -1270,24 +1270,24 @@ class Holiday extends CommonObject global $langs; // Liste des statuts - $name = array('DraftCP','ToReviewCP','ApprovedCP','CancelCP','RefuseCP'); - $nb = count($name)+1; + $name = array('DraftCP', 'ToReviewCP', 'ApprovedCP', 'CancelCP', 'RefuseCP'); + $nb = count($name) + 1; // Select HTML $statut = ''."\n"; + $statut .= ''."\n"; print $statut; } @@ -1302,12 +1302,12 @@ class Holiday extends CommonObject { $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; - $sql.= " value = '".$value."'"; - $sql.= " WHERE name = '".$name."'"; + $sql .= " value = '".$value."'"; + $sql .= " WHERE name = '".$name."'"; dol_syslog(get_class($this).'::updateConfCP name='.$name.'', LOG_DEBUG); $result = $this->db->query($sql); - if($result) { + if ($result) { return true; } @@ -1325,13 +1325,13 @@ class Holiday extends CommonObject public function getConfCP($name, $createifnotfound = '') { $sql = "SELECT value"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; - $sql.= " WHERE name = '".$this->db->escape($name)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_config"; + $sql .= " WHERE name = '".$this->db->escape($name)."'"; dol_syslog(get_class($this).'::getConfCP name='.$name.' createifnotfound='.$createifnotfound, LOG_DEBUG); $result = $this->db->query($sql); - if($result) { + if ($result) { $obj = $this->db->fetch_object($result); // Return value if (empty($obj)) @@ -1339,7 +1339,7 @@ class Holiday extends CommonObject if ($createifnotfound) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_config(name, value)"; - $sql.= " VALUES('".$this->db->escape($name)."', '".$this->db->escape($createifnotfound)."')"; + $sql .= " VALUES('".$this->db->escape($name)."', '".$this->db->escape($createifnotfound)."')"; $result = $this->db->query($sql); if ($result) { @@ -1347,7 +1347,7 @@ class Holiday extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -2; } } @@ -1362,7 +1362,7 @@ class Holiday extends CommonObject } } else { // Erreur SQL - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1386,7 +1386,7 @@ class Holiday extends CommonObject $langs->load("holiday"); // Si mise à jour pour tout le monde en début de mois - $now=dol_now(); + $now = dol_now(); $month = date('m', $now); $newdateforlastupdate = dol_print_date($now, '%Y%m%d%H%M%S'); @@ -1405,16 +1405,16 @@ class Holiday extends CommonObject $nbUser = count($users); $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; - $sql.= " value = '".$this->db->escape($newdateforlastupdate)."'"; - $sql.= " WHERE name = 'lastUpdate'"; + $sql .= " value = '".$this->db->escape($newdateforlastupdate)."'"; + $sql .= " WHERE name = 'lastUpdate'"; $result = $this->db->query($sql); - $typeleaves=$this->getTypes(1, 1); + $typeleaves = $this->getTypes(1, 1); // Update each user counter foreach ($users as $userCounter) { $nbDaysToAdd = $typeleaves[$userCounter['type']]['newByMonth']; - if(empty($nbDaysToAdd)) continue; + if (empty($nbDaysToAdd)) continue; dol_syslog("We update leave type id ".$userCounter['type']." for user id ".$userCounter['rowid'], LOG_DEBUG); @@ -1433,7 +1433,7 @@ class Holiday extends CommonObject } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1453,7 +1453,7 @@ class Holiday extends CommonObject $nbHoliday = price2num($nbHoliday, 5); $sql = "SELECT nb_holiday FROM ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; + $sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; $resql = $this->db->query($sql); if ($resql) { @@ -1463,36 +1463,36 @@ class Holiday extends CommonObject { // Update for user $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; - $sql.= " nb_holiday = ".$nbHoliday; - $sql.= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; + $sql .= " nb_holiday = ".$nbHoliday; + $sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; $result = $this->db->query($sql); - if (! $result) + if (!$result) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } else { // Insert for user $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users(nb_holiday, fk_user, fk_type) VALUES ("; - $sql.= $nbHoliday; - $sql.= ", ".(int) $userID.", ".(int) $fk_type.")"; + $sql .= $nbHoliday; + $sql .= ", ".(int) $userID.", ".(int) $fk_type.")"; $result = $this->db->query($sql); - if (! $result) + if (!$result) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } } else { - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } - if (! $error) + if (!$error) { return 1; } @@ -1513,16 +1513,16 @@ class Holiday extends CommonObject { $sql = "SELECT value"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; - $sql.= " WHERE name = '".$name."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_config"; + $sql .= " WHERE name = '".$name."'"; $result = $this->db->query($sql); - if($result) { + if ($result) { $obj = $this->db->fetch_object($result); // Si la valeur est 1 on retourne checked - if($obj->value) { + if ($obj->value) { return 'checked'; } } @@ -1539,29 +1539,29 @@ class Holiday extends CommonObject public function createCPusers($single = false, $userid = '') { // Si c'est l'ensemble des utilisateurs à ajouter - if (! $single) + if (!$single) { dol_syslog(get_class($this).'::createCPusers'); $arrayofusers = $this->fetchUsers(false, true); - foreach($arrayofusers as $users) + foreach ($arrayofusers as $users) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " (fk_user, nb_holiday)"; - $sql.= " VALUES ('".$users['rowid']."','0')"; + $sql .= " (fk_user, nb_holiday)"; + $sql .= " VALUES ('".$users['rowid']."','0')"; - $resql=$this->db->query($sql); - if (! $resql) dol_print_error($this->db); + $resql = $this->db->query($sql); + if (!$resql) dol_print_error($this->db); } } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " (fk_user, nb_holiday)"; - $sql.= " VALUES ('".$userid."','0')"; + $sql .= " (fk_user, nb_holiday)"; + $sql .= " VALUES ('".$userid."','0')"; - $resql=$this->db->query($sql); - if (! $resql) dol_print_error($this->db); + $resql = $this->db->query($sql); + if (!$resql) dol_print_error($this->db); } } @@ -1575,7 +1575,7 @@ class Holiday extends CommonObject { $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " WHERE fk_user = '".$user_id."'"; + $sql .= " WHERE fk_user = '".$user_id."'"; $this->db->query($sql); } @@ -1591,13 +1591,13 @@ class Holiday extends CommonObject public function getCPforUser($user_id, $fk_type = 0) { $sql = "SELECT nb_holiday"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " WHERE fk_user = ".(int) $user_id; - if ($fk_type > 0) $sql.=" AND fk_type = ".(int) $fk_type; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users"; + $sql .= " WHERE fk_user = ".(int) $user_id; + if ($fk_type > 0) $sql .= " AND fk_type = ".(int) $fk_type; dol_syslog(get_class($this).'::getCPforUser user_id='.$user_id.' type_id='.$fk_type, LOG_DEBUG); $result = $this->db->query($sql); - if($result) + if ($result) { $obj = $this->db->fetch_object($result); //return number_format($obj->nb_holiday,2); @@ -1631,23 +1631,23 @@ class Holiday extends CommonObject // Si utilisateur de Dolibarr $sql = "SELECT u.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE (ug.fk_user = u.rowid"; - $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1"; + $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE (ug.fk_user = u.rowid"; + $sql .= " AND ug.entity = ".$conf->entity.")"; + $sql .= " OR u.admin = 1"; } else { - $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + $sql .= " WHERE u.entity IN (0,".$conf->entity.")"; } - $sql.= " AND u.statut > 0"; - if ($filters) $sql.=$filters; + $sql .= " AND u.statut > 0"; + if ($filters) $sql .= $filters; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) { @@ -1656,14 +1656,14 @@ class Holiday extends CommonObject $stringlist = ''; // Boucles du listage des utilisateurs - while($i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($i == 0) { - $stringlist.= $obj->rowid; + $stringlist .= $obj->rowid; } else { - $stringlist.= ', '.$obj->rowid; + $stringlist .= ', '.$obj->rowid; } $i++; @@ -1674,7 +1674,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -1682,11 +1682,11 @@ class Holiday extends CommonObject { // We want only list of vacation balance for user ids $sql = "SELECT DISTINCT cpu.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE cpu.fk_user = u.user"; - if ($filters) $sql.=$filters; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE cpu.fk_user = u.user"; + if ($filters) $sql .= $filters; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) { @@ -1695,14 +1695,14 @@ class Holiday extends CommonObject $stringlist = ''; // Boucles du listage des utilisateurs - while($i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); - if($i == 0) { - $stringlist.= $obj->fk_user; + if ($i == 0) { + $stringlist .= $obj->fk_user; } else { - $stringlist.= ', '.$obj->fk_user; + $stringlist .= ', '.$obj->fk_user; } $i++; @@ -1713,7 +1713,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -1779,11 +1779,11 @@ class Holiday extends CommonObject { // List of vacation balance users $sql = "SELECT cpu.fk_type, cpu.nb_holiday, u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE cpu.fk_user = u.rowid"; - if ($filters) $sql.=$filters; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE cpu.fk_user = u.rowid"; + if ($filters) $sql .= $filters; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) @@ -1793,19 +1793,19 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // Boucles du listage des utilisateurs - while($i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); - $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user - $tab_result[$i]['name'] = $obj->lastname; // deprecated + $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user + $tab_result[$i]['name'] = $obj->lastname; // deprecated $tab_result[$i]['lastname'] = $obj->lastname; $tab_result[$i]['firstname'] = $obj->firstname; $tab_result[$i]['gender'] = $obj->gender; $tab_result[$i]['status'] = $obj->statut; $tab_result[$i]['employee'] = $obj->employee; $tab_result[$i]['photo'] = $obj->photo; - $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager + $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager $tab_result[$i]['type'] = $obj->fk_type; $tab_result[$i]['nb_holiday'] = $obj->nb_holiday; @@ -1818,7 +1818,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -1836,20 +1836,20 @@ class Holiday extends CommonObject public function fetch_users_approver_holiday() { // phpcs:enable - $users_validator=array(); + $users_validator = array(); $sql = "SELECT DISTINCT ur.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; - $sql.= " WHERE ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; - $sql.= "UNION"; - $sql.= " SELECT DISTINCT ugu.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; - $sql.= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; + $sql .= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; + $sql .= " WHERE ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; + $sql .= "UNION"; + $sql .= " SELECT DISTINCT ugu.fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; + $sql .= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; //print $sql; dol_syslog(get_class($this)."::fetch_users_approver_holiday sql=".$sql); $result = $this->db->query($sql); - if($result) + if ($result) { $num_rows = $this->db->num_rows($result); $i = 0; while ($i < $num_rows) @@ -1862,7 +1862,7 @@ class Holiday extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this)."::fetch_users_approver_holiday Error ".$this->error, LOG_ERR); return -1; } @@ -1877,8 +1877,8 @@ class Holiday extends CommonObject public function countActiveUsers() { $sql = "SELECT count(u.rowid) as compteur"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.statut > 0"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.statut > 0"; $result = $this->db->query($sql); $objet = $this->db->fetch_object($result); @@ -1894,8 +1894,8 @@ class Holiday extends CommonObject { $sql = "SELECT count(u.rowid) as compteur"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u LEFT OUTER JOIN ".MAIN_DB_PREFIX."holiday_users hu ON (hu.fk_user=u.rowid)"; - $sql.= " WHERE u.statut > 0 AND hu.fk_user IS NULL"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u LEFT OUTER JOIN ".MAIN_DB_PREFIX."holiday_users hu ON (hu.fk_user=u.rowid)"; + $sql .= " WHERE u.statut > 0 AND hu.fk_user IS NULL"; $result = $this->db->query($sql); $objet = $this->db->fetch_object($result); @@ -1912,7 +1912,7 @@ class Holiday extends CommonObject */ public function verifNbUsers($userDolibarrWithoutCP, $userCP) { - if (empty($userCP)) $userCP=0; + if (empty($userCP)) $userCP = 0; dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); return 1; } @@ -1932,7 +1932,7 @@ class Holiday extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; $prev_solde = price2num($this->getCPforUser($fk_user_update, $fk_type), 5); $new_solde = price2num($new_solde, 5); @@ -1944,30 +1944,30 @@ class Holiday extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_logs ("; - $sql.= "date_action,"; - $sql.= "fk_user_action,"; - $sql.= "fk_user_update,"; - $sql.= "type_action,"; - $sql.= "prev_solde,"; - $sql.= "new_solde,"; - $sql.= "fk_type"; - $sql.= ") VALUES ("; - $sql.= " '".$this->db->idate(dol_now())."',"; - $sql.= " '".$fk_user_action."',"; - $sql.= " '".$fk_user_update."',"; - $sql.= " '".$this->db->escape($label)."',"; - $sql.= " '".$prev_solde."',"; - $sql.= " '".$new_solde."',"; - $sql.= " ".$fk_type; - $sql.= ")"; + $sql .= "date_action,"; + $sql .= "fk_user_action,"; + $sql .= "fk_user_update,"; + $sql .= "type_action,"; + $sql .= "prev_solde,"; + $sql .= "new_solde,"; + $sql .= "fk_type"; + $sql .= ") VALUES ("; + $sql .= " '".$this->db->idate(dol_now())."',"; + $sql .= " '".$fk_user_action."',"; + $sql .= " '".$fk_user_update."',"; + $sql .= " '".$this->db->escape($label)."',"; + $sql .= " '".$prev_solde."',"; + $sql .= " '".$new_solde."',"; + $sql .= " ".$fk_type; + $sql .= ")"; - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { $this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_logs"); } @@ -1975,13 +1975,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::addLogCP ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -2002,29 +2002,29 @@ class Holiday extends CommonObject global $langs; $sql = "SELECT"; - $sql.= " cpl.rowid,"; - $sql.= " cpl.date_action,"; - $sql.= " cpl.fk_user_action,"; - $sql.= " cpl.fk_user_update,"; - $sql.= " cpl.type_action,"; - $sql.= " cpl.prev_solde,"; - $sql.= " cpl.new_solde,"; - $sql.= " cpl.fk_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_logs as cpl"; - $sql.= " WHERE cpl.rowid > 0"; // To avoid error with other search and criteria + $sql .= " cpl.rowid,"; + $sql .= " cpl.date_action,"; + $sql .= " cpl.fk_user_action,"; + $sql .= " cpl.fk_user_update,"; + $sql .= " cpl.type_action,"; + $sql .= " cpl.prev_solde,"; + $sql .= " cpl.new_solde,"; + $sql .= " cpl.fk_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_logs as cpl"; + $sql .= " WHERE cpl.rowid > 0"; // To avoid error with other search and criteria // Filtrage de séléction - if(!empty($filter)) { - $sql.= " ".$filter; + if (!empty($filter)) { + $sql .= " ".$filter; } // Ordre d'affichage - if(!empty($order)) { - $sql.= " ".$order; + if (!empty($order)) { + $sql .= " ".$order; } dol_syslog(get_class($this)."::fetchLog", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) { @@ -2033,12 +2033,12 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // Si pas d'enregistrement - if(!$num) { + if (!$num) { return 2; } // On liste les résultats et on les ajoutent dans le tableau - while($i < $num) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->rowid; @@ -2059,7 +2059,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -2077,10 +2077,10 @@ class Holiday extends CommonObject global $mysoc; $sql = "SELECT rowid, code, label, affect, delay, newByMonth"; - $sql.= " FROM " . MAIN_DB_PREFIX . "c_holiday_types"; - $sql.= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')'; - if ($active >= 0) $sql.=" AND active = ".((int) $active); - if ($affect >= 0) $sql.=" AND affect = ".((int) $affect); + $sql .= " FROM ".MAIN_DB_PREFIX."c_holiday_types"; + $sql .= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')'; + if ($active >= 0) $sql .= " AND active = ".((int) $active); + if ($affect >= 0) $sql .= " AND affect = ".((int) $affect); $result = $this->db->query($sql); if ($result) @@ -2111,21 +2111,21 @@ class Holiday extends CommonObject */ public function initAsSpecimen() { - global $user,$langs; + global $user, $langs; // Initialise parameters - $this->id=0; - $this->specimen=1; + $this->id = 0; + $this->specimen = 1; - $this->fk_user=1; - $this->description='SPECIMEN description'; - $this->date_debut=dol_now(); - $this->date_fin=dol_now()+(24*3600); - $this->date_valid=dol_now(); - $this->fk_validator=1; - $this->halfday=0; - $this->fk_type=1; - $this->statut=Holiday::STATUS_VALIDATED; + $this->fk_user = 1; + $this->description = 'SPECIMEN description'; + $this->date_debut = dol_now(); + $this->date_fin = dol_now() + (24 * 3600); + $this->date_valid = dol_now(); + $this->fk_validator = 1; + $this->halfday = 0; + $this->fk_type = 1; + $this->statut = Holiday::STATUS_VALIDATED; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2137,17 +2137,17 @@ class Holiday extends CommonObject public function load_state_board() { // phpcs:enable - $this->nb=array(); + $this->nb = array(); $sql = "SELECT count(h.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as h"; - $sql.= " WHERE h.statut > 1"; - $sql.= " AND h.entity IN (".getEntity('holiday').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as h"; + $sql .= " WHERE h.statut > 1"; + $sql .= " AND h.entity IN (".getEntity('holiday').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) { - $this->nb["holidays"]=$obj->nb; + while ($obj = $this->db->fetch_object($resql)) { + $this->nb["holidays"] = $obj->nb; } $this->db->free($resql); return 1; @@ -2155,7 +2155,7 @@ class Holiday extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2211,7 +2211,7 @@ class Holiday extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 0efb8dfde59..d4fd5a20caf 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -92,14 +92,14 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial * View */ -if ((! $versionfrom || preg_match('/version/', $versionfrom)) && (! $versionto || preg_match('/version/', $versionto))) +if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto || preg_match('/version/', $versionto))) { print 'Error: Parameter versionfrom or versionto missing or having a bad format.'."\n"; print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n"; // Test if batch mode $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); - $path=__DIR__.'/'; + $path = __DIR__.'/'; if (substr($sapi_type, 0, 3) == 'cli') { print 'Syntax from command line: '.$script_file." x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...]\n"; @@ -107,24 +107,24 @@ if ((! $versionfrom || preg_match('/version/', $versionfrom)) && (! $versionto | exit; } -pHeader('', 'step5', GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'upgrade', 'versionfrom='.$versionfrom.'&versionto='.$versionto); +pHeader('', 'step5', GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'upgrade', 'versionfrom='.$versionfrom.'&versionto='.$versionto); -if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) +if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) { print '

        Database '.$langs->trans('DataMigration').'

        '; print ''; // If password is encoded, we decode it - if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) + 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_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); - $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted + $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); } @@ -137,25 +137,25 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a $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); // Create the global $hookmanager object include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); + $hookmanager = new HookManager($db); $hookmanager->initHooks(array('upgrade')); if (!$db->connected) { print ''; - dolibarr_install_syslog('upgrade2: failed to connect to database :' . $conf->db->name . ' on ' . $conf->db->host . ' for user ' . $conf->db->user, LOG_ERR); + dolibarr_install_syslog('upgrade2: failed to connect to database :'.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR); $error++; } - if (! $error) + if (!$error) { - if($db->database_selected) + if ($db->database_selected) { - dolibarr_install_syslog('upgrade2: database connection successful :' . $dolibarr_main_db_name); + dolibarr_install_syslog('upgrade2: database connection successful :'.$dolibarr_main_db_name); } else { @@ -163,17 +163,17 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } } - if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0; + if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; - if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey=''; + if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; // Chargement config - if (! $error) + if (!$error) { $conf->setValues($db); // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE=constant('SYSLOG_FILE'); + if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; } @@ -185,18 +185,18 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a ***************************************************************************************/ $db->begin(); - if (! $error) + if (!$error) { // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE // Version to install is DOL_VERSION - $dolibarrlastupgradeversionarray=preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:(isset($conf->global->MAIN_VERSION_LAST_INSTALL)?$conf->global->MAIN_VERSION_LAST_INSTALL:'')); + $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : '')); // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec // dans la 1ere colonne, la description de l'action a faire // dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error' - $versiontoarray=explode('.', $versionto); - $versionranarray=explode('.', DOL_VERSION); + $versiontoarray = explode('.', $versionto); + $versionranarray = explode('.', DOL_VERSION); // Force to execute this at begin to avoid the new core code into Dolibarr to be broken. @@ -224,8 +224,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a $db->query($sql, 1); - $afterversionarray=explode('.', '2.0.0'); - $beforeversionarray=explode('.', '2.7.9'); + $afterversionarray = explode('.', '2.0.0'); + $beforeversionarray = explode('.', '2.7.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Script pour V2 -> V2.1 @@ -287,12 +287,12 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 2.8 - $afterversionarray=explode('.', '2.7.9'); - $beforeversionarray=explode('.', '2.8.9'); + $afterversionarray = explode('.', '2.7.9'); + $beforeversionarray = explode('.', '2.8.9'); //print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx + migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx migrate_relationship_tables($db, $langs, $conf, 'co_exp', 'fk_commande', 'commande', 'fk_expedition', 'shipping'); @@ -314,8 +314,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 2.9 - $afterversionarray=explode('.', '2.8.9'); - $beforeversionarray=explode('.', '2.9.9'); + $afterversionarray = explode('.', '2.8.9'); + $beforeversionarray = explode('.', '2.9.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_project_task_time($db, $langs, $conf); @@ -328,16 +328,16 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 3.0 - $afterversionarray=explode('.', '2.9.9'); - $beforeversionarray=explode('.', '3.0.9'); + $afterversionarray = explode('.', '2.9.9'); + $beforeversionarray = explode('.', '3.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // No particular code } // Script for 3.1 - $afterversionarray=explode('.', '3.0.9'); - $beforeversionarray=explode('.', '3.1.9'); + $afterversionarray = explode('.', '3.0.9'); + $beforeversionarray = explode('.', '3.1.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/rss', '/externalrss'); @@ -346,8 +346,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 3.2 - $afterversionarray=explode('.', '3.1.9'); - $beforeversionarray=explode('.', '3.2.9'); + $afterversionarray = explode('.', '3.1.9'); + $beforeversionarray = explode('.', '3.2.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_price_contrat($db, $langs, $conf); @@ -358,8 +358,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 3.3 - $afterversionarray=explode('.', '3.2.9'); - $beforeversionarray=explode('.', '3.3.9'); + $afterversionarray = explode('.', '3.2.9'); + $beforeversionarray = explode('.', '3.3.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_categorie_association($db, $langs, $conf); @@ -369,32 +369,32 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a // No specific scripts // Tasks to do always and only into last targeted version - $afterversionarray=explode('.', '3.6.9'); // target is after this - $beforeversionarray=explode('.', '3.7.9'); // target is before this + $afterversionarray = explode('.', '3.6.9'); // target is after this + $beforeversionarray = explode('.', '3.7.9'); // target is before this if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_event_assignement($db, $langs, $conf); } // Scripts for 3.9 - $afterversionarray=explode('.', '3.7.9'); - $beforeversionarray=explode('.', '3.8.9'); + $afterversionarray = explode('.', '3.7.9'); + $beforeversionarray = explode('.', '3.8.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // No particular code } // Scripts for 4.0 - $afterversionarray=explode('.', '3.9.9'); - $beforeversionarray=explode('.', '4.0.9'); + $afterversionarray = explode('.', '3.9.9'); + $beforeversionarray = explode('.', '4.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/fckeditor', '/medias'); } // Scripts for 5.0 - $afterversionarray=explode('.', '4.0.9'); - $beforeversionarray=explode('.', '5.0.9'); + $afterversionarray = explode('.', '4.0.9'); + $beforeversionarray = explode('.', '5.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Migrate to add entity value into llx_societe_remise @@ -405,11 +405,11 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Scripts for 6.0 - $afterversionarray=explode('.', '5.0.9'); - $beforeversionarray=explode('.', '6.0.9'); + $afterversionarray = explode('.', '5.0.9'); + $beforeversionarray = explode('.', '6.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - if (! empty($conf->multicompany->enabled)) + if (!empty($conf->multicompany->enabled)) { global $multicompany_transverse_mode; @@ -426,8 +426,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Scripts for 7.0 - $afterversionarray=explode('.', '6.0.9'); - $beforeversionarray=explode('.', '7.0.9'); + $afterversionarray = explode('.', '6.0.9'); + $beforeversionarray = explode('.', '7.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Migrate contact association @@ -437,16 +437,16 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Scripts for 8.0 - $afterversionarray=explode('.', '7.0.9'); - $beforeversionarray=explode('.', '8.0.9'); + $afterversionarray = explode('.', '7.0.9'); + $beforeversionarray = explode('.', '8.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/contracts', '/contract'); } // Scripts for 9.0 - $afterversionarray=explode('.', '8.0.9'); - $beforeversionarray=explode('.', '9.0.9'); + $afterversionarray = explode('.', '8.0.9'); + $beforeversionarray = explode('.', '9.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_user_photospath(); @@ -467,7 +467,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) { // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) - $listofmodule=array( + $listofmodule = array( 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', 'MAIN_MODULE_AGENDA'=>'newboxdefonly', 'MAIN_MODULE_BARCODE'=>'newboxdefonly', @@ -488,7 +488,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a 'MAIN_MODULE_SYSLOG'=>'newboxdefonly', 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', 'MAIN_MODULE_SERVICE'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) + 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) 'MAIN_MODULE_VARIANTS'=>'newboxdefonly', 'MAIN_MODULE_WEBSITE'=>'newboxdefonly', ); @@ -500,27 +500,27 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a // Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' // In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line. - if (! $error && $enablemodules) + if (!$error && $enablemodules) { // Reload modules (this must be always done and only into last targeted version) - $listofmodules=array(); - $enablemodules=preg_replace('/enablemodules=/', '', $enablemodules); - $tmplistofmodules=explode(',', $enablemodules); - foreach($tmplistofmodules as $value) + $listofmodules = array(); + $enablemodules = preg_replace('/enablemodules=/', '', $enablemodules); + $tmplistofmodules = explode(',', $enablemodules); + foreach ($tmplistofmodules as $value) { - $listofmodules[$value]='forceactivate'; + $listofmodules[$value] = 'forceactivate'; } migrate_reload_modules($db, $langs, $conf, $listofmodules, 1); } // Can call a dedicated external upgrade process - if (! $error) + if (!$error) { - $parameters=array('versionfrom'=>$versionfrom, 'versionto='.$versionto); - $object=new stdClass(); - $action="upgrade"; - $reshook=$hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('versionfrom'=>$versionfrom, 'versionto='.$versionto); + $object = new stdClass(); + $action = "upgrade"; + $reshook = $hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($hookmanager->resNbOfHooks > 0) { if ($reshook < 0) @@ -542,7 +542,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a else { //if (! empty($conf->modules)) - if (! empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done + if (!empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done { print ''; $insert_sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn SET '; - $insert_sql.= ' fk_paiementfourn = \''.$select_obj->rowid.'\','; - $insert_sql.= ' fk_facturefourn = \''.$select_obj->fk_facture_fourn.'\','; - $insert_sql.= ' amount = \''.$select_obj->amount.'\''; + $insert_sql .= ' fk_paiementfourn = \''.$select_obj->rowid.'\','; + $insert_sql .= ' fk_facturefourn = \''.$select_obj->fk_facture_fourn.'\','; + $insert_sql .= ' amount = \''.$select_obj->amount.'\''; $insert_resql = $db->query($insert_sql); if ($insert_resql) @@ -1454,9 +1454,9 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) */ function migrate_price_facture($db, $langs, $conf) { - $err=0; + $err = 0; - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); $db->begin(); @@ -1468,14 +1468,14 @@ function migrate_price_facture($db, $langs, $conf) // List of invoice lines not up to date $sql = "SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_tx as vatrate, fd.total_ttc, fd.info_bits,"; - $sql.= " f.rowid as facid, f.remise_percent as remise_percent_global, f.total_ttc as total_ttc_f"; - $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE fd.fk_facture = f.rowid"; - $sql.= " AND (((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL) or f.total_ttc IS NULL)"; + $sql .= " f.rowid as facid, f.remise_percent as remise_percent_global, f.total_ttc as total_ttc_f"; + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE fd.fk_facture = f.rowid"; + $sql .= " AND (((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL) or f.total_ttc IS NULL)"; //print $sql; dolibarr_install_syslog("upgrade2::migrate_price_facture"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1496,10 +1496,10 @@ function migrate_price_facture($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $facligne= new FactureLigne($db); + $facligne = new FactureLigne($db); $facligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $facligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $facligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1508,20 +1508,20 @@ function migrate_price_facture($db, $langs, $conf) $facligne->total_tva = $total_tva; $facligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: line " . $rowid . ": facid=" . $obj->facid . " pu=" . $pu ." qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global . " -> " . $total_ht . ", " . $total_tva . ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: line ".$rowid.": facid=".$obj->facid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $facligne->update_total(); /* On touche a facture mere uniquement si total_ttc = 0 */ - if (! $total_ttc_f) + if (!$total_ttc_f) { $facture = new Facture($db); - $facture->id=$obj->facid; + $facture->id = $obj->facid; - if ( $facture->fetch($facture->id) >= 0) + if ($facture->fetch($facture->id) >= 0) { - if ( $facture->update_price() > 0 ) + if ($facture->update_price() > 0) { //print $facture->id; } @@ -1573,7 +1573,7 @@ function migrate_price_facture($db, $langs, $conf) */ function migrate_price_propal($db, $langs, $conf) { - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); $db->begin(); @@ -1585,13 +1585,13 @@ function migrate_price_propal($db, $langs, $conf) // List of proposal lines not up to date $sql = "SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as vatrate, pd.info_bits,"; - $sql.= " p.rowid as propalid, p.remise_percent as remise_percent_global"; - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p"; - $sql.= " WHERE pd.fk_propal = p.rowid"; - $sql.= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)"; + $sql .= " p.rowid as propalid, p.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p"; + $sql .= " WHERE pd.fk_propal = p.rowid"; + $sql .= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_propal"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1611,10 +1611,10 @@ function migrate_price_propal($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $propalligne= new PropaleLigne($db); + $propalligne = new PropaleLigne($db); $propalligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $propalligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $propalligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1623,7 +1623,7 @@ function migrate_price_propal($db, $langs, $conf) $propalligne->total_tva = $total_tva; $propalligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . ": propalid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global . " -> " . $total_ht . ", " . $total_tva. ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": propalid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $propalligne->update_total(); @@ -1683,9 +1683,9 @@ function migrate_price_contrat($db, $langs, $conf) { $db->begin(); - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); - if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id=0; // Ti not have this set to '' or will make sql syntax error. + if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id = 0; // Ti not have this set to '' or will make sql syntax error. print ''; print ''; @@ -3722,7 +3722,7 @@ function migrate_categorie_association($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT fk_categorie_mere, fk_categorie_fille"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."categorie_association"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."categorie_association"; $resql = $db->query($sqlSelect); if ($resql) @@ -3737,11 +3737,11 @@ function migrate_categorie_association($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."categorie SET "; - $sqlUpdate.= "fk_parent = ".$obj->fk_categorie_mere; - $sqlUpdate.= " WHERE rowid = ".$obj->fk_categorie_fille; + $sqlUpdate .= "fk_parent = ".$obj->fk_categorie_mere; + $sqlUpdate .= " WHERE rowid = ".$obj->fk_categorie_fille; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3755,7 +3755,7 @@ function migrate_categorie_association($db, $langs, $conf) print $langs->trans('AlreadyDone')."
        \n"; } - if (! $error) + if (!$error) { // TODO DROP table in the next release /* @@ -3813,10 +3813,10 @@ function migrate_event_assignement($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT a.id, a.fk_user_action"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action"; - $sqlSelect.= " WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user')"; - $sqlSelect.= " ORDER BY a.id"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sqlSelect .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action"; + $sqlSelect .= " WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user')"; + $sqlSelect .= " ORDER BY a.id"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -3832,10 +3832,10 @@ function migrate_event_assignement($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) "; - $sqlUpdate.= "VALUES(".$obj->id.", 'user', ".$obj->fk_user_action.")"; + $sqlUpdate .= "VALUES(".$obj->id.", 'user', ".$obj->fk_user_action.")"; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3849,7 +3849,7 @@ function migrate_event_assignement($db, $langs, $conf) print $langs->trans('AlreadyDone')."
        \n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -3890,10 +3890,10 @@ function migrate_event_assignement_contact($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT a.id, a.fk_contact"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople' AND ar.fk_element = a.fk_contact"; - $sqlSelect.= " WHERE fk_contact > 0 AND fk_contact NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople')"; - $sqlSelect.= " ORDER BY a.id"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sqlSelect .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople' AND ar.fk_element = a.fk_contact"; + $sqlSelect .= " WHERE fk_contact > 0 AND fk_contact NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople')"; + $sqlSelect .= " ORDER BY a.id"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -3909,10 +3909,10 @@ function migrate_event_assignement_contact($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) "; - $sqlUpdate.= "VALUES(".$obj->id.", 'socpeople', ".$obj->fk_contact.")"; + $sqlUpdate .= "VALUES(".$obj->id.", 'socpeople', ".$obj->fk_contact.")"; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3926,7 +3926,7 @@ function migrate_event_assignement_contact($db, $langs, $conf) print $langs->trans('AlreadyDone')."
        \n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -3972,7 +3972,7 @@ function migrate_reset_blocked_log($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT DISTINCT entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."blockedlog"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."blockedlog"; //print $sqlSelect; @@ -4001,9 +4001,9 @@ function migrate_reset_blocked_log($db, $langs, $conf) print ' - Record for entity must be reset...'; $sqlUpdate = "DELETE FROM ".MAIN_DB_PREFIX."blockedlog"; - $sqlUpdate.= " WHERE entity = " . $obj->entity; - $resqlUpdate=$db->query($sqlUpdate); - if (! $resqlUpdate) + $sqlUpdate .= " WHERE entity = ".$obj->entity; + $resqlUpdate = $db->query($sqlUpdate); + if (!$resqlUpdate) { $error++; dol_print_error($db); @@ -4011,18 +4011,18 @@ function migrate_reset_blocked_log($db, $langs, $conf) else { // Add set line - $object=new stdClass(); + $object = new stdClass(); $object->id = 1; $object->element = 'module'; $object->ref = 'systemevent'; $object->entity = $obj->entity; $object->date = dol_now(); - $b=new BlockedLog($db); + $b = new BlockedLog($db); $b->setObjectData($object, 'MODULE_SET', 0); $res = $b->create($user); - if ($res<=0) { + if ($res <= 0) { $error++; } } @@ -4045,7 +4045,7 @@ function migrate_reset_blocked_log($db, $langs, $conf) print $langs->trans('NothingToDo')."
        \n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4086,8 +4086,8 @@ function migrate_remise_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT sr.rowid, s.entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."societe_remise as sr, ".MAIN_DB_PREFIX."societe as s"; - $sqlSelect.= " WHERE sr.fk_soc = s.rowid and sr.entity != s.entity"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."societe_remise as sr, ".MAIN_DB_PREFIX."societe as s"; + $sqlSelect .= " WHERE sr.fk_soc = s.rowid and sr.entity != s.entity"; //print $sqlSelect; @@ -4104,11 +4104,11 @@ function migrate_remise_entity($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise SET"; - $sqlUpdate.= " entity = " . $obj->entity; - $sqlUpdate.= " WHERE rowid = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj->entity; + $sqlUpdate .= " WHERE rowid = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4123,7 +4123,7 @@ function migrate_remise_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
        \n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4163,7 +4163,7 @@ function migrate_remise_except_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT sr.rowid, sr.fk_soc, sr.fk_facture_source, sr.fk_facture, sr.fk_facture_line"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -4183,21 +4183,21 @@ function migrate_remise_except_entity($db, $langs, $conf) $fk_facture = (!empty($obj->fk_facture_source) ? $obj->fk_facture_source : $obj->fk_facture); $sqlSelect2 = "SELECT f.entity"; - $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sqlSelect2.= " WHERE f.rowid = " . $fk_facture; + $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sqlSelect2 .= " WHERE f.rowid = ".$fk_facture; } elseif (!empty($obj->fk_facture_line)) { $sqlSelect2 = "SELECT f.entity"; - $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; - $sqlSelect2.= " WHERE fd.rowid = " . $obj->fk_facture_line; - $sqlSelect2.= " AND fd.fk_facture = f.rowid"; + $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; + $sqlSelect2 .= " WHERE fd.rowid = ".$obj->fk_facture_line; + $sqlSelect2 .= " AND fd.fk_facture = f.rowid"; } else { $sqlSelect2 = "SELECT s.entity"; - $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sqlSelect2.= " WHERE s.rowid = " . $obj->fk_soc; + $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sqlSelect2 .= " WHERE s.rowid = ".$obj->fk_soc; } $resql2 = $db->query($sqlSelect2); @@ -4208,11 +4208,11 @@ function migrate_remise_except_entity($db, $langs, $conf) $obj2 = $db->fetch_object($resql2); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except SET"; - $sqlUpdate.= " entity = " . $obj2->entity; - $sqlUpdate.= " WHERE rowid = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj2->entity; + $sqlUpdate .= " WHERE rowid = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4234,7 +4234,7 @@ function migrate_remise_except_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
        \n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4274,8 +4274,8 @@ function migrate_user_rights_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT u.rowid, u.entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sqlSelect.= " WHERE u.entity > 1"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sqlSelect .= " WHERE u.entity > 1"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -4291,11 +4291,11 @@ function migrate_user_rights_entity($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."user_rights SET"; - $sqlUpdate.= " entity = " . $obj->entity; - $sqlUpdate.= " WHERE fk_user = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj->entity; + $sqlUpdate .= " WHERE fk_user = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4310,7 +4310,7 @@ function migrate_user_rights_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
        \n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4350,8 +4350,8 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT u.rowid, u.entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."usergroup as u"; - $sqlSelect.= " WHERE u.entity > 1"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."usergroup as u"; + $sqlSelect .= " WHERE u.entity > 1"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -4367,11 +4367,11 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."usergroup_rights SET"; - $sqlUpdate.= " entity = " . $obj->entity; - $sqlUpdate.= " WHERE fk_usergroup = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj->entity; + $sqlUpdate .= " WHERE fk_usergroup = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4386,7 +4386,7 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
        \n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4419,9 +4419,9 @@ function migrate_rename_directories($db, $langs, $conf, $oldname, $newname) { dolibarr_install_syslog("upgrade2::migrate_rename_directories"); - if (is_dir(DOL_DATA_ROOT.$oldname) && ! file_exists(DOL_DATA_ROOT.$newname)) + if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname)) { - dolibarr_install_syslog("upgrade2::migrate_rename_directories move " . DOL_DATA_ROOT . $oldname . ' into ' . DOL_DATA_ROOT . $newname); + dolibarr_install_syslog("upgrade2::migrate_rename_directories move ".DOL_DATA_ROOT.$oldname.' into '.DOL_DATA_ROOT.$newname); @rename(DOL_DATA_ROOT.$oldname, DOL_DATA_ROOT.$newname); } } @@ -4496,9 +4496,9 @@ function migrate_delete_old_files($db, $langs, $conf) $result = 1; if (file_exists(DOL_DOCUMENT_ROOT.$filetodelete)) { $result = dol_delete_file(DOL_DOCUMENT_ROOT.$filetodelete, 0, 0, 0, null, true, false); - if (! $result) { + if (!$result) { $langs->load("errors"); - print '
        '.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteFile", DOL_DOCUMENT_ROOT . $filetodelete); + print '
        '.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteFile", DOL_DOCUMENT_ROOT.$filetodelete); print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'
        '; } else { //print $langs->trans("FileWasRemoved", $filetodelete).'
        '; @@ -4523,7 +4523,7 @@ function migrate_delete_old_dir($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_delete_old_dir"); // List of files to delete - $filetodeletearray=array( + $filetodeletearray = array( DOL_DOCUMENT_ROOT.'/core/modules/facture/terre', DOL_DOCUMENT_ROOT.'/core/modules/facture/mercure', ); @@ -4533,7 +4533,7 @@ function migrate_delete_old_dir($db, $langs, $conf) if (file_exists($filetodelete)) { $result = dol_delete_dir_recursive($filetodelete); } - if (! $result) { + if (!$result) { $langs->load("errors"); print '
        '.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteDir", $filetodelete); print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'
        '; @@ -4561,18 +4561,18 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".join(',', array_keys($listofmodule))); - foreach($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' + foreach ($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' { - if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && ! $force)) continue; // Discard reload if module not enabled + if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && !$force)) continue; // Discard reload if module not enabled - $mod=null; + $mod = null; if ($moduletoreload == 'MAIN_MODULE_AGENDA') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Agenda module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modAgenda.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modAgenda.class.php'; if ($res) { - $mod=new modAgenda($db); + $mod = new modAgenda($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4580,9 +4580,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_API') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Rest API module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; if ($res) { - $mod=new modApi($db); + $mod = new modApi($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4590,9 +4590,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_BARCODE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Barcode module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; if ($res) { - $mod=new modBarcode($db); + $mod = new modBarcode($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4600,9 +4600,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_CRON') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; if ($res) { - $mod=new modCron($db); + $mod = new modCron($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4610,9 +4610,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_SOCIETE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Societe module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; if ($res) { - $mod=new modSociete($db); + $mod = new modSociete($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4620,9 +4620,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Produit module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; if ($res) { - $mod=new modProduct($db); + $mod = new modProduct($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4630,9 +4630,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Service module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; if ($res) { - $mod=new modService($db); + $mod = new modService($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4640,9 +4640,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Commande module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; if ($res) { - $mod=new modCommande($db); + $mod = new modCommande($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4650,9 +4650,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Facture module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; if ($res) { - $mod=new modFacture($db); + $mod = new modFacture($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4660,9 +4660,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Fournisseur module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; if ($res) { - $mod=new modFournisseur($db); + $mod = new modFournisseur($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4670,9 +4670,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Leave Request module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; if ($res) { - $mod=new modHoliday($db); + $mod = new modHoliday($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4680,9 +4680,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Deplacement module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; if ($res) { - $mod=new modDeplacement($db); + $mod = new modDeplacement($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4690,9 +4690,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Don module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; if ($res) { - $mod=new modDon($db); + $mod = new modDon($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4700,47 +4700,47 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate ECM module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; if ($res) { - $mod=new modECM($db); - $mod->remove('noboxes'); // We need to remove because a permission id has been removed + $mod = new modECM($db); + $mod->remove('noboxes'); // We need to remove because a permission id has been removed $mod->init($reloadmode); } } elseif ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Paybox module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; if ($res) { - $mod=new modPaybox($db); - $mod->remove('noboxes'); // We need to remove because id of module has changed + $mod = new modPaybox($db); + $mod->remove('noboxes'); // We need to remove because id of module has changed $mod->init($reloadmode); } } elseif ($moduletoreload == 'MAIN_MODULE_SUPPLIERPROPOSAL') // Module after 3.5 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Supplier Proposal module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSupplierProposal.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modSupplierProposal.class.php'; if ($res) { - $mod=new modSupplierProposal($db); - $mod->remove('noboxes'); // We need to remove because id of module has changed + $mod = new modSupplierProposal($db); + $mod->remove('noboxes'); // We need to remove because id of module has changed $mod->init($reloadmode); } } elseif ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; if ($res) { - $mod=new modOpenSurvey($db); - $mod->remove('noboxes'); // We need to remove because menu entries has changed + $mod = new modOpenSurvey($db); + $mod->remove('noboxes'); // We need to remove because menu entries has changed $mod->init($reloadmode); } } else { $tmp = preg_match('/MAIN_MODULE_([a-zA-Z0-9]+)/', $moduletoreload, $reg); - if (! empty($reg[1])) + if (!empty($reg[1])) { if (strtoupper($moduletoreload) == $moduletoreload) // If key is un uppercase { @@ -4751,10 +4751,10 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $moduletoreloadshort = $reg[1]; } dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort." with mode ".$reloadmode); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'; if ($res) { $classname = 'mod'.$moduletoreloadshort; - $mod=new $classname($db); + $mod = new $classname($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4762,10 +4762,10 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo { dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'); - $res=@dol_include_once(strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php'); + $res = @dol_include_once(strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php'); if ($res) { $classname = 'mod'.$moduletoreloadshort; - $mod=new $classname($db); + $mod = new $classname($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4782,11 +4782,11 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo } } - if (! empty($mod) && is_object($mod)) + if (!empty($mod) && is_object($mod)) { print '
        '; @@ -4811,11 +4811,11 @@ function migrate_reload_menu($db, $langs, $conf, $versionto) dolibarr_install_syslog("upgrade2::migrate_reload_menu"); // Define list of menu handlers to initialize - $listofmenuhandler=array(); + $listofmenuhandler = array(); if ($conf->global->MAIN_MENU_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENU_SMARTPHONE == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') { - $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers + $listofmenuhandler['auguria'] = 1; // We set here only dynamic menu handlers } foreach ($listofmenuhandler as $key => $val) @@ -4828,10 +4828,10 @@ function migrate_reload_menu($db, $langs, $conf, $versionto) // Load sql ini_menu_handler.sql file $dir = DOL_DOCUMENT_ROOT."/core/menus/"; - $file='init_menu_'.$key.'.sql'; + $file = 'init_menu_'.$key.'.sql'; if (file_exists($dir.$file)) { - $result=run_sql($dir.$file, 1, '', 1, $key); + $result = run_sql($dir.$file, 1, '', 1, $key); } print ''; @@ -4854,9 +4854,9 @@ function migrate_user_photospath() include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $fuser = new User($db); - if (! is_object($user)) $user = $fuser; // To avoid error during migration + if (!is_object($user)) $user = $fuser; // To avoid error during migration - $sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users + $sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users $resql = $db->query($sql); if ($resql) { @@ -4866,25 +4866,25 @@ function migrate_user_photospath() //echo '
        '.$fuser->id.' -> '.$fuser->entity; $entity = (empty($fuser->entity) ? 1 : $fuser->entity); if ($entity > 1) { - $dir = DOL_DATA_ROOT . '/' . $entity . '/users'; + $dir = DOL_DATA_ROOT.'/'.$entity.'/users'; } else { - $dir = $conf->user->multidir_output[$entity]; // $conf->user->multidir_output[] for each entity is construct by the multicompany module + $dir = $conf->user->multidir_output[$entity]; // $conf->user->multidir_output[] for each entity is construct by the multicompany module } if ($dir) { //print "Process user id ".$fuser->id."
        \n"; - $origin = $dir .'/'. get_exdir($fuser->id, 2, 0, 1, $fuser, 'user'); // Use old behaviour to get x/y path - $destin = $dir .'/'. $fuser->id; + $origin = $dir.'/'.get_exdir($fuser->id, 2, 0, 1, $fuser, 'user'); // Use old behaviour to get x/y path + $destin = $dir.'/'.$fuser->id; - $origin_osencoded=dol_osencode($origin); + $origin_osencoded = dol_osencode($origin); dol_mkdir($destin); //echo '
        '.$origin.' -> '.$destin; if (dol_is_dir($origin)) { - $handle=opendir($origin_osencoded); + $handle = opendir($origin_osencoded); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) @@ -4899,7 +4899,7 @@ function migrate_user_photospath() dol_mkdir($destin.'/'.$file); while (($thumb = readdir($thumbs)) !== false) { - if (! dol_is_file($destin.'/'.$file.'/'.$thumb)) + if (!dol_is_file($destin.'/'.$file.'/'.$thumb)) { if ($thumb == '.' || $thumb == '..') continue; @@ -4914,7 +4914,7 @@ function migrate_user_photospath() } else // it is a file { - if (! dol_is_file($destin.'/'.$file)) + if (!dol_is_file($destin.'/'.$file)) { //print $origin.'/'.$file.' -> '.$destin.'/'.$file.'
        '."\n"; print '.'; diff --git a/htdocs/loan/calcmens.php b/htdocs/loan/calcmens.php index 5cde353105f..9a95ec9d438 100644 --- a/htdocs/loan/calcmens.php +++ b/htdocs/loan/calcmens.php @@ -22,42 +22,42 @@ * \brief File to return datables output */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../main.inc.php'; require DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; -$mens=GETPOST('mens'); -$capital=GETPOST('capital'); -$rate=GETPOST('rate'); -$echance=GETPOST('echeance'); -$nbterm=GETPOST('nbterm'); +$mens = GETPOST('mens'); +$capital = GETPOST('capital'); +$rate = GETPOST('rate'); +$echance = GETPOST('echeance'); +$nbterm = GETPOST('nbterm'); top_httphead(); -$output=array(); +$output = array(); $object = new LoanSchedule($db); -$int = ($capital*($rate/12)); +$int = ($capital * ($rate / 12)); $int = round($int, 2, PHP_ROUND_HALF_UP); -$cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP); -$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens); +$cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); +$output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1), 'mens'=>$mens); $echance++; -$capital=$cap_rest; -while ($echance<=$nbterm) { - $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm-$echance+1), 2, PHP_ROUND_HALF_UP); +$capital = $cap_rest; +while ($echance <= $nbterm) { + $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm - $echance + 1), 2, PHP_ROUND_HALF_UP); - $int = ($capital*($rate/12)); + $int = ($capital * ($rate / 12)); $int = round($int, 2, PHP_ROUND_HALF_UP); - $cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP); + $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); - $output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens); + $output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1), 'mens'=>$mens); - $capital=$cap_rest; + $capital = $cap_rest; $echance++; } diff --git a/htdocs/opensurvey/wizard/choix_autre.php b/htdocs/opensurvey/wizard/choix_autre.php index a8a1f8248d1..f8a3e13b80a 100644 --- a/htdocs/opensurvey/wizard/choix_autre.php +++ b/htdocs/opensurvey/wizard/choix_autre.php @@ -40,19 +40,19 @@ if (!$user->rights->opensurvey->write) accessforbidden(); if (isset($_SESSION["nbrecases"])) { for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { if (isset($_POST["choix"][$i])) { - $_SESSION["choix$i"]=$_POST["choix"][$i]; + $_SESSION["choix$i"] = $_POST["choix"][$i]; } if (isset($_POST["typecolonne"][$i])) { - $_SESSION["typecolonne$i"]=$_POST["typecolonne"][$i]; + $_SESSION["typecolonne$i"] = $_POST["typecolonne"][$i]; } } } else { //nombre de cases par défaut - $_SESSION["nbrecases"]=5; + $_SESSION["nbrecases"] = 5; } if (GETPOST("ajoutcases") || GETPOST("ajoutcases_x")) { - $_SESSION["nbrecases"]=$_SESSION["nbrecases"]+5; + $_SESSION["nbrecases"] = $_SESSION["nbrecases"] + 5; } // Create survey into database @@ -62,23 +62,23 @@ if (isset($_POST["confirmecreation"])) $toutchoix = ''; for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++) { - if (! empty($_POST["choix"][$i])) + if (!empty($_POST["choix"][$i])) { - $toutchoix.=','; - $toutchoix.=str_replace(array(",","@"), " ", $_POST["choix"][$i]).(empty($_POST["typecolonne"][$i])?'':'@'.$_POST["typecolonne"][$i]); + $toutchoix .= ','; + $toutchoix .= str_replace(array(",", "@"), " ", $_POST["choix"][$i]).(empty($_POST["typecolonne"][$i]) ? '' : '@'.$_POST["typecolonne"][$i]); } } - $toutchoix=substr("$toutchoix", 1); - $_SESSION["toutchoix"]=$toutchoix; + $toutchoix = substr("$toutchoix", 1); + $_SESSION["toutchoix"] = $toutchoix; //test de remplissage des cases $testremplissage = ''; - for ($i=0;$i<$_SESSION["nbrecases"];$i++) + for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { if (isset($_POST["choix"][$i])) { - $testremplissage="ok"; + $testremplissage = "ok"; } } @@ -87,7 +87,7 @@ if (isset($_POST["confirmecreation"])) setEventMessages($langs->trans("ErrorOpenSurveyOneChoice"), null, 'errors'); } else { //format du sondage AUTRE - $_SESSION["formatsondage"]="A"; + $_SESSION["formatsondage"] = "A"; // Add into database ajouter_sondage(); @@ -101,10 +101,10 @@ if (isset($_POST["confirmecreation"])) * View */ -$form=new Form($db); +$form = new Form($db); -$arrayofjs=array(); -$arrayofcss=array('/opensurvey/css/style.css'); +$arrayofjs = array(); +$arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss); if (empty($_SESSION['titre'])) @@ -123,7 +123,7 @@ print ''."\n"; print load_fiche_titre($langs->trans("CreatePoll").' (2 / 2)'); -print '
        '. $langs->trans("PollOnChoice") .'

        '."\n"; +print '
        '.$langs->trans("PollOnChoice").'

        '."\n"; print '
        '."\n"; print '
        '.$langs->trans("ErrorFailedToConnectToDatabase", $conf->db->name).''.$langs->trans('Error').'
        '; print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("None"); @@ -560,8 +560,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a // Copy directory medias - $srcroot=DOL_DOCUMENT_ROOT.'/install/medias'; - $destroot=DOL_DATA_ROOT.'/medias'; + $srcroot = DOL_DOCUMENT_ROOT.'/install/medias'; + $destroot = DOL_DATA_ROOT.'/medias'; dolCopyDir($srcroot, $destroot, 0, 0); @@ -581,12 +581,12 @@ else $error++; } -$ret=0; -if ($error && isset($argv[1])) $ret=1; +$ret = 0; +if ($error && isset($argv[1])) $ret = 1; dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("--- upgrade2: end"); -pFooter($error?2:0, $setuplang); +pFooter($error ? 2 : 0, $setuplang); if ($db->connected) $db->close(); @@ -630,7 +630,7 @@ function migrate_paiements($db, $langs, $conf) while ($i < $num) { $obj = $db->fetch_object($resql); - $row[$i][0] = $obj->rowid ; + $row[$i][0] = $obj->rowid; $row[$i][1] = $obj->fk_facture; $row[$i][2] = $obj->amount; $i++; @@ -647,11 +647,11 @@ function migrate_paiements($db, $langs, $conf) if ($db->begin()) { $res = 0; - $num=count($row); + $num = count($row); for ($i = 0; $i < $num; $i++) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql.= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")"; + $sql .= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")"; $res += $db->query($sql); @@ -710,13 +710,13 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) { // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; - $sql.= " bu2.url_id as socid"; - $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; - $sql.= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid"; - $sql.= " AND b.rappro = 1"; - $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; + $sql .= " bu2.url_id as socid"; + $sql .= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; + $sql .= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid"; + $sql .= " AND b.rappro = 1"; + $sql .= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; $resql = $db->query($sql); @@ -732,7 +732,7 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) $obj = $db->fetch_object($resql); if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas { - $row[$j]['paymentid'] = $obj->rowid ; // paymentid + $row[$j]['paymentid'] = $obj->rowid; // paymentid $row[$j]['pamount'] = $obj->pamount; $row[$j]['fk_bank'] = $obj->fk_bank; $row[$j]['bamount'] = $obj->bamount; @@ -754,30 +754,30 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) $db->begin(); $res = 0; - $num=count($row); + $num = count($row); for ($i = 0; $i < $num; $i++) { if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
        '; // On cherche facture sans lien paiement et du meme montant et pour meme societe. - $sql=" SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql.=" WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; - $sql.=" AND pf.fk_facture IS NULL"; - $sql.=" ORDER BY f.fk_statut"; + $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; + $sql .= " AND pf.fk_facture IS NULL"; + $sql .= " ORDER BY f.fk_statut"; //print $sql.'
        '; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); //print 'Nb of invoice found for this amount and company :'.$num.'
        '; if ($num >= 1) { - $obj=$db->fetch_object($resql); - $facid=$obj->rowid; + $obj = $db->fetch_object($resql); + $facid = $obj->rowid; $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql.= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; + $sql .= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; $res += $db->query($sql); @@ -837,12 +837,12 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) { // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; - $sql.= " bu2.url_id as socid"; - $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; - $sql.= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid"; - $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; + $sql .= " bu2.url_id as socid"; + $sql .= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; + $sql .= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid"; + $sql .= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; $resql = $db->query($sql); @@ -858,7 +858,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $obj = $db->fetch_object($resql); if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas { - $row[$j]['paymentid'] = $obj->rowid ; // paymentid + $row[$j]['paymentid'] = $obj->rowid; // paymentid $row[$j]['pamount'] = $obj->pamount; $row[$j]['fk_bank'] = $obj->fk_bank; $row[$j]['bamount'] = $obj->bamount; @@ -874,9 +874,9 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) dol_print_error($db); } - $nberr=0; + $nberr = 0; - $num=count($row); + $num = count($row); if ($num) { print $langs->trans('OrphelinsPaymentsDetectedByMethod', 2).': '.count($row)."
        \n"; @@ -888,24 +888,24 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
        '; // On cherche facture sans lien paiement et du meme montant et pour meme societe. - $sql=" SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql.=" WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; - $sql.=" AND pf.fk_facture IS NULL"; - $sql.=" ORDER BY f.fk_statut"; + $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; + $sql .= " AND pf.fk_facture IS NULL"; + $sql .= " ORDER BY f.fk_statut"; //print $sql.'
        '; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); //print 'Nb of invoice found for this amount and company :'.$num.'
        '; if ($num >= 1) { - $obj=$db->fetch_object($resql); - $facid=$obj->rowid; + $obj = $db->fetch_object($resql); + $facid = $obj->rowid; $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql.= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; + $sql .= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; $res += $db->query($sql); print $langs->trans('MigrationProcessPaymentUpdate', 'facid='.$facid.'-paymentid='.$row[$i]['paymentid'].'-amount='.$row[$i]['pamount'])."
        \n"; @@ -971,19 +971,19 @@ function migrate_contracts_det($db, $langs, $conf) { print '
        '; - $nberr=0; + $nberr = 0; print '
        '; print ''.$langs->trans('MigrationContractsUpdate')."
        \n"; $sql = "SELECT c.rowid as cref, c.date_contrat, c.statut, c.mise_en_service, c.fin_validite, c.date_cloture, c.fk_product, c.fk_facture, c.fk_user_author,"; - $sql.= " p.ref, p.label, p.description, p.price, p.tva_tx, p.duration, cd.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p"; - $sql.= " ON c.fk_product = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " ON c.rowid=cd.fk_contrat"; - $sql.= " WHERE cd.rowid IS NULL AND p.rowid IS NOT NULL"; + $sql .= " p.ref, p.label, p.description, p.price, p.tva_tx, p.duration, cd.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p"; + $sql .= " ON c.fk_product = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " ON c.rowid=cd.fk_contrat"; + $sql .= " WHERE cd.rowid IS NULL AND p.rowid IS NOT NULL"; $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_contracts_det"); @@ -1003,20 +1003,20 @@ function migrate_contracts_det($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet ("; - $sql.= "fk_contrat, fk_product, statut, label, description,"; - $sql.= "date_ouverture_prevue, date_ouverture, date_fin_validite, tva_tx, qty,"; - $sql.= "subprice, price_ht, fk_user_author, fk_user_ouverture)"; - $sql.= " VALUES ("; - $sql.= $obj->cref.",".($obj->fk_product?$obj->fk_product:0).","; - $sql.= ($obj->mise_en_service?"4":"0").","; - $sql.= "'".$db->escape($obj->label)."', null,"; - $sql.= ($obj->mise_en_service?"'".$obj->mise_en_service."'":($obj->date_contrat?"'".$obj->date_contrat."'":"null")).","; - $sql.= ($obj->mise_en_service?"'".$obj->mise_en_service."'":"null").","; - $sql.= ($obj->fin_validite?"'".$obj->fin_validite."'":"null").","; - $sql.= "'".$obj->tva_tx."', 1,"; - $sql.= "'".$obj->price."', '".$obj->price."',".$obj->fk_user_author.","; - $sql.= ($obj->mise_en_service?$obj->fk_user_author:"null"); - $sql.= ")"; + $sql .= "fk_contrat, fk_product, statut, label, description,"; + $sql .= "date_ouverture_prevue, date_ouverture, date_fin_validite, tva_tx, qty,"; + $sql .= "subprice, price_ht, fk_user_author, fk_user_ouverture)"; + $sql .= " VALUES ("; + $sql .= $obj->cref.",".($obj->fk_product ? $obj->fk_product : 0).","; + $sql .= ($obj->mise_en_service ? "4" : "0").","; + $sql .= "'".$db->escape($obj->label)."', null,"; + $sql .= ($obj->mise_en_service ? "'".$obj->mise_en_service."'" : ($obj->date_contrat ? "'".$obj->date_contrat."'" : "null")).","; + $sql .= ($obj->mise_en_service ? "'".$obj->mise_en_service."'" : "null").","; + $sql .= ($obj->fin_validite ? "'".$obj->fin_validite."'" : "null").","; + $sql .= "'".$obj->tva_tx."', 1,"; + $sql .= "'".$obj->price."', '".$obj->price."',".$obj->fk_user_author.","; + $sql .= ($obj->mise_en_service ? $obj->fk_user_author : "null"); + $sql .= ")"; if ($db->query($sql)) { @@ -1031,7 +1031,7 @@ function migrate_contracts_det($db, $langs, $conf) $i++; } - if (! $nberr) + if (!$nberr) { // $db->rollback(); $db->commit(); @@ -1069,17 +1069,17 @@ function migrate_links_transfert($db, $langs, $conf) { print '
        '; - $nberr=0; + $nberr = 0; print '
        '; print ''.$langs->trans('MigrationBankTransfertsUpdate')."
        \n"; $sql = "SELECT ba.rowid as barowid, bb.rowid as bbrowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as bb, ".MAIN_DB_PREFIX."bank as ba"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = ba.rowid"; - $sql.= " WHERE ba.amount = -bb.amount AND ba.fk_account <> bb.fk_account"; - $sql.= " AND ba.datev = bb.datev AND ba.datec = bb.datec"; - $sql.= " AND bu.fk_bank IS NULL"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as bb, ".MAIN_DB_PREFIX."bank as ba"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = ba.rowid"; + $sql .= " WHERE ba.amount = -bb.amount AND ba.fk_account <> bb.fk_account"; + $sql .= " AND ba.datev = bb.datev AND ba.datec = bb.datec"; + $sql .= " AND bu.fk_bank IS NULL"; $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_links_transfert"); @@ -1099,16 +1099,16 @@ function migrate_links_transfert($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; - $sql.= "fk_bank, url_id, url, label, type"; - $sql.= ")"; - $sql.= " VALUES ("; - $sql.= $obj->barowid.",".$obj->bbrowid.", '/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'"; - $sql.= ")"; + $sql .= "fk_bank, url_id, url, label, type"; + $sql .= ")"; + $sql .= " VALUES ("; + $sql .= $obj->barowid.",".$obj->bbrowid.", '/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'"; + $sql .= ")"; print $sql.'
        '; dolibarr_install_syslog("migrate_links_transfert"); - if (! $db->query($sql)) + if (!$db->query($sql)) { dol_print_error($db); $nberr++; @@ -1117,7 +1117,7 @@ function migrate_links_transfert($db, $langs, $conf) $i++; } - if (! $nberr) + if (!$nberr) { // $db->rollback(); $db->commit(); @@ -1156,19 +1156,19 @@ function migrate_contracts_date1($db, $langs, $conf) print '
        '; print ''.$langs->trans('MigrationContractsEmptyDatesUpdate')."
        \n"; - $sql="update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; + $sql = "update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')."
        \n"; else print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')."
        \n"; - $sql="update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; + $sql = "update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')."
        \n"; else @@ -1184,16 +1184,16 @@ function migrate_contracts_date2($db, $langs, $conf) { print '
        '; - $nberr=0; + $nberr = 0; print '
        '; print ''.$langs->trans('MigrationContractsInvalidDatesUpdate')."
        \n"; $sql = "SELECT c.rowid as cref, c.datec, c.date_contrat, MIN(cd.date_ouverture) as datemin"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c,"; - $sql.= " ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " WHERE c.rowid=cd.fk_contrat AND cd.date_ouverture IS NOT NULL"; - $sql.= " GROUP BY c.rowid, c.date_contrat"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c,"; + $sql .= " ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " WHERE c.rowid=cd.fk_contrat AND cd.date_ouverture IS NOT NULL"; + $sql .= " GROUP BY c.rowid, c.date_contrat"; $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_contracts_date2"); @@ -1205,7 +1205,7 @@ function migrate_contracts_date2($db, $langs, $conf) if ($num) { - $nbcontratsmodifie=0; + $nbcontratsmodifie = 0; $db->begin(); while ($i < $num) @@ -1214,11 +1214,11 @@ function migrate_contracts_date2($db, $langs, $conf) if ($obj->date_contrat > $obj->datemin) { print $langs->trans('MigrationContractsInvalidDateFix', $obj->cref, $obj->date_contrat, $obj->datemin)."
        \n"; - $sql ="UPDATE ".MAIN_DB_PREFIX."contrat"; - $sql.=" SET date_contrat='".$obj->datemin."'"; - $sql.=" WHERE rowid=".$obj->cref; - $resql2=$db->query($sql); - if (! $resql2) dol_print_error($db); + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat"; + $sql .= " SET date_contrat='".$obj->datemin."'"; + $sql .= " WHERE rowid=".$obj->cref; + $resql2 = $db->query($sql); + if (!$resql2) dol_print_error($db); $nbcontratsmodifie++; } @@ -1256,10 +1256,10 @@ function migrate_contracts_date3($db, $langs, $conf) print '
        '; print ''.$langs->trans('MigrationContractsIncoherentCreationDateUpdate')."
        \n"; - $sql="update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; + $sql = "update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_date3"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')."
        \n"; else @@ -1284,10 +1284,10 @@ function migrate_contracts_open($db, $langs, $conf) print ''.$langs->trans('MigrationReopeningContracts')."
        \n"; $sql = "SELECT c.rowid as cref FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; + $sql .= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_open"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) { $i = 0; $row = array(); @@ -1295,7 +1295,7 @@ function migrate_contracts_open($db, $langs, $conf) if ($num) { - $nbcontratsmodifie=0; + $nbcontratsmodifie = 0; $db->begin(); while ($i < $num) @@ -1303,11 +1303,11 @@ function migrate_contracts_open($db, $langs, $conf) $obj = $db->fetch_object($resql); print $langs->trans('MigrationReopenThisContract', $obj->cref)."
        \n"; - $sql ="UPDATE ".MAIN_DB_PREFIX."contrat"; - $sql.=" SET statut=1"; - $sql.=" WHERE rowid=".$obj->cref; - $resql2=$db->query($sql); - if (! $resql2) dol_print_error($db); + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat"; + $sql .= " SET statut=1"; + $sql .= " WHERE rowid=".$obj->cref; + $resql2 = $db->query($sql); + if (!$resql2) dol_print_error($db); $nbcontratsmodifie++; @@ -1348,31 +1348,31 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $obj = $db->fetch_object($result); if ($obj) { - $error=0; - $nb=0; + $error = 0; + $nb = 0; $select_sql = 'SELECT rowid, fk_facture_fourn, amount'; - $select_sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn'; - $select_sql.= ' WHERE fk_facture_fourn IS NOT NULL'; + $select_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn'; + $select_sql .= ' WHERE fk_facture_fourn IS NOT NULL'; dolibarr_install_syslog("upgrade2::migrate_paiementfourn_facturefourn"); $select_resql = $db->query($select_sql); if ($select_resql) { $select_num = $db->num_rows($select_resql); - $i=0; + $i = 0; $var = true; // Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn - while (($i < $select_num) && (! $error)) + while (($i < $select_num) && (!$error)) { $var = !$var; $select_obj = $db->fetch_object($select_resql); // Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons. $check_sql = 'SELECT fk_paiementfourn, fk_facturefourn'; - $check_sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; - $check_sql.= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; + $check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; + $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; $check_resql = $db->query($check_sql); if ($check_resql) { @@ -1391,9 +1391,9 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) print '
        '.$select_obj->rowid.''.$select_obj->fk_facture_fourn.''.$select_obj->amount.'
        '; @@ -1694,13 +1694,13 @@ function migrate_price_contrat($db, $langs, $conf) // List of contract lines not up to date $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql.= " c.rowid as contratid"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " WHERE cd.fk_contrat = c.rowid"; - $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)"; + $sql .= " c.rowid as contratid"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " WHERE cd.fk_contrat = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_contrat"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1719,11 +1719,11 @@ function migrate_price_contrat($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $contratligne= new ContratLigne($db); + $contratligne = new ContratLigne($db); //$contratligne->fetch($rowid); Non requis car le update_total ne met a jour que chp redefinis $contratligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, 0, 'HT', $info_bits, $contratligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, 0, 'HT', $info_bits, $contratligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1732,7 +1732,7 @@ function migrate_price_contrat($db, $langs, $conf) $contratligne->total_tva = $total_tva; $contratligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . ": contratdetid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent. " -> " . $total_ht . ", " . $total_tva. " , " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": contratdetid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." -> ".$total_ht.", ".$total_tva." , ".$total_ttc); print ". "; $contratligne->update_total(); @@ -1772,7 +1772,7 @@ function migrate_price_commande($db, $langs, $conf) { $db->begin(); - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); print '
        '; @@ -1782,13 +1782,13 @@ function migrate_price_commande($db, $langs, $conf) // List of sales orders lines not up to date $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c"; - $sql.= " WHERE cd.fk_commande = c.rowid"; - $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; + $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c"; + $sql .= " WHERE cd.fk_commande = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_commande"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1808,10 +1808,10 @@ function migrate_price_commande($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $commandeligne= new OrderLine($db); + $commandeligne = new OrderLine($db); $commandeligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1820,7 +1820,7 @@ function migrate_price_commande($db, $langs, $conf) $commandeligne->total_tva = $total_tva; $commandeligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . " : commandeid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global. " -> " . $total_ht . ", " . $total_tva . ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid." : commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $commandeligne->update_total(); @@ -1889,7 +1889,7 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) { $db->begin(); - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); print '
        '; @@ -1899,13 +1899,13 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) // List of purchase order lines not up to date $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd, ".MAIN_DB_PREFIX."commande_fournisseur as c"; - $sql.= " WHERE cd.fk_commande = c.rowid"; - $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; + $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd, ".MAIN_DB_PREFIX."commande_fournisseur as c"; + $sql .= " WHERE cd.fk_commande = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1925,10 +1925,10 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $commandeligne= new CommandeFournisseurLigne($db); + $commandeligne = new CommandeFournisseurLigne($db); $commandeligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpsoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpsoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1937,7 +1937,7 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $commandeligne->total_tva = $total_tva; $commandeligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . ": commandeid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global . " -> " . $total_ht . ", " . $total_tva . ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $commandeligne->update_total(); @@ -2009,42 +2009,42 @@ function migrate_modeles($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_modeles"); - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $modellist=ModelePDFFactures::liste_modeles($db); - if (count($modellist)==0) + $modellist = ModelePDFFactures::liste_modeles($db); + if (count($modellist) == 0) { // Aucun model par defaut. - $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } } - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; - $modellist=ModelePDFCommandes::liste_modeles($db); - if (count($modellist)==0) + $modellist = ModelePDFCommandes::liste_modeles($db); + if (count($modellist) == 0) { // Aucun model par defaut. - $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } } - if (! empty($conf->expedition->enabled)) + if (!empty($conf->expedition->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; - $modellist=ModelePDFExpedition::liste_modeles($db); - if (count($modellist)==0) + $modellist = ModelePDFExpedition::liste_modeles($db); + if (count($modellist) == 0) { // Aucun model par defaut. - $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } } @@ -2091,8 +2091,8 @@ function migrate_commande_expedition($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)"; - $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; - $resql2=$db->query($sql); + $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; + $resql2 = $db->query($sql); if (!$resql2) { @@ -2155,9 +2155,9 @@ function migrate_commande_livraison($db, $langs, $conf) $db->begin(); $sql = "SELECT l.rowid, l.fk_commande"; - $sql.= ", c.ref_client, c.date_livraison"; - $sql.= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; - $sql.= " WHERE c.rowid = l.fk_commande"; + $sql .= ", c.ref_client, c.date_livraison"; + $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; + $sql .= " WHERE c.rowid = l.fk_commande"; $resql = $db->query($sql); if ($resql) { @@ -2171,16 +2171,16 @@ function migrate_commande_livraison($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)"; - $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; - $resql2=$db->query($sql); + $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; + $resql2 = $db->query($sql); if ($resql2) { $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlu.= " ref_client='".$obj->ref_client."'"; - $sqlu.= ", date_livraison='".$obj->date_livraison."'"; - $sqlu.= " WHERE rowid = ".$obj->rowid; - $resql3=$db->query($sqlu); + $sqlu .= " ref_client='".$obj->ref_client."'"; + $sqlu .= ", date_livraison='".$obj->date_livraison."'"; + $sqlu .= " WHERE rowid = ".$obj->rowid; + $resql3 = $db->query($sqlu); if (!$resql3) { $error++; @@ -2250,9 +2250,9 @@ function migrate_detail_livraison($db, $langs, $conf) $db->begin(); $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.subprice, cd.total_ht"; - $sql.= ", ld.fk_livraison"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; - $sql.= " WHERE ld.fk_commande_ligne = cd.rowid"; + $sql .= ", ld.fk_livraison"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; + $sql .= " WHERE ld.fk_commande_ligne = cd.rowid"; $resql = $db->query($sql); if ($resql) { @@ -2266,19 +2266,19 @@ function migrate_detail_livraison($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET"; - $sql.= " fk_product=".$obj->fk_product; - $sql.= ",description='".$db->escape($obj->description)."'"; - $sql.= ",subprice='".$obj->subprice."'"; - $sql.= ",total_ht='".$obj->total_ht."'"; - $sql.= " WHERE fk_commande_ligne = ".$obj->rowid; - $resql2=$db->query($sql); + $sql .= " fk_product=".$obj->fk_product; + $sql .= ",description='".$db->escape($obj->description)."'"; + $sql .= ",subprice='".$obj->subprice."'"; + $sql .= ",total_ht='".$obj->total_ht."'"; + $sql .= " WHERE fk_commande_ligne = ".$obj->rowid; + $resql2 = $db->query($sql); if ($resql2) { $sql = "SELECT total_ht"; - $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; - $sql.= " WHERE rowid = ".$obj->fk_livraison; - $resql3=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; + $sql .= " WHERE rowid = ".$obj->fk_livraison; + $resql3 = $db->query($sql); if ($resql3) { @@ -2286,9 +2286,9 @@ function migrate_detail_livraison($db, $langs, $conf) $total_ht = $obju->total_ht + $obj->total_ht; $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlu.= " total_ht='".$total_ht."'"; - $sqlu.= " WHERE rowid=".$obj->fk_livraison; - $resql4=$db->query($sqlu); + $sqlu .= " total_ht='".$total_ht."'"; + $sqlu .= " WHERE rowid=".$obj->fk_livraison; + $resql4 = $db->query($sqlu); if (!$resql4) { $error++; @@ -2365,8 +2365,8 @@ function migrate_stocks($db, $langs, $conf) $db->begin(); $sql = "SELECT SUM(reel) as total, fk_product"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; - $sql.= " GROUP BY fk_product"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " GROUP BY fk_product"; $resql = $db->query($sql); if ($resql) { @@ -2380,10 +2380,10 @@ function migrate_stocks($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; - $sql.= " stock = '".$obj->total."'"; - $sql.= " WHERE rowid=".$obj->fk_product; + $sql .= " stock = '".$obj->total."'"; + $sql .= " WHERE rowid=".$obj->fk_product; - $resql2=$db->query($sql); + $resql2 = $db->query($sql); if ($resql2) { } @@ -2440,9 +2440,9 @@ function migrate_menus($db, $langs, $conf) $db->begin(); $sql = "SELECT m.rowid, mc.action"; - $sql.= " FROM ".MAIN_DB_PREFIX."menu_constraint as mc, ".MAIN_DB_PREFIX."menu_const as md, ".MAIN_DB_PREFIX."menu as m"; - $sql.= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid"; - $sql.= " AND m.enabled = '1'"; + $sql .= " FROM ".MAIN_DB_PREFIX."menu_constraint as mc, ".MAIN_DB_PREFIX."menu_const as md, ".MAIN_DB_PREFIX."menu as m"; + $sql .= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid"; + $sql .= " AND m.enabled = '1'"; $resql = $db->query($sql); if ($resql) { @@ -2455,11 +2455,11 @@ function migrate_menus($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET"; - $sql.= " enabled = '".$obj->action."'"; - $sql.= " WHERE rowid=".$obj->rowid; - $sql.= " AND enabled = '1'"; + $sql .= " enabled = '".$obj->action."'"; + $sql .= " WHERE rowid=".$obj->rowid; + $sql .= " AND enabled = '1'"; - $resql2=$db->query($sql); + $resql2 = $db->query($sql); if ($resql2) { } @@ -2521,10 +2521,10 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $db->begin(); $sql = "SELECT c.fk_adresse_livraison, ce.fk_expedition"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."co_exp as ce"; - $sql.= " WHERE c.rowid = ce.fk_commande"; - $sql.= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."co_exp as ce"; + $sql .= " WHERE c.rowid = ce.fk_commande"; + $sql .= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; $resql = $db->query($sql); if ($resql) @@ -2539,10 +2539,10 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sql.= " fk_adresse_livraison = '".$obj->fk_adresse_livraison."'"; - $sql.= " WHERE rowid=".$obj->fk_expedition; + $sql .= " fk_adresse_livraison = '".$obj->fk_adresse_livraison."'"; + $sql .= " WHERE rowid=".$obj->fk_expedition; - $resql2=$db->query($sql); + $resql2 = $db->query($sql); if (!$resql2) { $error++; @@ -2595,7 +2595,7 @@ function migrate_restore_missing_links($db, $langs, $conf) if (($db->type == 'mysql' || $db->type == 'mysqli')) { - if (versioncompare($db->getVersionArray(), array(4,0)) < 0) + if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) { dolibarr_install_syslog("upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action"); return 0; @@ -2610,16 +2610,16 @@ function migrate_restore_missing_links($db, $langs, $conf) // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 1. - $table1='facturedet'; $field1='fk_remise_except'; - $table2='societe_remise_except'; $field2='fk_facture_line'; + $table1 = 'facturedet'; $field1 = 'fk_remise_except'; + $table2 = 'societe_remise_except'; $field2 = 'fk_facture_line'; $db->begin(); $sql = "SELECT t1.rowid, t1.".$field1." as field"; - $sql.= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; - $sql.= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; - $sql.= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; - $sql.= " WHERE t1.rowid = t2.".$field2.")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; + $sql .= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; + $sql .= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; + $sql .= " WHERE t1.rowid = t2.".$field2.")"; dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 1"); $resql = $db->query($sql); @@ -2636,11 +2636,11 @@ function migrate_restore_missing_links($db, $langs, $conf) print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
        '; $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET"; - $sql.= " ".$field2." = '".$obj->rowid."'"; - $sql.= " WHERE rowid=".$obj->field; + $sql .= " ".$field2." = '".$obj->rowid."'"; + $sql .= " WHERE rowid=".$obj->field; - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { $error++; dol_print_error($db); @@ -2675,16 +2675,16 @@ function migrate_restore_missing_links($db, $langs, $conf) print ''.$langs->trans('MigrationFixData')." (2)
        \n"; // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 2. - $table2='facturedet'; $field2='fk_remise_except'; - $table1='societe_remise_except'; $field1='fk_facture_line'; + $table2 = 'facturedet'; $field2 = 'fk_remise_except'; + $table1 = 'societe_remise_except'; $field1 = 'fk_facture_line'; $db->begin(); $sql = "SELECT t1.rowid, t1.".$field1." as field"; - $sql.= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; - $sql.= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; - $sql.= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; - $sql.= " WHERE t1.rowid = t2.".$field2.")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; + $sql .= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; + $sql .= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; + $sql .= " WHERE t1.rowid = t2.".$field2.")"; dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 2"); $resql = $db->query($sql); @@ -2701,11 +2701,11 @@ function migrate_restore_missing_links($db, $langs, $conf) print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
        '; $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET"; - $sql.= " ".$field2." = '".$obj->rowid."'"; - $sql.= " WHERE rowid=".$obj->field; + $sql .= " ".$field2." = '".$obj->rowid."'"; + $sql .= " WHERE rowid=".$obj->field; - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { $error++; dol_print_error($db); @@ -2776,22 +2776,22 @@ function migrate_project_user_resp($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; - $sql2.= "datecreate"; - $sql2.= ", statut"; - $sql2.= ", element_id"; - $sql2.= ", fk_c_type_contact"; - $sql2.= ", fk_socpeople"; - $sql2.= ") VALUES ("; - $sql2.= "'".$db->idate(dol_now())."'"; - $sql2.= ", '4'"; - $sql2.= ", ".$obj->rowid; - $sql2.= ", '160'"; - $sql2.= ", ".$obj->fk_user_resp; - $sql2.= ")"; + $sql2 .= "datecreate"; + $sql2 .= ", statut"; + $sql2 .= ", element_id"; + $sql2 .= ", fk_c_type_contact"; + $sql2 .= ", fk_socpeople"; + $sql2 .= ") VALUES ("; + $sql2 .= "'".$db->idate(dol_now())."'"; + $sql2 .= ", '4'"; + $sql2 .= ", ".$obj->rowid; + $sql2 .= ", '160'"; + $sql2 .= ", ".$obj->fk_user_resp; + $sql2 .= ")"; if ($obj->fk_user_resp > 0) { - $resql2=$db->query($sql2); + $resql2 = $db->query($sql2); if (!$resql2) { $error++; @@ -2871,20 +2871,20 @@ function migrate_project_task_actors($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; - $sql2.= "datecreate"; - $sql2.= ", statut"; - $sql2.= ", element_id"; - $sql2.= ", fk_c_type_contact"; - $sql2.= ", fk_socpeople"; - $sql2.= ") VALUES ("; - $sql2.= "'".$db->idate(dol_now())."'"; - $sql2.= ", '4'"; - $sql2.= ", ".$obj->fk_project_task; - $sql2.= ", '180'"; - $sql2.= ", ".$obj->fk_user; - $sql2.= ")"; + $sql2 .= "datecreate"; + $sql2 .= ", statut"; + $sql2 .= ", element_id"; + $sql2 .= ", fk_c_type_contact"; + $sql2 .= ", fk_socpeople"; + $sql2 .= ") VALUES ("; + $sql2 .= "'".$db->idate(dol_now())."'"; + $sql2 .= ", '4'"; + $sql2 .= ", ".$obj->fk_project_task; + $sql2 .= ", '180'"; + $sql2 .= ", ".$obj->fk_user; + $sql2 .= ")"; - $resql2=$db->query($sql2); + $resql2 = $db->query($sql2); if (!$resql2) { @@ -2950,12 +2950,12 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) { - dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = " . MAIN_DB_PREFIX . $table); + dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table); $db->begin(); $sqlSelect = "SELECT ".$fk_source.", ".$fk_target; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX.$table; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX.$table; $resql = $db->query($sqlSelect); if ($resql) @@ -2970,19 +2970,19 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sqlInsert.= "fk_source"; - $sqlInsert.= ", sourcetype"; - $sqlInsert.= ", fk_target"; - $sqlInsert.= ", targettype"; - $sqlInsert.= ") VALUES ("; - $sqlInsert.= $obj->$fk_source; - $sqlInsert.= ", '".$sourcetype."'"; - $sqlInsert.= ", ".$obj->$fk_target; - $sqlInsert.= ", '".$targettype."'"; - $sqlInsert.= ")"; + $sqlInsert .= "fk_source"; + $sqlInsert .= ", sourcetype"; + $sqlInsert .= ", fk_target"; + $sqlInsert .= ", targettype"; + $sqlInsert .= ") VALUES ("; + $sqlInsert .= $obj->$fk_source; + $sqlInsert .= ", '".$sourcetype."'"; + $sqlInsert .= ", ".$obj->$fk_target; + $sqlInsert .= ", '".$targettype."'"; + $sqlInsert .= ")"; - $result=$db->query($sqlInsert); - if (! $result) + $result = $db->query($sqlInsert); + if (!$result) { $error++; dol_print_error($db); @@ -3049,7 +3049,7 @@ function migrate_project_task_time($db, $langs, $conf) $db->begin(); $sql = "SELECT rowid, fk_task, task_duration"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; $resql = $db->query($sql); if ($resql) { @@ -3069,16 +3069,16 @@ function migrate_project_task_time($db, $langs, $conf) { // convert to second // only for int time and float time ex: 1,75 for 1h45 - list($hour,$min) = explode('.', $obj->task_duration); - $hour = $hour*60*60; - $min = ($min/100)*60*60; - $newtime = $hour+$min; + list($hour, $min) = explode('.', $obj->task_duration); + $hour = $hour * 60 * 60; + $min = ($min / 100) * 60 * 60; + $newtime = $hour + $min; $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; - $sql2.= " task_duration = ".$newtime; - $sql2.= " WHERE rowid = ".$obj->rowid; + $sql2 .= " task_duration = ".$newtime; + $sql2 .= " WHERE rowid = ".$obj->rowid; - $resql2=$db->query($sql2); + $resql2 = $db->query($sql2); if (!$resql2) { $error++; @@ -3086,12 +3086,12 @@ function migrate_project_task_time($db, $langs, $conf) } print ". "; $oldtime++; - if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime; + if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime; else $totaltime[$obj->fk_task] = $newtime; } else { - if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration; + if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration; else $totaltime[$obj->fk_task] = $obj->task_duration; } @@ -3102,13 +3102,13 @@ function migrate_project_task_time($db, $langs, $conf) { if ($oldtime > 0) { - foreach($totaltime as $taskid => $total_duration) + foreach ($totaltime as $taskid => $total_duration) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; - $sql.= " duration_effective = ".$total_duration; - $sql.= " WHERE rowid = ".$taskid; + $sql .= " duration_effective = ".$total_duration; + $sql .= " WHERE rowid = ".$taskid; - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) { $error++; @@ -3181,11 +3181,11 @@ function migrate_customerorder_shipping($db, $langs, $conf) if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) { $sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sqlSelect.= ", ".MAIN_DB_PREFIX."element_element as el"; - $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'"; - $sqlSelect.= " WHERE e.rowid = el.fk_target"; - $sqlSelect.= " AND el.targettype = 'shipping'"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sqlSelect .= ", ".MAIN_DB_PREFIX."element_element as el"; + $sqlSelect .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'"; + $sqlSelect .= " WHERE e.rowid = el.fk_target"; + $sqlSelect .= " AND el.targettype = 'shipping'"; $resql = $db->query($sqlSelect); if ($resql) @@ -3200,12 +3200,12 @@ function migrate_customerorder_shipping($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sqlUpdate.= " ref_customer = '".$obj->ref_client."'"; - $sqlUpdate.= ", date_delivery = '".($obj->date_livraison?$obj->date_livraison:'null')."'"; - $sqlUpdate.= " WHERE rowid = ".$obj->shipping_id; + $sqlUpdate .= " ref_customer = '".$obj->ref_client."'"; + $sqlUpdate .= ", date_delivery = '".($obj->date_livraison ? $obj->date_livraison : 'null')."'"; + $sqlUpdate .= " WHERE rowid = ".$obj->shipping_id; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3275,8 +3275,8 @@ function migrate_shipping_delivery($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT rowid, fk_expedition"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison"; - $sqlSelect.= " WHERE fk_expedition is not null"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."livraison"; + $sqlSelect .= " WHERE fk_expedition is not null"; $resql = $db->query($sqlSelect); if ($resql) @@ -3291,25 +3291,25 @@ function migrate_shipping_delivery($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sqlInsert.= "fk_source"; - $sqlInsert.= ", sourcetype"; - $sqlInsert.= ", fk_target"; - $sqlInsert.= ", targettype"; - $sqlInsert.= ") VALUES ("; - $sqlInsert.= $obj->fk_expedition; - $sqlInsert.= ", 'shipping'"; - $sqlInsert.= ", ".$obj->rowid; - $sqlInsert.= ", 'delivery'"; - $sqlInsert.= ")"; + $sqlInsert .= "fk_source"; + $sqlInsert .= ", sourcetype"; + $sqlInsert .= ", fk_target"; + $sqlInsert .= ", targettype"; + $sqlInsert .= ") VALUES ("; + $sqlInsert .= $obj->fk_expedition; + $sqlInsert .= ", 'shipping'"; + $sqlInsert .= ", ".$obj->rowid; + $sqlInsert .= ", 'delivery'"; + $sqlInsert .= ")"; - $result=$db->query($sqlInsert); + $result = $db->query($sqlInsert); if ($result) { $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET fk_expedition = NULL"; - $sqlUpdate.= " WHERE rowid = ".$obj->rowid; + $sqlUpdate .= " WHERE rowid = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3383,16 +3383,16 @@ function migrate_shipping_delivery2($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT l.rowid as delivery_id, e.ref_customer, e.date_delivery"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison as l,"; - $sqlSelect.= " ".MAIN_DB_PREFIX."element_element as el,"; - $sqlSelect.= " ".MAIN_DB_PREFIX."expedition as e"; - $sqlSelect.= " WHERE l.rowid = el.fk_target"; - $sqlSelect.= " AND el.targettype = 'delivery'"; - $sqlSelect.= " AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'"; - $sqlSelect.= " AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)"; // Useless to process this record if both are null + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."livraison as l,"; + $sqlSelect .= " ".MAIN_DB_PREFIX."element_element as el,"; + $sqlSelect .= " ".MAIN_DB_PREFIX."expedition as e"; + $sqlSelect .= " WHERE l.rowid = el.fk_target"; + $sqlSelect .= " AND el.targettype = 'delivery'"; + $sqlSelect .= " AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'"; + $sqlSelect .= " AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)"; // Useless to process this record if both are null // Add condition to know if we never migrate this record - $sqlSelect.= " AND (l.ref_customer IS NULL".($db->type!='pgsql'?" or l.ref_customer = ''":"").")"; - $sqlSelect.= " AND (l.date_delivery IS NULL".($db->type!='pgsql'?" or l.date_delivery = ''":"").")"; + $sqlSelect .= " AND (l.ref_customer IS NULL".($db->type != 'pgsql' ? " or l.ref_customer = ''" : "").")"; + $sqlSelect .= " AND (l.date_delivery IS NULL".($db->type != 'pgsql' ? " or l.date_delivery = ''" : "").")"; $resql = $db->query($sqlSelect); if ($resql) @@ -3407,12 +3407,12 @@ function migrate_shipping_delivery2($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlUpdate.= " ref_customer = '".$obj->ref_customer."',"; - $sqlUpdate.= " date_delivery = ".($obj->date_delivery?"'".$obj->date_delivery."'":'null'); - $sqlUpdate.= " WHERE rowid = ".$obj->delivery_id; + $sqlUpdate .= " ref_customer = '".$obj->ref_customer."',"; + $sqlUpdate .= " date_delivery = ".($obj->date_delivery ? "'".$obj->date_delivery."'" : 'null'); + $sqlUpdate .= " WHERE rowid = ".$obj->delivery_id; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3469,21 +3469,21 @@ function migrate_actioncomm_element($db, $langs, $conf) 'invoice_supplier' => 'fk_supplier_invoice' ); - foreach($elements as $type => $field) + foreach ($elements as $type => $field) { $result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm", $field); $obj = $db->fetch_object($result); if ($obj) { - dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=" . $field); + dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field); $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm SET "; - $sql.= "fk_element = ".$field.", elementtype = '".$type."'"; - $sql.= " WHERE ".$field." IS NOT NULL"; - $sql.= " AND fk_element IS NULL"; - $sql.= " AND elementtype IS NULL"; + $sql .= "fk_element = ".$field.", elementtype = '".$type."'"; + $sql .= " WHERE ".$field." IS NOT NULL"; + $sql .= " AND fk_element IS NULL"; + $sql .= " AND elementtype IS NULL"; $resql = $db->query($sql); if ($resql) @@ -3527,23 +3527,23 @@ function migrate_mode_reglement($db, $langs, $conf) print ''.$langs->trans('MigrationPaymentMode')."
        \n"; $elements = array( - 'old_id' => array(5,8,9,10,11), - 'new_id' => array(50,51,52,53,54), - 'code' => array('VAD','TRA','LCR','FAC','PRO'), - 'tables' => array('commande_fournisseur','commande','facture_rec','facture','propal') + 'old_id' => array(5, 8, 9, 10, 11), + 'new_id' => array(50, 51, 52, 53, 54), + 'code' => array('VAD', 'TRA', 'LCR', 'FAC', 'PRO'), + 'tables' => array('commande_fournisseur', 'commande', 'facture_rec', 'facture', 'propal') ); - $count=0; + $count = 0; - foreach($elements['old_id'] as $key => $old_id) + foreach ($elements['old_id'] as $key => $old_id) { - $error=0; + $error = 0; - dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=" . $elements['code'][$key]); + dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=".$elements['code'][$key]); $sqlSelect = "SELECT id"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."c_paiement"; - $sqlSelect.= " WHERE id = ".$old_id; - $sqlSelect.= " AND code = '".$elements['code'][$key]."'"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."c_paiement"; + $sqlSelect .= " WHERE id = ".$old_id; + $sqlSelect .= " AND code = '".$elements['code'][$key]."'"; $resql = $db->query($sqlSelect); if ($resql) @@ -3556,27 +3556,27 @@ function migrate_mode_reglement($db, $langs, $conf) $db->begin(); $sqla = "UPDATE ".MAIN_DB_PREFIX."paiement SET "; - $sqla.= "fk_paiement = ".$elements['new_id'][$key]; - $sqla.= " WHERE fk_paiement = ".$old_id; - $sqla.= " AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE id = ".$old_id." AND code = '".$elements['code'][$key]."')"; + $sqla .= "fk_paiement = ".$elements['new_id'][$key]; + $sqla .= " WHERE fk_paiement = ".$old_id; + $sqla .= " AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE id = ".$old_id." AND code = '".$elements['code'][$key]."')"; $resqla = $db->query($sqla); $sql = "UPDATE ".MAIN_DB_PREFIX."c_paiement SET "; - $sql.= "id = ".$elements['new_id'][$key]; - $sql.= " WHERE id = ".$old_id; - $sql.= " AND code = '".$elements['code'][$key]."'"; + $sql .= "id = ".$elements['new_id'][$key]; + $sql .= " WHERE id = ".$old_id; + $sql .= " AND code = '".$elements['code'][$key]."'"; $resql = $db->query($sql); if ($resqla && $resql) { - foreach($elements['tables'] as $table) + foreach ($elements['tables'] as $table) { $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; - $sql.= "fk_mode_reglement = ".$elements['new_id'][$key]; - $sql.= " WHERE fk_mode_reglement = ".$old_id; + $sql .= "fk_mode_reglement = ".$elements['new_id'][$key]; + $sql .= " WHERE fk_mode_reglement = ".$old_id; $resql = $db->query($sql); - if (! $resql) + if (!$resql) { dol_print_error($db); $error++; @@ -3584,7 +3584,7 @@ function migrate_mode_reglement($db, $langs, $conf) print ". "; } - if (! $error) + if (!$error) { $db->commit(); } @@ -3627,54 +3627,54 @@ function migrate_clean_association($db, $langs, $conf, $versionto) $obj = $db->fetch_object($result); if ($obj) // It table categorie_association exists { - $couples=array(); - $filles=array(); + $couples = array(); + $filles = array(); $sql = "SELECT fk_categorie_mere, fk_categorie_fille"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_association"; dolibarr_install_syslog("upgrade: search duplicate"); $resql = $db->query($sql); if ($resql) { - $num=$db->num_rows($resql); - while ($obj=$db->fetch_object($resql)) + $num = $db->num_rows($resql); + while ($obj = $db->fetch_object($resql)) { - if (! isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent). + if (!isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent). { if ($obj->fk_categorie_mere != $obj->fk_categorie_fille) { - $filles[$obj->fk_categorie_fille]=1; // Set record for this child - $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille]=array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille); + $filles[$obj->fk_categorie_fille] = 1; // Set record for this child + $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille] = array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille); } } } - dolibarr_install_syslog("upgrade: result is num=" . $num . " count(couples)=" . count($couples)); + dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples)); // If there is duplicates couples or child with two parents if (count($couples) > 0 && $num > count($couples)) { - $error=0; + $error = 0; $db->begin(); // We delete all - $sql="DELETE FROM ".MAIN_DB_PREFIX."categorie_association"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association"; dolibarr_install_syslog("upgrade: delete association"); - $resqld=$db->query($sql); + $resqld = $db->query($sql); if ($resqld) { // And we insert only each record once - foreach($couples as $key => $val) + foreach ($couples as $key => $val) { - $sql ="INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)"; - $sql.=" VALUES(".$val['mere'].", ".$val['fille'].")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)"; + $sql .= " VALUES(".$val['mere'].", ".$val['fille'].")"; dolibarr_install_syslog("upgrade: insert association"); - $resqli=$db->query($sql); - if (! $resqli) $error++; + $resqli = $db->query($sql); + if (!$resqli) $error++; } } - if (! $error) + if (!$error) { print '
        '.$langs->trans("MigrationCategorieAssociation").''.$langs->trans("RemoveDuplicates").' '.$langs->trans("Success").' ('.$num.'=>'.count($couples).')
        '; print ''.$langs->trans('Upgrade').': '; - print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated + print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated print ""; print "
        \n"; print '
        '."\n"; @@ -134,8 +134,8 @@ for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { if (isset($_SESSION["choix$i"]) === false) { $_SESSION["choix$i"] = ''; } - print ''."\n"; } @@ -144,7 +144,7 @@ print '
        '. $langs->trans("TitleChoice") .' '.$j.': '; - $tmparray=array('checkbox'=>$langs->trans("CheckBox"),'yesno'=>$langs->trans("YesNoList"),'foragainst'=>$langs->trans("PourContreList")); + print '
        '.$langs->trans("TitleChoice").' '.$j.': '; + $tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList")); print '   '.$langs->trans("Type").' '.$form->selectarray("typecolonne[]", $tmparray, $_SESSION["typecolonne$i"]); print '
        '."\n"; //ajout de cases supplementaires print ''."\n"; -print ''."\n"; +print ''."\n"; print '
        '. $langs->trans("5MoreChoices") .''.$langs->trans("5MoreChoices").'
        '."\n"; print'
        '."\n"; diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 4f6eea5b903..8a2d643189b 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -22,13 +22,13 @@ * \brief File to return Ajax response on product list request */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); require '../../main.inc.php'; @@ -57,9 +57,9 @@ $hidepriceinlabel = GETPOST('hidepriceinlabel', 'int'); dol_syslog(join(',', $_GET)); // print_r($_GET); -if (! empty($action) && $action == 'fetch' && ! empty($id)) +if (!empty($action) && $action == 'fetch' && !empty($id)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $outjson = array(); @@ -77,11 +77,11 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $found = false; // Price by qty - if (! empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty + if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty { $sql = "SELECT price, unitprice, quantity, remise_percent"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty "; - $sql .= " WHERE rowid=" . $price_by_qty_rowid . ""; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty "; + $sql .= " WHERE rowid=".$price_by_qty_rowid.""; $result = $db->query($sql); if ($result) { @@ -99,14 +99,14 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } // Multiprice - if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price + if (!$found && isset($price_level) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price // level (from 1 to 6) { $sql = "SELECT price, price_ttc, price_base_type, tva_tx"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price "; - $sql .= " WHERE fk_product='" . $id . "'"; - $sql .= " AND entity IN (" . getEntity('productprice') . ")"; - $sql .= " AND price_level=" . $price_level; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price "; + $sql .= " WHERE fk_product='".$id."'"; + $sql .= " AND entity IN (".getEntity('productprice').")"; + $sql .= " AND price_level=".$price_level; $sql .= " ORDER BY date_price"; $sql .= " DESC LIMIT 1"; @@ -124,12 +124,12 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } // Price by customer - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && ! empty($socid)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); - $filter = array('t.fk_product' => $object->id,'t.fk_soc' => $socid); + $filter = array('t.fk_product' => $object->id, 't.fk_soc' => $socid); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result) { @@ -143,21 +143,21 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } } - if (! $found) { + if (!$found) { $outprice_ht = price($object->price); $outprice_ttc = price($object->price_ttc); $outpricebasetype = $object->price_base_type; $outtva_tx = $object->tva_tx; } - $outjson = array('ref' => $outref,'label' => $outlabel,'desc' => $outdesc,'type' => $outtype,'price_ht' => $outprice_ht,'price_ttc' => $outprice_ttc,'pricebasetype' => $outpricebasetype,'tva_tx' => $outtva_tx,'qty' => $outqty,'discount' => $outdiscount); + $outjson = array('ref' => $outref, 'label' => $outlabel, 'desc' => $outdesc, 'type' => $outtype, 'price_ht' => $outprice_ht, 'price_ttc' => $outprice_ttc, 'pricebasetype' => $outpricebasetype, 'tva_tx' => $outtva_tx, 'qty' => $outqty, 'discount' => $outdiscount); } echo json_encode($outjson); } else { - require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $langs->load("products"); $langs->load("main"); @@ -170,19 +170,19 @@ else return; } - $match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET)); + $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); sort($match); - $idprod = (! empty($match[0]) ? $match[0] : ''); + $idprod = (!empty($match[0]) ? $match[0] : ''); - if (GETPOST($htmlname, 'alpha') == '' && (! $idprod || ! GETPOST($idprod, 'alpha'))) + if (GETPOST($htmlname, 'alpha') == '' && (!$idprod || !GETPOST($idprod, 'alpha'))) { print json_encode(array()); return; } // When used from jQuery, the search term is added as GET param "term". - $searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : '')); + $searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : '')); $form = new Form($db); if (empty($mode) || $mode == 1) { // mode=1: customer diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index b12a0d41370..99ddd39d49b 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -16,16 +16,16 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } -$object=$GLOBALS['object']; +$object = $GLOBALS['object']; -$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); +$statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); ?> @@ -35,7 +35,7 @@ print load_fiche_titre($langs->trans("NewProduct"), '', 'products'); dol_fiche_head(''); ?> -error)?'':$object->error), $object->errors); ?> +error) ? '' : $object->error), $object->errors); ?> @@ -71,7 +71,7 @@ dol_fiche_head(''); selectarray('statut_buy', $statutarray, $object->status_buy); ?> -stock->enabled)) { ?> +stock->enabled)) { ?> trans("StockLimit"); ?> @@ -108,7 +108,7 @@ dol_fiche_head('');
        -global->PRODUIT_MULTIPRICES) { ?> +global->PRODUIT_MULTIPRICES) { ?> diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index d51e1541278..26daca173a4 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -16,16 +16,16 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } -$object=$GLOBALS['object']; +$object = $GLOBALS['object']; -$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); +$statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); ?> @@ -80,7 +80,7 @@ dol_fiche_head('');
        -global->PRODUIT_MULTIPRICES) { ?> +global->PRODUIT_MULTIPRICES) { ?>
        trans("SellingPrice"); ?>
        diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 8117d8fb6aa..dd542b71f8d 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -21,7 +21,7 @@ * \ingroup produit * \brief File of class to manage predefined price products or services by customer */ -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** * File of class to manage predefined price products or services by customer @@ -73,7 +73,7 @@ class Productcustomerprice extends CommonObject */ public $fk_user; - public $lines = array (); + public $lines = array(); /** @@ -166,7 +166,7 @@ class Productcustomerprice extends CommonObject } // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_customer_price("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_customer_price("; $sql .= "entity,"; $sql .= "datec,"; $sql .= "fk_product,"; @@ -186,39 +186,39 @@ class Productcustomerprice extends CommonObject $sql .= "fk_user,"; $sql .= "import_key"; $sql .= ") VALUES ("; - $sql .= " " . $conf->entity . ","; - $sql .= " '" . $this->db->idate(dol_now()) . "',"; - $sql .= " " . (! isset($this->fk_product) ? 'NULL' : "'" . $this->db->escape($this->fk_product) . "'") . ","; - $sql .= " " . (! isset($this->fk_soc) ? 'NULL' : "'" . $this->db->escape($this->fk_soc) . "'") . ","; - $sql .= " " . (empty($this->price) ? '0' : "'" . $this->db->escape($this->price) . "'") . ","; - $sql .= " " . (empty($this->price_ttc) ? '0' : "'" . $this->db->escape($this->price_ttc) . "'") . ","; - $sql .= " " . (empty($this->price_min) ? '0' : "'" . $this->db->escape($this->price_min) . "'") . ","; - $sql .= " " . (empty($this->price_min_ttc) ? '0' : "'" . $this->db->escape($this->price_min_ttc) . "'") . ","; - $sql .= " " . (! isset($this->price_base_type) ? 'NULL' : "'" . $this->db->escape($this->price_base_type) . "'") . ","; + $sql .= " ".$conf->entity.","; + $sql .= " '".$this->db->idate(dol_now())."',"; + $sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").","; + $sql .= " ".(!isset($this->fk_soc) ? 'NULL' : "'".$this->db->escape($this->fk_soc)."'").","; + $sql .= " ".(empty($this->price) ? '0' : "'".$this->db->escape($this->price)."'").","; + $sql .= " ".(empty($this->price_ttc) ? '0' : "'".$this->db->escape($this->price_ttc)."'").","; + $sql .= " ".(empty($this->price_min) ? '0' : "'".$this->db->escape($this->price_min)."'").","; + $sql .= " ".(empty($this->price_min_ttc) ? '0' : "'".$this->db->escape($this->price_min_ttc)."'").","; + $sql .= " ".(!isset($this->price_base_type) ? 'NULL' : "'".$this->db->escape($this->price_base_type)."'").","; $sql .= " ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").","; - $sql .= " " . (! isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx)?0:$this->tva_tx)) . ","; - $sql .= " " . (! isset($this->recuperableonly) ? 'NULL' : "'" . $this->db->escape($this->recuperableonly) . "'") . ","; - $sql .= " " . (empty($this->localtax1_type) ? "'0'" : "'" . $this->db->escape($this->localtax1_type) . "'") . ","; - $sql .= " " . (! isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx)?0:$this->localtax1_tx)) . ","; - $sql .= " " . (empty($this->localtax2_type) ? "'0'" : "'" . $this->db->escape($this->localtax2_type) . "'") . ","; - $sql .= " " . (! isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx)?0:$this->localtax2_tx)) . ","; - $sql .= " " . $user->id . ","; - $sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ""; + $sql .= " ".(!isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx) ? 0 : $this->tva_tx)).","; + $sql .= " ".(!isset($this->recuperableonly) ? 'NULL' : "'".$this->db->escape($this->recuperableonly)."'").","; + $sql .= " ".(empty($this->localtax1_type) ? "'0'" : "'".$this->db->escape($this->localtax1_type)."'").","; + $sql .= " ".(!isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx)).","; + $sql .= " ".(empty($this->localtax2_type) ? "'0'" : "'".$this->db->escape($this->localtax2_type)."'").","; + $sql .= " ".(!isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx)).","; + $sql .= " ".$user->id.","; + $sql .= " ".(!isset($this->import_key) ? 'NULL' : "'".$this->db->escape($this->import_key)."'").""; $sql .= ")"; $this->db->begin(); - dol_syslog(get_class($this) . "::create", LOG_DEBUG); + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } - if (! $error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_customer_price"); + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_customer_price"); - if (! $notrigger) { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -231,21 +231,21 @@ class Productcustomerprice extends CommonObject } } - if (! $error) { + if (!$error) { $result = $this->setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $error++; } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); return $this->id; @@ -283,10 +283,10 @@ class Productcustomerprice extends CommonObject $sql .= " t.fk_user,"; $sql .= " t.import_key"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t"; - $sql .= " WHERE t.rowid = " . $id; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t"; + $sql .= " WHERE t.rowid = ".$id; - dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { @@ -316,8 +316,8 @@ class Productcustomerprice extends CommonObject return 1; } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -337,8 +337,8 @@ class Productcustomerprice extends CommonObject // phpcs:enable global $langs; - if ( empty($sortfield)) $sortfield = "t.rowid"; - if ( empty($sortorder)) $sortorder = "DESC"; + if (empty($sortfield)) $sortfield = "t.rowid"; + if (empty($sortorder)) $sortorder = "DESC"; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -364,39 +364,39 @@ class Productcustomerprice extends CommonObject $sql .= " t.import_key,"; $sql .= " soc.nom as socname,"; $sql .= " prod.ref as prodref"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t "; - $sql .= " ," . MAIN_DB_PREFIX . "product as prod "; - $sql .= " ," . MAIN_DB_PREFIX . "societe as soc "; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t "; + $sql .= " ,".MAIN_DB_PREFIX."product as prod "; + $sql .= " ,".MAIN_DB_PREFIX."societe as soc "; $sql .= " WHERE soc.rowid=t.fk_soc "; $sql .= " AND prod.rowid=t.fk_product "; - $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; - $sql .= " AND t.entity IN (" . getEntity('productprice') . ")"; + $sql .= " AND prod.entity IN (".getEntity('product').")"; + $sql .= " AND t.entity IN (".getEntity('productprice').")"; // Manage filter if (count($filter) > 0) { foreach ($filter as $key => $value) { if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year { - $sql .= ' AND ' . $key . ' = \'' . $value . '\''; + $sql .= ' AND '.$key.' = \''.$value.'\''; } elseif ($key == 'soc.nom') { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } elseif ($key == 'prod.ref') { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } else { - $sql .= ' AND ' . $key . ' = ' . $value; + $sql .= ' AND '.$key.' = '.$value; } } } - $sql.= $this->db->order($sortfield, $sortorder); - if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + $sql .= $this->db->order($sortfield, $sortorder); + if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset); - dol_syslog(get_class($this) . "::fetch_all", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); + $this->lines = array(); $num = $this->db->num_rows($resql); - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $line = new PriceByCustomerLine(); $line->id = $obj->rowid; @@ -429,8 +429,8 @@ class Productcustomerprice extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -450,8 +450,8 @@ class Productcustomerprice extends CommonObject // phpcs:enable global $langs; - if (! empty($sortfield)) $sortfield = "t.rowid"; - if (! empty($sortorder)) $sortorder = "DESC"; + if (!empty($sortfield)) $sortfield = "t.rowid"; + if (!empty($sortorder)) $sortorder = "DESC"; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -474,38 +474,38 @@ class Productcustomerprice extends CommonObject $sql .= " t.import_key,"; $sql .= " soc.nom as socname,"; $sql .= " prod.ref as prodref"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price_log as t "; - $sql .= " ," . MAIN_DB_PREFIX . "product as prod "; - $sql .= " ," . MAIN_DB_PREFIX . "societe as soc "; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price_log as t "; + $sql .= " ,".MAIN_DB_PREFIX."product as prod "; + $sql .= " ,".MAIN_DB_PREFIX."societe as soc "; $sql .= " WHERE soc.rowid=t.fk_soc "; $sql .= " AND prod.rowid=t.fk_product "; - $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; - $sql .= " AND t.entity IN (" . getEntity('productprice') . ")"; + $sql .= " AND prod.entity IN (".getEntity('product').")"; + $sql .= " AND t.entity IN (".getEntity('productprice').")"; // Manage filter if (count($filter) > 0) { foreach ($filter as $key => $value) { if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year { - $sql .= ' AND ' . $key . ' = \'' . $value . '\''; + $sql .= ' AND '.$key.' = \''.$value.'\''; } elseif ($key == 'soc.nom') { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } else { - $sql .= ' AND ' . $key . ' = ' . $value; + $sql .= ' AND '.$key.' = '.$value; } } } - $sql.= $this->db->order($sortfield, $sortorder); - if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + $sql .= $this->db->order($sortfield, $sortorder); + if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset); - dol_syslog(get_class($this) . "::fetch_all_log", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch_all_log", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); + $this->lines = array(); $num = $this->db->num_rows($resql); - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $line = new PriceByCustomerLine(); $line->id = $obj->rowid; @@ -536,8 +536,8 @@ class Productcustomerprice extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -622,7 +622,7 @@ class Productcustomerprice extends CommonObject // Do a copy of current record into log table // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_customer_price_log("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_customer_price_log("; $sql .= "entity,"; $sql .= "datec,"; @@ -665,75 +665,75 @@ class Productcustomerprice extends CommonObject $sql .= " t.fk_user,"; $sql .= " t.import_key"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t"; - $sql .= " WHERE t.rowid = " . $this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t"; + $sql .= " WHERE t.rowid = ".$this->id; $this->db->begin(); - dol_syslog(get_class($this) . "::update", LOG_DEBUG); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } // Update request - $sql = "UPDATE " . MAIN_DB_PREFIX . "product_customer_price SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."product_customer_price SET"; - $sql .= " entity=" . $conf->entity . ","; - $sql .= " datec='" . $this->db->idate(dol_now()) . "',"; - $sql .= " tms=" . (dol_strlen($this->tms) != 0 ? "'" . $this->db->idate($this->tms) . "'" : 'null') . ","; - $sql .= " fk_product=" . (isset($this->fk_product) ? $this->fk_product : "null") . ","; - $sql .= " fk_soc=" . (isset($this->fk_soc) ? $this->fk_soc : "null") . ","; - $sql .= " price=" . (isset($this->price) ? $this->price : "null") . ","; - $sql .= " price_ttc=" . (isset($this->price_ttc) ? $this->price_ttc : "null") . ","; - $sql .= " price_min=" . (isset($this->price_min) ? $this->price_min : "null") . ","; - $sql .= " price_min_ttc=" . (isset($this->price_min_ttc) ? $this->price_min_ttc : "null") . ","; - $sql .= " price_base_type=" . (isset($this->price_base_type) ? "'" . $this->db->escape($this->price_base_type) . "'" : "null") . ","; + $sql .= " entity=".$conf->entity.","; + $sql .= " datec='".$this->db->idate(dol_now())."',"; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").","; + $sql .= " fk_soc=".(isset($this->fk_soc) ? $this->fk_soc : "null").","; + $sql .= " price=".(isset($this->price) ? $this->price : "null").","; + $sql .= " price_ttc=".(isset($this->price_ttc) ? $this->price_ttc : "null").","; + $sql .= " price_min=".(isset($this->price_min) ? $this->price_min : "null").","; + $sql .= " price_min_ttc=".(isset($this->price_min_ttc) ? $this->price_min_ttc : "null").","; + $sql .= " price_base_type=".(isset($this->price_base_type) ? "'".$this->db->escape($this->price_base_type)."'" : "null").","; $sql .= " default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").","; - $sql .= " tva_tx=" . (isset($this->tva_tx) ? (empty($this->tva_tx)?0:$this->tva_tx) : "null") . ","; - $sql .= " recuperableonly=" . (isset($this->recuperableonly) ? $this->recuperableonly : "null") . ","; - $sql .= " localtax1_tx=" . (isset($this->localtax1_tx) ? (empty($this->localtax1_tx)?0:$this->localtax1_tx) : "null") . ","; - $sql .= " localtax2_tx=" . (isset($this->localtax2_tx) ? (empty($this->localtax2_tx)?0:$this->localtax2_tx) : "null") . ","; - $sql .= " localtax1_type=" . (! empty($this->localtax1_type) ? "'".$this->db->escape($this->localtax1_type)."'": "'0'") . ","; - $sql .= " localtax2_type=" . (! empty($this->localtax2_type) ? "'".$this->db->escape($this->localtax2_type)."'": "'0'") . ","; - $sql .= " fk_user=" . $user->id . ","; - $sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ""; + $sql .= " tva_tx=".(isset($this->tva_tx) ? (empty($this->tva_tx) ? 0 : $this->tva_tx) : "null").","; + $sql .= " recuperableonly=".(isset($this->recuperableonly) ? $this->recuperableonly : "null").","; + $sql .= " localtax1_tx=".(isset($this->localtax1_tx) ? (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx) : "null").","; + $sql .= " localtax2_tx=".(isset($this->localtax2_tx) ? (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx) : "null").","; + $sql .= " localtax1_type=".(!empty($this->localtax1_type) ? "'".$this->db->escape($this->localtax1_type)."'" : "'0'").","; + $sql .= " localtax2_type=".(!empty($this->localtax2_type) ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'").","; + $sql .= " fk_user=".$user->id.","; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; - $sql .= " WHERE rowid=" . $this->id; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this) . "::update", LOG_DEBUG); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } - if (! $error) { - if (! $notrigger) { + if (!$error) { + if (!$notrigger) { // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE', $this, $user, $langs, $conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interface = new Interfaces($this->db); + $result = $interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE', $this, $user, $langs, $conf); + if ($result < 0) { $error++; $this->errors = $interface->errors; } // End call triggers } } - if (! $error) { + if (!$error) { $result = $this->setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $error++; } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); return 1; @@ -754,34 +754,34 @@ class Productcustomerprice extends CommonObject // Find all susidiaries $sql = "SELECT s.rowid"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; - $sql .= " WHERE s.parent = " . $this->fk_soc; - $sql .= " AND s.entity IN (" . getEntity('societe') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.parent = ".$this->fk_soc; + $sql .= " AND s.entity IN (".getEntity('societe').")"; - dol_syslog(get_class($this) . "::setPriceOnAffiliateThirdparty", LOG_DEBUG); + dol_syslog(get_class($this)."::setPriceOnAffiliateThirdparty", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); + $this->lines = array(); $num = $this->db->num_rows($resql); - while ( ($obj = $this->db->fetch_object($resql)) && (empty($error)) ) { + while (($obj = $this->db->fetch_object($resql)) && (empty($error))) { // find if there is an existing line for the product and the subsidiaries $prodsocprice = new Productcustomerprice($this->db); - $filter = array ( - 't.fk_product' => $this->fk_product,'t.fk_soc' => $obj->rowid + $filter = array( + 't.fk_product' => $this->fk_product, 't.fk_soc' => $obj->rowid ); $result = $prodsocprice->fetch_all('', '', 0, 0, $filter); if ($result < 0) { - $error ++; + $error++; $this->error = $prodsocprice->error; } else { // There is one line if (count($prodsocprice->lines) > 0) { // If force update => Update - if (! empty($forceupdateaffiliate)) { + if (!empty($forceupdateaffiliate)) { $prodsocpriceupd = new Productcustomerprice($this->db); $prodsocpriceupd->fetch($prodsocprice->lines [0]->id); @@ -793,7 +793,7 @@ class Productcustomerprice extends CommonObject $resultupd = $prodsocpriceupd->update($user, 0, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $error++; $this->error = $prodsocpriceupd->error; } } @@ -810,7 +810,7 @@ class Productcustomerprice extends CommonObject $resultupd = $prodsocpricenew->create($user, 0, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $error++; $this->error = $prodsocpriceupd->error; } } @@ -821,11 +821,11 @@ class Productcustomerprice extends CommonObject if (empty($error)) { return 1; } else { - return - 1; + return -1; } } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -844,8 +844,8 @@ class Productcustomerprice extends CommonObject $this->db->begin(); - if (! $error) { - if (! $notrigger) { + if (!$error) { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -858,26 +858,26 @@ class Productcustomerprice extends CommonObject } } - if (! $error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_customer_price"; - $sql .= " WHERE rowid=" . $this->id; + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_customer_price"; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); return 1; @@ -908,28 +908,28 @@ class Productcustomerprice extends CommonObject // ... // Create clone - $object->context['createfromclone']='createfromclone'; + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options if ($result < 0) { $this->error = $object->error; - $this->errors=array_merge($this->errors, $object->errors); + $this->errors = array_merge($this->errors, $object->errors); $error++; } - if (! $error) { + if (!$error) { } unset($object->context['createfromclone']); // End - if (! $error) { + if (!$error) { $this->db->commit(); return $object->id; } else { $this->db->rollback(); - return - 1; + return -1; } } diff --git a/htdocs/product/document.php b/htdocs/product/document.php index ef508c9a200..f12b20b7921 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -62,33 +62,33 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="position_name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "position_name"; $object = new Product($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); - elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + if (!empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + elseif (!empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { - if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + if (!empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; } } -$modulepart='produit'; +$modulepart = 'produit'; /* * Actions */ -$parameters=array('id'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id); +$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)) @@ -102,10 +102,10 @@ if (empty($reshook)) $urlfile = GETPOST('urlfile', 'alpha'); $filename = basename($urlfile); $filetomerge = new Propalmergepdfproduct($db); - $filetomerge->fk_product=$object->id; - $filetomerge->file_name=$filename; - $result=$filetomerge->delete_by_file($user); - if ($result<0) { + $filetomerge->fk_product = $object->id; + $filetomerge->file_name = $filename; + $result = $filetomerge->delete_by_file($user); + if ($result < 0) { setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } } @@ -115,7 +115,7 @@ if (empty($reshook)) include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; } -if ($action=='filemerge') +if ($action == 'filemerge') { $is_refresh = GETPOST('refresh'); if (empty($is_refresh)) { @@ -131,11 +131,11 @@ if ($action=='filemerge') $filetomerge = new Propalmergepdfproduct($db); if ($conf->global->MAIN_MULTILANGS) { - $result=$filetomerge->delete_by_product($user, $object->id, $lang_id); + $result = $filetomerge->delete_by_product($user, $object->id, $lang_id); } else { - $result=$filetomerge->delete_by_product($user, $object->id); + $result = $filetomerge->delete_by_product($user, $object->id); } - if ($result<0) { + if ($result < 0) { setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } @@ -149,8 +149,8 @@ if ($action=='filemerge') $filetomerge->lang = $lang_id; } - $result=$filetomerge->create($user); - if ($result<0) { + $result = $filetomerge->create($user); + if ($result < 0) { setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } } @@ -170,13 +170,13 @@ $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Documents'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Documents'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Documents'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Documents'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); @@ -234,8 +234,8 @@ if ($object->id) dol_fiche_end(); $permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; // Merge propal PDF document PDF files @@ -255,7 +255,7 @@ if ($object->id) $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { $filearray = array_merge($filearray, dol_dir_list($upload_dirold, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1)); } @@ -269,8 +269,8 @@ if ($object->id) print $langs->trans('PropalMergePdfProductActualFile'); } - print ''; - print ''; + print ''; + print ''; print ''; if (count($filetomerge->lines) == 0) { print $langs->trans('PropalMergePdfProductChooseFile'); @@ -291,7 +291,7 @@ if ($object->id) print Form::selectarray('lang_id', $langs_available, $default_lang, 0, 0, 0, '', 0, 0, 0, 'ASC'); if ($conf->global->MAIN_MULTILANGS) { - print ''; + print ''; } print ''; @@ -306,9 +306,9 @@ if ($object->id) if ($conf->global->MAIN_MULTILANGS) { - if (array_key_exists($filetoadd['name'] . '_' . $default_lang, $filetomerge->lines)) + if (array_key_exists($filetoadd['name'].'_'.$default_lang, $filetomerge->lines)) { - $filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $default_lang); + $filename = $filetoadd['name'].' - '.$langs->trans('Language_'.$default_lang); $checked = ' checked '; } } @@ -321,13 +321,13 @@ if ($object->id) } print ''; } } print ''; print '
        trans("SellingPrice"); ?>
        '; - print '' . $filename . ''; + print ''.$filename.''; print '
        '; - print ''; + print ''; print '
        '; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 3054aebfa9d..12c9163cf92 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -56,20 +56,20 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page < 0) $page = 0; -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="ASC"; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "ASC"; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page ; +$offset = $limit * $page; // Load sale and categ filters $search_sale = GETPOST("search_sale"); $search_categ = GETPOST("search_categ"); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -$canvas=GETPOST("canvas"); -$objcanvas=null; -if (! empty($canvas)) +$canvas = GETPOST("canvas"); +$objcanvas = null; +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); @@ -77,10 +77,10 @@ if (! empty($canvas)) } // Define virtualdiffersfromphysical -$virtualdiffersfromphysical=0; -if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)|| ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) +$virtualdiffersfromphysical = 0; +if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { - $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } @@ -91,18 +91,18 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global 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 { - $sref=""; - $snom=""; - $sall=""; - $tosell=""; - $tobuy=""; - $search_sale=""; - $search_categ=""; - $type=""; - $catid=''; - $toolowstock=''; - $fourn_id=''; - $sbarcode=''; + $sref = ""; + $snom = ""; + $sall = ""; + $tosell = ""; + $tobuy = ""; + $search_sale = ""; + $search_categ = ""; + $type = ""; + $catid = ''; + $toolowstock = ''; + $fourn_id = ''; + $sbarcode = ''; } @@ -111,50 +111,50 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' * View */ -$helpurl='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; +$helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; -$form=new Form($db); -$htmlother=new FormOther($db); +$form = new Form($db); +$htmlother = new FormOther($db); $sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; -$sql.= ' p.fk_product_type, p.tms as datem,'; -$sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; -$sql.= ' SUM(s.reel) as stock_physique'; -if (! empty($conf->global->PRODUCT_USE_UNITS)) $sql.= ', u.short_label as unit_short'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product'; -if (! empty($conf->global->PRODUCT_USE_UNITS)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid'; +$sql .= ' p.fk_product_type, p.tms as datem,'; +$sql .= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; +$sql .= ' SUM(s.reel) as stock_physique'; +if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ', u.short_label as unit_short'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product'; +if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid'; // We'll need this table joined to the select in order to filter by categ -if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -$sql.= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ -if ($sall) $sql.=natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); +if ($search_categ) $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; +$sql .= " WHERE p.entity IN (".getEntity('product').")"; +if ($search_categ) $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ +if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($type)) { - if ($type==1) + if ($type == 1) { - $sql.= " AND p.fk_product_type = '1'"; + $sql .= " AND p.fk_product_type = '1'"; } else { - $sql.= " AND p.fk_product_type <> '1'"; + $sql .= " AND p.fk_product_type <> '1'"; } } -if ($sref) $sql.= natural_search('p.ref', $sref); -if ($search_barcode) $sql.= natural_search('p.barcode', $search_barcode); -if ($snom) $sql.= natural_search('p.label', $snom); -if (! empty($tosell)) $sql.= " AND p.tosell = ".$tosell; -if (! empty($tobuy)) $sql.= " AND p.tobuy = ".$tobuy; -if (! empty($canvas)) $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; -if($catid) $sql.= " AND cp.fk_categorie = ".$catid; -if ($fourn_id > 0) $sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; +if ($sref) $sql .= natural_search('p.ref', $sref); +if ($search_barcode) $sql .= natural_search('p.barcode', $search_barcode); +if ($snom) $sql .= natural_search('p.label', $snom); +if (!empty($tosell)) $sql .= " AND p.tosell = ".$tosell; +if (!empty($tobuy)) $sql .= " AND p.tobuy = ".$tobuy; +if (!empty($canvas)) $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; +if ($catid) $sql .= " AND cp.fk_categorie = ".$catid; +if ($fourn_id > 0) $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; // Insert categ filter if ($search_categ) $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); -$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; -$sql.= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock"; -if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; -$sql.= $db->order($sortfield, $sortorder); +$sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; +$sql .= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock"; +if ($toolowstock) $sql .= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -169,7 +169,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -187,31 +187,31 @@ if ($resql) if (isset($type)) { - if ($type==1) { $texte = $langs->trans("Services"); } + if ($type == 1) { $texte = $langs->trans("Services"); } else { $texte = $langs->trans("Products"); } } else { $texte = $langs->trans("ProductsAndServices"); } - $texte.=' ('.$langs->trans("MenuStocks").')'; + $texte .= ' ('.$langs->trans("MenuStocks").')'; - $param=''; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($tosell) $param.="&tosell=".urlencode($tosell); - if ($tobuy) $param.="&tobuy=".urlencode($tobuy); - if ($type) $param.="&type=".urlencode($type); - if ($fourn_id) $param.="&fourn_id=".urlencode($fourn_id); - if ($snom) $param.="&snom=".urlencode($snom); - if ($sref) $param.="&sref=".urlencode($sref); - if ($search_sale) $param.="&search_sale=".urlencode($search_sale); - if ($search_categ) $param.="&search_categ=".urlencode($search_categ); - if ($toolowstock) $param.="&toolowstock=".urlencode($toolowstock); - if ($sbarcode) $param.="&sbarcode=".urlencode($sbarcode); - if ($catid) $param.="&catid=".urlencode($catid); + $param = ''; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= "&sall=".urlencode($sall); + if ($tosell) $param .= "&tosell=".urlencode($tosell); + if ($tobuy) $param .= "&tobuy=".urlencode($tobuy); + if ($type) $param .= "&type=".urlencode($type); + if ($fourn_id) $param .= "&fourn_id=".urlencode($fourn_id); + if ($snom) $param .= "&snom=".urlencode($snom); + if ($sref) $param .= "&sref=".urlencode($sref); + if ($search_sale) $param .= "&search_sale=".urlencode($search_sale); + if ($search_categ) $param .= "&search_categ=".urlencode($search_categ); + if ($toolowstock) $param .= "&toolowstock=".urlencode($toolowstock); + if ($sbarcode) $param .= "&sbarcode=".urlencode($sbarcode); + if ($catid) $param .= "&catid=".urlencode($catid); llxHeader("", $texte, $helpurl); - print ''; + print ''; print ''; print ''; print ''; @@ -220,7 +220,7 @@ if ($resql) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'products', 0, '', '', $limit); - if (! empty($catid)) + if (!empty($catid)) { print "
        "; $c = new Categorie($db); @@ -231,48 +231,48 @@ if ($resql) } // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) + $moreforfilter = ''; + if (!empty($conf->categorie->enabled)) { - $moreforfilter.='
        '; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); - $moreforfilter.='
        '; + $moreforfilter .= '
        '; + $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); + $moreforfilter .= '
        '; } - $moreforfilter.='
        '; - $moreforfilter.=$langs->trans("StockTooLow").' '; - $moreforfilter.='
        '; + $moreforfilter .= '
        '; + $moreforfilter .= $langs->trans("StockTooLow").' '; + $moreforfilter .= '
        '; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
        '; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
        '; } - $param=''; - if ($tosell) $param.="&tosell=".$tosell; - if ($tobuy) $param.="&tobuy=".$tobuy; - if ($type) $param.="&type=".$type; - if ($fourn_id) $param.="&fourn_id=".$fourn_id; - if ($snom) $param.="&snom=".$snom; - if ($sref) $param.="&sref=".$sref; - if ($toolowstock) $param.="&toolowstock=".$toolowstock; - if ($search_categ) $param.="&search_categ=".$search_categ; + $param = ''; + if ($tosell) $param .= "&tosell=".$tosell; + if ($tobuy) $param .= "&tobuy=".$tobuy; + if ($type) $param .= "&type=".$type; + if ($fourn_id) $param .= "&fourn_id=".$fourn_id; + if ($snom) $param .= "&snom=".$snom; + if ($sref) $param .= "&sref=".$sref; + if ($toolowstock) $param .= "&toolowstock=".$toolowstock; + if ($search_categ) $param .= "&search_categ=".$search_categ; $formProduct = new FormProduct($db); $formProduct->loadWarehouses(); $warehouses_list = $formProduct->cache_warehouses; $nb_warehouse = count($warehouses_list); $colspan_warehouse = 1; - if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse+1 : 1; } + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse + 1 : 1; } print '
        '; - print ''; + print '
        '; // Fields title search print ''; @@ -283,7 +283,7 @@ if ($resql) print ''; print ''; // Duration - if (! empty($conf->service->enabled) && $type == 1) + if (!empty($conf->service->enabled) && $type == 1) { print ''; print ''; print ''; print ''; @@ -307,14 +307,14 @@ if ($resql) print ""; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", $param, "", "", $sortfield, $sortorder); - if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); + if (!empty($conf->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); print_liste_field_titre("StockLimit", $_SERVER["PHP_SELF"], "p.seuil_stock_alerte", $param, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock", $param, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", $param, "", '', $sortfield, $sortorder, 'right '); // Details per warehouse - if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) { - if ($nb_warehouse>1) { + if ($nb_warehouse > 1) { foreach ($warehouses_list as &$wh) { print_liste_field_titre($wh['label'], '', '', '', '', '', '', '', 'right '); } @@ -322,7 +322,7 @@ if ($resql) } if ($virtualdiffersfromphysical) print_liste_field_titre("VirtualStock", $_SERVER["PHP_SELF"], "", $param, "", '', $sortfield, $sortorder, 'right '); // Units - if (! empty($conf->global->PRODUCT_USE_UNITS)) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print_liste_field_titre("Unit", $_SERVER["PHP_SELF"], "unit_short", $param, "", 'align="right"', $sortfield, $sortorder); } print_liste_field_titre(''); @@ -335,7 +335,7 @@ if ($resql) { $objp = $db->fetch_object($resql); - $product=new Product($db); + $product = new Product($db); $product->fetch($objp->rowid); $product->load_stock(); @@ -346,7 +346,7 @@ if ($resql) print ''; print ''; - if (! empty($conf->service->enabled) && $type == 1) + if (!empty($conf->service->enabled) && $type == 1) { print ''; // Details per warehouse - if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) { - if($nb_warehouse>1) { - foreach($warehouses_list as &$wh) { + if ($nb_warehouse > 1) { + foreach ($warehouses_list as &$wh) { print ''; @@ -385,8 +385,8 @@ if ($resql) print ''; } // Units - if (! empty($conf->global->PRODUCT_USE_UNITS)) { - print ''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; } print ''; print ''; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 6a0748f8f84..7ffc0908c4e 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -26,13 +26,13 @@ * \brief File to offer a way to make an online signature for a particular Dolibarr entity */ -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +define("NOLOGIN", 1); // This means this output page does not require to be logged. +define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php // TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; @@ -46,7 +46,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox")); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); // Input are: // type ('invoice','order','contractline'), @@ -55,15 +55,15 @@ $action=GETPOST('action', 'alpha'); // tag (a free text, required if type is empty) // currency (iso code) -$suffix=GETPOST("suffix", 'alpha'); -$source=GETPOST("source", 'alpha'); -$ref=$REF=GETPOST("ref", 'alpha'); +$suffix = GETPOST("suffix", 'alpha'); +$source = GETPOST("source", 'alpha'); +$ref = $REF = GETPOST("ref", 'alpha'); -if (empty($source)) $source='proposal'; +if (empty($source)) $source = 'proposal'; -if (! $action) +if (!$action) { - if ($source && ! $ref) + if ($source && !$ref) { print $langs->trans('ErrorBadParameters')." - ref missing"; exit; @@ -71,8 +71,8 @@ if (! $action) } -$paymentmethod=''; -$validpaymentmethod=array(); +$paymentmethod = ''; +$validpaymentmethod = array(); @@ -80,34 +80,34 @@ $validpaymentmethod=array(); // Define $urlwithroot //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file -$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. +$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. // Complete urls for post treatment -$SECUREKEY=GETPOST("securekey"); // Secure key +$SECUREKEY = GETPOST("securekey"); // Secure key -if (! empty($source)) +if (!empty($source)) { - $urlok.='source='.urlencode($source).'&'; - $urlko.='source='.urlencode($source).'&'; + $urlok .= 'source='.urlencode($source).'&'; + $urlko .= 'source='.urlencode($source).'&'; } -if (! empty($REF)) +if (!empty($REF)) { - $urlok.='ref='.urlencode($REF).'&'; - $urlko.='ref='.urlencode($REF).'&'; + $urlok .= 'ref='.urlencode($REF).'&'; + $urlko .= 'ref='.urlencode($REF).'&'; } -if (! empty($SECUREKEY)) +if (!empty($SECUREKEY)) { - $urlok.='securekey='.urlencode($SECUREKEY).'&'; - $urlko.='securekey='.urlencode($SECUREKEY).'&'; + $urlok .= 'securekey='.urlencode($SECUREKEY).'&'; + $urlko .= 'securekey='.urlencode($SECUREKEY).'&'; } -if (! empty($entity)) +if (!empty($entity)) { - $urlok.='entity='.urlencode($entity).'&'; - $urlko.='entity='.urlencode($entity).'&'; + $urlok .= 'entity='.urlencode($entity).'&'; + $urlko .= 'entity='.urlencode($entity).'&'; } -$urlok=preg_replace('/&$/', '', $urlok); // Remove last & -$urlko=preg_replace('/&$/', '', $urlko); // Remove last & +$urlok = preg_replace('/&$/', '', $urlok); // Remove last & +$urlko = preg_replace('/&$/', '', $urlko); // Remove last & $creditor = $mysoc->name; @@ -127,16 +127,16 @@ if ($action == 'dosign') * View */ -$head=''; -if (! empty($conf->global->MAIN_SIGN_CSS_URL)) $head=''."\n"; +$head = ''; +if (!empty($conf->global->MAIN_SIGN_CSS_URL)) $head = ''."\n"; -$conf->dol_hide_topmenu=1; -$conf->dol_hide_leftmenu=1; +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; llxHeader($head, $langs->trans("OnlineSignature"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); // Check link validity -if (! empty($source) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) +if (!empty($source) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) { $langs->load("errors"); dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); @@ -161,24 +161,24 @@ print ''."\n"; print '
        '; print ' '; @@ -298,7 +298,7 @@ if ($resql) print ' '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
        '.$product->label.''; if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationYear"); @@ -361,14 +361,14 @@ if ($resql) // Real stock print ''; if ($objp->seuil_stock_alerte != '' && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; - print $objp->stock_physique|0; + print $objp->stock_physique | 0; print ''; print empty($product->stock_warehouse[$wh['id']]->real) ? '0' : $product->stock_warehouse[$wh['id']]->real; print '' . $objp->unit_short . ''.$objp->unit_short.''.$langs->trans("Movements").''.$product->LibStatut($objp->statut, 5, 0).'
        '."\n"; // Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo) -$width=0; +$width = 0; // Define logo and logosmall -$logosmall=$mysoc->logo_small; -$logo=$mysoc->logo; -$paramlogo='ONLINE_SIGN_LOGO_'.$suffix; -if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo; -elseif (! empty($conf->global->ONLINE_SIGN_LOGO)) $logosmall=$conf->global->ONLINE_SIGN_LOGO; +$logosmall = $mysoc->logo_small; +$logo = $mysoc->logo; +$paramlogo = 'ONLINE_SIGN_LOGO_'.$suffix; +if (!empty($conf->global->$paramlogo)) $logosmall = $conf->global->$paramlogo; +elseif (!empty($conf->global->ONLINE_SIGN_LOGO)) $logosmall = $conf->global->ONLINE_SIGN_LOGO; //print ''."\n"; // Define urllogo -$urllogo=''; -if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) +$urllogo = ''; +if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); } -elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) +elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); - $width=96; + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $width = 96; } // Output html code for logo if ($urllogo) @@ -191,18 +191,18 @@ if ($urllogo) } // Output introduction text -$text=''; -if (! empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT)) +$text = ''; +if (!empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT)) { $langs->load("members"); - if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text.=$langs->trans($reg[1])."
        \n"; - else $text.=$conf->global->ONLINE_SIGN_NEWFORM_TEXT."
        \n"; - $text=''."\n"; + if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text .= $langs->trans($reg[1])."
        \n"; + else $text .= $conf->global->ONLINE_SIGN_NEWFORM_TEXT."
        \n"; + $text = ''."\n"; } if (empty($text)) { - $text.=''."\n"; - $text.=''."\n"; + $text .= ''."\n"; + $text .= ''."\n"; } print $text; @@ -211,47 +211,47 @@ print ''; From c5b83ca3d85429815b25887d1d3e202f25db25de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Nov 2019 12:43:44 +0100 Subject: [PATCH 287/299] Fix link translation of --- htdocs/core/class/html.formwebsite.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 7aab9bd6774..8b7740d5382 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -229,9 +229,10 @@ class FormWebsite * @param int $showempty Show empty record * @param string $action Action on page that use this select list * @param string $morecss More CSS + * @param array $excludeids Exclude some ID in list * @return string HTML select component with list of type of containers */ - public function selectContainer($website, $htmlname = 'pageid', $pageid = 0, $showempty = 0, $action = '', $morecss = 'minwidth200') + public function selectContainer($website, $htmlname = 'pageid', $pageid = 0, $showempty = 0, $action = '', $morecss = 'minwidth200', $excludeids = null) { global $langs; @@ -264,6 +265,8 @@ class FormWebsite foreach($website->lines as $key => $valpage) { + if (is_array($excludeids) && count($excludeids) && in_array($valpage->id, $excludeids)) continue; + $valueforoption = '['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).'] '; $valueforoption.= $valpage->pageurl.' - '.$valpage->title; if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption.=' ('.$langs->trans("HomePage").')'; From f40fdad06cecc9486fb13172e599a35874a2783a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Nov 2019 12:54:05 +0100 Subject: [PATCH 288/299] Fix link between translations --- htdocs/website/index.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index f34b629b733..5d2dcb9a15f 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3034,19 +3034,23 @@ if ($action == 'editmeta' || $action == 'createcontainer') $num_rows = $db->num_rows($resql); if ($num_rows > 0) { - print ''.$langs->trans('ThisPageHasTranslationPages').':
        '; + print ''.$langs->trans('ThisPageHasTranslationPages').':'; $i = 0; $tmppage = new WebsitePage($db); + $tmpstring = ''; while ($obj = $db->fetch_object($resql)) { $result = $tmppage->fetch($obj->rowid); if ($result > 0) { - if ($i > 0) print '
        '; - print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')'; + if ($i > 0) $tmpstring .= '
        '; + $tmpstring .= $tmppage->getNomUrl(1).' ('.$tmppage->lang.')'; $translatedby++; $i++; } } + if ($i > 1) print '
        '; + else print ' '; + print $tmpstring; } } else dol_print_error($db); @@ -3064,6 +3068,9 @@ if ($action == 'editmeta' || $action == 'createcontainer') $translationof = $objectpage->fk_page; print ''.$langs->trans('ThisPageIsTranslationOf').' '; print $formwebsite->selectContainer($website, 'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action, 'minwidth300', array($objectpage->id)); + if ($translationof > 0) { + print $sourcepage->getNomUrl(2).' ('.$sourcepage->lang.')'; + } } } print ''; From 6dcd1f62753bfb196c2b56f5ef4994a46d2c098b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Nov 2019 13:50:12 +0100 Subject: [PATCH 289/299] Fix css --- .../websites/website_template-stellar.jpg | Bin 106795 -> 29924 bytes .../websites/website_template-stellar.zip | Bin 194363 -> 114796 bytes htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 11 ++++++++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/install/doctemplates/websites/website_template-stellar.jpg b/htdocs/install/doctemplates/websites/website_template-stellar.jpg index 66867384b58e4b7ba3cfde11f8141db4a48772bc..9e8251b1deb7191991370ab52f2552f7c3257240 100644 GIT binary patch literal 29924 zcmc%x1z1#V|1gTK31H|MKtd3P9uOo&Qih?C76l0fBn2cDDH%FcT3R|4l@1jc5T%h) z=`I5#l#tpBjOYEn_xb*N?{l5&oSSv6xxIg#>z-L_c{p@91t2w4)Kvfo1Oljmf571= zpa{UA(4zw!aPS~P5D~%QL}Vl+#0Uy93JP*Ea&k&48YCqZii(^ZNsmO)(w#VQf`XcX zk)Do`hVBI25fcauq=6HW5)qNoQIb>A{l6ZE%>W7knS$bB5EKAKL0~AzVGF((0mbs+*a1KTfCxm=W0c5%;KYPrG6OW? z4=T%}dL&dIuZt!NN7H2^@c=gfr&lJY;~)ZX7c_808b|>D8`sTKToejWutW=NnR?sw`1(%aHGs&#tUnGT5pu@~;34{W zGBnfxN5`iW06=t!?gv|zcJPJNX*{@%N7LXr9)|xB2;yUvV*q|#2sQx61?Wd00cft| zI1hcc=tmouBxW&F>++=zIs~p$4V#Yxemjn(z8eDJ22Nmr93Yzp;8O|*Ah%V;dZv|n zBsW(!#4JST)LUzO8wlqlNaZc->XB zqQ}06A-q0y_7d;hv-_eSzl6^9Ehc?hl==)n*d#nFmSifAbnKc~Bp^T~mBU{7Zq*dI z)q{)2gA9B0fk6X+J^(<^JAJe5^>jR1T5xv12e5PJ2T=R$eDl|z_dZ(u--l|~{@x3! z1su2zOR4W6!Xx8`vbNr3Z2h$ z8yz%3WNUqiIRyYSh3e)ZAfa#pU?=C7+xowws6&JK0!wS`rXe$e07;W~JxAYrUCsIz z5vUC||1$wEg8T97hNe7<+r=&S8o`9q!KZ)4KX$k^M_K=NK`~r3;=#v;%ra^ zAOI3E|1|6o9qaB!#=(=0A26MVpAQ&@c?0Dr-?}Sh}E2f4+6yRA6M{J5aHUWe#E*txon9!EBq}nzG`|z#+e>M$3ZSeM9 z4S1={PRES^+@)E1!^t4<+{yFqlkcUj5*+UHG2dW(i>oa74HH zH>PWYT`7g-v7zzQ*Ul#b9~?nzG8MgvKVkAX0?PoYM^qL#GzK2HyV&FNv+(o~rBNeU zozb|&&DsN>Gd2>o(abD$B_0N*XJi+o1(U5`%`S?!*So*{d{xxlJ=tq9)M!k!p@PCD zX!G><1PTg*G}F2;@T1~W7C1jrdLrmWpq`pCg&i!VcL5rV)g=Y}mc|Mi42!zU!{A|? zD0ThLL7c_yd5$SJtC{lgPobh^FXQi?3veBNSUwUPMftv^y_qJN!3wS?u)gX?F3j&1=Auw-EI zcSjq{?LuoJG?1vXrx9^(TXLRXXCmJn=-ZAyOlFRItn%~J& z&7AZw)W0|#0EGEsNba*q2EAf4W5PQ~0GtatSstf8!=c7lWqzqgtd>ZK9>DiUX#h~G zL}nrLFzi@>E3p@BTO~sj)DNgiAwPyE0wR97RhsGtfTK6Y5ebQ9ck&<6g9$AmcQO7e zFbL)lMHl{eCc%(ieN((T0L#W`wBxxnEcCqfPX_Ebc)h=3k6<{8Nj7i-`70*vU@oU< zTEdi_iOs=0`8^;3i;La1Q+UeO+Kd%vuo;Q&lV`1D>B8Bq^VqwW+|6}c0DkswnZI0q zHVsnPy(86qRqE^3hU%Hge!YO?e>lCBo%*zpTgn=DceoS)qEqgM^m>Ma7q@$sF$>?N zN&|F3OaAyl1Wm-Q01%u1p$7XyUgy0U(Wfu6VhsVPnTogds02V539=by-dN9)q;e(ZMg z&iq%u0y~*Yt4qwiCjj6r;nISKR5%KY#IXL@khxmeHuQ@t0FazYLZx?-y4G35Q+Xy8 zyv6RpI6X>li|5 zo)sbnZUYdOIJyu~Q2?M$IXI#`+KfYl#Qc+Wp&WRUS9?d2z$B)$Ayx)Lc~oq$00pIu zG9LtCV*|4LKoM!FYi{FsR0aDyr%1dJN1Io0uSIr5F1NT)U9S^e4#4y%^8vs?M1l!q z#A9O)P*7+%f^C3_2@i;zO&9^Mit=DIYv#Z`w(b!*L<3OL{Y!o_@~DTMO-|FGpwI%Z z?U0C)t}f)@kp{pGzEZ&V-S-SX@;h9haHLe)UJEn<2z(7@;jz)bNC4t;X0;ojd~jz6 zgSnigJBk(JXaOW{@FVwtiU7b-3X33!FbI?%sQJE5bSW@+(HsDiS5dE$zzm2)g}rna zmf1`PC{>itrfC3@85zc68;jdtZ85Mblv$t;gfemCAy6fd*HLaDFc<{u+J;F+Ve1fJ zcMgwmEiCwON~pDNbia1&$pSEFWqHw@y}$bTtdE@hBWc#<{ck69#@2Kl*cD2lyqA{N zXKbTPb)3(%X7}y0ox+QpWhQ_bt8+f2K0*V903cpzdjx!7AU@h_=V_z((ak()^R{?VEQmGe7z=8PMI?Mu9NDiIL~*>)mo&^m>Qw&oJxn+}h)1<8>QIA7V`H zu(E;dFiZQg=?Ha<4$SZPxNdCBdHuY7;B1s-caDxt+>bX?VWNc|lNSzHjQ z4kLks-?4vxkv;kjON62!Mq){58PM!!CFq1jbWd=I;y4w|@#5gOR|JR%A%Y$P&H5j7 z_pUoNcWJYl?isV#JBH==R99ViNPQ+yk%)MMLY}P7^n#O!KzM}n!AWhEq8$U7UOl%Z zoW;UZS1r@;VlLlAc!KSnHOvRL-73!cL(yB3+e=_iL9!w_W zvv}NK=C)PAl*<>iV@c?IQ=OSQnRwc1jhZtk+8e@&^kpw}CFoTT0mMkjwG!dl2Qw^p z*D)0u{qr=gstp!1+&o;p&y784=alpcu5J5MP6z9--|;3)e}RRSP_dRu{@YYo@(y8o z78Z7&iuKPF#1;OH`yZ?S^K=vz=16s_RPr`q`hT8!5T*xUVVb0SC3zcy=ij|FY;-l~ z$r$%?SV4UpZDmy~9NxOIc+dKMZK5e!&Ex*4tA?TwnF-N~lQEW)4qgwCQtbY~mG?JeL(`+GU&D9igOME1DK@V*-mr%mrm4~+!q$%z7+%uD}2 znj9Okcw^Vsea_e~C?R_^NYF{SwZ9)!2%5 zmQ(zZ#P_Dzp5jexCF%^c_!~D$c3A%v;(Q! z>S{{m?-e^APHLOS@#oq)az-TQ|prd)MbyI&;&Ko2>VAl2~@=LBztdA4V;e%Wy+Yjz-lO zac%l4Irlg2yxgMaW>_LUeyEchjcHi*1#= zvddSVS_Nl!_G`z5C@b*i{7g zvG5ygRBn#_?9~OsPyR?aTQK+7)WO(7o>1p18EURS5F%9fPRT)Hs>Y?elajKGShKdP z@%GI8OM+YfIhG*q;-RzB&s({qh%XrDPv*>jcUt0>*2cz-n2J!nA>d_6lm>Fb~{Nw;^qwhyMYPgA-%exUV}?!LzI$C6j|qxR7kgFXm(eonNv z5z&5?{3DfC*d%}!YD{*vQ&0F}KwAZGq~((+8BeO@MLHBqA@v9TMbYarUMyrbL0YL<=Rlp7{BhqGD54UHcf$un^aVTjxHhgWgRKqh8EON>xxwdiF(WH1sTn+I_vS9Gcb#1lCu9r#w%pZH|f?WQas_j>$ zrWak3BgnW5IoOKajibRVzX}eru7=y(VUA(@fdTTU`b1&67k$p}o!q>{yXQPj~ z+ce%!xcyKWH-ik&Gd(y_B+3{~s%Q!C&U1}Ztz)uwrLySG)a?!A+PMA~|B=>m9kH|Y zU>R4KdBThzrD;&;_mcVjDxTD^RK;ag$Ae2J9fsYL=sRcNtX)$hG@q1Mis?TNwXz;J zimr~_qR-M%e@=+1&`V%H3Rynpzg6YeAh`~9P9MY3V+H?fVYf;T7fGj^6GDf{Rwl#z zfAb#{u5;3U8Jl2B`=#lwuj`*4chtF$dfYFJr+l?axh@fxI&$hhN`E@;t3D%@6*_CJ zg4SR5eU>pfr(F0JnRv|nmM{^iADF%QlnOa0$)Y3f^nX>zfB#0*McWybe=OzOjs9n+ z&Pb=Y^M&3^Iw&cxv1AQYENGFo=+_mDw+pGvNXnk)r>JRoP(O@C(aB0FCML0Xf&Hic zcR%+TsiMli!CVwj7r`8!4W5edfue#c|0f@o+A7>q{fe=SJf*EdSxoY@5gK z`DL#s+lRnS_4MXxOprd+jro|kTBk2;^GQn0Ed_if@7J&K?zyKnxU3?D_2!cDHza#& zNGnxqi=V7Vn2H-vte8=glEV&xH*qhL+T`al)bmseLxOSEs{*fIio5aaYgX}>C|$Q+ zvUwG@mLa*$<_>Q9Bv9b32pBQA?Sm0P!0j`*5eHCEma958NZlL-r#mE|@4A3+fCkw}}j`?kU{X+apqWD@LlVPSSM<%riL@I$*WmQvXi*~gg*hMk$Qmr@Ez`R@lv1+{XZ*}+yizO3VM^YvQOJ- z6!bpS%H~hQT@sz-U$%G})U98QV`V2}40cGCiZJMu;WzTy+aM9)e`LPEeNl`Qnk~yV zl774Nh23uUVhV`ysXLAR2P#V~>839ALd{4kq`~vg+@9EaSEDu^kBR94nQ{)aOEdB%xE7kyjO z-o`+X zGduHOd#PZxp@Vt7W13Z}0Fxk}-D1|e&HDySXX&GKhLDiK;l$v5wO{EBMZw_gVp!KE zA|!YhP((pjPapj&sk1q8=COU#_<*%vDGfbJ=|cdXZ))6(bM?*a(p05e4As>Y84J$J z@5}bZF5=%~v}5eBbk0g2DD%8ab@{VgoFLdIzOi<5SG7Iy?IX-%yGo)5&j%Wcto& zKrt>vh^ODTH7|zu<4zi^7&K?{{9(38E1hlEaVh7kj%3Q9FN5_3nY62FEPV}x9^Pep{%v2VdCA}Z(tYx~+yc6pHIF>?2=vr69*ZM)3!|90=Xd&J=VaP|xZtt9w?M~+6p+yceG9#= zF-`4@%4-!Fr}h<#WTy5tu#b%Hr1nMfGi56w5obgc6i#XyD&65}eel@!$Z{~$zkGbe zcF~!Z?Fo*4l#aa%{)e`-QcS>n1wR;(U)TosRF1H{S~`Af*u!(_ z$YpvHU9mlWx(zsz>X6ik6sO&iM~YjB!>rz z374$$Fq!@Ke9bmxko;H|$KD5seoH;Q)3@#Juqz4D@(27;7DO-rm34AGMQ1XS)AK&B z=l!h$TU|jWeK7i9I%XM*<~!Ux$~|nQwFVeq&@UkILooM1v!HzsPakK(4WeBB%hgA| z0I9~(Xz?$Cs`fU7z0_SYcdM~(o}J}*_k)=G!9{yT;m+#?mn7~NgZXye^m@w6 zLEm;hVdAvG^uiX`ZeGpUz-^(W2HKxqar%PS?{YmBD|``wZjfEjjz0t<%1e??iUw%3 zGcnj@@>pN|rO&+7I4ud?etS*`cyGzKSR`+ic9Qpd9Z6foC)}g(415nJQ z%Al_|Ij=Q$z?GB0<9a&l9B+rHqxhA2b?wUWT+F%RK_;$~s6G3JB-C8jW8X=zkEIU?2is3Bdo2FNZ==3j| z;{(gr6mw>N|2{=55B@%d({fa>k8|a4OHb99$|BsQ3`R-#ahJ|Memp2VAQMt{&I8_w zyF6;=q-!3|8!8bnt8GO)R+`k}z~UtOdSq(Zy=Ys2N7hbOdPTSGMA)TTcmTIqLAj2B8i~& z@3zQcK80M3De9B|qP%TFE@}Ikg*L=7Of$uo&X?o#DMA!#B~tYSA*k>MVFq`=yf>I# ziFhC)#4vWNsEk~Ze9Y8X+;H!tg+W{%Da^1sFXJIjRpHWejfc5{8d02Chd|K9e1{kF zako14+dSRCgQp#BA6IVVWX8ug`>N7*rSe7C6=q`xp>}JTAco8Kn}V9DG|PqGFNUE$2zE~MOwEG_y|e-H=FjggV3 z?ut+=Zyq zrVcCnm#I2$mJ@idEU`Vt6BbR%ZQt%1ci4r`bm}C}dN}QW){mT7{FKSgQ1nh6C2t@xS1=#{78l59-Y)|AjiC8*P4aW8{+A z*Oze*-a99{25%lD&d6lrtS}FPKj6ans@-!!uO0&P$y5Ch$JdK@s-B+xsc9lluCL{f zXg|-HJzQ~1%Mtp6#tX)9u8ZewSKK3EEPFXB5U@|E1%$lVI_$2#LF)=(*wPU5KD(ZQaws6nivucVfhq}$9j3D}w7>xwLl;YR9| zmB!={Q#t|mSC>hW3EG40JM2`mT zQ`f2}+__5)zmg{$=YEBr3(fde(=Q9^AgLNonbg~FFj3gt7(`XgzC4go=bfYNb zI^-cAH`DzHdRpK*&-q?T2#T09OY?q&K2HBJF^ggIJwC?3i?>s=KBa^)+|+V--F31h zjoIOTL!4DtM{jIm#3F^2(bv$$zUuo0#i+3Tp?Jo%zj1W$q+ulrRGPYzI3rhQhDa_u zh0OdSW+1ASV5k~UK%pqLmmt7{N|y}09{W%5n0ZuhbcRgHpZyWzOR~^VPCcEO`m;?w z^sd7f_B+(wtjNkAN)^MqF5#>8^bhRci!a4yER~(|$*|GpK?Njf(+)erO8h4||H+%n z3|m&q+hybX!qmwvpWgfQ^xTY?d9+_>kBJbvny+QzG+fDZlCl7tLh9p zF&Znugk7poA;+SdJ3OyNJ@U-ttDf0Epr&*;u^CmqdAX!gW1-UOJ5P$JmKfB`IrX0C zgxt*m<8R;(cioxg?Yfj|wHkwYd~UAXubddZ>=dL(4DIS`bKeJ_@G81`R;b*JzpmL` znkOf-#J%A2%61{SqP0Y3Dh1?ed<2}*uBwh1{?5%D5IyzevcSP+k<-kY#V}pFbTdyU z5mzs<)@P3wZ8S8Ac}4=2#^Q+&G&m{aod~IRCs7pT9YHF~@;TJPC2X(Snbz(a7D5#& zopdiCJuEHEueQs-q!)0mAg15gmA(JBB2hhqX*|R9C8;0$I(!))O&Rx9M_S+mttQTX zeuL+te0H|Aj>ZC_L9X=f_WPFLegw_zmygP*4|kpd5!w~oURn%{7Ug|n#vc4Qn)Cv* zLhWFSs(`_Kt^M}3C=R=+`8Wy2xs|SL+nd*RjYf_3Q(UY$?XAs9 z&#R9LBN3`g!EZ1#4r8g3d}l{4JjqpU;RQMsUOE)c6LVgq~dJSkzHxixaau z$!iZWC;fO@)y-pCTcP!y%##YsB>1Qym7HvhJM#^vN19c>0|fJU6JhlZ-1}WB;iVSe zbN4jwluwrka1uFgOSDzLUvCNiBCiz;q34~GVjRD`W6P-H{ORTy?8;>;u6vKrMCzvE zlGQ^uxZT>7H)M$M`Bs2kcuZ=H-R1kCgDk+1F5S>GvZ)hIRu3+4scR=(&e!J(fr{5# z1*~4AVZPL4;Br75(WaBORs%Q{=xWWG2nJ0TRitfr*BiAe4(llgQDxyJn3xwNpV506d@ zR(p$R-)g4LY9_=)iht#Qdje5u7cOeH_Qp|C(?czEp;9wpjB`7$>OLde4*H}(sV*e? zZv$%C-ZdS!)EIr>ILu6!aq{Pg*7_ z#j$jG)sSsD)$>Hl0eaYP>DuGxYY6|)yEpD=)6z)1UBgubOm&52)skgKK4)YJyAJrSS|2DeanZK8kZ{dH^#<_v>81-z@z)$1y8iA*sr`q;fELu5nsI$K&G$HTrB~GF29lzYlHl9d(!6+iE2Vk0GM( z&7|Y+Q(#maa?U=Dz;PGMqoN`grH3d5?JDiv!j)Rg)tpKp!{Q&!H{4lH!b5C6e;Sm1 zA9RytMok(`TOoK4;bYl}&$4IIKdBc%Os79`#f~!e)8ohkq@OMPLq}kFs&MiFW2_xB zM{g|ca6VhUh}GTR*i%xKe>8kS4jg zdXf^V+nq`M9zVJ0ZYC8bKAufqeM^k%i?;QRFP?*R!!5oSc--AQI)knyzDA|&{2spwxk2A$_a|X*O1!CvPks|KH(yBa?Ijm!RQ9(8*t?Z)zI&Jv z?TpLh6O{aC{mSQy^WJiCW{d@_6xKFdCD{}2$%tt_jrM8UJ8X7dJ;#c^@w2yp;%(QJ zV#~iN6Xn5TH;Gd>jOtHk(>`I?kv;ib+?7=W*}(3}xF?q^mTuJx zZ{L3YbgZGqEqOCo7cp}P2nG3?KD9vcuEpqwI+S$=<9D?fs*LHRRWOpVe-*}s@&!>0 zET4ESosgxyJE&J+?GRc0;Pa?Y8I*6-m7~6exHDCnUrvR9E<*MQh2;WFL6 zwP|ygKhJ>3vma2)@A+;o?pV)v*PkVjZ-y2GV47-)NtGEManCEcFk8}_H=Fe8x)@}s zvtbRF%xQr@qCDgnz5a`nZ|iAkhJ|}Ml9gC4HN}yOG&r!Xeh+#|CN#XqcYv6RLNbY9 zCSBBMPAMg@udo(0DPs$A{Z#fOiRdXE;XzBOo1=+1srb94J>Og}B;1VK*|W{OtT;@o zhT=r-5wJo6%hVl~?3x0Ufj{sZ0@Rp4GF?Mv_D4Y9UzTdgaehGQ#2 zbz|4uUz}gO<=69h_tE<;8S<6e3}auP*A0Wq4M)o}yN}*%$=qAXbDV0EaFOt;*AihEZK- zybBN`&_nXkFPzp%R&TKp==+tBB}i(F#;6jndBT&SJ@KR&&KU96cM@y}YzRg>7{F#6 zXLN;|UQoXN+BN3fsN1rERIIsb1&>8_$sG8Tx&&XM>go21JLd_cWT+zgZ$_Lxz^c>_ zPC4@%W2>08jxU|eAqg{jPdq<0Rtgl#5Ef?Ha*6K;V(V3i6PVEtXYXkpk7sU3A|1ht|i>6__Bd<*s82Z}2rF{87O?sQ8SFKetfia|3i$Y-C(*@ynkM|lw)=4RR zOj+%_tf-S$7_o|2l26~VZ$PeJXIaxUOfFFjo^T^6Vj^rmEXp#EekJ7|m1%%EYm;_< zuaU%Rbk2}XZv(dXEpy6Yb-nU+L$72EIWYjZ|y9vnq-p4oD|75w78dx@dx{NrrV9Y+rE^L$=aF<<5Z5L6fj;6Q^3}VDzFkq!}^rNonfvTPMXx4G5)z3YYu8CCHFJ zT#f0DIoZ;rQV<9*GBuj9U&ow@AMlPk+sd;Bw~x{3AZc^N6BPxNwf$Is`h<~rWt!D; z>rn_H>U?WW*R2eg)+voVqh;cpXc1amAgpg>=xje7Ip0j@a2iiKslFM#Iv0T-zHpTc z+Q5zPY*NIMd!8zQt?Mfy;Gg)F^4j|tqpTX=#H6lgBMk$2a7 zX{QI!`qL<{Q%*sm1$I|u%{=jUdD-v`1jT9OUbbC3J}iKrS%!!*)lYbTzFsn}rc1^% ztLPe3GRBSfjLXY_mz=Q+vbV&gX1@CPwqBV6dhKGaH}ypvZ&WmpL-dP*zx$;L{xS1Hu2B&=(MADok;XzZJw|Q7AvCfF4Z)%z=)5oeq*-E@ zN@Dk;1E5p%yjI?cWqKE(s#O=r-uGBZ=r-ZcE8Zj?BE?}zN-q)fhauZ{lZ?p9A$M&X z_L`Z-a>x`|v*YCv{+3f?l}2*4un=2GSgW^E8=6aa0HSSZ;ep#%w7oC7Q9HK+T9ZzFwSFG)v9qL?hpR`-J-ZX_3Hn>)=ea$~2+gDq@RuHpLQRXRLh@io=&7PO>} zaqM}xy6+#H(Wb}?lombFuMACiuNKK0KQy*u39!%U5Ykli|H^y9V4ISvp>#YsR>Zvb z`qk%l;_-gL!aE4A8mNVx;XB?AdJ^dv1n?>M*^~{9!gVxDaIdYKmkLiFj;71at@NgC z%?UCfM(!CCqh5d|>`c+fNwkGjaQ`?Uz9+AaWdu;X=Cs+NQuk6R0LpeQ&u>E8Q+N__ zsHp1MjcnDWhx9}RW~@&go-|x91+G<>hJFr8LEj|a)^*SeBnohF8(;%IC&v@3ED>FQ zOo7G;a?-9B~as7Zai17L=Np`?t%Btb}{ zE`Vr?F-o+yhF#XwjdYE%>niibeTo?<9{!$9l?RDO;$4V208QbBHIn4}cw84iKz06f zfj<78yw3?kma%_xGXJi20>Kyw_a;Ih^~7XUnIaQms{606wU_CpQ3YLDPA2O@QX!9`9tj=}jM}xP&CE)q>apNkP?AMgUG60R3_QQ?U)UP`4DT)tzQzWH0WLN& z$zah(7>}k>v3IaCerDSERq6!eOP|O_Bc!T2aS?Fxq4P2ega#<) z?L`LOnZp^}IHNJ2=aF^Whc7zilNSX%zI;z6o=)Ib2!7Mi~dqh&nYGPJX1@49a;9P8pMoZ~Z-~*bk z!p&D598Kk-os-;))*>;DH22=PJa2Wl6^%m10rcwqEaoLMq2F@})FQWCPWc+R51!q~ z{c#l;oFi{_2tecsI;*sM@c*2#Lj~xiyrRAG>=wjWlFh4)k)6T=cR#)?M6CIF?4Sar z7)dlm*$PMOIm1FXI8`KHX1qJTvcXCK3PZdD*2cR4nH(n9zty{~cqc$3kk!`IM*3_( zXipBq$;cBwuW7Ev=j67yK^a)AU}JJcSY-&5JZ1!_{l$m6e}8-9UQiPyG1jE*{UK11 z_KY}nQ_=hbFyLp5G#7qTlm=f>#*_sQ%RJ0HbvLLRcoBG+oe=OtfFPeMYyPF=5qk-% zKA+GaY(+RZ_&&|TZSywg#LS?&;97oZtEeR>Wzq{x+swx)KSy2}|&m|c|@oY?e= z%AJqC*f)HAhpzqNDXYwPUr6Ixpcql2zJ3%GS(QnFX%o6?%(!{KeYsS2Vj@<;nDI26 z%M20AXI%{!koitnr61jlyC3@2TQiFwQySklQ*U?nv`$Or>gHelY43%-&$BN5Lj3$KRdffVFtu9daQGoW9!zBQmD7Xz;<@u8<1`6B zQE$WY3FtQmRIL?Vw=xN=%CF#5CIbes4RU>@Zk+wu#N-px(t5Q4C%71A%gBZC0wWSh zrnoEKq5iQa@|Sp4qrLR(=YjUK6uGK5g`2Dx=5W%2Z!cNQhks2Q)Y;Ho5?QirQGE<4 zis87lSjgr+ydeD!6|Vhae?~UV9DozKCef~?^hyWO`3mrMwdxXn*2roA6I3&f1)uWV zcc*`ZDV$@L>@3@N4Mrsyk-WS;X7X+(9JPDWeqrHMZ1nw4y-fE;3h&TjPb`yxU{S2h; z5R+!pok8?8`cjefJakQ3dIt2Xn_g)KBKZ6>GluoHOCUdPWmTERnc>M@H zzd)WGApWrY4pIfWlixG~rp`-(9Ni^lZ9FTCJOsllTR^MfOgXJGh;NG1q!Az7*HJFa zBD{0gm8JV(BP7Z6G-;4kyi@nob$UA1sdl%LU-*sRHC7&@NcrW1>z}Jvr(mS1+Me!za;RJ?ixPI0SaM z3r0KbxvEFMIMvh_*jNAH8J74D@FBpJFzV;Tl{o6}^lG9?L1H3rv|#uTdE?GpT$wp!JiXk<4m0Ws^d(YLV;c*J0)q=-R>QTc_ zTyY|HG~6#py<|N4R7&|;B8$1=e?eg{y+Nq@(Gf#>bjE`d_21Ae;Ffd5Z|EAY7?jG^J?(Ie}!sQcRE!sHUYu^3Z*=P?(Lvyn9ww! zo{;~Ae>`b5m??+AOD?DscY#OqkKmc#N@L+5YCJjDs2~X5bp+HoTr{fRZQ1?;$Ed>r z1Xnx^jCS>YgA>voeF(Vb#YX_Yz<6~qvElJhFxu7rTgzEq?7g9RzZrvmLx8Wy!Q)SY zu}*9}*iVq+LL#jGLh)(<6amC@t0!rdzdtwx%Ii34DMD!M!ddX}AO$X@Ishd_#}gNe zc31ywoV+W=Q>)AVa{_?>R7kj`1XV*rNr8Cc_dI5x+J?K|>bS%{H?JVcrZj#~s&mn( zp@Adf1Fmt2Lty0)I0Wi=a88+5SUGrbomhJ=8c=a{5MkFQMI21uV+3>*U5CBtX*J8_euXgBof1g&J?-RJrxae{0n74|MqH8e3uBZ>YRq_2h?l zhrp;)@o!>0Xu87hc^v5J>W>G*N5OQe`?IJRS<(Jy?$=m7;WH|~`#^IHPxfv zMyx^N2r&HsD7XaHz~8f9b;hXAsAl7G%28njl5)iwMJgT;`-g;zUDEszec0FMF7Ux6!Lp?dTJ2wyIkOyNR; zFtFAAwF--l^AH_%c52+O{F1_Tqz@Ji);&}mIFhc8jxz`xb*=|%qGq4PJH{k|rBQrO-4A`i&8A z8kJgj9XwEN*(n8xv-!~ER0G~5IDP!)0G#~y9Rkql;F|+zb`hkof-6>6&*JDsfu_FI zY4f$?djvC_6eVs8!URE`BO1y3OD>eT`U!)sXI4vh1cC{gK4FRX7 z9Sfo;n2-sE#YnPUO_*y58V356;$NfM>k3Kiykt_X@RkZADa$FUbHK~cyTwo2`>DV%O%=m!l*0fPw5J-uY6gbg>7JI~>}inp0K z)G2iH9`8?f2QJ+}0l_z1b6;^F&50QzR^ZMs!fLoe-vmR*)SatRDr>K(Va=-zQS3;~ zc#God*3pjCMzK3e% zhEy^Ki3mNu-(JMr!4VMfRi|?HT0w!Lxo@%-x%Qm1grkWp3T{!kp5|fA!Cg^u2q52C zH}eFnXV%lk@TAu{<*QMR36h!GF2-q|TA1^(ESTG`>2TB)JIf#5*LiE((P{d6YwT+` zswE^vAApm0{p!QSocLt5@v;HhFVLN&0-3jg%PI`yVCA3lltQ8qG#4ImvD54NM&xF+?ta)bvXE!6(%pJik-)!MX9GLJSkLj}vf`i6wt7841a zM1&?YQne6-&4JIp%zQdU0Runp(cIoHtrbx^k7Z%W#2~ruZ@R~2l=HgOmxNEf?v2LO$(b^}D%9G#ooP52nD~Hbs+hdchgIS|N6h)a%|X2I8O0oF zH-t87ar>Tm1mSW^)U_h0k|gnaLI*>yLV5lG<<-@otPp*acsKFxx&2^m7Rn-qN0rzY z9dEth-{j7b!#PB5>C-U!iT_Z5aC!P{rXy7*;z`y3OX_|Mg8Lu`pcFBpIxoj5tn&U| zaR764rd|01MW0(Nfjms(y`GW^l8o=NJkhI4z1Gu6!_VG0taA}Qx+a^8X`zT&(US=N zU?`0&RMb0nZ~?{bW>Z-hz`j?G1fgH$7eKq9|GyUrGq}4|5r6% z{S`;kbvuL2;4(PD-QArG!94^L2<{LZ0t6XcfFpuxYR z00)H1s8=+EgJ*Kh;YLi}4&_JZyF^`MV@x6qnmZ_9bPB>m5!B4`*=* z1_@uL^`|`caKcP9Y1ZpKru7hDET2}0U^vrnaMiAd(PmSrz}b?$czvhV{k{f1Z#z1JVRJdDJ;EY0~CR2G+i z+cQl$M^XHFl(nPI+D%Z(B%VPbBo8w(l6G|tU-?qvx3c(=hAfO^X%?dk5Pk3=e{U9J zHuwk)A3w+#B1Qx1z-sqfnU-E@CPhbH;%Ekwqa%${Or>^pwENdoD6hfw1T~U7IEEUU zfSNy;U}XvxvO7Qwb3x4*v)_9tu8F}t`v@J9q%AB#VFXBh*wINsm5DpF@U&+nz^0+M`|{0? zj{(hG2!KKBzvEp>Dt7^G398U?cgjkxv%-X677cBAcl1szmRr!<={L;E`|&t#7bRE4 zlj$-SiWRm15d~A<^*Sv)N)-417>wPp#jTPWjF~L4#;tmpN(cDlNGT9yNe2-|g^@JO zl9+zXoZpYRK<2b-_gkxX=T-c4KGEsL)K$BiC^x4K96G8bQ&?R^HyGV_Rfq*b38vtk zAaC#uj`TXez9HLCjHU0dXobo#bY7n$m6mX&?bOa$!uG9J^g$8n`LUewA(TP-dzl!2 zc;=_ANy9fZ;bgAv-ys|?+4$-(ps9OF-vv1a#j13}b>=A)6oMi0g5e>MsKzUJvb zq8i6PsD=Ut{V!Cb=cnUCYR-{>Mj)r{h6J_X)&GFnKMRHkRvh94)u%H<$1}^$S>P8o z6%1K=4$Nk`!GvWFN?8uvFC8;uSAxo<_kn)xYP59RT?_wI=kKo9xjxiJ!c$a${P|II`R;VNBQd5XAcCF(6S{ACGHEyLM_v~>01^k|qE;ZRx5?s!U)Z`)#^g+RN1B)d^TVg0>UJ=P)^z3!N0oDi%hC#uRFlC#jTWhHA8w6ijQVcV`g~rMS`yvZ!Z; zx>=-`u*dxSXW9J>{IAK`L1*_BbSvg_O>gdDXgotE969n|BYedC+)!!;BpfU^ts9PyDx+=A>{r~g46tt1y{^e1YjD1Odo$hLLF?Yw!z6BkQRU&Po= z9WtgQrIKA^2^DhmP_s0L;Rt19V6~f~O6E9R^&}$o|3Jf892P*F< z!_dYDQnTTb@+gFsm64x7_$MKuV*F2VB!P1FB&1!dU#;0g9-ciyp@(KO!676(nSHJF7S}}o!z^4 zLqITG9eCmYMKBVT=~)zKWycs>HzV~h>@F&RIx&Nv7FL(AnqZ|YfUDEKoGhe@_}kraw>uCaU@Q&dm3@sWi@zizwVzLjZKogd@5pWvR>UNx}(dZ|I!+YYD@o0xfCtxG9y+j4ZZ&@h56mLFrh67B8; z(z*qXbYE|#(H=CElCU5z2u*`wp1?xPl9DXTp!GoFAdtuvHPPFU_kj6I$f^LL#S2vc zwI~wIUZd=G4!FpqnvXKt{$Yu}bJ>SE5+r!;EKSMb7Jq#z>G1&x*|>6PwWE_WC>W1k z`=w}4U2p)QgbILWk)8?W&V=?57!f#1gU?C1SGl(!!LFr!(5k@FWl2w{NM`=UBtdq% zVJ4Q!puqjMhTBb35gx4y_}R6V10u>dKR7YinxbR;DvS6JvgL-Zvaj4&FnIwvkB{JA z2|x(b>xR#+j~d%v&$1A7S&Y;{A+cE7r$U61WI1v^uh5LYn1f$X0jFXU$qWOiub||E z11@wPau{NVxH=4nG5mC8x$GHPrY~_Q2wuC=(jo^=C|IPxwOVcf?ey+#5-NI%y4Wq` zVXLWi!a<{}qLHJkoUpI__run;-?@C*&ReskV~rMStaNpzxe#ye$!nu2QTlv6ECwr) zohVnCv?8+?Oit$Io?!W9(^qtY%a2zAJtap?FW^&@$RT0|cjf_CzU<$Q_kB6KOo}pz z*psKuxd}dv+f^=%i(N(Vv@q^asM3sd1bS>LQlj&*dutYXwUn`eH6elQtihX&HFYjc zYmOt_oK;kZJHo!ip8pgSOljz8PqbKmIm!(^w{~tSntD^-ylY%1ejmtnT5uU6w zm8h5$L{gk+3y&AU(PrZaDY;+z*c+GW5HLI8wGV?>gCboC$t_;Q zztBV`hDC9^h=gST0On{G{Tm2m&`W2m4skDb7F`)U3%5r;M;E!N%r?#p2CE1*4ChBv zi}rAnJ!psu2F1DL$esp7zsM`pw@s%&Q8Qx(ck3cEn)pqj`aZ_FpUp=d2R~aw#z)bO zIBvlzs<>N0C1k~YAO?Jzl2XZ#`RTZKigJ-L6Za4QhcdW8ZB96vyK+S5wC-QP`zk5i z=dK8jP9j#bogpT`@Rv@8UZWIw0Ti4;ksWBx-eM{j_<@eLtdmb!48rL5B|M_U^yuPE zd4*?8!4QRlwNL6xdbgJX;7RXXFtiN*MjLZ{tcRS$=PLlg)zOIcF_5EK>AHf|y zjX{Eh%bwKDGh18rT=otQm(KMr(F+>cm6C^YSJn)f0^<~r;YP0Da4u>s+W8MFcdZ-D zP1W_%;We!?8QFHP0P&Lx7Z%2E+T6R@nYY)ynkpM^tl`aTTJSXLz_#V|9RJbN$&22Q zAhuMeKaY?6d@lrgiM44Gd*r6`t2`MmU>i46-qrJ>c1cltmY831lTqIYwK)r9qBki5 zsmP-HDW(XFxW8ZXf2D7~DXNZoc|eNAi5}xnxCqbj>x)*w_3Tt-i61)HKg+t4Ws47bIJb)qOk)LVz$f)S1o}&R@yG^oUj<;yFQ+ zrRW7rWYCEJXDhW6C{o%UeBlA)m6%{aCkiR&|7PAeX@&L7bI-DjPw}aUu^?)~NR$`7 zSnN#vMGG!zx7Z-vM*{6L10qgsUFZS&$AvuN=H0GzQKI$I(X@-2Q`X5e8vk;>^`HFP zJ0%eXg;(9EL=g(-545q*MldYkA%({Mm)KB(jOXlbZeaF69_LtwOxS^e zVyaL;BmvNqk_*3z?b3>XO0g~2(N;{~69}jK@gBb=AqMLesv6!fzBRv0jIcy9GDXLy z!*HnFrn4NU8E`LCI7$dJzm|8!)V#Y;6b^gk7R18B;t*U{89(P_Lscv8Q!?5*D!gTi zb_byeQuL=02oR0UH8HVGkQQLRz-nWdtzmR(gc-{V6Op5q=sLtC>8%11SJEYHO0b3& zBHMq$e@4*fPc}L6=>e z<*0;@#xM2sexcn@ho27foYb4`S2El){C^1M%6#{Ey_QBTBhTX+C0=>G=r^Oi=#1 z(q`mnQ+Iea|MQc=VykC=;|wY7Vk+aU6z_m=_23OvzR1!o?byN~Sz4cL)8Y2?;0MwV zG~%J4h9Kz%tC(jzE~{z0cS{b$b}!3SZ^%?{K0mQf6mJg3UsWZBk;UEb?-%)l0vS!@ z^s4OB7Kg9h+y2zP=M5VfW@q>IcygRS3^56LKO1z)|C{cEv3U&s+p(M=ayr7u$aeJ% zJ_R?xB_`s@^{pJQ;`9^fJd*^=L}2tUz=?o^gXRa4VZIkragko!X3qRMN#4;K@nv&9 zIAAyH_AlU%GTD^O-1kaodjo;AV5#)C?3ERI`3c8b6Iad2NdnRwbiapZ1bUIaU*2w} zyEHY`;Qj?1hk0WCplQ}cXU-dSvZ^)P{tIZPlS2(Vk}eQG_vvskZuiP~LcNgN?%Uq2 zF*>iSx(HWNZZaS{w(G;oEb~rLsByL!^Z}Hmr~wsQ(|=pjH9yBxX_J7DSdA8TEfvVo ztG=O>gyYT1xnBG9``y3mT$6Mn7f%<`x7J2jQ(sEspks-`C!+R)J1ZpJXnQ8@q&21@ z->kf#0E9F}EX9}q!UJ%kbNseL(=Yyw{<8=wJlHo;h~=8 zrL%J4l6oa#-!(hA96QcU`CeRvWf9CI;ujvx;KQTGWhDA4616$5Vo_ggL?ibZN;kLP z)J$~!TwjTX;Y>8jVucbXB(^&dtdXf=|8;--G1gpsr~*aOi7k#5*KV)g2Xx{nRF4Wq z>;EjIl!XYiD>TWnuL!dzf|yB-2z@RmeB-t7T#T7Z8jBLuIn-)S7luY6vL88FN`uY# zJiwid*;Y(=VV-%si?dVQ9b+&T|Lp*Vd1ru`jBF2T7(ONnK+A>Z z@(pB*BR?bEm*N-vlNgZ^VGPs~C)SkIsT~Umwd>L`UkrJyE0~`|fBsDJLm)guTe51< zo_Ztv+AD`f`u&qYolEo3Tkk#4%EHZ0Bbox}z2_rHDUW|F#$_<;)b}i2Z_9pUa-?*( zjPhH>F3YY!MDaM_gEjy!$tB+`=6%F{M!6TPMNwU!WcH0ev{N4L0JpU@tN<+!D4)<5 z#oAAoooiXn5*l3z#cvT&6UzBH#+jM?k({lt{%S}PX%3Ci`JwORi6}v5q9$ZC`#^{~ zjrRM>4PqgI_Jz0tp?2M4_IidT-UXX4;(I}&bJE4{A=>mgmPjq-6;H)su_^RUzeN2< zj`AF9vkz^L0$EKb51u`>N#;V*nb zH=Lm&vYtKxqu523WC+M5eJOx0wE%_W)A=XTg`Hbn77ssRBlHziQQy4Vm+Qrqr~C}p zGV_5ik5~2U2an;x@Rk7KAG<;w*HM4JqI7XYU+D$T1~*;z0--*xO0jD3Eiwa@%K&Ct z(cUWymmMXhQ6~Kf2UXH`r4l#mO05+{H;~UD`TZwM4Eb_L^pV$i4@BCOEeu71bOVaoNE< z&UR7yjXbq?Dl{O$pK6;ePo9VAL@oZui#21FwKO7MEou=l;8AKv3b7~6ZEp1Suar26 zJWH@j{%$7GtVQTl{-b4thuw+ZK~Lv#ZmiRQDhW@SrG79c+MEG&iSp#}@tF~!LmXVCe$DK#y9VG@g|V}6L|FTIBwnv2v`kv=2aPErJE@3nG*o) z@FHXNP3!eiy`9c5i(9;dLYjS;hXPhhJ(o}2v_IV9j)--2C}*8&_?(^OJ-__CriMcn zj&P!A0O7N^>kzdFv3{|*#L~3xH%R$9JMb5fZnMiXIM<(IYRPxg0%}u(J zbi&ht+&9hg^5yNrMC}OzkxrAhjZRsTA;k~=4`$AuoTx?HTj#G_u7;!;G_Om?Dp||Y ziY|t+UcTC-`Ppfug>>Pc&Y2w=)L*sXl#-L>#5#Qe&xBZRKi~P4t=IC z_kc99JPZZio>{2xEd4oFiP|Q7)A+lXpGJ&U8A=G2i-I$1vNEgLL>Qt?5bDXMxu7$3 zu<^R((-oI%G^rgL5T%X>|2T$@ky!&ZI9_AAK*f?mC3aKs=S2)bQ5~BKCkh=(6YQKGjTqg?VAR0NV7H+<|I$9zb)Ckq(OL_}K<~&?=qD9%E zu|S2fSZx7Yn3RH9qe_HQrwjg7KHL?Hnb1(3UlFdLqC7*V2;k%F4Z$IvKvNDzV_HUe zr~D>4zZgo!d*+G44d9SGc9_L$$CDN8NHiK7@|-->`X(9hb>#6ORkiwr-~{>ga?RmL z=_K9PLEZNR8Pm#YZ1;MtoTmJ|RkMT#+k`{X?M3^A>v!boM;LV)p$g}&u}RuO5@3@T zQpb+ygxZ(j)I$l27gcUInH+ZLG+F2{)%Uha7fkTP{*gAJ7hTUHo%@CA`K{+dq8Os) zk`O0U+(HF>;Axz&26*{*N>maE0CAh7Tt+Dno;N7dTUPZAaR`LKSjC>_^bi;((ltzi zU~%Nw$y3Ac4qj$=a-n#lRq0wPDa%0!tw?*DwZDc85#xjyG~izF-Bt4w*eP@Nl%cyC zUn6jUU&HjO2XWl1zQ6v^^ooPYgN0NL-3_RZSr7tMr+_5|OlfZ$fU;m1KN)?1iBy~c zFT2$U8c0|@6Ceiu@4oy3HWkzWk@-0dulGG-^l)A^PNY*YX{uZ57iCF`eIh`-R;S}B zUP`qg z^o8|~qbKE_&=H+=v6JT0l--gCm)x@kA-1&HyS^)Zd0Ly6K);bh1`#k%Q>L+)g2X9o ziUU`>AjI?KVz!0z$9#!3&kI>{_ta;ohJZHif-qvJDS$33l4_d;N6m>UuScK@)tE?B ziE_BsM}TAl3S{9g)y&GhQLd8{K!MZ&ZzQcC z)#lSQ+4Ha+KOQ2dwYP2|A-KEuj_0?dZ|EVhMhn6B06+Ox5^7wTOyM1i zVH?hEOgy$N`5mr_`ePwz&slQ+A6^gjSXXw;CJiD0NUmbaRe~IOl+Eq7RcPtSx?1vh51zzBDt)dzplt zZ4=ttIO2pD72lGko_H4eOi)gH{fi;z+NJg~E?Q!Db zM5K*=>;r)gC4jmtj=mLFEPoQiI#?Uuwoo&o(}SK(E{s?6eIdv1PxN3E0~=PZ$#%tH zuFOi+G5Ijw#sDChRpEre8+LicIagf`#up>rdot{+B<*2g?<5DQS!z_+6qdvbZL&9a zR*J6i7JN!R{kD2dAgNfa{|)P?xsdK|oQuBte7Xc%V6`ww_uFy4-}{xTied{*)Ol*` zp3#W-?`v7I9?W6PIX_Jmwx2OC-;&)fWtuGJS;9=4(?3o%esbB`ae};hNin7(9yVa8X;D_~~ zjiD5=^J4Mz#?0CSzP<>u?IOVE_Vk5bc$8drG2WV(;j6X>qP*h~D~tpELe12;eOLR{ z0PH!5t@f#kOW(7Pr=DlUClnEn`GF|fj zc|VpBtJTN)1f{knQtaZXCpq9mm)xAzS^ zX+AnaQg?Y!E}mw@e5_ft@SV7MKN+;Fy3Wu3K{^|$*tVTT@$F!eDqpn?2@rSN9{G@c zv^4mP2;eQ8LW+euhqVUqk&;+)XKHx)sqdm2_o^NL_az_C(f9rBbp}R1t6rLPS2Sg6 z{pADmf!!^J)6->BCGs?@6D&`;T@k;`0Uq>FF>BF9keefQCmE?ATclW!`dhrL6Z$ch!p&&sHl0+id*an zz2pypikFHx+A!a41aV(<$w$(CP`?zu>YluaV_k9U#@h}OOKiGv{|m4o0Zw~E6^>s1 zARorP@i#3U-yRh|qmgOY<1{Ewa&Fsy9D6jl&%3L=mc2AR3fk-V^A|83)bbZl@E73m z7oh*N{Z#ol@Sycn2jrn-!pp02(s(9l!&CV~4@DAWZ8NSe^ifs}vh(0#qeZ;@+2@%r zrfGrfLBMHS`oD}9H9mvEUqEO4t}}CQF5a(yn5}8vdwlE|%C6=#Y9C~wl26L7T%?F+ z|6z3`*=!88BM3?UoH3uPMbmP-;p?Xr-d>L>oge2WY%fdGjKO;IP`Y|c7Wy@iaX5e3aj-KI$Lv*3)n`;0MYN&c9UF0%U1H3t@2CykL@zg%jsj7P4RB-pUj*O=Ea>d%T?-WowgyqIcr+t zj~qiPv0)}0r47+Jw!Wz?+4+w)l~8es5|ih4g5y1HJ+JD2@%3-O2)IbyyJ^=VSd>&H z0VE>*I&} zdC#%?+kTYYeZAO0<2PEsim;i2GH3|R@aj4H9d@Em?T_Ns*jjk$ec^z|^-&w10oYz( zOp8Vl8=Kcd&2+@l6O+&1f=C=Ty<21;M-Oy(sB(^%6Q$wqi(W%gG*Y#)l^S^Sc=Kw7 zff=OT*CS?>!HI{77oGU(kuG4P*(Z#m+31G8?cwvg`F=Cao*-*}?~lt2%~G~Tr1+d6 z{w0_)8bl_Gva9_*C)B=>K&4n@61g6lI9hSm7-O$XNn@%sQtP`WUYN^tYliz~M@ek1 zGYzykMfeW;b?5{&ud%v`Ozgd7%5LO2dvHx|4?(^(`~9CJ;Mrv2$2rEdoiCgK9{Gkh zxPfm2=fS|X_Y|z6MY2r<_Ou@Nf^OpTj^{8slI4582BZDm3$yFPL{Rb17%zN{yl-gr zHWDh1wOP zn~uZ>L9zI!bHkuCkX8dgK#Plx)d?_{X^^tq(asFwB?(ACWaky+DY?&z&6xiA5by;h z#%@3O!nX20ey$TE@5Aw)C6H1QQXBKweHcOt-Fyr6B&9iv3<$({5XO&2_)u))YNk_VB9BcbRB0= z(zb;9XQncejsFE4cx2kAIVW6RShD;DX!|vzlZ`K*21|u;0Q5aEgb?9@+a9w*)dv6r zytXChnt~nTQTf--(gAI*E-`wPNe)*UvR?xELL~B#Q}T>%bKyhp4$#qX62#W} aX zd(w{6R;`Bnj`4!|JJFlc^B=h__=^Z}GHQFuBGY$P6ZPPC*}rH*fdx`B(inv|$kcyg z$$VHrE|LD@1>`wB9#=o*#}n^)FK^DYTz&1%?SJ`!D%<(-$jlFYWo`}E%kMdsSh>q} zrm30sP`o?KUR_$>Cn#a$GW}6bXvi65>xjI*Gfdexr8|3P{!-z35YH*JG5DT0NnsNv z8R8}TwG&(wz?S9b_yQ$k5AjtNHR6<&3H6$~tqg}{k+Y?VIl>}>F@BNaFh>$zf|k}{PU~;*P}G-9@_e4cb$(X S)fcCdQlHe@F{PIO&i@ZEka=tX literal 106795 zcmdSC1z1(v8ZJC(L{dPy5fPCTkVX&?LAs?=x}+p6Lb^KyB&1n12uL^5-JMD*rT<*u z-dn}9H=gtF=iWQ?nQN{&M}75v->Ajcp|4W_<~)d`k$WD#X(04f|<5EBj)0ARMNP1-NL5ddK1kpWl$21@_{;9-O@ z;iaK z77kcM07nK8h89ImhhAu50l-}vpv4pbz_*wH?#ZiHC<3&|?$FzRN^l{AwJ5L(pkmNH z0V@Y6X~7civ`GMz9smo<6-;T6M?fMVP3{hWZ^;3=lUIT`?$TJ$yMIg|86e4T0s%k) z+FRfbSSt)5a|Z@W4?vj+UdR(cL4kruybS>0TLA#dK!Ec3H6W1^diPHWN(MlCL4h0q z-avZ`cqIY=ERf^{3#A7T7631|1uy}4Sa%qKrvOL|*pGDZAs~z_3nOp`diPHWN(LbP zuc{SX*kB#-yL2?~9_1>vFRmK3ESB&{sZT9{s&{TBo42z}0$Kh$RG|eOEJhv&w8j5I`-! zL;(t(W;e|m3#6-XmfVvw1 z7K)OvC?L#`;{Yh|SVL2XRPzEbn?{QOK&DET=#Ej#>+^Xr1I&9)YXwae#Kzx{s8CtY zA>4co%(nOE8i06v9TE=kW9)vIsmg|SjaD!a1(qDV`?~}xQ4I+Cpuak=lie^=m zNVGR$+<^n+<8}Ze;cezV$7=zw9jtRX4Je_YFZc~L+Rbg}C3Od!^IUacN)M$sYJh#I zr4K5g0!J z=LZM8qP~OG1>#r%Tf-*9J1|nI7=r-PlxzQyXYctvCS2HPjXP*90O-BX=`!8aw=HZ9XiNcdpF0WNq*LLzIZt3Ri*oJwjBVFsE?l? zi`pz|Ccjk#dw*WR!nCeWfziNkY17Bb61c{@V3SluLx&N(?(hJD07&C`492>`0R)2I z6DgV`UihqK(GrY}H8*jWkoaz$} zw*}6vPXUR}+@B30w+P;9-Z;j7(YIz7JzkYIKjHJ<$W>*j+HNz}IU)2wYV^oyp`7%S z_tsaS8|z>&dOK!2A2cJ+X>-I?ANas9 z>bypGaRMaNUMCh zofZ!MC8>+9*$Wk@WMF@zd_Iwp+C@)3IaJcK9VM0sJm&z4(`CW|6PfnBrpIr!X+0+} zJ$EEGlu+pqkv%j_;@b3d-SsOlU8Q|+?NBttjd4e_%%O|({f_geMJWe<$?f<>zd?g> zGS5Q{sdi9%VqKM%HDx+?xUO;_&1z&X?>#>!ELk5`euM`Dk>A9n-y5|eF;;W|$nZGe z2oxNLf?);1zcFrwk^=k&+yASP>j^0UIp%L5&VMm>Js|}UAWsC`&*O^G?NCExH#gMQ z4Amn+{1E_W73{di&1*TWO`;yQg5fVLa2`+q5rGHvWal+AxYEG@t7Jn~m2l4Kga;MG zo7xc4$pnV#8?ipQiNg^Lx+By6vFx9#g*2B)ZCAI3)68?yZp8aYUNUUaW^T(IS!e5H zci3h#UuD;weLO{bPNYRQv`+y2?YXr{uA7<5Co zSWK9ITQYD_lMA8buwEd~&J79w#e^2fvWK(+|F&qL#JEelqmci;+59=*a}J|{5(B&f za0Gq>(7>#Jj>s{g!@YmRfD>Y11pjSCJ0S-4IUoaSz`21B%=&xNzbC{12*^MZ*v!A@ zM^A_WQ2u4JIVA?b`IpV+lo;Sgvk_hULOQA05D0=C3dl-mLI#%tzyx{-Xc9QNLPv6- zl6{v162W))N}aA7&cyEDJ%`@Hw13zZ06%|h$~Ao7>`Rjm6Ew$fCZraA@dPpGtkw?+ ziM6@|`rrr7!7W>aFYWQDxc`;4edy#Kvrpi!XaC_2W=pDPvBxa&r`LZ_^rM*`JeV)% z4Y;iJS7uH`tv)k=&@U0Z!ue|fT%XG%of9o*Lkx`BV!&)Lwf+iG>43>ikyZBe0aNe^ z66uYYzK7nSbN2v|^3#5PtIj!Or)($Y;a`=X-q|=EH77!EzXzsY5IslmY+EJ5(Q^CZ zvTjaJmHz5NRR#BAmry3(S%kpKvjg3&@Gk zFW*x}ChlA!nm+?hocxiH$lFO3H3nvTa``l_G^w=(g%i#XSTlFIb~v|NufsGk0VHbS z6MP(!%3Ef$Q?qjmI^FR+`jPXa^ZwR*S^&(Vey<^ex{7Wcw~OPhlkJ}JxE#Zc*rDk~ z|19e+qOM_&BkQ#q04_0{CM$nIBBkss$|u zgZh2p|8T#5bs4g3_a2;9`yruQyjp-iLzigJRjRUcRKe&U4QolW(%p;uzTao z!srP_FsJLCe|blYw5kWmBbEz)SL1(rw-2{mu(a2IrX|iQ&qy%J7lxMmt0foSt#Q&` z&;JU1o5}7+h?c)Pvo>Ypf&td|vzQK?Ku}CW*ZNQW{+s6*fqXFx0k&t?F&7Rxj%yjj6he=qAbs@S8+}Rgac>D za^c>3%XfkjFtfXB8ywqPOvCMx)RjI=(l=wMTw;`75YcyP@Wu{1;8*jF^UKtJOg5LJ zw+QNoWGr`Yh*WMhG0==Zu<9z5gs;eNOCHTFX<`sGjv(S}{RN+DYKWdBY4DW$QVxjp zhFFbD_n~oo6)A84bOb1ts3>QmQkEImd0@};Rqbr=*t!)>3%?2xYc>ODn zL^#Lt*7i)+A8pK<_qQ!h&fBeS*qO|%w)wZ^i&HNyqmV$+U+7&|lL9`9TZ0N}8bo;7YRN+ z`U*%+l-MPRm1qX`mh>tGm2Pded8%i{XDY5aaXL4~Rj185-;d{@S6*C2e>(fYc7Eo7 z?Tcqy^>$8`Ynr0-vQzd0=c@Gw#o7l3mDSeSbMJAfokR@|lMjhYHym}A1yMm*bg>X?;8<4sLt3JJNei;Pu1cnf( z2L7~-;zZ>DAXET+bGn%Y8n=I^a)YzZ<^(oeg^%MLcZT$b3_bBsH@iq5Rc4v+I27!8 z#x`!*)VUJu4o^>LCkVy!#=ec3f4z`uTgNH-0x~cgVHcgXq|~Rf__3`V;;H^3R{7`< z^+3J+D`3$?{uc?~?u=R4+Im*Ip0`~Rx#_FlSX=+(?nN0RYstph$;Di5X7ME^1Ezsf0L(libgc~xlz&QnX1A2* zd$i-rtRMuI%8^-jg`ZG9F~T)g&9CYbg(xv}7(kncq6XL%j$dph;`|a3K@MiPf(h!* z>1HQzTwE=AZbt(40Drz`bvUP8Q3UZis_`9)mu>Vom$L5_T{9cKnlhXj6Ml;b+64e^ z4kPU?&9pT1{)c5@B>tYQdUx>Y55mPr<5S8!m)nGs$(x>i%)=FEHx)AXa*Iy$z;or!tQk>;XJ*chWoq%dEewntt%CX_i@-U+Dl(7VDzX1hnE`rXF*iy|POZ^1YD2-o>5v4t()<2@%4YTgMQg(S98pp@CTq^#Z=UuM$pp5++V!!MqB=6&AIu zPL^CLh!iWmh!$88+#DIGD|2T%0+m$anU3HscZHr$Qa59yI5N$>E!D8$2rRR%fPF#M zx`5v;Lr)+$mNXzDA`H3J+&bZep->@t%8`8}sLK3eY1HPJkrt5tNohcpfp&!Z?|5Uncd!)b zj^lS?+|O(< z8uk6|K23a~k5Vva5N4e%>xnxy8lc?UA;EyWe5O+_vLv@nk&BGuOhxL(MggWFkAVt$U1td!Iw1q0iij7{9%I zlq&1*sz(_5iC8necbT?N-1D;b2cJw5TZIugGWz2P?~!2iLXfse1ny*SrDDT z3%Z^t01hu;;MHm4DSOGBGpPuVGeMfr0fJcJs zL13>Una!FVIq#voW!Yxn;OK0#zLuKF$;u!{BFDh;fLSeTee*4vMMQj@h+G6C4cA&4 zi+U3x+aTqwJ?raX4Bn4a=ofV#kG+mCwPhQIpU;uqWNDIkD~SggeMVey5r00lA-3H@ zGc+1Eb_X9zN7$P{g+hrk9O4^trM-idg`I#j+1!8BpwibJG?guk-tzl>(7Do|HZLz8 zxZb^!2_(WkAqU(2(^G!~UoG(2^6ORWrZ^Af`2bwU?#5PoW&HvD00BGMEvq(>apzd; znV}{I{iXc$*Lm#4``bG1?@N+$AZ%>cHLr}08>V?% zcWS7d`Xa;-tM1j|KJECT2DThT2pnjkY&p!{IVq(X&NUR<0`P{_3~iBBL4spu~2??_8{wzCHK7b^mm#iw5W8v7-Glh<;sMY*&JXdbLtAyYYDL4GlvB-a)>Nh%{0D znB;{1j@EuilgaR?X+ir9hqkIl5r{al`bOLw(leD(st|R8NJD46 zz#xJf1ldGz;q%8h2i+}g4(DtyVRjZcpB?OjC5)xN@P|cDMf=7dN zSwZL3%gWX%u{!c$Vcll15G)BIUHYRK0a$l1?EPWO0Mz>3rD3lq|K!5HW2M8GhST+l zX@|p|)$Z!D@#Libihk3<#oe_ToxM0ho(&>SF1y`ho&(#pjUv;fPs_WDx*nQwx(V0q z;z54q5IkJ!u1-ky17`_KYNiv|B~iP^O?#)T?IR7FBi^)K_JbsgDAW!@dh`SEG&&L2 zd9sNfXCIUpjgOi2wl^_yRDH~g-szfvR#7}XI_-$R*u7R4 z=QruM%-R%_X{cGDL`HOAdpevzyNXR**%((o2&Zlm0jH*I{<>BI52|?DzCyS!XkY3n zv`VbEfVdPDHGFVY^y*c5dnl8gU+kg>Jp9Gs4bCqKfiMEdVLy3Ja47SK+e8oNI#{!8 z^R7^e?l0*z^ze4NersfVWWq%_hHa?x(OT=O<#d=q`K$;@n6Z%NMD z{M@z$I1tZ=q}3UWdSVd26;a+lR4k|CV$;$g*R=o|D~Vb>lt>GFgizKvavhBPr^ z`)j0vTP>y;&2o81iyX5bIML_5a~QCk+Fr3+ozsm-f}D)203&*b z4idsam8_b6hVq(Pwwz3>5Y<@*M4IcA4=4oRS%=UyH@DbG^s;quBCYT`bNSVP93i7{ z5lSBW#aR=$gyns3@e7Nth89S?3+B9V2fVmb9-l_aTHu$zPlWfI0(&c-`8yCM!>O*a zMGu=Wv9&$bDixt&pQTR`P%cuUO;w21e?VQ7?}GT)<&!AGNt}w*tSPKD1()98>`d1|;^Z8b0&mq4Zc#GU@Si)bQsuLmKWE5mQ{)Mcl@ zp846Wg2+(bj)#q0-=KZ@wy|tzb8|bCTV3xDIJrBbJ+#1@pu9>M!~6xa)_D2J1%NZQ z#uu|MS$!HQI<#Aa4tuOwk7rsK^|vhCd~|SRxpZLrB_{LR!1k9tg%i`Qx7k@{%YlF# zY%ChkD)+?$U6A&ZE6xtO5o-gGva7Q;LomxQw%+J z6~F{{bNz&_E*x8NuDzaGVBs13RO{W#c2^?Io*A!$-~Us(856*rX^{X1Wh-iE;?Ipi zL@gaCWk5v4LRG{sC_uR!W-a0C>)Z9-e(Uku5w;isup&^fa$NV5esMm_A4F47*0eB} zvS8i+8WNG+KT6OnoQAs7e@Gq>+K(e#w;;SmZ`ANqjrFtH+OlmU3FjM`OAvy*aW2ue zK2Q-e>tvCf zkT+^q`c*r?PbM`y>+1}8_>0qP{%)`5 zp#JA4y+1#5po5~v#ru9vc?~(^va4(Zr32-!p;64GnaCVwR5M*g;pP-pAI-E!R*#QI zZk`N@psFsh%xMZw79_{sAmub|zbP5C8Ohf5#q*tPw|E?xT(D@>R9+ z4)Gi|2E;Pkfs4;eMXq~$U#6DNq#H_GdP^Mt$?X&nPEeaQW#kt}`_Mt&oVdLoVd^{H zP-H>5dy-h#|G4|%6Al|&d%kdE>!8F~-5|p@dQiD&PTjb;k0@@zsjW{=k2Jb27AksWQInyI=Pp;k(h zs*KJc#Nse*y-2KOKn_)n0Z4Zl8FfAJEB# zZOi2wWP&pX00tvN8xvFG+Nh_#hx{^gTU7kp>(#^+&iV8ApaJq(W}ZBuNKbulJG9ti zGTg7507v|}$FJDNx~Z@YLkOazACB3FR`abO7`3pbjQ`@~sYYGT7I+*OoJjr=t4G(7FEL@8FiJ zgV*+)q0>c(fq&Ei2pRo#|L4PRH#MMy^P2yBN=9)k$xAwQdba9&-*qwx1Hhco7Z8jY zx(rWdVg9V-oHsCAWPP(e<^pG_1E<2M!K1`KQwQ?1g7<`<=WOAxY)H*+askk3x1aYy zLgyhs?)AAKHQi zvE@f3gtjFND&9{5`ybm<;B9MI^urq zo{e7|UxpGU0FLP4e}wq|l`s;Tsb8F91_>iiJWClAA|b;cf9*K_q~X^$&YruE%18z(Bj{kxkX8wX zs7~-z5_Tz0)o;HN6-P-(?B1GT;L~D!vnbp1!1trZznQJ7Y!298L-?>JCl*Pd$%yb zy`VprO{f2XvfPxhpUzxE;{xc^8_e0p zz=%w}s_Pl(<$gQC%}Herf>uVE2p0W89idzV!14Yoa32&H6P!j`Fan^&{ztmNJpo`_ ze_A#8iwHOv;E$njV1nTj0EdVGiwFn)WD1m$(;q{*gpG-HnTbsc2bY}P5=nr9l9`27 zn(E3;yhLi6Jn)xNkij2OfkA-%3XDu&V|zn-sVI`*z~+WPRSdpnul?QETH<%-=}^7y z?b{X)Y%S-(1>g`yhGp!O_mBx!!Fw~Q^tPqj&%bFcyS$a2H)hPfH>}Z+Nn`c)`ny;m z74j>03fIE0qOx>Mspt9I*xr*sqQoUSsCi3sFN^0T6c?+C^c-E z*w;kt##KWrEg`N@XXGe-V`CX;;;%$I8y~N_=0oidpE{Qq!fO7%yIB;|G_P zdGQw*J*)R6%ifw`NK*M)F}f(DUu&$>2uNQKy0jjeBDkFK?wSNoM0_(IpD+G+0SQi{m#tMWd|@ZRFaT-R&77$WYGGEuxOQa4I9tzvy` zPt@zE!I8vE{mw#jo7GXm&WG1`51!nJ!upb&%Q7WDiyw|jk`=L zg=*W(Uu65eWL=^3X<5!(r?2IU6KARYtUrR3FFIe(UVR*Z*x;XGZB-aLAai`{D-eQOC^<`( zE=9NjFWM;rKfJS=p(|y*7W0Mp!qZ?Grq%&-hKq}Y7JZ6h3T6Z43s_%)COazh>5C{P zn(3yOZd841lIcF>!jSIa&DQud2RB6iYs=yXHn>ikN~NyxU00GXc0bgK)z)3WOOWKB zt78apXj;Lh@v$Q0Y^WLiM(gc+^L*g*NTkHtjF0iz9FF`7k1$~ynrV&fkf*k;isw2FjSnh|b^Z%| z9-|PFgsZ4JaIYe`;zO{w5phW`Yfx0EudQ8q86+QtuNvOa{6hG7h?!o6<5%E-vC*qc z2NjQ=GyvCHuhfsN)_WFjPbSI1!wy?aPU>bV$v)kyuKHv!`O|-ES85 zG1kfsO;e8#(N zyIr_vD@aIv=osn5WYV|(FL_KNeTys6()NcAqNfx8`FQ2YyMDN5Z;+7W(f?08P9r9f zyu}r3X?tsG#p+$(?6Zs}BsqWdUpz+a^+!u1CX&3x9&2fKYih*mUE%CAqo$u9TUO#p zr$`1&)9f{3?0t9_;bK_KXXkE<5yyYWM{q~nKkUt%t;T&}*& z^~^@s|5fOL!odMqz7MY1kgy}SW(+BpfD^dPdV7$=;9uRXcTy9id-~Ox7!27G4dzN2OJ)YKA@mx4hIBo`HzPDf8eFS9=bHSyQaa7E#8>;=M~$=`lv5#`4>st6<)ER<|SclP2fP?;a@U8=rYyD zFhAaMyB|z@B&hi;n==}>FbX#(wu^#VWDD*QO~!7UPT0_ND{gj)vBuS8xg_dHCTGIp z>$^LY=;GJjS3Wc-95H$`7{-tTyQ*8JPQk+C<>NCrSti48b$s^7{ zJp#nr|L0XCQp{vg`~|gg zRXzWiOUXz5Mb&j*qV?)$j9i1JT9al+1djhy$s^;y2?&Aw&BkDnV8oY*!6K1k1q7i& zGW<5*iiW*htbQPK*;r0__qp=isJAUfmmkisOBu3(91G4-s!m97lu=#&%ZL;S9SZgp zQh^|L9)bGs*H;E({Jpl5#S!&_4QlDbw8%a`_wJrS)MLAX!87(q=YpwtUAK09+;iL6 zI{i`n{ITd!Sqizv0QA!JSC^VUg$yw3-WcbYm4hI@$+wxk*~?f$afwFM3y+W0%)Y-Yw7AxeDD3bE(wN57l`D(2SN?q>uEqP|bJhgPY zp_hlP1OZ-YIRo6KsxTr4Zq+pyXrk&2sOb_jW!boUjP*OrNqxhI7|>Bn0iQImrfFzJYjT%-F4jL~Yk69>^8+`eqy?>YsRL#U*80 z;8HN@-z)d1XH5GFd{idvg@X^JR_Mq#R%GPpR`A<&NxqN<*&}6?Nh+%FGQX2582=`v z*f;^DEjy{e_-(`*(*j}H%UxEb26Kh@+S-Xp!^t6bA=?kLCNwE!$KIKn)UFgQMgmsg z7PZNh$t7di5!7~}3KsJVieCZ99}{yz{&sQD6H_OHNIOx3b(4 zxk_mkuSR;036(?;4XX{l4{oWNEU(wcZXbq@{K#Ju1{fXtm}k5e4VDTD z-=b=D)Ba{qC0*N*K~&_d^A__KBVmLJgpy?h7L>eAUEi29+R7wcn!=wd`g!Zq7RNzw zvS4!a)t;nwG2WxY(}rEjU+Yt+S=!bbp(yI^S`Zx*?Z3`XyZ^elzzT(2w6d(^6c_d- z>-#k$Fm8~l^5i)xZ@rqQYV`~YpeI%4DRi{dVR%}BS!6Gl{ZpN5yzau(j4 z68krFF{l58b$KRoLw;=nmEgesIE$m`fsDaDg(#kHfaFrD8D-$)-M^^OJOAMjIcJ%R z-+2FnT(Fiyzs4of&M6j$*Hc&CaS$Et`8r`r+JLf_W|Hvv z)t)|&3B{IPELbWz>76Q5N3>R>%gENQ{oG+w-e~0?=y*KlSvwgU8c1bXCtTki`5kq9 z30Dg0KHzTqLml&9ddpEOcY06=xKIpbwIo@jDHcX0i93Zb&>Y%Ra(S&Q2rKwqd}$ZW zde=P;dAi<0{`h?uu_4S zeaOh2)uv?TnXFL>#c{8`i(Wx;%B#$J%7Qv{^k#3|UOredkbgKqxQfCwDi4X4V5`e{ zd~=(3h#5;I50a)r9va7POj$5q-zdYk-`q~8@1swWmc)j*fTK6SPe>ot-_c;+xDYAk zh*nL?%xv`{$}F1CMzdJ80Fw7^o8y3EZL-5ZYb|$oe&W>Q%uD11XvxscyhD|(^L5+HhZ**N5Uo}TVKAk?Z;*%J$%QAQPh7-ghuw26lFXiet_I%<{~k)FcLjof2#-b z-hs;T9>$bRkwwhf+47sX1Z>RM#FYM*NUT$@XT9Mz(Z0zfE2@G&OGkAtuz{Yovk1n6 z`m>HgM30FLWMw)ZsW$Oe%1Jw;R=%vwj!fsxnB$iG0itM~&v>280f@JU-1d$iksc5+!#%xeF!T zE4@JmGnpGLB3>t$*ib?2g2lZIALf-2y?xE#+FtW$DoG*t1}Eo!(z(PEO2;o!x3^0U z?AIroa}_^#e(6*{^|)0d_MaO(S4&(w4l&}Y&A*5ohZ%mk%CF;QLHEs^=oFHu?$L|X zMunM1c5yzceK2!t1XcCbFzQ6%YOo$96;^iOk@t}2P2sT;RL63h)ErrfocWYId$cNC zFBNKj%TdO`F7r;-$QR))J_ZxPF$?k~9|-hks`RyTqHYDQ1u+j7BR{ucMhwLn3cBZK z?TxWX?Lu2D7D8jXQ_EWAAL;54=f#ee`vNWN*Fr3?i&q;M^Cd>O86AqwFu)hoD-OxQ@@d zc1#6y%esYr1w_6A0b$>aJ#@w4&>>@UMd(3`qN>bx8zH8R9!(rZcoIG|S>Xi^b`AR6Y_+8n&WD-xC`|fHcRmBW` z&eJW^kzCrf+rFte7cffh%#k7Kl43!aONcWaneGwaTV_%9^iqA$m#sphYF)KUB^~={ zT1YT3z4J3d-lAWLkvUJjC$1C&7lBpSy?`57lUAsO1(kIjH=>oq_8t<+uB^QpY&IJU zh(j~EZr&UJVf`{$OWs~WrW=)8vcu#uxd_MF1RcM?;HGu%X$ZG%P$SX%451Y5z@YZd zo(s!L@3qfC4_=U&zEPYj?={k|u6}U=Q}r;y%~$!$hy2OqNr=M)$2z&jOSf6gbEFbUZmt=2{f-FW$7bL+!t54T>wYS59N6no4y8AW4) zy|(9@2BAe6N>qleb-7cN%Hcwy}KB=FDO~^A*24^$?+T_dsLQ{;pB=kXfyx)5FBLof zbgp@`H|EXDoeT~RS!z+i#jI&*iY_d(8~4S83rnV6fji8*;sU8#L)Zz$=^Q)Uh<82& zDw@1=YFc%!?F7F+lg;hQ@;J{qNvO1wih8Pb?g zNj~d`DAHR|7bE5pR*vuvITae{jA>(g4T@;hRLhuaGa!QMu8sxM4r!|<8gVcy`>^&d&WAgpn%%#9Gh#Om&ZFp~oi3m%6)sk9@4iW8#FKQ`EPGwXm6FQfp+Ebt~D?;ST?u4 z>SUZnvR);(i66>?@N3UDNX<975llG9a)-7`cC?QJLr*0Mcp zUSnMn(~R6diRtW%4{i03KZP!pFCn7hGdW2at@9at9Fd<{)xtqu;YkVIU@(I^B(Q4} z#~$?B>r7gEk-TYL$r&G8E*vd(p2RzE%SIa?GzVDuAaiLQi=dJX$@I((xh1TfsOSfC zYu`_3vVto3IMj1nZRG7RW@vhA)_X7TZLQoU3P8n%A>%KX96tv$fSA)61e0xx~fql!#7Q zez&YR!PuQLiq!jyG5*7(Tk~v({1q${{5Y_@(+ijf`n}nCNjE_fL8DtTE2=DCV|wkO zY|d@qC~lRzb^=f!ML~zhmd8!DdZh*6JbA4k#J(Mit0p74g2KmFhCp__Dr#X@Z^zrl zxzi*)$Y5D2J#?*^w7A;vQ>wf8k^_U5_0X&%$FFG6^Wsg4{6z0ayTB^a^j^R_VCip+65mRgcrizW#O zLbL-OXhIHWZ_J1Guw67M>W)XB9*`%lGk>AIthHqDv~FACGC{aDzKj7uZFeAkwhxhc z>ShSX=wGcJ_i94&9yPmK6S{|o>_+zp$vGS?+-%$ULx`av9kGoz1nq{*=lOWIC{5X_ z?)C5r8nqvDV51PBt{8c+@F#odIKsY!?{t3QZQ1Gk0?B&U>HNY6bLW%!1yHu9lN8*e z38#}36Jw{76zF@4r;`+CDj_YP=RTKm{gx*FznB>hI=gj-KY!0;^<8i#=m#dde3MiK zbS4NYsY%r@CE(hn5EcLf2OuIKBOxM!f9(OfbP4_q2)IiW%(rDIS+um@VKWI>T0MD{ zkI5=19n}31o}5Zn$6DxVLGASB%|x8Qyqc4BOz=-Z@WXrsisrroJveSF?QWm*8&WUN ztrK-)YF|_%N)WnS&dUk}d-)f1M5|myyXvA*G&X4eD)U--d(1qViqPFrcO_4>mW3>= zvOBVfzP+~kS~NS|j(6H5XRxzUAU6+RI(kuAd!?WeWV~NHKz>=yNs&U>yNhgeIb;{v z_-U?X>`U_^c?Ntcn=g5igK*Y(qxLE~jkV@p6c_0QYkPz71lN?YqV0mS)6_50@2Ghd zz_Le4_DJ@~rKz*3x|Td9N)o%@9r)sXe$Z0Yj#>8G`-!sy8y~);qCI>ePxndzC0#-A z4X*T?Uw?5=q(y=K`SMEe1qu$W^qCJLI6Ch$9 zw~qRT1}&!Iv{N`qX_sm`CvhIZm04P-x&c;)FsmEQ+vtS@7q_`?2pGY4HDuyvWD!58eg}};BN(1}(oMAZj!fC9GNdrs zx}lTuJ?5na-&XYO6zmTvV-7EHGdTI?(EL7pRO0Mti*$Xf=DsPz_>k8t%E;O+djom- zCTa+;uD;Aco=kUc={?s>Cx@#VQ%{14O37a0MYZp*kD7nNDhw&-`C>8*w~Dh)xxV)~ z+0*YT)~s~_aU-iFsoMocrp12>p7wMd3(KlTFj{PXRc-xXg) zpt;>5Je@I6UhozU9lZr6i72dPM4`k>vM5n6&NS#{%x%0xD)Ui$wT_A$gYiLD^VO(t z(jB*9-zbZ*S8E4fs1LF-tVTuHwzrip=#Sg5Y?MXWvv-rf;k41$=C_``ctJ_kFJk*v z+QFw|!%q))D*}RFQQvI*3fz28*v6nlL!?LZ#FR?^OE?L+YV-}J7sUaR*dNmAG89gd zR_jzE9@`w>b4^lN)KIk6g#oik?}gOs|&y4#-_tV#D?5cko&VQ+}AF)bU96+GmB!y7A@ zT>d5nHv|8j=OC`?kbEN0!zf=>u5cxkflT?0rYyJXJ)Z}q`*hq@e8v%j=v~2=Gsyet zLV@>d3iN{*HCb1%G@gkTv7n{SN%WK^WcHJm3W~SCu}}oM<}$L=K^BD27o8G-U{TOy z7$gxvZgQLw7>OQ*PrlL;crCVZEXv@eerU%-O~XMqx1Bf8hQbdRv--(j8WQ(|-9UEg z!4c(0_RG~D8>>ym9E6F$Oz)b04o|5sLMN~MAe#NCv zjm)e`B}Nav(sK9ka)03=_vjA%G?{?|nIewFL`K!1#hw#* zCo7P2124g`KHc9#HHp0_!lvYrFV$p?)NOvdojYc_3?t-RVpv6{6%PfL^+ftv)+?)x zqcS@RqSIf#vi=IBIOE+o5S(|rtCl*IX)d??=8c6~{1*5ZCX^@+0vcHSUq#oi-NNcs zV}Bi8!N=u@RfO6<{CRn!#F!uxQa8p>Z8UuHIbvtL?I5OvzjITO3FP1pgs;&s?18PK$_dsAv@gq<)gok$6mr-B*l8@ zGfuwjb*F>GDsoe5F!jS$C_9QkJE0aINeX0 zH-9FniF2&7!)#WgXYcS0A>!$~CCV4356T(u!=+f@EBW$a6J{Lf9gVnW{RVgO+GK=3Ev(Rzm%%_);K|eQ^v>6>ER3ISS z(x_@fjcXNV6^5-7Bi40Hn}-@cZdfaBs zp8Wc8RfA8#)n4Bn#6!PN>#S^cwpFtyePahCX@|K()!)M1$jXVURit`Mb3@=>+hZ4B zM|@a6f4eCZvz&(=9EwWD>~P~VNj+lTt?2c=_k@+$PuEP1U&C}A_ zT1E6R+>M8w&V92_+3`@r#V=^aSkFLWF)s&Nhlw&iM=h+TzH_$)8zAm3u%|D{x>}|Q z2mXLInGk%8{XQM1ji7Bv85Vk`Up(!wG37{UMrraJDZ^;W3+CcCRsowSKhPV=KR_lB zK&dC@6AM=EvAVPLsVSOWa&DdU`J`2~5olJ`3UO&IB#$LQG?SArxq_IbH#?JYW1e42 zkyO%VDx02s@{4q7!xDb_+RK-rk9^nVpE^p7U`xi~PhN|DY7dSdkZQ5Bjo|E~EwZn! zOhw;(*eQs$8yc7Xc#vdrB>h+&-%htVO+0chrad*G5o1lLzvL4qze+~t#CwFD%^1*et+=A}bE@$R zG3Sfk2{}8n7&ee1EaF(LTN&w#q?0)C3Ttpve%WzHC||BP(|^1lUA*8FZipc2X0;_R z8vI5QGbve(+gX|oJPGHK?r|B1_t6HaSk>!fNOPJo=?6BpYZ)ZfPak^R;~Ir7 zzr#q+*q6P#7-hG7-eZzGJ^h4d*h{p*bwAZ0SF$3eI?-Z*@v!26+oehDM4M9j^$g$L zQk{N8V^sExxdHB`ZNYx+%f1&0O4p)ens8Q$KQi%M#IbCVS!Jz$n$&k;u#^KHm|xLO zo_Rv!mxj%QdnF|NLXuG(Q}^cm;FbyL9f6zm#Gb)%ghOdVM*R04Mif|m1&}X2Y}>kz zeQ)7dEmGf?J6mw>PE}Cyh5gL+W1f4-gB#b^*0TmU^6|vQpMrtTg#pA5@fQY=HmDjg z^VcVc)9bf1i-?{`<@LCRn!d4#N4YLSRMf*pu z`C2(Aa1>LVU=bmz>updZD5zSRa_=><*{{_OGA7OMz?TZvL(DT*5If?DMS3Eq#@SKp zjGYVU;T7oYuF0Ac%N-l7k%|L37-ORFh%pZmI+Wh-NOox03^TMXUc^@#%L_HF){WXA z6uJufz>b(`>}sF!{k&9^g4m)?SU3WMh@gLNw-Xsz~;$ z<@qDw#_Jc=J;hU;huAZsEA9+xJ^ugLd(W__nyy_CNs@C0B{tCH*hI-7sRf|8?TBqLc6P(V>YaQb=P@4S!SoViYzIWyP%IKTGZRkdnW z)vmSfS`}7-0sI7R3zdyXznjHVkg@p1ez!wj8#3pkNNe_|f!slJ4fjgcRbtNsS->SM z-w1A~Q{Q?dxE_?LSZQ^1Zx2W*d1ZxLh0dI?)pZ zY%1dwByr5je{b4&BN>FP`C4`?TpI1Jqq~Ps#m5;2>fZuM+<8X^X}#ZSR%05Q=C+;P z8aOzuz}&LxHNiJRu69-N2?&Glag8HeVf9=S{ z|Cc2@ygic%e#7P?MoxV#2#q)dmue`{+kW_F9NRlQRWz+u&-VOo?;d9_DN_Vh=Gpvb zn0$2%{~FVVmIwcwcl@o%`mLSpjUEu@4xe_PpB{o+42#Y2JL*%rvK5jyG^jJt;Z_kEKxT&n)+0gRCVgd6-FtBVOzZ2O)s-w4?_r=pS!N$m1iY= z_0jBul$Z3x!y&vUq76b$g2#Oi6z(K_`uT27khax%4B|?Bn^&q(C+^aE%Z4omDNUL{ zjkMpm^LKGRUZY?X>&r!*3`(}OXD+Z9wK&4C;vLJvYi%Bk4<>A*Jbs%eGXi=6hP@C{ zoiw?-o$~cjrGEMvu9}SWQYs?YH0Lyf{&+x=vY9JcnAe~V7wzYE{hq>4LU)8X%-}an z4A+zXgV(xY9Lw+vAdJP=%6b(&GUc?z#(p36gPg5=p%mjIrA3y+_K0{^I|@RxSaHRV zQOo1}R4#Bb_)}rF0=jfu_6@(t`EIw2DQN?YpYF&6V=Lk|Xyq1wnSv8KCWla#3@zRR zP{VksScdW4EmxzDZ|6`R`D19}_3+`(lVS~glTS>_J^35qNjfj+7>pon-HvVjbt*BZ zRCP_maX+h5yf1F9S$jEsP7R zpQ5uZxsXPt_;#0=H1!8Ds80JWsGhhs`xyol7=KhL9^a7c z{vvz;<;89jfoT>txwUOI6n)n)ssC9e=@4tQlZ`A)>sh6BF2IcAK)ndp*l#35-eoQ3 zs)}fJ_IkbA@Aft+f=<&Q8yw|DMs^NI!g>;jAkU1(aTA$-CL5ffq zrR4yyiQeQ+u4Q!Z7ItKXR5^KF#vO*YXXFyOlZY99UT|K_b9~kL$%3-}%?$zkcj9yl zWQ73l;4B*^w%Kf_I0bBlVC`JhG+@Y_Xs?R<-H~*%hhkNEoI#a~qaS1%(J z3040Q@z?V|KL4x7zp4LQiT=NcYq=O9kFTn2S^S@Vm@%_k*yD~N{C6LXRbrsDi2f-Y z6C90x_ol14HBy*79&PXSKN!V`qbhbaharW@a8#y^RYJH7b*5^|7tQ`}MltK#S4|up zO#2*dd?B!RUTSZbS-xy(e>-o1JvthbQ#lg5irG75S7@yWqKp+7c;K+~b?A8Ey}?(5 zv*>@4pt7(xY63Nw<~&2c@GX0Sy9VaD=rBo1J_@dXZYCV%54o@vdB<-N_9z|1E4 zCAg=meu@`Zt{CP7b`3FYDrtpY6uJ|%jEFhhzWe1i>J2FVI_5z#Rmauzg_x+$TjF=0 z=sk$g2+V{>^N{>d+4fEml~KcEVd18(fnOSVI!*lxBV$ZS)-F;fIyzdmHzk(XVO8kr zy!3P4NkxxSQ<5kvhf4UNebAyWK4x73WFn?#FzUs_49<|V{*S*Dhenpp3sKd5aL-l=b1&*ogkmnUd#hy=NBa8l#t^M+YUYkXSej2{p6+n#2pE z-1i$>fJ(X@(49c~DEzclQol%R^vh=Ba>-2%kDe;?Sk7^DD|DKqcXfF~FURaUoD+NR zXIAOF-c*iLnRhzSelXYlk4mo+caJqc@pEnc;q@f6wgI`alIL~EZlV8|5`T~SH}8k$|1kV-1cNrzA2JKpyAN7Wq#M69m8j3+c1_e|=b5h$ViiHH z;720zNh^Tm#S9N`W8{erUyW;RSf47R5yp5Zh7BW_=+M{US40qw+|PuQwS&JNRtA6Z zfkL71)Jvy-ReSDM-}2H0clqB`c7L$smVm zsEN5SRzX^4ksCw|xwppr;JRZC+rRPZ{WFpyzYGVur-Ej~Nrz$d=La`q zwSMD0$&Il%H1#|j|ho3cAB2}QPMUY0oC*p$a`AB3Pz39$x;Amd#lI$l*SW34KCEb_^ zsZ3JhEXj*cBd3*CBi=F^p!4>Vz$?>w{jDh2Cp~Cg9m34u7gX0(T_jmqM z>wo>2FETLR4mU%okR16#xRKYv0BsdrZU=gZ$;DB`cjQI3tbl; zs4U+%{>VvD^n6Ym7__DEM+SAN>A$8&=MR%l@6z$rV0%Av)y8h`SLDx}myz~*O|WIX zvWk@e_Jznpzyo5}7Q>qb=LxFu-=G)M^ zhn2#;4auQtn{}U-l6JgbKgvpg*9_X7{l?SlA87uWs}sy|H;hYD(O+h^Vt> z%G3Mx)W5ohw4|9!!-I4J4jmKKbT6fxV$&bqL$Y}GF>~F;)n-}ERpskw=h;25J zhCMe{C&HHr$sRo{I^+4Qw26+dRs=?PZgF4b|0;BM!)0cnrCuN8`hoJr1i$m*QY`wU zzE@GlwF`&6QS~5opD#HbDe;gKU-pAcAuUI#U^LaBs#K!qG=Ju=?{EX`8? z^yI`w%(PYH2edH~#mX+n9Sf-$&%ZPyR@l@#8O+JJCcu@7-3mRhpfc~J6Dmu$Ui;LK z;FzKpp?F=mR^vi~;n9>qL^;;DJSUzPP5z)xj?D^ok`tCL z`Ebk-(XP)Grjrob?*H95MNiF0Q=b_5+P71e9PyO+t>;G|yY@Qh!-zdtn$ow=6<3s` z;uUhY;q&ugw34uk7F-IqD&J{azU>zhr8}fzJX__TsqW9v)vnDW?;m5R58 zlXzMiea-3}nAu6_TRU0H4jomkgh}1(J61bi;ELll^aERs$lrK;o9B~MJ^S?11qUk8 zpbi%B{2l0u#kkKyp|`t~FIIyp(!G7I?Y6qmG{`ek(FK<_%LQ8-YfFRFQHGQ-BkJ)9V?ZVo>$gYi1}Qz zc3$0DT|?f#bafjJBbpIAepRso>q9@iuSIi@-oHQU5$j#fJ@^|n^8Ox^P(o?)2v*32 z-Y=(YI{5L)sj91l>YKWGsQOw~@oOntVn$NgZi(|rN#rc;yj08CDSB*o_3o~$?G}+` zQ)loU(yeIO*Ud9Uc+ppQ3BFVl3)@}SNdh-t2gxNr&!GtqqUWJU^h@EHiMA)eMgq92 z#U*lsMYn9kRlnsDILxg5Fp_#f`626R+5C@qtN;Q$M3J+tnthA*j^npFtxwMfFeNyb z#mxl^%97GDa`~_&cbvX-mUNy=`KB``pOZUtDrR+gl}Infrm~lQqG@Ss51PQ?ME=4} z__ocjz*);Wc8WEJYC&c6Deo9OWuMEbU&$CZsjcRCCtKyj5G#V^bh>56As>0pBh)&U zS5O_8{KK$+>#Q+#SD!t<_)wOHIEQ)9-uHW;hO}&cV?t3Co}~6cekR=QO_khb>0{wr zeB!g7TEx;SK@rk2DnV#+J#fDdC=8k>=oysII320fNE)yhl9T!5g5lYXp-Xn}KmR1M zHU$kDGTO3|cfOr#0;6N6AYty$oD zXnQQ&qP|dj+UI@#pwW#t7_wMRWkF9ujyQ#2^}*h$q|vPvl+=KC%MCn z)a$*Ub$Uv0i&}}5AK5_)kG~kn#LNGLV)oRdMa;2m*f5q1ljBDlLrs8bH^S4 z9h%xyPNDrijaNH4j-Nev_cH~^7(J3n=TE8L(CH~5ws6+Nect`tg&rT7tCHOPeiw2! z%GD907j9D0%=)_Y61xZz^Wk>Ai^`oyQ41UC?{wh0CX;%HjsHZ4%0V%Y4B1YJZLZwP zZ$<1D{5@Pb!i{>4jz=!ZrA{aQ9zy*sF!@!|!6hH|h@6IBS3YIhI`ZkVzu)lcA0f$k zxUZC=if&!oDhxL8>1>d?EAt!g$nA-xQf}4*z=^5I3+CXT;XY$4*Ft+gsV(t@^(w>vFAVk4I}MuJr1ks?}YtB_Ep{(tM6KkQ6l`e zAg-)G>T0U1Z?65H z{>iQM{JGQ{i~s;fvI%_GMwK~O}(~} z!lA5qy!#O;BnL+blY9Kk{H;Hk;3(>M$F zFSYtt0p)Nu@L#_XSHS;8!9gpybr1**&ie@A4MGYsQhY)}qQ6|b;Czx0($aC$OKO-B zG4M#qsM~ub7uQeH@Jif&^f)xE@Ew=5nhC_)C#lY1oe!Gwl~L327$B=v&51MX!Ccyx$3Db7Ztt5sQ zROhmv+L9mv?h46CkoyYtA+S=LNfcsKs4swf%3koL;IM`HZrY#xxgHx2zoD~|2BB6$|Ty);;DeQ?@Qi2i}nbM2mRt( zDlZ3LTze->C$&S`?|$M(67(B<=@LgfoUe@vb-oKZzhYg5q~ILDsJt3TxKO*g$!3mW zN=~7cs6KTEeybFF`x`GkB){lnd-f3?x4$ceN^W5W{1fs<$MXF^W(H}+klm5(J%~j^ zmQl&`pwvsd@36a)1A8MMlp>6t2gN1-9A;2m`?3eYndKkuy6?#;N4^KoEH+UAs1JVy z@^3GwTgA$Bv)RAdbS2@u>o~yk8}H`@3_1R`puGG-T56%bI@OFJf(*zX9?06-N5Q1& zdiLNv5a`@R0KXbP`&KD<=;qOQ8mE$OgGXH29Q1?pa{Gb=iC<~aNM-I|sz}=VSvgoA z313EANFMY|RrMyny56(wRO8FEjy$TZK+b~9(Ih*F)q^=OOT0%y6g{MQP)dO`i$f6N!Gu7$RrlZUou_{xQ zLkItS-rWHik1?H8?BGjLlOI*$<@*}&K~5MVS7Cfx)j)9DuRUx4_^TfR|E8S3r_ce= zh_v?y<>vz3<$yXRuT%~2%>pN)Aadd&6N26+@3fNrmhxkzR6BxE&v6@DhjmD=Izqgn z%!d1uDJcj&URc?4?#P98dCE(JJ8vnx&?Neh%`9<&DbDobbNki=yIwUgiJ>;g>?f8E zq#$&Qe=yDTO~-!EyaM&$m2P)+0Y;wi!-Y^xtKg-hWe)F)BPD zi=6fBEAiYrLQ9mQf~7*$J_NU=z)jS9rZiSwmCkshRZI$TPN@%(=GdLOJ(a&W@vEBJ zjfdH&9Whm94{)ROYUSXfmFJxDu!EhwM3->0kdsW&kpl;_`R>@h|n9oNhROsKV>(3Cpzk8RhVGe_gzu&~(3&DV-RXyW%2BB1cyZ#=57R z)hD!)7ctk*DF6z?Q#Zd*2*hKvJL{Ds}6=@kwQ!bN+ z##R{JTV?-}E7L7^B*>@LInWgG&A2W9jK}9RVS~XaZ28_PrCd?u-IM2JmUT*|u2-SA zSzk|`_pY_h-=+=zji(>_OC!HjNZ8^mc##3kR-TfKQ!8W3Z$ zKd+0aW%<(S^?m9MAoy1gR5&1Po=}8arv#eK`pC5@q4wf#=GDVQRKm=?(~pK5(|UfC z>Wcask=rJ2>BOH;Sqzdt-XzeIy+%Vh;}|>kS4=letH7hQI$zZkM~$w7Qw;~jX}_ax zo~a6Eld+=|r6w2gex&dHvFOHw{Hy+h@p_P5h+)2w@CejJAZ(UL& zLSl0-MFgTX(*4vKO)GF47Bk;KMei8#T&>+;w{u7`6y(67j3vTwO}L>KS~q~H}cQR z%E-1KN-LA%AWYFGsX*2K>M^9NGc4+MC(lA?Y$=YR zl!|HMJoZJ*MiZ#O=W|5o#TT!DQT9;l_DoUU^A|F`7c9R1<@l0kEK6cWr4IKg-*Y96 z5+b7ON{*~_3W*_}?G`!}X3ta`nbCgQ6lnALH2j;7f$LKIrLKk~kT1J8H6yt`)+)lJ;`FwEg=qbOsDxf38Q9!R02l>MNRN z{fDMWIF507!L@mE4&*nyZD51MAKV|mlNqBED+_u}*XeK5WftEZ5N=?!%SutyIvw@c z(CFAn3iWHar<2_kRSK9$jX_(?_~!CDaX9o9^D(NwsRAFqNEJ2Jg-fd~N>iloy<-9% zY@^)#n~=ja@~ym1x1gvu@gs=k!T#Iy(uSR%3O$Nd#hFX6ed$*D9J|(Xq6jiq_y>8` zLhKI9$ktc=utS-MmUOz*iu!qtMB4bCOR77uu4Kirzt zk3){;-}0zZ-cB0^=%Ibg*gfszI*kd-#in&zMbRZwp}?@7F+_ItTN@1ugH$P+5#kCD z&Rk@USZ|JdjWD~9z<`x7wF1H$1#z{WMP)GMKwMMWkG=gFg`J;|)YxNag%Q9!-}kbb z&z!A98p$=f56ibv5l*yswXqa*+=e4{N#tBrX*TB6NWQ2@S@I(HF;YFFgFET%=^S2C z9|4nhP2g7T1=!JYw=zcHJx&7@xn(+i_GS(aLGPooQkhe?AGL%Cy7qC_hu4%^|E>Mn)kH|8%UL`aA|7f63BXeM+zVYw7p!WhA4*cuMQ8$&_z3 zEOyaLtn8R;#^2MoS0>M0CN|5Ls?3tnu7qhZY{Cb~Uwj0_jr{Fg&KrPV{1TR}R8EDO zW~woq_fgKwGB$?8%mqZ@RN`OgEP%z&dneW30A>2%8)rTB(K%4P3=L1e-Zas>>vZ++ z-p+KdSqb|KeDw-tm)f!Xkz-$J)99{jQS3OusI%O8Z1~MkQZXyla=ju0BFD{f{+XTU zXdW8nY0<6`%rYQjlux6efSPs$v>6 z*%;+6W0Ysgpl=6uZ#bX4_G4zW;v;8U#^%&Ze^)pK~~s&C9X-bamHerKOJ z?aov}pP(%Bxlzo4l;g3?3B5QdHwJ!*2MiOS0|I5dZCkcr}MZF|1{CI!|9L7HaNTDdBo_74$`Ihk~K*wCaDTRWJR zC^gljQ@50q(D_%y8E=z7&ZaPTZ@a)Y0H(?j1w2y)3^8t1U5dRUU$CT69LNBH8WQKx@~nRRPwe&cHDHQ-*10Ka9{AUdsD z(Cw{yvo$Dkb@8AEF762-C46OWX1=`X39QFJ8dWr%I0Cu*q##T7=8Hh{Om7=u1uBqV2DQJ>KX^-p)7(!!EW%a%xUh&WlPONN1Xs-aZ< zNB`0$({WRJ^m+1rX%2}g2^xq2*k$HWr3>LhRtjdI*4!oUtMm$=5Qn)`KW>MCWw9>P zN82Go8!0BfCtA3FaMs2zX=(7pvC0kggdI*Z!b%h49p_HZe|hpg!^e5+glcT9%Y$dw z4HdYOB>*{co69u?g`6bYc^TQ}lDSiKNlS5x%)L!N7=O(&$Xs83)2kItD1Xqn=cEvm zxFOECHA_wwsGnsOdhkYC(7F2-y^oT;7|#e@EWOds2SCL#iwFK8Iqv5P90oGZo?7h- zTAuQCJ*px~VyJqQ9D|uZdiZxSTMcI8;}z@gd@UAU&1XN6^` zUwIz<`x0?$a|;9j>wOR2u^dce+Gl#@*7LT_R!rVnh$n0P;RraLtbdPOd+&M@r{IiK z&Ivn+fZ#(ydTH4VFm^uG{7&sK#r~|w&@zZ#bC7g1yx3#5#1I)?CJ^15ZPrmI5$Sv) z^(7fyG@R=*ajX_VRzz?kF~&_|<6-9yh8?#DDw-Z6hO7^wo1Wz)cX|=+m5okgnfiBT zLVVUKWdvT%d3=nOgU!I{#iB6N{Reri3Ce);fHZ?PqSB(Rq%rCm=lh+f)l8nGjR55^ zKzi1@411#XSaXKcd&!(ei$Vr9+|%BYEzmZ=PR=v_(sz19vMnrw4T_d&ZJ+VwG!unx z2cW7#g0i$0o;12eqF)bNp!Ea$R4+asa)J|r2cm8?%x{yY`kD4@q3igT^vRQ zV*`l~qN)@YRd676)$mEq>5l#TNgPV89prj1j4=<* z8AD10MFk}Fs!aDHvlMg9X?=_UGoRI~L`9XO7~&XcFiYd4Bg&CAZ*4JVG>a=59Jb$u z;AE}EJkAzWJN3tQi#Gyy7GD1ig(j9%2)-GA~ zTk{dKS*0E6Z7u$FTl+cF9jOuhnWhkXU-Ka#Kjvl(P+Tel0MQexczgE?sjm+upy{ER znV`d2u0i=PU0E8bFW5031Op*p)=(yWHVhXP^u1qV`LtiDCYVZ?w%_roV*q;(`!ws` zK^%j!Qi_Lz@Gvh$(AXb8KgDj>Q2LzhTvOag7Hj8=mnO2)gU1u>$ZjfP_4LNZ*cv@> zAp~^(XlB$ozMbo;3Mc~=lmpn#FLceFWB62ULEMzD`J3qQqnLO&y-GcN3mPn|F`a4oh zu;parR(GA~Z#*))pARBxxbTU*KCpu?FlH9a7S^~GmfCN<#SS*Tl(Si>c{+UO)2H!K z4Ma20S79Q)xy2avGL#&B4aifw&!#E4AV1-;Tw;w+U{~a(IkJ{@m|=qhR8uFLk_nx; zsEjT_o8HUZrUe` zM#RVYopBhy^bq>U>&y~hkFFjr-PGTBwgHYb$BZyDrI>wnq9qH0_9d-Sc*3sE_JfLF+e z_(z@oNF(MK@=_rac*q*nK-;E5{7>?PVYGq53@JF+ zh2PRfGzFb|{gqy7*oHvXCz?uHD7DJj6ac$g2P=ncy1h?R^R3W|B6iS|xmtHkf5^{N znTEn;QJDhX-k#l*lJfPnWwYicGg8v-ea%nG#&GQX zXljhQ*N|3P?lxc9&lh4#ddOs;+oK3Q?rZ~LMKOs;3vfIyp0K%eVb?LA&canJPa_GWS0i(q+9{2Bb`A;~1V9}ARz_q((n<1RPlZk)7QbH5^od`8NSubu$nzRG`VBt@8%^NBQ@d?4=&C34>k^a!KiJdioh7U znY|{WuDy!-1JvY!eFGnxl)f~=bmWEKxt?*>di(=_J6FZ3VJ`yD3UvIhYa~Ao$e&#P zS%^30+cAB{i{0TwBrOkU?L`0VBkdw53N#p!b?IC3>rmDGyJT6o?Ev!DA1;!*ce-X? zvdUhUJR0iy?idOFjaR`T=6El=2Q6ZIwACH|?sI&uY{(<=C%lvpT?w8^2 zEZV+~|B1wlcj@C!&kngg) zDcn*Is|~wnWGM}aCaT3If6pex%5DmGf**YTi18U{*~sHLZ)j~V7ndiQ@%+*!B0M?yUUfZC5#yBS)TRYgQQ&#{X z*^&R(O;p8$de06(>ghunV2(NJ=Au2y7Y;B!41;}A_#7!&4^4PfnRlGlYcj!4e_bE2#-%n^++8l zvX8}68lGwlS<Em@Xu;F&FCca0G)DI?D*_1$7CHs zsyuZ#nUvbPjHu0AYk5qym*3S)p+AAOkNQw+YbeQbOn!#y<|{r<*GRxDEKLA}57Psy%VK*(QfR+ynZS=44ghpx~&QFXkT1NNQLU$&}bmpWV{iQT4Xdj;D;^ zfmE6)9UbZ8cK$N!H$=XS1cbpZ3n()=x^-+ijWoB`vDQm9C-3q{@`Y&i+}^^hbY{lz z(ts%8RDolko@rKMzjv0u@%n1+qrr&*wIxP}Z#kfX9=x{>we@b#&vUqM-X5^M0C`|8 zXoi(di!k=-6vdG0j_xn6RCd8CH19O<_4i?F<8dCR2cT5t+&rcvjhx7RfZ1|8olCFS zz;Jz0c17Hs^V#2c2k|Me_kbM8!t2>scT;xaqDK^+?sPuY22S1yMJeP@YpUq`fv53l zmX^BakH|yj5)FAQ?;}_YJ55D%`|d$NDr$;$$(1E&gPKn+m%IqH1qLutN(Q0&ni9_) zJ~Cyl*ppH24W*~caex83E9vEX(x|dsecokLNb$pps#{va7*cE>h8rI?u9_Rz*V$}q z>(SQAe_)OC?H^lt`q~N{GF7g}E9>aaYKG4Cv(WayZm*l~%9ErEs_9vJ!ijyhKfh*C z?(!-)(V!Mj{lmH#Did4TR+_e?J*4S~g$b_#waW8d!&{bQa29ltMnI%Jm8b`-wUe3c zwxxFJ@>FW1g{UX%MVnw)zNfzdHwKipjaRYe9?qNu=Y3jIUXtJvX_6jdU@*)@fUddq zSitYo4d>Q95=6=3A`u<0;}SA^7`ri3=jZm~G|FNyEK1U*x4d%E9zhAK1|>H!X1n#X zK`domW*IHxJLY>voqjh_xW7BS6Td=u zwUeoNm6q2ElBL33wrX6wcifmffp5${*a(w7@_3Yu!6P%kK4TJ&M#;3{uh|pHQOxg# z#YJu%+g2&m^(>HOYLEnIOjW*=$ZdGS@C8PycYBf~V=!dezl3k%#W-2UkUv^z+cREo zcbvr6rPY;)r|qS`L3~r2&RHd&Kqkk8wTJ`UiTgXe#$iG3Ef96N(1hil{-vqa?# zdfK3W=DJe0q`x#}iCA?%R1TUKv}fYVp4xa`Cy_Kn%F*TZQj=r;9Q+4DF5L^|^s0Qt zI7Tq^hdI18DVps2Aw6~~{cXQgEAxrEnW*2DMYW*UH8&U#wZjm;+>!jGPNZ~d>s=-z zl9EFA19h9pCj&7+)2#f=JA0&(*mjnB8Ue#4g%r7XV^lo5Z||f~M90oCerZyYmAHXC z^r_}s@^HYAlkz;YLjN{|sB*=TzS7sIno>D^@BZ>!R?}`28}y-pBDtjs*<1{{jj7fU8tA@G|@ac)tzBRQcSB87e7G5oLQ zDGJM+nUT9Z*^3JIRmQxX62-P8F6zb8=WSkA@tLZ!7%0eD34;$S9Eo1)-bDq9R0qg( zmK>2@+iy9&@)Egnj|M}cGe{7-OqUig0GC;Q2k`P1#(IdUdSwm6;m*HFEvI4i*b)3_ zQN*gIwF6lPv41GlJyQM%R5~ZAu6P`Eg6n`wq`u$^UZ4DX9H6PpARD8Y<}|Q)$T8w; z-?`Lb5lXhS#fqrR!WY>20k2PSy>V+fU_h?AQOHotUeA}C$|*f8Z^{rDUnz~nYms%q zq`bbvoiW8>YrYtnoVTFtz@LYVk~(;p{m3DEM}T8_!VYT0k7^f)m=u)|gE*5xLZmmT zg!xV~k!Cgaz-8)OR;|X*FUj?QEO`Fw21Ck-sY;4Lqs>l+Vb-Sz7iMvu>?OK6z`)rc zpmxz`ibDgj_KZ*29?7+Ee9c`j;yDKFMc_HPeD0^)*GQ(O>mxyBWWj5=Wr-6>XGv}K z*2U1~{A5pV?oy3Ju2k~B6bqYKx9qV6?kqlDTpBUjwk&$ktI{}v`2b6e5y(&m&4FhS z5ZKh5oG?d{pg2S-fzT5|`AD9{YdQQK0-Y+qU4$y!4V(73Bh^>}w4k9Z*x8KC(zSUn zn@$*GZw`sEF0xzvNh#=CT`8UMkWtp9T6VVtbg5HrUXE%S;a*R{X!V7Sbgl6@K}M#< z35lwtl3I7;3cpBKh zTTda7^PePR!Mo3?w?5)qcQeTX@rm%Tki8TCve6NL;>iPs>>Fa~WXW;MPTrs6;{%2s z3|qQ-$R{oU_*?fdAYGhGkO!>)4`!d_1ZJGl5O;M#OwH*{Q zs4|{g`hILAXyPb(BR)e%?@9GQ4AfI-R@citBcQi)#4ml)l1BQLiIAwmU5OuY9*a^2 zZw9Od!7Y^_m-+2N!ujdUX*?I8xxIl~;6mxL#%ky1M`oZh$upfHEaH_#puTStp{Fiz zQ`xl6)4VD(5&f;ZiB{H)Q`7wwpnK{GqU{0aB8RPxi_~W>?uW}&120>P%$(5Q>r*Sp z7keX0JNzB#jUmT&ZooFWb^D`O7D!QMx%wZ3;<6yXc;kMM!Z%qJY+?~p^A~=! zYWQzF3AVx4K&&vLWm@>g2$iwhQlLcjqzKi*;$!%wS+h-_rK4`HySpKNMQI-RyA2d} z{LZ^4Wf8k(DD3Bw=!-P89C>XUiOIk-mEpzBdO%L5?^WO68U<<_K@&GgZ7|x8t-;iX zq#0IjboKg{OQtMBhhGk%RQg@wDyJFcgpEy+>7=^_sA-4fRlO4QT@d4D#DUqY|ER+} zJSU8F%_f^4b|PT5R0tqTh5U>VM8>1)ZTfRGZt)4OAbc|y2!$+m>)$h5L3LY%iskt9 zWF>khe6i*H2qArAwnvem>4)+g%YwvX6UMZ* znkTW#ykiQSCe7OQ&9YbjfO&+_LLyu})1>!X5#W{AfQ_#pP#fY_oO`UHk(GGm_buLBx78C3%rmd*O>o9dYHQP+3BYYXq$8%z)`{;SvfPa4Nn+dwH}* zxFfyQt;RL0jSGh6R+DOX^K4%a<iXI0a1w^X`1oN^NpkaCn~P0$-ETb7#n;IE z%C>Q4{Vz3R?EGkMbs?xB*D|Ed2V^-Co3BiHr|552O(VZNI zPQz?hJ7Y{Q)SJmd$n<|GM|K&AWUOU)FX68jMf5qJ6g%1vZ$9#(d`%SGscYcE zRLBz&__lNcrf!+hhVzYT`c>daPT}L*os(yO*rHb{0#ChDtDE{?>HNsk6dd!3DF{h@ zKT>fQkDy{;u;PZRu+cf!23NHkiCS-kPKdV7!y>aLLM{hbu^P|Y#ozv3Q3j08TB&!xg9tX&fp;A4#8oGqWLx;sk$ zsIL(up_*i{!YoAgrLHuxW6x&R5QETDXB_jDzI1e=Sst>-nnZ9B;=4gd*qLQEe~_XH zs}n(+q@^@)Y?6FV ztrt&J=1I?x9}+?l<8&{nm26k_47G(&D+%%5nUa)0-jBr370V&sgPm*oRF9Sb+&}K? z>S;*%YfDs>8druVDcZ(kA?}f%FZ+jQgH77x zB9U(;>)y+s#z}0-DM?J<%V~YoP17KOsy4y`&5M#56tp}>2N7gYs8BPNn^wK|7cjcV zJ=7b0gQH-I@Mr<^;>>B7sKm}w5;R;&zP3*O$yApK15!jTzZdz6(s7G? zpOIWav_qt6$X~JAafL9OM=T-7oc+*9^Z_z;6u3*}!ii%5&)zq2G2MNR(SHq{|>%#-Q8gMdG^s zoY3GPHboANAo4yV*MOJrZpNqh8V5(F%2E=>&uuhT>9?o*ewQ!VW?3u&aP7n8TQ{9{ zpt7E`0qP{RCZV{?Hk$2*ix5qMr4u4NS;daY*`^Oo)@|tNeRA9)B3j-3_+vG?+n$6us8ZTr!241m-^!X!UkC~%Wl#f zK)UhQL5=vX^eH(G@j@S2Y9Wi$Do=Y3q$QiIGV~?&@ncf8{Wl#}pJwTd?AdhqML$F^ zN-(5ZHi+NHPWkRu8S#pHw3C5p=p-@r$&;3B!pAk(m3_6HNHbKg5#Ja#q@Bpsy4O8E z8M0>e!h>NVwA?Y9&BX|L9|C4`7hFFxS*Jr#g}1eKgr%EyvTPa&{-2AdD~7QGirx0| zXh@YEQxkNhh)~=hdtfr}18_FEM`RL>m-Dh=V0(a{b~I?y#oLTd;rV|OLtEG8dN&V- za)!CBOp&_(vgE}!A$+Ozxz&h<4!4R&#Ot^){8bwOZw^$~T_EIf=NU;6L%Y_OsnTwQ ze5+i?T~-N%h`n{*jLgZ%6NE4n!+8qfvb~xkR$2F6!9T;X35&OejOM3XC$O)}KoT1S zW&9PU!uk#h_LPdB0`wSK_~$9*6if6X){^yIs=lKai@Zd^P7B$6u0t~~^zXYQc8Lko>K6fALn=fzx&+# zJXhAU-FvTD-+5>DXU&@R&bwwL>dn*yH51#Lw4aVYG_ntqh2CdmJdnPxVv|$t-!s%P zI@udjYdM>&W%;o7Y$^wM&Qp7kB5ccU5h@3 zVicnbydGBf5t2GmCJRbnjVz`Z`f@OOOUThEqKFyQE{oDwRjaZ~H%xUWX^x^PyxeN( zm7+B;W%#829)_Y&P?W3q`LQT1JV*4W-wRU1yfo=Q3%cOdH`lV33bXiUo7W;N14Iw8gj@;@%vv?{dhbViF zM-%q*x*bUgWl9F2M3V6L7rMvnPwHi>*` zHhnRp*GBv zPQ6SkUb(e9WoYWylY{+OEv!!L4R3D%K@l{$6}&9iQ)yE|hEMK%~rxQc=&7lTig(gt@Hv@zJqGXa>UDt!%?4hB-x7w>^4&SZCc` z*+!wvsZ8pp#9_Q1n}=;4Si956s9>3Ejv$DLL8)!V=f6~#BA^+K{jhdmZx~&mej!_` zh{s-*i6*)ht;A_kO6oC|W>+58cHWZzP>q!(#smF(WQ5#7V{w0)6sXYNFQf0jry2*0 zXv?cfS|lr^NoLHgiGaeSo%Xt+D4#APbQvQY$dX@2k_C;P;sLI%`s z}R1wrdP zwZ0N`)!R%ni_I$`feEHO7wT$_N8SVpW)*BRWi$}!r$%5}bf?lptt^}(3il6nR$OBt z7$D~#?}d}4DOlHRkz$u~Y5DK;!sut%NpmV9!rUq|566=VI8&O{nu$1UxS!%j!g73m$8RWf?^=ggbbPvLwyt!AZy+_UF@dE<_Nfzt0Z^B1Tp_{?TQfWY=4>RbMK`?%m|$7ZvT z;uI!X8C8z>EC3+evQksd5LFw>qCLVafV+qv|kw6Y)l9v=?Q3j%f~=)UY~h4!TN zYE;Ffm5+lhiax_NZV)c2A3HJkmHs?HbC2snN8mD;jcZ6t6wGhiPFyrdA`(w1#>ib& zb3giL{Sba_>?XJJX~hHGi}-LU>$< zxp9{@ipRU0hTXW};B9Db90EeZL|C&io+6i=QUu&(Ux70Ozut%_fie?U;$A(BR2_$$ z9O~@X(7c{g^_oP9;q2@?x1ATXV;W-kYDVZ6<4i#KW+>f>wHiniq({qpe&%H12ym92 z5pvta+m@w3FhUiuG@FO=ePNVat&3==O!&(2bno*%hemLGcILwxto@7+4aK}Q3l95Q z9oKe?%EvyO2~%moz3YdwKiWQRd5JJ7E=7_{DTjjAcynev-d2%chE=+hqKVom$O6%F zt*ut#ZJ>6HgjnCBxArnJTC3ugLR61pUaHOCwo9}^$)-JZ98Hj#K2Bm#m(dudAZ(uU zqKx?8*J^HVles?C19USHTh#Xe}@L!Z<(on&SLaaLbEn+&#A>kH5&avOjAc+v59> zp!xCxyDcpX42##TwH;r*D8oQLoKA-iM}a?_OQqbg#u}w&33S<^O#;&kZ4Dt3RCl6;)$${#S@h<;7n?H6MR4 zcmSA;;jgF~&cDiiC3Gk4hd7-7lt-Fm@JWc-Q>p)d`+s>2$O1vXe*{(-WHg}GGmvxd{ED(^)s{FJbzib z=O4?;^8u5S9@<2*cvi>d0?&b2q?w9#gsv-g5t0sh-rF;HBkBr{PT#sc-EgtPHC+hN zimms)?X}NrH@1<|lIyyAu?9c+p5B?QZe(qIcJZ>~%kY3NR`WHgy#y4g#r!>C0Rz?H z89ZGIog!{U_*Ac^40X11UFdm|1l7Jqg{5~gsNPF^_i6F8+)BGJecDE_c{94)^4jS;66f{l;lA{~oVleA*E3RDafC$~VwP<=Hu=9oeviasHaikm_jxlKkqYAvZ}Z z4pld#b4Pn^Q*WZ|5Y@d`E!*jP9qxK3vB{2^sa=OzNj8odn?y3lic8_!={N(rCd21B zxBFlY8r%eO(C|uh;0%@b2k6!q({-l>vGY=;-;kHTKPS%v#o!6%MQT2~1jEzfvr^5I!eqB0*YNGUWxH4QLZ2HC zolm};Jls5QQRIiuYJ78;S6oo-=mEr(S--!PXqWP;%{|mgo0{7fSa^81UYXNB{k~fX z#4L}@qT+`RU=k*s64Z8)0*kJZ^D(fg!U$~F7wcI~o(D|9A9SgTw#r(8M-U$X4`4+J z>Q>)*ka25Pw88<|oBK{if3$2g${X9$>LDc3>{n-8u$ZLb)2*voR<%f@M1uw4W(AAA z@5jha-xfg4c*sKyG_^P+HK?T@l%?TZkX0hT-1c~J*j7{vj?wSP5)O3=lJVkvqVH_I zpa*_;OG`G;10xpWTMU)f-uTL@Ixd;@uj z->2y8jRVV+JAD2c*31)2y{@D zIEon5w@PDL{ets%o!^EH-bYq^H6I>mbBnmN>FsBJ{~$f0SUR!yFnN-jAH={-a9{G) zd1r9;>mMt@BoD0%r^4ZIj)dR~p=J`BJ-~n}L3GLTJhlrg_n#_){t}eWf!sqFxVY!^ z6};1Gy;#-%S$h|LZ8KpITk9oiQ%|2ltw@KF&|-lz#&Zer?e^pn*>ko6U;}Ot%dOD&UaA@_D09ka9%#oZXcQ>>hMU%)O07OwL!0bK5fdOIbx6_->CGW*rC4V ze$FvV3GHa~r(zM$Nkr8mmLMbhkztk<;aU`jFqZiDFBiI%+=BLNooqn8{i1hS5?$T= z2;ZHhb4FpGuuPCqlqd(w$gQBnbv}h(ws;T?RfPSt(u;ke@4>;aTUeRWH&7i*Z)52l z(gAd{kiL@5`w*KFdUze@g9*=kMU_4sI|QQ(vft?ZU@q51AI<;?K$tE|$akXK{r3ANrS`$u!ynNmztd z))QCSE$i-YX5Si-DwVg#Z-$8*XfDsEH^o%y$OS1WSGeR_h(UPB%?>oo$NV= ztUfEpLy3yU0wFvpClUA0Lv~(N4=|! zUciVsg{T|Rnn7)hblX&o%+Q@%tE9E=7JWh-E*wlPyGM*E0moy-Gh$K2LP>5GIhSRw zw<3IY{>d*EHAcr&MKNURHgag|6ENaDS6w>geFrED8{v4KS`r|e3qa3J_%E9K<7SM9 z73H*wR?}%*P+5)hyntV=x+OHKECVrz@>)l)dh8WupE0OjTeU#rndJ0qdpd5sm^$jC z91Gp{t>jzfxGM@YYVk|Y>FPBb9%(pBZ6-FrNI189rh38p-;Gg~j+`J$e#0@)m0dpw zxoRC=-R509iz+Ny&T89F<0TtqkZ?Z5%p$B|`wcYQ`f8d^X^PwZ9TKrO60Gv(WjJjq?gXdKv z96i(Imqd@?^>h1{QWZxkyXzYd)7lQO-?lj|c!?O@I;yWZf}g(wCCJ&Sl1wnYI*Vzf z@L?*QR zM)%gBP0JgSOeBS&U%_e47@ml%b7`qQ$`EP4uTtC*i&IOue~-FA(Js-V>SL%%oY^whZvZJW2>OWL%MnT>=#hU7+V1W7yd4v9=; z>8WBMP8{V*?%Uv}dqGoLR&x)6UmLk*Zu6_m*MyV=PbxIxKX11~*UDfh>^XyXFeRn& z&#J`LwbShBGsWq(#jx`#oO8e@&<`vVRL5Zh)8*Ic35LFLXrX@iR3H?yY;l&m_XPaD z3X^}tlLV6cj*+6ufT4RySVK`&?`Vg7?BzTPsgY}D667E^%*%<8 z%!t_f;$27Vl8LR;jEOP-ofM8Wt6sbjhoac*90COk=(1`V{lN^hBp>y$+)n&O^(WET zxOO66wWcnn98Hqm8{{M(o+srbuYEo4sKs&U8^bUd9Dc{qr2L3vpzdz*$cIppSgeX_ z+HOe${^cjzL&)d3cY+YNWMo(kL+z3DhNJ9-qfjhR#z__qa{6AVBof6= zTeKuwlXQ~KV_G8FYD^MM{!AwnLIt?g;GBI$Oa_hGKAYWzVl{c8>^VQdijH+%`%p?Q zq~SZ`diFK@a87!~wM`p5z2@9ZX}gYN^^sl=q%!2Hbb3B22Zd_(KJ=dDXg}b=HmG{w zDga?b;1^nH#b{&n^|d+}owsJQ-`_dZIF!QsVlcg3%OMj>vy#Rl<=*lg0>f$ZnG)&p z!XXX)j5-49SWi?XsNrQ++z{hKH|<353mtmA`calDHkFpSXC^sfW=4-U?DpS5<#=vr zRzwlV%IxkAvo2xpx+fv}L*Xj+wdOolQS=XH{oeIYrypp$|u9#=xLIvgY}SdR-iq!Lwg& zKxF;Fdf%wVHsSH?gHO+QUhX$L_WytKEj!;?K2!?++^1XjXU{tol`S!f|@k{=Dn$Gb+oE#zgOV_f7TIQ?>5qvm?l0 zdw>RQ8Izh*pU5^svL7(}RC2qYpqMvX6Hi()hkY;{rch?vuNP&hzqP4PyeD~x&I@K> z;-ruKKKzOkJsug^dOrdd@8BEvj6Q+ z1sarLl9k?he#|bgqbdn9wl85m0i?3Sr1-f)9TpS||3}uzz}XKkunjd6x$amS*+AeC z-1bnR%87MBqEPE`5r#k*oaw;eNkg8rW_HQ#93_6in|ab6|CH?j@58CKvT8;nC%;42 zLA-@-7T63J6q*`JZN1x6sy=o|QpX$Z;3!gD*8&YgkAJ;|3`?)P#6$+m=G1Xkd z*ZUfGPEm<7Uu?oOZ;2hfijk`2u-VB-9<_!5Yujz{ct_XVqt;q`v}#K&sYdWgILW*LZM;a_!M1mnjf(F!1Q?WM7dQVZv~=nL!E@mRVU z7Bdj|(oCEWY+MMP^en*H!0xieo=Sxgu7VzD_j-RZu~iTAl`0(C?{-aVO85YqgaEPg ziMdWkK;fu%)R>#{mMXCwX(;aa#Z;^rh?=9Q;?tW)!6tAH|BoiypNzZi2W= zFiDH!8$T|+d)Sy!>(25ycA@wMyLE+J>&J?99+&&OE%SS_i9M}|{zMx$XVPx)?J z+{Bh{ubBJ<9`Qkg7KteKP~+?8bEjpb3}zabvI!g5QF?e4+-x|vyd4(UW(;PLPsv~< zSF2)b12%2bBJ1r?Q|1RgnHeN^NLPF_EY{ES1zPoX3tt(v>H|nCnBbml!}el}%M>0q zK&s3Njv=#>cex;}f}|q({laRP`fo$^X}s1cAC#UzDSmPHgZFkNB-r6mV_yBbh~gc* z=PN0<9kvf}pUzkuh|q6KkRnxzI~4K6qaP_&erws}dNIz5?vsZt$K z+-~-cEowM&0sOv&D!5HANI_peTjsw&38R$2njTBohY==BkWO3|WMHEp@x)sX8`UJRewHKaZq!DNOtPP&nFq)ZL#7$h$1BwO8KSU=r9&~u zcv-_=nQ(jJ;e_X%1K2KbbWs&fYx&Z2ryfDSW`PwF)MMao6b{jsWz{n12w^b-Y|?73 z*k{yw4aZSbXA)>*v;g3{s_um2Kp0XmIJ|l>pHB5YxOo@d23>7B#Bfey2aCm^qgSmN z8&9&g-X-Q}VkE!tFZc z<~jy3)>zCH%RMX0t-DC|c5_pBK}f_VO+>ym?3|9f9f#+5uI^?05;Yy6A|>g!=ot%y zMJr-tK6ouf4MUkeM=rBgwpr7If!H|Ys-jiE;c(J+IC*b_hNvuY5Y(BSC*sRttt%wA z-vCFebLXT6`&JppYAQQ*JHnRDXOLjWdS&Nv1^!oswO3RA$AV0f42}++0|$=_kX((L zXRr~fWW-HszpkoVRaJgCJ5T3}U(iU#rpH!W4za~4S1a!k>j=hfJ6kRf28vDG6QA&) z)n@|^hXWRcN+R6EEBf`?d0G(~hV{boQ@_+ul43*6kEv_@1H!F)aS)siqYx9qMW6JQ zRM|cnH3)AqcfBTZ61hjyEHd1z%Jw8igL%mjJO?dTa{<2JHDSl#UC4jmm}C+`V}W=a z-Jx&_tZExdz(f$iGJ5aL#FO{M@%7HJg$#Ndl%tIrqB@g(c;KC^;jUheZRZjFje;>W z^c-y?r8U1Tn=qD#Y7h+^srrGjn|hGeg4HPCBv#X>CLGm0KFDVF_@6noeMc*$X`rMx zlA!tlw~;T@z(IVsOeqRG)>@-I?JzZyWZXn^d0gJ4`Aj{RH!Uh=8GL0)*^W($t-GYR z+N^wS=yGhaajp0xT82U1a^LtKBhbf^^4zDn^stFzTr=ozUFc$yPGLbye zE?jqbMq>6<@(n*hwLcf)+#PWdhkk1|M0a>cwq@F-0#7W0lF=2|uk|Bj`nhux7N{?m zS7-fs)$Un-X2YUN@MV2jn~V9V$&@6e9S>EGEB+hkkz-r(;FkpIxws^=d=pf$a6JZ8 znNZjq6x3iVlnTu_ys)B$s`@Y3h*Ww!3srt9%24nTO7{g`e|^z|7d;J2qew+Eu)?PD zIGY+jDY-{juMl`hidU<1ng=!*i#l^y7pB*yqpsXAm9*zzmr333Gn|?cQv&N;>n=sB zPpDCkiK@Ik;o!zeD+Co~@}0@_NNCt})XZQ7aJ5AKMza^|Nj_eVp80X1cR#_i5rvQ( z9hsgl0;6~7vka_8PdX*-sWrez^@Uy`75!Qb-PtoD5GWH3()#EsVVn47j+8wvHDE-% zrME`HozH~_&5nDgY*}q&rE@f)xXtdyk3ch6ZGI4c8f?&krIL(6HzYjjdt3h1w31HE z-U^dgC0@FsD73^#$*U?2m+rfC&ipTmE%XcLWxjBpv<)95JcbZzpH8wwi!7GPSDGn< zHhRMwq=Hljrm^SF*O;DFs*J#D7?cIapf zP4Yi+Wqz0hIY+DM=xkr4{7FN9ro(|!2|2c^yKEj<<})MT(9z1Jdqu}sFhj%YP4dqB z5^sr?nMbP-jVs#(U*_?OYlezwpv-I#-ii_!gwT_67p|f$g1y%LDyL%Kyf*cGg_Mr_ zprb8C|6|M^h+D5#G{Vr?FRK`$d}aO=Qvx2{ z(gb$*Zt0MknZ`Z&szg**NM|_bG#-uWG@3^i!!HnQ+Id=NaU(wm7(>X-(CG>}mU6dx zDogBW;td!K2AIJSGFX&fSkW@t>QV3*W#J14kG*-vAi2Wb(K|t}CETlSw-RW#+?qt( z;|nZkAOBKsm{ys)^MiWHAz{E52ngP~QkYm24aND_{+V=rTxH#)C8q@<=@-a;F6jdpf z;h%29dXxcdvU50eHBMZ>+}?FjS?ZRMvc z2df-t{gSyjPf=XPSQ~JCy3|5}8MW?uX7<5QCpZQht#a^arQcHaB}r>XCJ+kJ77zc5 z%BU_epPSHb;bjP7D9{=;%U6CIJDOYUcuS217rMScVP}lxaXx&y#xiKT&78h6BkCAm z3(FVFCOBuBBB$6Fuhpr*ngcpgj`?Nllpd0j%=ngnX+P#IEA64?$)jMk`8y&nH&ODG z@(nQ@vs{Qq`asGYRxfv(w3RrFAalT5tOpDs)~J%+y*XS*2DGj8^-srZYN}wI-CRc@ zwZaiga33Y9awJ)2F=!f8ipN`yiG0;zEMPtIoXL32cYCq8`#~kA&M10swA7o2{?Gc^ z6UOufED8>+NjQB(%2`bf61aeHMIo59b}dTEo}4<%4)erU6~=eIzGFEiyRfUF<}6EL6U3JVvtW zc>pb11hR@GybXLKj0S}lR!U0fB7G`v95obb%wm#*ip5J-WrT}SSP#Mm7yYVAlBM!P zh+Uev9B@cl-|1kXEXhEpAiYvd@<#S68RizqvNBY~2)#d+A_4|x$*1xkPjDJB<+znE z=X=j7p1Z(rxFpfHGrPRj$<299D9_ra<>=-3^OdimT+3lTIdEZUN)+f#rgfHM1q_uC zrJ5z-Wu^-h2Z0LjV(IP?JSo34lMy#x&skxEnL$cnf}!X$ZW5bS0tG>caSnq*FhxX& z4o7=GHgPragIhA-r1f?F2QcfPm%Xm98`jjf2-*_ylA6mBp)j6d4w{4Y)bu8EpT(vu z;AyjRFlrkcEL39#i6lMgPNeWHMV0vAq@S>k+5l!hQwQI25&4u2*Zw3&#!9V=+)~ni zy}i;=r-Wue(ajjaYhD=gZK%5IX2p8-h&>Z9Px=5NWyZZk{VLOmjgkcc?#EKOzPN4PTE`n1wJJ%H_hw=) zb4(^4C22~{p|2ACRVo>E1|pqY2ySJE3^ZH=Z#=b6yv;Tn9v$QHNIB}v4XLnas1s+d&`kIo-^CJS_6GAWW$*-x zm7i)q1w2Muoe++ahD6C++Q4+aZ)J1REx~>1t|=e~HE8b&Dlp+E5P=E}E)ul{$I$Bi zcO?i8SuQ7e5A_j8!&=l|PNw6R2^fnT=A_e%hF| z`er^jp**CnBN&TbOA_dn(=e@JGe(#rkuHE8bAgemFH!08z}dpy#v~prwcUBYLlPgY zcPQ>&+gz~*3o^TH*jZHOtv3ik(_t08f;9>oc#C&FQRl0K_Hb_s1Q!HqSh2(<#>&AL zW|}@gV>Kp2y%%b7$5tu%DR|hgyth1t8YM{&=Y{}vAYC-9~yVR^F{cg;ge;Q7lq`Xp^7eepVyd5m{7O2|UkUm?4w^hNvj zRs>*&l$5c?pjz1NRG6Wr(<~?iv6>b4G!Y^oQM0nVeipWfs^hv|ur1zv0Ly+`xmF}-x&lHLvr4%X`w zJDgUmV<&QrX)^Xh7Sn zci_py21_i%LuHyNe>Sla5Wm54ttBi zEDB)dSr>EVASg`6SbR^t_XQK`709F9l4jU!@lVwjpdV_n@S&TftWa z^6+>~(OIAh*WhEYPC-iQHj_nMM!y;TN93n3t87{c&dliG7Mr||rHQ%^r=>ak7wPNn z1@7kWhhrLkhNzY1c2XZ4ukg&$rc=|2@^w-!bi0G_vZbQhU8DEZTJCX+X-FZiV$%{+ z_VQ5|wF91N%ILZRG@WpKN-1el$p+qu6Q{MkM$aoZQ-ppS7X!jJONr^F>V299&yUJ< z7jRj)T3t*0N)~MCIxdD1q5Wg~x6iX~xu;u>ww2ncRO5k~LKDGfi%RH@)Ep)c9(}>V zA`#Me=E+d3JyI#{QCpn2Fwm`D1=RuhJyg^8IWSIAQhoQoxwzR>K zzqB=X??Pu&_p*uFV=>lPFAw22qaa*tjmfhMpNHQ-Tm4S(J~-uuIURLPNE#t(^})6V z9bj!+CTH8=`0NHBQBP)rH8|onw2pN-Xl9%Q!dJUz7jx-URAp!3pWbFjimlMghXQvq zy9Nu|W~JVXSoB6;waCP$8I6!0LZwKN`W9$l?PTnSqb!;MxBS+J-jL$W>}a#kVD49h zl-avHGK`DBE1s$f_lGCuULQ)#?@{Ga{$hY@_XhG%D_d}g7`!!;C?SSNS*vjoB>YMM z#1bW{b1~DgI*v@i?(&`*7#8^IeS<%CnT7(!PA zDO8n8^6CAoQy_m=25b48d=8%Qje#~$w~hMidj+xRQ>w$RJ!Fr)mn+&1T3KH1F+pBb zGk_2hd(5O(;B~4F&hM-gJ)1B~q18vG*>xdx5n=LszKFBfI(mPXjZ&*Io~Z~tH`Ri; zhBOaX_k`<$cq(bj2u%ibasA|pNF$8RUm&*Y5h*Yi7cxd=K4t^}rDw4EkudC~cz z5~rF7iaA8S(;M*W@IrKYt;fSMK`tgu96MYPlg_c-9A1`8WS4!W$4ky{MY;c-LCMFp#jy?%8W2x^<9cmbD{-( z3_>z?Q9`^?gs^C*@?e&ETYE+emR z&A_iW{;R1CmQsshwJ}smMWDf7Q4v4kmIiH?mnziPYiXfu`%JlEWi|5nyWe zCY2)1Ot&{)zD#itU5C>X#W=+BV2%njbbm_%!cSs@ye8#O^>ab-HBc%rtdCy~9i&zKGTv{-S{Bw1- zFOaLOS0$3UrW@VseyfHS)I3M^QngLt3?~BbLbr5@Gv7@5p}YM?_}Dl;PzpVb`nq-8 zw58a5k!twy?c4B2R)xTT;9Z!a8o#CTnzGG_r$=GJl#a0~(kW1L6N;)xK3ED`42vUt zbEC)07iY9sPffIl9(FS`tsd@5CikyuPLMsv5XAe)v<&e|AI9bZA3NsZ?(pg1*H|4p zcXT@I9I%{Rt!n@;0!$s%-iL0@k3da`ppMaV9idi!1L?kBKDni?l5@gCu^E74BaO5v#YWo3JN#fo1SOA751R8=%Y0R5ua44UE{68fCfpTIWxGAh zj%By_{<~e&{;`dIr$YD;;RDSFzH6vXPNLm>7|TR~GoreHE14$!WxzKOHY|SGasWM- zeh-S8-P<_)h$YX8XOq1DXU?Dh?yUR&kNUsga{XN$s(b^TNt8#SL_GE(zf0T)D`qd0 zgfsv|z#>5bA+sPT5D0_@gIp8mX_;Ls4&2e7T7CnSTW&>7nu@2Lij!AGA5C6N9{5gP zBwGTDA6IHx)rM^W+!r-gZ?=9kI124=kyf;&yoQ&DQ*?@1(??nhzd5C zoTR83h~_(r5;vpTsy(k=gRed3oV5N1G6odMyGmDKZlwGT^hR#d%oKJ)@@aevVBzd3 z*33tS8ehOIToolL&S%-O)gmU{vQ{(camrCMX+|mS!Ow6L<(3Ob|4B)HPOxV7>u;dT z(vR01by-%Ce>l&M(h$G=K`l=Nfmi7opg13kYbM26Elwc*xf*`k3lwq}lXF4?q9$sZ zVh89a)?Ref)&NgpQF?5VM}cK0txv7N7}h72HM19emNgUN(YgbOHxLG%9{2|G%%}km zAXmk$F#&5fShgH7yspr+glGE(G9!RqDP}HjlL1m3*taHK6%oOk*)$pUvA2Dlo$vkPWkMHNLyED1E=0ikj{<* zfgr^hZi@7IF~tp$P7)^vn%pQM%Nr66oOEV4L|Q?d7z84Z08Ww{HPJv#Scu<@X;2jK z6N-~-+^~@bnvGM98$wN-9mNmGKODVbD}7nbH>Mgunmmf^rtS2l^upKzbW5kAThj~_d#lpF12rtIH&H-`ytjXKv(ESjJI{{401io)6*M4zMvuJup14&ZQ@TRRM~Ok)l=9@c z-@4u6QbafFb_3TcHDkI_ z&wCu6JmTh*U+H`QN6LxC$^U1R*FyrmrT-D-*6(kN|L-WDxZnr+O#dUw$M&HA1?B(l z=CZjZg8asm|Lglp>%%jzn{xgy?=ZiCN|*k3paY#CkN+9z!1aFP_KFez=B<9S{|feiGv@M7oIDD+#hkQ${oT!T`H4JA;di$b z(A(Ln5hstn^mtr;FAcm*l6+72qZ0&hQeFQ2g#Ovm+6`p>z!{%G;#`&wXzjmy8EsNeq4VtDe~@PH46A?hA6pdEco?sE(cya|858D;dB z2~pyNzgO3vIheHU{HFZ_@~1zV=dBzskVYOQw8ryD9V|}HKlmU_f;~!{EKW$VqU#4~ zk*oFb5%8`7zsirWUo8EgOc{2UAfk&rvIvTB5-CcY7z4xeKm!n@iyle8{X^Lz{jMro z?wtN+^ADK+SkXTm{6l^}*!o8TVumZy!PXwLm(qU`{!=agaoj(vMv2p2^%fdyx?cQd z@}Fe8{wI-N*c&B#&0SbAIeUfai8sJq<-h$0;eORwcpf)%mFUD@ne?CP1pBJWc8H_Zw)rjcTvpT>q;h|5GtUuX(?Ln^%S_IG;WKFQlWdxxX)|_;?lQ z!2e|7uj*^%sssGeE!guj(3!tF@IRG<>#FKx1 z$X^}$p9&Iv%>kan1T@Z9poaf%q>rw;3yW!hcJ2z*K=wt%+LO) z=d;6EzLepk-*Vl*>IL_oG_$;l_3u{vA^qEtS6)5k^_wt5LQJCE$)UgR;<-9hsmD1f zc@68{D>A?ONLaa@ z%mX)Ez|Zb+)eByRTyvf4E+8#CiuR|Z)1UQzsG-|=~asdIo6jx zWscu^$5K~4;NuW_c$U||Uiw4eZ*%ZufIu8g<7SR9*zZ+Cf(Ft@0zTg>UK3(O(4^%R zvXB2(^3OaYNFS7QE2-%c4Ah6TeJ`YR?bR{(M35Tn6|^rdlM+{4zTT=3Ade6mzEl(@ zkAf$U5)1jR&ST_P^(yww@fm|SS;_a57*_}3&EG@5xkmQo!D4Y7)A!DK$7&s+>oXf( zOdGcsJyFrcg0lWzAgKq~nCPtjcQ-)1DI(7=(?7cA`u;e|k9C#oB_Ju*+MC2kawu#p z! zM2VC3ay95TMD4DaDmg4U!2{p$Nndpano1UVUZEN|HiC}!u?G@XSFvQIk_tmaNB0Yo z1vlh~xSX!<$^uw%K^^9VUaV(PBt4;*Ew$uTSKx%8_Twu|FI^f103l93A>Q=e!0%$> z(0{&<5Rq`>%I)r$5^l**H@@5({o4@yk3jF;-natv?^S$xeX#;;_aJ}S^<9(i&x;6% z#9Vx`J^%1cWq7H&6xyY7^0knXmWX)upK!jcVv!MF0aa5oW+?Qbp+q)lxmmUPZtMBB z8v5^TgaFiIllR$hP`o~g(}d%kKzec5s}UvEXTA+rU#GqZ-#|+gKf}Cqne?AGEI#D) zJEw`rXI`WiotKFtuSb*s9WatBEMHdggZ=)0$^c>rXFpPCi_2~&*;)_&QuQy?)Ku}M%j_ku29&_p0R8@-VXpk1@}FeMqhJN{yboW)4M~@2N#6xB zB9FTGBc9|>n74rD^kqJ75}*$GcNOvb_n>Lyc#-!=4!Z@vo8opYMyk<$@(R&ESM=XxLAo=)+vjG{ zDGU9Za@y4pDe1|}5Un48{@y5GHgZvXKp8I^q+e|C(7fXz`Hq!)K(fmOKOM&x^%KQy|7_W>_rhNd zSsgq2Nd6PWzuyo2yGj=PMab$%OHJ2L6yM~Y@0!)X4fxfFRfcn5OyNh0|En6l7OzTT zy;boO#s3w;1iu(g>_PMZhChCwnEKzvZ(Q^ACyM{83Xc9otm;wQ?9Ukg zS2f&nJ@mQ;>*6PjVXyt(H>ertYoXVT=Vi4&aolwSnQNyd|Mk%8C$n3AKV$s(zfg|A zxEgp(`3>~sXN(iCnRA1xA-@)P-F5F&|0j-(Zy1C>=Dh|10sTOrEjkF8_gWrJ-_|QqFQeS1b(ff# ze^74zvu8wl+4qUBfeEtt(7u7zSIo_w$WL1N%GlWsQ%pAQe;5h)(sORCdz@qlOi6TW z)Nq3Zn3l-oqHysW$i`1v+GOKyd#-nGW$XDuD$ZOJ%OUYOD%{+K&lf@}`24JOuJ+uj zIYm*7FCX%a1XS`D@9-nxVOCCX`6_^%;KQVsIG|x>&|p z^10*_5nzs3_aVW2J>s(`I=+Ks^QjmXy}eNFt#s8<;8YiYKH8Mh&omV`^8*0})*Q7s6zdbTV-y?RUOpx*1L8eZ9#q+5chgX`U%E2MLIuGY9 zN__?r>)h%EN-+rK#l`t*5=%g4;is~vbGytPy40bi>_S1NM|mJtvJW~A zEMRnMc#1&L`%KaiB}Ck!T5b~Jl@h4;oQQLJc`4n^g&u!M0YkH<){nhbtNPUce7KEM zfFK|4E?QF_KWDhK|&M|nVuCtBs9)GLJ4 z@l4;nFV)<*2-zdgt>E3K8tfTg`0-9gWgl~Bp2`-URc~#D2X@)Mx?6(4bmfx5Gy}yG zkYv?xl7)vhb{3IZK})Kn^>^Nv2;0&9{z19BMA@z| zR;yrHmA3x(4=3hX@_EDN9Jrw(S#o(ww098v1T%hmgW#Q>NBiST<{$sEzU2P!FDKtz zBkt#yScx2ke5C?q+E|Hjsl^jq!=d{Z{s{;De7n*K_9vRe8}_g85i>j{ANl1oJ$Ku5 zwmcyT1p8XqK9LOHIhqIFit{NNt6!|+B%ycWBfgqH)vKiz#TT#@q$gTHaxo$LN=lRI zeoG>N*X;eRy1zF2ALzWJ7v6CakFvty`nvnyyP5yvxf6Le$^yZji z8#D2VABs)K$=eW>2eNe!4HFa1(AxvK->1es1P3xYE@rLlqYETNp^vjn9wBnZpc_)X zPn(q*W*}iKP+OAzl-fbufsz|q<+u}A*xPcT+Y*{tQV1>T5M4C$0#6U8y%*|YuLDHc z8(4)wr5Vw;kh#zNE@Hno^{n7gXba5F9GFfl+o$2KOHF8XrX=nTi}m{&Cb_2GfPf=t zvviTcd)&*P)RG1JO5X609`#y33i_D13_Y1oSxa4^mN_A`L(#BT%pG{^najIKenhx$ zprP~rNZdwVr3U_54%76a$%U}bNnLopq05OIuO!|*;(Up?$S}2&!^JRX+5Dcg>_&P-?D<_$pzu zi88m-4iOb`AvP33v-|*wUMyY#!`hdlStJOlQjuFx$=1(N?YlMkFf^#WO*d-O7lhGiO@88YBoOq~yAV{hMyNFJ9wt|2{6 zhQzaTt#}9iQdm~~Nlmgf+{J(ywERRfzPXw({hsjoj_Rq`JR$H*)8M1MJ_jUMvZH*g zyO7+d70z;UFa4dnSlrLo>UQI}3R*az1wRuQVqH`gKi>AVG(;b4S_y2~8rvPs#CrR1 z%lp~!s9$CqH(sh+J_{E|gJ803V79vcK4rs;*HlMnMNPNp?2czD9Qipz!y-RuaN3wP zt+=y~xuBJ!B~Lvb*)=HlKtHs@DE9Hofk!>z#5BeXTlVTNFITLX8@FSt(l4$v%B3AI#1 zi#KhL%lKu@)Mrp1l2mI|8S!Z4&Q7n53sSKmMcF0Qg(~lr&Yq$FeCB54^00-kntlHg zI0FZU2opOG*gJD=&yj!MG5`HMcfUN(i7rzIT&BMEaM}ON?VGO8xIaQib2k;yr%L-Swhxrq!I7XT&Ug7132`g z(hzrV(HM9?(!z9QTZ(F7i%Kwyq5ucuZSW=G$uCH~GQ)0)jp63i84_%a4$OOCPeiDO zYiXu@WVprQD;Q-TeZK!9MRmbW;g&(`bbP@F)AT#Y;Q>303d3TX$3hF*qk(r)9&UC9 zA8)7;E&C5h4G4GBnq~R6x-*-7l;DeSF+tsC*~G-;4!0Mr$3!}*YI}Z)il3vSPd*CW`-Gti1(L zTut*gN^pX^J0ZBcyE_Dj;O_3h-JL~(E)XEd;!bb~zPP&uhv4LH-sgG$x9+XFU)`_j ztJ93z%+ySup8oZ8FGZYcgv1L+J+ac}@HUX_shSzjKjvi!EG4U(NeSe7z8zgs zsfr#6%^_Es82rV1%?(_`}IF(LiVQufpJ5B=bbQnI5P7=MSC`>Kxl_M?g zfUGFVbk^jmZkV5-4y#woOunQOdxeDP4C6f%^T|R1dZ1t4EBa|Z3mO_dCKy5a` zv#D7a#Ujx*=4gHNq<=SC)Hr_AVc7OH>8Q*)`&v@WJa^;HKAF0yrzEtYLgfTQCY?}& zo{pj2x8P!ZYf&?;D!mFOw?HoN+sVjbhbWhB3Qn1h)e47!&YNbyw5j~3jArXDBR#`= z>Yd!i)0s+Wc+I%!mAk#aPEE}I@V4^42gmEmgG|3TT zjTO)qgp&d1<^%s?R;&n4`eb?srHC6l;kIR5t4p_ftE5iiSy6o%H)j{?tXFMTfC+0$ z88y!*>V#&^m6;Rd46uCF8h@hCy3-UUqc4bHnpJ5W*UquKft>tohuGbg950)=!fS-L zLhtQVu)vPWxREwy1s_z8629?Po5g`Ovw=W*t5`=3?2|mQubh5ls1L@mw&B}Z;m11F zT584xlwI7Ikhh4ICe8skeXX*fqVM<`R$Y^u-SF53SpRiy@m9YWj8_F#W`+|V+>BR? z`o`wxGcGe9%L{BQ!T+8|m063UDJ?Gj;e@%j(5fK7&_(&%;5Xi?PiroiCtm2P1aup1 z3krk!?JkYl8SdO={3U*jIG$y@q3sKH40lms10~!54%N!bpcScTS~RC&`worX_}x6~ z(B7AYbYrlp06XpRc2diUW1V>|XVz&u_s7Qal~6IYv0VCX)s~~WJaOatd-K{8C!ysV z_qawb{N5hBa2Czd!N<4X--~1``Y&{bDut0#@5!f^$Xw4j=Tth0Iew~Is)C-~J(g8= z(R(hDXU2df3Q@P_VL#49i|4E746B%$NT_O!e7NK^g^0DZrtd`1S0$v&&f|t1G6L7+ zCnW;-imZ$zn2XYSclZ~UY4~BI9}jDSWED*5S`V?J+J9H^UGix4_z+Q{$^vAJ3 zT3`y}`Ba|e#%UfM{*BN6+U6Es82%a-%x`0{GHD zsEzg3)u*}A+!7l2T0IB1xp>LOY9;Ns0orWtS*imYg~-sP>N)vW!j@|{|@VqEb z1rC+eTj1b5gTuPsZ1f;$Zfq53FoJjp@&FHRo0**G0o zJw|PFq3tpAEK!~Oz>8Ua9{FbLT(95~&q)eZfLTTGO>k8EP1SybDkUCjDVZaHf-?O^ zj%?u&H(WtjPs*?FcM+2*r$8iWEehXkHY_q~aAUxvcd;)|XKL|HuNI=-+n91Z;`bp) zU5VHfL5`0)bpHK-U?*8q@s+%eVxk*re}C;#4ljQGQTH6Xd-4w|Se7y;)?LMJYGJez z-j$nbbj{%s6Y+30`sC=IqW$nKn-nn*GF=c%R} z`|=D}oR!QS#sp^c2_sbOR@62ifkXW+rj?=CqSN4FJPx}vy?4R*ZVxwYWH#7{S}c`C zZ~F`JwYq}ug}y*du*Wj%4|2HxsA7HGilZ6q%k;};L9vI@1|ga{yM6#bf={$;WnIu( zi6tzmb&GNZ;e}AS&mcWf%~{N5m)kgXGaZTxXu~S-1a0hQs4F&;M~m8pl}oBe?O_mc zLD%;y0ET2L^Ru7wGXH_EeJl$~^I40EmM%a0co~IUv$;IsBZEviE4gLQy7+XZz(9aj z-H}b58|JF;^Ra^(G;Q|Mky#`vTvqkZM}2W(C80^e7VED@&)|k;$)8ZqIN85S>9=2+ z*NbyAt%dfYR_#8)AM?}WpxhT|cA8a#V7n+@=~cxM!R$65X7!6TBz;};qU874%BdZ%0%H5z0onA>M%cu+Ig6_mdk zQJ(IPRr^Sry@9*piAE&pOFy;+l-u3FMF}GbXa0hR#@VGbZT?C!%MQ-U^I2RJB;j7T z&yA7%K3A~{I)*ompMz@dCiKz75`BAr-Tj=etj_>2yr5`$8d;a!ICz)xx{nm1KM;c9ZETo@K87@T)X*Vtqmodq!8cZE+bvZv3`*ky zx}<5;T=`Dkj*s)m3ZxF|^}$-kO{LW?Hr3iTEyxLT5eR;Lv!bW9Jfto4=jqCc8&na`L%W*e!pBhZ2A|=t%i;x4>f~v7XP@{rLM; z856aP`Z4y;Q40nt?K#rTM;(?%%cB9>EP#pp5ZWIo_fGW)i=zB1Qhh*gv^!$j$=a4JGp{r3b5Yc6dr9`{SxMUA5&1*ZidwZLx#1>l}6y;*^=& zOjl>hV#W~;T<=iJz;Pg}A9P#t#_}*ZoT9j;VH0Ij(hp1ThDfZZZT#e zmOHzk#*e#?0l@IMGGWRq-V1Dv#O6c6;bstyl}eDJ$gN^J;oh2$nVGqPvK(>DX-A#1 zML4@bX3C!EzUNAb+?4JDZ5=9@Y@BT6S@klBERRDAtfg!=k10)JR@_w416|^mNKn0y zM>K`F9UBSyJB!X?^1-dMLmbVaeUEbx~>J&viVF`$Zv&Z?# zPI4RRtKpc?6bBa#8aW@(OrJJ$Ww(8qKyDrCqGYn4V3H5aO4neo23-NI71}1!^7$VY zqGi$?FbRjc-y=fHk5lt+9Dv72%RVxMZ99I`m`U3-TQv{5?VG5%3RwBBXynAnH%ZQw zk;?i&AIg>#a^ut}DVF9E^Rf~7;T;~Q{VoyHgpv@AcXD(BYgbFvz-(Lto)9coaz(2N z`X>?_ndZ*BN^%;18iVX%K3k}LQwO`jKTx!AM@j# zby8;TQywbMt)2(;1rJztkn~W&PEG=m=8B&dj&EAFD{psm5c@Y)*D8!$BzA^2%$}Pl z*uL6z1ax5F?fd-(k~T=43@kT6gLua9LrvrqdVn7hKk?(@mq2N#7 z{3eBoi%1aTjZ1!C&XWhW_Nm>J!4%x@_xG=%hcsh+`&>}a<6`+J={n$2IomS*UTwe-uvNctI` zu#%(y&iA2yrtI;iYkfML5zzWUb_f$XMRwRB-=T^&;m01?8_d2z@lNF%oYr$Z7D+2I zBPR`tB_*#&A%j4xA_6XDrtR+?T{gtY!t(IGB|O0%g_7_>p8;~qInL4tB_bzE%+!+-sawsDt;+eo&npMDbU^ z{zkHw_>5CV7&SI^7&}*}cJj=YxY2ZHrWP3ScYztZ0VDPeh`P@oq$5=|lY-WmqR4712uz2cIPSo(^Ra0P8N zOs9h32%mq=}qU3uTRwe)W_N8Hk_Fs#e?2XUr z7>d0?m>{B!`viuq*W;vUV7rU*j-2@!Ck{LdOfzYJW$Sc7k>1HqVXliVPWo2PMsdua zR0gNL=0qVRq2wQ6@es1vRMu;C$VF|@Mdr=d?w_fu2cuPU!c6^E2C?M5MOb)}567ZW zg7=2%dt@=2Xv#8l+Q)CCzARSzt3e5%!&%%sa)q%`E+dONs7cf!-xeXiv-ZiU(j z7lMb_oYEKA=Ls}X+GaiR_q;lZoneSOSvSu)eec_Z&U{Rj_*8>Qs-$Q@@dLkp)bMW<~R2e~x zbJHk@5!D`MDKrnS0ktUdP}7fT4&YbXwM(Q<;4^H{eN=)_NLHz0C8TT(ZMG0^K6qa& z@%RSS&(&D@U0PoHG>f3dwz$|wsG^6UvXH-`%B-oPx~UdE6#VIg8wmaM6~DZgQLe_S z*v_Uru}Sc97{0ieU0qpOQC)jN2&1BOqg`v7Q)$9h8}(H+?)SEQ8I|#r>%A7EfNbyX zwc?D6VUNQ@+63Z{mBrbIn=-vz25ez}vw+!P783X4qd^~_RZ&F+#AKANsN@3Pl_Qpf zX%1QA2HMf(4BE@9>)A0dFpK|Ku{{a++yYdp_Cjam5ok)<&276|X^t ztM?!_$-KPVp3QNUIbrVSWuV)_jcfWSo%vaF=e0?XU7p7)aVVe3r%0Oc50v_qQ+k${ z?D*xCoPsChC=k~-Y`0KMu3^Thi6<}yfdA09LM_^!sPwqF4xF3*kY=h)8+3@t8|Rn;=Pedzxn1^}eS##FAvWuW2;aaRDM zYasn*VAfY}l5!0;51)gK$L>z1^GUpMVFnrl&lZUS0I*=sTO3`&JsZ6MK&-5&V*SBD zdxu*?StCt#km)F_83z^^o3!KRlQygO?nPu!pLO>WaP$66gt)2!4>`k^=aphmb`dQTnI*g0m!Z{HH@q! zebi+Zn&@ej&8`I7G-6ymcp_at2&J&)LdU0!j-thdizKeDslSqH)8;W?a_7Xl-7LOv zs1yX8HGeKNR121ooslao#k54(iRM)AlA4zBk>Z{U>FuI1D-LnjLxw|g7Lbt-G>UtO zjHdKVvi%%=Q-&Dhc2-0?-b@x(^DaNt6i6#OiUppSLmPOTOsqK)8u`dZ$i0|P#gSG_ zc*d!MvLg)og?2kayyiv`*16HvfL*qDXw@ zoalZ?9Aj@jw^ndP7A0!i#Nb4tC_kBWZN$66>~4_R(?r}U4|-88&?V5S@0R;^@}J+R z?#FrLl7>-AxqIS|4WgyH{rvHw38U;kbd{mY5|m$Uz|_J92)y4wRmfm!~80>4A} zpW?^=MS&q8a8dmwM#>Bur1~+1*!Gp$zZfv|zZmegSSASM{rRQDIxqQ6+rx zqZadu3pT9(`jU{MN?veHBX#OpM$TT|$WCtR%eW2pYgwa%@7GeyB1S2}KTu4aKXjTv z)?gfqnqa>-UE8Upv!?-VtdLXhml|Qhy0`E*w2QF?8Nshd{8n_);ICsKt8agxWGFl| z@1I{P@oj{A%6J}vv^se^L}&5#Uf;CRRv5`4RS*2hFZPWE?|W`dJDe{bwJ$Hfe4bYG z^s^U(CC~7jEwy$(9gSFn)Fb)A*c*D_3Z?AT}b5B!%Kf+!3X9` z97Cj$m+ET73yGdnTuc0%+c4*fDkD^7d zO><=7G_CRjz|7sJFIx7AU!)OCuJl>t+{ptpH6m%^eC?8<9haVvTru?G8XL-*TXrRo zLqFTeLhX?=OAXpK$2om?{VUx&a8rg)Klv^NV%9TIe@Fr(i$O|ozUR0Zl8KYbDOXDT zdWI|Hr6{eJX#FtFS^6{W*p#VxTGBi`8@6(x z^TgHnlyVF(X~jg*D_JCrd9_HF^GQedMQy97N7^<-vz$Re4Zash;BU_V`a3y3^f+n$ z%YcY2@kjY2fEL#m>RZv~cIuX5*jG4)OOp3ACRt0l9>qm4o>B`PM!0;JUqSbpbE4n< z=8to`AYj)qk*V@~;tKMaBPbpL%2V)LRmb_0pzrji$|dRMO&4r)(eFP{>A@&m3`bn& z@zm>(gqF#pOc%p`kW_MNZqy-Sx*x6gye#FWjr2)KTfY6U26ZXC=@~OaQB+LOOw^(^ zFUvH#*v=}9_nT@;Ahpvjb~)Os(9$=A*<_BZ~~d)Egx| z*h`<{r~{E^<3vzT9HrcYPWnhc-;AqI2N&0yCdDR8K|&-H5JnvJgU{P+3&LujWv9$_ z18iHLB){9BK@N7Iz_ZEuzg22OC)>spW7nw4xGp}q{K}EsTrhOU*G z0zD*KzhSFwniV`gOCPFMh=MuAj3*(E-QYSFO(y-W-`JyOHq!?-!UQpe&)8?qVaX|C z5UEM)YKj@$N1+Cfc$gUP7Wrm4|Glc?df=OtO0w{XXrsc4SWIJF=2zJ^JZe;`?L zRgbQ-@@~7YL}F|70k8eujDMNm8~7X{R7$cULm%e~i8AIP{>E%#kokmXL*<1@aBZjU z2YZ>ouaW$#vdyuF@Udz%y5~K2OQw&#Xw6#)V|=ce`HC&-hQZdymF&z>D*07S2@q%P zV}~VbT_2`;LJ9we?k9Mjy2Iw8ANb5}f?%4~S?W#a{k~`xNbY@bpMV4r%BaAEPg2DH z`s14v@&EpW?R17*8B1;(i#^m*1n4A-FpiMp?xDwCBMkb&{Fn9*8R|deUUJ+m^w>*; zK_3YD-IX!aLoI|5EW-GIoba~^kmmJW8Jj%RvIXd5i!lBq$2~xgz4`wnME&;;iicW^ z0G((N#sPBN9rV~MNOK{g#IKAY1cCsacoD`Sa@<`AA!^X4f2Y&*%9!o{C*d0M49T6& zqAO#yhg!M-opce#F>>5}$cX)K6Hqe)l43V{MIa$xzm2|z`N=vr`?E~-by2sh3TIir zVfwJU=cHx!4736>53_&Yv4k-vT+Bfi?vxIKgjt^Py}lsf+oh;IWto1Be-7lw<1UpU z-!p_Kf83a-8Q4e}xnt=U#Sh90LssDMt6*y^K7P?cvc(pCF#18;c}tHps| zWrh;EXX%D({Wc8?rfjAQ%1e>Y6SUD1jbClh5R9y9j3pc>&4c%IJgP>$A%(jiH+f3o zLof%(3!{X!-8qY$`r5yf!G2hp8Pe@Wol(xF65FI}Yr7{x&?WFpb4pI@H0S=-0JjvM zM@pEcpDS466y42iv&oGOpxD5B4xVLI(xQI*-dbkTK*)=U1WvM>03(grQS&iDz;o?C zP-@-I828DmnvOj3;7CbKL5~VVrt%szRbIWy^<(xyq`RNWIwesv!-7w7>DC--isCPGC4H)_dX6P-#%JF<-~{s~*MfMr)q8TV zTwCaQto7T@KN1?Lg#7rp5ehxW?3!iuk*7@0yzMfdwf#LygEuBSdxHMYp(l*h4Q8sL z=QRNbJ5F@WKTr{~f`OoAuP@uKtiyD}O1HHlOxC5J!0l@i2rWin4Ak^XGn##DM@HHo z?{a(Gl+I?e869A9Q}SDQ^;eHm2ud1`R+saBW;JoCQ^G$`XzKD|`_xEZkbICeyscn( z+2Czg8IAygn>^6)Wo7tvpj1CS%T8~-+r~&*ci9r|F9lO4pB(gCZgVqGa_olEe38*E z%@o6KhGHHIO>O*s?H-uts+()kVF}(HS8&;n`xP%MxZ&bZ##pGlI8JPw6>D|`9Ec{H znG8dTcVR(W+PBwAwe^R3RmNNHUqUY=&Nb%QcwBA(4SPMdpL2F7Sk}mR$x!Ft0i=MM zXyXT{wGw6x4Ft2>&}U&Gyp>4%?pNyzd4f=BzNWnEs}fMm)akVs0tcmpde&jpqMW+s zCj3j?M~x1}&*mW=2e-Tom>rn(E%$yP!HEGn;qrnLWETQ<+wAT9E4y5wxKP-{rg0tO z+KVIj4_3!LwxFN{R&oNPfmJUXo6abtMg_ZPBkj+f+wdP_{PBs8R({68cfCk`nq4%+zYYjUJD9OPJwn$H^DaIAQb=bB_J8;E z2kOT$Y0|$+qW<@ksh7y|uMSc8+r;6&T4QS?XZ5UL9CYcdboP775yAlUdbV!< z^+G%cnFOm|L8!<1-OFcxZaT0W1F% zASjZPQib03swQZrcKQU|9R)TfBp}vt#iYjJM;X!8xoyo~+wJUp&fG|9a_wZ0Z@*25 zIsU7bSkj9!%dqjvU>iRvNg55C&thZysi!7e04GY{{$!9bnk{Z=evR50{gs)|Ntz^I@m)F%& zNO{}*+k4yPJGx;tv8>$oD%NgZX~e7o;khd2oZ{hJXXEyt6O0vn`9eKCg@WHKe$o0^ zpDT-?VT57S&ssZv!@v*qD)vJpp?AZDgfJWntynQj=S)tbfjDdQSWpDLrU2PyWjbt5 ztWOEEHTao4%2Y!9v+ct_IiC9#s==Y>+kJ!V^`Gy=rHJPcZ&nZ1wQr5(=tsUTf^Z0z z>MzL4&Ny(USH$_3cO+|zkZ2g+XH&uuH@jBWGX6^US8$0v8Me4dbd`DXh#xB8x^o)G z8~@Qy%-rx59!hxU)lp9Zo^<*TRAOKDgs;J^61P-`gKRw<$9rp$pI*+*??ZH!e}AkZ z4t_6jtCU;EXL?^Q`ZP*kY0Ye)Koq;KTfLw#pd1$U*_gB z@cSKYnk4*2`8h}^4YC3Hh270nHJsN~^jmS^Jl-{jIvjhbGao#>ZE14Z0Gi=OiVf=$ z6b=0S=?Boae;M^Y!KSP-QMyBdc!dyJr<`on54^w_zav|iFeqKAje6GAG6x^~2kM*J zb8WwI`sEMSA;arLEklcBr{H@Tel2(_i%r&}&XMA-Se7Hl3z)A(CWIFj~ ztu&_-Z_aezK|h)Nf$9VVA0GfT$eXglVa`}>W@C{pAfw}_ffGmJ2>N1^CSS`KROh2- zaF=t4+sehnnIOXR4Q4iVPK+pHgRJcpfq2INCgscXY zDPUo{;qRn%OC&A&T%%)C0ku`>gjfP#BgQ>(-7XQXZ?-JsOCv2Wxs`&KH@X>G#*qBs zm#jG??PhvwySfa^Vpw{ybAbRq+;n31Db$S4jI4nq&`14wu3;)cZM7U5Mmq28<0LzS z7mq;)dYmSQvb$~S47+IaG~o-C$?ad_v(<5)9$%#Ki4_hrAE{^yctp)FH+r7zaT0BM zfQU7WQDsfQuS)s}>3+#G*_EYq*5u%$e28LDnW~7y8KlzCd4>y1L+eq&X7|&OfJ|U< zoe8Cx*f{M$RiL933U?fs`IWY`m;p@Nox-KPT%?%J`6?2#^laVu>p2z~mpD*=5VuD0 zL{rm{f#k{Qj#I^^BDFp??a2rmq9V$z*Vwe4ta3F@CAkGY-Px8**W9s7{HiRODUK_z z=#Hq>fb4Pp>KH+hEj7)6SulF3re8u6{_U=`vXW+Occbgu``Cp-NDNG6WxU#`==8tL zxwKZ%_R>|M(Kf|I!WB`2#?YN`zV9z_4@FmQzMlE~ftr^fDIzzowDo#|Z_4|0RG9~! zK;!R?@}c1+>>#@T5< z*Q#Tgr+NTZ{_RHb9oPA7c9&{VEU7S6U{DN1bIyUz?szLwZMrM~4CHcMaMHLna0dGB zaOT`!b>_$tx|CKx>N^#+X_ zD{ryl8hI)KEPnh?lYiwyZa7{3j>`nrJZ`U-SBJEjOPf{yQ`7C>sY0rKgg(ewNmE1F z01Oyp9A5Z4GQR{xvPU$+JK{eV(9zgNl1{3A5ld+lUV2^ZI^cCEP3fo<9T#6gN1EBN ze>q2sb$|Do&TxsX5&|Z7`SPV7LC?TIF-YPv!SN*y0p(WxM5GFFC8{044+(Fv9pV12 zxW5rQRDPxk0ft0_hEMgfO*#CkQ@qEREE4Sle~R!_X`v2Ig-YSIynyJmqoTSUzhw=XkJJ4wNw7Z}a+~Y5HQ?yY zQ2I^dBvT@1o3Td{-q(DOyf7#qm&!;gXq3n5U8iOh1GE}lz`}s@20uh<5yw^AGMBq( zDZAvX!eBQ~3!2?ZI~ATtM~-(@F*cIB=u?#batvz``X(t60*;)430z}fscZDeMk>3D z?z6kjtr)8}>BvmP1kyg1Q&3RYa4?UBbjS}vUkd}PHz>SQ%&z#Em5xdiV8xWv=*6x$ z5@w-qQRfWIbD9-Zj+Glje~Cjf$ui8+pbiq925cJHRDBT38*vJ}g%M@~U;=tp^;4~eQvG8;Pip!xQ_<0ii` z<^%4k%P(y|c{@c!N9!oh+V*+2W@I9ifjmVib+~@l7RTo8eCAj)8%dW8;iH0ejCH1h z5bm!YvEI-f>bA20i9S-(w7^LoWn%^WTpT1GvAKAQToj|pS$WPHWgm4FivzETZ6Jez zB+d!c-q=Nv6ScV|ib+QA%#63*S3AAmV*TO`s?l7)$n?BrG7l!EjIwykBA#`wLMF`S z0XgNAs01U8K~P&ehRcd+?u=eYm?thub;Mq#_jc}Pf_~&wazi_|3T-ddg6_n+)4 zg=k9Ohr-#ZW%HFVd930Uo~x&t7{hycP|qD^7ov&kQM{p_d!~nqb5jiFGeNpQJF6BA zX?-9d8+fK)K1X<)-z3^+=k=rv>t{VLC#q8nF>mUAJ-O5aoT>#Jcbn7jJ>SOR@} z4XjY?0~Q7vHU}qY3MBZ&Wb3pFuMgb?%(au{Z0nZlt6lQ6Fvrfvp97ClS8tTmqu+(I^Cen0Ls>l{zP+0Xhabr-rJxAn_TbbWk+}y!b6f_OJwL+0lN) zndkcQ`4{cb-n#Uixl-PV*7iNL3G_}5LOceqRebM_DM`N(|8%R0NgdEf&7AX8{F&y? zDf0FNCW-b=W51C1*`RV8#=DD{b9e8sW&vEgUtnXgSI*SfQ-%)no2A@*tR&FpG(;ew;t z_oc1Qm;%Ej3#55Y+n|hh{N$EwL$qyFfuYWAeZYg@QM|~(5`t^})y^n0K_ww~jehw9 z_g6SLWt@TtWk~p>q1{GKjU9cpruwm6ddX}c@gFFpx0o4-mAm8>*ipVfzV+!9o}QcD zUhWnU+hsm$w=dJ3c3N8s@#zNDNP)BYIMO`Cy zAqT5z4JJz@FZd*3o|$(>Y&+PC%2p#9aV_^s8_P^Pwlpi)M19_#aR-HFF76JRP>YUh zj@z9;P;kmv)QdZNfU+aB_A>3v7-B~aA2L#w)=xna$C#q`26TO#@be%Qe41Q`m0u%{ z06eCcb<6wc;|seF*^&7E_>V)6*}Y4AMhNUJ`1J~y6(YAtD+3)?)SHHeog*-g2}gUx zDnC~_#Z4P%NF7D4e4N!XQ}Z+>^J`&G)ne6H;e!NHxVATe{6Bw6NpcbtrT_`N`FpT& zm~e_%cCl{iTNJ>E8ct51+gClZX@4TLnyluv;JTL({OS<*2Za~*SO9E*}&ogVY4Y^2BJWT@bM4DZV(xA<7(%eI?S z0m@ia5ii@d@};B>n{sgZ_3#r4V!bAlD4pU138ZVww8{$g zo5C@>j$EFFZqq+5h7D9`=M+&e=zIo-R*`thh|}7sS2AhG*F4j0n^+Oa;z(CEW87%L z*Fw4ZbOvH-`BF-*w6vsIKuml}zoCUyI`Jw@hv~qtMDO`r^Q}of%Et~ZrFYLAs?<9l zuY#q!42AUpfMH-D_ADdL{BaGqiJM(hQ?Fzp5WXqU_}};A%D9G5&f7Qeg}0>Mvi)2& zK9j6u4@-KKoMxgVs9-EKA9u;XiD|`^uS$`JOhX1Nsx@AMG%>BTwo#`b^D7W8Ct;oc zQ#f90q|*~j zx|>|c;Yy!_)E1|BUY7O!8skh;FNtbWhb?eygON&ZSB>_FoolMPPY{C|rP?-99@8-c z2?KgMlq+rzX7hC#UNU}6jC+CeMU{X--`V+Kuu#w{3g>m_kff5GG~#J!!l~-AZrA`%|Y}E97HY zhSs;^@8Qmt1+YRZALD|pVfE!lZK$u4VE~XDP2YbS1?_N0G|@% zg5z~{R}my!6{t-E3`_VHUg&7l-wC`U;jnMcEr6r5<05?`wy3fB@eEh`CDQO1c1fN` z&X5OW#!NJaF)vHyW-GwF?8dfoZ!pZQF9o;n>Zsc)pys-Ow_AR(rHjX$I*^ywh zggMq6ew&AedoY!?O#d*ho%N`P%3e}xd3Jf1-DXu`=I2Zs=;bX_YbHr{!C8MsU0oAm z{BoD!ij;{|ImZ^1dcosbIdDfh3P|8oA4hXE3 z7Rjn4a?~xm?I}7AyYu_IWkQ=e!N-{s?2ZjZ7OOxnHjHGSvewt6O;J01s7zDabVoZh zuYZFZvGtDpxcP{0ns?1{{boma?J5_~WhAM1JpkE*9dZ1D+E{$+=G3dOv!1?<>B8bl zQFgr@DK}((ER`n?q52Rx_ZaWUdWj z?@rB_CB{%)FR|yeQ7P37#UpO)YzNoE!STxZ-VQdjVExXcxChepqMWJc13De;5Mu(D zoYU^RQ{&6daxrbXfSz3y1SasLF|Idq1L^V}dYi~W{xyoY*Jyhmmnj3zDsr{WGRO$0HNaliK4ixbSW?xi4g z^XQ4+N&n1>3iSZt;M9zGbI5P}p2Im1?^`1|77PKTyYz>m=2mBAas$*{6axm2#kj-8 zTuD4T6Goa>D0&k%Jj(GuFW_zZE|-2vFog!d$PzR0c&pXN4CUc@{~Brrvi<0o{@~is z9Lf2^5p|~q@CT|4d5UF%qHxoT`hRhk_@zC zZ}=gI>wnsW`_8WLoY0oDke%arJjVqh^QY*Z`(Tcd@w05;byqtWSHLl2Ph0`osJH+O? zdvw=*ogfS3dO|*)NQ;H|{om>jHk!(J9BZbu)IqEFc70yA*yrn; z(aZ`sTkKP!#VgaDbz8<5F4xV<#Tx(fxT0XQ-VF{fSZ80YB+FQ57Q)dM`w9tM3DFYT z?g(y3M9HjvCm1|CYRCJeq|sgf;_elC3kJ_<9t%u|{CDO95xzsIyw5+T*tBp)L0gZP z%J6T{>?NftG%ZY|@hBplW{+o78CO}`NM{&R&xr>0d%lP5r7UaW@oYjwFg3Pkro5ov zMN3k!&&@7DZH_ABHJtN#{!^i_9Mnid^^nLBfBq@n_UI?`Y~mxjWz~$)Z|>yP$rYXKY+3q4 zZPm+1K}Nk)1VP271V{ftjt}))VuI$GX?)rv_MQ13tr^;7p!T3V=%`;&rfd@pj*>~k zpu+b#`4iF^3Dpmi1vW04qz7$1i;AB}XlLlFzGrn=UU>4C@owTCFkh=Gq=1FQIs1j_ z*?7vWg`9X=%FHo{lcP6hvrWTAc4S7BPkCL*%uGqj^9{(iuf5b9TlZNxpURvFNQ|kB zUTLq?JZ8&d{TwUz$W6^Y@SJAn&N250Ilu0HKcNJfM}>dNN@g9Sa|sU`jzseYz9E6!-YFp+A7Vj({=Rmi2WqD z22ywE??&bH!;357!4j?YvS%!c!bilJM}ys9SRKLJ$B~DpqP}kfiZQjuvJm+@S2t~& zhko;KE6MjTYQVIPJTU`d_M^5I_YXC>6Biv%i zRn9gRXU%lUOvzXISc2Y8yHxvHZAM9#iq2d1bys+uCUEt^9sy%x zGz-kf7!w=|j;E1;iOSor^2H_d17MBSyLMjlzn+TYK5HnLrW{}R_2%lDzRw@3z4ICA zcNQb~W5?(A3iR@Cx@+CvTJPgDThAzb%>^e(^o*JN#bUq%#bJk=N$qxIdmi@emdMVY7E6R zCvLj%a}7-8gZ`+Ghgo_z)!hh$M2+VBLbx zs-Db1>eAAOU?!Wi)Q`>!0Zmp-C4urvGXZ`R%Bn@UoQirAs+YO*Rs3I% z{*~)0?x$CIn{H=k$12%epQQ6(%VicwQ}dQnSy@d!EAY>NwBCIQcGl$Pn)xE%1N;)A ztY5EP6zjCoQt}i?4DrQ9S+9k;0;DCC#mtfnwe5sWi<>He^8h;~4K`et#i#s#cy7mI zZJm72UgG+4JL8}26%Ykx8Ax8!p^02drTL0uoplE})wy{pmo<;Mhw5V?XHhTI5Jjv0 znVDZS4+BG0IQn|Wt{L{6Oa}KrlubDC`mS=&gi!{gNNw;Y9BK*Q&ih>WJeA`$pz-U@ zdoS{$YZ^rx%yT{pxci!S!L%Q!>v_oBrap%oBsi&;n1#;uB?=6R@wCHdBI)QEq9$_5 zLDLZAL}{kY{mLs+{?-sxrR-b@NK&#YuG@z5X9GzDz`I*g^ z7~h48HvPNs!uM4r>+5z-!g3<-abylc80 zkX!`ePnHY+a1GRP{SM;g2W37U9?Ae8Q~CNoap-xp%uL}pFe&#A`1@a zga)C*3j~C$A34tJ1`VVhSYCc)SN1|B=wWf}yFgfWBX|w1tqaQLjO8O8n0xx=xQ}je z@{vl)i+}P_gtzC>1crSwy2j};}}C1glBW!<`p(4}CKQh7`^mNDG5^n8J-`;v*vOy_9h zWrW}(Bx-r}>F4dc^f<{V)W*n)PsTdG>&HrAJ`w4RdL&*I7wx{&cl##t_1m+bzYz5_ zJ6SZJ@vj)vtvmi-F>{al*iwLbP&dGnys?+T@;s>U^{&l#>gU{V6)7%=(amfO^HM{l z(d=MB?mjKrA|pA^2(i|EgH?+mM@#pS68kP&Lzdc+wzso3AJuSS?6Z8l)1?C{x*;Xf z{920$EV)pXMY{%y`#7aKvqqB6vJ}GN$a6k_*%w>DI;X#X?foh2^2INk+H~6T{!7mp zP3~#mSMTehDr0oD*YP)TKYeRcR_#=XLIH)+Teik6P;sZB^a@ zRe^t?-0H0!X00;|j*g#saDouUjc}D_=gE0o{=p2eQQ zxehva9xxvM^|6unS5LoV+x+MKEa>nP7jl)Q1o4rtm(|Fd zzJY8?vWt&yj=#H91E5QV@ek=0yx#|WtshB>m}q>&eHdwH9T3e93Mm@&eemg$>>U-& z@W607=PESg9DVXeR90uz65V07tPD|!`wqg_5v!DEvJ@o$cA><*)elT0X7G6BeOgAr zf#gPcfMU3bKMTMF2B>Lu(x}IAZtnkw6Cu}>$pIPD8}Em5W)l7)QjG|7W=sl zp&4#bC`lcgkjaL>X++se?Dc*^rx9^QDb#eJdQvKAckvLCF@j@Mwsi}Jugbf5RqPGglC$+=|`0fUo9ofp$tUZ|U-lEKP{TjTpsmtRNK_H}6r4}za|i#`~c z=o~$c!(t=uWioI>5B;>uT!LADCeSHePx~zKvZF%_!ulqBe(lBzv&(ADe^^J{8sS;6)PyHD3Ny=@%kQN^;V3*_8ZKtXzd*P6D!zwAZMEJ8ihvD z&4Z?^eBn^koIT_7Cs(vIlqJyx7HE+=^OJ|m+!}gm8O$L;$dXhYc^~@&3To2LS1tF@9HOS9=o%L&5Kod0kp3HGL;TlY_ms5*#(Dj5z|pPegt z>dr};2@1x;9T04INWSQXBltWBJjtgftELXYI>(yaoS$@{p)L%>9QdJx))$BzSZ|10 z*`n{alaP}F5=-3j6_ukA)v|*V%Y^Pmz*S7g>c9g&eW4x*GpK^rhzZ~?nYB|ZT4`l+ z3gZO}M;EYF^M4*=5;vv^thbjU0q>8`QOE4_H9m)CH#aDUm!&pz5p= zt&{<`wgqURutz1qf$SxcAj7l`ifguWSLR$Q081ls%)1j@oeY=7h!%{dH29);9+ z$vt;ZL`yNsa&5#Aajra%rLuZmhtne##jpu!3I%vAaU!x0@AS%R z`LJ!(jE4e92vTpUMu-zx@;Kw*ynE50px}f1^W0jLF1WC@jEk@+pv~p1{ zps2f}HInhIZk)?fy0mN^yN7yR2z1w7O1fpf@hVH@d}us_B~xjCSM4h;-%?i=4^-4##Rb7i!P#4FPi)16Q-Wt%p9ft%iup_C$aM>n(Iwrp)u0ZU!ITsl zlu6@digmlICfY=ErDU)1(|~7~zDcxVc^GnHwb(Iyu>30ON4cIDj6k9RJZRe95S5PM zcLO%v@T>bTXsjNh+bDA zy6y*_|Es;XjHx4f`$aeI?(R|?in~kMxYLchyKmf`BE`MMix$|pd$DfZ-QA(k9{%q+ zCns<2&G~k}-Q-EuT9a9m$;xES%=7%@t8-1Gr1O^$g~h8OD&ykJa1l<5#^{|(`7nNj zST4hmkR@i`h^$tI2QHlNboCxntXh&>zjGq=T@jRnWT7cJ&{nFtM0Nt(q}<)U*YpT{ z`B*6XK4Ld2t?g+LHyrpK~vHFmZ+L8ObU6CVGG#)!BKI{nSi17g@spoN8SHS_ISvOgKBJHd5d#D2-+r zU>a(u6Q~)S=lg=G@oXr`vP;g)pW9AB|26-kQ-PDg3ehm$0J0>?fq`n2$R_BxYL-N! z!4F!%qv2lGSSoqj^)UT3wM00aW*Coz2K@&@7dj`PvIw#d?H298<2hGj}%v=ZnMAS`d>7* zR3)}XyYd3R!z97o_bBk&jv_Yu-?4*C9rnKh0C?~GPoogdOtg%62{FBsc0(MfyCn2m-i2{}FCT?{ z;4(35DP6w$bsHQ!+vM&S{9n4&Kb8j*f-{2GY;yiqktb(`@-a?~{W1As0a{YG=j1+r z>4ImXMn%xZJfVV2uYS>_?QDc2z8uCrWkA4}o)VI%Z$2NXKZ7U_6TkJ9-?QGk7k%G= zG3%1J&gQOTf)I?>)vK+kFkPsK?z&dIr zLBMrvz%HXm!3=lvs8~f9Z2~{)I8!<@@6>M=MLK%}*@pF%*i76A&;&Mo98FH_Qc2SR z@@BK}iSLOmoFMiIGi!AoRKwqhl4)q!WDE4$@a(&MtPF67C0H`KA%OZ$tG;Fo{9|*> zY#Qw<Y3p!BUMK7_y&DLO3aG@@uYSHIj+?uwwfVs ztz^__Imn?7-t2xkqYUr@M>)OrP?QO$7W`VLk{oZ#4@B7B(uOpOw~09w)j<6|`rPXf zj1|M5XPh(y@OK`MewdPXI}VStIxqqS$g)Z6-@=!a=|6gwmBG{1%|TFE6Vh>sVJe~?Gro2zhpc<5 zPH^wT7t;Xb5S)xKOuu?SOFq`P;pNdhe}_SF42QKvbG5u-XBm!!jjDTv3-Kw6Dr${y;(>Z`gorO^RS~*HJ)V7BwL5=UkX%J3QCafFo}cEz({si6Gf z?V2zp%mzEdCOz-6`9`$axXef>Lq&uH1fm^PBU6SQ(=x!BDxr4l~(THb^FN9 zka|07siPoXuW5s^D!2Ta+)cN#N6_`lTjuJ+3q|g!lUGVwrUY(0?`pNX>sDK(4S)fy zvf6j5;!i3ms}qh7H*8`94o}C-_Ap^+9+%@9Yz8L~>iAKgP>RBkr6)`?lPA!@(ejX?xAdO z?5s=G@vqyknn+}+Z$%pTm7T~Y5lZM9E4GMx3&^C7X+*vr#U~&t@NL$Rh4+B<+f;uhgDBh+-v|{*Ts|t9Dh2f)Rha&vBP@J`_ zy>Vi(;U565&Q;@ctt`O0Ud}pFy+}v8as+6wSfIK#B7+(MaYGjsnWhyx6wKBnGRB43 zLSOiWm-T@iW?4sLc3AnS9T2BzmfvBaNRaide;eRbg@=~H&X(EdeV9;Dg3GvC#VVBv zsHl(CNg`3V|HTMcl)jJh^ngCu@ArmR{sV-e3;xyV@(N4x?IziIvWed=;EejecO%A; zlK%n9RY4w60udv(+0VaT4}v@-gbMSfr)&;C{{IL5-`7LHEA$^=UjerwL$-=RizQoo zs@BV+Iv;ehFR2q6*HE4U&Urcfl>hLmw<%Gl^~Yw7^>0F*_|2cTjl1~AsgV-37H^{B zz`WP&m!@N`zdJS#e*})EFOeBMX}U8DU2fMwSNv~W$b~@M>QsIEKAl-n)7vp4U-js= zaPDoSHB#5MNEwRW`X&pc%w{}(>l5LWPZjd652N&F-A8dx-0k0;+z2QY;PR2*iBtNb zKuZCXKvoWd{NiLcoHwFRAL6cAMDktAuby1HP_g}$nx3)9bu$oR=;jBa+SocxmJHz%MC4%(+mK-Dw z*pl*fytqDdYaAq`oC6-H(**K^_NjkcI1}b$0ZD_;VQ~!I{b5>H#ZgxRC<3~dM8VJ? zj6kk;eb|s8*miDY{9}c_LNkF&F4f$5?w0g-Cx9AZnk$gS)%@F@NN~UlWQOAbY5R>l zRtSN7@A>9+MXW3ktG3Gz3_2EPX*mDuRb4poXtNh!MouwaLIcO+0@{&{yM8;MZ1T{@ z#!xDDzT*9o_bIy9iKZqI#+(QJjsA^{{Gt2LVv%+q(QlqLBF)?Rx#67;L3228+Iyw0 zY1}ps+9pRVLOO|C5OM`o1wpG=HoJY=gbz|odTj8dmbmBnN1i~;^L+B1B+Df+4AAfJ6Y;yYJ8nf*w`+8Y3j0OQ!4h$N6k1tag*YACWE zoAYp2c`cPSQHv6g5TiRP53;F{1XzKDACS46q{;BT$sJ14un zHf4q|pZ&_6EN0(@^x80pOj|$q#!-DDfwf~DuYJnDkjc?hOt9g49B}7?0!s#qT+0j_ z2+=cO#vjZtOk01awM4DbA$``o#A39K4cC*EF${3^4?au9Z?E;tYzD(Ux(qYU|6;i} z+6mP~(&I!H!w~l!{9-J=TUVwCJ}D%g>GU^MK?vBh+jEE6MdCH;+{YMN{XD8ykUN%x zncOf;=q>gBuXvuQ@mhEPVq4w@&VM7{dIkKUEbHPL%_`CO2N0Z}-v85dBUZlwlV`6^ z9U)4WvHnez1)g~0ev^W=zs8^u=}Xj~*!Y7qweRJw;}wlpLrA!NX^J%lb1pzB61;La zWrSw*KohKr?R&6zcDh*1{VSGWZ0gZ#2jCJMZmq#3;Nqp%sEnjX#qblk2p7G*{=kZ1 z4pA{p^~9ScO6kc^EoPiocpEA|WnEd(ui}+P28>lz@GD4nb}5)J9`gOz-H3NOl_e8eDgncZIn>RO*FrW1fE?Qgm}NGslk?kowvLU%cN* z1#f{3Wq+ryPeYqmzf6V?H=K|O@@yudZwZR-7&>h7Tl4_u&o>!wr@@@8yU2%H!=w^& z{hx0)g|07SaJwZ%y||0*=AcJ^6XHJVo#s<9Ehb1#CMi^|-2~^J9A-a$_*50>5s>%O zw5kTq!L83crp%Ccku6~GNF?UmcBQuApkXR+fOXz`X9FEKXjEg{8lDj+WlM_EnRA@# zidw^hKPY>})Fdw4bn7~QmwnO-ez(NN->-?Sq@}ag$NJOG3O^^@oqe*T(R?zyJJ^8b zhU?neByQ%zq?{-tKi&-+E2ZL|;OtvVL21LD#~`hCFTJO9wk}MAxhNAk_8XgYHJyFp zMwdR9e~5imN^v!>1%;+009HlHqOH?}Sk4dsXS$#u&mcVQ@0<-i!HqK`Qy8Om;r)B` zoPBNMpBre&l?kC$hGz;s0>P8gFyEED+ss&If+WJsa*3I|;CcjVId^e#QyBa!J2QpB zC`!$$_Ro`lu~KB3bE1haFZdbKbr&oJy$QyD@_J_s>?F(ifM1+FrG zKdP>I*QPdYlkC4-o#=ojIbMwV=(XR24_T5iF~3vBpKg-pJXq0xj$d^eu?X0O^}hY+ zAP!RZIZn^`SV?6ABki_Hr22gqv2+C7TKrK*<&@QH7k61$(9U>iY`To+TRRIS)p0MP zaX_-=ad-mux3qXbe^rhkNmRG-79O`Z)6Bk7@iYL`M=8KZA zVNzsE&Skf9Iob`ka0_9lL~yhfqYH>zrNVBqaaOt(3b)^}NuoLC3Yzh|K+=dF$q6 zgRVw(uT@UlKU*^$3uKBWLjJOa#Pq6PP1l*4;yB8hV$Mdi?g{PR}MH9Oa z&*yg&!?cQEx)XY71+82EcjQMox*)abNpv0NQ%Q?X2gpJ#0i{O&HtE`vGV2hrV{4u+ z)~6pb@6xS#S#aQJ+*-z12Q+#nH*S9zN!B%O|CT2xAc+Y%U(Wx29U>O^i@nn{_GI#4 zQZW28ULHXdy?Aigw>;8g+DgXdrQIVCRU8TSIX`9W!Zjyj9J zzFeH`4eJ&3ZBq)-ee%T?N1J~D?gsJ>m8>6oEz=38)s)%xIah6U<$3Z2kTK{kmDr9K z{A7F`nAk~hmrrO6GzB?UAKv$fpepcCC=_a05A+?p7S$Q*&MMh7ve0QrmOQa^7uoYq zB0&r<@A_L1c-X?yL zuWUk`0+Vb*Kzf_pm59(Vv@1$_9mC(9-PY}Vlj)!5Z}qUKF+R6hi>^-D<+{(;>8G%N z`lal01Q;Div88tzM$tSoR$ZCwvFwhHMK>b#w?}1z`AH}s_pdAit{m+P+Tv1O3tTF!p(;3!+CIa8*}eUsxi)VHwQ4^tvrwt~B#IfcLM=oEjK zct%d#T30LH*;U5qw>Id(c-cqzSLp1Sk1>%>3_;!qMAF|bBh12K*0Xzl9;uJ z^JSdouD?@w?RY5}nBMLW)cHJhm6rbZHqGBBjQD;7w5VDRyt>OOSEc-@z~WBgY3#~) zNx{YV%op$YbRIfa=0@55>rLWx&rfXhkHn~EEP=A6NEf;{eumFylZ+v-oj_CJDLFg; zHsSi)Rizpb^Rt5j@o^uc<1AljH+U!V#b-!MW^#}`@Oc<_c2Zf@A95n*cSxpmVdiul zt-djklP6Q_O?w+QFL;{9WFk~_yNc;iCVez{lqECOd2sOa5yDq~9CNox%;$$$_!!cD zI@RDAc^v*}gRK{Jfi*92!}S%YVs9=yrRHAn1fPMg+A}H~d!^&AAzl}K9Hg17RakvD z#q%)k(LE)0Q})3)@OA;%sN;1V%gc$VeV?1enx0vPJ;kYj`?Fsu(4DNs!FQeNl<=hs z2r7+%UlPDTnRb50TnN}nP4L}t+!PZr4P7or^L#OF=}~3WUN=sv_xsQ_AWRM+XBT1= zXid0jQ=BJW%zAQRg>5GGLQ(T&biCmefu|Wq=Jk ztulqg6s?yS*yKq_`yv3C#pC}JXGwS!q2P4mC2!!XhA^Ag5ENgAO@*twr1^*b_6Mibdt zJ;YBovR>&v^X4~F5E2mk82o2?I>8&-*7wD?8!{*AH+t`~NwNn9;=zr8;UK$t6$uWD zIW^ks1qYp*XdzzvvW1{yKCd3n zNVt4nGKWY*eU{-8PZ;%}6LTs`t|)A7Dx^aQBB^t7ninush?FgaO;=G4LfoIj7yBy1a}J)KlKV2*MB-lt{^roT&!YjsFp z;bt6KI!qo$Ey|bN2;L=+E@^Qx zL@EL?mA0~TnVBxFH^+BD8nEqVi9M#S&xnv|OQq9Qtz1z)rU*N6symjGcyo=}lND7L zIdW<03>d&A$}WOhwH-gX`AwGR?*{gvZhU|S{EPw0jiy*;#xSaH3P!XHdDCh($CB}= z7AP5}c5S%xKacQv&c$7E*y%rP6FSi?qSG&=XvNxKz7a(WCA_#4VBawp+&Sn~?&Fj--@75)cd@m~#IkY^a*=LG(T_z(`5@3|gsX9^ z`&hzeFYdF41y8)Ly-%zls*>|8WR>SZ?7D78@8g_qlE!Ov;!7j38#%$NZKq9ltDDkA ze5D_mNUfW^8+g360O502)vrE7MnCgslIN!7H)ohOg0t)ywziu^F9~au(Yac9l1fC` z2Hd2)SaO_}J;L_!6C#WPxqO^&aANF6|g^VUJ?_P z8t{+6%gGf|=Sh@?zOY|2>a2gNCfRWMZ^2R;Q9Bd(T547$in}EI%rl7bY9aJ9e{c`oD)j_0y9{S|!Nx+qajZM0hfnPUx*z z6}ZIKDzB+M!iVhAl2s*sUlep^=J>9q(!t^3 zrLi^fRhSt~XiVuK3))f9Vj_6kUK8+MiLIVs5VpOxFei7UdEbwR6e(GZWQBUCip_@BKl;>bw>z*#N z+jmYEQOBy>zBp_=UKWNt1g!yzXTJwuZOf+*2Q~$CFxzTkVxukWZeZBEGh*R-)i~lO zA{H(BBjsPR=_Ir4q2T=1w7OO$-71oY6%+IZjq?RXaeyxj zY}U75phA?Qb`_E-7iJ8m_Sx!A~jy_gD#7D{po-}JP#WCsLg0J(%$q|H9L zzN_|U2%o7*2dq-uq6%^|wj}x^=bn6p|i)rD`I)OwcjzYMAose%*yK@-26B7v*@g6fib; z>+#yY9E5KE7&{&*<31$K*&bNrk*cTz(;V$TpeqoRF)&U|p{yn?JKY~9u)Y4-+nsoE zQ;058cW`Do-yma5TP3z#1Uo1Q!nI!bkOo6x{`REs;X#7$9PUUv3blyL7lCEPf!wI4 z;50s$pzMjqv8EPYEo#@N;q~3T&Gt)xydEy9%f@b3`LL)i6<7m$ZcVL2G&JU?Frw-a zU;-9&c~?bur|{pQZ~Gzmu`i1O;TX!%;oUd;$#dMRv|F1p|LUY+tN-^VBd$m1eAC;u z<1Vt?W#&ae3Aweu%SBeHZ-f&^P{Yq&!1K!Nv_nuO`&qK zP@_JY!T1i}?~V!2@Sb`)_C_P-=IxP+$s&@_jZ+&d(W$m*f|MyMXXK28$cli=G)}lW zu!fjqcG}AczB`Mk%CX;vXQLj?Gkc3siD*8p)~wHxNZa;)Q5Qi(`2DRTR%$^U-CUAL zfu@2?j`i{2<%n2{x9nG5rlG7%1v0!bM9sE_y-JhD3-jRSAjya}21W;4w5WE49-V)% z0xIL|Y_S+@v4gKc$Av=cE}#xy#BV0voCnr`lQl{$eyKA5DmY|^qvGl?a3Z;eP*M(L zDayhPW2F9V%RFOv^vm?ao@}VMjgZckCOm^o9*Ij98tJGr3x%FR{dQ%XYsi=OVvYvk z72Kk4XuhFBJJZ4eWua&rby-f+Z_=YbR7lU3V|0*8`>AO=Y(ZO4*AO=wNm&K|-Z{?` z3t-f}xBQH~Z%9DxE~H(kx44?-$5hC7IFE#b-1Iyp%p)>fbFM|X*4|>NEG5bnTsU%F zgr8m+VRVCZ+c+ZLT7EtfBV6?g1*LI1x;cW?;WEX8>t15$zg@`tv~fQ@M_caP*9>FJfuWF-VWWxdJX*n7hpTJVMnVhws#=XaXa7wukxPPI z8-Z0lH9~NLni-&2@}+jfukP2u7Z``){m@GS^>K{IUT06c+&dwfSz#uWwSG$!Gi`jS z(beh{GMK_fp$G)2VU}^`ZAU4>7{<{x>@%~2`odrBwYex8c?i1$&pnR-Gr?j3F+Q_-S0(P2jhyiiyCCn^27V#=zC_2rSKAQ;SkgG%zov}RjkTyF$^K8i4zrzn zz0igT6Z(+m+LfvcSr*BWq@l?7mgru=dAbf`8bV4}EjS9{@rWeq7~6TurB9QXVT2zH zw+Rnn1#z@AZ7no&oQd1v79zgkC|k8P?`lS!;Q~6?iWBK%H;fR(P+WkZ^0cJCKswPX zpt6*qh`y@S{4hPazwHML+~wE=BU;l>$mk6NDToBH(Y`>!gbHiNhz~0>3{jB_SoGXk zrCHSKEtnq-Xsl$JX-W~jhIU=;ERHGK572nNUPI(iTTqXNP0It>Q?g_=;6Ua~@PF7W z1&A7KH~7Kn_%Yvm4dvL1JTi}x11g2w@_c7!gUF%o%bhsRHSSsohX@&irllKFx*jTA z3q+_nlShzA0ruS9K=B1^$yk1Sl&H)a5i}`DY|R07^S7{mEKCUU%Jb6qZx({qd`}I8 zvetP&ZEKAd>|-S3ss!GZ%>^2>un1?2VtG`pB^TEt5fxI+|3qvJ{nXgIl}QLA{nNU} zO`(|Bm&2<|O@Jy#aoz4n$ebbVE@}5kXYl)daW8@i5NTh_o*Aj~I*EXq4(FFPf-<8x z3JL_BSN;3acAK$ST$cGtJ754W@)X&MS*j{FAs`R|M#-GeMcjA*vN5$)mVjk z|3{PL*S#fwJi(-JWV%s{KzgnmBI*c@Qqoz9GQ)_pl;ZCTRQ$BFH26QswYu55bMQm( z)IgM>7NoRE;l5?ujSDG5CdlD7mLnd_%2GDMiy&%e0F`g1<@@J-d(@EhUD&eN`qVy44r>5X9ga)UQC+d z-eV>Iu?f#TE)o$czlg;hQ}~N3kE|-49to|(q@b*D02o#S-XTVzu6u;m zvyC_AXZj&RvVe;%B@I-%eu-vpHc9dlfRB6lV=oZ~zQq95k}{5gN|PL+o7#HWPRUn- z6*P>#w`&g3vamprr7+0B1&NVEE z!~!SWDvapcO`qR&vQfc0cdPb@tWfuJgUD?vo{^iwAD(F@g%;j^L>`GtVfd~xImhZL zN6Piv$+7vq*|n{qyi0bq`n2zBzD<)Mp<4 zsmsE6l3f`t=}E1w0*mkImPX#L?2|-Yqe_>E4;c70(PmZk^N?PK!N^MCxm~(fj#iPm zYL`#lGll0Tf<0>*P0k9U%!f*6SmMH3YDF;sIoZOt|4`Q$oRg58+pjqjtBcOpjsGxIwNL$ue_9BRV*RijN>(M$Ycf(WWCrJ zgcGxa>?#97S_F5Nxs-LfeCn+29~c97s?aIecK+z^@p+}*s|SbbJb<4NzYjkK;Y^)s zFRqDP*Bu&E5pW)Rmt#oCaqH>EBh7bRx45wRKW zlFj`o4#}xIgvpFAlF}R*M-s+wh9dm0b4#nL(#FF?dbL@IyE}?mR1RDwd%JEs>j?5GM4oQXgPQTWQrY7ehCe^mBKbX#M z-WP12=AQe#n8{{bhJ6t1Uv2b1L`KLihIKK3)wLmT590f%_;{WeAO!1pn-k8dGl(FW zto7D(O(}5zPYWb%rOwRx=a&aDE)PE!me{^!L<~z+@7xH$|NKkU<6>+vK2wF#Z&XGnkFEwjtVrdQ z6ke)06YwPv*Zh!J9oLz!gEDJ5W+DnBQ9mh>$tze^j-^unXGw}nS;NbBTU*Rx2u7R@ zs{}%@NtNgL+qp?eS%C{sU`M<6%jOZntS(3ho1j4{Zg~|y-nHG|KX$zMr}^C^;$Iyd zJUN}Hq>nEs(f&>Kji(8wpoGIhz-(Pn zW15~)g|vKAMqyY_-Mp}sf5)l9kc#L=7Bj-$7YMHinZNmG1?QO6B=j(ds;cAjjw9nh z_8~(p;6Xb|DgmSIl=*9T-@Rcc$tjUdbGRRwzs+0O{E#J6|TUL*hk2MLB;`S>!FN zEROboblNnpPRkLA^vW)e)hfWke8GiqTuFt#w+hDRO2hwWz0N;K8_r3ioZ-wrU-R`Rb zi@ql$aD3-eH0|)G$y1=;4~N9$11-WQHiCFWs@YWwqQr=o2B`$_=OMhW7IG)2xvrF% zwK^OfR`9IdS#yMwrugEqdOaA+5cHC2H)Z z+73y)YR(NJ*d#GS3wTDV%c0K*$OY?$_Y$RdM}rTnJ>`_kURD=k-0fm+XwBC=edrop z8(E)jfHn#gZq3bC=J~CO3ZB=A{{ULFCCRlM{7iXLpHFjejmPqlTto&@FS% zcRBI1+sPnJI^g{d-(x6}fboj|!RcET!ox7_2q=sG)5hENC<&aOnDgD>>TntF?`Jnz z@#+`RPvxN!zmR2D^XdK|poQ{1^u+>H!;B9wbU}2pWRFcMmsEMGl?2qx$uL3#2Jm~0 zh^xhBo*dk(xC6Z`CO{*9gINRkEn^G80X=Jl6pq+-+~7!DKA4N#g4cjuG({}8K@q+4 z4)NAQLI;aQq9*DK@In73$zqo`*F8yCUf993E>lE)lZ@XR^0h#OkIx3j34Sp=fTWcW;T;u0Gn@t^qeIPqAMg zuIRm6nnJgy5pgN)`GKeS1$kJw>Z#N%*N}7M#eGolFB+}dqE0(*KRjv6e}EeeQw=uh zc0aew-&AusH(u5f=G1W~5U)VrA$Xrk_~YN>84JBD!d``eJ5cD{QVoQa9y4U@`K&7 zTU(+e9?c`mk?%(b-#yz(>~3@O4}o~*r^Ev2k_9R|L{WDjV>L_$R3sG}#4hmputCVW z*KtN^rpD=Y$Z2=(fc%SF_?p!Rn*^i2^(oA3?6dnR`bml^G4{If159Q)%_CI|;$i0Vtw*z??2MOI-xtYPgFz9V{s?ih5_-5+yeLh2L(Lx2nsIgr! zD>@F>mk|KQrOxzgpNUKRq|EvZrU*WY97&Prr-H=xgzFJdiwKUWwhf8U)^7fA-%-B1 zwA3!xs79|XHl&G>=5x_BYDl?QdK)x48kNXJwU!ReTDc)CYjPO z3a=<=A)`ObHU#`M$mYA`+qHr98Hz%J8G?*x-)Zr5d=V5~xTmf?+086;8qmERLaeO{ zA>aK7U3`MWYbds!8aYk<@=~Ug_#(&HRphBFs=i+K8x3C@8^$TDP8*Y`^oGg z_4<>{Ir*UTIl$Q!^)G}-kZku|+z(i46zzLrfovMw-@OK8q_!l!RBGN_Hy;K~Z!X?t zDVMnIzP&zAl6V+~q3ixz>5!uvqJtZMJcO%~}mQqXhms??=rc+{glDt!Obpubp@J)?UK@cnYGSxSa`$7fH0DvvR=4CK1;`)>nR z{+9Mw))vQ5bQR4BsDQiQiCKVK`=Oyngo;C7ig!8KF5rHcMa)CmU=eQ~OYCDpH^^d^ z3FII*Z^3Oi`FI{rV%cB)$YXzd92TB`ze{D*R5KwAV$d^k$gHDVB@2;$T)+w%Q8gON zaiPEPPp0@QGJVUX-}B)nWoope=vm@M0h3(Nb$cNCzct~?#-y8;5|55pYFdhSYC;~b z>OP{6-0-rcvr}!4Y<^;$VAFTay}iXU%(O!|{Ot>~gZM*q!$mOLducsfYb*gf;4qfk z)g>V&EwlJb$pfVAxi4bTho7OqJsxSw0jKAZ=FWvzO^i_!SM|-+ycm}fAOyBlGg59? zyWYCrB@W>R`TG6w-{QxI3;74&MMx_CeF2a9GWhcNu3TPZu@{h^XJ!6lU9m^)ZOuki z)?93)G#a-SGELOF4s8hYinY93r;-qW)ifdnC!_53-jpE-*eIZXFZ073Cg>L4^*<0G zuu2lKSXI9c2fH2O6W-mm_4MS;9G`}8e&k4VXu+06%E_Ydd@*%X60vG6i4dq$zPKZ| zN1Df_p!5qWEV0JJD#SW_bulG`hkLyvqSsmN0M*-C;I9R{k(=1{D-`K5IXxhTs-qTP zhQdTJC%;=qhxekcjNVU7UL@Bo9~OcThf6fL9~I~vAUEP!ccRt1cYkxQ6WC4F!AV~5 zVAGA(?(7~o+G%kj5#fi?*bt&tHNkXfIh<7Ch6!eNxjKid&S7!7^J6Z*_Ad6!8QIc? z9+TnlPXeORr;pgN@qDzbol7;Q*;T_%4}Bto}b#p5wn@v{Z>N=V4+4Zg+?b z01CG-x=1+N*>CjhA`{pk)0`sK9qf&(NQ>@M$w-RWVJr(el~A7ElyCbZx-7@QgN1n{ z&%yv>11z|3vr!!@*0CrU{F<-`US!*SZr+R412B20F11C84u~rTo@Q6=$`;vf<;Tm2 z!r1*l{14bojYVi7)iohv`slS`6HFm*tyKi!^i`XsM zxnSw3HS0F9G3>UJZz&t5ozwBOv0cKQXk~{7i4i(Act_dxUWx1a(0tNUQVbJk(>8w< z@GI(XRQNll?DiD~EtPIj^B2Bw?s3#YNo0)8t%CO}fU=(gj&KU=?Z zxnQZ2zD%$Ovs{|*$f?Pi*qo+kiQPZ-{YgtSaUCIZ?pY?$zr6Uv!6?tP@_)_0?D<8-}^mv+e7Jpsn|MPVO%JlKHP!nm9 zTJ}su3=_-Z^(sxIeJO=PU{;_iGkYBs1mXq9jkQ)N@>ztE#m z8?g0zh%BJIV*Wq&p8viR{eLqG+WoKVjuy4a2L1haFJaz4k&_fPk{0q z7sA#608iSHo+p2l{dHU$PuMq%25ry=cMqSlGn)PjNwH z#N^~;#H6H@G|Y6AR7}*Qr1V_$Of0PI9PAWy+%CwJbCg28;DJWjZMTx zNlMA~|95#901yCCY|%kzCl@>r=XysA?baBJV=3p^8a=0 zzk?5-0Jwi>C;(It8VLDGZY{Sn4uu?QIX3yqZdIqrKDP>ZPEY8g@UA5)wwi6Td?<41wcPFq%6nghekevM%jO1!((ESkwg+(-sx_V5ur|s7J~xg zFE1&#oAhqhVK>&v&@OvNV0trRf`9{NwROYvw!hbpD7wOgKr{h>)ddd8a8UJ^9F6j4Etx%9Ihv+evMm zs5O7VdF*m_BQoyqjR2O;zcY^19G)0rDoBk3fYy(~Lhb?RsL0WP?0_(tlaRAq_51_atl z#*&Z6xG6~=ibkQ+2q?yKTokW%Hz?uo#5GU{uADjQ1IL^6N)7bhv8BmS+W)cfR@bwu z)~b;~p{xbPHtEPK0jk~2nrdTSc!(Zwg1!YE>?&uLVaJxI=jJh>0I@LQ%M|392|0hT z=u?3+>UK88Y|iw0ZSU}mCQO}N$0I^j`h>^{?9 z#P^0*AdATrj1w7@TzTINiR)G1=VY!eW!eP}RvILzD2#7l#-vU{pC^8T>jOQ1splBW ztL!eAF;_XJ8SM{u#B^ND#HYg+;YWWzHnlTbD8Vo$Y^5k=dUM|%kx6^RArGPnyq4J_ zKEY$g(mK81T=JTetr|KRh7+$1N&pd53z2GrjfQQFN!1gbpNC=U)r^Zn>fr}mgI>&& z_3l?qrq{WXpQqAj^jhQCO-%vv)r7-#)fqYaz`ERY7w;d|jUd2lsviNyq?~^QIzJO% zzWAbmKlL%WtZG5*uh<`f&iDkzUER1c00Sc^jzDL|XF@P@w+eQEC5+lgL!hd)QtqXy zvropRwNh4YH!ROBk53|xAPy&A4kwjoj1gsvHv2Bk06*x9B+SRqy^Oa=g%n8|m+ zQ}fMfnut~g>tUe)QYe2B5ltjq#$;>=<&nLnTIz_i!)E|oODvUs*+Fu)_$V6;M|vTf z1e46|h%!vnW_cMvpLcU{7$*P)*Ro7!1E5!jRV}Y%6QkEoMy#w{m#0=fT=#ZV%~znh z7*$?I9uV8?tc5DC3+UoWHJ=WS*&1laG@?=$$wiTbgt^3?Kv5)i9;$a$>Lzuqrp#6NRZJ zt~Ja6LseUg1L@a*TmY11ysC+i6BG?)0AL}t83l~ufFZ0ixQWp)s;X6`URCm}2TQ&B zvGhf-sTSQkTnz*uXMBS~*+BxYc0}TWfRijDnz2;bqM>n^HYo&f-GJC@=FGsF$R!kv&tYO{An0rWX|}1H_I+rzZi!(i}YU z-f_z(n&?4lC{AgMq-76J55FWrj8JClu7U;TdF_R|YsN|95dh+7OQdMnapeGt?6O+R z!<=E?mVSTER9VN=$%)nnefYK~_NUXC!vHNtbYjNj9P+kIB`i*XY?z|OZ{?8gaQnJ+`q$~<;o1I^ zg1Uh9;Re5#zr6OXIVc-B1T&*h8^iU(^vV{Rofv-wmS(k?4Cu)L)PBCIZN4g7mAICT zMXXVZ+8+I8KV+I&sBZ(M^L*0NlLlwuFd$6h7Ta}S|a=>ii{_HcU+SyIczMrGh zE5Vy)!REo#7~DI%R%C39uGk!e#VBO}G{!du0qaw1UlLP@-=fL@awm0MWdIXWcX0RMj(R#l&~sLl_Ga6R6SdYu;{b3NV#pAK z;}exD$({Z00)n3ueUO(i_AJ)RIdD)JDp5zF{N8Cl&cE?v(^+Vy1}n%zk&=AnYk7Z1 zr?Zy+Sz)rsV!#LK{G0pGjVsB5>`!k9bjrf8M@s0~s@*ZFY_uug$W$#n&%kx8aZO;U z7;&(!nZEk9(Ni@0#aIh~n>(uwpu^igz5AHAq!I&K3YYB@Vn}*EQI4Tu5@xFv8*jj% zC9wN}Hni^a8VM>04rr>dQZ)%aWm$iGp1{(iHW{~lV=~p^4@}^4j&XFhF?)aaoo3M@ zX^>&<@Ws96%a@W%t$YBIFzoO+a$GrTV!$YNcoJpPAhpgCnhsm{m%Q`iYY!1m*eAw# zefz-piYeFI!}YIsOvAq{*=#bZQFNA^^1QU`vcP6azz*D>GpUqH1|2#!^1XlTKTm_7 zJYgh*b*E>~cH&9}RLfFRMahlB7FRTA> zwD#F23%Uln;_bb|nbqC$YGb(=AuoBAQNTo)o>3Gh2rvSf7y$qFc73TrEACO>@Hgg_GJ-M-U1E54Evz6UdF+A6ySVCShn*`1iCi(!8&&S$>4i$Y=C zJ5>M`BpAz(PlP-3x9r|YS%nnM?i~l77zB#$A9x?&cCP>e3dC+j-Va|tjr_dlwKt0E zB_qZmW2qO0N6D|xRkxt8gO)Y@6TWu!0MO*EJ`I#|_&B)Ny_sBaeq0?KV&KzWrB|IYzIy|t5nHZ2UBejMSGlQ3{nf<{qwTp)k0Vayq-c=AhC>his0 zzfS{A17F>ToK%k91Qi+X{F!j5ELcq6@9vt2hVg}=Gy1ZG(_>?k<69uE>9{y(^tyOj z426tadqgzMf722VI{(L=0?zx*^A$%!7Z7UtgZo{FRvs;|Nih(pIO`gc9=EqdA{9U zvYSWU@jHLNApiZoAiUm8ObdW;q8Bp)V$dqq4)tM%E%)hM-uyVSc}pwR`EvS?gRA8` zJd+M*TmT9-LzRQQp``IDCwbEIq>Xbxx#x19&{ML?rsG`(IO1QEFvWiedh4aRn{1kNoM-=*_$-jwBwnbg zAsCqdo)dO8b8k_0cKxX%QSDuBW_hmXijHd@2mnOqB$OYA>8()y82mUh0YFZVb*Cbe ztD{=T?ZT{jxic;%Hm)Z(J75n@u+w^)d1N=1Yf7;+>CMO+0PeKJ=hHtYYkfVe8nhp! z{&Ig(F4c^6lJr@-@J?Nv-WdIC?V6mf+ZXygS)a3#v;4y_FW?=%A#PnohPmn8i{UT% zOB=rvm*z42X>K=POMReNNnoA4?zYhUenA|i9*d!rF00Hk&hnkdh$nE!l+oRe{jJv` z-r2V=q=`lYCMbzP1uy=zwDl--UK_8xg;am>Q48hq7^&*nCyf~?Kwqj`**kSFV<;!i ztbK&d36(!#w|v23NYi4aid5O#LO8G!Q)x1{x;8hjC~tpodFGm>Ef;6zV&uTZ^jGnu z4k9czkFpcCb2x1@W1e5}y&U&Xk$~x4NO04$s|)YjkENsMrolReS;{zPo0+b=dnNF!J*9yeB+=hpRbnk>frUF+M-52nd`lE^t(K?vqC(y6IS_x7z0N z2>VV>+BasfLL&uG-e#fzmSiTHpV=dxqtPIU6pawJf*sX z^k`7DH3~fgJvJ{(XH!@oCZEJ%k&3ItdNS0xJP%xsXYH($C9h-m93`jbYwn1?Ld6qk zBYaLs%LYJ>!Ybq^Q+HY)Z2ZOY>02N(@5t;D<6-j2^@R0-h&VB_`R0L#6o*CF1yC7Wa z1>T~gSJY6j)FPaC4BU$&eAqB;ga8HrK7g2Ry-t3>OR2I&49u`Fk}z84(NdwVPbo_P za+SwKmqP{}ScQfhk|jkanbUvh&x?1K^Z*bRa9TkIoA}BfGC5=eZ0J|FRFat6Jz2k9Z_y8z{oKgwT z<*NX1@Bvx?06GAGOkY@0U$W6lyie9~LJooy2MMYSGTR1#l6k(>n6Q6M$yEYoo;}-b znOXWh{cf7wN-XIQP@NbRhXON3zs~NtjI}$!UO zX||YW(h2}r0$`vJh5-O^Fm!E66ng7RPt_&(RIuM8?0u>pK0~I3%g{or(x$NFn zP)!yAjuzJsCz2@V=ng%d6*>t z^GWV(;JMJ_-3Vd;00qxyrey^LNC8nB_)UayPB|<%KJxVMJ_`_u52#XJDK;p$HYl-H zFjTOd7SbdMs!%W@ewi@a;R5UcsF9$lQ5O4^J?#kBHWXYoAc}wXq-{m*JU1>n01YKh z7Da{u?g%8I?{1gme?u_*VozNhPvKE!0B{PXq7rfxCQ(ZWeHEsP-E&n|p;_260<{qU z03!tsfW!ji0H82rMv2U0(Eup1!~j{PT$?bqFw|HXhR6FhxQ`-1SpWc{q9I6zEKvaz z21Wp&LRFs+00@7;q$igHEr%gnmH_1GeduVQzG9?EtSQUvuw=*quQ4D1bUw;3J_0C) zB?R!MOf-)?1|6ArkPo5CV1ek%5fBu5RPs0!1b+$&(r<{dX^^=gGddayU6rN2K9gOeh;`-Mh1;UiJlMiNE9I| z06d5Etr&**Dy{v2))+nj7*i{TQNcJzjsOOiLwRH_9*hYAHpP;ZXf+Wl(=!$W%MmeJ zLwxK;C62_T*h>5OT9}+*SZuR`3O~SynM2kNYz+WoQ=k$mB`Y{%M$?1F$pIq_VM7c6 z6nZ|Sp5cGxmU_e~TGkY7VdYL7c!bSS7&%Ea43q3C@#KK1F#>C_96@yoYFx>LvU7>E zE>uB}15;)iQ;CpKAvO=CMj3<)Ws@U=pVsyA1 z`3M^L4U%0DxE4l_-DycsOK%(22fzdfr6bY_yfDIrw4(S|5S#@<8Cq)TE!N%xCN`r=Dr?1{+e=4fD8NoJG`st~}MkdLv( zL`=8bH#2qP#|sx-Wg0oQnTV-hFRGN3v2|MY!Z1kd01;JT_Hrm;F_5});x1LTT1cW# zRL%lG1p}xylwQKY_*x5Kn@fQml}gHp2?3DGGKn|MabZHL$pmRbn)ZIY33#=8c=mtO zIdi*;V6x7A8GuNqWT+BN)lp}jn(LTJZCxs_GM$U6dtc~wmS|P3F7{$mc;;Zr^$Ci1 zIJdfhV1fONn*$XvehR8;hK||t9Gk(_5k4+VXr;DPoC1!dj7YO4OZuVg%O|eXlub%X zFm0Dj>L{d~0aLCc$$1z8@PPoRC}@9Zs2J#|sA&J)IYuEsMI!_eF`(095Hs>Y_yuHS znFOJ7U?DAL*uy6P5P22~2I?(XITd_S8W|a(2A^K^qF9)fjpq|yYa3Np`qBJUhov+P z0d!d_+?1>qs2WF16(Xib+$k0Ufp7Y$Tt8KPsv9Vgrf9B-Km5U%q+%>Nopyi8uM9>Y zyUf8ZWmNv1GzDL+Z}FKXOv1;7r}p>f${S+tI1XpGT8mTAT~aK$uXvb>a0u`#mYt`> zn*XuWREcHZno@)1Q{We8NJ-->FG%LFwyDA4af+1VV1!bRIEyku1aHyvCD`KuV4ML- z9RWLMCMGE|THBZ%D{d)EB9wo@rHS+rK;+*dLU{#vOa1_ut8!Fwj3@)!l#yp=rzm!! zyP$()F~J~f>oNKW!AK%PpaYBA)HpT4T7O&|<*D@)huDfx1THQGx|7n|@yL&af)PLn zpFQqycIp?@H+l=quIq1V3dd57-xiveT9-PvV8fmHs@ALevzwp2@ezNZu~b!JY6jAq z$UZgt8G);YEXI)#$DyGirJ*686j^lYi+)PwG=5fNTZB>#v>L0Fc;an_*8Dg+xt_d| zK5?^}W7WF6o~%kD{YWXP^^|cWA0Gt5ke`nj7o{)P;ozq7A=fhXVb~C%05_|pa__6J z`ud_C$S;l6R+KJ?a@2pMA&Zj$dVDoROs+bq!B^&Og(U~*ZSiwHJ~^{^EPj5)Cr>C@ zY?YGmfiOmbxClN4U_UwjT6mikngZryVd09AgYXGYw|K;|GbDYXL#wOU&#o!Y0LQU~ z z03dCT;{TQwuRMSFhW&PjdtU5Vk+uA%d35I}eWh}&s9F)#1`oyEl7`mh}UPn7xF29 z9+2Yxc{Vq8lyr%7DW+y+do`rWyz*kUb8>Pzkeb`?vPUY@z1+ZYoC4|Q_&9AQwUq}y zKi6mr79!Xg(-I*N2p_W8yjka?VPRoQq(9GQam#-ez(g8$0>qvL?DQgG@V2{(|BXiE z0+QfI7C^}ado=BHmx(0v^NY8lrRZ*@c2sQdTO7~)YMj65dbTfish2vg3s1MXwP0FK zw^>e6gvZ69gA_Z#2w!}`e*zNEBlaa;T;AL}DETSEJ~lNqHincv&IfhUYBTxClInpv zUkZN;qA#gAsi~mKfP&IEVKR~*bS*38w!~I( zVDLY}R=B#J`~Gl$#oFA(UZ1eS>mzg?9Q=R&bG}n(eUoj)55r|raaF$>GFO5!gl3au zvw!=!zDkX61g;W&INr;CO#UVak~GL760r&5;%GATsw&^)9-MIS9dPR|Z?I*G-2!~d{xhZmhu4e7bG|e2@dtl; zwfC&Ybwqv~^?nvRf=t7&_Pw8R`j-~0N6!Nb{-e-|(r9x<<@ns`DP$g{}>NM+H< z3)zjGC)!Z8 zb&}>9iUj%y{F=I3xi7;hicRAEl$ZPoACPE-B;XN|Qjyk>ayqpS(xscdOOPD#CN z0$_wO*CP@mzWL01{F0*fLpmDLnd2cOz%6?g7Syuv65x@Rcy&cCyPK@_pPt+YfO>$% zyVbQEW?wyhGlicDXEckx=@x(1oh%A4B!D1Q1PKs*!{iG#%84v&5x7Rx5c))lzMJ*U1LwE8^0T1&Ka+PfKE8j!yt;<3GkKr) zsy!v>Qpqvsz+bRweP+{UIiah_7_#E3-(*VSsQ%LQ0nm8J&Hv}~wS-(``F$sD#Irnp z0Rii}mv|$(KA%a3R76ETrXi5P1}@wOzYk0>IPLu^BB8VVor}0vV7Kn)fm7)h9oVJf&XK9004wCx^D*-ttU7USYDJP92P}HA=W$pT^A#3u^&A`RTq;aHs8ndpYBEzb; z4}clO!bDF+Vpo5cN7H4{OJ(Llr(gB(3=tY3GIvhBdF$GDgA9dSI)!}aJ3Bu#kVTWo z*yKd|w|`4vkpOb|e=2_kel$u7ow|nUr?VM`Ux8K$yjec=nPD-?)7fc)s@g;{A>>YXLn;$V+ZDjL5epYJaju1Uw_%C z)W8>t5c~mCd;zZi&i;ojSe-dom7~7GSCx|6+;?s>-OMMe)?yi;2j zk(=wYvNnH?L^;@Bm>VSji2kwjO1LjPH7j^1?F0cUeYPhr(Xy?$cP>(^j}fATc%;^RPUni`M)-zEYNx(D$1W#pC-cNsQ$KO4 za=+IDfU@$LaINcqbHRbd@!HL&%hwZ^|K2}Zzj&pjrojUse%ZrA*nZekKmM)mrJ`^%jENm+v8i6*vBhUyGLmvTt2?@lB>(~!-M`n`qt#*JUkXC)28;Gku@ z2Y}$=%56ikN7enP;lkc?`LnVt>GprJ zw0gC%Gy#UC8*q_x@VmQ2@uE(}ITh<_MbzuEOfh9is;G_zmGi6mtkIj=9mL0(cB#(| zZ6P-gfQgSAAM39EiYFiWTDT{dt`+X;;a8mN3yOSRzSy|`vikriYSFw9JdoO@gE0i_ z-O}xrTTlk|UN~8d_5ApK_sQg_^ZbALwPdZu3-gA9zr1(%l|SdtLo^N7U))$^X=qee zjm@Mnf7bl6@BsLzxxiar6yaOja+j-r%G(jzu4)}&puj&f6lU8ef{b~X_3)HS1Q$a!A zV_tFbNF%f7LtsO-nEA3$$=QGX^BFhY^Lq?Eea)7opbJx^NH4t~vq3_oFI%$ezD(Yw zkJYa@MEg63#IRy^RsC7j%R~0}`a(PvrBj8Loi9bcKjjZd zn<}(DW6hCRK-LL5-4VSOW+5{*GnHh%fXJ!R{~whJS^wMX1jK7XlzV@XwI}i1W5Kke zCd4{zY9S#0$r9VR`0@cBvf`#9mvIHwdCxh_khYo8b6sn5T^DxzpX&5~T5fs5)46#6Q`O_~ z;?*B(lq-`J6>wEpJ7+1ajsZ0M}OaJzI zt^(Gj|F>G@as4~Jc{W$z=_5oVo^=)u z*Zxkl>5Ys`6ct@~Mw{={Kf0~VwSz1_jP2C|yfOpvHj%W(Gol#>Qzso_-j6t@X9XYc*YT&{$QBq7O(m{xM^MkYJ)yJKe;I5;7IoG5x_r zivW_xEd+n;qzZe-M65&T>x5 zp>YY25y4I(IHYAGvj<~Jv@Jj?=am>l_Y=Y-q{DxtM=-bu*NdY>b5V*6z2#fWGByF< zB0q_O4upc*u>@haqe`QAm`mMyFvy#$N1d>f?OEeBBE+1ijx;)M>LN6LaDgbbB6#tO8@cHG(1)zSRM-)zMhWivS% z5W9ad*{9i20c$=@+WNg&w<%6tLxo{+6WU@i1f`awrP~ZSomz*CecLI7C{83oC?fKus>7=Dafp6e%) zsAnw83ZE57$n~tpY=z2NnD~_!jMkWJ_a_$ubcSVheq`rJD)NOOzQ=2*jO>>j`1#_rKTrpdisjko?Tiz{$?9T7fue8FLx6Np^P+ ziAKn3XTSz+Qf^Y=C?;pnd5vb97&lIhTRu^_6hthMPpp*_QFLm-5v}#Jl#Nx~xtO$C zU))XS^CwTEDxYDxulYqRY*#J(K~I0Fz#jbt;k;S z_`?u@hX8DK4EuK%5)B1K z8pWK7j*7y|%X4cT%(!5qB0~MWyOL?qCkr1hG0NmQb2INdn`yWW`3NLA4&Hy!(c$Up zmPSoQh5rNrDwFSp?sTb^b=U|C->^ty!ENS7q%ciQP0g+Ye*_kmBS2Byj^@~R>^Oo9 zK=~2^$0)9pCRZvj$TM##HfJ9-8 zC_!gWEsVi-bP}WdUnv2#Le3a~P*8#@i~%_$vc$?GKaVb9lH;MR{3b=Jwx5Ivfd`#1 zkxwQhydFSuyPxVFoqKHHXpTcZqBNR*84KNlk|EoWM`4)$S0I;@gV29t%R-88<{aZd zV+NcYpvmg!A1W#!^h~Rp;#jL=(-FxTZ?$}Rv%3Pa*>%KRT9b%;w0IABi~(rT z)cxLFUd;w6Rcv$yoaihvT$`0B#)So>Jdnp(_0#4G(`05Ba$iR&qZ{kkc3L(?^}bLr_88e=$c!KF!CyzN=;%N=9T~ zA*GW^o63a{Um@7vu0iQ<+UA(=jM?}cY~8UDzZS?!DTV(|cU6CRBc2iSQ9M_|#EIlh%%-N+nUFp&KXHe&TKb*%^Hcx0y~hqiM1EXh5}z4Iy2& zV>W7{iH$#GAB+#0xT~P<3KDv2*Z7|VtRDb%#0zgmZiyAkpky4#p8Z?@7OGUo$K@o( zd;a<*Pdr*63CDk0A23z3c~ox9YNP%}KRZr8ME~MduMb*FdWtGa zIO2Ym_%IGusAEJ&!SYU;_Zgcn8LeL!&vw@rWwX?_L9n0wqtbpdp{%1DSvmsA!Uc#2 zC5>7h0Jwi9*4a_dNfdUrLhF(VlXgW@CCGc`!TKlvbi+nWn%P&X`iKjo8NSb-G>ecJ zeYhds9%i#P)@86fq}dnkaC0O$Lqc$+J+S}Ttdnc3 zF$8WmJV<_qlzj{&O;5Kw-ivu08#gop9H1^Z>pg$`6S03qn;&Ww_fE_DBGFO)(OsK2 zHoVQ4Pfg|J=R}2tsmZ$Pneg|0e^{I;#0|ztYAIatGN)>Lj)Z!pc8{AfJzd{suzfeu z86(uX%O6|f5E#Wow-rl9%4K1*@o74rR?qJ&N!*` z=jvMWFBBH!JY0ZuX3J;+YX@xD6yW6=`*&h-ay4vI)N-ObdUy zY9-_1-tt4XBU0?fs*I|wp*t@l38{&fwtrZhUJ{y`p|O-)@#ODMynV`=Mn0PguZml> zSvXfiYIb*bP^^bl45QXwnQ?i({e?!nGTuAYrQV#V-$@PC1oan)V z#ASYtY?jW{EM?EplDE3H7!izhAT(c}|5a{>iM@F4GTy^9Zv0sDE&WoC?Qnqu7KOdi~({ zFQCMv@%*c+=Xq52QUB&7Qqq6SSm<3iunfxDgPbYfXt5Eyn6SbgCn|(7tA<8?ffyGz zcWOwJMyLeAH+~_07lgeMH#Z9oeH&I8l)#m=pICM=vhs-rj&cP$FN$YF@&5z`kKazB zqo6&0v;SXEK!}Qr3DAi6ApA12jL4vXNkGRF-O4NFUr>Ph7!+JOLQj7fNI3L#y!nR{ zQq$cWP!o;r)#Xu1-$j(9or-apc9TWSNiTzUh7nB>_Uy3KII_$92k8Lh(bnk8H^QHrP>cf1R+7Sz+6hvc%>_# zN-MJ~VI`nW71wCcV{o%M;l(p1XjTTFi_ym}l&i!-&!!+id6f*Z=zs9*9Hmzk#eic& z3%5CL+CzF?;0G3Tg&hVQ#irEEy2jfD2nj1;nN0La_N`h7`hOD(34uhGY0g#D-2-v~}i8 zK;K+e|HVh6O^^I@=sj|f&V~&BVCc{Ui^WhGvNZ+SUs#LN0xB zX$gO?bRBP48+_)LjAGX6Y7k9`RyAC4)_`7+MZ{G=HcVvLNNKJNY#5Bb|=Tz}N);SGDUG zRHc>tYBq6VQ@?FCZ-ePPGaD2jaNFb;Nc($aDiD7HZyarA$T{hc>R{!v{FSzpBN^l< z4`W33iet_3sD;}*UnprTbdk0M*`G(gPprKp?}q=D-BQkF>~pQ8qAvV0uF8SYEgRYu zNPdz6lFvD$uojSb$aN(y-I;$cM}9kn6!Z!Id5D^KzEW(VT8k-B{>+~yoQdcXg5>It zNfv(tujpZW@1RIi!X{?ZItUS6LASvsSo*60x1k&N7UO00{8g~nVcJQ^KL_i^-=SI9 zO~_*9=jTQvpR%$+x)nU|&mEID2pO9rd(mq~wI6$m(qDi7r|3!CM+Zl?e|}dG;Npc-eA5u_*Cqfd z@EPE*krT64XrO|kJAuzllN80j{p3$>0q!L0vh6&Y&;M9aER?j?&Zl7q;k60$I1^tlW)nGQu*Ytrd>k2D7!rkLcg7Sdm)oz9P4=(BEFa4q&lP}`<%M| zk}&@KtkPR)^4P&!b=>>Z)Q0?a3^tl|XsUeaSipkL0M9;wQ2hgGM+}-Ah;MB^^HaCyUNasdR|+% z>(zHvNL5`mU7H4-8wl2sgu5j#mfm5|m5-kIBaLoETl&!4XXl58JR{lOp)*qT_smU5 zKfmTI`tjle{8fOM*r$K+ove79QA9gRjlVuXayIn%}w>2H5T4Id*yTnXSn8!p%* zFe9hC@c>@t*VjLgF$5F@KtV-EeS(3Bfrg5K@o#|>1QkTUz%PqNNYAJ370xJQm0FBW z#H6LO4Yh9SpBJ$7MjV4-o)IT6!b%3d{?C#pOlj0#Y9gLa9eZ{xYi*0X0bVPb5($G( zQ~g0xzTAYQW!Zmr_w!b5-m6wIR6Fh!Oay@e3QA+;xd}Dl zgI%GvPyTuX6(rfD;@x!{ODc`DLSe*f+P@Qyn8%p>o+ zuilY;H%_RN-5H)6rHkW>*ZVtQEpFZWaGt!i#iq+QoKN(&S;(iRre;5geoL~Zb89;c ziIB%GDfwP7@Bonfdq3;Wrd_(tt#`|=f7hcIH|p7?X|ER}v26+|{3U2cn?noi{e1Do zgYhi*J)TE)0>o6CNBM%sd$bgBoe}#`U?sv zm2t+I)Ss*_7Y_p5Sb zu?}nYlB4=J*%@&(0a3(DQYx#_O(&;;GKiPTF9Y&zrDAQLo|&31iTkf|boSC8oljhN zftoRKZ|3h*eT9D0rX407ZkFo#=vio!PYnq^JJK3G1Qg6fA)RV>!!EW@z%NU)y#6q1cRWszS29= zAp*s+X$>w>Ro6 zYx>(HQgRiqUyr@l9w<=L--&*si<;U`?58)SWMwOuaHZ~=J%4&-*sM4L*0kt3W$R#8 z3W)pK`n#ryn*h(Tt~Lwnm8&-QpSpZ^m%&Nr8xd~Kzc}1D`!@SF@7|J$!f7jjsd^~OC&Sm0~5)j9)(F8ovmT`=lcq>K7I65Gg?(6|@ zP@y14KgN&CH$sqZ_sb;iPLk&9iD`;ash*OqkmSe4{<>bBlvh$+Twcu1uaX_-Ihb8^ zy4VoB2)VhxjpAY@uTKoVCxRlgCP;rpkD`gT_wa}*1*a-f3Bf`i@>Jzd?lluj{-&Hj z=bamX?Ud$4)g`;SvJZf|qFz6*i&xT1@pEqq|F|DsrPtg_J19H=0&;WNoNjWNcbxa> zW7vY!L+uy12yAsfZ5h3}-sUWgBim7)W;W8P%F^3%Tp`t?|Ap6G8S|NR-gAF-B{4am z@@TJFmLZxgF16&a>4ZLp>7GuVnEibClib(6-d_<90Pn`Pe%2>?46pYih|dMRJQqs- zDyAJR8~r_D97q$(_|Dbs|>Qdcr+# zsJHyqYAiA<=;L)mdq_gx(xQK{cLH;U^=Txj#+>!0V9LcX#W} zjenluygAgpH+%r3M#^;ep8B;?3hnfI`AGfH*T2yx6n$e6)U7%(M7R6&rP~9*SZ;VM z01JoXrTp0YAFU}&qi!>G%6dXJKl?iLJ|_CM7F9B}6Vl-*x1HFL#Mn)8Tm@^56Iaa#zJyBF2@B_-2#( zbkeAu3`T{V@d-J##7=dY+?xFJj*D+K4;o;_B-V*;xhegmPI{kVJ?O#0^am{8f7rA< zUB0DBXWG9ectO9*F}Rk{SEkIm`PtEgi3BcptUS}@bmS_~HDT!m%w24-4=VwT>D;41R?kUb% z^T3#O3EeG!=&Cm1UocgFKjr>BHK}FG>tq_h|5LVQSxS8+7#N`1r&4Ukn_g$FlORp0 zLF*kS0q(A(lZ@>I{Yq758G5#wR3`DhAj5BK?V#YS;;`--YeH4?cBbX9X~FXhaf&$2 z54vF7k$b=JVpZe$zmu1!Bz1f2bg`msZ_NA%RYfa5+LUeoVBTea-WBaUV$1u$DjBu= zLAUxT&mYWLy(=_u6Wg8@FLnkE3&Pkapkh>ca7Ok2^VF(>1De9>FZs>MO@S07lterU ztQzwBB0N>ra)jh5txD!#8XOMtl%WXIA?{I9uNSM@B7qvOu)2T3GDvI-hJ_G$*?vJi zf!~rP;QvaDY>F*^KLuun?V!qBwi*i&R@4CBAgQd2$r0aRAe?Uymv2xx-Ht**J4QQw z>T#cL$H5OTWp`ex8K07?I6a5~L+G>AXV34R?pLNp5TRoN)j-({d{9d{T;?q~Y;qiC zIObDb)T?Z=slFb2k~6-Boamqt3rNca~|7-29G>Y0wz7XEjxFEQB46htnaqRG(^*Q94{0=uHMp}-pIALyh&*mJ$ z@VK{@o%5PfLP`Wb^3As-(QnBj%A$|^H+zqtiNy|CL&!hiDlifJYr*A`{vEB33sJk# ze3#z5X3NiipZWZ80jqMwphuyGM1Fw8MsV)W@4@g%cUoiRdzriG%HYgR(bE9Y8{U?} z$>a}XPHlGyiM?*?GwbbZ0p@;b$r4jLr&Cj2yW34UZk20W_L8rmyKaJ14jlM-F+6Ej zDb_a>q;D3Q0+USCTf8oK-jfu{B}tvUkDOj{dnWaNZNS*oKb=kg!iATPf2`T$NGCz0 z`+lJ~$A*Cb)7aMZo>gbAP-0Tgd;)Gh+`vLU=&nGJZascOQ4}Eht!%?9MqoX_%>Gbf zlm=HxBEMCUcJC$+7vf~D_C5gD-gH{Ux%)lyf?jcK@fP30P5!M4x>{4baof56Wq!29ieFZ#T$DT=%o-%nm~_~Y|5 z);mC7-^eu^OH3?HxTx!1@#-=iU%^|C1-{#Vmolof7u)n%59(H@e&Pmy^{4RRiR7w} zQE>QWZ*EHbVKTEO$JOq8@Xo?9t^0d!2{gQSu|piS45@+SsxnsGc$jib40npO8aihK zR@!CjPdSxG3r4bN3NeP?#p{Ide*ovJ5_5fxyU9sbHV9a{bGCy{dUuCm2hH+ZGZZ=n;O1Wv|e?_>?e^k)2w zgv)Y)zpFY-MfG95SL2vocu>4O+sc=Lw`Qx^T7( zA>EkJn3{4e6I;;;2W>Vj=!PAMcLuBgN2Qbw8QODz9=|EX{C9Kke;#^+LI7fafXHfF zd4;DI(>Ki@_ivx@$!PuWuNI^kl$4AbF0~;LW(@K%W?H6$sAMaNsG-bZZ)g70;yP?r zY$?<)a#0Q&_3^%a>ZOUWjc5^@KODTiRI3A(jX8TojepR8gBsEVAn7GGN2Zb(-_Rcb z5y51w7ou+-0RA&eZX4R13hY0B%(XoXINuyQtYPmpKqEAl?n^bsFCEYlDR1QLYC^9Z z%h=r28-GExeB4>|Bl({&4u?*pmkgR>^HPxHFUgtu4Rah-)t0jMKjTd0S^WT;*o`xd z&3UKfwrc8csimtI^~Eyxn1P`#t=~};Z3%ZB!u)0{it+)lW-=c~Nof9m?VRDg+?8%q zZA01G*RuQY>-jm#-}i6HKS>OikZcL7JY99F8s1TQT`V4JM2d5-SI$E$Pg#g{Zf{_~ z8mAU(uMK5?X{6k^^<|!Jj>8+o>?$@-(nHZIFTIWR0GRfVXDp2LA^N2f5C@LU-Vo)Z zz$B%XWnctlr$n*NWBp-&F~`=H&_pXmH{B|RSjaW=$M>i5t&zh|%8{ai^^5ab+?wcQ z)k#W~=GrEpFLE%ETg4cwagpLsnzDee!*T4k+bjGH621|DHKs}u`o_RGZz6@^r%WTl z-`z&Tv-1eISRAugw0*5b8dreK(Z*^n%L!a_OAzNMZq_5h1VOWZ3Nv`YQ;cwl1}mfI zK`@UFr$I*6g(@4tU-RU4E)Hl3ReSg@ z#vId4@8`^(L{-r{x?)QF9dWtqnIgE|&LEN$g5y%PG88^fPKnWEv%d}VvY zM%>ud%wH!ju zVgrV&&07d81sP<%vUE)!rCAfVok}*>6Mxm02xM$p(w0B9VBC48v4KADqG?t2GsWM5 z3_tyUaWe3cKLx}WUW(mcT#v5ifEtNS<>-Mu^sCI3t?#H`o(eL^6_dLpr4WK4C|7IM z^5uT4o$-9i&?MKEA8w-&9TQFT04RSFNjDb-hFWXZ5TP>w)rhDP*}e3#L5?wYb`Hg` zTlkJyGMBT&Q(~UiadQDmyWu+!)z$a7yOz*@5|)6%)Lt|z)2GGg(Vk@4@3BlpRX0JrxSLoN!}lKmVxIm2^eNd*adCGznDXnId3)MrpDIg@7Sh#v z7G>-zI$v3%(+x<-M~2umw8BLj55s+b z#iFaIsAcPcU%AlK{70rB{i2j|pmLaLT65@dw*<(QmW{p%hv0>ce&EIaJQRO#vZ&_H zQfDgy-o`*DR}xPkd{mzvJ(m!^YB#p9Q;?!cCkx$bjG|lQD`)rAZoj4HeZxTnjc_9F zPqd7ppIc;*sz6TH5rs|fb$PAsu&``@jE$z$G70B|XFVn)Pbib>SRJPu!^M*3$+!{_ zFVA(p!4ADdBd|mXz(g>dj$^`2p402arX%J|kCmvz!cm!nxlHD-M4m>+wq_|d3|5QG zb%sa6wmJM2#&&n46V&O({&+)EV+_ElF);YJ&Mn<=Tt#O~bI;SNj_y9Ak9Dhm9({vG z-qR3Qv#%(|5G~i#{zGqlqJ(+(jiSoV5S99#t#Kg0t z!44y+RWSass|LsF>&BFDUNp-?T`VHSaQ~Dtlg~fSqFauBg6RvsfGdtz$pIJ@%v`Gxy`39M)iRMI$` z+>{z!uu;_01IygJ6sAA^ohriEDG|BdP`8?}`20`ASb>y=)ibN`TB5NM1-Tdn-9Zde zmc9Ba$IKzm*Uv3`w6z^I2Ybhy#y+Nvx$~Xifn2pMG-VMK{sYN-*8Oww6Fc%oW~2UT z@A*mfTA0_mqSQ;K6b3R(R%!+3PtglBu+@sQ#@LOrqjq$w<5C_^o<8MkOOO z(|NZMDq;nD?VTM1utMSMqYFW}TaK`8FB4nsJf3*cZq8|->KctYI5r7=k$h@o%^Wz! z!kgA{MC4-#G=CC*E&)=S-&TsrHd8u=Ny?Ye{$Vd+_bg|p zMaO3Mt@qek+0Dno0r1mp@0nri@GPu%%Oo*GV6LGdRR) z)-XawYoXA8TfutHNFVEl%Qpsniv9{Gdwb4G%f7_lD!qe@xAWjH(dkgXH&&F+xqn=J zs?i^{9LWcO(vNZ6&qQMHu{N>ktoYFYyV-I-S8;Fct6T(H(y*@qql;zbb7S zp>%Sk(RuE8#qUL*^U%CU!EIqscE`}f8PUmq!sF9PzZa5@b9)9SX!xh zkr!3CSZg;m?GjHh;VKl}XQtQqR<_!@OX4XCFFKYO6GBWPnZZvI^;i{*uVCuc)a+<@vN>x+W@1CzU;u6(`|2VW7m^aua=_+IAEss$II; zlycltAe1KJd44Tse`+e3z3KLu)WB|kR_jgLMy~D$X@s9`{$*dOIL_xXUPeZcYU+#v z<7A)Z825IJ>@@6df`lu(&^BnRBO`n_BCB)}+aK6Tew#S>i8d(kbSz76J+Ql7RG&34^LZZIl}f|u6@<}74JCIhcg^v1s^b@!VnisjHdc$VS5;Aeb`oAq{Sl;UaZ5|=r2Vhwop0-%(%|Xa+`&{}5`{3TDRDjVK zVZmI`m#qf?gjrfCYLYy?5cus$-2oE@E%{ibR_1=>s_^fyU!tA_!mKENSNN-AIc?Jn z30w~VwYy~eS-IDj>{wvLI9RHQ(#FWD(P}m}2WtCLC4@ysZNa%JP+-iO5y;Qa!Gt4% zA8lttk*tH;d9BqXNZ^Yc>ucLM9TuJi!}3$SS9U)O>;4S*1r|0?>U^_ctv<5r`y^Pn zW2BQVCm+Dj@~PW@eXCr5;PKa89P0LoMw*f0y*Nxlc%}+&9njsxmjN23-C&hJ_obVt z=ni3B0)4X)o~*dUI-xw-%MXCMNYbw0>@(^5A#F2FYGTD|dFz?WGO{Z`X7Z-s0|3cP zO7peJFyA?26K!A!MuoPSlUWBi#laMwJ4n@j%kneviYnb`oyC5CI^miJdsIB9oqwka z4$?%&q(!qORGcHl!Q&-j`~a$-Hty~o?QPd-U^A@waW9=-&W=R3a_0HdZoD!1aZ!Jr zER1(dbM4lI%8rdAwB7u2~&Bn1hFm_rn;XNC#)`CqvaB?+Qx2Z}P{E zy_QIsPl?|8kht1UihXIBvQs*8qW z95Jaqt%9OvNA{j-Q=3ak(Au+{LiN0yUG)J#*G}tHS<3c*r83j0N%@OByJ{SU`~x8E z`P{tledGnne0m2vaa!h!qTg#?z1j?MYU34ZX_=~qe^Nzn?E4jF2QQ!gj5pARkp=O~ zVoVf#58d-KUelSkm0?b0E|mqM3!Mwt?EPjtZi_p}sU|Q-Cn6$SY+%sMLKUNtyjOTH zq`;>qiYcpq{^f-9D&x-L1HlYq)F-*0kwjHC*1Aj)=0nHP;3G#D^np8dL{!Nx!Dl3G ztjRZbEnh>rwD}WckXq1Ax}QN)wGB6MbM8fTN+~q_^xa)tA>>n8$S0{Mb*a<@YYB!3 zi9Zhjo&a?m?c*;pp$?a{ALAR%@Th@nsr(Gxan2)u{O!Ycz;Ald)m>PF?wLzha{rEeYLc; zh*8ddv)O2DLtH+%REzkVKt68L#7Um?%`Kks!>nAjH$_Pn>UCIof8XDWgE9XhA}c2q zBc05D9v8MNbH!9{f}N4G#^61D=EIcXJ1(b>yqLY=x5;0DR!hfxfx0L) zV+t%A`?8(+G)%Vab+*AN`)g!cv#t4IRPj%(6w%K}m2)Dtd5&|6?lsT&XU)@Pwx;ZV z5pnAsg|eZR@@%i6YC9`HmjlR~CABvtlulQ8iTS;0eDE(#c)urfl7GFvNO+f3d?_#+ zv5gGG(nH2WUw4FfE)Vg4p{BX!J5B%Sg`OZoGE+me@3ZzfzY6Px>P?3snUFq_MzJ+lDIREPCkCx7kDY zZ;sgCNb$MV&#irADWyH0t2La@DUe)h)P?;_^!{KX*0J>0@2J9`b80#73yqvYTH<8x zX9G30Y86hQpPu&mbSygQ9-bnN+P1TZN4QY!QxCa$`uko*r-L}Urr%EbompC7OIf7UqObg^WR0~1L?i$>;Vse@#@`k z4UNInSMakFq1^41D@75(5PU1e@h#C6>soI0>CD&r2c{~CKcmww=(X*NYbT?5uudBP zby9j?KN&rcHctHbZd)a2_d=n6G1T#YNBEzOu3_yZ6}yUKNG=(+sgq|p@1ly%H_wiD zB1|s|=wj@arCtjZ!lsG79DF<-{aHj~b&SWKNS3u_;t-RuWg4n!QPBe|843O}e?0p- zdf=OiskFDxYV@^}W?|1H)-lGwwrceMj+jM>c34!TcbIz2BdHL&o-p+ZRhPb?FG=ZD z@R)tkD6w)yZ61>uJ0}o-ATAy7W|8Uvzxz*I z&G`F-FgG9WC?)Ux7p?wdnxG4h=EbNjjoPKamU^O%X)Yla``qfQfH<_T{)Noia}y#S zmmNkSl|`jnAj+JR2Y}!ywD2xAwW4NrPAAu?;zEk@0nlIl9<`=__fq$FNM`0mXrD%1 z>jU6ZvQEpAG1-$C#shz%(HT<7iIXBd2H@D(v7^-X13&}o)d$#HhOZa>KA8hfc4>gi zQO$Y$UrqOYF@jXag58W{BYD7sG@{>UWJkm7?-(O8KQXP|v0rN|Ua;N~-N!uu6!#tW z9bRmhX+t)q9U9Jm?aU`gtrLvKo}!lh2ap9j=*NX^rpK z>2N;7bv|NGyNG1I{4o0DgY?SNn@s%42SCI;ygb&7dHEdOw4>MJ$-YJZ^#h>#rnmZr z?D*v?>B!zsw{&~F{rA_>n--CGLYLATat{D$GV=RodHS-S4bX~&nBbY)DpPcL9d8bkZ(wvvx!BQbFwe?K|)oqgUM z{mYoZ=kyQBm*{8vtHO{^^mjIYsQJoDQU%v({HrP<=qGSyAG+NN=xa;MQd4qq+Kxt)GdZE00{ zo9}ui^q(OMH+6n z_3;{iyZs6e?FI9mknxUq`@P1X1)gGsTHwgYuj{AkBj3MwP@Rf=Phc&$AUu=6Dgy7{ zPrBm7RacTzQ6$;6zP6F@PE>BsMJf56KYw`SdF_5CObT#+{wXN!%sxH1!^cYD<$u>{o_^6t#jWxy z{ssQIZIb ziPZ8=14qvF8ce3HTs7Vrow}Y=HCUyed2Tc`eY$&6Y7Ck(+dWL(@aG!K;z>Dm42jWy zk=8M;u1;ZgUME~Jd&g5_ftf$AP!c)K`<`=NrU2*tE9z;nc|3=vK(Xvhi~gLV)wkY$<^RNrC`+gV~0ckpVS5mz(kj+Wgo{c&EeTIN$j z+8yG(ODfL~6Z3~VZam+FN(BCN9`nk7yqhnqf4cOARl710wpl*2zsDAcCEA~b4w`~T zoeJ&5G1TLHWcaWu^FBq|IANG_!@%x>DJQLR#m)@<+Lk$R00&YsF0DH?|9xMqFO3yT9ver0LwPI5 zrU%S6FLqqoQ&vn9K5k6E6|RY6?qb=zx|(xgJCM|l3$6I3?>mz%B zI+UO&X980U8B|@IR-3Aq{h;0|vKs?x)gf>lS@=*$9w&krL!96mNC#?)4|4g=XC$6!H*z+j9IQz0Y`}l zPD7#Utcbcs_jfl`+nE`8?wZV=!Zw`a4C`}_q4IYnAHIy>{_^yd#;}jv7{4NX+j2DX zUYHhoE+GuxtSdq_g}nXUmv!XHOd)OW5DdFBEyVt*kmIzWxAo>ohx(lq%r14nt{>5~ z+sZ2br6WURE30A4ejzb`UND)(P=4$4Qa3)OSRca4%=G(^s_$olW(9k~orz>or(k$y zE6H-+S9^uGYO&J|=^XG)>&yMO%|8<|S)l zOF_$Lw9pRS@cIWplN2fc_quNMMYhAu#Bs7t`#Ocn+ND`XbKDqzp^Y!NZ4@MmpSZuL ze^_LfDBLq>tDRJvdkJ;&XUbG$JJp(ZUFOH)Zv$dTb zd6OpFgwUCfIo(k{Nhz$M+X$d(NMn+lWBjWBOXBbgeYv3&wq!vwwPJ;J{N8)mTjS){ zr>yQbIU+|?f^RQ>C2{5{yFca%9hk+P=I!afH7}bsBjH}n-<4E+&zm2$nAD*CR)so4 z^gUq!!P{7;Bb>BL5cArW_IvX|8}%J0t&dhgC>{n4athnaIPajQhqkS%y6(*$kyUri z68F1rW4fP8@lCT9=SdKpvgS83boVH{MdpTS6(O3kL|ICI<6S8Q?sz}U5;T;(QkfEO z5j$yV-U6^Gh43T6Q`nhvf`QuY)8*?N^`|?hll{wyr$M~ddiPI`*6v$`Yu}-p7c4GI zdzX1X-R&N<%Mt{7&-Pa~KtiLpNi{mp$#FA>$h~ByP?L9oN#Nb=Y=75{ z+3VECRiCV#PfTmsOTINi0i$&`-?`TIZoF`3 zy?^sFu9rdc!#Wd-Ev=1rlx-oFz>BOIHP@}zo8NYSi^@cbwcWGs(Cvq0!={-pjaM-7mqDX9ZJxnvO+DX? z<)8CLoXgJjsO~Ih{H2TA6Y!j1>7;ex8hWP}Q&ZcQY2W-T+3TEne`i@J$Df?FB6=&} z;Bk700kzL+c?wE(c`8OMX!y@n}|GI?FK1wTfI`9C8EVTy!nvUz7 z^_Nxqmx|*&3VFp?2ZVYVzNq`i{c|c7YX&z}a{#&i34!=~1{4D}xg81?m}3I|HM+a|r68S{75LG|x{ z1bNg0a8@VHrM@N+e(+sNkqmSeQW0u6isqV^ET0%(;R(vcPh#eF{zwY1ZjppF>tqHl z8cS+wi#A?aJNL$lC#>9$*wt=K4qOum>;J@iD(_2`VIC#eDcDVE@5S!T&N1~T0=9IT z+qRNy@e=m7W%aeUuvjKcxwZ8Rq|Ek5)CMKD`|e)lPH)~tEA@WRW zMU)bMij47A63ph(I5mqo#&2-P@*e=|*cqRl?U^P!V9Jtbb1EVFmxSz8$*B(j%x%`X zIa!V%Okq}aioMba+jjyS><3!A@T^3OHMO{iqAU4k2HpdJyTvh&(8Y&&=x0b7 zTkRYD%e1Bjs~4%MMCuEFbP+LbsmFv)nvK)$v|;awa$m(CuDTye0YBXWkECkr6&3Wy z4aE{9DH#a1?v|FhUHb_)KE!kk``U8o`-5&{WGlr==c@~%sD#s(snCndOYS5w)MZ1* z@Vf8%dwCqlthp6Tzo32hSbFC2i{evEq6z;ylE6~aIk(?M)owk1Xm&MIu75QRp0DkW zA-K+t?HC)H24Af1mP|P~NDX)9-Ov*5CS|_%^~!Ox@BNUAvnT#Vk9M)JnSj9ICyxA! zyf$vzyL1<=z&s(EQ*iN>I#%}vf}+L^+?hnE>aNN*@r+GUZK2ckmz>8BMtI??4<)5} zg%%fr;&Hwv49d@cH3&&+R3$P~lO;At1r$t5EyjM?m+lGY@n+$t0NjwymY|u&2>vFQw&E?QO?gx-RK2`-Nw^=!gSIfY!^Aw>R&F92cHH=e?y-DyVS}|5-o$=FjA^Jn7^>WZQHizwm0*EhB#@ z(Db)?fJLXkaiZmUSl>=m|Q8I;IM%FX3-kGzoa z@1hNT=*MHpE7NMcmCOJJ7uU^KGpY^;3$a=o!iMU9qm&a*VPA<&V?{JvN|}p%Ds;Vc z@$Jjk;ww~~ib>0OLSW3PEKtE`#-<6?-IFxYRq?TD*8KLLFNr=E*;}>DungzU`a7(1 z$LNA9QSHWHQD#$rRs?#zGPQZpM1w9|YfAlczK8zrKj-@Q)C17a`@C9#C!RQDMa`{= za^ER`%xP#0imPohfXf%-0!^FVg(*7d>7U#h%A-N6-=DZ;DizL*b5{nh5i|n1NZJU8 z%_4_YsBJEmChQUSd5)=I#Pd=v3d1e$B2AB;0sh@MzYa~9{laRv1bLe)WM1(o%+T{> zr302_BS3n-fkI?tTj6-&n#nXOyqm z@ScG`DMR0Kho}obe*oNs{=HGQWqwZj02ms)*FtzfvDEf2T`Ictg6Z6z=y!XC$kip^ z9>n(3Shm!<#~X3l61?*4QPtXy{BoZH{g6VR*TbH?rL?ENwu|w#yGz@k`e`50DsvNm zS@PAr%WE~BmCIS&7IqYqHCxKO+hGeFx9@ZGB;Q)COb^Cuzun!-FfjTe*7fiDzlCG{ zg89N-3 zjZFSRNvs&>_-R8v5#?3Q^Ru<7aU@oM&i|WaKtAw9u&I7gHy`ubx1Rn5m~Q3Vc6O7> zPk#U1`!62p)Q%EFd=BIF*QbW2ruY4E$1^{vWm}VD^a(v-H}Gb~N*R%j z0N!90-&Cq%E#KGQTtM90Mo)FmanhJs#FV2y_-7`6;^vew$Or*TYp)n;!}++@k$ z0^~JSrfRwY zT70=%ok%6Kt}sUQ4d#0N^2M6#jC*i%)1TTE5rM|X_y2$c?yj}&;fJn;Xr|3U_=G)aeEo9C5 z_rejE7{51J{TgxqB=<86+Bm$X4SU5w()yNOPned*bSX9ie!{Pi)o*2aC@lKyyS0Nju||pAmaM{{u>_I*Gb2zI=^@2 zzz(XSZ#X|h$4XxQ8ccA1lDGVTj@&v2x;&%c|6CJm(Zyy= zSyJXkmh@>cRXA6&4_Zld?KtH3iPfXD-c~q>vD+te7pqhJy3j^{$w2jFZl%k+p-=qx zc8uDMJJ!18w-JnmXhPSno4yAC2oVLV72cZ`J&dpey)1q9@mCHl(XaLH>SwG8o0#7W zgD%2_J_iP}1$}d9nqx{0v=I6*n+xSYztHS>hZ`EIB^_yP@KS~%*HDnYjwFlX{+>qV zv&xevsu=b)@l9TTR?Dm>b|nrMq%Ot+EEWbWltzHpzDx13LZ>?F&%B3j+HZmsFEj(6 zwQ&6Ln94DJ%K)9(D5O3W>Ap*Gz{ZkTX+c4}IG^Q0!NPfq|4ia`8;6M&;MYprZRL-> z$wK7i3Z@MUfae79wid@WZ&SWfr4)WuD)}5Mcsk;Iz2Z-QI=?w;pL&fMm7ygHYOyO( z)hhgNsG>86?%U_CK3*anugE55qB{T5N9Qu7|5$~2sAUR1cOm{{w`=(TSk%V4G26Gv zp-&|E@}piog@+}*Y~q?QV}sECB76A|)h9aB$X3L~wHM>){N0cJ0jQzHg7g(?p7$!= zsUk6Tnaan1uR5JSd=Koh#uaE^z3g3(Q!o3-#I{P)3~>z~w8iPZYDH{EVuQi)O&xK4 zT`SyKRxB|$Y7HTO_w8VO3u=V0W@Xu6sRFxrAW+K8vP20lLI%BtXLI@ikdmCYxKxI4 zYkD=4_C=J@HUdZWDRa8=DVwsNw=!{IQ2NbuP1ervlUR;>!y>x$W4E4I!S#Cnl3ypq%`H9eMCRDxwBhIL^LSG+4 z^OReEKfzGVzXazhw=M(=tUF?+vY{DuP5P`iW7!-RDIaZ~COND>0Pasyxm$kvzI*`G zTB6E;lhg77xZB2mX5|UCRUn+olrWz0d|E5ZQg)ww0OX-J$uvCxRvrKkfWOEYrR~cD zAjeT7&nfs_+tPyi0|23xf{_r)gSe6UBKg;UxQo=SuKmXj7E0l|L$I2e9}s=O*@;oU z1jl^ya>3~pbF;EtvoTKC=kvC8yWG3`S-ZA%x4%e|EqEQuvaFmH+%r>vwxla zFsYRDl-&yYO)2H|K4uh-Ayj9czolPfQ%=8AoCqSCDlki5&K=I%Hn~DU zQKSxRnz#(2I=yAh#38A4nDhzzWb<{%1II$I2Rw7~b6Ler7j_m|2Rzq*jPlr3M+Sz$ zDJ-vX`h>Ol)78pKPmP)0JsBVZMLhr_qmE^X@{b>%bb$5v3?F|U;__jCol+QVfWHHq zNm!>K4g5`Yz#0_gulC=Qg6u*0R*z3cV9f+Y(Pxos2oMdzPWYiOP|u9kh-J}pHvQ)E zW!WpE?O7B0(buTB6JfT0HbzjZPLJX)wq_txHC9BDjd1`2P)$}VLNkDc+M4*9OQ9z{ zL~(~JTn;&otsOBmK%0kHK>=!ogT8AcpQ)9DH$fchDuGRuX|xeJzsBcpz-sg}cVYy+ zM6+BWdpU7vl65R@wJ_?0h!O@hieeCr+NPlB9^#7)#r#;(8}Xul>6=@+4*pDh4zSW% zah|AxCBlO*3c^7iiaEFHaa6_{FBwM%3Us0bwnQOV15vZ=97<-jI%((B6EVV8T4alr z+L+&%Lo8MhApJZh)E?{62u7?#v7)Ucv{O^+$l-89Dq*cg{ajO>4C3yO^ zT{R(N*zVGQ3Md$yXaN%^Xz-7E$^`W+9~wZKR0Z26!;@I3gV7pYlwS;ldPcGSd9+9diMc{-kyxZ%#!Sb@8VGKpGoV}gr~$7f zV#lVxrmqRDzipJ{CBElIK(_lZ|N9ZIr=7WB+}f=SpQfvX7v$Z<@rBCDc5pq8lqCjqC{cLvadZTbKD@TS$<~E?*!~-+ z@m~QNb{eGmpZ|7=vANdR-m!kt1cG!hL+8r#!mskf(6;Hr9@GO7c)454$ma zl{)26Q#}$h`T6+~u7M5bs;~e~FyR0wI~2ouAT`HB02H}U^0GU$3IRn*7Pp*#;+oJ# zEBlgIQw>U7&WkayTO+-8Ax#hjODF>;zHuQ_Q>wDo&mblQDT7b#*tP2^k^YyCgv&?2 zZdw`YGA~(BhRYgtlyBELkII&@B@(Mug^Mio!0Cv|K9sE4J_&f<+$BIVfjr;03+6fk zqD-Y-{j832XcGWo#50;tDbI!w)3ZI+F!v8jxuoYbg^e^tIp zc;3!ZLzoSU4v#1`R#2-jMQUogPg71-{#*D z1Yah55I&BJwRP+e&YUyH;XF@D4SEyL@mMSrvkVs^|JD6Hn{qKT@i0#jfx5*na-xAeKv0oYES=NYImgyCDSHWG3vD2#LM!ZUNJ&UrYL?omTu zF9WNOdZv^FxeN1D%bq=d0N8ZPB!IHTfA;UO{C+p0O^zXx z3+IBez~~_)@@2#xhnFeX69nhg+?_<(YR4giIUWAzN7l++oM?=XM*77c4o{{kxf@s} zyiUa6u>z{)g8U<}VzQIx682*5v_95Abw9}^6vsb55`$YRT~iBx$4r>!GO!8^k2I<1 zd`%BR1t~>HFTs?IA+K)k8O2Kcdi#*y;+VMrBq4qE!AqJideO)3CF9b z!=}0P5x4nWau>FL&sebMCG)Cz5g;T;oK(;8q?8BYBEY;6yYJBmOSToZ9{_5m3keaT zOV*!h6VurhKZ!GDiGWFnp)9LYY#Nc!FP_1lVn|@Gh{Sh+%IGQ58Sz*#aMuB+y*WAF z71nuvZ=lXi9A}BbS7?M1F(`yS(ledG$F$_x7m9u>yCva&oX&D~6&6#S^wK}DH=i0- z$Kb{a(%S9nq=U+98`jp|Y5eNjqC$>y&2?^=5f)`7@@>y*_GAhB#Tf;K@s}Mn;07sq zq+lYp4mGEQqlvV*6tg|(1;+);iNXWm=L6tUc(RoNn!f)4@KT*_jc>eU@Eh80C_yun z^IQ)uh@B9BkZ1SoFpV|eK}cG^L14%0Y{Mpk&a1cHn#|GBXN`G>!Dydr+?x9C)*7Uv#Y+| zl#Km5HT*Hri?t-HV8EYF&JlUaV>i4wk6ZSCJ){W`m+z`rY*$R^oErO)8U4-6+Wwmy zU`pO~QaRL}-14Td1xY~1e@mx?kuSQEEM9DjUr}4{d7k0Wo;KfxoOVFGdRVOj=p1CN z)4Ly?=W*@RrRG(7`S31sw8FDh`C+zy>;#LIN#0sRrgE>h+vr;ZnY z@bm^0^#eKm$^Q`5#2fy9E!R?P;{UJd|Bm>7S8$m#Jnkt}bP7*Yzjbr)cyLn+I?k6M zOR=CS<}xz8k0_OYEbJ=rP5-rwOlvqeke7e|ud|L0Bu`#QTCeIKcmJ)_!Zt;2PwMJ= zu3Ep%wN-$Vgp!=R1P{R$R^ma+1&hQ)0p)uDHL;Hc?5}j1&+;jx6BOe5*5r>tO8Z!5^2hdByDTO z3R9MWDadl3VBT0YR<^F$Gdt=&T^n-#(qG9A43-7MV1g-sx`diRLG+y)OKcN6MhNAt*>Snmq_N9S#ByDt~dvL_43ieCkM9d3y{kNLm6_<|g+X3&Q9@yVX1f!=Crb44LdT_V@NTpKHxp8{>8aW51$YL#f=mz~wg#y9pDGNK8GJY@WQGogJyR{EpF_534*WD}jnE8q|CLwGA>W)|nTb&rGpl(8Y?? zF}=3&udCxEB7!WnkkXQWuH`WdePwza}g=rk(6H0tMeE4H9W3}<;B*4Cyfk2m~4j$rNc#8yyK`_mxVt+9_k$DM9RdV*3I6fC?|1L* zS@UCht(xwxf2yh4yL(MHeki%IR`s~bZZ!e3+?67Y*b64Y7ijjvTf5?w0Z*%27pMP; zptLI)a=XPs#MW2op?givDtl?HA^l$(dmvN7CczR!V47gZP--lsP-^6sKdFsb4EWSo zW+tGsP)-Kg45u%Rw_VnfQ7Tu{fuaherY0Qb%%A>jfA(L5G&ePObPzfWk;F*+^jlxf zt_rUK6Rc=**5P3)MDqVl4r%>fDmUr0`z3Tm;vt2iNg=;e5@y;+gB(j^@zB$ORx*Q( zGfM7Nn_0jrM8v;V-1+odCq}) zoMp(8e`Ka13*4ux^&`$Cm1XtllrBVkrMMz@>M==1vS5TE=qrVQ*$+So7H!6V3S;5_%>UMmCPBIXxU!XMuwre@MGZphc;Gtog|tXx--Q>ADPf>3$QFhk+6zW(RQcqo_`e-<-R!IbEyhOCaXLP6_lG9Dg=g$e>$ zVg*qSqU?9*Kay;`MM-Dh4P_J|9nn2Cf5N^YTZQ)~-gOEOU74B=l0ySU{~>@HZB(_b zfT0qS!|CM>a?z|at~xZKR)U(C%FK@Lcf2+5LWpl>L#DOs54pP;44e-w9* zjTl`wRDUAH%|XjV-SpkrjDr5A#N z4c?7{wH9PTgM|&<@5I#-VCQB(0- zy^%afl7#w@=^mN?`_b4w+e_YZXuIHU9lejfcYIh6G+L%uygZ_Mg)G$eHF`6m8)+1EO*iPZ(W;F#@RM zpR}d1fCLlEogjat5r=0wJv!MM{wu;vF0criEt!HqtH|^}L@ias&E{^mlF=1?rm=eA zjvey}eKFbSpiv}>y+`fCe@A0tY|w47;Nq}A)T|0M;pl4ka&u@+5y!DTEmPI1k#0+Cs=e>Mb>@(>%YV)nu!@far@lu|V-iHvs>G0T6$HM5cUp=1*%XrKC) z4TpZad_y|<0L)DP;%Z*wE+JM9XA;*GKQX~7pr1*`*DCJ7YUtnxW0JEbtbTzXRSu9S zfER2044$65O}NxQ1r15$$=Uux5M<4~pOKgF0{~U#7|%pOe}TM(U^7oRW03z6Of@4_ z(U5rqog9+}|DD3%H$rXrh_pg%V`Dfyp*RVh)U{*62++{<2p0j#Rlt?pE$;4naiiD? zVHkP6T7sAqLjg)?cnFfpeoKX;&eF#zEO1W5SDSYae z=FA5GngX7z@JFf6Izq5fy_jQ6gxCOvsS|5?xGW|ZUBTkNsYrQp7@)#`XF-S|2TSZ- zb#hJ*!_!D$_8aACllVBX&UEr~z?`L%L;I42h-+{Ss8B&B7nwRhqi8Mgd=VdN7h}PR z9Uv}1e@&Q;YA*lI9{hx~!$ibmr=uKg;x3G1YNjl`BdRGCY)+PP5USdRNe(YsjT<@q z+3=~5^cEhim<5(lAxT7+pqTL8z2!4(JQLYkl`QbZ7 z4eX6Ea^LnRKTSUqN|snfmPk+WAC}B6K-lxMf6N~hGr>Xv{}Y_T8hHI=IvM&%4SWA* z!WFizfwEY%se!U2SQRU8`M)}9V|cLuhEpN9v>_L*`=L)aq9*IAD)9K9&LO0WVf`n| zI6%@Hh4pV+`*_!Y)BszU@bn+@9Sbx~xZ`KSZ+pHTz-yGk`fnTNK%eBF ze^>zfpQBK6;lj`Gz=Eb#c={ydNg8`)@clK0!XH~K!1t4fX>xjQ84I%J+Wd!bwYC2r ziTq!R=S#q88y<^YXin!O_sTQWWNz_0i(AS8&M}CZD@gLcC5Qi45<>qwMb?axlJft| zEq@No@&8P0W3i@Ze>U{LYM|svAN`+of1cgwSQezL*W~baF%!p(ylLO%=dxGsfa|hX z`v8UCyPk&p?}-2Br=U*&4#RS<=<$wYAv2&5rLuS3_5Vok@4qgRV>cxSzIb>;b&R`S zh3L5f_dp7CD;q+(HVq98<U!;OvfA%Qa zYFCA<@m{HSP;UvD*V%C{qVz0R)=tUafOgZuw13Bv{kJ{1<0|jFveblhvY+pZ8viUR zSF=iMSTn1#)*)6(8@VtdDUsjFdgpm(d#pbI`nz6R4zwraz|RgcFmMKYGaH6oi-U{t zb4XNT5%9!~+a+-r?Ws*oLT4JIe~8&}pwAKJKnBz*p!W8XAuKvM&=ZTmF4`w+qeX}K z-yPdwApZXynIHfd|93+s^oIV~tKDld*8jU76FR{&gn%OQFfE6pYC2;Nn7#$Brq2x| zW+9$&oKL{C1(@*!Pr!B1&>aJQ8yQQ$@YOa11>Q$$5ic@_K1-Z*ACf1He~EiwrEn%H zh^0$-tShRsbk%VA4yE^4Scos}`AJ=?j=Pq>(q7X!dwmc25h-@EMQ*Ml8GTJd^N>>< za?A9ErC5#yY}LO}zTXQXDb@Llx!94)mv#_r&r!m}!ahw4XF}r!HaL(?p)c_hA|nzq zQWw`x%ISfT)HOQ&W&|qOe+-G+R3an6iKK;}y}+#S4`zI{#*w{In=8{vK94k=>ayU8 zIE^&&qIbD-yZieA;3571>=nwUVDbYAbc`~LqL4C*#OS!eMG`C#>=#7RJtmVwZGV*) zCiiqF4E%$UTNjM_(_oQcE@6<3xA6~gHx!i{SMCa{-3aY1H&`w7f7Sjp`=v_K8&O-H zxXsxARe@M}9%$=^&$y;k&s|Ms9egm!G$KdU$u-IL?nek}SxG7v0=ECjoe>WrLo5(@ zBeW%1;NR%PK<2?kxd$_7KSn3WaM?vzqPE~XtMnUr52+<+DhbxZA(zv!d;oGj)u1_( zek>sSyiiUtbM+hZe?A04`_Db|nj-M+M-JORko`#0S)v9{&{I^;BK}og@=Fff>HD9) ztr(~ftm+>{AAoSS7-OJ=6OS&XU0i<4@1dTCMM+7(mt%DEHqiqJn-enKn{Y=r0HZ`q ziK!htnJ9c3*L|C~l2HM9V5;Llhe-}T>ZnA7e0wAQ9s=t0f8=dS*T7|AkI{=rC)I9- zVnb=RNb?&mw{!w&^U;s$R+SvXVrj#GS6fhjGib9FZV0^V$T)j~70MBm^c!ySnzBIh zMnscY8&ES&B`j;~-z&*pB9fl|tk+vYsz~L>aI{fjDE$E-dc%LSQ7ey^dDB*oj4x`h z-l*^H1JSrPe@t`{@X6<#12>9T5$1StSf$#U(uZ_eIRNvQ>?jFkvruMG0@~}0*Eq8w z$1rf3OpwrZ`6?Ou1$X!%VdRU!?pR$^d}RNEPn|bHpe7N*(0jR1@!1AxQyE|S_0kT# z$3WN*M&3bgxm{3=*3o3djG9{Ge}>l1C4P|FaQ!f&1KB0bkUW!g z%WG;CTF+_-Djjb&1TjBK{CJ-i>WUanl|KN#OEXLighJ;kaJ3O#pVII!7#JsMXo1J* z48=Hu>ERVYFdKHr-U^ZvD2kv?GgTlQG;MnM|(6uOy)*K z;-9?9e=<1{`+I=;1TD2|;Py-&l&Jodu2WPjt3KtXXI7K^(1Y2P3Nsen3)2JsyQ0dW z6JpsKDSH{!KMSejU}u_QUQ(-AXz|1-(go28&T~6mrNl z>S|-q-HSR=o(+-YU+5ZYaaHJz;s_YV#!{B_f4jc*x?_i{Q?$j}?_2nM)tM0bZwY)G ziYAZJ)wa`+2S02~vi&KR;$`#-vm9xXP^N#2oZXS3(#^ERHRksIvlPXuRL!v8UN%!H zxkt-LS}*$gz5Xoe7w@wMOg9yQns<{BO?8jiU9ifoOk0;imDj^)x|8+%r%q zKP?5eRb^Z|zdNj1dSE#)H^6b;1@lu8e+fvvl0~HljkV!o2f6z8AHFr7ufp(>G!;_$ zr0ET-ha6(o9gvLStaT=Bc!dTc1^D)eKInl{$6eSUzErV*I}tCa$SNJi+5E9Lb?U&Yifx@_g75#t3Ze|c5NQ`%QSwaheZ#ZDi9(BM7QH8iVilmS`hd;>#q zKK6#{e}PEho8u@guwzuYrpv_P_Ke~FYTP=>l;771IR*7}(3)7Pwow1TIAF$q+n1_W zm_J5jCzS~<_g0V-`b%Ht8GTZ&Q$AS(W@S5PT$Dq>U|RbNpZIfeA}Os>fAkoB)hKc= zzYb4lQh5N5FKn@ic}7u5apjyUHbpKw=rQ#%?s_s*T4+Op9wC%J>^LsjSC-s=hQ6Kn zz_A4@9nRC1z$-kG#Ma5Yzaums+@48NJX4nyXn#4zY$OJ6l75zrG=7voba2%FAY`Io z15rQ`GRC^#nVm2AyLSNJf6Ft>vwGAN$1{qkm#r!MRdN&C;xA)jpZP6GrQz(eo^D`Q z0cw3ud1k%ZuvV5Iq#Gk{9jmUi2$-0o@E{%H9669C z58fg51Rk3%SgX9u?)I*(2sj=r5O=|BlhFzVlmw!&6244C$pP;Ye@h4TccgKz35*$` z9JZ(msP4rJp`8QmRERxMjSBChCk^QM3&I}0;_QOhgucVg!5%tSYR_S1i`WI*+5fC{ z)rmQB)y4Z&yNs!m{s+>m;1ZJEf^5^!E71@^E0&5!&oy-21M^iffteS@97s}*JGew* z=B`1nG~JH7`HhC=e=n}%4=vOmUPgT95ba=AQuNcWjv9~RRgdxHZL|;Cjs+el0YlgfivEnr>npRkXnz@54>+%}?u+b&*NJ>d5*`Oxde!SCt zZ*9?CU5y4eIQ)Afxilp1eY%g7J14mn_LaQrFF7u0r?B+of3C{GNUN!DG3K(*Y%xd+ zqUpn|O&K!evvgqtyN)V|j2J7jKQNN;B2|}|uY3k4dt#tK?UO3RG7Tnf7D=z-W*6*n z+EUA1Xo_eVw2pt@LP_12ZZDBKjfm;dW)D$Ey6O5a5qB(zSefQ@$7xrwPa-)78T)v9 zS;=RaCr5~ef1q1JY+ax=DPcS}G|eOV#TxN2T!pA(eI+iPdfo~%f%j1v)6D`i>Uxx@ zlal5`h%StL4>Epb%=jHK4V?eTS6(Kr@;o6+(k%$jp(qN}Dr1LF7~SqIF`flL<2kZI zaI!;++C2%sUHYB=RRv=(wSWzknNu&g3oXwXX{m;ue_3Xq>t?UpPR8*jW%fPnx<#h;U=-q+C8e(n#W*5k?|2i8|AdqF<>Sbr)ssNG4$m5jEJUn z^xI>&%wRzXDHv-(p5h(4;sUIC@m7SBp^HLB#PMDh(?zKBgQ$_{_^nC$ebn;ct~VGi zZ1zyOe>sFP*fr@yy1rB|mE3AP+FJzzB}**mg6J^;bo=EBC<*fpAH}qBCC%>aXrI2F zoBU`x;xmf4KoEO|4U~)qU0Ne4=0rKG4sI8iuUL7PcIv`9+UEl> zE`7vAg>uL<<{GTvRC+1xEOg*P07u1)6FQx5%&#GmK-Xh$2yAkb;xIgdEmI< zl)`Dvr>iiUDeh|~9%J>zyE>5;(eJ7p-1`UpU}ceEUgqGzJ2F-FPW1fY+5N+lmwq05 z(9u%EBUR|TZHdNuZ~Bo#9}n}l!P#@Be-8jK0)dVTr`^%$x!?H>&R5XLoG;}>yd;cY zJUzq#o%A`J->7ROA?ZrI5#DhCc61P3PZFEVWKY|@Eesv(HGYlvyReDmA5gSP⪚N z^xG~~>>|saf$12ENLE4?!+fGmcaUiUkq;#BW+aCCbVSiHBsk=ndJIp|0*Q{Pe;(`y zHQ<~GgM!&PG8@wwb;`oJF`?X{7|c-Yy{D;_R-v-D@QZ<}K^tuThN=0^%;-H4#y>$+ z$24(W7J8>=`o$76QfU=+pZ}~W>>eabD#HWUY#bC;Cmyfh!Aev)PNzTnc8mJ`qWj>` zZ?sFgf`Ij9)OGul9l^(wws07~f5_z+B;}s5bhVbvc#1MOZ`GUP4m@VZOsLVj%E_dllC71HJ}Oq5^bHXaO!0y(`CVM&_>w6tD;1?FIvX5u1Q%2SLr?*=$= zSgs4;-ZS`N2f1gVze=&c4)cxdmyjJ%@~+iEsUb`^`8>Ud05y#$jRvEQf7VKWm*icJ zXc%7lsmdmP1lbhW6Cu$|tW-dqkeBRPqAhX)b3^i(Vi5QSv0zx-)qMh&L{lsQU&dCd z3}p*>;%b87A3FJ6IsV<@*vUMHB54dbax}~qbT}?BSQWJ|9z55h6uCgrD{)kj$&K4T zPIT|M)y%1^zvi;=?FYzCe}~Z9vW=!d)2ig~8dZFij&-BOiNi#B&afKL8Q9`nzd4zI zZr;JV_a)Q4Cq*xTSqADm#4&`^Ltp?<8)C#16%0FioP@gv*s}$OSL!rk)`&UEE&!t` zC?m5p?=X{sTumDO@*MTc588C+ulN;B8df)jj@6|j&t766Ea|v+f9D9<`->pO>O=qG zQo^pviFa)t6*6iXL@T~~$Ji(N{^Jz0gJJS2w;sR#J_q|TykE#d?FJtyKWUR& zo12?<(Kov(e7j2o{AYn>bm8Dz*v;KWCca?4Bu60HF2jGBr@dlr`J;8)DX3xNjvhK#?}LEqa5E+PE<{RHH`d?vRhQe=erYrh+W1 zhwUE9Z@Z&_to0;hf>@Fc7^;?F>qZs0;<6ukMYO+hOv931*q&i~jIdm&ui57j1;r*i zgQhuXod@DgpM5g870R2QnFv|O))DcmV9hs|e>;U%9iY!yan(pfo+o+VNobhRZyu{m zH#1M|7_5o$NTh6WC$@GZKLBI4bijwKNknk1gop_T_bF!fLWvXN zc}nS_E!!{V0zysP!R*4P^iv@01w!<*rhLg!hQGy6kh|QsYiVV@x+cPOt?~;etf2{_ ze?c+x8Yuv0z3rswGLf$|v^cuSNIpn|0-#f(CkyKl8D(?O;2G%|uZ}x~p^dp^Cm=dT zl0b^4qOvj`t71L~c};r_*kd7Y*XJRgvf1(rN3*v%y3*@uZIcP#@0$P$gOd>bU3*WA0IclYoS7QGOQ6_?*kQ?wM2H{EkOL|q7 z%<3R}+3H*LZ+}F2i@F8#1xL&ZZV^ZtIyavq*q z{k1ELFeh`C5xYBPZbsa~07m|n1TpCxgPtEICAxo>`(usT+cZB%9x9y&*h69Tkjx?G zlyS+2(!`!L#^l)^HAMl3j**1ze}bz4mm%TNC0}XY7830uqoOpi?nyW060Z!6RV?`5g4^hFHbREgTZj&|;7fA2EPNDJu>aF!6F zO*Zrn&~2byoRbV|f28h14x_Y}QM=lXf`>o? zyVmc2=Fe06*xdXvg*h5N_Bv*F(px}%568DZGcucSdl^7T9IEoZfri;=F5m|s4Doh* zqF3vso`voQD3vc)AoLZ@^MD`G@VD58(C*q};EB(8#}CisuBt)$tCt~lJd);KYyV05 zfMmbdi3OrIe>vjaK9M7HU?Y;Ah+B&L)ZJK{dHZJDH~eq)r{dZo!me<6U5bN;FtfO; zcM--o#nEbCp)_XKiY^}FQW>^%-HT$_TM?xr6?L`n*uuDnIpq|dX;ic!N$^Zq*2vup zPUdht$Zr3|nT;kozkTsc@CoKp>QwT>Kg}?t<%qX>e}l#C6EfEqBCmurQ;&8@YnDQ{ z1!G56?%^L3HWqyYI>5uRZVla25DZo_I$ig-i(8}lUb;BA49P#S2WsInk08M^Z(PG^ zu+qyO(C~2h_6rQzA{TDd0ip2x4rq(Icz}8h90+c#ZXwR9Win7<22Dz6{zgcmaapR9 zlkv$)fB%Bi`wC246$^)%l+MyeFw#lY$O4Tw3k-SxrG|M_9X4vLdKcZ&mp|7XGKF8g z&9g5n^TBtI;?A~}L&5n=|hf{=3&R ze`SZX8l)^2OpTsOyR8*u@50w4cn88t&`)Jn!@PM6DwPhSkIgMrZ;7(@2XhTKIVwe zpz5N_VT$kamB$_#SMg4)qAneBkU^Rte>9IiXC!)&tFx`Zu0m?k&X({jw>ZYm*P0+m z<8r|u#j-g%Mhyi^K_2oG+n|P`&dTB4VY>ArHq=>FHjw|qJ7p;$|I1gmiu$*i!Q&cd z<^=f)Kj&!n!Uf~LzOC;Yp$}_5?e0w9i~P~ME)uKW7bD6ovIrL0u<>|c*3j~Ie}7yz zFr~JrQ~JF5K5zInXQUDAnsJ^{C%jC_lT;5?xxxych}yInqRbMAUmxVeWt|4TYlG8jHWQ9_sbI zPv_vpstBF>b*5Wm1U%KDP55iue{>QZvpKMRiX=KPs(qxRVD*e=4f?lR3Fs${(FFB; zq={kDAuR2(uJ8msm&b1{qlC@}%3DDPq!q>qL zN(So4Ow-`T(&=IbURLbhbv(!I^i5lX8K&HFSi}hR3C+xX=9gv{yt7Hge?@6#mVABl z=-NIW#Ui3IDE>LPpTGQe0;1She{vZHtig4g5tdetm~ND+RNH+3OuXaM@zJZ92yoc% zTQihbw74=G8>NMVxWn#4mdJmpRu9TIrLRjED5CDy@lk0)q5maGwzbw+i&N>QRt(xA zZ#YNiaq|8F{~&>)W}je>fBpP*7uG<-Ymz{{e_X?(OcA~z%3j3!+jkXr@>raeG5tBB z2!zqbf!Oym+7qKOB!11Vg7?C8GUWKl4!c-#;xYbH!1T!xf+hLNT!VM>$Gb&pU4Q(Iy2KB5&@)0Elbmr${qo`0T}R9 z%T{o*o~dn5Q{8?>e~R|RXS~HbG@(c;SB8=Hl+5C5#MrXgZ*YoJOizIND7@K=E z10zmTArDd6LR7Ldexhv6Y#Qaw~`ZCOC9Ax?0IE} zj2{?#@XI<;L!Cz1i55v0<_+@d{f-D}HmK*ybaHJ7Frh4FKS%gX40gA1Td~5)D@(1& z$9w8C`S3ZD|L*Bt#ZD=YU1C#&8LfpYHAV&AE0=7PEU(g1V)mWqR;#ssw?JA$V*Po^ z-bXyw9`7lue_rnM0njUIM&Ee|1ckbjNd%hfL%U;t7qsyUIWXx+S}eGaZ3}D*O67nm z3D)3>b%T24w}^-d2%0y{MsFc;OhBZnma}sPejGYS)|%TLd_R7?2_6@t+A4!*wOKe`62|+Z1br)0f?}n5zkq+9O;E zOT9+AhrK1L`}ojNgAo=QH-7KY9{x?r*Q(5k?)>)R688ks=e)Ml-RD>QOe*sOCZ6XC<8SbXD-e|Uv0NBI`(#3rA zv{@C_B@73sl}M>L=ZUKuo+e-!pa4~W^3WbF6NoUISm68`$RNjDH(j-Rx;0 zy54E^l3RWbtKA4;f9C>Z-pqrZC}fE&ax#v<@Q5LMsJBQ}#^v5VQ|7a|U`^|SUUkyBZ>RJY*IJ3Vbn8~RXtiNvVGTK#eVE}Q?se>9>h z4{8ZkujtnY04~0O3%P|p9Tei;OwwRkQMI`9SZ6S!-R`&3Pt-5^rkp*XPJo0-;LRAS z19PW?sK-q;QsGI8IrTKIoBx z`f@8Ox>J<%a|0TXkdF_Dg^K!#e@IerJs`LA4L0{d=itc=nkkjxId@WmhCeLXxddIm z%ozzf7hV-eX9;AU3D|>)?xwP}LmfLvZ(WDgU+xB9b<3qKO9#^rK7?kGEscX{Sf2wb zv|(#Zem^5UoB&thGh85D+UivwC1#9`VvvhoVypvE(q{^ki9g*qQq2Gj9 zhF4z%_)QlnO!%olsC?3HSOcMdA)-H}#U=i+#{UpS@4|k#L@cK@Kt!~DY#2_xeTvh0 zRbW8|nRQ$VlSh3mudnacf3!Nok26`nA$+eZ8AQ+RRZiO?|4G}q^v%YK{`srwC9((9 z@=*unTCdf2P8Ve3m}U`f3SlU0d*poCSct_)ol;UKf)7C81r%57#bgtINB^%zVfcJ5 z(1YSp43CEL2-yE^XHe>>_a#M{D90oRlm!0GAJbF0tdklfK}_<4 z(z003?jY_1kcCN^9-iK>-;mu7tZ5vdKo5_uE+de7G*eoW+*2W#OYF!0Mf4Qn%8`;L zgU15AgR8*p&?VF-f45)gXh1KJ@fhquC-x5%5d@P}eFP625%Pom9~@8m`sgfT==+Ac^=7Y&D-T<^hz1nWoGmn?MYzi6+;!q6`k5hIp z;NmJXAYdy&k1AlqSUAeJO2O(ktf4Q zvDdI)f2`JDvy`dv6=9w@orP(^h8(?I=shx$LkHl1ABd!2$L5?ng$YAN6mc53h2Eok z3lFm@#J-HX3JB61gyB9u4ZKL54|WK=S5NxPgz3f#g85CJCy0h7JO3W(^<3S4lV9=N z&UoDd%2FUmWk%^WO$oqXZ19q5Ys+~Up`d+4=C9I$st5I54CX}RCfIUX{4%fHXs z!?UqL_{Y{S@Is@pPgAKjk1M+uVXYDo#0K!9?u&kjRkMs|LuU;~16)aP zG1F`5Y(hbgsiz?%e>d|E0hr*1b7I+Ve?g>kPPBadWPrhXm-!>Q`ya*PGr9j_EPC5x z%0R49ukl?DB{1+*9xUw7A>?1HqILXwGoaAU|Y*enPy z6%Mm+aICc4f>OV%2dAs&dTrBQy1J;E+q&b|NJYOuNo|e2`xQR)I%9)=g=9uQ^M#=0 zzx`cfv4ul_CiH_QRg%8u@5keef12*RybGy1nmwJ}-wf~lU zg#7_nLHhte9g@C6wrdDWvlOh8t|GILs_ebVeE|COBrll_-=XlF{G-7wlF{(kn*E4( zfu`-Mk7vETwA=`*yTO4f6uC{9ZT>F z2J2~Vhi9b$dFk~unT3z%3@8%Bdhssg(s0f2g{X!u|J0%Ck@-i5+{1r)CEhz&V2}GW zi>KUkT3+G7MA|)0wPafSYFu<)pC8^G+CuMZ$UWLSMAYzXblROj!u~L>!M8g6-iiRR ziL^Uwe8W$f$#&;YL1sqne|Zwh?4$(^J12}dh84D{{#(LDw*D=lvVAI8mO?a8!9$>v zsixtU+P$$%!@)UMd-trdMcMjq=Iv&Rhxn2Cl-Nlf4C?l}l7%`eNQ+wp4BT)%Q{*&8UsIgJf_ih9*q1 zz7Ef6;{!Eq)1L1Je^0}NGTG0k~WldfGg;a%3**A~uVDOGvH)E02Njc0|>m)tV#X{f7pH41srylpo@ z;L1UuP8Uy-rMy}{=3cyvQHdKUeBGYR(U5&2NS`{d>sRnre>wd`-5Nof)QMhaXuI>S z-pK&+#=8Zq0T~$e1Mo9^4DwtXR_}}R&Y|JlpCqEVVE#p_4*(97MZ$Dx4iSHNZ#3r4 zp5Ff$ljYcXrE!N7a*He)wUE*EvWc$nbR&*CbGPl&(1tTnm(;nlF3fs*Vypw%;c?|; z1(Lv(PpOl}fBzgouOph}xVL1Zw}_chtNvpAmeD}lL2c(3{ciYCVja&h1Q08PQ-Z#8 z@(vpCJ9n}STY&BKvfA(|`p!LPWJ?Vu-N`vO>GMh?9HTpCnm^Pnn{54&u@)hBs1L^Z zOx|J2qM#eBrn^Y3zw(hjqg!R(BG+dD&hazvJG3Bgf3yooB*pj(=+lE25c*Sq3(Lh@ zpYDXm^aZ!w8O zjQ&6i-RkxmbKYKn;Wa?LI{@sxeF=2y-Nx#D|CclU2xk2G0T2}LeE0xhK=cz*;Ko#v z+tEYif9o|9cZx~|BXR9`yegmvy_VM)KCP)8d;okE(ORD4Esx*C-wjW2-rF;4<J- z6fajWInTPJ!kAeJbn=s{{E8T*t6aC z0YJKC{{T2-ynXL}wqd*Au@V(?HRj z315kYWd3PnjrkC){4<_|!P@TK&dHPGJ*mEJzl)&}7ByI4=jqh8f_(qn9+-kehK{Rbe_gYi>mvb;TIbAY!=N;;ML? z0HH}bDE&i?Q zS%h;d^xRU1f@V+l63<40+dp7InoW4<1^7;yQTo2UA4 zqPFl0f0Y^777ez(lOjE6d?Z;XaWGE}_wEm;HuFs;ewA-$Sx_2cSNi22 z!(=BIBaPOULuzl|+1okZdMJE0(Z9?#p`Z^F`}BzMN{{U69Z<2Bw{?pX#u9(eV|4p| zPWGQZJ@=l(Y+pSgHPb) zC4-qyd`>V>Xv`_}k%PV!@nE4KZIh5e>Nr)2XKk5& z%ye$2Z}prr&{s~&_H9l`qGLi6FnT1SF zsWQTAkC-N^u6mwjlI^vDf0{|O$7tEtIF!j)6^N6V-55%DWcVz*IM=NK6Ru7i#jgex z*rfqKkh5j-Yni!8nVA4pDVW89=~aHpFGew+$8~y-sb7)KJXVu?$Aavu*PObxH{>3a zxpF)I;28fao6-Rl~PdBtJm7L zFo)@xDTfN=w^H3mV_ls~V@ME;>t+VRQ1lpc z8J6&6w<-SnleER!c^@guHoFPgC7wbX?u>g*uN`{6>YT%af69ez6k+l;7I*oYLx&Ql zRDFrWp%?%a>}&zBDHyti_E4Pc7s1oYgsn?OK4xj+RS*9IQo}um4St+#b*m`!9ZL%CF*?*ZS6Bc%+kmU zq1sppy}BD=e`3Mb$pd4}$7=Y*%eV}Yk@3@8!$eEJDooAP4pH1lJ1Xj?wM<#vs5#$N z-S5N=i=jX2*a=VSPS@Qlim)W2Ho!S7(97X$#3HsPQMun+pZz`*u0BdzY{&Q;m^CeN zn1h8jx}_jqt34mJ#e+`W`*8a~shMBja*Mtib*#cBfA~ogTv}3=%y+AV81AL4{sLNo ztk>aqm&ExA;gvbS;OR(;vHW#Hd%9wnB9@^p?kZ5lq~xHy)%He|=b=(2w$`fJJ-uspZ|Z>hbd04{@|LTH*2a=}hyO1b=})>G}3G zbRk?#tV!T`V#P(#DF0G?g|V7TH_F7U1(B0DsEb99emZ=rcD}n*aNn5j*IBwXaHOr> z!PrsZII1bW_6m19xhmdBoZIO4`DD2u=iNQ_FsO|xSKEh@hG8D$#h!N)j7PQ?bYWBP zOHzj-jQCrVJp2~YkSW7x82!8p&IUrurdw_}BzV|${`kx_?QCv5m${+LCGl<~CeO7UDZ>Q_4loFF$*-l5!@Zu7p5c6>U&J>w? z1O`9t0fp1i4Q|s?HL@&qW^PF}a$;_^N~3BI`cJGcHmVCkmX`BBapvS=3Ka%)_5R+| zu_5!ya-F`&?(7+0N8R>q>4kjBJhO5f9Z6nKz3Y*QgD7eN;Vp!s#+^YfjLPF4we8_v z7oDQNC0|F+P%eq$7~5T5dVjAnpJR;3JmL69Szl!$#w!w2_oX_gYVs&jmFEEqKy&9cB8XmFt z@^sZ7Acy`1EgJ|lq1eVY8(4C1Hr1Wb%1G`Wvvki>I-ZxOJ*fe!OWjNYfVYG9x_k{H z9Tt=%%82#51A4g3w-d+a(%Tmud5(USQg@(H29B@B{xrLN-J=(rV zWrNQQDjkg<0Xxn2Yz|Dpjc_1us#-LZ8K?csuRt13>t_s~&~6NYw#90uZ|oBSsFKfk zIv1nK{_e%2aOtH;N4gsA_(m-1k62unN=wo65iJ+zp_chITDqb*p36&Y@tWE>f7#%v zvtNonUq=VCrG^N5Rj9sGR>B1N;*6%B4%XesfEW&7O0uljgMa6y@ z4Lw~mowevjxy`8qT@-H&G2TIKgzVM99JGl|&u=upyvX&ZhxGc|Z(6|ZJ{)O4m{rgh z1VLksrXqJ4$DoFQp7i}VrKWW<7enZi`9!q$?C`fWu~FW`%0%j-5Z#mlE)Q=}sZJih zTMBXXRd88n=~Gu* zKZpVRG-WT-NP<{z!n-+DtB&-SZm6Io5U(R)n(Nw=H^$vGFq9d_D%&c-a*n~DAT^Ct zOy>3{Xl9O(Oq!_$J&bF`jZt(Xe-@)6g_GXO`v&qT)~mR83ydG5@(cP|hUK#&@-~P` zo)anY3YpKg5V9>b)Wp;Lsyeg@T-Q3%q_%80)u-otV1|pmoL#hX#2Gje%P6V^8ayyd zkO}W-;zD(l@FKD>ZL}zN)H6{PT~=!0MR-&ePU&~27Qh}Ink=lC zc%SC<2*?IbHR1hv_&`2nK4Aurhzv!Umbj=lB9<3-+lo8nsh-)Xkk6T!UVA?&Ok-3i z^_LY#={v&$G18~SgwZ@)Uhn-hkW=sVEn!HEEGvDcic-ip$u^RC2OY-6NI!zG5JsGf@iaxzhX38n{M3+oQgF$3}z~+s^(@_!#!~ z8vRJ96p6^TxN10I&3s1dETzYTfg6*6hQV^W=_0iFqu-6vZLU6s6=@iw3`jfIj#f!5 zZ`K`e>5daHxA?b@T3@>&9Iu8p$-8M5GOCtC8rZy&CXYUPFZrxzxq3Y3s}n!eAB^qP z%50su6{opS%@0|{A#g+OSVr#cwS3JP+N5PSj{p%XIZs`MVy!TA-R+n^Wn0-}hB2-ap@;HGHxh52Xd79x3=TSoQe&C| zm+#{A8u3ri*m=uZ0|uuO{?PvE%NnoOdDXdtg4j+G@w=qE!!4Ei5S^K|x!D+Rauq$#Hz*R$G$ZXarxq>~ z5HF+!1Yr(p9|lD+JXq249F!J#>=sLJPIMw*NRUZJtH?bojO($u*6UoFP!B;i=2&vF zC8LO{8BnR^)8{Kt;a(gR$10~#>I&5cytG~%2481R6`L=W9fLMvpWO(WQP~nj)Lkbz zABzpbAGi^YcSknzPlu+!F1_{j80xzz zQ8f)QO*4m6C(VH_J9{qk@gJ0>@|cr`TNK3YQ>t6ODJeOG?Zd>GxSdjD$EYc1T2^8N z_G{D4CLVWOoJMqEj4mJkdEoSlCt}=}rEH+o#HS}HDjU!>+Gz2snm_L#3=Nuyeb#9|M{RL~r zgMXZG-Py6ouXou#Ct9Z-D<9t+8k;|=n` zK01-sC5i&o1vD>2;cAxpo|dy6x8c`N;L_Xf|NLPC16>GL+H`;+cH4^b&BM#cx-{4< z@a4~EnG;8n7TN$m2T1E;2put#)y<)Y;4I3SB*4P=kq50%;%`dP5A69Sy=I0ozmuBC z(47F@S#h_8!){n{&vG9iT_JQYD2&^WYcpAbtz4Qx5d#Ltk%9^bo>$lz=R8YlWQ!#p zjGUhPjR~%hCh_#^5?2AfV0Y=Mmt1wlj+`bQH3hQ+$8wCkC}A2^@N{bzOLa9Zz^QGE z(v~=A)Z?vjm}|fU3SW9ll)dSdR)yPWfo$ z_yHPJy+5tQ*5L7*r$s~p`_5Cp_P+cRkhp)jZjW?xU&|OD`1W`r6@TG6uZYh z5d_$6kXj`>+a%VzstbGx?q7w5|4wz7eI;%BWxCDzlC%u<8Cphn05wR_AT3T$XjB#A z0f|54w_>x8n6BEfjiu+3#9K{uOs)8pyJs)jEtY&6fzS|J%!@SH2d(@O)QU+zGdhY6 zP{SUEa?j&us@ok{66GJqU?sgwcvXL{72E_#{XYAx?fUJYmO1WI^jm}HAuUKF_K?E8 zK|y&qjY7LuJa2mUnaEJ@-o|qGSHiNyh%DvZWi`R*%Jk1PZT+u zM=n`p9`)!KuRYT6q$@=|PQI4pCC!t}<%yp^3C;-{#5m73ZEEQ2FkTaO^$t5!DaFYm zMMN(N#9C6ER}vZq-N~SwES6gFxe5Lrb@VGj`qD zWp-$o!*0!gWA47fqIXg%bQP)hJawC~hgSqKyykiMM52EfRk~WUQ6HWN*|B$W(~^xw zn$Jz!8lS}BG`YEx>|iNdEJuz8Ngkh^u$E){4;4y+tA>(OvkOT!Ya8O}*=y}ajVGVZ zI)H7YX5OBN)agX@{;V(%4T?!Xsb&`KKZ2L`wQ8S7X>{ZlrP2;u ztXirmIj>z;O5ABieGl3O|MvaU>I$v5JGLE7mRc zLC;c}5?H^cC14v};uyu<1X+#JqN*neyt*E#_qB~+Zv}@U?V^8KmN_9CkXZpH`P)+^ z4~})028zBG!xo;%RBlp(9y^B`;*|v@3BOD)UvlD#SPT`|e%#ax$bhVwOy$M1hbOVI zsYS*`Mq{>)PK}OlR`5(1%z09TCb?z;pvW=qKHSl8nY|FoogFKOFI~=*|04oRq z|BD;(%g5;KDy}7e*>#XAw;~l+g?He{3{7JlrE*d^2X)G)-0~$MkaVgWG>ABrp)?7%S0>22_IbR9ae$v zE^kytO7kaX90yHd?jos(GZ|9?hl4c{7gKh|5VVu(WD64~ZWue?eB#ObU`}}DE6zYL ziKz9kGBIZqOHt7ZavaPaK@5zqEXkE+!u|fmql`7gC(m9P)|dzg@sykIhr=LTW^%>{ zpXvlJCoa(uftWAg4zZZC5XZ^(F_wd&#egFl{q0URN#0v-+c^@Uk6k9}-HwIMULh3h z(Hm9UGvhhga-MvzGTXljMZ>q%a7}lY2xjlDw{v`e8jJM;mAmPioEkb}Mzt%#*>s@t zSUcLNuIghj-ZKgrzn((h6Uy|r=6oU{K`lsCskB19cC{F&b$7_Z{RE5Eeo*Ce(0_EJ z?U#8|G(|PR6i2HW?a;_`k;6auRO0afV^2knpgF{KWGk)%iR7PCL4(X?3UFb;X<$j! z3B_sAg93Vi>esHvEw{dM5-(ZVP@@`YT+8#FyN}stDvy~ODIA+1N%HMC!oqTPbp3iZ zV5w9OEw2PQv2PmiygF9WS))Nocd76@BUCKaHRmXV#*uzMVG4^EE1RD@?jr9^40-Dy z^cS_6a(yTKLGJCDVl!oeny18+iH9K#V|$l|dAM{M2o4C>jd-;iIN`P$!>$FxR%#Om zG5AZ2{lR@zN0UOUFx*UIU-=$RcyYLnum1uRo0&gHLcKH{{k#6 z2fu~!gW^1vix)~7cepE6WUf|?#EwWL(t5=7i3^{Em3Ou$l#q8+zMzSnosTE?Q> z@%f6;2dzwMe}bD?D1F(^5O);vYCht*R=0Cd3F|gjk~9m3txWp3*!dVzEXG zFF{$?*O?Tx$1*&bBie-eaN_QkUJEu?9n>?I8WG-f!+GTv@+50#{mBo;NP_qy5bqoz z662^`7;6+#Y0omo)OUl*RGno+nu@PI-(r?^vMJgKagseovL|id^?Fis%|n)w2@Pu! zPvFCgsk#58cPRfa7r`2_u|zbqvPjO7D(i+Dorsmib1_2av-2)y2_@1rikxsAP0;HW zD`{G7==^xE{ruB*l@ap8@tPriCA{6EXJruNhkb2p2gvd>VilPj^0_*jDK3>5vwd{R3M@ydhvZWDuhsGLn! z-{T>02(zRxc;wd-Iy~7e$b*vUzu63> z+g9g(xqSJYE{kVcm5IsqM3+Irmuj%n!BBbK5D;ImV6H$9=vLU~ZRRi>8~629*Dlu3 zC+#PwR9Wc3QZX@=dBSc+RAeK=>t2*7q0r-~!_d~m{T;=d-BQ~=FYjh~r2omk{fQDC zX8A|I-MDd0YWzJMdQE<~-wNn-k_fVqV#n~qeAz3|RIc{^CB~vFJjBuy_J!rEgcqpO zbg#D)X#~Fd(K^%KLtM^9Hl_&mWl@-Sr4Zo|u}+j>WsUGjgU2Kq^`nDXk=g$IcP<>> zp=s+bkBHXjU7mWvc*N8>Um$)wt)_eY2S&Bd5m&1}THVut0PUJg}RIcFU{y`+~BX8BMpw0&E5UoKG z{_z7o_BpEffaB?6hYktVGUpUJNPH^qzF*Zgx__l?n795)^cWi=gsv@MYEy z&zBcf8IQQgY9eX8J%`*gNOyBHeX}SG<@VhpOjVq^nuS%IbaIuWgFaN1mWam%yq(V_ z>BmG3r3qd{PM;uKgVZQnI23<_bzz=ljiJ{BiP`r}rrRxWW+2r<78)9p0wGVf%u&!@m z-y%QoL!-SK$}+JnY%*>5sGF1T2zoOX&oXGo1Z|1*g+v zvyX7U8sw%{77-yB7nE?WyINn##8s%I8qG{;7Ga7GS5|9CKOT{l_cbmdfDk36KNH?< zLBnOFT~Y`cuhhIXV58qMxp{^BA`1zH009932SMZSSXU%&CJXsSG%0EVk*WTnz;BhP zDc^}uKOoD8w-H4KKgFpNR0xQOrhY$Q91IBld!{nn9EkJy#!X?FgUa@FXn~{1y79n@ zM%o#j?zfrkt?KY3$wISbxTCFyN;oPfg;gpB`<>hXhpBO+xe=$Sp_^>S8lkA_GeREJ zm=SB-D37dhbT$A&v8Aw8Cv?YP;sx-CCtbC8_C&C~OJxDwdoe}GSCzjtX81G#6$a8e zw=|xRsRzPj^k{l>@?#pNO2 z@luJ-9Yua5@&9HSLsBUgi5reun$Au74H>dN-*T>vxw&v6u=jBWGr=#kSt|6_31LQw z;lp2%pNah`TIaN)@F2Du7wKAS8(5HNvu2YSxrHKPMjQ>_ah)fNAsH3^JcOZ+?64RD zjdYJu5UQ1|J{f%DcY{#>?GilELRL7Yj{3_Q2($tx8J7U7NVH6h`I#+=V16dD3(S2v zbbEMX7lI#_@*fsP3oaA)P+HKA*^ym>1QM0w$$xIc&Bg02t00eczrK>y(Ita~>8fmD z$Yr(XC~q1<8MJIifYVSD-#)@KdHk0C6r0W)MUaje7HfOJ!bghqcCSOv>s|Z0hZ#=E z@`NM7>aQ5;4+$b^F@5HWjOP66QDR5jR^PPu(;I9jaqLI@pf9M8AJ1%b@M<>VKjC(kH%tj7lP!h)X%FWPD34MUN!=7J8f;r>! z(hjM`n~^~8o;MdN3QMX}TRn8)(`u|BW4&%f@ecO?1GS96g@YqeEIQoD;twBirZqVL z<%Wyvv>D<`koxT@8E;=Iu9x%=K@2N$vhcN|4=j2V+@2>4Iz+%AXekI~t6u(jgV@p& zoDZny+HTs`YZyMO@Y2>a->k6BsL_CMBJZ#8B*)a>hEjkGH7YmI?mT`>p%~evSq=Lv z!DKn?;4EtQ34gUOsf9>4Wa_|)x;bU`7sa$07qU^J{#K0;NuhnxO$ch&4%PKTIK?L? z!UPC1PkNf5pxZ8Y(1Wd&NwBTjY6T(~z1;=aXof3nu65Xaa%D>DQ`nEQu0UIQK@x?s zY)S&};K7SA%R!o#HY~wNLmAPQi&fz|{|dVb`kd6HmM*@aiI?3K4%5VIxVkfvc!-%Ul*r9BjTze(7P>+?Yj9x+69VeOA^0N-|miLYci)sz%Q}ofP2A z*pcy^eN=3T{^HtdBVsbYzXoo@(hj!Hu@}=tdr|Jm%bt1W8g{Qcbw@X8iv2TadDY#r zgQlf*ufxB@fNpa-db4wPM6odQx!j|2W=croVqWyA|3TkT%6ZW(V#(KT>6__J_6SfNDb?TL9X3xhbZV{v`pt2%?7u}Mqc2-HWU10kaoBO-)eIT(#N_Cu>|E2 zHbpZ9J-Vw8Xm%mG2P=IUaT$;cLIlc`Lv@648J$|Gb+l6x5+^a&I@g0m31x;w){Np0 z(ojT7m{THhgL%^&=Ih3)JSxhaUu>l^R|Gl^xD0rlKwgs1sVPoqN4Us!lo|zcWnsZ_ z5<(zD^3cW;;1s%RKb|+4Z_gII$zxXR&Lt0E8b|g z&^~AOg91F$bN1;B9Kk+qim4~`P!Zd=2~YTfA4iB!jHFLFTQT|Q;w~oYWP6VbQja16 zsXeRn+}10w`=LLZ3^Xd?jVQDBrho@>sj%~SCCiZVl%vF;EB%q5z4N_>qhYF2n6&!g>#&YhaKzgJ--blVU%|DgsOF z4k3lHZDsh6u}-p`N-)VcJ1auESaG(H7!u{D$ku$H0i<8JX^p#|RF#E)k9^TB`1~Am zA1n|~EV3dyZbFydF`IGD@yh5Ewz%KLtQ+)dX7Q_&j<@{hF5N{lPtdtH+9=2?)!PQa zp||LVe92pHGzG=Vi4iS(H%~WlX*+{1F&Ho7+F#5~W>Z4#JdcNwDQ(;^>g+=eraoD5 z7m}?MJK)BdtB(o;4phAZru=A>lO?SdD(E%}o~7PgIBHO4f10**zMceZcW(zf(2tfy zi=KY%^cceWsygI$GD`p#TebzFDGL09FvEYSIA6ZN9dUJDH)KzI3QLO!ab>-?yFo(V zn5}-Jo1#JURE(${VCY_n z@L^407lhC6;|cdXSn6;1-8REFx&Oqg-fu0pD1WtG0txc-mvRXaBWHr_U)*@;XUf(r zGExv7hms8Gp$#HCPDZ4}5-WC>&1bynZ~UFUDkSeaU!A}|uWLThT0q6Gf8`EmA*3Y$ zuH@5~A!#)@M8^%-!+=6@`LMsIxyrUjVf${ICrr2^|^S|)& zl|ZF;R8A$({T=nO3YhyZ#;#i6-uqB-9T1BAovK;@hW^VQ-pzkag2}dk*Y6VWwt>Zu@3z!Xf54--$+ovblqTx8 z=`h97b7@~tJ7Rf=^8rb;6EmMo;|loKPf*DY?st#wul5c@((WIQj;OBl#OR33jPd6s z0)M*kgJK$UR)5#h7u9gerRcwP$<)pO`Eirt^lqEF*Ry!S;L-1!MB@+vzGywM^_cox z{=m@8|rqGFi+a0O^%#pN^%FaBu=vuh?$zA2Lry|cBw@96z z(1r=^levjdKk3penJ5mIaI}cih9_(y8&cKDRW?q6{i|e3XzdrE2X(*t5Yg+KGi(b8;XiZn=GSM4kuAP}Abg(4TRbM@ zb@^oOj%)Z^c)m)`*eICn1~HnUDWs>9kutXXfh%c@D#?{b@z@Q(n9+JsicEwtVvAc<<1qBYr9APdknPFj1w!08n;DAYooHCg18V9g z_kNi%onK)wstk;ii2+_9xJN7ZL9z~a3C*|O97=W=q^$)O+dpfBcP>k)a`ArkW4u#!`mC(MaGzDivxpI z)L>hEmgEa-rsQt*0`3;n?Wi(E({7BdyL|exrPdi7#Ec{iZ+ z3xIlonOP1<1E3Zq!@C0IDw?ha2DcEcN36$>N&4#f`Nnao%>%PmgqwXcUwdA@3!8PG z;MMe(On>|!-0oIUvIuQ(7$PIr ziX;+6{M6Q@wSU-7ojw#fhW2~Ce-BvpfzDWsu7FeCG#hkNGhd6H6hqY5ciN-B z(2E<{J?O`E7jk!7gE4(x8UP=)h*N)TRAllev#cDl>d3xnIJtNb)_$qN^-Dej8PsMH@*RPahXV2Izmd`Ddp6}huS6;g4J+mEpR$E)|(&1VoM>BX*}W2Y;zXQ5|B=ha~2 zEpv7Ux|>@jr%~|p56TE8LPL2k>9QBjZg&s(uME zdjo{D#;^11gZr^Wj>hdm=k!c0;kQk^gs1aU)Lb=``Eo&CJa;~FW8;0hOmQ18 zHb@J1bvJ(tsmAnxuQ2Mjz;LU`;f7zv9V8w}D;U4|4bg~rEu)9aY9$Chr3qtt80}1H z!_xN3>L9orAkg7oVT_d>;3dMpRYwh30vdzp{N?-jpr^5iK1t{LTfFq4NA^Nga=8v* zV;J8-&gk(}*?c8;xTT~j#_;U)5i|&Zq3ywONxje&m3e(*TBuOQqj5H#crpL>(Eg0%=vc1((YS{$H2)|hveEzWYc9XJi zr+Oj&A`1XwLj03i{8u=JZ~|m|k8FfafZXqd*9q`5@;~{+Z<-f$eCn~{z&VU~w&&U8^15F?$nCTpd^v))54*bXmAq{}A zGc&a^a%Q%6X8teEcS984E&BHl)_*SE(wPu6(g1M$IgpI>za=@vARy5G1N(>2d4nyS z1Bv+mf&ITTi2u3xN1D4f0K&w<-o?nu-t6oDYsSAEV7Yj6AX^&%R=5CCziULvV$EoJ zVi_?0_Z$G=+Djn$JB*u7+q>*dzCG;! zlt1MN01FoW+m?4FBv)@r>RjGRiIoDe8UJeo-aS|3Pwm&xee;nE2mwLx-z?2=1%SU_ z0cqcbRQw}^-5mhVDFBn}{qJ>Y{YQwgF91AM3&aGUT>o3!(?7#9egH834Up=69j^QCe`&m} zu_ng<+$E(P0NCgTNDlYUx!CD}Zvl5*1F<33N&w)38z9L$w>nql#s6Jwvj66LUnu~* ze*x}+`Z+$D!#(4`Qd-q)D_8;rY0btMDe_OZ5rrvM$wze|= zYi;=}0N}1$Anm*S|NND}`JbD)SqT8k?*cz!f02cT`9~qi+b8SI-=?NFu@L_Uor@TC delta 141567 zcmV((K;XaZfCszo3k^_90|W{H00000j+ktb4I%@Mm~4?UC{0v4vv^?Pp4q< z#??ds082)Zo+p2uw{=upPqQ{Ug9QRX1}Dfc4DK$$8Qk679R>&l_u%dt+}%lVC%7jN zoL~vTUB3L@^SglTPs@}U_R$jIMM3P>%RsevkECT=)@PG00 z3xEUjFt`5z00NNyw&nkdwh*0d+}&LSSXrIiSWGRP%`AUe%$*%sy-ZzL*;&|F0fHi4 zE~e)8mhNCPOKV#vA;_Q4JrJ<1g%CuWTaiuCMZ(g?R>m7{sqU?$VeV~j&Tjz`5e5r- z33xfWI9j@!g1sCaoZJMwgdqPS7x?@BkC+t#{+Eioy%0p~pAN8&q6%2T8Ey&YX5nNu zXJcmv^YDMLuyb+q@USz1IoQ}aSlRwwJk0D|0^B?T9K7Iv1M+t?xP_H~8cgcnWBqLj zLH-?-r>7^2Cnt+D+?ti0pP&C94h|0HzZ%SLADrAxy_lWcsQ$wMvvf0u+q$^hIy-^? zX`7lkd$ZGb{g1YryPAKc)&H*Trt!hWl2y&p&DjHPZuwW8 z>i;p+|8Dw^;$LqBl;O627sb>8=4|faXzAoG3loC;?P0O7wGe=DN%4xYONdLsIC&*` z*xC7DFg8gJelB)C4haqke%}9Z{7<%g-0VF3FdlABJ_#vyc1a#_PH`zQ7#AlSr=%1& z4;O#`e{5x)+}ur_%q{<8Yx{p~x&BvM0SUOJsk<{=!`a#4KN+B6#dn3fTS+h38!x9g8!wCt@^4#<|37oa`qvrO|4)Ci{73XR1OIvb@6`X>`0wJeboyH{@V}+; zast5oSGWL+-oGUXd|3sA0uT}Y!QVR~G9n@(GBOe(A`&tR@;^X9MS1lXD5$7tuV24L zL&f+PF#iGee*=h!goJ{Ef`N*P0m8(<1mXQ7#KZYlAI^V0uyL^e7rgWWa8QB5Kw*DG zAPxWl2Z)FRd>I5p0)YRG|Jp$i5r9Ylohh10f>l*fP{?nUm*d2 zI0yhrb}?0uDWYpoBILB7p^syB3m553T+IxQ7fh8@$O+}b`8OHje{%wH{xLFjMF0gg zB))tHU?BeG$3esahyY#y#kq$HU(bKR@R?N4nh%cN;nr&=!>~f4F@H$ioU-u#&S;TC z;#KKlG7pX6SjeD4;g9LqE}M-?j2qez$dupU>*f~#$R`;C4#h}Q)LL?}?)lNd!NX_q zoRYt7{o@1{>=O#A9lM_wXpi4J>6sGaDSqz}tq~#g{3{6O1lxn@F;(Cr>o0##ybdL8 z9opa84GOT&7oeSqf;y@&r6(bU&rhRq963RR)Q88?dV_f{062@m9{UR*F+iXbm-W|; z1wXM2V**Cl!BFC>t_|8%{x_LIcKL@Ek?GeW^}74aGHQGmWlB==4~C~g^GVF~ge8pJ z6c0jIqn=PVCw&ihIS!#0K+}JEB;p;lZ=v*|)R|1*Q~WQY2cIPE_+2<}ja+dI#kUiL z!QFs6YciWozZjwC+eE)Hira_y;gpm9ji>ID+%asXSJe3eA`{jEr_a*?f};nsB64X` z6u&$p_a2i@treaa<~IJan%`0T?Nt;A`aEq?oGT4H!zfzp^iR)JpQnGlRomdI+G9Oa zbzMZWPkCox^4;2xdv*C?s#*gNWOJxw{r#`jYf_~j$hN>(a6=p_Zsltc0J4Xy3fKA46k<{%UKUF*gs0awD^$&Vu>L2 zbuM$U2V^B-xrbkRuWAY_iHKD~7N)-=9Sef4pa|o?tq|O<9v^@H=R%nQ|UtE6&UN*d)7cyQhqRXI+72g<+CorGPQ=5|f2D{=e*;zgy+&$)a8~Xw< z(jx3i6ZBr-Bw3AO*fhT`vGn4BNYOX{s*H(xJ$=3^Y=r0HrwYwW6ZNxeH;bgmq}xPz z^+#E&mSYzPZq*uDYLbpezzF^RzD@2&_%rHjCE<_WM#w;na1}Kc8B;D!dx#5+RDq9R{5QB;`@vBHC&E{<1B)NWZ;XUJ zeAUsx3nq4H<0N_dO^oNT0o_h$xSlWtb z*3#qb4YzGdsg`t{f?iu|xba=&n6Ke#77&hxS%GiFS~%pM&dMbg$K>W1&z-Z|xBQ7N zPIYrH0D*-<*Mm_E!-BH7mMp7?2{0>5XsTk$ZD#uWd*nJf$aKFYJ)*_Oy?}S~Ov-;8 zkUiJ7+d}W^N6HihSs(J|??lum*pxu$7)MoaSrGc?HiO0Oc=+BOGwSWJ?y31i15s|R zhgnv&m+TeI&P|P0%LzP!Sd>j!U4nm+pBnGtEUJx=e9vJeSb8LvL#ne>6nb1a<6x7Q zuleh%Z^Ocetd`6n4l@YTJ+= z`4u@LZ+E_;!}|xr8ELp%6ms%c%q#nxzQ3DaO~b%g3nC6vlGIHDG%L3JL}4hS@=kix zXjy`r+?T>7Vif%oI-^rd_0Bsx!*BJ3K0T@Cd^4YuUf+=X@p(LY0f>agNyKA|^kQ)x zHSi$h3o(CKHL8=M0?{AB{TFpFi!&wV-%sYgWl|N)glHez+c%XB zRdf6fj`aCT;SH@EMi_%UEBM(daI|&y?jkFt zP$sYky!O%`%g;m>?x^0tx-&5wrTCs3Y*dZ&Ny>tYsjq@dM(-dyBj$gJVNxA`EM8e% zC8sJTD$=`@+2oI}x}T~l4?O8e#7FhfsN7Qo8!Pv0Pa&#S_#l$mkE=+aa)#6y`+qa9FIvmd&hTRB7hY#^h zKel}u_g(;0IaWuNdkB9PS2BJg-mwb1y;$Y#gcp?o$&aLECS-N@*)yLHCPp~1Ib5@v zqKn|$K#ZPJ4!aK9yizyhDjW|#+hY+)D%@Bu8>9fcvNx;V^oooeM1YO$%TPHzvY@M~ zSnGug-o5Oa8_jHCbOhDdQ6I9yrDS?c)`_>@95r-8*jR|r8eM-k=^Eaop?iW?^xtW< zScs)#6Ln>Zyw&n!x=yo_fehK#ws11ZBwLNz`6FvqL<)V?)9EAdqX(J6dXJRkmIr6` zB6l5>kel}Omh2TG5lxt+j=kUHcyq?+@U&aSEw*g-wp{uwmTYmL#zkvH8F4+&&n7(f zJjUv@n2baNqYHn3(Y?k^Oq%%|9oPK$26b>msxq%FN980kj(&aT6`A*?yG=eAb z)m*t7KCyfv_}yV*!1oN<35vn*OT8P$ui4FlRbt*U2RVmnR}V$D4Wg&|GBj1VZcDe( zD%8n&JLqH+kfV>+$RjJRsybX1XmV-ga&6$%d5elue(-;A_RzhZrZE2O|0`lG@YRT( zQ$r5vn!r`pr0_rywZ$!=bd_h{XrxbMJE1B13m_|gVag1gI;#6Yfcch938}rY5x=!Y zUt@Du?G?*F|NV?4r5nNZD-rLKEm#CW-0Rb}xxAo>B#F;IuyA0d$`RB_DK0hsDPCbL z2XRbaxQ~BjbMZ17JQqChnPt-5Lf7Ci{e=6;8 zB+|CmZy%lK1^1P1QGoJMYo#2AmK2QIwUqa~Mw1?BlH{Tp$3+wJZYUEEc!Td+^QBxa z?81ICem%FZI3~t9Hu=FQdr=FO<^^!nC+v~Bc#+Z-x=!8FaHt%ql8728kP)R3io$%} zKI?zPP^CS=rh-IpjS%^)tcBhz4@9RR1syF$qu-7~n}bZ}bFK5!S5DH`a{o-^BOTPb za6p7dv*Smdt|pCIys6x!+=+!WD{wdxEvl_+4iFQ;*ysYWGUu95;xh-<+YL!6VnqJ< zVcrIjE*+DHBvn^F)ZzT2yeKtGo$ZH55)glEgR*aRyb5ICH{*# zB*f0`)Sqn>@)l|Lqvn+iL_*bJ{mQ$L#vJDbup$LGj%tRe-88f2PR}lG$s+;YM089W zrIHuR^mqY(2MF1eZBz3_1`8bMmzb}mrLlagEGyv$4kqX?*F{#PKqoBl(A#?qZSsGI zc3^#EMj7{-9|g{s>PN>8_vcbC@T|u!R}5dLNAC6Sx&nP|6*?nv3t&i(-detDOUR?H z4O6P`w61e#!Bh)CXVN9%5=o*n$~RcCc1Laa6Ym;N$kDq1q2Wk@s4Ka?cF`^3ripny zUDBZ`L72Kw-VhBd@A{?Q$GlWXzZrj6@BYi8pZ1WL4Et|+lja8v&ge+eNQG)r-^1Z9 zgV@1g0#1z{AmR?=!6{FXcaL-31_#;L;7TL#Ovtlpncn1G3Fv|{yhW*Xi9-zmER+2w zYCmeaw~W$6MN7|Pu7!5X7K!WFX_R^4X5kbGo{KSR)Oj|Ik)O5%!aU?p~E8`2* zdrn3p7=Z6~@$f!`F4W9vo#kVHiB6txl-F@Cu*K3l(i4?3eaG@pW4y5uh9D*^;A{3N zgt5$r^+GY%$s^u3|B5`-s9JwEx3`0mX@|s7D?GAP%hIIxJ_7yU-MXE;Z(RFu$Sw*w6;TX#7I=0!ZZ$d>4V@mPCABWAap&i9vt_ z$Nat?iCM|X`W>Y3(bADY9_b;lrMvC8i|SeoGPdK>6mou6o%vk?j+B3hy|742;FA0K zdYXxPo9*zK^GYlTE)@d|JBF2^fdVL_t@7$J3g}#M_+P&O3>e&wejWAz{kVCK?YIne z(wRc&vTyaSWE^Z##|TJ5f|=tPgjw(W;?6`y1J1#=b$W|&>WFIz$vXj9h_EzbhY*f9 z$+VceMa8$^o>=+?PUwHP`o1ZN7K&c}QM`tnBke;i(sq7);y1kg6bN;NUX(1V^{^jy zTFo0u7)iHjVkY1G!U*v;_vjVD)HiK7Xiz9WLgih)<-lD4h6jPEEDMaF;ND3(7XDs^DTK+!mC8|w;rn7NZagK}@B7tT zE$<8k8IA-K{CVCQ*(lzm^tK7C5bd6lhT>BzT?)CWqs4LQbYk1+rWSQ%FI-$~x2+yM zz352JXaKp?6B&PMq0tN*ivz_{?!C|#1D`Yu(}e!T#Q^b25GOe3!GGbdIM^h?{Dca_ zC@h_j*jmD}9kE1D#6ENYkbt~APl&@!>c8VqFL6DXO)Ya~r z$fKk0VZ59BNDogEI2cJKXGNxG`mu$QR$2KYB#|;A7Zo#iUo>W+_6jM!13%RZmkX8f zm4We8%jLH&SO>Ne5hZCz*CSo38Nc54J`c43qxeq?0JtD5eyPe_0HhH~=P|>sbb5m= zg9Jt(XZ3&P+Kh<;msJpy&U!$UnATDq_IbNg)FX06;ctb8C}z)a^9kR(#Qu1+<8PpW zt-igp49IGyp>9fZkm|o9hR%JEEJP%ezXkn;N^ARysWN2(1Tn zWhT3Fq!OM~Q!Of`y2^2Pl~zP7TL41854av0LO67|RBm-&z00clrnE$ZyF|5$4uUvh z(D{i-a8B(mqu_*K01l=5+MQ;GaGWKZWLu34UO&hB97TWD z#y(+Ws(?rtG8M5#>UWqjwkYL_hI3Y8X|9mp9Qv#Krj(vx2i&znD`24cC>Rx!;Yb!V zqj?nuhw2l6No!NJl~|KMe{QQ?DmUH;jRaG<&i6X28CZnyve)xSZ)tv~))9y{k(ySl zFfNpOZ{a#$m#Pg!$`tR@Th-^<-YS3M0LAgHVWkq^>6Bx$n_z|9t0_=pGL}T}QZNV~ zi)gP>qo_=^9cx}5zIvCOi?#B^u)=;F&_EY=xkW(Cunf&|ol=p5zi-gDnjVkCl2}W} zrus@tF3dGnqf{vVidZ1lu)9T0fLJlf(uIASA>5rK0V`u}xk2i-3NsFtO~HTVR_j(H zFg-hE3E_G=7Ey91jlS7n;;gZ2DNhN8qf53}krr}Bn1guqU)M=tjE+W(i%k!?_8GiRGYYe4@c^g|h_Z<(5jtt|947KH0 zOQAP-3KnDy@k?PAG7M)-hc$nl^YHSUbG%`0n6E7?YOGGm85uV&zm!hR*Fs^+W0ZQQ zze;=f0vjT|p#DV>mqz@qQ_uWRi`!fb%<-mf^G{T>H33wdDQ2TCm)OOwCl&N&K;f4! z-EikDRF{5TS%}dX2dTqHZrB4bTX@?(77@6c_Ll(XmaoX-Lf(JOE?Roe+ayy` zu2J^u5U)SX-fDM)K%&@}i2F*FI>c}pdcWVA6QtmD6w&UFBYItGdPZgj3S9%GszW*j zNGqfgv0r91`buK@6U2ASV|=|;1nzsj1x!K^;C!%UMR-smIQfEiD0v0XUeETrtg*NdFK5H26 zP9;b0pdyCH`M#dPwez!nwZ;x(CKfid6QJUZDF*$BPbG3f8W)#HP zw5olt@XnrSBHScP&!r$-4lOpk!+@XSt>RUhjI2mjdz!@`UEFueJk+}dA1a1U#yACh zJC-gZB*q_YRMLM!T`H9)zJNCWZf!3b*fX$pBOKhMj2Eyqc0@y9VG>=wF7t{;ghF4R zwP*vW_~HjWdJm&gp)|5;&H;I;3_7E4;ay`gn#E}*{)Tp0l(4`XnYu^M79%Vz8nuDt z-3r6`NJL_vYV5tU9i4-brRUKX!0+r{j-EV^+FBQAbdi5qKVd7w41GEWN_wmF!;)Jp zYNjh0+WqsQi|(l!4O2SRb>*VF8VxnZ?Qgp-u{3Q%-vCvOmUj9Z>e2DlKVd4PxEvx2 zO(Aes7y4^FV#ZOgt*oiK8HFu~%rfBb0e^^&8XXJx^Jum7?@nkD%og9?vlM|y|LTJ= z9cFut-g18cYRU=@5Ws|$YiS1kP*A6DjOAT}14{20EG4F;9pJ{3bGp9|w@dh>q!kku z``C=nB1Hc+QtPWnp0kv{`n1kIl~QW8h(}Ig&FwC;*X^Q5>1dL3dd(kL_4F#z{pY|h z44G9w=@i(^uHH9PWw@3~$G5Ml`TNXP5st3tgoJ;RJXPKo!M0VAaZPKR$IR}PtYCo@ zk72L0(0q&K`dF{ZGJ1+*LJ~z|97~Mq&{mTKWfo}f7thp&O+%1Y&5gyRCXS{J<)?2=} zr=9h*pz_#vW|%lS*yllqeIr!7L6tL;+JQd4CdS)^-wSciU2zf1=uy!+wKy;E6GtnQ znXOjp7Skvv&WK=_Us)qjpMX*3ksPDCfm44h`!`kQ4n!i0(2E+Gp|8gfWU%8ZA842xR@V2E6w=+FMEfGS54 zo#{1x0wqo#qq@K^5pdw=RX5p`V99@2HrbxK@yhAT#1}xE=KXr1>iV`&>sZUx)6t;J zIE3SbV{#*dr3S0xDGAHpBu$|>va4IOjUw)Ye2flim{ochwhT59TL&icRm+6TnCPKeOpTns=F#%w47BE-!u&It7$5#@<*CL9CY4% zUpbJ)A=@CHV?F@`E=h`%n6PdcgU$&c{XRiPI5im!Bol3cp7KV_%t9K@S(A2U zwnfF>-nxgSua`|gAT;PTdU6RZ4@L^EDSvElwm zs`acM?}rdj;4@b&J6wPJ+NbIrsiVj7b5S!srTi&IF91dFnKBa#u|$scae_8Ity8jz z;P-SV3@Q64Rw|Mq<_=ePDjgE^2(a*;9XU6J%*|ri1pPJ8y#dMO7EVqPG)~Evprx9B zR!*EU>Gh9QxryI8k&2vegN5BsBCX=@luX>7zbAL8aYw||Zlix06IVth{EVu%T|Ja6 ztN01jQN-!_n5*dqnlVXz0kD2lE+Oqhvh(0w{_5Q#8wG0XoLzRjDKK=f!W6XmV)x5i zXii6*F1n|NSEOhWZpni`){-s=@vGb z1EeIWkkyfbBClcLn``6q8^a=cx&9Gay+a|_TsNf&7OH<&`Z|j{DuUry8Dx%X^{{Fk zd9dyiy$;&cPs&&^(36dL0uwMfEWhQAZavvI+8`g?8u?ieYUg|H^C4}Gr-*UNI9YwY zYPFB;gSj)a7^*{EcyTqHU5B0iHkQ!ZhO+e-qi{74!gU*!(qRM#z(5~^VyUU-RU-6< zgWPhj8k>LNyd&>}Dt#)7uX)KY<^;~m0%*cFLRyJ@RjphKO1i-Nw>G>rdL^AxZqY(S z#51kS%bF?fMTOA+-v?V6J-hNoSqgP#{3SjGou}Kc4tg*&M&bMDO(--aRt=EYB+0L zWxc3eM2u^p*z;wDH!sd@YA9>dp;SxiG{k?IxwVy3EhMK{vbOQ-Q{~4aYPu>DMBn`q zVihaxPTD~-o(ilx-YGS$yQK!1WPX7AhNtdula%$%>65EW<`?OAu2Onuuh%tQtF6I! z)3rABex@g&vB{|U?Mt;jVIz?Xo|{MGyRQQR7Q>0?MR5imx%p&4V|^1h)?E z%%z1vEL2#{+^e>qBGNysWjCmO$_bVI9Fv!RMP=7bareqah7h~+c98*NS7d)xvov2o z7%ca$t$;#6k+gUvu{C6;zp*Ts0|$&4a7FS#Gu9hTPHWYLiT+Fs1T}D&6Cs)HNqzM^ z0bQGN^8ixY_nmSXYA{A!Sq7ex8LFaj$Ih^!6j#)^CiEXc^4B5t z@+4YZPqGQr^1ZpN(O&9NLM(rqHdm+f$7*Liqe5$NCgsHixIGblF>iY}JzoJ>269+G zY%fGXLZh1_cYIv}68e@=p8fOYyuhnL2E-b(RJD0J9#6;?<{nBS{P16sFcr1U}4}YW=FYBqK zg4<#z=?c|$L)CkN&P%oAi64RzEux>89qBgu*;2Aeq7j4bZrx6GZsLi_su4~nDTsFN z>wZ%_KW|b4>8)>S+qVRMay&|?@h7fDWj!Hvi;lLG4z7nCScuw!+=*{Bu52u+P9nq= zgB_TTMYO`<-VjtnW<`G@%uN&I8Jv(Bm2fxO)t}fsM$N-T`R&o^+ic1Tsy(kl61_o6 zvS-IyKi+Y1)F&kB+1oMSmyUv*EYR29FwBcuDHge?OSyN5LTbh7t(-#T%8r)Co?vjG)RA-6IVZqVE5HuZ>Su$ zcT{ukMp)UD`#q1GdvbW~=+AXGjY{v-X8w^W2KP#hO#N1uA z$zk6Tuah!)2H&r2H@ntn3NImu-U~6lI^B*qb96mf)#nArhoQmrVMBut21S-Lwdtz_%h0x-Ux{MpwABtU#)nLl$88 zl=?U?at+0ZS=M*m8(}Io8&pRl^|P@zDHcP1!{)7zZ>fJ~V&xSy&1>SAWcNcmFj3@o z)G;7m4dc?Y3hvDMu13_6)O>o&i@N5$NtL9)S*6Fiu(^CsVd z-tBHz{KVQU^D$Y=7nq(0QqlUPI}ULpsP#01fB7;iU)9a*)pTJl*rM@*3;e|Ive=@e zU?|*o^Ui0k9`dC z(F_)(&W-jY(d4N>UH%zJU@y!P%U;xOUWNQ~$+&-n1~;vkC4-lhi#{~o1As8ov@BO| ziZp}t*(Z*LUAZrp)wvU*(!dyi*`izGTF-$p*!bFhy1!1*9dmCUyq`4hsSXWY{8Ns+ z(;sU*cl{6)60R6A$+%TSIhfb^H#y(nE~263flCFLD^|F+;qBTa#;$WU+qcg>4{AFb zxfg%*UKYzm%gL9RyFo}_{j%mdCOKQCIUqms?veG5DBP2mR_vbflSc%j%&dP3vg(Ov z=EUQe5MNgB8rLg~Za)CG^oD~tP~qd~OAXo=y`E?`f${NkE%ci{;XF{F$2nfWVRy$w z1acailCQ_4R>2LLc3%VXir#`FIFtA_2S9&EwM+dK?Pw_GhJfQ^Ga843?t5zc`5L{N z$Jc6nG_#Ao&e{ZV3Xs=5arOk4A2ZtLDfcm39d?MwwOhtI@3j1g1VPg6oTmP*nhv%( z85YS@K^J|6FMt9;F_EJ|Q862Td}b;64i*I+y}R2oNzn&w;t&W#R5)G{UwX8?y!tSgz6<($ z91P4hw~Dp?+$Xzwl33myp`Y~K3p#(bnNaF|uY zCv!uE*xJszsd+|1HplAYFJY?GWIcZ`<%$?h8ZuhoEn|T4l?M@ValYvVfRZOPZIQvK z{MLR?bo_bsfwbrPT@o-(ZCOR}eH~exEm&Syz;-U%qg!PRwiiR4HFZ||s)MdxG0!eP z+zm`?+C9F%uV|0>?mLD27uCW2oDi1LtzX{rr=!FZgKu5YiCceZS$$^;| zbTz$}Om`P@QSz$2*&te5;J1XnBt05nu~GJ-h|SvIM?U~^GxK5Y2Q0<`&2dRLFz46k zSvMJTp&Jd&jBi#>r&GFxJ7RvD}?LL_NENEJY@tlz6KWaUQ#ZH)-xfWhmlAP zaE#k;ZwPo7QB%@4dL^dDY*&BqsacTC(z?*ui!et3!g-M?=I3$=Zeqy#$C?`>PFt_M z8+kb4@b<+Lznda022Rl+ZmVBSTP?Wrxz14J;Z6#@<;6Q=CpC6>OX4siVF=pl2?!Rs z=W84P+IdUU?QKu~q*3Y?Qawba@9@+2SUxcb`YYx?+F1Pqo!n$fu2Fvt*#bI~^ux+( zoge8w2402_RWucW|QnC!a9FgeB>dLIc3+W zZws^D5ejg9O6Ge3Sbv80rG(YiUDauJo=wzq{5`YUqo*+vV+G~}zKTTMB6HQtRY`d=uiTQn=*EOmW~+{G&U>hD+ngaMS9KFD-zE{Y$>9yZO)VDRfwI zpYHX$Qc*(oK`_4lLgX0;$q+gFHE*s+y+V6|Yr)X`QgvgFSmJ-Hgbr$K#CeA$>rHQd zoZpEsoj~kTb-F!H2-MP-O!=$#hq7rkD|B|$7*fKrr3PQVJPW?yVdocsVZ}hq9{wlC zTS3imk7TCmh;QcH8KqLe9%IXH`+6(#76e6*? zfjIZSHAK+Kk8h-|+YXNUXcBPy#SW4u4>zi4dL*95$)10=_+pCvt-b#kq5jNVAdvcd z2w_xH#UBg};%TcYI{fx2v3}V2Q`v1Z$P#-*?DSxf&Z>|=`_BF7YLXsFc_(2y^Lxy_ z#1H7$&{`T7>yDhDlMPgCFp=ncb`hd5WOu*rP%3LbqYFrhnBz4@%2}}LEKr9LxgSemI3kxO)d+u#tEqP@TZ+|U0RcWfyj%1$*0Yc$ z>}cnI??Kv9=&Z?Y`8^@wlEmD~ky%u{JIVuzvwudddyPJv>&;8lkPhWdmB- zhP!NvrKA+nG&_x=qk+8J-ZplNfjL?ZQnLJI`al-gmODMpo+d6LCzaV--dD;Yuq435 zLx;}eko8ua|9OY-Jvb<*~S4A6|Tm@*i17O8)v z)T2nj`W&awnaN3#uX74UAXV7+WRpi4!x7;OB+KJ1|Jjn1`KZ6}y+Vpf0XuTu9$!33 zh>IADGrap&J2_gJb(j4ymo#-@LOt^zTix9(4cGa zXf&{ycX)=v6`7q4p880GKCkbS%zuKS46P(d-yG|<#mce#d0W&Ss#m8SoCrm6H6y0B zJE~&i$d*7GFgdQ@iZ@t}+Xx@eyB;pN4pno_y)i7}M!jLLtQ4Gn%+{53Er zAPm;I1QHr;u#f`W9;;Kw#Hf6j4~SWqMd}9!*I)ZA^o5QkW|_M%k&P7%_@L5Y*}|mYkZHSxc+vyS5)M(C*k=9F;L}e>57^q4Mm|a?|QWI-7uP9ll`5^=eag~ zV%$aD6_MJOXqSH_;)DoRq+MqE;XEiHLz}Y8kItHeMpSAGfMwKDr^NJ@oEoPt>})Bb zp&=&_6TIJNZPXlatdU4VyTP|wGNQmvw9x+K2u@6JsDDckQORw|F479Kq z_gSxF3H@FLqrq^I@hYWF8otX9M!7b>l|D4tZ{W`6b=ifgBPeHFl4;_89N~rg%0%=z zi|ozDbnJiMq1Ffsn`Iqa^?Cv!kjYk$s$myg;zh$?ZZ5~+Pgce;jrhg{9iuU3aozRgcD!fyq90X6uz%RPnC5#luBtd_CY}r)O!Um6AVP-8N z7FSMP#Mz(K_Bd2ds=e=tz8TKa_hk~xo_wR;rL})o%jj*t@SKaVPz;3L=NJl={}9&t z`zcH%^K*25ty{eZyfxfS)_PXRnk1C3j#b1r|Bx$P*wDIISHmQOq}b^YQtQE+zyWwG z?TndgAAp~PO>`!xq;E{3<^Q&`Xbn)%6<(djt`Jz%4ppfCWvmJd*Boe9s1H00+tRRl zjzoV0XoXOCa|dV>4<-DWt=h-0;lE?DlHs7#-`9@rzo2W4?d{Vk(wLJ{QA4G5`$>QM z_1gG1$fs)^?C-`pv0Qfib40K&es`+o`O@f1g1+hL}iwGdU#US@%{2!@mq%yjd zM_&>px1bY5*S{{jr)dm1^0HUk3r6{n9WEk5Ug5VO zJH7&X`7;86ISwXIv-zI+vZ=^QB2S(x0s=C+VN*)Mx72^#a!XT^ zJusqw0Z0cYkZ-F7{Bqohnw)Q#{y~Q=!KYL9c)x_;nF&lc!IUW4{(-cM9~OC+&rm&| z&n47fDAh{DCqlAht#O>?iX@qWqV-!d)?=D6-=&H7?ATm6Y8-PPnHd*s&JZ3%j{wNK zCfeZI*NFR2FGBbNFv`5onmB*DCqJ-(TQ>NRD7f9o@_>V?7VfkhhnwhV2Kbr73MvZZ zIJS-21pLZpU1(sKyikKPJnjR`T|Dnx20M4lXmqcl=qTkunbFYHaICqY&7Z0~2%@)T z&vrYSgsAy1031igcNGX~l7X$r9+fd-9NP*`Tr|(z6;L~k5L}3k(k*|PT6N~VgB%@! z;ecFI`+Fh!?C;mGE??WeZKR8@B&^D>m-_2v;sVW`Qd28^i+2KfTJ3Iq%!h4$W9Qyc z=C^278$bgVz8yZl(W)bO7x>9RO@86S;x8PR^kxh}n~^`7LRS{!%2DYb<7#VA$kxAK z=NJp@=#?G~Nq3SO=}&(ZfNhT^!eSByPQGwe|G}c960xYChr9sJQCfNoo<-h2&mul> z($YvD+0Wbml-WH=Wd6VwwNz0vg&Mk(ZHG_Nh2=uVCMW$zi#RAb5yJZF)p!txG`}`T zEYZwc!_VyoQ83Bmm7`skeebvwbZwOyFeRY*#Q!OSIHHyPQ{{hMbi*{e*=v19o!MAX zB`BM*#MX7C4r7)LBdr#OppX35MuaE2hU&+TeL@6kOY4WF zwstl(uyn+1!q9Ksrp^Vo34}p$Dx(&=dJt3?a&2UePw|8o<8ZO;Q^9Yj{K{)>4r!J!prAA}yC$itH`Z=Q=}VF4$Fv!c>=oiZGXbfKg(K6A`6O{!)&$KbrB;^9u`)m&dg(q)LwsN5^oTHp&KM_CK^fL03dIE z0T5QjOo=RG)hHx!0tIuw1n8AG6sqw?&6mYmW@<3({!$4IWI2@P%0 zl?gXM41}zyx~uBbKg)s>8WF_xbWIwU9lJW)0DuYTsD5uoMg|nM;xVMjzw0&h%!q`s zs27~0go4?*Q(~=H>vSp@&x&g`lFRl;+E2*zEhm4rQ=`e?f*-ETv|m!5T5GZ^6TyyT z_4623C1~HQkeTqi&`9gFvLb^Pua^=rFQfbk7RCFG*VUUkdN$+2dcm56`Do(<=ikWdC%t1nUmK2%zEY6z@4bIF3c9z|b)06~>&p&Vw!c?DQ&Jt>SW{X5 zJ{wJgV44Ip;}b68I-v)yjUm!Jky%#ED06_j6Hlv-+$Pb3JZ7WWC3N;rq$WM=sx%JX zMOX&1f3p3fZr~;dW{*WmkJYLJu6IB&rPZ|ZUpMg{t0Bngn%i8SS2DRxAfFI2q0fJb zYKTdW9-$RJe{ZY(FbZ{P3M;Xc7W^b5M8q&jSYy`;;VZ1izVBpKLvP2(YH~izn$W$P z21hYDAwPHHwWz>}u73v}bH<9wpX;<#|Jh~;!UZ)k?ag>|jD0(BJFmSf`jC8Gs#4dSfSPcTU zEqW@C9?o1jr{p0|!P1{VNOLR|PW8l!-L(+fwc}oJVpyx*={Jw^XML-AtdeMwz}Aeo zz2Nc!&_r8ZgDcBlRyO4tSflt`_jZ1ceLqzxv<^iy3DM@7p4-z&PNX&TD9C@|lHMqy37nzxGeF4;k$Bi%Q1WG@u>S%RowFI5OQmMSkS{Z3PzW#{d5vIPpDx0dK zdzT1urCHabAeoLuP*_1h3EzLN8ZggO-B!HtIKN-)GGQWe!{P9dMSmu>7+TitS#nxBV3bfVHqRit)CIuA}o%xNl4<{ ztQT>0=Yk=ISH|isiaH<*<#W?k*|Lw|J+PVXV`uigmRqG*(lje4Yp#E`Gs!5&5;noq z6>Is46w-s@V&~&gIEUnSt**H8L%T_J?A70GpWbPTFb*T~WMBy!;k*3VYXy7>XLY+M z{GLI5(k)iCD>2e^~phwOOCk?+rdm)@|hvk&kL7x85VL?JSqS;K*+!DCB+_L z9uU@Ig^{mG>_x*|u&n3EjB9j%a4R5CY~Yi`a7W0?gBK+Rz7sJ<-_r6hrQ{rU-K99; zu5sCUVtq=mT>m2|B{gPu{9|X^nzS+J)US%V>7x1@NuMV(Hei^iO+p(PDS_s?&&aq$ z@g&?gCPj=`Z&lH5^HUc4(y@7oY9+nsAUFUb=>4-HK;AsdG@W()=ThT;lWqUc6YMeN z5y>5`mS2Gxf--Nb*j@mW`ty@WLw9vxn~ts9{S1tPlRMudL!_d?(!R0N>X!EXlMskp zC(E_ydfml@NE_Ff*}hVIiOz>h&d8sa3%8nfV>$s1Tsp-gA}$FslsOxJ1NaK|Gou_=9YS1H?Ew<$*nCw;0N^FblBdF@x^sx=D$gB5 z%~pyUVAaYvzC=nD5nD0oF4>MXmbMcni%MzwY?ll2fPRBYOUn-OKSOWRmkFv}#-P@0 zSh$I%3%BzhkIXEpo2jOUt4zH{t;BkGj*=r2bHra&w3XU*vtGP^r5g8*D=?pmu&@^_ zdJGFYuSA`tb@%1g_pLlLDxXLqL9bN~Qy;=d`-JD&JMUe;floZln>Zy^*tBGQ=$c7w ze@EH#M~^=`rgvAu!g#?}YsvNb)AKaWMn07}dBX{-VJXboNuT51d?-I}eIQ>tR zhZx&@quBYiyxbX{wYHH7GRU}YcCFlEYoxN+OIt>l_hkliK$&i7U&>2&LcvX4BJdUP zHS^L7z{!8t<*lxetj45T$4{gPbT{hgEBqV*G&F$MiiN3vt=3gFQlZ%On$8y;bMN#K zu0he6bAkO$)vLO85K?^S`B0PY7wz6D+86)=jvMgnsTS70%nocherVBBHGhczu3JhM zPh~ip*=t6B*6H7pHono~J6K-{=2{LXywaF-1$cx#B8TGP)QpKAm>-WwO%t*rkvB0I zz8uEpy8@zC4ZUZD6imnlwBALv&c6Tzy<`#kX7mOeD=Pg{tU(SkbE~-w15qH@xbE`& zj@%^1?(Sk;rEp8lR&FTnvck_GP4fL+B984ZEZmiUMx-x*<0tK>k{3Y38s}rCXwR9^ z!ygJ1FEpSN%!Ks^1OHitb*~a-5wqe*e3;53(rqNUcB{piH(~D$6@^Pq&pGveO{IMn zam1I6wdWT=i!rtZ4j@7K0ay2#`)rc$Atd$UoM1>>V*+F6x1a^*vaq>byFvGme-+o_ z8rFM%_C2a;C-J*^NNM@IhS;a?#(kIgLC*n7P6uX#h>Q8<_`Y_C5o+uy#`j@6lD3nS z->xf|UjS4-oq7k>*fVK>t`i};ZpPz0v%$gYdgHuoEiWtnJ%DjHRSLLl39VW68qdr+@R0YNkE@~p10KngWxC{Njn((<-^7!jz^->QB70$4M6~Bki zn}OoMVXSks)!$ha_i?|>M(7P=guc)n%jAfwCF}yFb}16@QR8ScZ^EZO_|}NQivEBV z-dcRIFQGWTwhl=#f1W$t`$|Ss3Z0_F2V>9kY@iecA}j~R^(x+RJ#aUaIE_5}`gx3W&7cXt620rT9oQ7r+kQBA-r z9Xw8MaoX6QZ>~u0wKRu`$SEfn_mlk`^-o#^>5wU0@sT$7;9)lsK!gMYh4=;jJ}_Rvr{cmeaUl`NzrpgiHk7TsxUPcIzw7#2l4ALHP=0=X ze11?q50nGHpqQB0KR$$nc>gkZy#n05t^9f2y;%R_LBY<;2IYkGcJgqC{8P5F_VDqR zVqy7D2yRFXjsJ4|-}Zl&n;ZXs*k0bccJ}`>+e<$HX~(Z?=jGvpva$P1XZ^pb`kzhz zA^vTRxE9Lk@1R(@DtOrVxY@aTt13vb{MGQ;I@yXVJXI2r6O@0ZqyQCBgb50YDkumj z3W+@x6cv&ek{1*CkB|S(R#aFJCZ+%rgNn*42?{F0oh9%jcD70=4>!oa`d8fPzo}n90IH-UApA^T5i0sm++t9eupCrGNk9bp zOh828Da*fYZU29N`i%c?WBC7{WciQiZwCJJ`(LU5xA0$+$Ikulj6waK8uy0);(vt; zuQC# z{|i_^5C|6+mkIoO6+h2&(3YTppjT3_Cbz&*h0 zny>9hBVG(99!p@jCLzC)YQ4dM4r|^f4FYL_x8?C|2#|D8dt!Y6wnbmQ3#01X#v%EQ z97P7V3_+Agc_6ww`*H?eF|ab7GOU+D7xgX1O(%cwcpWNOTXq=v#p#;b9jUrQ`lhLl zHI;0m2uJ4^-_{>z6a=9}Ia7o!H4HK3WY(|g8Ybgy^@d`9scK_S26pr}ReN4w5vvGn zI+gj@6Odjf1|aq$rc!UBj_nKV#LFg`7BD#92|4i&@&X8g3QKHCrC~AnE(f_60J;dP zEBAk~3{pBWJ(E}|T$>L*!dGKo#6Vd>-oyI!@Vq`y8xIrOj^4@6WzzvEY>Vk3tnsT4 zfaE)!8f@Vt0-&Fe4t@N#ihdJ>*FSliI0%KG!J-vjhLUMd+iM`NnUzr-;mAm*}|%1dU?_=cV#cM9WF zRqB!opq|R`R(`V^x>RJ4Kx%dmP&01#?Dht;ZM-esA@S3Llgh6-Jc1U(8Vq}f%{YHB zRW7Ki0o%(ng|>d3L-GLqwpfP1s6~Qs@MpD*m?UANdjJ^5F9ht&a*N-O-YA^P_yXiM50WD>6zc{Tj zQTanbz+Bd>Tc}De$2tL4Yc9=L$NqmM=Sr0)dy`PbqY9VgfH+72et)Bq&5Far**m>} z*j1vDkQ$KB@@90gyLqC>tQ+NzEWbL4r=&XeB3I5t_zSOj)tFv;vKai$hMu-v7}${2 zGEP~2h~q?+kU(zd9`M9v-eT)O8z;orK076m%W871pbM?A8Yyl?crvh3zj=Q+B$D&h zdHo%zuws}nrPUUNwB)pC)j3Eygc1vx>c_yE62qqW&|5R7;-Nv?cp2;9 zo0^@o_@>$}cUAOVv|% zu#ZHB(}=A0)pgb!eA%k~9hJld9f@jg;EkU_q!_vCC_+_+kz10%!Y5tJLe?YKL?+tO zw+S$T$Iy(2M(W=drn*7uIE0_)eg3i%m~I_f-ayRUnW6*9nPob8mnDB{Cd2I?IYa+? z!!s#V@2gAGnR4zH^FTN3m1(7Q=zuHD0(k;*ogf_@q73%S`tw)^#y^n-=uqe4J<@73 zv@&$fXqMjnsm}<VUf*p=>MS9AVM$qq0++FB-Mq^1d6%7$*e(q z`;3!EJXNbb4h@BxqNjh~i6ypy0pxOnyI^BghoC%C&9J1!JJnUedf(K3!I?Cl!11q5 zuVn?lT=jqCTL{X=$=S3zJyBl`9J@QPy<>&Y_q=?w72D#fs{`f76v?y`^$>3v(=7N7R2i&_=^NA06QQna zENs+9Bdr#a@-H$AjLJw*O-*r$(AdH@t;EYU-*RFAuH^@x!aa)*`++BQehx<|l=eJ& zR=PmhZ_k6?$UT2zGn^DWxyv;95;}k_PrV&%@KPdUag+k5V5lMsU+r9HGCV=x;3HaZ zj4qXpu~$+=MK&&Eh)+r$D~7(s&|s@p?|l3c8nMh7ap>DeBc#?kGvflouM-Ya3+3}V z(rcOHT#+oy5g>^fIj-%HKXf0=4Uu?KNMpJJiPTv{{~3QX3~v1zl}*=UYn;2hg1r*c zzIpS!)1pCo1DkCm>!{x-F?vNc#NkdK>E_2j#!a*P&Ukr6Jd1a;VAD|fYm=I-Kh2R+ zFt6PU&qQ1&(CLxJR!9Sk)Us{h(w}E{EvW{=a2)GBA7tfn%!fvA!gB0Byw5ecQRZ4Q z32hta7BhcHX;nELVi*dBKl^yWrx0=G#Tj~1p~sJGba0zlG4GL)GT(zXOH##>R1~3* zOhhGcifK!X2P8z0L(|8~@AUZE#s4D5Lw1BZov@0V&H-SO;u6J1S7jwvk zn6W6*JlA=`Sv05?|E5?hmUp%t4SgLkOoOdJ^sL6|d)+32tRmn<9UdVyOuXsnK-5q! zk?DUb-?{No(s|ymt|qww;4l6TUfZ-nN0mQVz<}*ot!o-mf6qbUP&608A;Wd?5UF7?W-t*mhV&Gvv#eVPexASm_Wu zBy!;+lV<A&B_qpw6BYs8*bm-KEb8N$dqJnzd2a;W@EP+rJ(cylon2QlB#V zZD`y*w}j7@A6Z37i~hDz_^zE?s9H2~MY28DT4<~f5jy0iXmzeZKHbs^!C%1p-j264 z9Jl*RBA}{iPa-IBy;VT=`;WZywzDFR(_P^|9NS$DRA*0#2A%L+-uu<_@Hl_$Ng3eI z`?iMi4N549mwQ%!@EXB}tPg|~7}b(g*B}Qm3nNaU6BR5rF0u7O!Q=a*)9CX?Y}65> zU#7u0g}Z(Kv=W~9L)XNU{&O(+7}H6$|K5UTdF38(OE);-r$pt;F`)Z{-DJ}Cg34hu zFJ%7G=`<*)Xm9H9<3yah`KEse(u!0x=qJxqwomDJ^h7=T$mJhMYf#iZ;0H}47HvoM z>DxbgD7o61$=*Ni09OR3u~H5 z^#azKOBD^YgA#vqy9z51i#YveouuROIQw4L^R~yHtM4}Ix-0{GCcL)2O4L%b=>XRxmhA%mU5)h+Ag@_ckTsvw)o%=(2VvL8 zxxF|!fh78zbcd8~x@4UJhw{(#xaH1BMIN+d`DC{th@A0(CvGyCE@mIQs_B=WI=wpd zX3KuB)Q<(x+;~ta)U=Rcwd1rb5I>y}17p)(YHtP0EQM_0cgBBUn-A-+qkT>VkyA#Z zJZO@1np?j^>VH7P)he|5CADz+6~=<*xxu)kfaE)=H=njOch?xANR9n+7KgCe2k!{_W@G3!{lM zHC>YZEo&EI`K*&y#2M#d8i;zH#T=b35?JD#T*18CqqKjfVKad%=bXpCiF-w97*wyh zY3Kbetclt4{m;}BICXL_BFV9w2))|tiMo23$1`@b{J-dPn2ihw@^MyT9EL&<_GNe+ zeU9LFt@A^^^=al$$!;n`V(cfrl}r=v@0WK+%x_|S*!rOUvGtCEUODbQ!l%DkhTQh{6-lkvJOr zA}N0(_CRbgKXO=^6niYcOa!GC&$*qRb)iPl-F5nvdR!V2!NVB(qFop5_<`Jpsif{x@qkH^RB>6m&4t_vay`9K=7?^(*XGPu=;h0CHh6^FCyb;UH ztp~@YK{E|zxy`$!`0jrY$wx*nHR)ZI+GuE`oy7`TS4hwDyBV!$PP~cw zDq8utBl*PNddKvI`wcRtj&;%>%XmC??A<$}^rzWIjc0+vrWoxAl+VpjH1@w1Evlwi zJO%}ToIWZZJm045lTGgdT#X*RO#Tm=w4Qj+Zb*D17;V5N&`OtLh^{FXjbVSI-_3p5 z@YBXP?0a_M*BJwcpacqC)q&@o3_|Rq>^U9vzWlemiuDCGIO8xT@F;XwjC7 z@5@IG&dcdrxHm#geaxdaVP5N%0S-Z=YBrRP+l7mhbPH4h!8wp#vVvr*d;Ae6b5ec;i_*5o!N6BgcD@{xR=$67yUp<1R#L&q zrx;SUijq6!O|#<9@WEaW7#`s>O21NGg7HGMTC|84get zLK$D^Cc0}RCSLeiMV-#$cg1r1p-TRq(!m){tdp3CMcf}4Knj0Z>^GhEQbwPxajmeX zCaIQv)I3RrApfFhk4jLYEVRBq#+jfXthVfZB_{a?7X2HEh_`#jlK3OzdznstQatpd z2!lW=>I)uC3(U-vPmuw#ev`*)5bH}n1*%&9P~T|I2E@g$avkwjM(^h>YldJyX7dnF z#;Yn_|(*A;~17wMZHwI77k8K>v8;`eg{-|~eh~VMcx{Li$GvtbFWlqq~ zw+2VNp*WOz3tkpYuYsHKu`JYuRY_QsG@js$2Iqh~A$x5`4jzNuN|Y_7krTPsof(#wu*~@la)+u<@O=Mq?TL+SJUV`USex7c(=nwX$ck8@o&j z_EGK4&iv3uV^v`w)C#4z%#X)0tT1e;ud9pvIj?{41hs}-@vPr2ZH#Rtd=v@kwM*do zdlgcgz(c3nd@|>LXwn;~iuzrl`Qdk0NgHYc(J1Tv*^q|-cdj+}**66 zS3xP(LPtwNk`67#i(#xXJ4b6mdC5Qi@SEo|JZKw8#Rp?_D0#Fj)7dLqjWL@v2+-!~ zZq0uj?iH+K_mfy;C`E3h8?L2PiTx++ZyTsJ(J*OblW^_qD=<^CCGZmv`)<4C?d5ib zLHIQfKHCVX^y~eE9Nus*P&P!yZMJ`b_dFOcUCRs_Ei1V^G!eLXxx+`N#WF#`u3L2{9gwR0w-X-2wZfa z>jIG1(Q314yOY;rgk~E&u-`CtVMfAW|8ytXq(*CTm@trJwOnoeL^4`-u>05M2Qhz- zM;S#rQn3a|PGad*-|Dm~SD7eliJa?G6wbgRy4-G`+4^2~JnKvkE ztB}@Sn}q2q$p`BV`FYaHxm1AckmS*UOAbtVf@)kC8=A^nM|vwa>JVlUM$%RYLveaN zb}2^g_nIVJO-fP5Bm z)U$`L+wIk9H|f>8UrJ-~z!wuv1B6NvYdqn#AlKSCx}Yd~CEL+I?5ZPl8N%CiTCv7( zn!K0s#L5|z9o0h~2$OcZqoTcnyb?4%b#}wgD@AG&mJbD-_}{fiO!ys0K+=f^mCkDc zKgyVTM}F(8qQT|^97KFRHTi!gD!KM2@J}z@T^R{3>j@((J+v)lL`;4vwJx;%P<6Va z4CK3wjV)#6l*T*#$tS(T@itC0#2_@w%H(|fAbYN#?O{?`g2X@pQ)Q>n)dmtsCo+@v zX&cg!UoWIK^-@c;xJ$JzGF5tw)_epr*(L7!TJKyRaO8)ful0yWe^h^Ui2bbpgdkmR zS`Hc0Xa+cxo3);7pZ{38!eSOX&VXCpkk2=e3fmL{fB#YC+{GU9SphsP6F*~MPqN<- zzNSqpoPxv6VlofRuoaZ~td!K-Oi0ZNZKr+3>lc8$cJwCx(6<3Sq;P0?C990fT!&;B z@lDT}A{=e9c)eR76n%e)<4SWLJIEqGE0NCdhV5Xw|I0(2rh%?}<8dcxm52ryy{hMk zvxfRf$a;exe4SdaePisOAsOrVS zt{gT$&UK$rcCa~RJH)tiK(jXoiit)CFmKaDz~in55yZKO>=*n={M1+^q#+;&wK zeRZhNrQ$a1`mD*~QY|R!CLz3SkKti`|Cu|4^g!mbSX2N7E6=yU?M!Er`5U$Z6)|S= zK)X#h6og52mXPUMp4C+DsQ^3&8jSPd>?CzDajO_BNf>`#{oQ)5*~g{J4xUC{aP`{fpsE`gxQArNV8!Zb-pmrW{q2oag-;POm)(J5NyRk`| za?Jz)5lGAAH`0Zw_J;QBJSx6l5Y?B?;TMd9anvtBM`%a74LBz> z0aT`cXu>os$eKL#Mw-RqF$OA!3hBeNwngpG2XcP`gGx^iDV}`hGs6dw6n>1W)%=p? z4k2e6c;j})TQfQ_><_2TYQVmt8Ke-eq>lOVE!}tkKl-`ZTJnIb^h@HF)&oMV!Af~? zGG7|sB^!%|c4($^f&ig0%qL}wO9vLAf^|ZYosN^wDP*@vkD%Fo=TEYzqYHv&5mttf zx#E8dljCP;j4Hozb(Ugpr11&#A^H?z5%d^gu{Nn1CRjX!U+`fUhI67alPM<2+_gU} zSqDIvUl{uH+7kvQcoYv&mh*Z#HscM4d~V2cCsMsJ1@$QE6*4!T5DHyiL_-q~?CIj! z{Lf`eY{pzSDBJ=${bgOb;cPoO%XXedvqFD9L!a3=t)^bVic}N*oVbqs(H9(VV*pMw z7_DNBeCUagQdehMDeLUX=TbiEaEa$TScZMk3AnzD;#IU;8Uts4uVQWKoOFy`TOthv zsmy0{cx+f7(K&0spjSDYw{wCk-zDX;K?>Z>b_ZiUOZK`&S02`r9v&8>wck&)H8FG-l8SFPF5KgJ<%Qf;c2~k4=8^y3EwAK){F7Y z7B8%P?23Fb5jVP9s6a;*DuC>5b5wtinfs{&!5`SSn^&BJ4VwX`qA(7U4L_V!-ZsR| z2ha5F2du6~bvLL(d=1PSV4!0Jt^Dxo%155$>CLgbw23W4$nz-WS<@UpAXw%glea1;$ml zs3lRMIFx$z0U@xsIhcuI2f!mjKEl}efU5}sUxJJ;-Vu`pk;ih=p@0;w7h2%qvZkmE zvR&XHuO@jBQsO%&lcH*%u*OIaxk~EbjgazEx@B~tblt`SaRcUNpU*&(7U+A!nhv{M6(p+DKo?HM`J?{Z}n+y7}4^6c0ayv^u zQE}4T19lSAj-Sk&zCV9-iZ5{6!5kV_2T7MH_-|I)2yQ#ZNC*%u)bW2QDSxS~`4nmGpOudwJXO%!DcE;DZ~!0v^PSGH#e%hv}LW^98*|fv(vKqQj%7(ko8c43jz$@o} zC`bw?azAoOhS8VP#|-)yybLLUEavt(F;OdQpK_eDUydR+B)9-g`4VZR0(W|RguPAG z7R3^{!)SwkG--N({v%Ee*(0MJ60f{d3K?(BSN5**euaNi?an{RzlesEN))SBtHuI9 zBQ_Cd+!k+}`Us(bRd6o+Qay@_=KYcUc}ytIpqi`0e(tQ>7V6LWMG;(fn1aZ!O5iuTq9R=?ix(6&kL z)!ct?ivfRSuLs2}KHUo+h@c~9ZH1ejDD{HB@4YY3D||>Ykj6f)xm%Fu@91U$|5fk( zeDEc|pTmT=Tt*)iv01A4uN;j`t!NPu(CQ{*T+FaNntuN>DcwWOR5XaxSOBOUy8Rt| zzB4qmQtjFcyF-=sp9Enax17{iu-Bd^___CZ+kStFbF;A!1O4H&I|$VLF==!Umwy*?YzyGoqnRzL-<(@3pxYT}%$(8_zFdIXm`_9I4T! zpE`fp!E^dlYI$)U(N>Z53*aO;JS`6oi428i;S|D=DOF&(o&gx>>lDUuUwU+l#E0HAMa?8_zN zC8JX~C6#S|JTdt8rga%-?2FpBI10on_M*hkQ7oU_E9*k%R3&3@e7mQ`jd^fb>JY>VFt=q-yseOOu z|BLr4jf>eAvFhHLBDY0)XnyHp{(zMk=5ta?Ca9sMj=b8$%5q)P+ z)=?&xWAynzdZ^|2`@S&(k#ZZz$5!(cKH2)hGA>E1p0{afbpBHcPYUo`_*H_Th5Io` zHw69d@sZwcoUwky2`q$i_q%N0I`n_y39Q6LRn$K?#L#h`;{>Pi9w3CbL!fJY%o8F@ z!9vFewkude&}qjs%6psqU`7#B+jczhmENkVLidab$ieDDX~@1d>DK3+(6~l`uo@qS zhC{|j`Eh-WcpWp;BL;Np?FjsVht!*Rqw7miXVa<5Pa37=E}zVuWi8L5efbLDZA}-%uOE3A$}NW5ND` z&#Jt|!|927E-nT5cLr3CyW*jpFZfd4tUH>;;l#5;_c0tjo0s1ECHdUPAn>m?1s8u$ zS40l=?t9;In2n*p-Q$MmD0_e6uM#4*+%Ng4U#}In-eHvdCyWJ})bTuaDbi|&3EFU* zJOR?L!A7cLjs#FbpV)rE7j{(TfONIqW&D=RF><0f5=fV4u9%)ggom}aI1{H_oGYuY z#Z#^^ztl(Xasri>IU1%zhl69G4XVuMP1-9m6tv;2OvDW%yJ4GPUVMM6+W=1eZlZ*z zmm63#a{T=)8 zI*2F;3-t5HsBSn%gC4fZxWqnXz`lE|sNWeO77l!5kVkb|WP?41Oy6FGG1Y9sFKQ}- z?U^iK^O014T;mVI%Rhg&Gu`!fg^7fQ8nEeO@pkIG4dsFP|O6_`e?rl1t z3Ce1EH%M=10<%dP!8T6);dP=TXU!$c5TnBWyV4!RF@#=?Md4_@MmKTBM=+@nGjT16 zm9Its4zXS_l=_7_0GX&w$Oc{!P>DxY@FYxe1GC>AXGGTCVv?Nc8jb~2gNVm&tyMcq z=dQepc-rHnEN6ddd(H~uyNLhTtK5WdDsgJ1PgL+?eoD=k*sB8ItAtQ|-Apv2PjA+- zY!|rA%Gu_#u&CCVy$QOPTy9CW_qP$78^To>qR`$c%JHSjwBnT~m~b+7{a3TOb`f{>Qrugc1J!X3Z&gdP? zzffK}b9Vj;{}~#Izxj)c_wFMwPLx2J`%x-{)NBua_%2z5>c;C%X(@pFQ8Z2kAPi4N zA2Ss<0N;PAxT^SjF<{FTVB&@;KD?^eT_E3l3i%aD$$FDkJG$S_Gb{k0ee4o1U6Q2Y z>zR~k$O+{bR(CoYqmJrGAl3Z!-p5e5p@n>NVPN(2ct5OgEv6;8M^S!NhJ`w9m~D5d zD#Wm)4s`k%?0r<{$~~Twks4I)G0mtxxCeZb^)7$j!4H>u??)XpwT-y9P0DJ~*?BqA z#W+Px)P`3I)g)*(-4y#%`<&KEAUd=+n?7xoaIQdTe^0CS9PXjNc^g9@>2WHv&_{;2!y=YFvs*Tb618*Aj z*}s1d9RFI^Z39~6NO`jA+lVwWuA%JCk@tY3-7$-#Q670`pI&oLj_mipdYOnw%Rmf~ zyY#L5HTG@2fh)MQ1^>#UeORqs`9R^j%2v(W33@*~)7hx!UJn zLh!#}6BA@nvnN3IJzGKJIibT&x=Xo`0z1s;ji*@4<}7>4q_)_om;KRR7@W2qzq!rc zmDi7|n0D2r@--t`}=8>B1gioWZ%o`H-)kLKvPG`W@WTq;7)Tq5>u3hB2 zwSu@GvO)wTZ#&uCZN@*+j}VQzdh>s^nIl5G@U)$=rqCsp<=@ zcA4G-#NnqNmBN9iF(o7HMWEV(8YGV_&i9=&@6(zE%mF1?$(+-7gF=?7Iv$213jWHh z_U;4cRrK1`AC58CN|N$`R?h(Y?~p8m!i@?O%TKVuV?Z&d4o$jziHXyOL( zcuy~xb!(@WzXEI^4&gzcYyEmpB6M!^gkRZC-KQe_fuo)bCPOSWxhW1?>L8aY{=?0+TAqy>Ty z5w{{&oM+ng_AEfBH)Ttyd>4GGg{=?r@$%pG-V`guU{rJKd}D)$t{;D{ZMtrrG^3QD zY`BN<4iQOcNNcJm&vgiIzRK$5DSWnL-q~wqy_jnw=E!<-WetPX zT9jyvP4O%PdBeeA{W{WEDRT0G=0j1NP4)#}?Jar$bsgU@b5nFiAp{VMwTm_QerFi_ z43xrHrhleU%D)uw6!!7Go3Fg&m-nHLM_C=xSoHD?qoNp7gGd)o0QpaowK9Rcdq4swWT<8c#jrM0<*o6nJhXb6 z0gme|pA4T{jf-Ni?_F3~OR+tPWgkI$|EatMz`U^8NEi&_sBNrxr-gz|Qmhxf$dMzX zk#%(rKy4sloAQ628NQ^MU~WojyYWRm8#G)vOX&R`i&=!sWB%hefpl@}ynsFl=yvsd zFdd^pGu_%<`Kz%MacL$ksaI2fdOV(Q0$FVwVxl{@+E<6(*ns?>+b7g88eerIL?U@A zZjEx93(D}J$(aWwGb6#oBWq?xYzf#0OoS!kes=(e$nSqwD%Uzgy(h7>;eXTqu8hyHlD5B;`MH>2LX)n$Rvc6 zo^yc7Ls)-g?T}*o0kCt|b+zrpC#K5@p}deCrq9(dmFOhTapn2vZ3)0R5`Y;vz3K!V z`|ffW+ZI40r1cfLdWdgj&9LxHl76)ZVq8BkuDbosA<`Pp z!2v=}`MM>n#h7oc69fK(ExR>y)ixt}I-Ol(N+^HSP_J4V_A55Tn7oO)u&srd zzI#AsP?>#~>}ehQdF|CLRe!2z^Lx$YQIML=+*a5M&(KD^q->)kN@gj<;bAv%NplM6 z`*(lZJj%Qdb012|49`qT?g0f1w6l?3R&P_iUftD;o1pj>#-VbHlr3cAe)j?H5p#{)6dV?UsqDaPd{4Ln6|47fg(1Y^7ji}xEx(A%`#e#40D)c%aaYC?0t@6*{jnY zS`qn9H06{_ae{;mgM)#^<3=7jW3u>xZHgM^78ZYrgHsF)Q179GFb!#hhq=PP37`f( z);mf}PjtHazB*H?4ZmK;|Yf;X{2Ed{44_OoPU z+qMaa3qSegLV>z~MD{Cx_d;c|W!m${Yj_}B;3vrspIF|F|2^e~jwG0EB6^+_D8JN; zqVL9unAmnnBvq;{5>xrLOPQy#o9N+*zoEm&W_QJ_`I&&6NY#FnSnI{>$#H*phEiu) zJc>GU`ZhCWkWX{+G8INzNLe~ksGQL@t9L|cRc9#~E@r>q0I460pe7>+FDt6Tdwa}9 zibM_zoR@IT=4=3j+}@xiIh?mLXo^$JrkE)0F|+_g2~RBH>y-oY7obF`6@|9%~$7}iu#7O80QFu0CsBYA8mitVKQ&En`zH5 z%dNlF_t6Zn21y33h23h~8l!UNghY=c!_e2-u8T3V8uTDco{^q&Dq9LP3Ul@A7U1KU z+^3x3Ws`+<=D7WAI6})M3;^Kh3CZl?rpL#YMR}#03RH6E&2jC2ck)36mcMue#w@4f61QE8mm&U&q9nFtj`P|7dbw1QuI z>v#9Z_@!y-bk12Yu3rAzoAAG9DyBcm8!TS3%twSIukBnoK(uY3Jw~0!kJw3NQ)NW? zD~8D2^X>6K3xrP5)qTsc?-iTfM>>LximA%k*V*jM^2UXDKE;16v#!k!z_w9V05A=> zd(lYTTOAmiJxf~-KLH6x5cQ_bq$d&Z;oVQyW?{mp#p&$=)+IpSM*q+f<(n9 zcD00?^0DW`#wicA(qtD0QipZEgv=%(*~004`R<$@iqeo`P zVx#WMP8p33mXnrM=haQTWe-YcZNdj>Kbzq)?^i7JA*g?Bl;(aMj~cd;T}i~`P@UKb z{b13lJ+Wcid;4}*jXG<&?=(iM&xk5{Sf$kSpBN_|GLggdAC-7IA43_~cyd7!spv&) zR?9ajv}~)`n;Pn!ekRo=2>fw(AyS`Q=Gez*<%=1~xTrbLAgefk24wvPe6~Y6eBbScP!LnBSK$oVIUDI#ca(V1p>J-BTIEtiQY6O z+1gZ#jfdfmCmcfy)JS{SVM6R+p(Rm!qm*THZ`gkyNRsEGJDRq&*ks1lmawyG&_@7& zKrZy<)dQS1n!(FImARtKBUI&EC5xCVmMc|u^uWMCB|5jO9CtoE){3=HRD^zzTp5M{6{2T}zMpT4^*u!jG-2W%BG zkSTv-y%uAA7MyX;@6IYI4+F``0oW@bJF{FETci-R^y?evroe$@Uyj-QB*1RNDehaV z#@ybKWrbg~Ife>b~lBs&oDX*TCPO4{Md_xOR^3E;i_rNLZrd{H9}#C3S3 z0he=o|%8 z+&1(WbIUKPbc%3wb8rBj_%X3rWN!11V=H7|NnffY{;HP@q~iNJOIv`&Glwf&TmQ-i zwwmf@&C3T=9TOGCcLLJdG(LGrB^gJ=iPgQkOHYvPoJPF9;N$NY6s725Ar1b!!s&l- zwRtulhL&$3&x8>HzqLc)k?TuaL1V?$Jhs)N11l*ALQM&Uw3ny}j|F1;ac+<+V&N#eNTC;;A6 z#-AwPf;+Q$U^J(3TKZDfEW1Un=(B%8Pqs!1K$Vnq1xgHmZs%-Kz4a##fo55svblpW z$U#QBT#s~aYq5}m8+s1_Z4VLSrmQC<>5QT^@q?=d;)q2flz!(|z69h^Xp69yT!C&2 zNYVUOVxBV({Yej`OxU2i`G(=^Jf@!y1}_c^;mQ|SEPV;10M~{Azq)!@{ic7!v&Xo^ zxcC59K&Zc%5mdn%&QcpW5;gVJB~t=OdezC=$n!ImBsYD#sykxFS^(gNx^p&bXt@VG zV;?Fr<46!BVbN&J2CR$7ZROy8oIRzny+G;&zus;5$u0eCMLv}pFDeY{?O{-(cskNG}q|JCMGin);$F1%B-w*AUr0n9UH z4EXa_^{q4aHjKAK#wU{_Q!R&QxJM52_%)^uhUsNBD0+l5bRugbdd*1MQ4ZbO1WWLM%grv|gnN-#fCMF43n?!(%Vqs1|E~t)21t z7V0>;#n$}ZwpNcbn4iOM_4FTXN`?V988U-(292qb_kXRvYe(N@>^KFVsgqY!AQj>7 z-u-MR4Rkd=W9VBH(@17bGS0Rye8;#Cm*9ljZWi=7RnKS5H!$}23dbqDiLV57dw<-MmH-#x^LCP^w5Fey)PjF z=B|LE=K+Gk#>iS_Jm{75Cuufj%6i(YGWtNKXvw8 zaVa+K=V;k_a7G4A;5r`m()o-_!+YWl8U_I*rN6K&`!D8vAV!L{oNsDJ%)LsS>vfpi zKp$?XQ^6BwOe8jwMNU6Kr7Umi+R)oIjQVGgVW&C+`0T-Y^6s>)TmZ!Jy6W0D#L)UN z^uxo>6%WW{ZNS6D6o(tuvdK5tsxk$0>fYC5MDbnb`e) zf>{zM7osbhd8p*e?*MV8<7?E#1SQ)twQbi!MX{{tRqQj0D77+wdd}j>H4}kES%+j) zbyuXbAJIs(Y*PRLK)66$^p496KzMl&r8e4>_uEESLHb41>b44^-|`qtR}}&~L4Vrs z9UAmex=Gn8*o1Z$<8hfKMZ20zh}bU*nufcG^(8@E_$oR28jZ1b!9*AA%4hld5g|Md zVt4+PeMXt)R)JzjEL}aSV|B8`OXB87K1$+EbeEin1m_n4jge%i{j+6uO zhi8W2(?H~hg(~D}Qy9>3@C8j-fz0Eo1{GK4iDsL}_YH};7iA9=775eTvwT_%lnZsFYWKJPmgh*w!y$d>>X z#=fz&*OX^}Z=&|ShKz{-CZmWnuenTezsEboh^PE9lEID9-=eDD>Y#pLqccd%E2(+d7%{9o%iI0Z8U3ukRzA)*;FSOkN&@Q`BU+wnS9wT$ zvUCP#9#e!jCf;O~uX+*s+GG|c0WAz|K-nRun(KIfFhSr=d)ue+#W1x806EfN%|dR! zw6YN-!bFnrRiFwrR_vZyg@>Mz^WLPh7HeUnf?8h+?5e6gNVZ9I1}3u3cQ` z_NXoQ7#u-!3maVdQO>ww?zKWDeS zgQhBfy?sKFg$yyy39cedmjmow<}!J!61SHc*|-YHwDj()Y%cg>-BldFYKr1@AB-y^}wR6VtHjlSnaY z5pL|GD5kYjBf?XV{4CAo6_@=9Vj%&qoYm2P!TsfFgI{BzI(xzSSK3K?g=K&Mjfr{! zHl0+9nC-4l0#Ij~JkY=T_Pr5bhyd3>hxZfpse6FHgc-@}4$-V(vZLEH$Z_sEfFy=k z{CzylN-AM|AG*@r7c6wuWnqpPr;XK?(qJ1nO9AOmygYWSa0;zbR-me24rfXoqVO1h z3v&c)Ma(h;3pMoMsVSyxyoYJAAIQi0!jh-nkM=zCjl??o?(=TXRJm2LtbD}Sf>)LX z()(Lu#yQ5xUFe#7zRZkfbL*VvkH^Cy>l`2lGr^fv{AXjQuS(?uU|(XphZbK6jUVwG zqy|%7IVrqYd~0;lKcPeS*}q8Zta7P;AWPN10erCDuuc@H%+RQEX3U*gr9OzBsXK9O^6Rux21fdMm%zrXa%C^^P#m2qa=zOE2|s;_{M zE*242LW8wVU?D-{{?*@hfBvy^mp}0mIvQ<@2q7xCmAMB@~ zA%qq}5+Hy`mw?ou6p@Z}L+`x@0-{EgBBGQ~L@5D9Kxs-*Py|sFxjyfG-|yaa*SEeu z?r)uS&Y9h2&&=L?W=>z9t^m%OMfmvu02USy01M#%;PexK*EHPIKN3I(VEo&*{7ZjY zVF_Klt&H*x3knbQ^!_U@`G0lwKdb&D_}3d<+fcv1 zi{c(&8sr&%%{!1_VX7zbm!st6=cQ|^4%0GHH8F;ns%e>Ns;X+6nyQ#Vb<|b0p(aoh z9j*V^`0sSJHK6Kd8b<1B+9rQ6RaG-hV>M%#k*T_xikcZrLsMPnKe`ryVFdR;Pw)Te z`u!hWwf|99*Cf>2oe&g?4hjnRPXr*Z1`&e7t_B5zOzbs5U-Ya{nyPzdiL1 z^}Fuv1q%(j2Kv|h>iYdR{i~>`!C)#H#wKQJ+W(AOM@{puH(D?iEj52*6)jVBiGS;Q z{r}9F@?U3^|DRy_59x0N{`31^q5rq>U&-Sg_%~xh|E9+2E`aM_!v%Of{hNYxr*8pC z00#Ph@b}HY#K6G7#Kg$Jz{teR^beR>n9uwLGYbnV8yg!d3&+2}^$&Rd3v>*OjLgi; z94ssxd|Vt{d;oPBqr8ps3#6mTx%U%ZFMA2* zl{IEeQ~EQWXTE;bAOe<0(L>sR8=EEi|E4 zn(j}{FHBp zg4eqtwAGn)PacQCPpGPp%2BIW#aL%u)Z<=tD>k^({nEpCCm9yO6s-tg{?J9Q)-&jqWqfr#w{=(_ucdhs7kV6K6@={vSf zTsktwi_kiq#=)Bd5ctJ=F$5CfMeizcR6-%i<-1_nv)Au}{|srUx?0W+2Uk<=3!c>+ zW6`&P+3#=uIoGA_+c@mcV`Ob%dd3#giBIubVr6M*72dBUJSnE4`EO95!K!ruP_8a}<5{F=DZP8J=~y)v19s4=RyJ{zEtjJFNA3kS@RY?xUqFke^uyjqejJ4<*)G zP~X^2QetPVzWl6|ypzxsrS0e`UCRcZI|W2t1U^q%ZQq%Pk@qvbGEL6Ev7DOBp0H{@ z_XpBC^BM8zwHI{j?#!O;oHEm-I7QR!N|b-Sz@uG5G3ptXvwk-kCD&`D$X?-Y6_!OD z@wo5YO^6(kxZ9#c?hEQu%{iCPPdJ7f11V&qi{g3d$w(l@8QGa)s@+L&^-HW>k97K! zL6UayzeL!#@Zz;G5PBn@Vm?nyLE+%R`0U9I*+xEeeNvQL*Od~G9Z=j&r+pDpZ>I$Rrr4%LN%Qm z7+J2Xho6d)`#C6dN@y<_%Vix)07==aJi!FU19f$`55HE!kG!PekQ+O$C|A zRMkI_k0wbO&G2gO4V%zbcP*(Zq<$ww}pIYZ4xB}jkWW=p<>85!Q$dYhGv^f1Cm?L<}o;TdD$eGCE2p5wQ{ zn$R33DV4=8C#u0cg|YF*GyFN|L!LcPo7k^a&kG$`TpkN|Up+J%;Fx+8QL#OU90#%F ztV@XPSTsyZu#hgyAnJY5e1{>YL&kOWgC%D6bl!cy`j&{FfvvRbt)* zU-INZ1dHW|{Utd}@3j0cLA_plIW1Bxk0_yJNiTQc&bm)0K>jrJGkGu(}$w*9rd zE~sY@AN)J=OwWL;-M}fpKV@gDTL+#yLTj>xs5zY39Y$SBGY3_cq8<-t*2it8XTLbX zWIp=R0%1zKlSS%>kb(-<8R!myq{!8B|WV{zCp$3pP*MiZd&ZfMSot^4 zr3UM>nT}~?Z?)vi<#Jfi&ZBK+kZ1fKFQ7N^MS@u$R-WHl!cPTGXs?4b%QgwiZ4L)3 zxgeH&sDpo&=Zz*IB9#<%^{A;DcGFH|XI1P5u1WlrghKnnn2T)DnN^AyspdK}yfhR_ zy}j=pdZs|}x*fGMUH7r{9wzf}bYBQu%6VzW;6P(dQo@3{CGfLLZq#wsk;Q6ztQV&h zrcNrNK7eN*D{#Q#vmUpwyAe$*y}P0UxL9`7;`e`Rh|kPKn%1hVbuNtOc}=SDIhp(c zxVIzYAz>kpuyzXA+yJq2CUU2=GNnM_YJsU~M=iKpE2^Me!PVoGSxnorquQg8EBN)5 z=O9KpDY~gZhaZjaQ9ATFN=X9SjWogw@CTF7>qZpo8>5*?JnF22;beG^_6FE0-nhZ0 z?{|OmeMj-!ZC!f$o|(yxCg4yc{gOkJ&jBVo2uXKV{D&Yc;7K_&WG1U1icm}C@G_2Y zxkW9)%>{gH^pzFKv6BMiUlezqbvGB^5GM$q4?H*pV9RBfe*=lspB8C|8|)h7X3trdUD zXLal(d4?7v^+NQEq<3>`&3*Q+;aVA=9YqY5sj2NPmorU-8ih9PIeq!c;*ES6^QuR<35U;S;p#AOZD)KY{y3+f+CUOAj-9C9oQlf-u zs4#Nj@lQR8rBQ0#w)m_ivOu-+D1Xp(g|DIGg!4pi3@*RTv z_v|9KB5r+1g7E*QRb`G7k_zA5bNw|v|7E3s1F>u3{~JT}*`LX=H+3cBU*}X4bzlQ* zg?-*U`LFVLhJ?QFq4E;4O?ZFcpH8ktPb*s=Ne;4f8^l&<%SGp$r*Af_6K}}}c1q}1$pU~9Vw!|Yn$DFBiQuQwPgt=b=& zk&&KK9_20-3^-b7rZrYNEmrb+-H^NuJXyTRVIFal@9Y>FC`dcdBn^L*6RGs3MY9nz z2LjMa*=m!z2sAzcUpw}z%lVqkohFeXmW^P5rYkD`Hfut}ZBstNx2BwfkyAiT9D3o| zJH%aTeW*Aa92xYR_Mz3&lbB@h?jBqa^$5$KzYK||kLa0xp}m2UX*~s0+|b(|ia_y0 z-A2#TLj_fV3-(v%URv$KgaR$d@BYfUekdXWx3O3GTz3ib*kJGcNpk zJpB#4fl6ntYbH^|N1#o-+X_KJ=Yj>o3RRTY0QvyZ%h`YW&=Sru|5|@IaoEO4ICKj9 ztmN6m^K6eZf9o#k0=VpbE5|bw&B)mR|Efax(K+yZUmPBkB7=b9;~gJn*}kgxdD;w{ z5`;|cNkR9ODms4K%K$UXmBp*krVHfEX}(LaOrbov=SsQPo}R&#JPH{X8%1q!tu<(B z+y=&NumOKif7EwmUuGtSD>i?&IiN7j1iFrFzraJrlH?%P>~QZxE^q6EJsYv_tLk1_EU*>2 zrsSz#gG@3Xeg16ceJzNY5ztCK1u)NE4+tK+>_%#Kc7;sBK4W#Hffh-bIc>8a4pdI& zpvZrqZF$cP)6^9B7v09v$OeDf?OmQuH=gug6cJ7uvoXEAbpLWfyWj?Vg9&iYg>$9yemi%UfGiHa+4XKX4M;LE07~>E{o0lrdNZOBC!sm3RN!7k%1jCE=Doty zwVa`v`Tpzr@48zlTPwIe%A&T{#ukcd?5KaImEw)l5dg8IYg{~!DZf7h!=%A1^WOLC zcG|#wlQscy}ITv^9Q=}+FK!3-ooU6uMA?|md zTl8U*PwRk4eCfM=-kYK&)8Z6lqpj*<`f}T#(T7G>cf-g)sZKybb2VYV&V7G- zHHXR|dx3(#cRz`9K$wHty{+uf9pzUH_{!OBPbcz}$LqRL({tJf&Y;HvJ^N-~$YHG! z^U0Yx@ys?#VtpY`vNoFJP|`gzbiZ17fl(_y=>F5=8(vx0|-a98S8&pp0q#sfE+OERbMD~PJwC(Nl2`DQO+t(XItls9=vO` z(nHHU1=#2?=4VJS*9LpmC}}Dw%NRL-R`+7!ckW-PZ|dQdLekB9Xw+T(lx^$Qa=_}n zWBXOx1`-EeKG7gea^XCse*-?hy_I3Y&GHc>ky<;zLk|5EBjzmfG=G16;Md7kYrs~W zoFAkH$w_T3I0aZA)zb;jW(AbmFENKoJhE#~O~c?{5)+{c2N1_vuGUs2gtcXRbFCi4Zk(kC8dv*DDLOMP;(%$= zPk(*(C3Bw_splPRAXb0(XE|+`*yzwBEPd_2EyrI&0pWnbYNn!}Z%Dn0;sqUVICng5 zfuU4WnDTkTm*%&SoG}(_>#SeM2W!PTc3U9sc&p52S!v#!E4tOL_QNGbHTay;+T8Ee z%}|B-E8*;x7jumAhv*-_g2q6K$*=3f&d0SjPnQE#CNZGgQt^L~6|1w=RHm$spaS1> z>7HX$(x>!g^*Lp4R?^q*yK{Rud-oAAV@^{UI&(wG_>ivHK67sdXq>EsNH{Z>+1N7S z82KAlL(aZxT8XRryw&ZI2sWg=(5u_qTAvQD%tzO!#y9!c zJXoGkh1OwybYp+blXo3&jo_xfKJ&Ir<{pB)KLzY$MQHU}FhlHivuWemZzm)*Knd_1 zl$M*~Hc!fB01I)!A4NWrh)CLe=;|-yXh*GX`CVLaPXbqb?dm8`q~dFmyk^g|vbjk0 zvGMVP#jQTP5n(u#UTDefXWgU_@0bNB=U!mhZ&G3+-=%-_3wa}bn;(Um)w02eRxn1A z0$R(zioQ#y8BQAFekTow1TfLMX|kX?bvk8le2kDhN0K(Y<1-{M-_ zVa`!qDA{?<%y^l@3IyU)mkP4##%6oeI9edoKy|~~;16aZ#5!r@GVOzh(B@vW{0!r# zH6p9Vi=ltZ4SJJsc8Qj|(#m}o$Mqo4K^@xcVXFbQJQOfC*Ex&w`&E6f&A5Mzd`5({ z4q|Wa`CcDUJ;oz>*mvg$)zb*2Pi1GP3o2Qz!k#691f_4B0>I4B$Dme*7`d~a%AXzz z?@1)<+r&)7j`?l(g{Himm?-yYX#P06~BL+Rc_@HZ{;yL0HNuK)BA_`iRwI zDDHUXL+e18RE;0UN2V!%{#W3po&dYf(1+T2|t!@-!1`xQ*g z`Oq^2<`3_&U&^6hwXXF9VLk+Ru$fDFm~_}O3E;SN(g5ePNS&pg3YiwhbT{@<6#B4n%@C?teMU${!uSNBq)lg$Y?`#JMW+lS6*duO>l ztLV47uMm^HP5!VS2etYq6Q%in!MQMc7H5ec-<#yh#WZr#FdW?WWR6~j<@1lc79Q8n zPZc46>2aKsJNp7tZ=&zXY~Nh8Gva@!+ZWAsk^F&X)A4A^Zi=4mSYA+LGV@q@`_U>Z z*2+hQ;YCz(OJa(LF@yK+7+=QN7;XQmk{!Tr#kYytGs#kB#=EMRPiop9b45; z$CGgMO7fgetvpB5-&4nU{&_#F91dEvYVj5~s|tVNbyC(|vFV8(sRWS@-Qs`k{w@~L zl*mZOBXjU^)1hQl_^YP>Ld9>WNw(8hdUGs?*w4o66YDD_$lD6hwF{Y!)e|{fhlN&xMnFiM!8n;H{SLqy8$P_>n8=M zrJK4lwJ%ijJa*hWiV(NWIO+>Dbpss`?e2HiDjuuaci`p}3T+Y|582_iQ*5dUjNnZ9_o$$WpEF*In6EGrE6g0#BAU#}ma2 zGK|CrdtxI8KDrT&AF1p7B|>9P*6eiv$b^)KI;1Z;xsf@AWJh-=O2j zN!Cvdp{C#7Z*k8Y=erl?{;f_0_RaW$W_0@W5RA}WK%=Ml0LMLvIorPjD_mP09){Zz z_SYmx8as3Mt8T~GFF}7{m9iUUQbbwnjH=#`wPI*0Z~8snet1pI>XYN9w@prU_rC9PQlKEZsh8GPg( zbrHMW`ErX@3i6@+v)mr5DIhRq!k%p3ch+vgMA*6Zh|G>TY8cGD&i;;ULXphpqjy6s z`Rm`JXdR>&#bA^I7X0Dw{+t~Jtyi8r{R0s_J1T(yM+Z%{8arNI;bm~!ZVo<~EfSY} zgHE55n=+AVZ|;BlbASyp zxy)%(jLl~Uj@=f8oP!ox`Hd#i&Tn5zj0LY9^b!zVYm1=M@Pk` zPu|Xk>XjxG<|__fHkTD4aTMKeFO8(#97<9%m4CP8P&O<}~Y%_x1lXrh}pH zUdp)1)=c7P95YnvY05%fIY_yZwP5ZhL2)Auk3bkp2u3vEjAB?_{;=v)kz4>~aiKAATVd zCW}i}>EnM`g6=@19YZFQGXiel+VF%2q20L+FY%5@ABii%a*KVUf}Xj{we83^EptKM zcT`~D?!&*jm=wF?!!v)+t%lE&p0}*Jy|~o!RdM%A>biyUwq*`w$^O`Z>27MEK$ zNwF8U1Y=`$v&+Ns0gH>L0NksBY#WdDinf3A6rIdN1TY_O(=gmvegUEeuz1qP@BFj;=l#~FWxR-!FZOy#q9SoOZCoi+3K zo#tBo3XP@)8VZOqY?jz+ijvpV)JeKx{akDMV0qq0Es7qoJsyoRXb`D|zW!SXnq_y1 zH)aQ))KPG~;B~r00aUhdgNpDI&%uA(YR3ztQR~vz8>)#RfRUgLP-@?a; zJh=rVf+0-QnP-m!Hr~9oK_B`Zzq|ZkV1T39LOR}D2zwqGn{{LiQfx}FPj?dpb~N7h ztSg%f){V?5u&y}9l{~$@8zSwMNlHd)xc-pw^el9XM2_Djn| zBP5{_rf_JKpU}1Rw{gv&c zIQ<~pOcm)DsjO%=!`XE+;mcldmy9u@{RkH!nlr%)a@oSqnQ-YCiIf)xH-nqzh6CYf zrBbny8qb*Lu|?J`Q{x}^BH+8$L#Ke!wTbZMRNr9fAB)X>{@S{m>p8#St|fk(heIf! zVI-3tfdQ{GC+}WpP#J$8rzcnYN4U5CteC(bNI>7KR5uJ`0NJW8!r;cVj*!U*a9%dB zF_cGSlf<1eYX$vcqQbwS-TX*8e7Z8YTn#Ln`)Xu51|I4@~T2dD3LqW3_ zB;3gKL!LPbF1O$}xASq;FO@Mp z-{>_zB3MnZ`}%)3*KJ1=Xc`X^AP}?lLinrWL@g;)Sh9g_|JLXAhlW92xam)I<=RT; z1_QPBFzIK<##%xxxI0NS?Pu9RfudE^>Yzf}Wpi@2$qnIX`#SD-NS>BI!!#dt6KJpD zrrBI&N^ByZnMhvN?E_lDTfNP%0H#-cJ?G}s#y|e_=D2_5Znpfm{`wx%?y$7clzoGb zl0OW?;4GRyH4ZaoKXxz)r37dR0O543uOB|RGGYQ&QjU2R-XPp9XdfhC`=R9S4faK% z5nqe%Y^h9CTI+A^@t9RS4SsT-&;;xyK}RF4Uo9?{Dk;97w73OH3tOfbAacfZR6i+Q zB26-{WF{Xm{cg!Hz-GHk@GJ?MNH5%v;I)mYvY@;hD@cch5SgvgyhyDi6LG*-sWVcI zX$ucXIb&?a%_c{8DPCZxN_oA)6vqNac@^mcI=g>!{nKaXPbS$Y$)B<}_Rz_8`Fs{q z6_n2oC-sMQM?GBgM z`leG17d{~|kY1jN=0ai9N1qWzg}<^JQph#6W(Sk-_#N=lJ1^3WX9s;>6qNKJ^PjOQ zCKB0FZ4XQinleqHlJr@g^L>{!8eSOkU0{EGC8QA!e6Utf9*6Lcx^u2R)HDt~#O~6B zvm3_8Ftwpx#wI!(>_JAvnT%wwmMYN$d3q_vn3N7|+SGI1k&fA_K7XB+Z~@?BQ*+Az z^AUVE#_c*{tNV^_oo>k3Wkc=GV_Khxy{Hp#|4CZ2U@LITaovnN@F6~(NK8xZsXc$R z26s7q8NOnYFIyKmgZmn>UK)GSjywevRBiX$EZ zIIX{BeRnf9aP~mf3mTVr%`%c+;N;QHzL`D~%SCvSa*gEVLDZbT)w?t~#i8#_+4IR0g{g1cqAC3KCdz;HaYoTw z4nIWmLt)l@Z*Tfx88Tnd!&k2b?Uq?Qhbk04CwR#HkYi2a4!1^X{08?op^vae^N!g| zg)KnvhGDHTi5=S^Gvr|_l`A^Y51|@FJTAGXe2CuTIy)xS8!gimHKV0r6)Ay&L3(Zm z!OE%CW5|YsGYC&eX1CylvtWP!2CT?*wqdMv&OFJF43QT}f_I$)tWTyutHt9Wp5w<( z8ck0)Y3})OaS!IIp$n?$6tCPuwzM_e8h5%07!>CaJTHi@59Qg=lX;HPYPD&GGHi(} z9ha6I!Y6`esy{c#Odq)lQNjth@Hc z>N@Bv=YDH=5TN8)=wRnB=zo z02xwRo%0CAJ#LRJ&>Ivj~?9MSVeLUnV!>#x06nfq1bTLk+919$52M zd1zdWmh62pjL`go&&p)iqw6!p$*Da%lKd+NN9_|YKF^aiJv*9C978b5HQ%dDL*uH) zkB1)q_)^!7>2KFbN<06f7Mp*2!kSep_TtpcMb8wISZaUnHYtB=`TQ<}AYW(Ln&H>? zoiEg(L`ipAc)Pz$ch~T*9AuI>o#Ayma}Q0mI|58fjmNmz@o|@;ZsXb{7J{vAV$7%& z%RRalZ`cmL(dX{3}Lh7z#MVhVR#g`c4Bqq!4Ww?d*cE z84bsc+@%}mN^OeAHqhZp6mA=!gg}W>S7+1n40AAlv@ktsbVNeP;Z}Fd&Ly$yPRpv_WjwKNnAP2fcv7+WJMFUrI6yr&Rnpmo|<-x6j z<~|fZVY?pd$+luD8llI!RN!yk-OXzqubCGkTU#-%hYv-v(#;QrRDDk-AZUWQICC+#$ z1+71@F<*gQ9S9ixi2K~YYy?tY&3M!OO2ec?f``=OPx?8-9NOk(WL$FrcIO0p6L)z} z0+3#4;dpMb*mnjDexBs<7%~juvPH7WiDsFqX6lFg-Y7JyIwGiuR_!{jDN9l2(lW^p0Q;q18uu4&sS&it!*

        2|VT2m2zOtAjTexUXfNje)Q9%=8gEcEh`KRLNLkp)6Su_h!2nEIY)ICSQhm z1NI`OZEx~_bn>$a+{hR`YDjafy+*ga}WjLSgHa z>~^9!fC;4>c<8R0&#L30uEhVl@f%%c)xA3?13RnB8)z#o1;E9!Ic#V%HKOi~*0~_7 z{UJd7;*jk)U!m;5O#gFEaHacfc0po}Av7)nw3zHhJsJ4yLFXsDS z&$JdWBOT3>N6&w65q_)%I5=~+u2W_B76>6t_oVRi0!4O9dmSn}-6g88?l#~J_CDjF zM+NtA?zqa7HyQ;r?9P94n(bZrn@Btm_srY{y8!7e-hy9O0o#Kf@*uQeh(P5^}F{MLtV5lOc)VJ8WHY4v!a?Ii(b z5U{wJH`aj$6I*}8d;G%mr?dhY*Ae2ow=hnyCGmXvhMR(C@bh0W%(nI}*X}N)WpFR& z0ika+_N*>6Lm_{rql-)=R6W#_&*(>dbswoG9{wVq+aiz}-a@FCf{RBRESHU;_<7Se z8S37KnR{~SBmi6u4K@4xHItbQy=v#>XF~eW`C&Xlnr7~E5Bf>bnE)aZU@CWwb4R!F zIUm#Ll>i>R+|mV}i55N}P$^y>KJ36|Ajra1)Z&q-9ru4}w5!7RVSt=>?p|&9y&zmw zBkWhL8PnMB%QT|~;8$^tUbBI%s4fplBGJ=(rU5zHC-z9dNF6~aYk|MB( zc?(_%dh{{JY>5!#*T-Dmc1D@`$JgeM9X#tsW(?%-?XIPpSx2UqvEpJdL5sRbzp@$@ zG5aWQ#ms+H8!auy=@$(zETrGhQtc=*h#EnM_T}Y z0usu2)B5_f^zdJtS6~6>y*DAxuH^DqEV*7SXHS9(Ua`nJ?20l!!;$OZU>9ZmBZOKw z)eSy=rD{@?MsLuyx^ONSNM*FYE_mIt?6I8?o#lUW!}N1GWPO3wl!+hOsnIJbG!)ZD zv5hy%@j4rK>9B!k6r^J_(wCiZ2ZPngyfhIzLFUGdCn3!{S(Sdeb7LoG1!!cV;B za_WDJEu$QB-fhnAuI0kJDGsV=uBJ~NR+}*fVX0E$Zm$^;FG_>!ibp-HD;FZ>9%cG6 z0ZAc`xr*N61J}%Ut*=9x9KN)s;AC>3S_`v5+6W!(Q7TgpGfk+(V_Js}Lf<%k*l6d= z0mL%QKA(;M^MFju#?Zai>s5q>RzjN681H{Gal7=4zl(jJH2uN{ck$E3Ma+rel_>0s z-jXqiX*~;03jd+@xcxOw)IFFV@ch@i(|2&wYJ9;-JgKJuJ6vLbxOz0$yFZ#{wa2FB z&)>awquPnXHlFP!;so;by4~o|z;@TMH0HANZd}Btmg}yEWPn*qP3L9N{cAkJ$)2wm|lJ zmW@SioZpLjM{-4aF-g?i#4H@z2#d;#O#SZ3>$i6(S4-xI*LxNtnkzMtO1EI`soVyytnYN-!4N#=}p(&us8f2k_xuX#l5>_hbV2cuh)aU z7L?lk`b1XhWVd6av3vW?m)VO^g39=MOw9o7Ozm5LOzZR!Pm)-!v%jOAu-*f&V2e*Y z3Abivs#0Vo=p_=ra2*VLsY-u=_-tbkQ;Z)I_}2vHsA;C_GklPYMfz>sIZ~cy%(D4( zP_yfD+q3GNRm7o5_=VgoF%~NT;_ejxmd&-Z^`U2z(=c*((fAn0YO1yvN_6?0op$5c zt(7x5-Hq8Na(OxW@<3kc3vo=~xf_SiOcN{^h2^I!a-Lj7LG8zL$OQsI6{l-tT^M(Ow5RI0&n8HQO#P8%qRbu&PA=eppvvfY9-pld2Lu1?bLU z<`E(dO@gj%PY=}LlYbsqJm2!Vat(pv2NBQSqbJ~k5b)|TV{iLx6#TfwS((C0#%E}x%eS7BVBzDsTlsp_Ovh3f!cK%l>% z&&vc_|NPg z@&uw<%>sPS7b);$cWIE#_gD%+e8#7M{IDoReg@+wobPZQ8exC0M?4MchBmD>vo3vd z@{E>_5j*I*otW2mCfh(H+8RL=aht(>Dy_XMH-dAE^3leB?ObX%tKN=hf6Kg*@ zvZkBmAE&75CFpM9K5(JeKRQFPmvoZHkBm(~Z+CE0=k5VmsCvm$v18%FkGkEuh_(0$ zl1PTQM71OM*j`Y3eS?vRqCVVl>V>XoJ$b+DAN|}3onl0P6*PUleSoa@xfmXWC60Xs zWf>`kIbp9kIC3Bj z>CHrpT3lYDwAdc54vBzLQ4`5FH`(IqaD~r+ zEcYwm3tPB<&lW3TX);m?4j~SPHAFrP1rRs;@yyBy2-Se>?t7xyY67#nVobC{^33uFQk^G7HM=h6 zbBCYm_x%4njX!|_j=_2Ncva*?&MO5I#oZsw{2 zPqOJ>@46#ZObua>>FpO}lb9eWCjg!FWBGH9xqKqT?(Ect4Afs)$`RKBOAS{`8r z;qVon2cFvy zSA2;oNXnz@^1?Ft;*TjcZQ>c8LKA!eA(Rhz?EkItbpYwt5XMl_b(6RD%9h1eom9LQ zqqe}*7Dt>oqw*)D<^#0`k)#yA^9iw~`1?iCsThlG@{0Lz)0(%=napCB8ZHXi`bYtP zJA^^+AYV@F1mqq%R=oU$h_tBsU4SG^y$Bn1mOx8zA@;u49m_{j1vA)XZ!DM6LgNJu zGOB6IZNHI8b>KuH>lZKdJF@aqa~R*+ia{pUy#j0-OzyrhpRBS)4=}oL)paCnna_DC zUC9*;uv`LbrNZz662$s&n}U{?SL>vIFJankN1`sR2>1%3fYjW@DvDzTkW(R@t;XRO z_L103QUNC3)IElbX`(S>(wSI2XZFln+4!(tMXTlqW|)YO3i2sntZ;#*{NQmOU%Sm) z(FcCHuwF(Vi3yP}j`+RI+1dI6lKSU3Hs&by53m!hvZ=*Eht<>s;QE*!=>JwleG zsYzM-a(s;9wFR%wdNVdhuT`reYSI=aMvnUGUwPlS?| z;o1d!SHgd`)1uDvF`|iNGKp-3%onM*&ue%RZsRolVNmb;Z1@Ga&AIXfqcKQefyL-n zXRb9pt7gA&OGIrY!nnfqvpL6%&e?)s{ub-)4V$-oInnYRBgq$=mIXL?(VNP64I#P9 zhHvt98#Lv^JBtBw2ix|4C_jn`Uug|nywK*75XlP8%Xjt@dfT8>-7%yXdr%FbW0HG| zSrwBo@G!b7j;-L#d?}a}=XI`1SKj=El*dxk4&FyiM|(UoE|;$6+z!4+Pr&=QkSodU zy?xy|C_+kb^@dRgu3h6Goq7an!<6rCPYweU@0@{veo9W z9bn79aK6E5?1l`8FY##*`qMNJ$p7fdhf@IVLGTdkQ$XwBNb8QJvRWErE`qC>it6=$ zHTXDYl1`kO&ILXXiS*kaZp!6H8G9SO+6=hG2{VVGrV5IhqwO4g z$7D7{TKa!s+f!|G01f#BT!fy#(MiUqKodnb2CLfMe*Y@&0^Hq!bt5Q>9)LjJ*Y*?F z#`D5W-#%-vRY8U#+mjq)F@eFIojFoG@3mp%%=Z&n2WEPI>=JuUGvfO!j0i`@M*7UB zM39RBfH6wthlzOF`8Zw!5=4pnAwK{uD|QkOU&H3Hf8Yx*StzBp*MZh?Pqp&b6rufOWy!L<8YAq zQ8<{h@Bvv@dHS;QSoFtuN-K+)v~e(xTI$ ztC@G6x*L1W%ZGut`{YK0ak{DU3G@kty`X``uDd`n<`>p?uKQ}fL?+qWLH)ZND_nq% z&cBv_&1o)fn^iU3np8mEFw2cI?(6x1tA9NvVeRpo5~R4*+c@lwOnEKH*F{zO;?@sp2Sf7mLJl--XpJ{=p^RVC&NQ9^@X~tLs!%q_ z+t~;E?$JchZdZShE;KuvKhRhqo!b*1BiQ(VJ743;gDvpHK2o6Ki3X0BRhBfk7*27m ze59shCN4JS#wJ%q;u$?=_!+@>2mM+GyRXa>^d5b69PvS&DxT&=P`=XG5~G(>x z{zF}fP@_0Re3;fEOy-cVFay9lU`wqRx3-3_a3Q{9D#i)%Q(O<5{K!W!mitEQ`4=MJgUoZlRUOyodf&ej z@#f=}R(J~C!LESwMavSJX+e;SrSJrTN8sNo*r`#AX;Yt}h;6gLhb-9d(zY{n{6PGT z9S70q#uZk0xYpuZ=ROy|_g2IL?fT^t#AxHes*rtJ<&733R5;d*513r_*x4 zhNgf}_g6>FYmpX@T^6rzS;(13en`;-WYR2ju?qGAJIi)EhKpzD!q3rbjBIIwnn zp+Ma9X$9}%+kxnr>$QA*@NS%}?d`UT6st^Q+_t_ows}g$acofkAvt0~dkkEEJHYlj z@=V=xmTGWP5J_mE6(Ca%BkZ05qJ9H$GXtRg znyUc+FkeyI%DLNm4(J0KeDLiSt#I`nc{=J6U!;atDxt$=US68`z)5u1*^0R(2 zzh1f|+VW-Y5p?})xarr0G|aP9U0&Knd!_&w4AcXff0iB?n~MS<`#BLK^v~lAE^G>K z>FP>sXX198PXQQRxiG#WErr%a-;StAvHfZR$lY1U9|69vef2sy^Z-; z7Y9^H|1n=+t(%0ZRplXO~7<8O(bE4<(J2{7l2=0QEvvoDa*sn$ng$B385 zq$%njg{5bTcm~nc<5=E6_(4dzj=4n5PPncy3s3L*(I#}4lcesR|f7-n#%XnP3Z_TQtyibaG%J=^KuEXU0 zt+hG$crI1zlW5oKqxZG~u-Sv4f-^;@Z~hlhO9KQ7000080FIb!PgF6hC(j}P08S(T z03iSX0BvPtX<>7bsuq7WE^2URopyIPn{E4lM9iuZt7=8W-Z7*07F&#(wPMepMX6nz zB!U{XXUrmsR*TXGt)i%^s@WPHDAj7!SD*KJ-tX`D9`Et~@%tS2ao^Xuuk*al>%Okj z`O_7^MZHL0F95*ENDM#=_+OlU1TgDHc=$&FC;*@{+W3sMLK%PT6CNI-A}t*hCgtWC z?2eZ52o98vbPJJ|m6DMLsA@!pxOw=a!y)cyZ{Hv_=$HGCpb%eAHK?6}sf=le4%)}p zFdBnKMVncBMEiRnJfRxu5YN+v+*CcG!*ieO1Qro zRO^oba>djFq7#3NK|>UzXV>`|1Il~++vRDml& z{s#0c8phL0#Y$KI?^tJ)8uag^u3x_{bzM#>7~?H1i$Ea$_<+MD&om^%qJqNRA|->u z1pe`$iw^U^_=bf01_wd@&~EO*5#ef3=szh0hM1cE+wp&YtX5#4^gr5R;Z|s`|E?Wo z9TkF>wnB#mM_@eAXX*m~PpJQH`bY6>HY(;A-?K$=3(yVrhzLXng&XOrLC+*op1z(c zy7Kx;TCzIY`nqyTdWy2L%DTETdT@litTJ2&u7gne$H#xNRaSt@>nUjI$SLdS%gX90 zYRhTsYw3T=%gM;;=_@G8BmS{93JME%3-Un!W9$3Bw%Y&IRz(Mcb_);2SO*6O{L=vz zKEdI^VLrhj5FL~vM8wWF$TRqQnCPG7`Fo~ljPEtHr#>b)5b{@jReb+Ld>I)zeSH}P zZ5=&1`fM`N|EF30VV!m0pW(k-|BU$e z=0OLY?HJ72);RqPVEijxfak#37Nj_R14sr?0{`IbO-V&bNl8ToqND^-QB(Z^H7zyG z8K`M#>FDX{>1Y}L0^=Vr{TmdNAP_Y*H3Kaz1DKJ45zP9B$;$kfjQL+5CT6Dpg3|#2 zGcAAM4d4wW1v3E1OhL&^aXJi00#N)5|NesjDJcNdG@$>(Jxk+E0%8JCoXs9cMM?Fy zn1Y!f2$0pXbOVP{Cg3We@ZGyCgHtQoR(tM=m@4K!I+TEarT#B3%=~|}LxBn4-MhG{ zN~ref0)XKxB#@bs8K40;5OPIsHmsfk_WOTTdt>W=aIdcCM|3J6>UI$O-$zTvYUg>E zwH4Gj1Kvz+52}6f6{{UrA2YQl53;cDU9?<7{;D5yN~6N1FU=9(pC^~rbVS)t^c~jM z_3(OAna)O#*gLqhs^(}5`WySp6r^Ho%&yZ*J3PpmB4p2+xU5*)M%E&(LrZV9N@RbV z#bDKj#gK(s_ujCQ;*A5wan)^`qzu zYC-koG(k{ilM_cj%ET<}_XC?je!o3JtvFygaXFW-pQRg1_6LPvTErU+?hI0by` zyfomiUPSt}HFwqf{RL%w#j?oc$xg1byl{^;0<>|}Ce&i5&bZH_CO_Xs^;5VkIcw+6Nq=Nb+biXY%cK_bIMGy9)Fo;`c(Vprw0Qv96Ssm1K+Q&Hj4zm7L|i zY>ntJ1JP$Imh=q>H1buVg&d$l5--j#O&%V#WPN{#ibRG1#ifc*B5ksDH{|bU|H=$D z_ZT)we~ZguakzIO-OQ>Tb+mtQTg<979rxmxR5;Xv6M$-2dImP^x>y$WQQLADFKs#a zoz%iv(jlyFvs1_!S>6@#xsw=T*2hmQkn~v31PaR))0N8A*M0Af=fZ=JW8<(P&F8;f z*&y=el@{g4s8VgFr}i@8K=;AT#DfvnG3|Z&te|d`Z3g)BzG=Rp_Emq@#}!_nG;OLp zt>XN`Zr)``%Buy_oEgZk0Tq=D;~W+Y9Ryfc{>VN7=@o zG{!#KQLvAabiz&2GN^TRZJR$T)_5jk7*(a$98^lvI$mpny1TX?JO|ne25~n~!7~l2 zX71k^<%`Noq$zfBV%UR-J%@A=FE zRA+DE)DOc-IG0$56VdFjyHrw@^LHA%w;GOM+#pjZx1iGntIr}jObwN^_tJ@1FEl*2 zFv&+H|9mMe=8nM=yJ|LxOLW%FAB}NuUQNtZL!Zt)jWm?q4EcY}mTJ=7eiYkm=d{M^ zdd#wzF6#E4x5(y!G93hQ7nr@_ct`k$r#4x5t7^7P;={!o9i4qY@5~WFN9GVS?){~s zCWb^I@+LVF9b_*j|sYV z^Hx)cb-hf5{^pxCrxdw|wy|lL~9b`D7FK~dGp)9N$5tRIG z4he|s2rT=iCe47YTuQWdn1@0j%jHO$vG)gsqFfzdW|n_izovua4-lT`DWiTfpUiqq z%HXsvg4MQz!J;CQ@3aB~4fq5K=L8l(FzpKO&?|QzfyV7sox}hlE}gfnT?9m@pHH{U zd2(Lou1PJVjhBF%Hx^1SM4yUHVE--^s+OUE_20irkCl_*Y%tOvIEh|1z z;AK7NGRJ?2;xDQvW*x*?5@z-xy;fqcQ(4{v>w6`OgR^59-V1)R=Eqs;Sd5_xdj;LX zTf$Oq`2j0AdFf4Aqf6_w*5ew`{r2p8S>@sS&$ufGw+~^0GW(Yv1f`S2CV(g$o-fqh zJf#uO!`YlF)m;C{elA)c!z{hrV-o$ciMcc%S;R^1@17@}9eWMhY*~2mHvW`gkEkpx_*N%a(y<(XrrVV?+hR z{kyC2=jyE&x*iTWzjwNI3iuEW^YL`r@4Je!-gJp(Sp*AnW4dSe^g|R7h7?0$wVyJg zmh|hqc&`e&hVPg~h6paw8d?;K3wqn}*8hK?UJ4X-jR8p8Hc# z%1}T=v0>qUG6%Vso6o?;x(7}!Z3Zi%rbhJS;%=oHL3oZzvI$z{QZbFAhSt9MLgjzm zgBPQMaf0`zmfEA47kem}Evo$vue31|CVRCnay-qa525J+?&a^&q=-K5>6qnvzNyp> zhlIWur7U-PDdET^wFmj?)_Px!gPLX?PJh)xC-Mg>qXQ+&J3YRC`H-m4P7`u2-iY7G z94XaVaU&5n5)cr!(M}`*jx?sWq*{MZ0kwVl5+ zy+Xu4caHe3TW`RPw3n4NflRw@+zv>2aR=2I%%C=DtCeojyV-S3Ktnu4&~mV_ z!mnn-D_6nlT;}( zJ26l0G8k^Ay8ZaO30W9Cbu;xTvS?lo$Ecm~@KJPeTG4Y(=e)KSiQ#`5S4%om1>5?3 zA0(1BJ~`#?b5sPesF+z)jHj$F+T@4^!tAnDk8Cq88FQZaz?RtdiBSLP`ZJT~+M#cC zpcdCz2!l3#_UXtFzc{?c&J8Z#>8$GGhiTpr6PsV3<~m!;gVaXs2EHmqH#hGfZfOHw zzk5=nfhF%?M`zyWl}mrTM=&*TGtoG+Z5ONZuAc%rWt6TVE004zLxGoGy+auQ%p+#- z{q(-Y4;};I+CXtE^=~%IR_kvCeX$BCX)$LylZ*K7?=7=RO?R}tv@D!11f>MuBpJ@K z$ROb0jegNS%G*?idOea&kv0L+was-&B?!)t`SCJ-2=TVLc`OHP#;AqGSV`7n00dv>4p17I!dakHUDFBMrKNJ`pBaJVF0+Z3O zH3s%&3s3ah!jRVzrdy8cGfu1=DwYsSrAy zh#b>YMmXZ;^1s19i&Cku&6iGE@vN>mK%7-t{KasI7;CDLaqno69-hYlwUHx<%A=+` zT)U+;zbO1aOgHYwP(nXXF{n7Sf}Ka_)7gMa`Se1XxQeH(wmAixX1Z8~*@;^XVnXiQ zrPzudYEpj-dJ_#b=TzRReR$}UQ7g3qA;;u=^Xo&)%2Q>oND-RNv7J6mnLlhY3-9v` zV2&GpPR?Fm*R^U`SZZEzc&rW)H*_O6;Xh-jD7oq!L=$^h6zuwtj@Qbs3>+^T6tN2a>S+686={-Qm0t*HeLdS7G6g_Tfk z^a?Lsw}`KB_!(@iASbH9!A^XEFGpN`ytZQ7b)-Sy1ZJEc`a-gQtfs#Y5~u>5%h2$< z?P-kfrJl%$_071y&na*thvK)-SU)eChMRx-Trj=wry-vxk=^@K_G^QL$9rP6-^c&8u1bkh*7fuH#JzWFcY4lC=zbI}#ybuEy@J;bZ%&K2*+-U{fx z+{+G~<)U(M2-^%|b3NL&GjGRaRM3h0(Uvufd{jNJoo+h2jmhk^lv(BI-FaW#hpf-4 zp%#r4hITR54~s<8HRFet;}oL%SVU;|z0jAP!Ly^?v#0{JUWcCxXQUI)U^Rnb!{nmye+77XL7lQ2rPLm?B zMqT5|O=dO3RFW*>3tv2CQHYH|}d#QOvc~le9=v4Bl zmU!3e@;)XoAkL4meN63XSpLpSKP4I+QG?XGu!eeJ4ta0iHb{SrptpPkfAU;CF}cx-i6QlV;RhJPe`bq3D?G~{BtQHx0=3H_v+EXqToD@ z#S@o{0I>K+eA4vAIdb7Pvq6mVB>RCxn3k?Z2)EykRjB&AC<}k^&)LtVERc)NW0^`0 zB(3#qR>#W6sB^kA{o{a=e)e-7FrAio!yWq#Oi>}^0yLbV&E%)mTGq42;947IzM(Pz zCjuLWzK6F+41M;(e_F+pjR|IYqssNWH(x_(ue>(wyL!XcJEqhOCHjn&B2gSG zPqcrDIJ@(MDq(-6m%@@COTlB_NpEQnKf|kf(UQ%@g2%SwE&7;Jry82ttln$MS<%kS z&k=V3qcGH4iJZoki;;9pmA8K-Jwll$Wl=6-4NKS&$E=#gPtAYSw)J!Kx;(-suUpLx zUY=`Ta3VxL%s&sP1keVUBW*r( z1kMa^qkEN38DLAuY0K2hLrmcTj9bIzSGxfq+f$p0IKfLq1w={o~wslAO zJ#Xnvo&v^}Y!|&~Wpb#p%bLfYhZbpT0aA2hrf#zOd?!0!sf&+7#Ym)vR4(f`-5^nh zK8bPqxH5G}#8iV;wQ2V{^6#&98mFh@$)c2tf$xi7HkER0cn-x1UOr#e&Qkbv+NOWG z2e|C`MgQ0X!38XEii&8oMY^nGdUelhy+irnYf_%3v4x>(A)1U?wo8P;2Z`%FnyDTs ztd6^Clp6kocJQ_@V!0}hX{)wz%aTz0EZ)UdFb}E9CMUHCJ#!C{#bQTLW6Ht zP3)kYZKyKG9leHkPjtz(S$Q>K3?J3vyWZu%>FFZxJNkvnkEdz={9LtT-}Mww*(ai& z@6X$<`*e{q&Q;>jxak!}YX^dUMu_H3|TXOm_hr(bL38-wzHOoah4vJ*0hc6tSal6*Uy=qmcHs3u2U?bn!(AqgnZ#>9b zprFb)Wc6y@NuF9{YKkd$=yJI;1|vMw=aP2lzvEXW;6uUZH@5dA6ik0HfJSzvjQ4iw za^766O{~%l1@RbaE|L5e-IKrx6tBMQm^KCVjBA%~SXVSZ7QD{S#44G?pMrv(yo6TP34S)1>_TmygRAjX>swvQ9Ir$(R4>qC`dPV#`bGxL( zUar>Pec|BwaBUKml0nT5lAHi(jA@Xz=cp4+2g~-yi|;smNy&d+XSNi;#)axj1|W$L z+N^@{g|=~LhAbQN9)UYy8TF5)ES6IQKJ{CBq=WVlzh7DV&&)pPg9$_5t=A_y}eE%Qr4{1ETbg_$q5%a`ME?McF2OT98$?kW>R6k&j<~rS?IRwN<|a^0q~J!s>)` zh&7PKehAEyLlCgk#t0fK4EOXpA?}*d6k>J`4_6$>p<90*kFm@{(mI92BFv=<{^TI} z>h@I`s*lDEY{<|jR?MJZDK91a5!FvA!PDvD+3@43Tfd#jxw-MMAdy4=-W%Waz=-;x z5sQZStXBD|xj0D|k!Cu#xw2P4r(H~|{ZK?xtGnAMEj{z}wvW6u#qh|TqWLP9)-?xm z!DZ$yiwq0rI;FxT9JH?#sw-Qk&vBJn`GB13oba`LS zl7roI_qmLP#aHp+MTd;boY45u%D$=91OXYQ{zT#2g*FG1#w()~<8NBF33L`zC$AZ8 zq{hvNa2Q5>CLyeU^Fiy7FW9;zopV;KSb6gO6~ljnO_wa7CsPN%{#DuL-{OwNNmR*zLDx|2Qi1VfDs|+>7;ZZ;=DSX* z52AlfxW8=JvG&sP2iED)XDkv<0p!68etJKs1R2)*oum#8mpV``cB{;Dr56WKYYDCf zNKiQhNj1pu^c(S8#lE%?g}$A-0?ZOVx3-hiqv| zu==j+LijHHhQpOua6q~gx<#2IYdSaFWP5yZPB?eCNx27z*J}X7b&bYhfOFPFe>ZzfbFV0%n*jpo-=Zo47OqV$A?&;@smhW_yHQiHLs) zT+>!xnBv%2Ors{B!#=9dKPQj|p^5_SeXaDTqfM?GEFL$Lq^;0q8=^)X)otCgckci? z)cz8O&J6cgh#WaZzxBmMZxtH0vV!~`iQ{;N>86;o<@bwJ`^N)ZnN4{TaBE)xqAvlBo_sb!HgFF*l)G$F;4G2w@;kD}T1ytY z9-%{=jmjLvL6O@nGlAwF?XU_!D%#UoWPPu(dG1rhTj@XtQf6vB9&a6L%zDk*xnavA z?OT;p4bSsDq~6M1S&2R{GNO*ORinu)!A9BYueiy2ZeNg0N0bs%#nEbVZ2o^H`Ei0h zdpMoLZ0jjT(kUdOb60EMXvyY^iqLMxA5VEx_6=$Br7crV;mZwQh*dl?5UXnxYqnh< z-X3WEqA$KgN1z4jB{@!%T7{@4ajNvPUGpA?8L;&#rTKvpLFpaTbZe%z$yp|->%tS& zB4ADG57K7vp;A1IiECg}rTBk^!AF=$8U(-7>!#o<}7uEXjmC05(8Pp2*Bkz>`g`tN9&lBK?fKPTFkcKn)yszvZ(9H|1_96nryr zAmM^f`VC$2Zh1QvADk{gO-b_(Cw?zKFs{Tj^fWD*&h_GXC`$wnt08|rxQ$Vsn>uc` zQrzbna~^1mY}txDk)>zhczf7HnDp?voVrW0_qeL*x#PVTvOTkNnY&i`d*1XZz)#k8 zLYx2W_=+ZhU7qDpqd-5AC5e2|+1?Oqo|BPZ)2;a@`g+zE41S`Xacz$28m-ztyL%uq z3?K-csE8vLExZzIpWlBLFP=@zmEI4jd7mU>oWh^ZyRQGF>*FQ`$a%^L9AT%_lt4Dq zRS{B+W@~O{Ap;A$kWn;s`_~ertoOn#Qoq=i-9pC_gO(ruAew1obd6-t6jn9VdRO9p z&`O7y$%}M5m zZ0YaE22^R$kb|wO8#eQ?w1%^}MZ{;Co^g!;tPxG%=2lAx9PHo!hU2*tV^yeF4I5Vg zty^@Y(pF81?FD~-w&`1*%Ls~)M;929>9?fJ z33iVXTYZrt|C<_9q`AW;eS^drR?YuJc!6oD?DdNubSi)GNudefNNf)i9z6>xY+il6 ze~9l2*ScY6{6?eAo#pm#I|Y~Gi%X)9OkVpN%zEr{JiSUUuEAJHzRK}1@Yq(vCExpa zC-;(f>M5Yk$Vx+8q2Ko;R<8cKMoa6>t1ZmsvlB_DfII9neCD#F7&Ejqs`>z+d5|SjQ@__)ixc$mHUzp3v%ZthQ9~5 zN}CU*9Zh`-B}Sq?@@9Q0p%?z~I|j}-XXNSmP$4qZ=1PTBE00;n%m~2m0liZ81BLDy{C6S&Ye>N^^aA%!&c{r49|M%GUFpV^p znz7u**oQDk_BGouV@vLsA;d7oTDC0N(%31=KFk?}Wh+CQZiK|E`+e@` zd5_=mJDxw@&v6~sb)Db+JkRgSZJoTM1H6$~sdM@ey-1zNz~Dd}@e(95 z@JdjqPUKmszm4l0{r@JbNJ0JL9cr|AN$!Hv-m22W4XRFJDKkvr_-+R76CCa)i1v zp5UvZhD0KN+dv?cjwF;qqk@Q+B9($drT?*Df(!K~_yrUF@IjE@?Mq(xFydJ$seif< ze;90I^KZld>u3cAs{A7zN<`s&{=0OjQ&ccc1%(U6hY`GSN8-}|kE{Q#`djcQ8XY@= z-_fL8x?+O&4hzHu5iL#5N*!^Ov3^(`6Ad#hLp5U~GZS?!Q%yBBZ4(n!Qv^~&O&ej1 zFh*+qW8;6*)jp$PXl7)HRM$2(Q&Th5e>74zGBY&MP*+tqH9MoJf&53;GANXIDaaf5 zkFMW;bhZDhu8uJQcZrB6IN|YE{>cFQ%XlI_^fEpeV(h31fjRpHVet{6^1r9&Uyu(&r**MtP*f==Y+1S`QI5~cUlbe(42%Oy9JiNTTJly<$-U$AF;UM3C^`JmLTQ5fT>qe=j(E3J~T7%mL=uScCzr!YpjUEQdXS1OUt5_|FQ$ z%EkiV;$-=sWEKD`I~#`(faNH9R(1|{7LLEUEW%J$fEt^j1Mt%Ekc4chZ{q1htfu#lfq`ZKR3o*rYD+jEHl(lZychq8g}VXu@fu%@6a04+4fl;$OwG>nmu zC?#B_ieUS`EU3L&kH6QFUf5cMvt;OoMfa~ws>L#X}N1!|Jmg;dJDc*~c-?Jyqi;Q_rp6e@rX%4Q0t;vZyMx;_wgNIEF+54MfGizRy?ij%wU?YGRAc>x-IV-+4M{e|^)7!hZ-Tm{!!+ zs0q+|2tJ)^lk2Z~e~-x8ljQSI$*%;1bg6ro=UG-MGM;7m7R?gA>sFdBG%TJQ%o|Yg z+3ln2ls8GdZ_jg~wyc~4&#~>&qzb2H83+p5cF0muxyQ4c{(9qAM=c-ZuM;mF_%=^h zIMX!bm8~?swz*TEo@SuU&5Qh1`zdgq8=F3~pE4UgHE_@Tf2|AY0xc25W-?D#R-Bz* zSiW%}=P6d@GvZjB*_!>HNVnf{C}NQsvTvjLDsJ3NaTxkwHsCTf{%|?P{_Jzq9Nu(3 zQMXOlZ7^=0-W_$tN80On1W$EH^qwU3txFwa_`b(lo>pr@IxuZ`!r$5VZH}UYCAtOG zyg|OHJde5K3pM`HbrvAiX^qCVtx~ou6W*E}o=+4j$(a=X4wp z&%@CTJ7=YwaZP&#cD~uVz|n0!_+l24s3fvosT~Mko*zY$$^%aNojUnqkbBMgnp?fUfA$DRs?4vr z+peV`oK%H}9k6d?%G3&3V8~Fu%V(E3otcRcPqGoEDgF`~a?T7=6#ej_9$_AOZ}-|E zfF1ySfAxKI@oF(g;dX;$M5MRs((s0lOzn7e;6zpwfmObIiz?C$t}sA2Kk8M8eJJ;= zAC~9f@I+*;XDZ6AY~Vtf2iNsT2T`Rjcg?iSu$7RPPFcYccQeZ$uX{)p*kkALL^7%N z1w?oNIy?JoZRt_)Qr-qG_(u2%`iasN3oLpqe}SVYz&Sn(WtsI;7eju%qyJT?Z?&I1 zUObH44jJiUiijGxub6&K=nD>cG00JGp!2TU-%8u*1NTYM`<`|>a^2lY-TueQm~m(Q zycYOJ;x#kk+@`gBIV2diRt0f<`>Vs8FhoI`FV0>8qwZUS2oN540~Mc7ZCOrwDXOV+ ze;qXE@6>9nh#nRYL2GT2?{Eo#UCJFoWLwhlwhy~YKcF1ZVhwb!n_s{jr^a|m`U37L z=O2s4VvGanT{GnU`bPNzi~Pl&w|rOhs5!c+=S_uQ6rGi%EiV;6(`hew5MZ%JKn+kt z8fekwj;BzpIX~Hz&^{%Ie3S<(BcxQVf5hVWPKs@sTT(}TOpiygITN*?M*uo$w+B$B zD_W8(^V-;jB&1Z_U{83>Aqo#<@6k{x{fIj$0?cW;8(CtUBVuEHi>iln$R)WTL#7Xi zww#2CJkfKnp9yTz?2;*&?^5r-F4_@mcu1Bgw|95C?^fk$MyNG4;%M=7^LZGhfA1%P zeicUbs(!QNl^A!5em`W$3F;w@jXt+9n1Z0)2^&kt`fMdjl#z@E)N&*P!)NcUKF{p2 zVDDO{P9is&hKzH`rVuXoo!Wlu=l6?J%TN_Z1qCy{UxuCqD&G}Z^(^O83h&r&u)hHWI^BK@TahV?y}4bp`H&w6N3y#Qe{wbt97B!~#2fPu znjhYfcoQ>p167-@KgHpF2>4TQ@Fc0y^cQ8AdJOr6KT!p3^9%kWz4*n+HK)t2u}%kG zFJLRIhJnP5nvukvkP<9U=A*b;s!{3cF7v8WS9wG>Sp{^FUdQs|S^8TEKp?pk$k&~y zXzA7aOmTR{&Y+TXe>1Y>`lwBbs49Y2}KaxKuccB$Clhp01# zW)d<&1+}plaD8=(?{hdE*q?I?>il{-bJ0ZGW-#n8>iz?AeaG{E-EHQqey$jp4)M|tt1vYfP31j;IB znc1wG;=};qNf&>KcGsT_J_OunW6i+Q(6{Re;;dGD{(*ny3oLhxr$T^dmPItCi(Y82 za3mO9G-;TMe-7?*DP|9HTOV%-1;ensmMXQ;X#LF=lMVZIbINnDL7~uTLW42pdTDP? zVq77OEx^_r^2M6ZtpsiklSj@n*62~smB4&MBL+MEeoNip^D=ubQMFdy+A+_boxge3U&Yf2ugV=K$K#9x-(wB_F^mA7z$Z zH*Cp&WY;NcfivOF2opfBn5E@dN(!mu!<8heAk*tJE2cv)C=mlW;#?14Ewja%iUkC3 zxM;yFe!O9^@3~fUvT`lne}=Ni7&4IhnL(_0@CpZP+t{0K6lny3V=AzLYkK}s!$Xzu zg8WT3e~+z-66GB>?_c<8?fVNwWT5-d(s<+13M9j;%egU4udK{M?bS4V9GbKG>F@X3(M9+j1qdy%&{RiwftQKlUu0^%IM8w?5sRvQZRlnOtp zi_1Y89FtJxeJ5xu?*wksz8}68uJI>xY{Y^Ue-W^G;P(XEF)L>sRc(CHT7r=lF7p7` zcwzL*2<{KPq@v4Kxhr=3mR7)=-3=p6B?sxeE3wKd| zakM5^Gn_C4f`*HcDu)_}5erL0*3$B#le%a-j}v-zpSe7M4O7k?pDht5#&*%Kprn&L zf7z6-qqxslECU)VTr%cMTOVZ)3&n$41K(U;_x_16 z4mTOOmLGMtSD|_AY04S`5mZtYVX&h7$}H_%@3YLRH_Gps3{(3B{-;3W>PhB9R6pEY zPAKW^PugAX~e{WeW@jzY;V!4AQn9*F>?PLG$fh3T;l6?4GLQ?3xJv8QHsijzbtD3m{yfpWr;Py(;{ zm^9b#bwBdzOgMP(i}m^^N17I`I9kzSvVVHKj3TaJX1^oTmgfXG@(@sGMHK&fo^b_Q zU;u*AdOQxc&P#stSWT^!t~2YH&DFKXrb$%PC}z3VPKQ-$9X~*DTkdrFtML1%*#~LB z0{^1Y7b09)=q+wl?)6{UTkd#VJLjMB_)g~_<8y`B$F&ZG&?xuK!MV`}^PxnDntz__ zuXk?eD)$(<#wxvWp1gkKcj3|%0aNn1jC7tvAvP*Y+qqu0SX-oJh>t5%QfrTr4Z)%8Xm^Z6Lupo4yuMRA|Un`j-x2|~} zy5eWp2ZzbRw=mBs>EeEsV})+$p|a7DX-8++QsLX4D4`qg9g9X6GM{?_Uv84CgPMKP zT!p4(hwx!Xd&~KcdWV1$PHfLi zaR{h9?T+fxEAmz5(Se?Ze^{9Hg~)(iKKrg+uYH+>fI90~LD$HB<}f%`h)b}e5?y%= z354=eSR($Ses*b$a^T5rSktpPUWD*@gnViwB>bn?HdW-YJbwyXUV_w!L$A7&f=|p{2JgvJyZE;!p!Hq2$QAkcI7?43N7LxD6&0TdS0#1;a!wkX0PeNb<-#~ zW|ZAg_W>E3 z_rAvs4|qu{Scg+D*PT<3j`@Ot*LOOZxxH(p3qq0c^_79} zz9_ZZGVI|`k|oa!MvP?aczB{|22});95k9$(tp!9%PAono_`6P!cCm_u_GD>ac@~& z_09cyKIy^zRCq=8(J|8|UC_}klcLU*UQ1M@O=sDnvb+Zd3dMjo#wIoq5`-v)y0M32 z!726|avL}q4r@%yd!Yf7JfY{-w*=NIP++g8Pex$t7=>pM?YFq-()*9|e4Wz2vqb0F z(qBwa1v`7#zke^)ikNsqf&2BVwm)ix1{`mdy}1dbTSk-&C}w|d98G=6$b29?yH@iP zE#Esh5-X)cy07ZI83(V5=^atI*a~?sR7lRY3)DXMdv|Uu`ZGnOd0sM5o`2gcY=} zwMXA}w)$ZJC^P#e_37H$Cu@skZ*h)G6vu5}ctnqDGD8qu$w3-*Nll=x9=@Cmr$GB1w;sJ8iN~L?MP=sQxOMxnO9lL4q6MC0Lc%q_|HwPx8 zp6n%bOMeB@39sxLzC2G&sZ#GOuDClJ$cGGVEW-g z{f_ps@!-x48CA)Pb&pu<(WZs5>?0G z<;Tg%fXX5;^ijg8lJ^tfn6d=C0p5anKI#vd3tWL*IcUm9ta=t8`BdOThMaV%y^m*z z34cdiqW_roawe|NqP-@g`U06hMeBfOm2X&53=8UnkDdS@0-9n?69o3qIyRZTbJ@XM z{Z`GWFLw>%avMEqa@xwDa`pnJ>oeoX`TW_YGOb&I0-z>8 z)l5vSdPv6l*1_d1k1E9Tf;lSj40XK8Vt<*VU~cc|csBt~mB>B>406r+le_hq=K6~f zPu$90<{kpZQmroo!W_@vWnUj6b-q~6CCm~GCU%7l{^hDYsmbdp z8kYV8%K~?MTK)i4BcUFwWhlwEC-x9?a)^k1xIdeqKZ__xjmzJro!|03pno6$XKS7v z$4%Ogv>U_PaC-+^6(KMBzW*iWhpC^^Elj7hr)&6}dWX!!8U;byQ(9O4Q zjp!TmuE%5)Zr+rXXYkiH)PET0wC_x~Mnt}5tv>K`>m45Ms7m-{aWHT<|K+KD>!!~B zWmcgGk;+Yv_r{{01MgOxj$5}uw0k%C51c|UbrNL*B*)s0=&8qWWBF7xs#iFI+GLA7 z1Pu4`;ElGVvW${t(%O_9-tps3XBP^OH-3cuoGIchpLrpmIG9&nG=Go{w4A&k^>vf- zZFpz3bf2s}w#}1OQh&N?=hbp3um_rI9ffHgAcq@(>}l(+C5M2% z2vC;AMn}R2{jKOa<9~BPC$|5%%S8icTDm7WQYxpbT+e?9(lR7Cqs#ILA%FOvHhnl{ z>lfiIOysRBKY)L9U9K)+*TRJJ*##h#chHO5)2nFIv#ucFg^3}`KzAyTxy2^ z&;f_U>SAAJrqSluTgvM8mkrptCR4Y%>4vJtExgyPX#t93ogB=-DCvXv{v9CFcWA?6Xi_CE6mZh%Ls&^_8g%{2*e zgUh<>5O5XKd?|CepOg)tA8bBw81m{VG%38h<M zi7LQ&X}q1kV^(l_ef%xBO1E^ed&PicE)Bs?mMD8T@Y?gM5j2k=Lxgnt3oc#VNOd3t zUGX@3vF`O_`FXyU$y-_!Ojzsp0gY>-4e4;2?|&eF08@MW!IQJ7#h+6LWl=@9 zPrl`auF_YAXIi}#V|8@)SKH4orx{jV5%h#t;W`HaHigE!VpRyORs)YOd=qkzQItz- z*8;Gv)z%TvBy$<~>CPrKh{ye{(+{Mq;OLYsv__qUZ_D~7Wz-e+fy-HLDjF^DGV!=$ zKYzhIStk!{d3m@Z(IR<7K(MXFMu$PEMZDpf5}cc^M|C4*dzY);Y*MpEO9(>fwGN$SwBptwX-#i*X z^PIv7|6zU6FqBD~3E^Yq78Qz*;Eg*$#puno+K0T7+)Mxd(tRQYg>~Lz?x7cHV61`Z z)pcjIl>;f$Uh>(uN(`pYKR!q0y?8mztGQ<=OrDdA&ae^Sp#K>l6+Ab*OirB~Ri{k7bbjwFPr*qwt6H(yYeK@+q$b?lanf)2x2 z$`o|9C>g|1GtB1wv}*2_=$&)HH9f~R-E?iO6>gB*l_@njVd0ctf!b!F=Es$=iHf_?j| z&acnec*y8ylq}}2fqC#7-3-~y`E4rf5a96f&1bdcAJ)$Iw(6I}5PyPeI+iSRG=YU5 ztQ#xk(qEktH8l~7BKEA@I{UIZ)bpv^@nj?GN%CfvebN@HfNu?6JT~f-St<1l1W}0N ztzW+AKG>Q#kc>agUV*9O`D;mqbB-3Y{ND1suynscf$2Hrygv_wNC+10#rLmOFyDy_ z1s4ps6BN@^D4ABgqJPyzS{ruSZORL=_^}KA^LdshKym=^b?Iw`qa~+J`7=$N{A=UU z(K?O6<*1A&)3wz^9|OYp%vFXm^%#=eX$u0pQC){g4DX?k1;-u(H{@MYAXXg z{7P?oLr}?9dDegIjS-r00MY_mofGY{{!%e(YUY_8x0h+16Ms?$keno<)z|@P$YQZE z99tfn`oRFnie|nPeWUVA_`x9n*VMVX{3+@X5SeV0wE0UxlQ4Oiq|ECd6iB{l9T1gg z3A)NQo~dmNwI;}Y4<4MRWv(dy$qD6wye+7`EeB-H6E!ARU&xOdv@jDracRMpvk(9I zY6uFAH~U6g?thtlka%Ashzw4EtbT3JpQR&_&-(scuN9SZ_6Hp$YNp|o{##Q8oSK#t zPSd2r6@H4Om#^ftddIQC2ncC?<#BN`z|CX%x^5B|+3o(tZ+!;VLeXFBjO`ToNS6km z(d*(X5!wk?0a{MV0w^kRm(=q>TBoU=UOi$_tR-u(J%8b5!fYzsV&N#PZjhh6mXh3+ zFQB|&ys23il!bOd^7bnM@*Gi$baik7`QOsp9d`;=m|kL~USQ#cVKlfAb! zHYhD5-uKxLGOkg^uU$VbewqXQWT?DP=-$aUpnrpoGD;xkUbz0!2QS4JsM`$E2Ct)u z%{BR^@Q`c_PpnnoHZ@^J01RS%lHTy4*Fn*FaRSQDf$~=38Gd-3STI?4^etx3VTajjypcThWNr_oLg_yQ zly^3Fo@>a!?dtd)e9b>4__AJW#%To)$6FBzCb-siTKg2Z`t*p(A>fXCwc`Y{SDW2K zDIkn;W-Tij9n&F~kL6x(+t|hIJ5uW7q<>0J6yQw-4??=0-1MHshcGUxZE)Z7pELd9 zatLUJlNF|Yy(gaU@b6USL5ZanLc6CO5Pf;R~XnmupBSKoByKkh$I{W`VU|KA5cpJ1QZGY z000O8j+ksu_rzlBC-?vW%K4F=B7Zb4YH(+qyk}HXQPVIQdhfjl2t|rOs6krjy|)0; zYiJTc0qGzl)KI1O4w0^a(v%X4bfTgnLQsmJAYH)g^WOLU?p=3%>-%wMopo~dp0a25 zo|!%KCx74n{R&{$iSY9V01OPo0OWxG2mby5FldK+_(uW=0L1^sM*pV15`P8zhJ`&) zmXZnzz3b)~?Cy2fBREhh!tH^S%w1_IfQov=12+$UuP~symychNs=&{e!va7*PgMas zc@t@q2U=dfe)>@eFRLh1YmX>@4~VCLx*AX=LOCMvL7-Qd8!#d;AShHhLRH|uge(91 z{?D|O0Pw#^!u(YQp#MPt?SDi~G z43_*yAsHGO6y_Eo85An`KN7UPLOl?E55oL{gMj}TySWF4hp7q({C|%Lfe%bf{+HnY z?QR7IO8pOYXqcs!_y3tX)H?Ekmz1SfXmB{f!|NZp;Qwo>|1;}<2>)rLY=-drcPMTF z+QA;-fnGsj2HL6u|1ftw{XCVm<#ZLHGFqCt+Omo|3NkWE+S<}OV2GTI5?BkY1yTGT z8UH(8MLDoGL{kZsUxch1}i}2l%Tr*!)p)}8s-+{;q^bfe*X_I zVR9ML76d9XMWdN{HJp^J(>eBQ+nI8>4YdUCf`*c?M8tTZ{FP-bsMmQ#Vjyr+;z%gro?cVjd{#&YHQ zB+Tp#FMqnodIa4!?lh*0Gv#nc>Z8?5=IJxgAX0sq=jHy+y~DZKB#^AD;vhjSBRDgj z3Klln#B434le&}QT)_U`$xp-b44XC1hvD*l0R*99G+$D8VW$=8ocgk+A)cD7 zPKbr@f@_;28v^ZKnv$Qz6|9>inwp|uaxR% z)OsenPF^8dwoSSxf^FD{Cf3%gUI+^T|HtpJ4m`sTGB)95jQ{RmfQe+O-itTeHWsE@ zc?$1%6x&8fOdq*(yu`SdAwO(AB+GpiBY!#zzkUD5t=3yjv2`e85gS6lm{m#J)Cf;R za%gK7-HI!9$4Ao3-&kOrIVzc_CAaGQmeR2kNGxf{G|8r7LvI-?DTvrU$MqhvDxE($ zqK4oj#-YI$awJNxTNNN$!QB+mUFhH+vNTb2uZ+8I)4Bd>&AwgB{dfbV472fGmVek4 z<8)%Ka-BiZ%EERoZiH`ou>gz9-pKbGiyQdrIc_RZMu8Ky%KR6gK{cT{Y*tcJyg(c; zJz*Sm-q7t`y*(+>ug}`SBYG7EAwr3aGs5m!o$N6pq(G-y+qxUS5Hz7ir!Vp_x~T$@ zG*DO|uDi?}jODiX%xb#UanU^q;(ryTkG{3Wlt8whG8I-0bBgrgZixjVa;3g;Tj>%A zUOhpR7ad=j-;E)9`bD8o&e=NdgK_02ejVTa;%NwN)z(+rFl)7+J)H>3{*QCW9@-!Z zJY}w04`=3MeHqZ@O5?%occk=MDCs@h{3I+bf0qCmuG`M(_X?hi;kqQO@qdiWb!3p4 ziXKcSKt(hL7gV;O^pkD8#2bVD;;o-c+fJ_*3>~>q>H) zrZ|t;QkHBuCpCIVt6q{+kMD(m(XiIGT`X(FrpETkg*=_Pr<`L5kB;}7E6x6tXy=-o zS$)V1+5J~h<92VdJma_Uii42!p8h;3uNP0F=EpK}p=7-c#YYdc1b;jy3Tu8{jU`a( zY&Av=9RWoSQtVBG7pz+T0t$t72gOE4HtCp6zwJd?ho?<4V0Bhgm$Lm9IpRryY9?OG z4JTf((<=TAZx8*tJJ@Z&LtbXX;3jfxF;LU$t3g5bOF?u+F=&rkp9DjFlkZ?Gx?9sCxKTkk*R)r*uCF=>DuseMfrCz=o?h9X z;+jkMDCFDV9W#PTdy?=Ogy-%)1duN9ZT5k!;y`_M_NVaOZQD9&a@N$P`*vsD`a3db37wl)T(ljCZNyt3EpS51$93}+|6+60Z3|J;2nXS5r_hbB=aN9RU_et~Q z8Ho7bpC&(E^|b4$72-Kuq8 zEb1)L{C*#4nh=E)5kyE?8N*zmllS?|lxuL<1jV&4Z-1qKvonU^2^aie-W_6rnFBVe zaCa8sE`tY(jm_~QA2NRghUlJzu2ScMahi|YDW%d-N}DkLgJ3b^SGIQ%I6%LE?_#|D zIam2REwh~?BM^60dUqVB$d0g+qbQ8_*Ip_P1pQ-XpxaDlt`f4PSgL>A`h;SN(d3|& zb*M*9C4WPj@d>9@Mkm3`a=pM;d#i)G5%_5mrqC$WMlqK6G|-oWdU4cVNhG74d4tZf z5h5Z7UE~J6&J5=a<2}q_cfy)obD`3L7WHSfTd*dLKgiF_{^nq^Ppt7YlZNtUM1qs- zqUAw*=qh_Wl!5aiVpUnuO6mbIk5n8BY~N}H1b=Xwc^K1bRWk{;W}KDY(!LFgs%JI$ zSHcAEo2A+}jZirX)MWBd_Yj5)<0_H$5lBCOgzyQ2o%g}0bkA*Ap0do zO@B93S;)aHGELs(g!~%G#5!!>>OL`p5;3kSJ;1Q;9bv1Y*xkRCw(NY*PlS?g@NHrA z5)IDEGV%NSU+s?c0eL{cR~FSh_}dMD&tiGv#K%(S8^t+%V8v;o>d#Qt?sCHz#3TDJ;6$0p3x|x)n=F*1$6>@C z#Oa~mcJ}yYvbZAYSnq#D-dhzbAea$gi25=9XYmb|`xB{7$$=c+?kwppzZW3lw11>) zK^(o^(9&w$OKacYb^imM!|-u(g$~|2^D)i#<=T%GM#t2tIBM|Z7~FWp?y-BgR@wz`RZGw8`2^P-C#wn%J)4BU7rWXjO`v@9 zNe#blQv>=CLFdH305OcR#xLIeZDDxrimm~${G3$m{asl+sR@sf&t>C8k$)zHRyK}3 z%sI1tIG0tLqIf~Z8Tq}5Jteidx!9iCVtNdD=RkY4%|e@1xuF?78$kEmCnuM3&{jOE zD4)Rh(xjKg?R4;c{8I*m$WnS?T}G!;AM3)k7%to^Z6dyvmH%0uZPy3)E-L19AdP5d zbU@Jr-~-K<1JhGPj-B>~oqvYPpT%L=M`G&i-jRX6Mh_HsX*C+I6lu~M$vS^|vo~s;Q%Z*Jn@?Jdq__?&3dq<56hl~Q+aBn6&WrOj zMk(&y$P#A&1&T_aEKC3lMlR$PiHLZ(37QVJz-1)3+ep{AEMOnl za)?9vmvL)WDLqoY+RzDPUs?R0qtfoRWkET5$g~#t-#flt$&x}1Vm;=aLUn-@CECH2zMO2d$3}yygvda?G4)hwJ!=`lH@UR z!}vP{vk+ztWWFo+^jdF#=ugTh56)ZJR6g->l<0UaLADqcRJ%u=rB6=Wv+{B|ZA_3s znBwzd{qPQ3#~-L{OP%i9LW;~smj|$PD?#L|Tn6kJ^MTe3a(~N1t;`$UJ|umk^RAa`mIZu=>EKJ>l?`nyW9Y=} zGX=xwmRGQUI#C;u6meR4V+P1`N3~o}Z+2E?vYea@cE9SGjRKDC-T_6|BP)bZ{F+-h;k z-AguN^0pz%X-2}TcYf?rn`l?5S6qrxMOy$W0UrcjD4#J$^<7}gzLJ;5w( z8tf{SWgo;5O+uvbd%e5mLQt^Kc`JnQ-A^NpP{F$z+`Z3hM7=d;@kLVKw~Qx}@rJ|- zI2RY?;(u-Kwgl~IMaq@9B3+I%q-TWwztYw=e7^ka=K<*zQcsZ=QNt?`Y09z3Z3KaP z$~OCI86kwGFzCdA&2kxcSE)An?^@>bGxB7TiJFz=M9VFA*ZmK>Cf*j13i$rEPMNf` zD)M>4@?)D98;mlAL`UjOcB7m|&QVc|Z~hSF2!DY-uD`YJgs`B5)C~^o^hpg!c|HvM zG(k~lA@p8X2h|Gg(eBd&(;nJqvH5a&N z@+%Pc1=m)rO;Fu88K8Pe>t>LNN1CYFQ^QV2Ca`^nV6XY>Zo=^f$=a6DrV-=Tw)@#p zZC6i=ZmyJBfgoMMYSyT#mQ%U@r;>Ve#eZLMJ}5w0+g$S0r8Qq12O)GJX~yL7yXyIp zz5?NegEbNtlPzv%$NjY7SFH6Gn}^3J_VeT51uZ2z31C9bKRyDIq^^a&2b zF-9FWpgO;6i`n-m)H+D4%iR5X+d)0$*q+ZRA1vP>tl|2x-oDzg z?Us8ap<*(LE#(_}m>X3>V-y@Ww*T#F)Qzr=1uHo?%ka*WKyv5%n!2{LRT|RDi z{JdK!#W?8R?WycQ9~w$I5&r7l!hg#5^nbU9kotZHi^UbU!F_^`C&#U9SLU-H8O~OM zn~{@;LfPt+fy&)Et~G&Q`f5j(w8rRX)seMYB#&!UPU`i)_}cyjsPoEe(c`%)ANZxo z+9@RpsqiC8cD*e8Ora!o(-P86p(dGL;Y6ggU|T-#^#c={LM^=t+HzJDoESYd~T z%RD=TBiQq!zr(P8W}(Z&f%^6AO*DkjotcEMUebU)o^pa-=YGOzYpiTHePTGGYi2mg z!7J~hhwpmIqmAR~86)2AZ5_C=H?5YA*S5{9{RjSxoxVh`wP&F1Q3!~2Zv4h~7&-5Y zcj7K3-Jtg_mcd-toI|O1xqm2Qc`_y$pZUxkW?VN9kxR#nmKOBy>aAY8Yj69HUkhM- z#yt7LkY@VFEfr?O+vu@v)X-u(e5j3{m_Teyhs)UGQX0UeN_>*m5yQ@oPL2oPli4!) z>@Vhx0KI)?vf*c4B&1zePOeK3CN)6ZsIaWNTp#VOpu?K9fbzpgG}AimNhjR_Aov|MD3&`z zFb6E?*Xn*uk!WA4YF;vgGVfrmW_}zXT8&LFGkcJP@eI29KoWT@Y~yXKCt$&jQtYsf zv#HLV!n^%Es`otvsDJ2-2nPTP@3wT3Myl;>vFKQV3Cww04HK^isP0!`51bH zICm|NOKt;(Z%-GeY+;T!SN3&YrTeltgB~YZWskKR^#0cT9DmXwo%@Z8H|)bw@-Ifh zgwHy!;B%-o?hz50@H&WX)AlbgXc7+yM2GzDRj0iryQ{$XBWm$`lc@=}CyMop3uT9} z&KjZe0j}nI-gp(pt|y8EPs$|H@@P;dHcuj+JE33nTA5L%Lg{kd0(3M>Ouzn#U}*KkJE7O9y6X zGd*iIvE^Yz;6rX3NWX^H%7xI{*EU=6sEEGx$Do8ZDM_I>t#kw)2}{oquGi&V5$C(+Zj3Amr(L`@T^* zz~kv4-qCkKL6AMKV=<1!eE~vG9XVIfEO(>QMf}HPnen#AwKA>pl$(;=y(;=qH675? zc-~`Wz+rEGjeWb(X4rwSEdHgBR(0byDf%`oP%B>&tO9c_t-hyS-Eh+G__W8pG~ozN z<$;a_%6~uqd`C@M4afQN(gIB998YInudxL`4d(u#;UkgonE}^gk2gpsp*n9Nb|hi@ z$!FMHN>#i~Pav@_WqPM?mM*|I;niHHPB{%E*YFa>TpnPoqSrTiFIR_!Rgy84A4Hp& zzB9{&217evpslCe-p?jr`*S_s46>IB@DYe>xPSXweReR;O_vo|XO1KJ3%CO$$_GG^ zPX~KyTX7(O(k5wD7=uG)SNmOZET{9@F6{mAZ=AHN)QL{>kOWhq3aqzyy}2$+D_5vV z`D|C4NyVc=Jm0hwwN`+d(s+KWY@NT|*l79%L&jDx12A}h*nIN93?GsB@OeFDz(l8M zG=EwEMt*Xj(TshPlmA5%vuioQ!IZpD zp7v;YdG`t8ymM1K!S4>u8pci>8vHR*gWd%YZ$kD#>KhVzA{i9Ds^CQLxnTmb%*ASX zIFq#juqm%quZtr=%aAvUOn2)*b6-ZZ(|-t*H~=D2RGM$w_qmhD?$eYbTW$4|@kBBc zpSj*!r05V3X5)hPt|S)iGrENJQs;8{sWaaT)7htqRd$ImrO$kFi@5Knw<8#^M-UlY zulr5dle$7t_t#zp`vcgkgS2jtamA+6!-+gh%o;|NI`)Wk(1`g4bjMo5EO%~jfagmV=*}`SDzhaE3 zYmh(Gx!&z^Ye9TB{{kH1L-iT_9`2j+R*S-udE0yWjQ;|9AdFoy zi!wv`G?z@0D+xk50_!YVS;6S-JbwqKrm%*j9PE3zO@>7XB@J>cBE}DXMys)@O4?#$ zbvCi1RQVUs`tm@>-@FY=*2ra|x#)FFtCxP-a?8@mPY)IwNqDt-YT$G{71QxUTW1HZ zF^ir7Kjf7g|FQE-3K>ZsxN6Om14?AAqaB2+OB;8ilISf{M4chu5LkpTfPb7fb)t7O z0ZYECbQtrS>r_) zthUhjkACJO5eGHy5$vmk#hIjCJNLf;gB)`rev04BF%I7gT}|Ju`CCS-?0MyAacSzG z4|=;&X9MOOD2iHFxckZ?Fn_`CCd!w8R~MSonwz|mk7*gMuEEjWA&Pmz{-{Q9-6y+Z zx;N+-!Sp1fQt#fCx!zOi!g@f}fi3*(ffSm9e7`e$3Bz_$jMvwG3`GvDn2L&slmsMa z!|U! zc+Hq5=L};YNvNmXXl2$p3@+?_5-?`wFW~u5{%t%vcSbo4=gNReBg6g{Mg>J{Uxx?j zHul1nbI0)0N2IYm@S_wxhEIjTB=+m=HMhws00IW7=SOQ5Hcbq<6e1Q}fqJ`i{7C!1 z0RQr6G5b{Xxi^%!l7D5_Y&UqL6Z-%>D*gCj+YOsu4!zMAN3rl$$O?HOorZp|!>})Y zQ?jb#MS*p+1=<_dwZEm8(z!`NDL?VevQ_^#$Rk&1{V#y9uJM=yO{x0Mux_)v2H}<1 zdymFX`9rQg_B~hFecwD=Pfg8F`dU+qwx_0=N=A8^m_Z|RhJO_8_ek;YW*vuZfP78C zvj%&$DkXI9vN<2TW2EH{z>;#Zk{V1CV5OY@sRu$y9n>KXTM*X==!KB9QXvZiuKr%@TE)U8z{jws2{EdP57W)I*W}nD(0}`FJ#6xo@wMw;KmjL?Jl!dt zNh?e|&cKs^h@pu%{lj{S4xV8uY`<930U$?{Bv%SAUFM_QSsIgDVgaER=Ya=33r1Mg2H1?mNcFNJ7iAE$}PsUO(1U ztXEHBU_>Z}Zr^>~M-B@h4}p;+5kuH#U7aUCC_kJx3aMO`4Zrxf_;Ieg^`hA8XA$Qk zwtp86D@O)@0sJ|liIFtiszjqRJ(oI4x`la^kLT)M{wz0g zjGxUrHXP9j$TDFzdU(^~3!V|>EPX0I(RR%)qD{54A?`Yyuv7oe#8qo!aO?FD$FNPp$~ ztD!?+(>c+ViKuV zu4Um0fe1tztUNrfHzURy*NIf!h<`G@lPMHf3hRFn)plLM4|LC%CJI(gF1$z;IT+@5 zB{=!14X1S?=azW;Q#H!wGb2(c(V*h+-gxx_OW>!u{vxk zBKWk&>GKco_C_v7u+JgmK;DaT;|M|U#A^|&eO-^JH!@ko3Z^$I4_ii06UYPDRSOhj zrHpPfR1ZlKYK6nTTOh}Zvwt7lw2UQ*fWUtNDR84K4R@qa3eDj}&xTtONcxZ8SKU~a zqaDRD#6ZC-DTkB5(90Sy@a0~@f^AD*Bexb8?d*kfR{a=LKEpyZry|Sw*(m*(ELn>U zdljQr&bRp|mfbpKDTiz;OVO4NJAog!jqNMGqCk(_Fkvjg5drUOKYycucaj5NrKzwO z2~(ExkRP{zNRHUQunWN!aN1Hill(Nm@AWEeyB@O7YH^wJS^8NC`&XRSuRKkOpN9w~ z3?JF8wvqELw+Vz_EM=RVyHiJc8kJTI$+rwC)NMK*^=BLQx*K!`e0iN|m6JLc$>0&V zhi7{&b$~6Vj^^z63xA;C_NL2Vv^{};iAQ+x?FBFEH!`=fv%12iLYO(iQ6vPS6+n1H zc{7selOx+F&R%Irh6Ad(wBdC3@zp2nBB<*7@tl&)MK+s95ThOuap%(*7Vwxmolqb0 zs3oo;pJ*hLeSOBS+6hT(&xA~D$F;*UbKE=v->5e{vAVf4!+!`MsJLs+JNkaNyE?As;}l8AqXWV7A)E>`opEvKe%y)n@Hkt5>R% z{^DX+ZxKw!NPmf^A_#5^XYnz!$D0cBhsI@{Rv2P-p6Mh~zrgGs^L8r5Yb3c|Hytny zY8ZK5N3OK%u5XT*E2j+=&Il`zX-*C_Cpx2qLgvSU{sKy#9%XEagb=cvwJ?z5+5Owp zPV5884wVzc*f1_^F`Ce60&m#A7STl+q;)8$5}rtl!+&)zNuWTds?Db%6?2~N(@$yv zUilejFRK?XP8#PbR~ViO^m4M2c>a=oJfYxwiiu!Hk1$kmiC(QNAn#zEb(qC#UiDmTXn!U(TW(kDfHh`W? zPR=cAu75+y@<)YgcUo=bksi$Q=zEXax&uQ&8$=lcYA09b3{B^Lk27glQ}1QUz*#;Q zx4t=GjJv*M7vFMdztabSYcm8jzAoqd)`!p4bUqRPmW@A~Q|91%D?;oE<(KstWNR|( zAw~_UkHcyv!2t80s>2Q?+{F@%uU4jOH!6}QnSUwby`1CHj6;11rv?$@UA!RQTP4YS2p+*H8aP^+q-AbE_zt&s5+3orP=kt-9+iRq3uqeBI&1nC(T}GUDKx&=ZNz9=KoBC5 zrX?n@OsTs<6bsLl*RoOlp=C*nC;Ulvi<=q6&xZrcUEVZjMaQh0Uz1Rse7RCSP=CB! zX}>bNl1EZ^KWMd$wM%ml%^QZ(?v))^#KiO37$kWt=))+6t^Jq9%MuvIxIl_w&k9A^ zX>s?Qc3}&G?1J_?G-45B1Q`b%f?tq@K5|ruBOo$!_V{d=o2;U8_+M^S^kH zNVec{X?GZ8TNLLfvggBy%jn@JsDJ2HkhNmv9ytnhZM&5BaH*$I?QawhoO9LTG?VL>)=;R};0EtL=)7A>E zwVRso=L<8e`e|TtM8M{UuG!@-)WaO#m<@IxDxcQ}Z>K=3S=lT3C<~?Me1B#gXI>{| z7<42>KfV8=5i8^h?f1~lS;EzVTODX#u|uDoTpH#EdJzczuHES*nmUU2q(bppU$m;h zm>%)oJuNc`9WMv^IV@%3JCnp(L8q)Bdgq}YF8d?K$A`C$i!HJ2h9vy#4O2fISi5D$ z^plWka@r$FxddT6rE6`9$A52t0IW&7PKg*(A>_G;QE+z+*ZWk7jIn?1fRM@5UfC8Q zCATq`KM%$%m7Rk006i*HAYQvJ{B9k;k=h`Nf%F-?B~xfz9yNa3(5Y3T4$~1mdi}05O3vtN>D^i8#2IoNzM#FMy>96MzK}eRv<<*4}p0h<`Yg z|F9BJ2=b3n#vR$xpt4WblT+n^r@wZ;!p1kyA!=VyJ>?q8yAEF&u=PEU?kNv)LcCBF z!<;R%mDHIk4LYZM;(u0&;q%s-tASTGjo4Yd##sGhBV76)7qUM&(jrnTtG`AjC9D$x zf8ahBWQAt=`!9K#hig^1p8?`GUbbL@9l1Nl0%*orvR@&vA;g3!4xi6kaWzb2TuGGP z0Ip)%xSFy*iwlfWo<^?%L4{S^?=%pvCvl*$Za zN6%eBoullx)=o{`HAZM5HFelRRLnjvO0AK)r42M7h7cN%?Z62#K%l7$>n}zK@GSgM z+pjPVU5y#LZ@W!kte${;K2R)p=a;Ulr+r|$P5Ot0oJv-TRFuN+w)Jt1!rAVs{q;M) z-hpF2Fj96!m4CEtu2&0eXyvqo*{prjpLw<;hFgYn$18x|yNB`iP-7vUP8Fa+v80hH zLRxb(TejZ@iy-PQP{Q_c8#d1M7)b9Coay%~0^%9KNza3IuuzJt;^3+mZLsZcKV}fM0!h2nRi+nO>-+x+I-J7NE8qeogE%zxcq)}6E3)jqA}U`2Hk)i-zV@R}o^g!z13C}s5Y6&7*swSTe| z?<{bu*xH(;;{MGom2>$NeoQ7HM2hXI72EmqRBAu^zHPbj@5#uJ7Pc1AV5r)vb2CTttBC ziBGS@Psd^kes{piNpk~UG7oS+e%x7lG}nFdv))9jdvJ=w?5Z6{6$$(Au=~p-aXMsZ_)3MEqp8*J=TAvfb8`*v6Tbxhce*07!sj?+@H9f z?$|8PPGz2`{uXVRr@gSDhT5>0Y_v>*h`@;Z8SZL1PSBtF*!d%aawDz{@)xkr2qj~q z8Ll^U2Sf4X2y3O5TTX0M{?oqz(cvdV7vo?Dy@wv>wVO}35L6ijRZlUy^9>!FYFlz) za8`ejv<6}upiI)BFBp!(Sgwn7)5Rk7aN)R|}o*;3xuOTRIOX7@~$3PuGw za^*NhclK2jTWM{K#hon}cQ)W|_w@%EMXpArS$+ zHM1?o+7ni_WD7Rxf*WP&-JjA|NpFeniU_$&x~*l3B8ba^BvC(c@DV9id!Bt0>urA! z-9C_a-I^A$;i$yRZ^*5?^SZ*_=iZS4~I< z)BMEfN0wqOUOa#Q0GmeBeTGy{7eyfXv+yiH8RBaIHe^Ov|E#m&_ivrx0>t zgMxahydCB_m~k#m@@LDpbXO8-GHnI-3>v0!8jvET3W?z)U1~mrn{PuEnZSQ2mIn1@ z@^wiN1*pQ|Uce)37kY#UBQ!G5vV$YnoQX{97u;W}xzNb@sl~EGUL|Nk44TPU6=>Ww zUiM_lGLQ(4raqq0P9iNuLO!LF3w)a{Ks3P0MeOg{TJt(-^>r4tww!>m=^dV_M}v-P ztQ_7sxgU@R7*-lu9a(ZL$mV}*cc01zH4<<3SS;9l8=c`O6g+4VW`O-uR!!)+-u&h* zQ-v|?IU!nX)`_}n!orp0IBZ*Sbw&4`VQ{1WX}t#_ zbmfHC(Pp&m*I1i=DeZq}-{pN`2Kw2G&teWIN+N^P=y?ddsKPl{WzBicx>EggM zz0K7-`-HPkU5{{WZ=&9;ArNNSPg+*5v@Yr6U3*fW*z14O7u0waD_5iAPL0ZlYVBFE zBH8E8QroY3XY*(IC-rZtB0zr>?QeVMQL_B(C)*CTWAV_T>NkHapY63o(XV=GTVxtnBI{$&aXkWHwPR8dBBt zJ;Z6cyrH%GabG!wxmBN2IHvgs{@2tJkYpMcQC(cQ+`cz!GUa66h zVooJtuy0@Hzu`5OZ@3Mj2VPUIaB^_Rd;bM+o-})SN%TGWz4T=In=#tQ!gIW(v3km5 z=AD^Xuw9KYeb${n`C=FgQm1$%r@=|f5dn4+Ako=$b8q#qxTM(AdW!CKvxnly_F;c6 z1>)uYmKHRJ1W`%^v?&VMRDgEn-d3%MBo*qA1ez+GKBMxM;sezQG@|x=o;^u1i z36&&e_IO6uOKPZ55-}geV|(3@BP)NJ>ARLVvd?4ww~Z&wB_jn>SWx6sy;LnUHlE+* zO|Sh*W-;J#Lg?WwoY5sCbj9zOxtL3$Zj>ka<>dgg)g`Tfr~ExB&NilB$#^QGcE6=8 z(eZq3QBuZ^Mw1|IMrdg+N30D4-bKL2BT8(bmY;~JZd;K7{^T0R4ci5OxxasRdKad^ zQXTk9%x@uk>-uyuE+$;TK>xijGGed!EUYoca|Kp{oHmX|OX5g>t}K@W|%;T@1bVC(NH{SF0p`qVLtQtQqN2(7NcZ~^1CP-N)7 z-%h=6Dfp=sh&eU%WQfw-UD+#a!rnR2v2{Tx`=njSJ8!j#$kx^ z@XDp|mN}k4ha6C*;vl)1N~jxsT;~nkhC|CzekFF52Z|;RzHteJ>mP3(i?)XE|89JA zK_q(K)$!;4G!8C1>WS)1{tGZY2~&Xa--aAgsKN*Rp&6Zu_@IYN)hmx_{%J{_0tBx?oC{D8YK*GB z&2ln*RnKOcFojSeL_Y8ihOMgbosu)0Wv})A;e`~^0g->VqvE@EnAn^{q}gc|1gZyh zrP;$c$Z!oU?wY;jCBs7iXt$>kxTaa|u31TL%zPvcx!_godFM+oW!?P_4*sb)-+fGr zLY7Y+kXJ9ZCskG?C!W$k(BdZ&G09yalqqyk&OaZpv1jh1pbiQVi+9c|R|^G``Hyu= zIj4U`G950={9McVrEBq!BFdLUsV9=r?9P7sn`(dG#|Zr=-h{tPhU5i8@k$9nNii+c zomm>`h3qa+yHW3W<@+@5-%bM!rjn))Nrr|UI^Ocy=M+rbaHM4xunXXK@shS1I7prK zhuQt#t+WJ+B+(`?=6&ud22$QrI&+2@retM|qMbzLU1LI?tCJcaUW75Yp?j!+_k|!a zg)n~wo8012f>MV=$`A=hy-aD9HpAoVZ>_5eQg;%k_M6j$#hZy`!=>It4WC+)jW;|# zSnq9l=7RrH|NRkcy`7713hg2Dabz{BGt2JYfxl9nZ$_sKQpe9$@qN{%>4?+V-t*SS zi?PpivO^ivcy{bh)FEtks^sm~p&ge9ZexEBDy?7RK1771Cc015dc*jgLhz9ckM-f- zify(CXDWn}4dkA63ew-uO&Y$yM7;q9i|$PRhB1cdx*AA6bC^x@bA^fKi0%UYzU!uw zG3v9oa(yUyw|p{1OvV`~U&(QW1X|08GREe&4GAaMgQE|d{rb01uw*qBy%vUZZ}WfE z{qO6oFn3dlM24ZEFfD6Z{@w81Ud}LESj@>HW* zgyf~k1yJDFN-^A+?IiNgzpHyTS^b<`k!3CVLjd$(w2Bx|<$~FODK|!gA;yjODaN4Y=X~L(UzpH;ADWysv za>yL&WO4lT(Ey&N;U^;Dv>FsYY`ahE_1ALkd$c208|l%WQ}4_Tl+E87qxdduSu0jK zGH1Au3kTm#nTflx&%|O`Sj96@U_&y^@DdEW%Fi3Kk2&CPDMcJH`nJrg*Tx$Pp#FDQ z8|B%)RG>Zh&2-dzixlq=3J-r?Wj~*upJvOw9An0+S0_I$&e9?71T?SdLQk8lvBv^F zthP5x)n*)tbay`aDX=`Y1BC*gW(kLJ(&Bb)I;Nkd%neNLn{VXnaTJ~I`T3iprCHC)k3P1r4WG?x4wyfNE2$)5 z86Tw|Xk2_s2+%M7IML8KFIbQKwS3B=Aq`b3S|qVsy{)Z)RUz#%O(4d`>B1_|PdG2m z?-fQ!+xvWTCsU0IsnUO@QxyWesbg3s1wu0u@9rBW?m6wpU3t$$X6AYn0p1}h`B6Qm z$8A2ZIT#5Q`&gImXyqe?J$!A9uAKfAE)ZOktCL*AZy+%pO*=obP1{EI zv;)0_dph+m1Feq$u3}uN4kJ`VoDp;~*m9rH4hTw5yw69w;g!QaY(LmI*N*YALPJdJ zfRFY~WsANU5mV6#+WtG{u1f#MR2{0KsTB!tQ@Cez{VIEt3bm^}K_}sKn<^%6L~!Zj z*QQq3LM?(jRseq;%gXo#0}hcDt1szS#mwYgX2bsGD?gh;$L7rCIlGi?h7-QiellGL1uq`)b|g92Wo8 zAB4fA=RR;ddapYjK(k%Tt6F}N8k&=}w6@F~{=yZ7JP9GS&pVVb)_1TG=%nzc6w27;p4=f8vKLWPByh|p9l$;msaDfH5SKC>7x@G_kx_4f>?|y?nq4aZUqZM zwSd%!KW=GPo)FGTb{3v#B}Mr zORVWy&=Z$)-8pNu&gmjUi<->+j*9%cdfOy>bZ@1I#67j@-FKT=j!SKd;=#Fw%$~mh zd;0Y$ovmR*U&|vP`q`#RQ~nQ)syxn9%>6R(_*AZuUBu}DtTJJO!#JGFY`T4MLZ6=6 zzEpqbq-C5Vmw{ZW&o}jnKUz_u3(d!LcFK~u`4=#)n5AM|{`FZ;?>&8&bWQI`M~fRD zi$aM0IKRIhd^i<%mTr`6Y!g)!DkyAQbF~-|+aL@eAyQ3^!iBqpSI8bjJ0(6XH|S@K zNCb`6(r$X82Qu9>T6Z$ADhX$qHm}4chCqMEWCSEk^;&j!lm??`U$8*M8D&88{7sIO zlJ}1?05T7j#9^(Nxp**inyhjzC&txquzHKXL=EFn2w^~`B%2IKQFb9Sl7IlN75&(P zs21-3ITZX<48O3}|YO1C|OMMSUzp4+Okx2Ih5M&dW%GK~{5V<{$#A&Y)37hwKyV5S2Xcg)m zOt0zxxbdy1uu%IoN^)Pd`PbzyU9W#Cj*j?P-L|cJqf)sfD6x+gH%D2LbOjXQ_z5`q(4L2$;3&fY%oTS8u#`jZ^0Q-KfHzR)$z$0u8 z)m^#u?34$l8jmwe9n|aXR^?~Zv1{nwZtJp<*`eq63kL>(MJi>U_iMhfn^si*mX^I8 zlO4}jk3!;I!&VQp?h#3Jg7%1{al6(5j2a23OqD=$G8EI?Raz z7U*11nU)13Hc0uHJh!q*-NnP9O@l?7R}e@01#M(Y$+VZ7ebvu?3U8L)cut=f*XnLuI~L-UXyN?2Q4%Z)b}Iw~R-ite$!($X6~7Rk`UqWDUY?BK6Ua$g1<~ z47rPdkE1l2!s+O#R;PDQ>ds}d{F&0ZRI(cj*sH169r&Zeo4kLrb=5?RHRE!e%R@h+ zAppalP2p5gll1C&H0fb#GX>a1%~uWdFN0sKiCeAm^!zzu(#cPPVog2lt@ti za&Ztofq&y6d9Wn*O~;tN6#VFO^s?MvPH( zwxGX@y4;4Bm`$*t*07|q5cn7H7XYE0w%N7lRKUIm$+e7n9c3BN6KUmKg!3$k6gpM* zeWDXXAI}Jw-C-s4{hi{|H&W*LiNgJe#WuhVD-qzf|KfjNr(--A6oAicI6U=aN=^Wv zPu&wvh+jL#Q&leYUi+f3rEkO?C07~6-s5p3NxtuNcgNJOQRhxKcU44}TW%VWIO20_ zQc&nQdsK-}8V*7g@DjSPQ%l@5)B+;utp7hF0VG_KgQf@uQk z5`m$xNC2rQb>YXiN>3Oa@tR5g;jK}EF@2wbl@28XB3}-Am$ff!RGjJflN@fQ_v%k5 zR@nE6{cXkiA9r!UtJL#YDv{1k#l1)**`WXY&c9G1BdN++bFAe`!sedt?tiv=K&$PU z+4Fx}@uzNcW?>|?!Dv#|TGcn0W1@_ja3$ReHjxwpwNs#sT10}u$ley*miQRJQ)BtkbSGiQyq3G+oN7;26$ zO%2(v2tCUQ8QLz*SN{U`Aw@{%`z^T0EbV_iE%0j;+3QOE@9eaQ8hIT2R+IzGMLv5l zln;MJjTC3%VzBr@jqCt>M%nxd9$*sDI1xDi;!ybe4B|Dd|A1Vwua(vdAxh{;R8@Yb zz#6hS_xPlQWzqAGt}?xPNg?EUHpYhR4j$1bzOi0V#;eVS)&@JTR@T4mK)44YADMs}NucKqHzbTA?*#YEdLd&(XiVp06-3 zhl-J( z>?u)stNr2bN4k2XVQdH{E4xOm+j!n$I8D#57ICg(wI2ZzKYzDM{{`5g!8vQ^>#amy zljuE?=OS7L8DN#CXUQ)PwA6nGPC~bYUjy2;zhpf+Fx4h5i^mS7BwPjQfhhWwS!xD_ z73DJXH}8&=q9#k)Ufa7VSl7@GGWAr!6ON#t=Z#!K=BIX)j?~TB`2U zZ5Z0$9s2H|tE2UzdlQm`&8JUyzO(wLP3AAa{GsYps|_v>HG`S*i0Xg2feJD_{g|KN zHrVoOmvsU}9)IHHw^p3-+`-dOvV4&DBw)1}%c!BoS*_SGCs(6-@vLN8&a!sR_H(-q zeI)y*=G!RSHokFeo356@1%qa0pyN0HV8E_ju{#a z9UNnUbVAX6z;@}S(?<_W)eiONtc@=-?YVi%LIF!HlO=j9t z@-Lu7xt36Cg@7WOviVA>Nb{pJ=)xv+$D?@cXk6~)u-KgOJ$ujO6el#tpzj|tZfro} z8>wv_n+*9@PNW)am^krAjOY=Rg9z=>k*9y7 z2+Y2c7C_>B%b|ZTo)}!%1$!An!oA2ZQ1^Bvz6fLiw%CCTq-mT(C-uDrP{sPbmDVUG&|~G2#!D ze>~cHv4A)4PrqNeR+I!hijFr4kXvsa9~autg`$?$d-#8&4vp2Ij!KGHrwjbaS3jtaze6k6kQl>=;Ne zn>{YU*b}41k2n*R&AlD6(JJZPOAqM`-6mDCgc+47T5PRkJIaOSk@xq?!O_&+&Y!e6 z3HevmeUyJVMj10i2o{H7J9ww`oVFV{u3_HkNRT@n`0`;C)R zOxWgZysZ$?g!y!sFlHq=BlFqUhynSBq>-S2aJ@K(j{dSv-c7y*dkZ$FV-qh**3BMo z2p)>{G%CDShu3LgJ%|yH>Co1aI~gb!nB9TpZGV4mn8*XNsNvcu$aa>kn&8G_L0jl- zhQU~!E01$QyT2;a40z;auIN$qjCh%$?lF;Y8Dp$QnfAj>u2r$AZw;PoD$v+345piT z+%p1Uq72G!6f zdQE?!2~E-l$3Ha>h`?mc!G7so0)GL&V+ z$Hr>aTZ;c&jwFc@W7(N7mUPEpCdPk8A$^6dvf9xh+kK$Q3uX5**@U%sH4^2YoAuF( z^ppTbEz5_o{UwVfe4{K<=V!JWkOl@lM)niukbSkaZC%)Zyb_VELLJ4oRM2K9n4n28 zb#P@PU~WLl2_}>^enKHEp&vTbl0`FtEhe7I2^GZHjm-&bJx?wdYkAOrM8toJ{5aiq z)hRQ}I4HHHD_4fzE;P_NRHL!>lQ0_;5#Lztd$g&dFZ9_c$NI!QQN68`065YzKjUJK zmLV66HqJI$mMPu!$^*pDNB#xqqSPh%X9b{(T<^6lU>XLZ6>laRUbjS5y>tff_Usm9 z8UJxsC4Sg;ZCh8a+jVDEtmc1c#)U2FMLH@MK>U#S(#8hI0iXpA>h?<5`oz^f>SbFh z_M-ijl}Xz(x*s}2uhB#Q=$%8G^Wq=3Mhf_ z#{?t6nS3fn>Y;*4L4#tU%N>oUh8Lr%gdd0Ds!TXnw18@KfnH8#6`y~8TloT>fPdtt z|E@V^%AQHlp{3+F>mheCSCU=pPll;Ua%HO)3*x)6Vw3d)E1h5o2}fc@S@{?S)Gh8I zqwEt=LRNz8veY2BO{+s+X^Q}x4ZAow$2+X%CI>kB1M87xL>(P`X=Y*Jbo z>n88flC}y%A=#gV-n>%r9rV|EBC$iLOLeuVRjfd|QPhu#c=;DV{(;Q0&{EE($MDZW}EUl9BuHx;Oc7CG?shLH782}?spWB6;Pd-GXFYI zgZp%XbyMTe@9BSTJ~=~0{gI%-8bvFBG(+tA{Tp z5%FhPz8BbckW~3hR0v_IuH;=?tkIY`200!6$kaQ5a0p48!E5H@4S-~i8}y#;+hWjh zcg@cN&YPi0wY2e*yFQR>zHJt25@F)>WXOlcj2@h&CGSQKEiY8XrS$tPfbDkXw1xr->FI zZB?nOvWGFTo7&2+DP4N9f(NT0ZeM^sUKfPxM!bK1uw}C@Hgr|Hr1ILnOYe32%co*x zDMoDki7#YtZs$ZGf=SDtl?R~ji zZy=iC1zo_on>rcOywuz^*)fGn=A^PcHnC${Q~~wd)m=NG$P)xqYO>cBXXNa`l1tEA~*Hr{m@}(ND{&pCqN+g<4SNh?hznybxGa z*nwRK1Tl3yGWV9h-aexE+q`hxscTJ{X>@0&2FzZ^`%R_O7kX5lpL{F%c8;JxY4B1C znZ&QD&e+b!tGG_=NFa>I=6>rY0#pvnH9oM;iTGZj5A@+m+S0A8n$dqz9f&+|SdB*j zN0agGoB~z0uDO;k2W_|2t7rIK3l)!gIaAk!DLCa^o~X9V$fyll7m zYOPh_Az_KWCTXfD5;@K^sg7JNXa9EmZcVXAsSYJ509JpvUCG{bF{ub~FmO9-F=+b^ zKs!8H9y;Oq*GqB`im-pL#TG;phKg_jgFo#X9B)#0N&AE}BC8)DX86&>wE?E_OACJi z3y&nOTa{F_ax*&r0``<|dmEm=kT7*ZkoyKz?rX_GBv5Jx&b{2m-7ulM+7@K#Pw}_S zs>2#h!+EL;yi;SH;r_Pu3Nlz$#E~jIPX*@bR>I)XPq|{R#*csXj3lI3Im3AvzLGc9 zx}`~-%kLOZ6uc8kEKUS`HpU(qph@Q&gbUS@)P zEB{9kuB*Lu#%_8^@|(Cr-=xa;l%3VKoB^w%FqB`ieiv8IRJ=W9);1PlGm1Uw*}ivZ zNb&_Ybm;qgBoTj{B~kDqQ}&5&gwqMJ*HzZ4ShD-*bBXpO7MhbRi`Xhr^C#*y#?*ih zqOI3DT$ik;kp%C&>Lp=%Y7kmA{xuBKiFpONBnh_GHWs!C&IOJ3wmj7p7CO|{Klrfh zaMACnv4tW}9w}C~DCbE}n)t5wHKs`tO+CqQ2xVOqp{|ol)kd?%tuz-vS&o0V-9B*%gd&V()8LAicNr$`TmVO&VKEXG7 z;4m&PJ$qLPsd47r`o*RogbfYt$ZUG$FezQblajh!Z>f9s;?7Q)E^4uD3qi#cPUjHa z7vKSy{(OJhV*MU%plq;Jciy`3dV!k$T`>DnT2lsAsmnUg=O`+&T&bS{sq;8TxoN4X z2v62`8Gh6@&V(i^6zV>gD)$pb5CA9uE`g#2*553qIvg&Y+xG2b8oB#(2a0ThR%KGO z$$Y)^$s(EyRSXn_3TYO0SxjG}rpn@d^jU)6to47ZbZrqu5E-`P#Z}^`H}`(llbafn zpM0?T+L?Avt zo+^Lw-nBz}gaTk*aPeb9mKermM)rXCMg1z??$mz<0lt4V)O_BcGWhzoTf8U&j;AzJNKsL`Kl0Kr=H~S*5cY0 z;{b?F6mhU#<8AWxK|#)vLy~nG74`ATTsdfE{ug!r+~oacjBi=j2CB@*ZcA@@L{xu6 zBpRw-&x-tB=ol|yd>!Z@Cp%lDj4ZzqV@fKnbTy>nt7oO3ou`p{SFihJtJBVWQ-+$HUFSstL{sVBz=c2%-o zoeGS2|9Y!8D%{vLJ$3KO@J5836(; z9er^O3saM;=No`i#H9mPmm>5e0cHr$s-4@2ObBLZin|4Kd;`n8vwUM8HS(G zACif>8{a$oX?GGL`<68bdc1F}RcIkivWc=a%PfptGSeTnVDX_oP0@CfX;Kt-+t!6w z&j{uzD$>8c^@AOyM8;t6yo-O^?DjGK1tEP+-2PzSVxK!+g|?K-^frI4O_Fm~GbJ6G( z?5zrE<%oO?Bu%&85uImQj@+@~Gwq&X)N~_MY)E^s5N5p^1U_H@%mx>pI zWVzCUjQSb{9&qpWkIO`YlG_A;S{;|i+!$yMN65m5b-6~hIy@K)ES0=Hbtbp3JN^r} zQrsnNi3xbd`7`fP4ZNUJDK)Fsv~Y2GWu6h%pVNPQV0vWs8Znvf#_%nc#?gp69uF`w z!rU9TdTRqsMWzt;g~)%o=qkX7a_G>f%x#(>O3#c?YAI@A;q7$X@x-1J*>FYs+H;R8 z%jb=T@zem_Vxs0+V`x4in`zn30b7%o-|?@LuWyIF{=jRNV?0WDBaE4r$~<(3EpN)# zPSjLrh6oT6``L*rGSpy)KLy54^me^|l@M(}7GqaWr93a8NictA6JYyH+uhd46sR``{xr+f)^(r|E`P(Q@ixBSSiPXx z84aNYHoSxCwiQ9ViU1ky1SJjb&JYk| zQhwNgvO-_S15~Rb&#RWBUSv&Jwl!}RVTBpvF-^iR4rqUJWRMb{GRtWq2D12l+sr>Y zC{%qzP7*x-En{<2=g%16iP6A`b#JRZcgedmF+uNWkyA$Z14*s@{ybdg2n>|kUwF@R z=hqfP;T>MflpG9e@5?>Jm_%I_edwTigX{4YHc=Cy%?MoFWz6uRK^(#_^aOHQQ{=>} z8;{khRdjzol-sxPZDa{?C;MNgweL8npAc|Fyx|g)(2w;0M03{i6^&4$F{T-IP~(cC zPW=A7wHMxAZrmk>a&&PqRHM+7SmsY6SSPlr;)WNZL&p8+YeuBfB{6ya=>x_+{FU*DgyF(SqJm%;F=Se$?1<2u&lv z@^yt!`%1xDM`qk)I9K{Ljs+9Q)9;>!K*}nJvtKNpHJFx?N3!yFP2iaif1eI1g7aa)$6%g zsU$v>QXyMbeYtZKiS5hxEuyK9@prRKp4N@~jIrNpBDS*X?_VmfCesE3NM}jHL^+5< zNtkFq@4NzrDmByEiRlqkgMr+zo zluWgp!5Er5l1T7?*gCdW>Cau==fQuMt*g7#M{ZSHlFE--#JD@7lQc=k{Y+h`mVJO4 zW6h6Vm7Gip=t2NUlG6{Z7C3ay6q0kBw3#dfq5a_t%U2#aD#az6S@LCq+JMc&eBw_m zSsR4tsu#i$pGajJBBWY0_%qF#?q+sId#l%dy7LZKX8(E&{0S2bZKJzf)jNMOsp$aR z5Dn$?tP-bJ>2|5=h{vL^?0X};-Zw3~(z27RAAdBhXJ0TPls@3y%CBtjjHd=LobbP$$Tpn$E1!-$F`HK1nwA^FF` zQ^_D7!TuEou_-z$iQ@j)IMRRS^y_2M84Wk5hNe?3l9XE0PQxpeLy0z?YaaU|!uLy? zq}lb(4IF}^_aN31-(JXK(a2>hyy!$XGb_X-C;65};#ixJRB<6`aM+>Q$$*r3&mC?j zPxuZ&w1m07+k+pK$TV?ikp6K$Gpls*MnU)d8|X~({s~6PzP-oqaqoY&u3yP`h}!xq zt6nO33Q$r86cB8E(}Jw|8T<0)&U#5Be-<>wD9U0ns9F%cGj}vxZyDmF-sVotk<)y+ zS_68Kc_J_0_d!B)%$U}$wKpap^o~cB^qLQbZG6+KLWsVX@F^R#jY*$3@EGWlj&`587_pV zLQ!)2{fY+u_Vd>#4r9gOw|}PEnx8qPbBgyfU&C*o%BvVY!03OS7JUPA8z^OZ`hT*0 zzT2TqkRGvpZ4R!&1*J#?cD3x14!7E&cJ1UXh}{RA)=z>r%pt-u*qvZ2d(g4A(jc2p z6EE=B`0YS5CeCJ2kM4A6j|hHQLK(^1hI ze?MZec}BKLl%#IfcId)qw;Px;f~~KsI4zpb(o^7|S;OIe8+40T#G%nwKRfm@^c!W> zeIhMssaam!(7cHSYMU*4mF>K97Q&eshtx@x>3-w$rRIMN*?*m6tz_0ft^((>&qOTb zxI%0q;9KT$wDBDH2jkJvzTJ@_cbcn7{6|BH&fpQDI;OaBxxTVV0S!U^d)LY_{$gGb zeoDjV`To)nLS4z%52CD&s_{2BSF5L$dTKyvd*8^_0mT{$?XtRttG9NN@GEK}0uEV* zuezDW#}I$&6q)|kt5>0uK;#(X&t`GM$Ms+=1zW%RxYt9#%ptqiCUZ#~88O;mBi&Gp z@i`1_uP9V0De5;b@wxMyzADfS{!Yv5!Rb&-SN!&zlz>j7p~)6lz&8G%zsdX?6vnRX zD|Uga!n!&TJzKrscG!W{P_*6APIK7jo_i#bOxb_cb~}mGr((2U5*ZEFT}4uGyviUi zjj;N)R?LtmKuoBPY8_|Chk!LKCOjH378F1iVMH;i^_J7>>B$2_hx0+|aSjb{nye9r zY9LXTMp&O>bA6%=c6wp&PLktoS#fj?$zU{G1$rq1;MSKIO!n7FoS0D$#r6v51&WPl zPEmhNU^oU^-b$H#J{AxbnN2&5<9<&4_M=w4m&|oSRj|aHODm!KX$a18$+hN|a0uD^ zncaHJ2L{atz@7J87Py`);{@Ja5h%PS13~Rm{qd}^MVlk8Cc{|!q{>kyf$5pjN9#=A z^{QDlVl10kFRSQVFiFD4SwHjF#PLMB+ns-IgG|RuUfA@<1sQ|-*4_M!kjJT?!yiZB zOkQiD zeP^$^y8={Ov-@3pbuUqKOe8Gl%0jQ3TV~A*hvI;zV?f6g|FL&}YwYX{;HvdH0!OFX4UDxFDsh*|!SZ0TujP z^;@S0+7>cnHOBYKJq+bKh0j6i^>E1-NvQJz0IFNJ^h%SQS}t6;J9zOTpi6%xOQXi3 zm=T^UkAtv8(Em8MiPOmggs@Jy=%}_dIv}LPX*+jeC<@{!AZv1C^-;q`A{%#oZgzw~ z`ISc~sHUv{)?e{AfJ1a%Yu_Q|zSek!cCGT|sx}*nOh5=aJcsNi&h5V^(<#vO`I;QN zNl1su&J;Lh2j)5|Q`y>3&v}33iNbl>ZFVloP*ZUB(3oI{i@<9LzKg%O;3!5kpB6^c zCi*z6rguZ}Q_LE>vt0R@$RBCe8V$lUB5Bh)fXc%I<9d!s=I6GyO9{^ca&fIfNP;0NI$^$g+jDhUx=Ed#1|EdO1G;I79kvKUJaJ+yx(Ba(?Z+?nWm4%k{h zPRLk^42bxg1axj*K4;H=PN5yS2pgjAp`^%8vLL1FV0pw>@6uK5#f|7sRET=34{?W% z>yyU8gPO&tw-6`8(-}TH|6-&4fULP?qD6M*lfBgEW~jRI;ux`f9_h$g?P?9e3RQ{# zS3s!0@oW9+iI5ck^3Gv@Y)lYH_ewI=&~_z2J5lxd6Ma+rBi9C8{QgPXmR6zmV@q{) zO1Ha4!Y4_MO|`Hy5io^%(8rV3)#fR{Y_92Gpu>yw(QU$e(M>6VeR{_fs;Mt_Z6GT% zD&%M(L(s)atw%|2kNHX4!UtZ#HK@?(dQof>5bs7K=E7SB3fUxoc`}h&W3!8B)99z} z%lv84M&0pzrgi-p&1S}&#%l%^H?u2uItgZdo~G_&kZZ_&a*EjA+AlNIT^!t6vX9^( zpS?V!9{bJQsg=TB#_K6bvrN0|oY|z@na;f!v2@nkeR%l`xqld9<{ovz>{fL#`Z076 zl>(QJ5srt7!f3~Tm**)QcjVxZ+JB+V3`jhbW58Z z{{t=74+Dn(!ce<=)8h%1Zwq46a>?j{RK<^Kp24>Y>*x=EA6>3my2}E8NNySQvwNE* z$1B@Lw3Ow5NKF>5tjc6VJi8d8uJ^96&-Jl)%l`sO)DPO%2#fX}zjV%lCoU4aF-Wy- z;0RS)Byc)k&!!c{tA3z|?qhau_%=NPk>osAHoiwz2#bX;)2kuwYNEN>_6$o&2bKte zq@(XP_l^61s`N9_xY+QAE1$Z=IMLjW^+ZZ#X_3y*$C$l5t_gey2^bp3)|wbKe0^xq zAGTVl#n`C^3wr;nS)ad@bmHV0q$l%Yy&h6oU z=*O)Dn;$1y9!R}zP1-Mn$*1RedU7pinnP$6a%ar~cTUZ?Cp2;!{{nO?Pc0dlTsao? z(J^9g{)Bok>N8ZopX-TI$QJnvz~254G1;sNo&BSoe=fthR_`?7#+}5g{PZKdK&z1V z$MHn?g`ECSg3>bxBkRo_CG|XMQZeU$OleVjQ0^t%Eb;*U6i$t%Uo>5@mqsWSQYL)P zGgfq!=Dk1o>~)LI<|yw5e|hhq zhVrsPZ3c_G%xy(qP9j009g4@bAcGlR?M&he-F(cddQM+-)n`6s{(N0yZl&>&diRVC zvIy_swd^%5G<&9E9%e7qxk_YzZ5+vevg?e>G6@QJ`SPdNX`_rm8e&Ew#UP`)e_wO# z{2skYak>s=r$j|uQ}(ysYw2I$$7MkS)2Oi<@^5R4eu6zAf$!%k)zGv@-`sE zxqlnXiWY}|Gj5>qWxA^~1xBr(BR;#DXA6`)ROF8b=^Z$DhofGcsefBDaciwDbS1%R zr^0dYp}YER+Jx^6mOAT64ZJW@s{Rh09Hd&gsKFLiV_gH4S%zU;y^_Hjah!6H3H9I(poO3c{^V*Z;ev1@btf z&^YO&YR^*_96(6T178+KUKeHH2@Qsuel=W(xf2p;CQ-1wS~Zu=gFvzk+bl>OJQ+KJ z>bD6^euG3gY^XeA+5liyX_s=6+3hh|vIlp(Xr1Q!XtQU3h6*BgAqB^7DW2uvGq#ArO_ST z+g@lDqC&*tE`>nl8kP)b|3xEv8uQy!L?VNgQA_V=kcU=FIBJhu)-LUen4Ohqx^TZj zpZ5+heI;{$m5-S^b0Hu_e-Pa5G-tp(29`*E%jd9dJQcwFO>pznQ0bc$f3{&5)RShU{V)4m8($>eqU`%+wYUZe&lNJXvSM0Pjs6Yu1V%`(l%9-0{fn^ z7i&E=sw}bnRB*$!BHuAHXp&XaEy2?XH^ z@dxH-38G0z-8jvrWvAmA&`}5PVv}=t+j5y!LA`Xs2@{O>0)LTfT<*ZOUb=Z9B7ooz zSI6iHCA4bfzFGTin-F)4WERjXV3Y2@)j|QuNjao{8gq&OC!0m8T5>=cSujt4r=adH z#4lQZ{Y1?dFXy9%bp^4hStU&2cJ$Q6pea(`)zMIz% zr*;I(7 z{CI(D%(PPM#7>aD`)Lnhj|?CW9vk)*p+GtIWGzdIo(W6sCA;+v{&lDW%Y^ny&(^b> z@U$wj5_$K^I-CGP-wAvuAA#t2TN9#tTWXVZHM@m`6mpTA*)reQN{JGTr?KGL(?u-iPS9ii|2mAnUSLuV!s?nmBIkABgMqYtuE4B&0r-H69;y)sPaWVAaiza3_U-YV)XE zt-kl;P66IaFD;Ub@rf#`kVfGYFcM1~c!xVbYF~FJHD~GSlOMFL-j=!*8s(1>)R`0n z#unY>MktuZ7F51stB}U#VvmY>qFY|UpQ-23QwkebCg{3wFdPE!fAaPF^?h}UB)@2R zs3CEEgZL9%BJsd(kTtv=bJ78S;t|1NP|!Ch*D%E>3%Sp3Iih)V7vV0P)W}Joa+-Uf}`yq`IsEY~4~(v6;GpB>mQfvXmC&-dB8-)AfI0%)t+`Uz<;jdJjVN^;AH{ZH{-#Fn3B}hg~ zFKsb4Ddt|H3hUWBV-Wf-?1#vphE}SWpGHHIR{9pG>MO(yQWxVaaqJgN+Vu z7%cI>%Z`L&y}c2@G+XwPqjIUGFIAvIAPOd~+28>Vi=4!%z@D<_O}f^9@?RxV7tmcla@m4eQ8`4Y*&WOKXeV%Ii5$vs?prHSXXPCzTCErM%Gy_ec}M(U zxEREYAjr85|B6ARQsh&~sQEU}m{6bV1EU-GQD`h+m$Z-uy1jXhriGW{te|z&f1NKe@<^1&? z-&2f{(-c7Dv0AYo~YU5aRQ>l!o9qG zyT5>UDqYxMa`!ub{Tjddb1esaV7+#&4`|)^g~!5w9oQW}$~re9NmFMGrGGwh;Z0}Jw36MrVbu%=6m zf&fa58D76JeoP3B7_|YMQsWPZ;#kK5PZ-ALss>R(3QdfT3TNTj$oK&s%F`PwX4LWz zS#PfibE?Zb;2ied^U{G$l$dV1$mB=hPQ8f zS;TDf7trv%&?-k7DtKPYvKcDDd&i!BJaZ2=$N)g+(D9Be?>V6~Z>q(ruZq4`h@#E1 z%Hb_n?Rg5?%uyy*^1<|YnHhSr2b8q#SuG->+%rsn&t6}x8ng9_(>kyE#F!IoeHco!XZYiZg#awzVmDHfDH=RIT$j%U@TJ zq|Vu+{gw_J6A^%tGz+v?%Nf}$T@yY;Lo@gvi^$ur@@sqEie?m$)l z3`|XIXR{hgs0?~nZ)TJb2Wfusu^W;Ycq8G`0}N2C38G?Wt_^-T)YE%l>WfhOfeiXq zKXYw`9!un&l0L6hiU~l9x;wkntAD%I+3N>?=qr*@|Go!L>Jm4{WR{E3unZ5D?G*sr1TfQEFR#$A?}S5MH+!uP?M` zjTY`6-=s!Tt0~ZDuKF{VK8~i{(j!NT=KopB@;md z!8&9$2OQ1mzl>ra+OR#yt(yUwYI6is6qMbCv4(L)UoE$6c$z|h96ix{bG)S5!ueIy zRDrr}p)(LkBG;4C7AUcoM54_qbVg9>KzVNEv~FG~yW>gZfo7IjmQIv^nc<+%R`F~u zDXZFsLoo~N68-?8K`7{?b>r7F?=ZCHNN-xN$F5F%Ou+-X{!1kaf<6H)#ucfgEn z-kmbEf(vd8@%HapQRAJJXq5<{fO4Cn5e42BXAgz{EfqaghVIR)@vwVs}!r5x%8nvKM3$Gh|GW zH@@i?5Kq(+w)8T>wvj$}R749@(Asoq|1E@IkJm1ZnbwmHl`@upUTfFNC4mCweD9dD?KYcme^rdm5h(GI!3Pb;&MyOxTC`Wt%zuSaCJ4N(D%B zysB$m4^t&`8BST;O3L~k_mbJi(e@O_XNmN)NSWViVW}kyfx+vd8MiB*`rfZa{h6e& z8LY-(-Y0(n-`tUZZ#%NTSlQkhQD^!kuyNM`tow&?751q3-oE=W*<&9v4x_V~6bDjp`J$TNK>Aw_})= z6OXthC6_pghO%B#UAIoM#-BPR%^o>y$AI>w($%Op66XJIkko0>QYCXwa?fHj!D^R5 z#gmxyLi@m#G&A|Uqwk$K(yN{L$#CnENL&6mzp=OG^(b=m}EsM|E~(p`mYJD4dbIhLOKVG zt|2gTNOyN_q%c}U21rPE!|3kr4keWs-60|I^X{CVXDnPb&M{fOR3TsS*e<%2%5PTv z{)3ReGn+GG*eZelwRyhKrl$$zxN+thKY5Z5Bd}tg)kv+Ylql|1eB1@N2 z)3Jts02PZ9ty9%A_g!H-g7+(iAQdQp?4skU#(xnnNfHnOLO2^^+jXDVAjZW-GkbY`B z40VA_gS_}us0Q43U#5WZi6zVZ8stHmNe6giu|?*qJ?an$@@oHfC3NoVfkp<7iR43n z?Ss%)U^qG{O!#_1^=|p6o#Xg2N4q4m+mcj@hR1J$zRko~V_w|Iy<-jU*^G%y9M6(u zym@dK03*9(lOdM(#~Vs+L^ks|u*Uu(1xD;HWPWGRjPr9!<;1Q07K0p(ef@&D{&pe5 zPB}i&reSrK)=QZ|VC#(9vK5LvPzXDJ912_{Q+UR{B*RhVyezZ`CBGhMIW{0On%Zg0 zIW=sXmLiFxW3}MWan^~F ztM*i~Uclk9@}L2w&QP z2bZDly}W7gMF#eS`QBy|w&oOnHjZU+@@IH`1d@QGyQ0%oJwZPL$>7ps{SV+4I2b>j z9Qjs1uL1yU@A?>Hd{u1>DnY||=->a`GM(}!C;<96iKh}9dzvU`b4C3*W|Qrzb$Tis zHriu9JHRWyHh)Pbw?dZk{QjsifQ1M2J!YG_>>w8>$DYKnp4&E~FkV@I`S}T7Av6vt z@VTP%)2rY0byQ&V%WkoC{UU~Oq#H17@-olZ&)CTGzLhQP$+JW^5^vC3y{I=AO;i&i zW%ds)BR>iD@vixfsvBjKXJwidVVs9^EfJ?A1IcplC*YksM#Q-*ks;Uq-u0xHJX<6I zF7-}Z28%oTdhZwY$wO>^l#y47*J8QX%4mFh&au;lJ^M>&SSoXkwqN-iuS{Nn}xn; zIMqTbZ&53RWawGbK9Y~iM59t47y4zz6Cu zirw~y;a0XJk9r2y8|JVf$N{;Dv|77P|Dc?oGQ154O5%Mm26u?A{L{-lv_ag7%K-obikA7>a#G zrp?}fLJm4~!?b0r(^=m)h0LY$jM)TF?5+m0u%Xd^0Bj}B2Wy%@0(MYpkC8%xr%tQ4 zjLiWA&64v=JkSnfK%|p9_>Qd8*LGt+FQbrIM5Ga=OVx}>%Ivjlmo^pqUWx=eq%4>H z`OkWOxZxyUDnw-Adr!zYFo5V&bF@5nd3pHOhuoj9simmepDpNRF5(E&wT3ibhr-uo z<~gu`&*im(^bq@H!1z0TEifDkrCU4}4_pr~Rv=fxKib(hY3w^t1hqBi3ntbpyEtcX zWO}Ar>aq||h!%}YJ{=BNasCbksMCo`{Hj@2mIv9-EHe}xKEKbm}R_<8sj zqDOUSt~Hn^riUQY)#Bd_Hw$9;>&=NxL@r@}Ffmo#zD>ZEZD~zP)75xyy)JVJq*zpm zh7WdJ&v@;lkCL~(sOrKxA?O!rf#ni@<*Zh7>P*KzQ%uWOR=^IK@Mk({GK%H7`z8Ah zTW_&ATun72^wW^{aZPx`C{y^s@TBk?=7iKDiIZ)z0EA-hF=sv-l7JpJj5Tt=Rxg}? zvpcbqm!{#Cia;jGUi)S29!$P10HFtf-Ji6Rh8KI2Qwf}!F$9F^ur;Q$LG=Uc!?ShK zYS!hv5@axkI6{KD1stuT!gvP9w64pZr6?X@hy<~^h!r6?ixgwtv?UbiF7}a!8 z1i2POaR~a#^8NuirtM8o4lVbs8W$aZXF)hA_(mvCR(UANZ0@dC-bp5w6W{!8E;_cR zDh4OcrWBm2k7qoFXB%BTe-aE3J%CcKYtXPriao7mF?m_On>5Z&pDS%Djf~?hRhGmZ z)s-h5hf)PxQ+cWCKvb?YP@Su4Y<)=PSzGdqIL?xK3jJs#8bkJ*_e6ky7x~hEv3Y=R zb=KgO(wFe%D&V!%D|-=c`N@WIbmS$@88rfu+xYJ}pn>MgAba6Q<9-=~@QZporU`B@xBRnDUI^6*}yJx5!FSDC9J9CAN?#?bpUh&^t9Aar&E0O7>% z8g_@OdB~v%5^H|Gsj+mavK93?zN;Ay0Z!VTS!~esZJ6~EufOq?`|~|N?7SvnAVR$C zwoR!jmPvL5&#&=w!U!f9opmUVFo^HFCJ23^)~(|88!`2E%jHO9;4l0#Cf_&+MxJSa z%Zt^(^2J>sLWheuq$CEnaLu;l4*JT zE+1Xiu35m^UZaYJ+7fFFSWt3Ja^T-FqIl1wn|Hrz_Z;#@aoG=?JPpxNa6mjZ-7l@p z%E&aoU?DeLH9Z+cw}a(=RrPUULO|N{ja#GK{p?T|iHJ&RPRVkAJx)9j_V%{eE76VN zqzYzBf+oSqziKcpo#&@Y+pS??pg4kwz*U@hCA)%w^wLA$1X9;?@aattdRXnGGzBLZdnXFrW&ugs(N-+!L+KA$mrL4bvaTlLhe7D}m3^*WCgK65mT z#>73@EK$@?&{hYRIsgjDPFnPbr`csIBdRF4SvtL!W!7bX(5-{!@cK@z!+cG_K##R9 z!V+{VL+CS?^b>4j&7-KYg)#H`i+S(|#kAjhCR93(Mmea zo1BDjW_dDy)?H6Vg++EnR%b#lK`+11#n0zGW)ObAT^)s7{-P*^N zlmLVR0TID%NlNA~k|XRk>4r#WH@s%sv{nrc?)x8qI`#MnFPIB+^vQTyM!bI}k&NGG zOCzl4Ma`4MSQyp1Xu$+Kq99!VK@1<)v4N5FgmnaW8^iQUu*>Lpkl=x3ZuGuMKPwam z+}lb~&@jf57gDW~@lIIYP$5$>cGBx26kc~k(xy%>efe}qE2N|r$ze>jYIqC`WdpHj zvxjkiOd2cf{{?cYAU95__3^#f_yW}(H&;>!r{frqHUfvL?o1rvy-tS%On!Jo z$j_$8-4?$?d5ko@vFj~8>yd-^&anYX^gee3hCcpge&(=Rh?=H)$obf!<8^L^lSXpt zP`Rq=X7^Xp^PpLv=4;(+_i;Do?d`oGN%lK;r72{6)~8vo3S@O@*#kiJv2idN8^kc=YN?A)Gm5&X;|O$ zZ*=ob1KZ+?$RY=b@RgYj+ci-G*42K0$tX3E{=8!yJT!^9<@0yc4(WxuHRCNOD8=D2 zJ5Jp!W^2W4i7BszZr2WYe486MVXY8or!Y!u&~aKt;1h}Nco@*v5>sQQzB*Ft5;SaE zm|SJnrR}PPO!MNzt-B5gT(#L>G1W(3r&uMm{n}AAxo6-83F6!Dbn$75)I>jj31I?> z$Yy@-I-%qiJ>yp5`H;ez9FOT!>OFEDs%n_VB~rktx;3>Qbtxn8Z#~s@-=RByO4@wg z`06S7;Xgq2Z1=I)?%q>$cgc4#W;f`ZsBOBJ#Xmrqr=@8SMSfw@k#%e`DXf@Gl?8j3 zAig?8t!xG`8t#F=>R{0a9NZv(ppt!V!k#Wd0{=+o4O<0naC~n0dGD$fI5!IYVR(?r zF}c4b-Npk}_$ zDtV66L=V1OQv>xDC`u%xyw-yeQuMRxFEu#v5`Yy!**_SUeHFREXJGyl#%096jV2&b45zqGNXHwQ;6z=~Pb>^e_f z9?kGf89@5tOwBC=c!`EQ!(^T6d10Y5H45(eMX=C-nfI9c<{3T zgc0s0j#)zVPw#cg@RgP);^yFA^!8rUU$)e)3Q1C6Y)5`-iTV?N;5dVi5xOX5{)G51 z7b2YDi0xL6NNINLA)2i_y(3^)A z~~IxcdXj`N1Wj;g=l>Fi}Aym-oSUaZA8xjUxq_X#U9+Xi;-d)-F^i(7GCHubxa zdxIhvkMCAjOEsZ?M9&LwUAl8*+Q$@k+Qq>~j>RfTX;*SQA4;fa$?Of3*+4FMCyFT8 z+gwJ9zKU z*R>N+h4#{$M_$Qs=tjYh*6nKlBobH~YI$sRz_qVtOq=tEnoCJ0y0AbrGcKPK zw`=P@^5FV^@w!hW?n}(u!S^OLRM}uG&S5sAK_Qtiyz=0lA&Vc%a%519h&h-r_pHfA z@>(s(0MWx^(|OQ-?cIvIi~XXuWpJHiH{<1OH>-5d*Cb6q764$Su9bb_nB53)WPQq* zdYwm~PRyVZUftz(yVcH{%UQMDR~h)pG20I3_sbW5noCLGO_Ge)dkra>{{X|NyvQWh zyaDyw3UInNIopHV?j~p-6-A!TeLLo~+Z8}d#{OGk{de^NgPa7+5tVLtE*@wKrlO`w zV^%AYC~rt+hmia|Y0##3PNiw7(Yx|nYoJ0!;?kp6tV#*~yRlS0=t0)LIOxep{V@Ec)&>kB%TRf=RYLb1GIFUjgm4DU* zSm`LkvEKGj$cZs{R-FBAqi`IrXvP zPdWW)Mjo1mkIIg{gvy(M^-5lUGjd!$&4EdOixDRfu?PLjBP=LX*ElP+eUbP&Twto1 zf`KZDQm@7{+MMQ@WuCHo5MzreEj6A1^X;+;yAgI^K}8iy z=7A;yLzuy_>7G;tS7Xt8n?y3UU6QbCxh_|Sb8`DVMD2F|7<$_<+`|pXVv#A{yF&AS ztEQ8eO4?$^1G@u$I0{M^kteWd@-%r_%s@@ay6N^uof4A6aeLOK&Ctw2A+7(b3#%O) zN%otyakWzGDahHJRck<=NobPu#cdbtu>*HM4uEt_Tub3r&ppiAx)K+^viqG$^x!fd zPKd)!(&2c-Z!5(C?k%fb(HZYt_0Pk9AW1ccOdHJ*1}t2FmjLTqvv-|(2qFR1HX8A- zmkcF7-Rkk{O{R`^+ER%#MgIWssb)k5X_y%6Tvpv{yTaa_%;T!)FQj)=9FHh2$?NS# zr-ge|a_*BiDJ9bK^R@UvxxsYWrms`Ee*5)OnLW}5W9xw;O6RssURsb+^#rrJg6-uF)I@H1N{WRPA zPU|7Jl`_abz?H=$J44Dl!}pQ4Isbh-k>%6x|2pyw>tRiS#g8TIju zpB>;5)s8I6UnV>nM1n}-a48Re%wPPf)BjIQk;3su%ANiz4yZQAx@7JW>fb6De7hLZ zl(>e57i27@TXR!7!E z8;{GsQU?)`6TBNut~)i*-1Sce92?NKNyWb1esC8toEEx%!CV1{d(DH;6Ia%JzZdzL zlDEp(-R0?U@_&|r%+FU92OX}oG?{?OaLy4O|~7O0we+$Y$KF&_s1$hcqEj;GKbtkf z$b#a3Qa&m2Fc^hW$D;Vb%xe|GnEm}Nv!ErT}_f<5SAm+YR#TZ8~-Nx?K^kr4+>IwtaCBRP4Jdt zF4vb?{q=WaOiDPy>_PQbI+}BbO5>ZWAJZu?eI$k@hW_O?@l;gVjAKQECa(%#q>mAC zTax1%Upvz?l@o8WyiYJD`Lo+bxkMq$-=4*w{ecBl^Fz#kim|l(C)QJatpVUGi?pz; zpQL6X@Q221t__M$frj56Mj2vBerI=H)u<-V#E?#dw(e_ZRs6H@BJ#!NExdRg8(kZ3 zsy8_AK~iB5PHF}}r+jJ*x$Wx^Z$(rt_R+klW^JNEor3-k6Ya*gZ?U|*6uuxR8B|1G zaIL&GeVayqv~?9qrO?Hqnlw?i7DY^F{!_Ba^IOI6G=#QoPu(af zo>u}l<)M~UIvdgUDrr?eZoP+rj%4FaeOAa45wMBz@9&1kC?&-(YFBx9myu47u=x8gm9pWnkbiQ~lb1$%>4cj0S;fdu=z2+)%&(9Gmq- z@gJbp5HN0{^@BJEF}_$zXK?nZdFlu0@zR##^Xh@jZI!|6W0 zg;Sx5DF16gY)>ZRVAE-F?jwm6=_<F)-Ga?)afq5a+1(isxSx=Tf$ z{rO0SZ@fKz@}=H;y|s!u$TZ6Cv*E>3)ZuiB_861OD_3+Q_DkINOoq?Y(lFD1)BgaO z8^iHcj(<2?TS?;ruNrQL>d@rs&ulkxdIE)xO*mVheg=kZC+|MQz%J3)1`B>odf<`i zOG*M}=Xa+{lLk~t5a#4A>Z|I2SB9PO@BYhi7SXR2@z>>ijXgYX-^Q~OC*K)gq*BSC zC#|UX!II@~#I{C8BmCnvbXD|!;HM;4ODH<7F>BH%&x20B7?Oo-osq3cl?jS{Lcd6%)CR9+Bt09`yFl}DID(caj9#G;@WEjpv#FnQ2l(O zHoJ|w2xD^hX3K5_1nZ66DfK6F>dc~?h!q2WK{CNaNpSW9pK&!2mU!A@6~m^B`5FVz zlEX(_*T7P=0Dv$1cDt*83^f=fDB>0@h zU1+p|6N?#(Xc>^moa`D_0GxBeK-_@4q( zt0;a*iY$jY#b&-tBQlK2d?RR#+3jruloHaORU7=yNRDv2q(ir>VJ<5uOilb*2($TR znq%wt*syv5sZU6`bxBK{HOU(1F8lBwSn1knrbki}Ua;`1mqZmRS?LZ9G`7` z9%gy|*0kYII9rPPwtUmAK__JT8Q4B8@7I89{cuLc%()ihCU5Vo9ie(JJG=s3d?DK& zLHorB7lDFE@|ZU>Vg+dL zhkU52OCP13+!mANPdxGlC#8bkEOp2W`~%1E#Sj6V_pal&t)r*wyoyq&6^fK+U`!diG8#Z)W1yUXa zPY%Ai8?{Y?(Md^egT~vnJpjz>H85^n!*Y0CnRGdqCthavPgtC+Xh*aF> z!&O5_Gc>8s$^Pe{uMq%OLK09$*}UPZ80&reBR-42*=wZ@X@3zgPu<#Na0? zGav14KjlgoUr}^V2@3Ff4LTpv@;h_?`ly1Vv`uH~r|Ny5XRoY1H0f_@lBuZ>xq(Z3 ztXPD9go5*uN#>)W{{SaAAk0SJvmmz%UGHg*@qH$$wUz;nbPWnmw+df}63h&F^618h z$(Yn38lmY-RsQh*CxkgHoMg}M;ZZ!`gtk4us_J51C}oPS!|QW4c)T`;OO@A=%5*A!W*Yj+<8G4j+*hnnsa-}ha;1sC6v@eg zjW?9=d_bb~t{udMV?4O}(tP9vR)W&uQqi({9z;>uuRBXfibqCyRDq6{HI<)+GJH!B zJu#j|SR*HyMz6}TR|O;Sb|#cu^;s$ieWLY|9h;6+D6YaZiSXOGgfQL@qkjM$QF4fX z&7#BIV$I57Vw;10Tn&l(D0#Df!h>6v^I8CMmsr4JjaLKt!cCJi6|RiD`B5%O7}CW= zl|DJnTiaXrrUk4Mon!spwTjpP(f&Mrz`_7nFdpqJ&f{?iFWS4HUDkOP! zIxkPIgA{})2$a9NL-Hduup#7K=kJY8uQsxs+r(TtEK)3bD3P3Q<@p39TY!w#3JzNf zF*Wnp#pP?$03zY;tldCUFJX}>Rs&~qGyDm@n?1b8#I>lIbO>Fs7Qs^2x4OxH$;g-Q zDBZ=&p;ivqgl9k9NKyMq%p>^UO%qKHh;=F&tN80^EhfNNYGcE>UHxte?!exgC2?N? z-xP)LY}iY3^+S_nofpyyz31$B>>W~#$=81C?uKtgToHqN@+UJ?O{^8h?8p(~6G0LE zq#tVx?FNQ##y8>Fef858MK67S*IN6U*s<;`(LN+gHGfMCemNmB>HX zZ%XgR%esYa8zi^@F!VJZCHE%~f^Rt&$=j(*5Ol zS161UDHWOd2K-L0r7SZ|G15z7C>oNccUqUp%mSoD;zn{Y$UdomNGu=eXHYt=dSZnH zLtculA(rds>@p@Ob+4r73Kl~85Nc%wILrFsmP%Slrpe7A`DSl|&CF%u_s5kUnT<-+ zIpTSr!{lQPyhYFLyi zGqlH|#yKYRCqz3FMW}aW8KIjJfbnu}C%+Xpx;@anAo%S3Lh=Xo5<^AqY#QU!xwyiu zGR`~>#C7ckfuKTrpiK)-u?prFF4bjzdHy~Mha57kL3ZtbGd#~ufbQFj<~>A#_T%;fLiMmWx+ljZf0EC`;*7T!f!v_v_`rd_n+2_E^ z8D!v5rNDK6lScF|3(q^g4Ac9hcc8HL^aQN4eO38IK@oNk*^u;5O&!WPT~@Ld4o-)V zG_c%Gxb;6Dh7y6w9V>2ESEWBWS+a4Q@dtUr>m9%TCk<$1XiBE3WgbDi%qu3IhVn=K zI`lul4c3>>O?>eTWSo=9QU3rEjoR0_Sk=zDxUQOiFWXg!DaFzQR~fUy6=T#&J&!fc zbUMhz@!2t^Y%F$h=puD%YqhllDM_?dmzYfyG$~GS3lXLxM5BWto}zl|cf@rpznI*SGVb zD5;iz=g0budH(G9VC(47Vl=)h9sOZ)xZRJY@&>xvOPLs*KIZO*)iq!rx43Q#+$}rk zW!x^k-rNtkTvKAkG_C9on_4_~>rI#}w|cbnA`$S-de7=&{je8Z+_A1y<^DA41l=l8 zk%X?`h(8?Q7yB!r;~JO(Krzp6#JADikx#eN&Z%%fO2Ov!!Ik z3^wzyyryZqf78VG094SolMOl|kAng>B)C3%W-%4hINm9}4C|@$J^^d;kZTR}tWOnx ze;AEw>)Yv~aEmaYOv%`+^8W;^+^Zw{AkJrcKqVIvXIk?BVu#Yi73~X{R5ua|iwkK# z!Ht^{ecr0XeC)={Ci#w=4n8Nk7u=hXJl=h~eB78^z+=E#+!9=(I<>=Tc1>~% z_Qr@2PhcB)r--OAd`5vXYAY(}$RZYOy~}wzG~D#84oWpSHm#7`sQm|`tEM5-ndC*r zM-`_H%slHIno6bP%|%3}fe~t*P4^-*^jLeiKGwC6_#~Yu@pLf%*cEaTD}^V2vt94~ zW+8ODL$s}{Gy%6F+ZHp4NF1_0kv|Me<*?(rNy!q2wE}G%v|x+)A1P?+w>5!SNp`4N8!ri9#Q@3`LJgDbddFiJ!r=@e+88s)4Zs zz&Zqos0BHE7baOlW{ku6S0sGlpC9+&++j&b*e{;T& z;r?0kZ0u|MP4znzkzZXP#en4EjPw7o+02Zz1L1%svY5p*L4+WN;;SDczSHcu08NRf zD{H1~wWqQpPnRGyuKYRysff1%931qT;YtK^iZcQ+zA|0BezBp(ICEzw1EV^od&bgi>A zgEPwleXCAEwCVk_L@e*~BWWHz6go1M+&?1D?|nHDa4tX?0(PK%;E$Dxf0T*j#*Y~> zG{ZLw#x0kqKS7glzp|?vIJQ+sp&e4V06NzuOjH7q52}-WlGjxwcR0nInWjlWs?uv- zeMw5%&UX54vk4>fqKTsbS-kq|7Q2k^iY&Jt`fDL6P&M!d_LB$R?asn>xm_Kd$CZ=b zuuGY@HO~SUYTJi7EYHk-f0(t|{g=83b`Lsb6*OlFXeSpe4oLRx1N3b-oA}W7W@^to z*5UYV_vvIx&t@lb+>C(RQ2ST9Jr@->4wU*^PNVY4^*I%Pq*&cweEwbC*}I=Z1@T~E zG#v>gji=wG%;jF(R~>q4(}yGE?R|On&87hLVZf=4VV}5XX2p%gf0-+JEOPnlD*o=} zw33Y+RtbL}wSoVgCYPmdGS$aLB9-*jy|2sFb$}d{>kyt>_MVzloKy1Z5Pf^L)?#OX zsfm*<-*cCf15$^~bKlo8c(&bbsJ%0dq0jqf%!$g_Zj|KmD`1~&T$Z(h}2it;*DW#e`+855~^28|XrF+4tXjt0#W^K%s7woK$jbS)^$AzzItk2Z?aYAhsy&8g+tSHZ@Mg_v0e-+=&5-I zhr-3pZnDWae=S%B_{HNUk;Tp1S#H@9FuVlEf`Z7+S_jI+E8!r1Lo#P-vUh|}>YhFZ zZp{p4_$^N*R5~%I-*qLLuKC4jVnqDfx{I!xY{q+eAY3EseEDGAsjt{Chf_1^`DOAp ze=YhikH~9jKlR7^xW*kFIm_|Yy7r?Gp!|Y!KoZBTf9bXYp`;-8f|Yr)P9y4)qZlrW z-zgpelhNULt3IJ+ZWyIW`0^l)b3bE(-J*T1ql0u9YQMKOR$QLTMw2$p#nX~ZbraH8 zxP^T-*rt;VQx`gQS&({efX4o4vsYTY`ihzXIT`?;T`kgcnx~q60Sa7(Z$)tQtyI?z z-D5lOf26@>SqcxLTl*twOuTpR{Hiof;o=P{>L}-G0dzn)4%p)Ix zf8Xi_q+lKs8g#wqK|GZ4VWD}YF^Ij=UtM7Iq1~jjlFs(WsZ>jnMFFOL<{neNy^?1t z$=SmRK?uln#-%K`pxTRVC=m6`*N=LK>@^Z9f7)V8Dp^*DoafskJX)=rZ)>}cPD-&} zTR2l83&3=o=QTuOyqG0X5ZAxMePDwmA!8FA7)%O0Dyn|7N6qNF0x1!sDl z1Q2X?U(dhgx2+Hv{oB;nEADC?*Yg}xLG7OhtlS>AE+fD2ROyCPpl05NF;lROE??x0 ze?Tu?cR!w0A%c<9Y_ElGQcC3c1A|CP+14g>uWN3)=Gk%Z<*HYKz>bN8K2|o8MfNEM zOlgBAw!%dXEtK_*d4!_uWEZ(N@bVdTdeJAJuJR3s^S}DXs3aPS3m64^3&fvyfBD#E!U{Zhfy4Ey$Z8lkezaC4E_`{s66)wJ z3^Zh)fN1imeQeQxVn!AaK{%YQ@i~-#5d1R1uHYZQxxTTBM;Tm69==kXkV~Eh3BU%l zF)|OhjXC28O)21Fi-)!~EK^fuQh2zo0p}FRxIY(1B#Fnf0|Efz^$zCc-V?c!e}=R* z{xyGh2ZbMocG724)>}J`hG;)y_RwkDHxjLp)Klf}e?tq}ekJ(N zSgR>**C#(063|qxj7mM#9QQAr#C=;T6b>Vv2NRkFZXD}$Ji*18q8x~qHML$AY?!BQ z2Q(ym-W#qt3F~q$J@p&V71{NQfNh-``~ys(LdPeKx$vleEERtbmwXe`dAmqv|4SwA%^U>#N5+1=X{Zk=;Mc4@1TW4>bK zJnGVPbu~0PgIfyEe>Yj@YN^;YB3%=C&s1uJ16Y*F!&e`xiy6T<;|e=d>(!4YCrCl^ zq?ZlcKAK!-cF zE$CC!@OF7*X8$4X6*pFyGw>5FnE86GWooe)gO_#suPnoYDDVUxN#vK+sO@f|=WCmKb3vkMQRNNHM#aFQ} zLcNI{u=%eE6z*Q~2bq+Fc%3k$dqv>Z7$q!6f9i1Oju5AH@c{0TNNU;kV+fV-hXka+0EIO@zi%j)0hPnM$L$06n ze%|j0bJi^*wr_!(S-h6`H@;>J6?7KgvCjC_Txc-84`cHyu_#N}ph%l8epXyz!UO_mA zbw&!#%&QG~IKnwU4X?M=Bcuo<2q{U@WOh?=71TJ%9~Q^20~OLW+tQr4uSILU0c0AY zH1siFlQg*qa5VQ1SE^(Ap ze}>lv^q8>~#_>PBlTjaH)M zPd%HcS1|~TC*1=zRFn8eq)!H-mEV3cv^C4n z+qk3KfF{S+dCz`TGm^`OPl=rIf2o7_QHtD_b*)G@3=Jl<-FMwyauxF*?hUttI zXPC9e3S!CL8dRAjG7%QsG+-kUH14(IN$&Ezu*rdq}*;ioF%J3+H2;J{cEnvnVzE}iu50#jwKYHg&)4p zJrWXac$@-zt542jdG-zdMVcW~i^S7~_)wLWXcC~KmaQjVL7I#4e^O|}wsrH>#{r38 zDblT|vX+(PfZIXjJO+sR{E?Y%Vw*u8EiS`(&c$T>=Ay670SMc{3oQTTW7J1*yVPu_ zJXu9#v1*e=iPj+B@HD6pfwvM=d;9=B996S8u3xUN-!3I54$la~tLxO-|BIza?U;(C zGNd0~ten^#ce>U%fBp`Ggu2kL+gv-ap^VsEGS0^Y+)VW4udBx^^br`4Uf&u?`}H@e<3&pd)c@5g7vil@$4tM zJiLzCY}TpompZZwOGN|b`>gUzb^!ZnugS`=ANa?5IfNC_ibE#6w_fxlUrz0t`3K~! z0`|t~Y2~rq&5V;#>umlwRZW{6{f=Y-Kt-vMwDX&M|JRz%nUp>#+VVom$!8pAFOADY z&}4aZ%=$~sfB6L5Q4(pS31Zy=;Yf7b^mR4XLHqjqkT(r~%I)<*kz~#-T5{Z&C-id? zN(WU*%859>&Zh3}IK0@a=L!`B73g#?>?N%Ci0w`{#2emJDULufTXM(5v7(m;1w(Wq zYM~g7o{{`H)gFeh_BPEvGqF7SgRgtimg8B{*FQ<}f4E1b?{2?-XNo7qn=l^`bS)fc z-cxpKY1~o4KpZH?W2U&TCfR2aAmj%YqGUntk~bE>s%(;IcIoSe$T$cNRYk{&Zw*t& zF-bVg)AgZ2B=a{gK5e_^7=B3dz&F{G;Kv;o`VtunNaHlT&Svl`jQYS#=V#`&0)0!X zBht!(f6~_VqOvtf0ieCNiuoIC@p9PY8@A0$yDP3~qib!}~*QQ|COwf0?d z7d3sEgvFR!rHX4cxl#Syt=@zVX9|mXmeC@Dpi`s&L$yy}Z-jDh1Xh2(T(S}przzEp`Lh1^K04;e1k>OIY~+1Dj?Zdc=DR3iY+Mvp>9hS`5KBDCd*546tYw(APQqX;zpAL}deASMXdCp$@hUasigv43rZ1_8 zf9tyHOxn>&4{KZm0r@k=Yn0Jq%6wJT62IZBMCNC**>(Pmy(!l9`7;rf=ZVQKEy+agzp#J)2_}oC_i5}Y&qEmtE zlP@((8wXge!sBImDnoqysDgw@@cM`Pf38BDXkH#$SWk}M_(PVjjYfWM)8bLfql+Ud*2x^aP6zd35Rgo&y$Tv-4sQ;i;>_c=#?~cC(efy34VAXsD-OV( z3(s-cbo&l0^q!ZqA?co9Y93|qe|kp#L~p9Db%Mh?TQTDW*|J(8P5}fKv)RDg?>#S) zxGVJHb*x)j28z?(;?fwuaz76vyPnN)Y;0qL4^ze`YVEx|GZO{2m%LJ29(O6pkU??> zP*QAsFnEwk{p@BUE-}|f4*y7)N~pa zmV42Y*h4dM;3br`H+<^N-zAZGNF)HK#S<>Jz@b2ya=|Ly9k-u8fi2<}zG!^ax1Vi+ z$q;;Ymtm%ASNP{)%2zOD#rf+k#(_m!Bc91fR_78>*iyFXE?PCZpU8+!@BG#H)|y%Y zM09?3Z@gATHAcm`kuDj?f7l)SU%=JK;W#}u`pP;vniRX5AkyZ4f$>H0d6->?BcWuc z=AY-P7SI<8CGJD>Q;DZ0SUM~Tn$K3@t(u(!cU&gdK~!nsX*YR;MS;dTN3=*RLXy9N zyxXo>kQq%#OPaAf4?Mq;a()Yz`jptruMFQmdr@94r9>(UBh@bTf7i_I8iJPifUVJE zQ5ipDzmV}-{n&i2xwMd?KwS3iqRUZ6@&>>n&;#CiZ5Q?OD{1(#T5}AH)XMjPzqqg= zofA7|a|QDC5|H*hq^s6~Ja|h(1h!e5{^m692;0VfSr7Zs~@)oU>U_GY=m;rMEN;Ur4V%`_TtY$hO{z?FRU z_Hjkke>gIY)n!G;xB5@ziyUxi+=6S9mYy(r4phASt9-c&UlGD#9hm6Xa3#9Ct1uc1 z80oPlZ18;}0&d0rn+We%z z`?vjXl!Sq$e}U)rZPamO77CnA;1F&U``Z)+oxy?Q4by%-ZkD1GmS+TM$wUlK54&g& z^-du0o7t6DZr$R)=zwichTVb!W%=uQ(e0XB?7r9a{>Hg?NTA8JTFk562pmG(M1|F0 zDb)fOij6-eb5AC)v8Y}M?3*2rJ#OJ*IXG@6`d6u$e+#gpWSK=*1k8NmR#hJuKM{%c75cVBtH$GA(0>5(#bQ#Yj?*lo)DrKY+GFl_VicwfEVN0V7?P@c^PV;plU@bDu%Jr41f&^r#CpA#tklyIx(DmY}22s zECQ@1Td72{$`9&6g^^ql#N;;{ravDGJ3xr)$3w<5({F7vm{g`1Qn_o3!jIsJOUA8y zf9W;op}*+h9V2d$x6}l?ouxHff;hpD)Dwp)aVK?f+%&k2Qk?Cb97S&ip4VShTbgDV z!W-9;UN@Ziz0qq3z~7Y>yUBP$X8R>}<8NOfk(q>=2{4iKmr%Z#*y!@xpGjwHfPFB z4}0cwu@BEw(w})StHT*m0?1?7zj@L9FhA>&LE9C*eE#Z5T|973r#~n7&NP(Nf=3jk zZ3#GZUP{}~et{HifB!@MXtLR9OTj3<>*VJj1}B`+>}OwA%~-9b06^qGs-Y~ue+h(( zj7>DyqSW$w9vq|EyX5KS=r#h?!KWF(L+lkh3+(eA5go&U1pl=hM!|&hO?~9^0uOn> zack%AW3B9P@9cNU!;dZ!GdLNd!E}aI+`||Z+HS@m#%>VCyl2a40lzJe2P@7Nx{RgC57te@N$c;?c!SUf8Ey#jv_D3xr7a?0AO!s_lrJURkP{=SFB)P9#_P8g7x z^5eSkTU%eNwl&rZPg4%G8gGQ)#b)LNTf8vg64=(%Aj5Dps-?Qg$bU5Pe~6yoqZzNI zVQR0y+lViu(#t33J)8=3#-dBfBaNDPAHOg^U!Jjjw}DZRNu{ZoF*Du}7Th>(?mB** ztpOl@&NNVGk^YqJ(5$ITOY}G3^S~+3{bjSxL%W5X$qaLG89~;TGTri_S>-g(S#YPh zxJH$e7U#e#tNRn_3DLA%f5K|}6=rr6&SoCmn10ueMH6B*9v95tG)^A2IPpV$?B&{o z_4ZzqS%=--f{2iHNLO`_NhbDaX|vuygWT$avEa_~c$xG^HuoRg)tMU4UzWa$1R$`d zhdlWuj|cP=y>$6#ADZ-6{{c9O_u`B0<$T~RL($W08O9;AKII{Ff7fb8QD>uM>kYdj z7_HII`GwH_*`9olcuhKQfLy9MwXvoyrsq{8h#~wYksf!aW&riB+L4`@o9kXFf8oCx-=+>SA88#uI~-dEFJBB@f}hya@crhC5sN+ontWnw~!U zqhQm6Z_UX~D+rF&GhDG-k*#tN#(sC@SGhU?dOa{cC)h-Fe>0m2ZSlI($@^QM&*@(( z#C(#)^-&jw-GA=Zub2_zFr3h9f$^GTFv5GH9i++oz9)^zUA5n)hLdeHTQ2j^R40*_ zVHMBIrG{ETeT!tr@YEEx;DVKj+UC7&w%gBEK(UpBw5U6iIO2ho+@T5Lb|g#$0W3~M zM=R)EM-2^2f8!=*XbJ)qH(9IDoKUnZPQS zo}QCrV={uHt=)$eD3L6zw6zNJC?Q3jLkClGMgK;eWwv9pt^nV8c3>)zZ;%mQJY5IJ zQiFd>a{#3XC(R^la*?eLFhP1w)xIva%%SWZe}?Y8@}$w z=NZr7jxka?eI0h$IMS^0HP_Hn`rWI4fREV&p`=RuXW&lOKD{;GxjAf5vp z2V(A8S5)`%=Yc3saLz^6B&$Kw_4t0{UJuBL@2_AO6u!UdDzBF#l0r#JwuP&}{sQAh ze_0Gmnco_P&ZWR;(w0MFS}Mpd>2oMO%Vg_UaWkQs<0L9Ss2SenIg*auJ-FSLwzw`T z?`Z#7b$vmV6c@%f)^~!`QxFtXiz$1*fI)IGWj=ZtYiFx%WWKr;Fa>=g2f{RCnWI?& z=@62;Q~}1W4x}z{n@q z_11I0kBk)Z?CamfUbEF2RqzTh03@mF0C7$}7gWoes1MrpkyE$K8ydOGXg$;0zGl>|?8p4Mn_e?8#C zJkik=J583$qfZE#aODH-Rxw0j!|5MW9>r(_05HhmQ22nr8V^V(Lgx)_<0-Vb4MI%c zBV8(UoE(~$gd=P07rn1PMn^8R^iXR)4(!9>>-^5E!|2DRPQ-PtA+n7pcg$B_Y)le-`yjt(94+;KXso#~Gcwx!9Ae-`Thf&= zuRvF%e_}Xync1`H)%#B?-gOUGEZ{-49(9L7MgdJ(_js}yZAdT zN5-aQ%8wz6C6cFTCVnJ0qC*e`eIXkMf^!<)ilvR?Jqw zU`;+NBM)4B+J^p-JG4oha<#M64Nc3mR7k0BSe9IuNzqYI`yyw`7y1lQ_!`Uy=H+=Cov&)?k#y4tef2#ZAeL0P?xS4t;kx*rAh!hd&wH4;y zeWlITG_aOvYG0IaK~I|Cclv)0_x?m8l zLi2}51UAdfI$_I=8d70GttE;&dFpYYY`D5*MFbJ`T0>e-X{I@GNeS{Bmftbhr;=(Q zKyxUa3vH8LZ2VXcPc=fmGF0j{jl}Tobk~%872P5zjgs=|jRen!CV7=Y6vICNwb1>w z<`}!pzyf^v3LVQ4=0T6+rTRcZf2kNjLC1Jq^QZAEQVRFE$HCD}$*;dU?O$J}j988F zQBZmJ7%?MOc#;<`elq_sxJyyJApVXr0qD!y%bLn9Kve=}oMt683S zyTKo}<)t%AfN{y4xF18Pk1nx@VtUwdA3G^>acvgf85J(bv~ive{sUA!f$yim+)0jn zkM%i}QNmsV>P9$eQkjH|IHB-4zIO+jC$yjM8G{*8g4%Y&16e;$#gE^g77|^u)rw%Z zSdg>>sO(-nli@!NXx7=)e?XduE-sIhSY1x1AqczAd>Rg1Gk|e38K}YTB5Biha?q{@ zk56-LXUHCk8-0gp$TD9#(D<5+ZqHZ_41zVoT>IHK>yd?24C45Nk2`RQ#gu?_l6ZFe zm8JcX_uLLil6A>$5z{|e*~8sFXJcPgeE5nKO2UYXbv*#%NjJJ}e?K;Mq^N^93ByP| zm+hS5*vF{H9%&GL2a`O!D<`fStxq2JnRQj?*-0oBG_W~7G~c#zoC}g~Ev|W5UD{=` z>~|gBuD)AY2e-o_bXrRT+IwtG4RWg+p;P^_V3Ky_I7(k~zgl&f zIJt!|e$W%Psjb-PfABv)v`*uJ>hI4Mt*F>fXWipJy->%|My=f~6*Gj9$V^SG^!${&ML801 z@!A1|xYuPpZNQCUbi#x(*Iz5jv_nByjMyzZ1D1qIaXd^&f0Cz+rs^}XL5{?R8%;`j zd4hBeVn046X~})@NPeWRFe92wM@Fc)vtpMdC?2SLh;S##->BqHkpIB@JYeWd1-_J$ z#hsYYUX>Dj+5SwC*n=+G!Wi|G+?Wsg$JbU(5*+fuLV}LtcSF^8qzbN$pl@;3NkPl} z+FdGz*XvH^e+Gd#>U6M$^IPA_-K2!PMEU{RB;`CbPF7h7GmQi*T_($A*>mZc$Ps^x z9|p^8yK_B38;9+VK!vhJ7{+t*q+)jrdQ905I5trl86#+mj=oaZ{Kg`vV&>TG}y#;5u?lv3F$e|bWN`YS3!2y6x1Ycav@QXZO7 z-8rpahekQcl$EL9{g~c$b{60GH3WJ~=Qbo|ZgB)uz>FW;u~aL{e`p&u>j~N&HaYt< zQB0iU2bwlW&4caQ{Z`EyjMo?d!wP(aXXZ-jibWp&f6W|YRQJ=0D2bboSI1B>n)@|3 z6gWfhe>c3TxN1sI=f~ZQY&AIKH-gK5sT!u3W0U==wUs70NrOmb>zN1h74T;fkY7ql z`^6ew3d?Pe;c=1j4PhkWs2_cc^OC>{=h)I?wxmh^g~qFYud7X$6!y+jB$;`?m%~R& z0p=?C3D|8GbMpo*8djGea&zy^BsWkPTV!zHf3aC5=8~TACI!Nm+;!5ikwEk|lRUZsC4cd*9Xq-(KY ze@nT=OKS6Q()cy4&7Q!m#oaP8sWC37F)*(D-!6#LA|j=@2R z(E6x2Y?2^VokI0$>fi;`$Qtu`s=(|Ke|NrjgmiPoj#86{2Q-nC0H5)a!D0BU_Od7^ zkV|d^-H#$k^r=xmvSF05W++VMpb-{;ZB1}~-6yMdG%ui+;OnaJ0+$1^Y0VE9B|ZY{ z{BFSAhE4>9iQ^2?#ko1mDDvunFh3t@4j}SZT2=dOvfYP4?BV~QKy+8o6e7`pf2Wjx z*%R|?ZjHViIp*-M6fm@%DsF2OYWib7McM zJQ?3sV)Jk6-$Qfv3aM2dg7}Kuf4Ac~XJp~}0FxY-R9Lbbax1a5BBf!o#8#K6 zI4r0=Y4;htH`tqV8%vtY4H`brOU%%Jt|Vb;y54-{Vt?v1Ai45_5yC=}o`ngs ztq7usT6cmFanC> zP&|u|nJsCmZiJGC)NwO&P^xoYslG18l_AS#Aa?8pahGaQe|qQ9jk!2avzO36c5_30 z1Ewv@BphGfb_5^6l{YPSf46I&ntzB<8w?z<$%1?WR=P0XxRsCz$PfuD3LTo0Rg>6j zvN1{g10>8|U3e!Ayc=0R)L46&=B!xyY=xS=Fl;c-Ya5$|SaOS$yoMY#L}+64%q6x%J?iBo5Ezd#SqALdQtCYf zR+#GZ@d11P47-eDk6IRmQ6fw(VQP`m8l1|X)5Wtzf2%QV1sz6xG4(lskqbgNov@4l zY`G?Mv+;zi#4G*nH4S{-pyZ_@H_o5!Y*}D9PdZjy$6E3?@4KW=grBeKU$0C$(hrO# z{_*t*HN#hl!n)$vUA6BH2T8h?ED5L)&69ImET5_gxfd%8f-VU9eJT=Fu*2Ixf8V7z zD}y^Ge`T6pKW&nvg^mE;Q^wtz_|8KVd3ZU$xR7j?krhYxz$q;0H(s1Vx(> z$Kg@~Ujz~@tW+e)I_vZp=9rF7@(M$(UFFI3VF0qF9@M-T*hKESO$-gZi3AlCohI9V zd?uO_fFXCGxH%?nvRswM*g@ z;H9jwz7H1vDVGq}OFOP^uRJ3ct;7%V9_2VWBP40^d}`%z9%8Bd*v#elu&(gHeLs ze}-OhXi0J2;&9<8jXVUJ{)9StaUIxC z02M-7U5v1%X-6d57=Kq^cp&FF@DJ6Ot4Q&U^cg7Ge=(ZXrUdL~;@?LnpTw$zML`!N z1>fl#>@)2&*)04^w%dGzvCaF~Rd8ske;iOU%G{XYXzG#*)I{Rv^V8s?WFC&mNe*>o zDDV=kbW`+}ux71X^f$8%PVmv9;;v<9el!{_;1JK3+Nus=FFJv3@6uMvR3;+v}(PcjpcN)u@X$J+9F%ft7h@MKyR*>&CIsrL%(VX4W@Or$?{FFY^j}~&#ZiT=}uL%V0hrc z$`c(U-`vrR#7Puw%}tBNPC}9HDIXNk6CoG##nqW*(#~B7+_2Oq>kwLKbCzngdL zkin6J+NZJTS4|W7KkiKPsAmoIY+VB+)#Xsw zLYoXB_?%A;-WGp08srhfk5I`hvuRxEf8Q!O3krE- z0!~JyH#*Sl8(t_%Wg*r>`CC*Rio#Vbn3!G1s1wuminEI8*#P9U@%^izy05Z@1ai3p zpS@q24mC?W1^84vO#+OQHKSf$YuaJ?Fff)p5k52lBXK}nIl;X0orNR#;=5gc#O8dg zUZ6lEPrq<}*UK`6zRAFFe-6Jo;k9X)xG2ZjNLAL?4h}UR$ zA9o`qLVSIQWE3eaf4P-p6~!EEenOnN9~U|Ph_#ezI{^s#`Li0P)6$|BA`~D0v)2d! zkaEGXGRjk{Z2Aiq>&f;uqiLZOK81tP(|HHO3tAb?!7?bbs#$8YI$ z1aSUx;#B2Kz!5*O{VH$qp7D8kU-}ds$@}J2|6Y=*n{cu(e|3=8&~W)p70WIbHclP* zH&;{Wyj2HA1jO*_$sd|Pb;u=-tF+Il0=Awi(uilK~yKEpA5yY4R?3T-vX z;J4KAx(}nqk*yeMC)dUN=f9ZAlO9EzG{4sL)q8R`EKJ)`jNR3JVJ00a_TtRXXaYEA zfe{()O%K%ye{uU1o+c^D#en)L0BKIepz9nr=SP;ItA18`Hao5$K<@JutN00=83ht7 zqCK@upet#xPVHImE;14;F^ zO@&gROin*MmM}n7ldtS@sKiZ$COC08Xptc? z{ELw&S9X#d6SoO)3XCnoT!W%>-YtGrCl&{qE?aIw*sjaNyqG*EaK88}dMH2x zSF=x++wE8V&Ibw*CZ^Wf#NZGB7*7yOXauOqUY&4vRYAB$KX%c+_9Ys1Ko@MtJ~thr zb8&h_DOg`>)<^VNn_xRK%UXOxX>7l(6>l_r)snkm63V= ze;d~(HQzTy8KfwIkm~uNM>xJUsYftsSR<&Uc-MYs;XI@Qd0XVTnO;)s5Ejd8!{TP zEYgG(&Ol*DlI5A~)>zT*27e;l{hoT^?r;LcbHp&u?XT(n7)AhA)69~g7~ zHdGBnjsYW9XjSH;PfbD#$gyAVG8C}N6_{R!niQ*q(UTmB%L*y$;L9j?hxsHno!pAY zPeO*%Cl-9`1AQGR)!yG1Y0WCmh?!{ho1W3wlH)suQ+20~n#!8yj*)1(Ya|D|f2Do- zqoSyjGk?9noU3DEVHp7zB zB>0_erTH(p9q!m4RhFyGIB2?4H6`my3=qhtY^3P&z5fu}{OzyvoB% zd;FE-ti7oSkw5F-k)i1Nz5$C*Z)>7Nx!2j z4-ib6dhQ`@(9;~mgd5pQ;mN<++hgEGzVJBUTt#~?JF=evO)1tj4JE~bSj6P$hr=!Q zaoBYn%6i65MtLt}GNQzve-1c(F}nvQh`#zFPtGyzis(&|?E~rZ0LA|2_q! zGi?OAnla#j2dX7FJgN4SEe^BQL3(gEhbrX>DMKpJ_LCe8mIr&vD$gRz`zaoz57L?;=Zs8*bsh>Ahb5f{8qDaW7{>ufoqtgi+A z))Ex%;-0C+{BHPIgoJ4Hns?a}tjlzyg@P`aeG_T|5%a(f-mI!?tyguTTjAN7*_~8 zKR~4Zg#yOwN0Qol#fBJU8Vtk6yP{oGwYjbI=H2z?q(Vc1gABvd?4<&PE(Bd-q2wwPN$`R{U43^ z!0YARucCmHD(RBPp9B5q>_Ho{Sg5zA4`2{dWHORAoBvv$JO+x}G<{WZ)kBxBPX8XB ztW=+TKafo*O@D`9>^17W`eF3U$9BOYBz584WH)UMSNkRLV}2& z;;s!TPP-p^YT8Hy$@~pxyX|WbF;3$R>lq2=M_Q=YdHNeX zSyS>Aa^g*2xaqx{nXrMgfG2HUlc+c=;J5vQQ%YAo5_D;LN;;zN5xVyW%d!SIR94(mwJQbogF(X=oMcsAr zBVepvp-BPjuIMI}^JH!Q@fDLGjI1xudY0;dAhDrT^kSDl6K3|~8EMr)_WX}ZS^ea( z;BcA6UA@J8Sj5`5ZIA=)5reDG4t=Z0q6(;#t%9PAO{Jcj__Yx=|R7QY)=x z^|@DB8E`r0*16z~S2X)6{NKO2T<^|*FcA!<(&!<_MxetkU7?%%L41UZtXE-r7d}ZE zv=>^!efmw2*WKxx+%!O+yvWe`W40mg9i044Oudz!ShhG~!(4R^cQn@~Kj%nYxwx zBN?5~{Yeh>2YlWWHfF|y12jK1Sw(nu6<6gH%x-KR6?S0Jl&Xn$S&>nd4vhqV@@KtZ z=%2?@S11<(Z#zt()4$_M-g1m!jA^_V5$nQ(SfOqO-nj z^Xlo}%qLc2e*1;m2gNkZO!_|ZS2ZECXpyvtbQ#MQn43I#JR5Ug?-t?S--N#9B`(0P z*fet^(+K*~fXD0{5EYcrvRZ5n8|S_@gzKUC%M z-Kf%_-tNJi|Lh-7VT8@I*gux7N!Zc$cAwjY>;i*A1PrSJ%oB==Mw$F=rMQjf-h!*I zz;f3#^t%*(^|y315(#)-#mG-OWg?R+Kg47nj%KWAB6%x4!$eP*k#GT zUk2<`x;8reO{=zx3hlvyRa(r#W%?jq!JpEF$|*i)sG*W=v${O8!bpSa`*7mTFSM~Y zaBwg1mIl=zL{ml47A6NT2Mf?Ss0tW-K0DU*DU$2rjoH7IS4gp`3JioA)_qN`%=No9 z)*!7bd+ZPXxlm@EqO@z@w~kSfS0*9(@!VRT;))|ni6WJPnL8|#`~VEZ%(vu zHtorB8R`7^*@N->IqG?HNneU%g1?`GC7?6Ws*~j|YfH;5u(*y9>Ikcx2B$rWU+L-A(R+%( zw`qj)c;QAd@##3_kMSN{Dw^HqcKjllX?DHad9qV-_%|UeFoSmWAtXMihgZI1BeD_- zFR-wiW?Y$Q(etJ_Ba*8FKTz(VsjL+(bw$rquES}5p>~l$-EGrY6mud|9UaYPleKOi z*r8g)pT>L@QyP&R7`hawU@idT3z&Ni&ggo56(+?kl7F_}(sEciX@J;xrW@o{&RM}f zLbN1yu_w^{DgSoxRKt{y$SFfwhq~kD1_mIf+u^pmUBJX#w@CY5o7QIe`ovjKAMH)$ zb=YrX`ioP=;m>AFPd_c&IBvG>%%0dG<^~v{=tva)-uN!GN^5A4raamh?m9o3~>spi6&)FB2uX zS+k@4`Ni8bu;q=kspp)6BfG`KrI{m^)Y5 zVKM32ZFIg6J`n0qtef2fnn|#Uz%eF786E`}XgPR*z;9HMY~}i`c)f9-ABxMOdcftp z+}u=OM&DC-tUMSU5Wez2Y9FP>+uGMxrHOtqD@ex&A&zh}%`;gT{jfwF5v0s~6j^Hn zbM=@|RrT|m(j&}{r$RV0cL2=&_-Nz0molgzf6~Igi7;lk^TRN*6TK}y9GG9+XSJQ$ zPd|gev~_%$5sL)3Xue;@+p-#UVyHW(x~i&8G#y#yyI}HoD1t8e?V+K_{C+m1tw1vJ z(5iN&9+4xX%m#paN)SEIQCAghIHi@%BH7(~ZEjhYdxRXE&EA{e0CK-(sN z8;Wmy(M>3g!F9W>8B3re2mWYBN#U6+j&W-c)j^<{9ni=@Vx?regOi!Tx6+Hw8;<2< z6J2MDh-_pd<~|`#FoR6BIpZQ^oe83|7wKB1o$sge-70h9^f7ZL2&JR7Q~q)mYt{U7 z$G=Biclq`xBvIVTnR>L^R&T4BTtmlM-x;G+>@<76k*Oc)5+$<88SLai%)UG|N2g}& zjd-6FEf)AHiekH>alJQ@o6SXHj&qZ`3Sh0n0;q%68;Dr?VRr; zUBKO1D;}I|D`fC!2NPm7y+p-iH6TPLxJ5wpL!M~7A+ly&vG-+5B~WDVrngH*?mN3r$KiW-S%C8)Q2xf!Fb5u~Q`dbhpqP zP?kKtK0B63tb(OZyX2vf&EU727JCusu&s_w>benfCkHNb1D6Zzw1GaiG^D>Xmlb`Q z?WIK+t#|-Re}QMqZ&)=)!N}SbLF+E(u{l6>e+kwsn)SZZH(8$hVy4A&6C0c+4|kl= zvj*R=52-1vKfPo8Avm>+I%GCI(X?N)PwAObi9+uB&Q4PkLAUuPx_!WYmUDup&WbnR zB8mY?01>m30&MdVSJc~?OOJ~qR9@rdjzq?6N9W9UE&a}B%NJuWc-=Ebm+0eBbX^u0 z?A_+2AVkv9?%*hY^z~H1k^B3pQ1vb5?`ApqRP(7D8lujNccm(4i)Gp*|6*#!%oDtKdyw5vvnd|_i^R5Zf(8{KeZ;`*8e zhu>EpnZ_9t)Zw#@q14Q)pn0muSmClm)_123HYX@JV5>-}ciWs}C41z2;cPx3Tjc$5 zhtBk_{v2`fi+F8O9NgJtFWo+{W93>;^p2(-@$gl zIM{jSb7T7~JcFD8Hwoy9jXBo^#Yb;o9phAv&f=jPL7eINA7qZPA2J)ufP&a@_6$Q`zz=ycbd;AR!hRqcf_~*<3;0r|K}5q{poM{5G^kOq6fDP;giwZ}|53U|(eLi4%S7vOYWblgvkN7G zxIt>Zk-9LCSN|&fB)5=LaBrfuLX72ZO^m;;unL;+%2Dcy=ZCwWFY^}KY$Z6rZSl(H z#E&AjfzqQSlqcp`I6K~$bFVQM93x*G6!@rjpXXs=<8^1_Q#3o$Z{B)UV;|ia3q~cb zcueJZXly>l=C%u2ardCfQ)H}um#-JIBVX?!AlRADYY1u^?+~S9XP;Hnv%~Rz?S@kV z*(`jAmw2a>)#K|lq9Y*ISh2TpuVt;_?q2g=rY21W)e*^G)by2U7gnh}-xnnp*g3qg z!Ofj5 zTPTfVc0N1Z8%(py1*PxewHm)J(%thBOjU1rTx7jJ+r>>!X;4_(9rTf|NyloU{ON$o zfLuP!#PguBFtG=n43bGW{A#Kd_HD+z{>;zf8l14r&rjWc&%JRE(>O!l+Ru=G>$Fx` zDO+(+x}RmLz6|rzD!Wsp;I3p(2DtYq@Ec801_t&8002M)#H89b-jhFl>R_HE2#OSt z@>$@J0y3jKX%sq64te*`0f3N3XDMI;JlM*A;C3SPH(qZqRE0AdDg9jy$5?UNf!8bP z$)*DhWi~_?#3TgZDow|pE09IrIsV5q6|Zzr;Hx&(bOP4LxL`vQ5(+V z33C*dfUd-fUx&B}*N|Fpm#f6&9u^otR8fWo9#Ge~YzVdVBU&b1&tF#VHWe(3E0c9ZJ#MeVXh39-ZGhT6ZSjPU^&9H7rzfQ z3-v=67Gjq~S0?8}7Dr@|&p;RQ18OV3wqAzls#x@_dRj%i7wpr0BX-9P_v>v`$o=cd zuOg%LhuFEnbf3Ii-e^7T6`8A>x>y4it}Xm1FBL(2InOu8h=CPt4X7&5HzkKldb7$b zgjhq#6c4-D#RS{sIEhR)g%68opnanm5H`t8+0sor5H=caZRJQIN`fcs`9g*YsS$RS zXI#9l0Df;%`R3~>0yON50HLLaM6y^4ZOO53XSiaYW^iNW5gf0DBl|j8gVPHfze%^7 zaH}nrLeHraC8`6UDc?c-nX?0$puqE zfxX@giE13uhm_cj!?-f4)tXN$8>~n#P6zW1e9~#Jab(!lWgiUhaV^;6Sa-x}zf;Dj zDcdGNKyS5gr9c9Sy z(CXP4PBcgVVH0x%K^8O3wtab{c=z*Wsz8cuy>(%g^rXouqg#9o@e#HcJQ7(y$d=pQ zFNMBuF?PUmqc-bPXaT9LyxJ*VLsgnmio96Soo6^yG}xo)w>&S{4>!c!{Me zBjQjhTtV{?o`em@AzlR2C>SbqZla%oViY1?5rME>D=hBuFx+XM-A@4DS$El9%P2;&YvormFKJbT3q}~?bF2! zMV;sY&g%RMgjuq4uO%t_tvYTg*ZF8sv3xwweYCLRbhF=Nu*Xf|Egj@ia*_y?0g}rv zzUt@lA7={aETocwb*A0-dh&^wG6U=g;N!H^z3uP#v=FncPQ)8kURd%;u8VRKNcIqB zjrXz34eglMC`G;>Ca<&|9Uuq`>n{oS?k&br(zwH_c0CRng*(Ji`jiIv-KQvQ1W zka$R;3O&^RrdiK(Md|P{C0DzM5JMxlGimQ_k?W(}DYWb^vv1CBOs#T~;ak`GlHpJvz9$1CMBOsUAx1Zjj#iuIf@P$VPwTBC;SP zE!taHod2Z?m}#-;{n)_g$)k6>oTyn>Z)d%lWGY;8Q`Q#cUG1rQ2gIl`@{`I(Yg1Jq z{l21Ni)3TXoG0Uag>)C(M9LULwZx|xomwHaG~dQ04&u&r&Ib#VN(~F8f2e%P7F)p( z2NL(W^1YHXnPHGfW~01l?F-o`hOYbgpCw}zdL&gmt^dZ$jag;ZaaNM%KIQ#}FBAH;*0gkhZ9}hlO>t4-5PrFapQ>j($FkNztxd54 zfi;bT*+_ux_t-#QCm&Yh`LF!sKBefZh&)x9Nj`wZdDz=q)#4c z@udzDSc5B0;XH;1@4n1;h*aU*D-2hz*5;mmCrR0`ua&9(Oipmb*UB`iUsBv5>6w7= z&UzMVt)$D$Zf;AMoJ)_xmf>YZZ*9y{;!^jOxnxpO^>uOGp+$n|>E^9!lQ7*v)I&`T9%xQWBLX78T31Kx! zqf_8Cn=o*^v@%8{s*eI_>yY*r`J}E*i;sv4*v!5_x7@*Eks8ycM|d?ttn9EneQy%K zrr)i3-n27w*j@pH!6))=&lEJsk`WuL{aYCA_hs~_yrl#9&k;vY*Cxdc%5XVyI)RjE z1Lt0)kH(6Iw-sC8py9u|`QOT1e2{qB%x)K)GyTq2KgT+==WfN@6HOO}WS+brbk%!q zx7|~FWw+$$C}{t?JUKJo2*UcD!v%aOT#ST5V~%EHl#(d&8A+P1D$w-dR(VZvI0F8y zUrxTdQ>g8+YRVc48=o29<>Z>bFVF|8w@l?89T3xO8>&W@Zp2gzsnPWo%7=%|Q5FZU z-sU-L0oB<#&>O0P4@V*Qk-C#CgC^mETPwC^7MZ0M$8y|>&`xSqL>rmIGrvv9O@(!j z2;hTrNV%dJd@}JyKkkhLmT&{!40`F81>3w{0c#fx2T2%;5@b}@P6l(fGdMBinl6z1 zFN#`Y>Vb-d7icxRxoq79@*+vQ2$SG_n`j|XUJIsB) z#`x0ygRda%*E=YZ!r9Lrh^HOueUI9;fjiYhXdi8u`w=84R9Acr7^y3mv)-;EjitfQ#2mbd|dTsW2>TslqAxDs|%)k{50k}?v z)!&MazjM{}-kjA|b^uH1G^53bld^g%sW8FAMM+$-!5_YZa#jGJgvkE7tfuYu?FQpj zWT-CL`;WG>9bW^{n_t8@OE*=3Uymg|sE%1j*K(r?M($s(`p4A(9DOlq+jAyl4^e82 zUpjN6oW1x+>Ly(3RN=i@8Hupf{SOqsrzV0GmE?n?ef^O4Bq8M`7_b);N zIDdV$w&ZJ5x{V6gCdO7@DpT{#-Tc~q*_fPe-guyL=$AF`t{BsEm4sQ_*`_?OjDgCA_4%Rkjn}n8@Qo$4%+7)M`cB*OCp}I?9U^VL%Fb}j;WSV zv#xXAd4x>Eqntrq)dk$c}?JVkN{k@8jyvYio9+ zG(7t4c5VUQ=BV`tk}#TcPyIBtN@4o>CJHMuvuli306Q|a>mlvs8G~&pcR=`#h zkKS&+u1?;kt1G9cyVs{b2O<8X%WZ*oEHSb26-?-#(ZGRgKk0Hk=_7-KNF{itLP`~} zrNRoXeU5`hc_8qb1>7ooM5XnU1`%T`Ft)!!oC}n=ja3j4|Z*$)%(HDKe}2s00ZUA1J5h+AMhZ`WlO= z2@@%fA~Zh84$Z|L|BXulI~PSI>(mNYC2%5|21eP1eUQKtfj&yRvW>&f3%xPbU>0T=CL*ZbYN(C0BG==F207(+==7n@c z9la(zDJ##Sp$U$$Lh(uYP%^(L&UvJAEzCE0U(YzD{(bGed8vH5Q~= zbnq5hyZCgxW|y5*<$QEJUPF>Nx07>3@cGWgosYYyKuP&n%q!+$)6=otHvXtxJ()hz z;UwO7o-Yz{%BJ$v0nVS)!}?SLZ`Mb%BFm8hTM3|_$|ZJp<@0PiBXtpYHii}kTT0}U~&0Ccg#@o>_BxS zR$-9>idKAreSZQ8?yioY3PmNFgv{(-K^b}+`d(t0VZo>{oAqUnbv8~qd|59JtWm@F z%0zl$#{<*vYgUjPWi3~@-jY^}j!Nv?(u4qVd1hqws zm97qd4P~c;V*=zRPrtHJqt)|uY!=gCQH59#CC;g;jzz$Yum%gV@r}XftvsSpxRt_F zt#g=jKApOq+-Crl`X;K+>tGlYd4w}!R4^x!bB3i`jO>+$Yj=&N9LOj#F);&g0)1OG ztSqj9y`qiV3hpoa9btz|M^C4$%pz5yyM9;~<6vyXW0WqGQ}fe3c5dy*PROlfGU5n* zJVCq05A}?~p2b}?NQ~Q!HiX&w_Z-jD+6WW(ay^^f?GH>BqLc-CAvptR{_|RbTfZ{7 zh}xn?F?OH>o7kl&w8m<*`J8g5ITzK_HMl8pBn?d-%wSuB!yf%vHoT~=!3NH=tHUyr zvs?l-1e3Hpg15t`ysj7A13e1&GIEd;Fwfecua__aPqS6?^DMA3+fC@em_xK51Y5r8}V3jL{7 zNcCB;9a!oy(s>e#ajN1AbULYk084{ogbJ$O5C5fo6`J<*hWnD&6!>vnH7p1$he z1~d*4=dO17m>K8R)i@$5!!?g+DL~2nmXDFz80OI ztW%jP?ydU|Fh*sHTvCrIk^)SI6(|jRaXp&!(%Q-XejXt^#`UtF1h6!xy(a9wA(6{< z33lw9nT$X9@RK0v{@5KWPt8?&Am(Y8)sNmRXTGwd7kwM!k;{u7_+@vs7n=oCqnQ^E zK=sRvaI2`{`VC`FYR{Af;vGIi43Y)Q*x}L|2_lYkA#6{^^>5y&${`lD*gKXus_d)O zsTxddv{*$nF=*9reX6kOVIEHh6vojdh=JiI?(t-pQDLszD%cuQ(OWGfJvQ4ahNIhl zHKyjsZ$M9Pf>GR+Nfp!&33-EB-O$FgWXs<&w%5Dn*5!&`KERtc2IiRORTXHB?^Rm7 zS}4L-n;$vOPN!F@bMoGu359Ui9Mp@9Z+<9MCvRkwntAYym)jpUzAKtnAph-I6AtE| zk6CbjVA2jxY-d6C+&&c|h+kp(^|>tK{Ilw;%L5Zvt7p)~`IX}3JsZ%6UH{G_RCT0) z!@+~qXMwW`D2n=L0NDP>z6Jok-uyRn$>0wY|4+2+|APr3Y6cR*h-iYIKoFH?ApUbQ?Vpt5 zD*hmVotdeXkqeWx3)8>S^E^BX|IFf_XPm!ZJk9C?eEyvWF=_(hll>Wpzh`})1`gwI z!XKf+9|S>Y0g~|jf&F{S%fDazu{#tC0+=}1yBb;9n>qh`K+od^F=~10$Vn^+0&W3P zKlh^ekA@}{1Q~1rJ{QlBgFhPVPaw#O36PNCUtRiZ#6O=>92~;{0Dezp@~gjH{}HCM zL6BT)AR)xQ6^Q(7+pqP>((lh8NO~)f8u3ryH5lx5kct){E(~Wr2(sS#50^-7Pe8H) z5ahrSNceP-@y|E;UqLJVX@xBTLB6>HasOXHd};j}xUx|FINY27)Mh0CE1GpV#eAtwI$bh(J4#?0Gou31n&{pKQuK-Le0}cG43p;GeKi zA=5&;r<|}N{C7@JD?yM2ucw?q+y4>5{vRi`H6X}~4&dwOEHQLEY0_&!5Sb1j)wA34 zzUwuOr~GPS0RXuF;Wlpu1hLNr;z5c#fXL4oUGG6^ft<8IWt8D32r~0eqc?wy;;eum zt0h1R2yf>O-biJyl=9q_gg(BRQmrVG Date: Sat, 16 Nov 2019 14:38:05 +0100 Subject: [PATCH 290/299] Fix pb with colspan and extrafields. Fix remove empty id --- htdocs/adherents/card.php | 2 +- htdocs/adherents/type.php | 6 ++-- htdocs/asset/type.php | 6 ++-- htdocs/categories/card.php | 2 +- htdocs/categories/edit.php | 2 +- htdocs/comm/action/card.php | 4 +-- htdocs/comm/mailing/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/compta/bank/card.php | 4 +-- htdocs/compta/bank/various_payment/card.php | 2 -- htdocs/compta/facture/card.php | 4 +-- htdocs/contact/card.php | 6 ++-- htdocs/contrat/card.php | 4 +-- htdocs/core/class/commonobject.class.php | 26 ++++++++++------ htdocs/core/class/extrafields.class.php | 5 ++-- htdocs/don/card.php | 4 +-- htdocs/expedition/card.php | 6 ++-- htdocs/expensereport/card.php | 4 +-- htdocs/fichinter/card.php | 17 +++++------ htdocs/fourn/commande/card.php | 33 ++++++++++----------- htdocs/fourn/commande/orderstoinvoice.php | 18 +++++------ htdocs/product/card.php | 2 +- htdocs/product/price.php | 2 +- htdocs/product/stock/card.php | 4 +-- htdocs/reception/card.php | 4 +-- htdocs/societe/card.php | 8 ++--- htdocs/supplier_proposal/card.php | 4 +-- htdocs/user/group/card.php | 2 +- 28 files changed, 93 insertions(+), 92 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 2a8177df6f2..e19afe70e13 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1077,7 +1077,7 @@ else print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print '

        '; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index b1b18e3ed31..ecfd12142f4 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -373,11 +373,11 @@ if ($action == 'create') // Other attributes $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; print "

        '.$text.'

        '.$text.'

        '.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).'
        '.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'


        '.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).'
        '.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'

        '; print ''; print ''."\n"; -$found=false; -$error=0; -$var=false; +$found = false; +$error = 0; +$var = false; // Payment on customer order if ($source == 'proposal') { - $found=true; + $found = true; $langs->load("proposal"); require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $proposal=new Propal($db); - $result=$proposal->fetch('', $ref); + $proposal = new Propal($db); + $result = $proposal->fetch('', $ref); if ($result <= 0) { - $mesg=$proposal->error; + $mesg = $proposal->error; $error++; } else { - $result=$proposal->fetch_thirdparty($proposal->socid); + $result = $proposal->fetch_thirdparty($proposal->socid); } // Creditor - print ''."\n"; // Debitor - print ''."\n"; @@ -259,7 +259,7 @@ if ($source == 'proposal') -if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters"); +if (!$found && !$mesg) $mesg = $langs->trans("ErrorBadParameters"); if ($mesg) print ''."\n"; @@ -268,7 +268,7 @@ print "\n"; if ($action != 'dosign') { - if ($found && ! $error) // We are in a management option and no error + if ($found && !$error) // We are in a management option and no error { } else diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 00a92ecc115..9b3dd7dea03 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -22,8 +22,8 @@ * \ingroup core * \brief Class file to manage forms into resource module */ -require_once DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php"; -require_once DOL_DOCUMENT_ROOT ."/resource/class/dolresource.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php"; +require_once DOL_DOCUMENT_ROOT."/resource/class/dolresource.class.php"; /** @@ -39,14 +39,14 @@ class FormResource */ public $db; - public $substit=array(); + public $substit = array(); - public $param=array(); + public $param = array(); /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** @@ -79,10 +79,10 @@ class FormResource public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20) { // phpcs:enable - global $conf,$user,$langs; + global $conf, $user, $langs; - $out=''; - $outarray=array(); + $out = ''; + $outarray = array(); $resourcestat = new Dolresource($this->db); @@ -91,20 +91,20 @@ class FormResource if ($outputmode != 2) { $out = ''; - $out.= ''; + $out .= ''; } if ($resourcestat) { - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && ! $forcecombo) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && !$forcecombo) { //$minLength = (is_numeric($conf->global->RESOURCE_USE_SEARCH_TO_SELECT)?$conf->global->RESOURCE_USE_SEARCH_TO_SELECT:2); - $out.= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT); + $out .= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT); } // Construct $out and $outarray - $out.= ''."\n"; + if ($showempty) $out .= ''."\n"; $num = 0; if (is_array($resourcestat->lines)) $num = count($resourcestat->lines); @@ -115,34 +115,34 @@ class FormResource { while ($i < $num) { - $resourceclass=ucfirst($resourcestat->lines[$i]->element); + $resourceclass = ucfirst($resourcestat->lines[$i]->element); - $label=$resourcestat->lines[$i]->ref?$resourcestat->lines[$i]->ref:''.$resourcestat->lines[$i]->label; - if ($resourceclass != 'Dolresource') $label.=' ('.$langs->trans($resourceclass).')'; + $label = $resourcestat->lines[$i]->ref ? $resourcestat->lines[$i]->ref : ''.$resourcestat->lines[$i]->label; + if ($resourceclass != 'Dolresource') $label .= ' ('.$langs->trans($resourceclass).')'; if ($selected > 0 && $selected == $resourcestat->lines[$i]->id) { - $out.= ''; + $out .= ''; } else { - $out.= ''; + $out .= ''; } array_push($outarray, array('key'=>$resourcestat->lines[$i]->id, 'value'=>$resourcestat->lines[$i]->label, 'label'=>$resourcestat->lines[$i]->label)); $i++; - if (($i % 10) == 0) $out.="\n"; + if (($i % 10) == 0) $out .= "\n"; } } - $out.= ''."\n"; - $out.= ajax_combobox($htmlname); + $out .= ''."\n"; + $out .= ajax_combobox($htmlname); if ($outputmode != 2) { - $out.= '     '; + $out .= '     '; - $out.= ''; + $out .= ''; } } else @@ -170,22 +170,22 @@ class FormResource public function select_types_resource($selected = '', $htmlname = 'type_resource', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0) { // phpcs:enable - global $langs,$user; + global $langs, $user; $resourcestat = new Dolresource($this->db); dol_syslog(get_class($this)."::select_types_resource ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); - $filterarray=array(); + $filterarray = array(); - if ($filtertype != '' && $filtertype != '-1') $filterarray=explode(',', $filtertype); + if ($filtertype != '' && $filtertype != '-1') $filterarray = explode(',', $filtertype); $resourcestat->load_cache_code_type_resource(); print ''; - if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin && !$noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 42fae860666..b8fbb099fb3 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -57,7 +57,7 @@ class Thirdparties extends DolibarrApi $this->company = new Societe($this->db); - if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY)) { + if (!empty($conf->global->SOCIETE_EMAIL_MANDATORY)) { static::$FIELDS[] = 'email'; } } @@ -121,24 +121,24 @@ class Thirdparties 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 && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."societe as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; - $sql.= " WHERE t.fk_stcomm = st.id"; - if ($mode == 1) $sql.= " AND t.client IN (1, 3)"; - if ($mode == 2) $sql.= " AND t.client IN (2, 3)"; - if ($mode == 3) $sql.= " AND t.client IN (0)"; - if ($mode == 4) $sql.= " AND t.fournisseur IN (1)"; - $sql.= ' AND t.entity IN ('.getEntity('societe').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st"; + $sql .= " WHERE t.fk_stcomm = st.id"; + if ($mode == 1) $sql .= " AND t.client IN (1, 3)"; + if ($mode == 2) $sql .= " AND t.client IN (2, 3)"; + if ($mode == 3) $sql .= " AND t.client IN (0)"; + if ($mode == 4) $sql .= " AND t.fournisseur IN (1)"; + $sql .= ' AND t.entity IN ('.getEntity('societe').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; //if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; - if ($socid) $sql.= " AND t.rowid IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + if ($socid) $sql .= " AND t.rowid IN (".$socids.")"; + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($search_sale > 0) { @@ -147,15 +147,15 @@ class Thirdparties extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -164,7 +164,7 @@ class Thirdparties extends DolibarrApi } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); @@ -176,7 +176,7 @@ class Thirdparties extends DolibarrApi { $obj = $db->fetch_object($result); $soc_static = new Societe($db); - if($soc_static->fetch($obj->rowid)) { + if ($soc_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($soc_static); } $i++; @@ -185,7 +185,7 @@ class Thirdparties extends DolibarrApi else { throw new RestException(503, 'Error when retrieve thirdparties : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'Thirdparties not found'); } return $obj_ret; @@ -199,13 +199,13 @@ class Thirdparties extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->company->$field = $value; } if ($this->company->create(DolibarrApiAccess::$user) < 0) @@ -223,25 +223,25 @@ class Thirdparties extends DolibarrApi */ public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->company->$field = $value; } - if($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) + if ($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) return $this->get($id); return false; @@ -272,27 +272,27 @@ class Thirdparties extends DolibarrApi throw new RestException(400, 'Try to merge a thirdparty into itself'); } - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } - $result = $this->company->fetch($id); // include the fetch of extra fields - if( ! $result ) { + $result = $this->company->fetch($id); // include the fetch of extra fields + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->companytoremove = new Societe($db); - $result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields - if( ! $result ) { + $result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->companytoremove->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->companytoremove->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -309,7 +309,7 @@ class Thirdparties extends DolibarrApi // Recopy some data $object->client = $object->client | $soc_origin->client; $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; - $listofproperties=array( + $listofproperties = array( 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', @@ -323,7 +323,7 @@ class Thirdparties extends DolibarrApi } // Concat some data - $listofproperties=array( + $listofproperties = array( 'note_public', 'note_private' ); foreach ($listofproperties as $property) @@ -367,7 +367,7 @@ class Thirdparties extends DolibarrApi } // Move links - if (! $error) + if (!$error) { $objects = array( 'Adherent' => '/adherents/class/adherent.class.php', @@ -422,12 +422,12 @@ class Thirdparties extends DolibarrApi } - if (! $error) + if (!$error) { - $object->context=array('merge'=>1, 'mergefromid'=>$soc_origin->id); + $object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id); // Call trigger - $result=$object->call_trigger('COMPANY_MODIFY', $user); + $result = $object->call_trigger('COMPANY_MODIFY', $user); if ($result < 0) { //setEventMessages($object->error, $object->errors, 'errors'); @@ -436,7 +436,7 @@ class Thirdparties extends DolibarrApi // End call triggers } - if (! $error) + if (!$error) { //We finally remove the old thirdparty if ($soc_origin->delete($soc_origin->id, $user) < 1) @@ -469,14 +469,14 @@ class Thirdparties extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->societe->supprimer) { + if (!DolibarrApiAccess::$user->rights->societe->supprimer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->company->oldcopy = clone $this->company; @@ -498,12 +498,12 @@ class Thirdparties extends DolibarrApi */ public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -537,24 +537,24 @@ class Thirdparties extends DolibarrApi */ public function addCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -575,24 +575,24 @@ class Thirdparties extends DolibarrApi */ public function deleteCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -616,12 +616,12 @@ class Thirdparties extends DolibarrApi */ public function getSupplierCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -655,24 +655,24 @@ class Thirdparties extends DolibarrApi */ public function addSupplierCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -693,24 +693,24 @@ class Thirdparties extends DolibarrApi */ public function deleteSupplierCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -738,20 +738,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -782,20 +782,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -825,20 +825,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -868,20 +868,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -935,14 +935,14 @@ class Thirdparties extends DolibarrApi if ($filter == "available") $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL"; if ($filter == "used") $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)"; - $sql.= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); $result = $this->db->query($sql); - if( ! $result ) { + if (!$result) { throw new RestException(503, $this->db->lasterror()); } else { $num = $this->db->num_rows($result); - while ( $obj = $this->db->fetch_object($result) ) { + while ($obj = $this->db->fetch_object($result)) { $obj_ret[] = $obj; } } @@ -967,14 +967,14 @@ class Thirdparties extends DolibarrApi */ public function getInvoicesQualifiedForReplacement($id) { - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -985,7 +985,7 @@ class Thirdparties extends DolibarrApi $invoice = new Facture($this->db); $result = $invoice->list_replacable_invoices($id); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->thirdparty->error); } @@ -1009,14 +1009,14 @@ class Thirdparties extends DolibarrApi */ public function getInvoicesQualifiedForCreditNote($id) { - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -1027,7 +1027,7 @@ class Thirdparties extends DolibarrApi $invoice = new Facture($this->db); $result = $invoice->list_qualified_avoir_invoices($id); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->thirdparty->error); } @@ -1047,14 +1047,14 @@ class Thirdparties extends DolibarrApi { global $db, $conf; - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -1063,18 +1063,18 @@ class Thirdparties extends DolibarrApi */ $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; - $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; - if ($id) $sql.= " WHERE fk_soc = ".$id." "; + $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql .= " WHERE fk_soc = ".$id." "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404, 'Account not found'); } - $i=0; + $i = 0; $accounts = array(); @@ -1085,13 +1085,13 @@ class Thirdparties extends DolibarrApi { $obj = $db->fetch_object($result); $account = new CompanyBankAccount($db); - if($account->fetch($obj->rowid)) { + if ($account->fetch($obj->rowid)) { $accounts[] = $account; } $i++; } } - else{ + else { throw new RestException(404, 'Account not found'); } @@ -1124,7 +1124,7 @@ class Thirdparties extends DolibarrApi */ public function createCompanyBankAccount($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1132,7 +1132,7 @@ class Thirdparties extends DolibarrApi $account->socid = $id; - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1159,7 +1159,7 @@ class Thirdparties extends DolibarrApi */ public function updateCompanyBankAccount($id, $bankaccount_id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1167,12 +1167,12 @@ class Thirdparties extends DolibarrApi $account->fetch($bankaccount_id, $id, -1, ''); - if($account->socid != $id){ + if ($account->socid != $id) { throw new RestException(401); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1194,7 +1194,7 @@ class Thirdparties extends DolibarrApi */ public function deleteCompanyBankAccount($id, $bankaccount_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1202,7 +1202,7 @@ class Thirdparties extends DolibarrApi $account->fetch($bankaccount_id); - if(!$account->socid == $id) + if (!$account->socid == $id) throw new RestException(401); return $account->delete(DolibarrApiAccess::$user); @@ -1222,12 +1222,12 @@ class Thirdparties extends DolibarrApi { global $conf; - $this->langs->loadLangs(array("main","dict","commercial","products","companies","banks","bills","withdrawals")); + $this->langs->loadLangs(array("main", "dict", "commercial", "products", "companies", "banks", "bills", "withdrawals")); $this->company->fetch($id); $action = 'builddoc'; - if(! DolibarrApiAccess::$user->rights->societe->creer) + if (!DolibarrApiAccess::$user->rights->societe->creer) throw new RestException(401); $this->company->setDocModel(DolibarrApiAccess::$user, $model); @@ -1235,32 +1235,32 @@ class Thirdparties extends DolibarrApi $this->company->fk_bank = $this->company->fk_account; $outputlangs = $this->langs; - $newlang=''; + $newlang = ''; - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang=$this->company->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang=$this->company->default_lang; // for thirdparty - if (! empty($newlang)) { + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang = $this->company->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang = $this->company->default_lang; // for thirdparty + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // To be sure vars is defined $hidedetails = $hidedesc = $hideref = 0; - $moreparams=null; - if (empty($hidedetails)) $hidedetails=0; - if (empty($hidedesc)) $hidedesc=0; - if (empty($hideref)) $hideref=0; - if (empty($moreparams)) $moreparams=null; + $moreparams = null; + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; - if ($id) $sql.= " WHERE fk_soc = ".$id." "; - if ($companybankid) $sql.= " AND id = ".$companybankid.""; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql .= " WHERE fk_soc = ".$id." "; + if ($companybankid) $sql .= " AND id = ".$companybankid.""; - $i=0; - $accounts=array(); + $i = 0; + $accounts = array(); $result = $this->db->query($sql); if ($result) @@ -1321,11 +1321,11 @@ class Thirdparties extends DolibarrApi { global $db, $conf; - if(!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(!DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -1333,16 +1333,16 @@ class Thirdparties extends DolibarrApi * We select all the records that match the socid */ $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account"; - $sql.= " WHERE fk_soc = $id"; - if($site) $sql .= " AND site ='$site'"; + $sql .= " WHERE fk_soc = $id"; + if ($site) $sql .= " AND site ='$site'"; $result = $db->query($sql); - if($result->num_rows == 0){ + if ($result->num_rows == 0) { throw new RestException(404, 'This thirdparty does not have any gateway attached or does not exist.'); } - $i=0; + $i = 0; $accounts = array(); @@ -1352,7 +1352,7 @@ class Thirdparties extends DolibarrApi $obj = $db->fetch_object($result); $account = new SocieteAccount($db); - if($account->fetch($obj->rowid)) { + if ($account->fetch($obj->rowid)) { $accounts[] = $account; } $i++; @@ -1398,25 +1398,25 @@ class Thirdparties extends DolibarrApi { global $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } - if(!isset($request_data['site'])) { + if (!isset($request_data['site'])) { throw new RestException(422, 'Unprocessable Entity: You must pass the site attribute in your request data !'); } - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { $account = new SocieteAccount($this->db); - if(!isset($request_data['login'])) { + if (!isset($request_data['login'])) { $account->login = ""; } $account->fk_soc = $id; - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1457,7 +1457,7 @@ class Thirdparties extends DolibarrApi { global $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1465,16 +1465,16 @@ class Thirdparties extends DolibarrApi $result = $db->query($sql); // We do not found an existing SocieteAccount entity for this fk_soc and site ; we then create a new one. - if($result->num_rows == 0 ){ - if(!isset($request_data['key_account'])) { + if ($result->num_rows == 0) { + if (!isset($request_data['key_account'])) { throw new RestException(422, 'Unprocessable Entity: You must pass the key_account attribute in your request data !'); } $account = new SocieteAccount($this->db); - if(!isset($request_data['login'])) { + if (!isset($request_data['login'])) { $account->login = ""; } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1501,13 +1501,13 @@ class Thirdparties extends DolibarrApi $account->id = $obj->rowid; $account->fk_soc = $id; $account->site = $site; - if(!isset($request_data['login'])) { + if (!isset($request_data['login'])) { $account->login = ""; } $account->fk_user_creat = $obj->fk_user_creat; $account->date_creation = $obj->date_creation; - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1539,30 +1539,30 @@ class Thirdparties extends DolibarrApi { global $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404, "This thirdparty does not have $site gateway attached or does not exist."); } else { // If the user tries to edit the site member, we check first if - if(isset($request_data['site']) && $request_data['site'] !== $site) { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; + if (isset($request_data['site']) && $request_data['site'] !== $site) { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' "; $result = $db->query($sql); - if($result->num_rows !== 0) - throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists for this thirdparty with this site key."); + if ($result->num_rows !== 0) + throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key."); } $obj = $db->fetch_object($result); $account = new SocieteAccount($this->db); $account->fetch($obj->rowid); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1593,21 +1593,21 @@ class Thirdparties extends DolibarrApi global /** @var Database $db */ $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404); } else { $obj = $db->fetch_object($result); $account = new SocieteAccount($this->db); $account->fetch($obj->rowid); - if($account->delete(DolibarrApiAccess::$user) < 0) { + if ($account->delete(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error while deleting $site gateway attached to this third party"); } } @@ -1630,7 +1630,7 @@ class Thirdparties extends DolibarrApi global /** @var Database $db */ $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1639,14 +1639,14 @@ class Thirdparties extends DolibarrApi */ $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id "; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404, 'This third party does not have any gateway attached or does not exist.'); } else { - $i=0; + $i = 0; $num = $db->num_rows($result); while ($i < $num) @@ -1655,7 +1655,7 @@ class Thirdparties extends DolibarrApi $account = new SocieteAccount($db); $account->fetch($obj->rowid); - if($account->delete(DolibarrApiAccess::$user) < 0) { + if ($account->delete(DolibarrApiAccess::$user) < 0) { throw new RestException(500, 'Error while deleting gateways attached to this third party'); } $i++; diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index d403499a79e..5cfe6fa3709 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -25,7 +25,7 @@ * \brief File of class to manage bank accounts description of third parties */ -require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; /** @@ -81,34 +81,34 @@ class CompanyBankAccount extends Account public function create(User $user = null, $notrigger = 0) { $now = dol_now(); - $error = 0; + $error = 0; // Correct default_rib to be sure to have always one default $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'"; $result = $this->db->query($sql); if ($result) { - $numrows=$this->db->num_rows($result); + $numrows = $this->db->num_rows($result); if ($this->default_rib && $numrows > 0) $this->default_rib = 0; if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1; } $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)"; - $sql.= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')"; - $resql=$this->db->query($sql); + $sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')"; + $resql = $this->db->query($sql); if ($resql) { if ($this->db->affected_rows($resql)) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib"); - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('COMPANY_RIB_CREATE', $user); + $result = $this->call_trigger('COMPANY_RIB_CREATE', $user); if ($result < 0) $error++; // End call triggers - if (! $error) + if (!$error) { return 1; } @@ -215,14 +215,14 @@ class CompanyBankAccount extends Account if (empty($id) && empty($socid)) return -1; $sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; - $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; - if ($id) $sql.= " WHERE rowid = ".$id; + $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql .= " WHERE rowid = ".$id; if ($socid) { - $sql.= " WHERE fk_soc = ".$socid; - if ($default > -1) $sql.=" AND default_rib = ".$this->db->escape($default); - if ($type) $sql.= " AND type ='".$this->db->escape($type)."'"; + $sql .= " WHERE fk_soc = ".$socid; + if ($default > -1) $sql .= " AND default_rib = ".$this->db->escape($default); + if ($type) $sql .= " AND type ='".$this->db->escape($type)."'"; } $resql = $this->db->query($sql); @@ -232,10 +232,10 @@ class CompanyBankAccount extends Account { $obj = $this->db->fetch_object($resql); - $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref + $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref - $this->id = $obj->rowid; - $this->type = $obj->type; + $this->id = $obj->rowid; + $this->type = $obj->type; $this->socid = $obj->fk_soc; $this->bank = $obj->bank; $this->code_banque = $obj->code_banque; @@ -243,7 +243,7 @@ class CompanyBankAccount extends Account $this->number = $obj->number; $this->cle_rib = $obj->cle_rib; $this->bic = $obj->bic; - $this->iban = $obj->iban; + $this->iban = $obj->iban; $this->domiciliation = $obj->domiciliation; $this->proprio = $obj->proprio; $this->owner_address = $obj->owner_address; @@ -279,31 +279,31 @@ class CompanyBankAccount extends Account $error = 0; - dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG); + dol_syslog(get_class($this)."::delete ".$this->id, LOG_DEBUG); $this->db->begin(); - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('COMPANY_RIB_DELETE', $user); + $result = $this->call_trigger('COMPANY_RIB_DELETE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib"; - $sql .= " WHERE rowid = " . $this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib"; + $sql .= " WHERE rowid = ".$this->id; - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -311,7 +311,7 @@ class CompanyBankAccount extends Account else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -325,7 +325,7 @@ class CompanyBankAccount extends Account { $rib = ''; - if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) { + if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic) { if ($this->label && $displayriblabel) { $rib = $this->label." : "; } @@ -345,7 +345,7 @@ class CompanyBankAccount extends Account public function setAsDefault($rib = 0) { $sql1 = "SELECT rowid as id, fk_soc FROM ".MAIN_DB_PREFIX."societe_rib"; - $sql1.= " WHERE rowid = ".($rib?$rib:$this->id); + $sql1 .= " WHERE rowid = ".($rib ? $rib : $this->id); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result1 = $this->db->query($sql1); @@ -362,12 +362,12 @@ class CompanyBankAccount extends Account $this->db->begin(); $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0"; - $sql2.= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc; + $sql2 .= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc; dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result2 = $this->db->query($sql2); $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1"; - $sql3.= " WHERE rowid = ".$obj->id; + $sql3 .= " WHERE rowid = ".$obj->id; dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result3 = $this->db->query($sql3); diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 0fe4c450fad..4692687220a 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -102,19 +102,19 @@ $stripeacc = $stripe->getStripeAccount($service); }*/ // Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('paiementcard','globalcard')); +$hookmanager->initHooks(array('paiementcard', 'globalcard')); /* * Actions */ -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$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)) { - if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) { $error = 0; @@ -125,7 +125,7 @@ if (empty($reshook)) $atleastonepaymentnotnull = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new Facture($db); + $tmpinvoice = new Facture($db); foreach ($_POST as $key => $value) { if (substr($key, 0, 7) == 'amount_') @@ -133,16 +133,16 @@ if (empty($reshook)) $cursorfacid = substr($key, 7); $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); if ($amounts[$cursorfacid]) { // Check amount if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date @@ -154,23 +154,23 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; - if (! empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $multicurrency_amountsresttopay[$cursorfacid]=price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); + $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); if ($multicurrency_amounts[$cursorfacid]) { // Check amount if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date @@ -182,7 +182,7 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => GETPOST($key, 'int')); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int')); } } @@ -193,7 +193,7 @@ if (empty($reshook)) $error++; }*/ - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // If bank module is on, account is required to enter a payment if (GETPOST('accountid') <= 0) @@ -242,7 +242,7 @@ if (empty($reshook)) */ if ($action == 'confirm_paiement' && $confirm == 'yes') { - $error=0; + $error = 0; $datepaye = dol_now(); @@ -264,7 +264,7 @@ if (empty($reshook)) } } - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement if (GETPOST('accountid') <= 0) @@ -282,34 +282,34 @@ if (empty($reshook)) if (is_object($stripe) && $stripeacc) { - $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); + $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); if ($customerstripe->id) { - $listofsources=$customerstripe->sources->data; + $listofsources = $customerstripe->sources->data; } } - $stripeamount=0; + $stripeamount = 0; foreach ($amounts as $key => $value) // How payment is dispatch { - $stripeamount+=price2num($value, 'MT'); + $stripeamount += price2num($value, 'MT'); } if (preg_match('/acct_/i', $source)) { - $paiementcode ="VIR"; + $paiementcode = "VIR"; } elseif (preg_match('/card_/i', $source)) { - $paiementcode ="CB"; + $paiementcode = "CB"; } elseif (preg_match('/src_/i', $source)) { - $customer2 = $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); + $customer2 = $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); $src = $customer2->sources->retrieve("$source"); - if ($src->type=='card') + if ($src->type == 'card') { - $paiementcode ="CB"; + $paiementcode = "CB"; } } @@ -319,17 +319,17 @@ if (empty($reshook)) $societe->fetch($facture->socid); dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); - $stripecu = $stripe->getStripeCustomerAccount($societe->id, $servicestatus); // Get thirdparty cu_... + $stripecu = $stripe->getStripeCustomerAccount($societe->id, $servicestatus); // Get thirdparty cu_... - $charge=$stripe->createPaymentStripe($stripeamount, $facture->multicurrency_code, "invoice", $facid, $source, $stripecu, $stripeacc, $servicestatus); + $charge = $stripe->createPaymentStripe($stripeamount, $facture->multicurrency_code, "invoice", $facid, $source, $stripecu, $stripeacc, $servicestatus); if (!$error) { // Creation of payment line $paiement = new Paiement($db); $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->amounts = $amounts; // Array with all payments dispatching + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = dol_getIdFromCode($db, $paiementcode, 'c_paiement'); $paiement->num_paiement = $charge->message; $paiement->note = GETPOST('comment'); @@ -337,7 +337,7 @@ if (empty($reshook)) $paiement->ext_payment_site = $service; } - if (! $error) + if (!$error) { $paiement_id = $paiement->create($user, 0); if ($paiement_id < 0) @@ -351,45 +351,45 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $facture->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$facture->modelpdf; + $model = $facture->modelpdf; $ret = $facture->fetch($facid); // Reload to get new records $facture->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - if (! $error) + if (!$error) { - $label='(CustomerInvoicePayment)'; - if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; - $result=$paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), '', ''); + $label = '(CustomerInvoicePayment)'; + if (GETPOST('type') == 2) $label = '(CustomerInvoicePaymentBack)'; + $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), '', ''); if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; } - elseif (GETPOST('closepaidinvoices')=='on') { + elseif (GETPOST('closepaidinvoices') == 'on') { $facture->set_paid($user); } } - if (! $error) + if (!$error) { $db->commit(); // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card - $invoiceid=0; + $invoiceid = 0; foreach ($paiement->amounts as $key => $amount) { $facid = $key; if (is_numeric($amount) && $amount <> 0) { - if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment - else $invoiceid=$facid; + if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment + else $invoiceid = $facid; } } if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; @@ -417,39 +417,39 @@ $form = new Form($db); llxHeader(); -if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) { +if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { $service = 'StripeLive'; $servicestatus = 0; } else { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } -if (GETPOST('error')){ +if (GETPOST('error')) { setEventMessages(GETPOST('error'), null, 'errors'); } if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') { $facture = new Facture($db); - $result=$facture->fetch($facid); + $result = $facture->fetch($facid); if ($result >= 0) { $facture->fetch_thirdparty(); - $title=''; - if ($facture->type != 2) $title.=$langs->trans("EnterPaymentReceivedFromCustomer"); - if ($facture->type == 2) $title.=$langs->trans("EnterPaymentDueToCustomer"); + $title = ''; + if ($facture->type != 2) $title .= $langs->trans("EnterPaymentReceivedFromCustomer"); + if ($facture->type == 2) $title .= $langs->trans("EnterPaymentDueToCustomer"); print load_fiche_titre($title); // Initialize data for confirmation (this is used because data can be change during confirmation) if ($action == 'add_paiement') { - $i=0; + $i = 0; - $formquestion[$i++]=array('type' => 'hidden','name' => 'facid', 'value' => $facture->id); - $formquestion[$i++]=array('type' => 'hidden','name' => 'socid', 'value' => $facture->socid); - $formquestion[$i++]=array('type' => 'hidden','name' => 'type', 'value' => $facture->type); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'socid', 'value' => $facture->socid); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'type', 'value' => $facture->type); } @@ -544,7 +544,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie '; print ' });'."\n"; - if (!empty($conf->use_javascript_ajax)){ + if (!empty($conf->use_javascript_ajax)) { //Add js for AutoFill print ' $(document).ready(function () {'; print ' $(".AutoFillAmout").on(\'click touchstart\', function(){ @@ -577,7 +577,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '\n"; // Bank account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { //$form->select_comptes($accountid,'accountid',0,'',2); print ''; @@ -615,7 +615,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie dol_fiche_end(); - $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); + $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); print '
        '; print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); @@ -632,62 +632,62 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; print ''; print ''; // Default print ''; @@ -711,32 +711,32 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // $account=\Stripe\Account::retrieve("".$stripe->getStripeCustomerAccount($facture->socid).""); //} - if (($account->type=='custom' or $account->type=='express') && $entity==1) { + if (($account->type == 'custom' or $account->type == 'express') && $entity == 1) { print ''; print ''; print ''; // Default print ''; print ''; } - if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid)) { + if (empty($input) && !$stripe->getStripeCustomerAccount($facture->socid)) { print ''; } @@ -768,33 +768,33 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie */ $sql = 'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, '; - $sql.= ' f.datef as df, f.fk_soc as socid'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' f.datef as df, f.fk_soc as socid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) { - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; } - $sql.= ' WHERE f.entity IN ('.getEntity('invoice').")"; - $sql.= ' AND (f.fk_soc = '.$facture->socid; + $sql .= ' WHERE f.entity IN ('.getEntity('invoice').")"; + $sql .= ' AND (f.fk_soc = '.$facture->socid; if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { - $sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; + $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; } - $sql.= ') AND f.paye = 0'; - $sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled + $sql .= ') AND f.paye = 0'; + $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled if ($facture->type != 2) { - $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation + $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation } else { - $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes + $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes } // Sort invoices by date and serial number: the older one comes first - $sql.=' ORDER BY f.datef ASC, f.ref ASC'; + $sql .= ' ORDER BY f.datef ASC, f.ref ASC'; $resql = $db->query($sql); if ($resql) @@ -802,17 +802,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $num = $db->num_rows($resql); if ($num > 0) { - $sign=1; - if ($facture->type == 2) $sign=-1; + $sign = 1; + if ($facture->type == 2) $sign = -1; - $arraytitle=$langs->trans('Invoice'); - if ($facture->type == 2) $arraytitle=$langs->trans("CreditNotes"); - $alreadypayedlabel=$langs->trans('Received'); - $multicurrencyalreadypayedlabel=$langs->trans('MulticurrencyReceived'); - if ($facture->type == 2) { $alreadypayedlabel=$langs->trans("PaidBack"); $multicurrencyalreadypayedlabel=$langs->trans("MulticurrencyPaidBack"); } - $remaindertopay=$langs->trans('RemainderToTake'); - $multicurrencyremaindertopay=$langs->trans('MulticurrencyRemainderToTake'); - if ($facture->type == 2) { $remaindertopay=$langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay=$langs->trans("MulticurrencyRemainderToPayBack"); } + $arraytitle = $langs->trans('Invoice'); + if ($facture->type == 2) $arraytitle = $langs->trans("CreditNotes"); + $alreadypayedlabel = $langs->trans('Received'); + $multicurrencyalreadypayedlabel = $langs->trans('MulticurrencyReceived'); + if ($facture->type == 2) { $alreadypayedlabel = $langs->trans("PaidBack"); $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack"); } + $remaindertopay = $langs->trans('RemainderToTake'); + $multicurrencyremaindertopay = $langs->trans('MulticurrencyRemainderToTake'); + if ($facture->type == 2) { $remaindertopay = $langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack"); } $i = 0; @@ -838,17 +838,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; } - $tmpinvoice =new Facture($db); - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpinvoice, $action); // Note that $action and $object may have been modified by hook + $tmpinvoice = new Facture($db); + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpinvoice, $action); // Note that $action and $object may have been modified by hook print ''; print "\n"; - $total=0; - $totalrecu=0; - $totalrecucreditnote=0; - $totalrecudeposits=0; + $total = 0; + $totalrecu = 0; + $totalrecucreditnote = 0; + $totalrecudeposits = 0; while ($i < $num) { @@ -857,29 +857,29 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $soc = new Societe($db); $soc->fetch($objp->socid); - $invoice=new Facture($db); + $invoice = new Facture($db); $invoice->fetch($objp->facid); $paiement = $invoice->getSommePaiement(); - $creditnotes=$invoice->getSumCreditNotesUsed(); - $deposits=$invoice->getSumDepositsUsed(); - $alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT'); - $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); + $creditnotes = $invoice->getSumCreditNotesUsed(); + $deposits = $invoice->getSumDepositsUsed(); + $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); + $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); // Multicurrency Price if (!empty($conf->multicurrency->enabled)) { $multicurrency_payment = $invoice->getSommePaiement(1); - $multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1); - $multicurrency_deposits=$invoice->getSumDepositsUsed(1); - $multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT'); - $multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT'); + $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1); + $multicurrency_deposits = $invoice->getSumDepositsUsed(1); + $multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT'); + $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT'); } print ''; print '\n"; // Date @@ -946,7 +946,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ""; // Multicurrency Price - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print '"; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook // Warning print '\n"; - $total+=$objp->total; - $total_ttc+=$objp->total_ttc; - $totalrecu+=$paiement; - $totalrecucreditnote+=$creditnotes; - $totalrecudeposits+=$deposits; + $total += $objp->total; + $total_ttc += $objp->total_ttc; + $totalrecu += $paiement; + $totalrecucreditnote += $creditnotes; + $totalrecudeposits += $deposits; $i++; } if ($i > 1) { - $amount=round(price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT'))*100); + $amount = round(price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')) * 100); // Print total print ''; @@ -1033,10 +1033,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Bouton Enregistrer if ($action != 'add_paiement') { - $checkboxlabel=$langs->trans("ClosePaidInvoicesAutomatically"); - if ($facture->type == 2) $checkboxlabel=$langs->trans("ClosePaidCreditNotesAutomatically"); - $buttontitle=$langs->trans('ToMakePayment'); - if ($facture->type == 2) $buttontitle=$langs->trans('ToMakePaymentBack'); + $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically"); + if ($facture->type == 2) $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically"); + $buttontitle = $langs->trans('ToMakePayment'); + if ($facture->type == 2) $buttontitle = $langs->trans('ToMakePaymentBack'); print '
        '; print ' '.$checkboxlabel; @@ -1052,18 +1052,18 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Form to confirm payment if ($action == 'add_paiement') { - $preselectedchoice=$addwarning?'no':'yes'; + $preselectedchoice = $addwarning ? 'no' : 'yes'; print '
        '; if (!empty($totalpayment)) { $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency)); } if (!empty($multicurrency_totalpayment)) { - $text.='
        '.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency")); + $text .= '
        '.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency")); } if (GETPOST('closepaidinvoices')) { - $text.='
        '.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); + $text .= '
        '.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); print ''; } print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice); @@ -1078,27 +1078,27 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie * Show list of payments */ -if (! GETPOST('action')) +if (!GETPOST('action')) { - if ($page == -1 || empty($page)) $page = 0 ; - $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; - $offset = $limit * $page ; + if ($page == -1 || empty($page)) $page = 0; + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; + $offset = $limit * $page; - if (! $sortorder) $sortorder='DESC'; - if (! $sortfield) $sortfield='p.datep'; + if (!$sortorder) $sortorder = 'DESC'; + if (!$sortfield) $sortfield = 'p.datep'; $sql = 'SELECT p.datep as dp, p.amount, f.amount as fa_amount, f.ref'; - $sql.=', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; - $sql.= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; - $sql.= ' AND f.entity IN ('.getEntity('invoice').")"; + $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; + $sql .= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; + $sql .= ' AND f.entity IN ('.getEntity('invoice').")"; if ($socid) { - $sql.= ' AND f.fk_soc = '.$socid; + $sql .= ' AND f.fk_soc = '.$socid; } - $sql.= ' ORDER BY '.$sortfield.' '.$sortorder; - $sql.= $db->plimit($limit+1, $offset); + $sql .= ' ORDER BY '.$sortfield.' '.$sortorder; + $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -1115,8 +1115,8 @@ if (! GETPOST('action')) print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'fa_amount', '', '', '', $sortfield, $sortorder, 'right '); $tmpobject = new Paiement($db); - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpobject, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpobject, $action); // Note that $action and $object may have been modified by hook print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "
        \n"; @@ -1131,8 +1131,8 @@ if (! GETPOST('action')) print '\n"; print ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook print ''; print ''; diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index 791ceda79eb..2815b1ac5a9 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -77,25 +77,25 @@ $stripeacc = $stripe->getStripeAccount($service); print $langs->trans('ErrorStripeAccountNotDefined'); }*/ -if (! $rowid) { - print ''; +if (!$rowid) { + print ''; if ($optioncss != '') { - print ''; + print ''; } - print ''; + print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - $title=$langs->trans("StripePayoutList"); - $title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'); + $title = $langs->trans("StripePayoutList"); + $title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); print '
        '; - print '
        '.$langs->trans("ThisIsInformationOnDocumentToSign").' :
        '.$langs->trans("Creditor"); - print ''.$creditor.''; + print '
        '.$langs->trans("Creditor"); + print ''.$creditor.''; print ''; print '
        '.$langs->trans("ThirdParty"); - print ''.$proposal->thirdparty->name.''; + print '
        '.$langs->trans("ThirdParty"); + print ''.$proposal->thirdparty->name.''; // Object - $text=''.$langs->trans("SignatureProposalRef", $proposal->ref).''; - print '
        '.$langs->trans("Designation"); - print ''.$text; + $text = ''.$langs->trans("SignatureProposalRef", $proposal->ref).''; + print '
        '.$langs->trans("Designation"); + print ''.$text; print ''; print ''; print '

        '.$mesg.'
        '.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
        id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print '>id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print ' disabled'; - } elseif (($customerstripe->default_source==$src->id && $action != 'add_paiement') or ($source==$src->id && $action == 'add_paiement')) { + } elseif (($customerstripe->default_source == $src->id && $action != 'add_paiement') or ($source == $src->id && $action == 'add_paiement')) { print ' checked'; } print '>id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print' >'; - if ($src->object=='card') { + if ($src->object == 'card') { print img_credit_card($src->brand); - } elseif ($src->object=='source' && $src->type=='card') { + } elseif ($src->object == 'source' && $src->type == 'card') { print img_credit_card($src->card->brand); - } elseif ($src->object=='source' && $src->type=='sepa_debit') { + } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print ''; } print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print' >'; - if ($src->object=='card') { + if ($src->object == 'card') { print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; print ''; if ($src->country) { $img = picto_from_langcode($src->country); - print $img?$img.' ':''; + print $img ? $img.' ' : ''; print getCountry($src->country, 1); } else { print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - } elseif ($src->object=='source' && $src->type=='card') { + } elseif ($src->object == 'source' && $src->type == 'card') { print $src->owner->name.'
        ....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; print '
        '; if ($src->card->country) { $img = picto_from_langcode($src->card->country); - print $img?$img.' ':''; + print $img ? $img.' ' : ''; print getCountry($src->card->country, 1); } else { print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - } elseif ($src->object=='source' && $src->type=='sepa_debit') { + } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print 'info sepa'; print ''; if ($src->sepa_debit->country) { $img = picto_from_langcode($src->sepa_debit->country); - print $img?$img.' ':''; + print $img ? $img.' ' : ''; print getCountry($src->sepa_debit->country, 1); } else { print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -696,11 +696,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print'>'; - if (($customerstripe->default_source==$src->id)) { + if (($customerstripe->default_source == $src->id)) { print ""; } print '
        getStripeCustomerAccount($facture->socid)!=$source) { + if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) { print'class="opacitymedium"'; } print'>global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { + if ((empty($input) && $action != 'add_paiement') or ($source == $conf->global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { print ' checked'; - } elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT!=$source) { + } elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT != $source) { print ' disabled'; } print '>getStripeCustomerAccount($facture->socid)!=$source) { + if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) { print'class="opacitymedium"'; } print '>getStripeCustomerAccount($facture->socid)!=$source) { + if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) { print'class="opacitymedium"'; } print'>'.$langs->trans('sold'); print'id!=$source) { + if ($action == 'add_paiement' && $src->id != $source) { print'class="opacitymedium"'; } print'>'; @@ -744,7 +744,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print 'id!=$source) { + if ($action == 'add_paiement' && $src->id != $source) { print'class="opacitymedium"'; } print'>'; @@ -756,7 +756,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
        '.$langs->trans("None").'
        '.$langs->trans('MulticurrencyPaymentAmount').' 
        '; print $invoice->getNomUrl(1, ''); - if($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' '; + if ($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' '; print "'; @@ -972,8 +972,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "'; @@ -987,16 +987,16 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "
        '.$objp->paiement_type.' '.$objp->num_paiement."'.price($objp->amount).' 
        ' . "\n"; + print '
        '."\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 906d7768bd4..6a0067bf220 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -77,24 +77,24 @@ $stripeacc = $stripe->getStripeAccount($service); print $langs->trans('ErrorStripeAccountNotDefined'); }*/ -if (! $rowid) { - print ''; +if (!$rowid) { + print ''; if ($optioncss != '') - print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - $title=$langs->trans("StripeTransactionList"); - $title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'); + $title = $langs->trans("StripeTransactionList"); + $title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); print '
        '; - print '
        ' . "\n"; + print '
        '."\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); diff --git a/htdocs/takepos/phone.php b/htdocs/takepos/phone.php index 2bd21626f34..5d0346a495c 100644 --- a/htdocs/takepos/phone.php +++ b/htdocs/takepos/phone.php @@ -25,37 +25,37 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -require '../main.inc.php'; // Load $user and permissions +require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant $action = GETPOST('action', 'alpha'); $setterminal = GETPOST('setterminal', 'int'); -if ($setterminal>0) +if ($setterminal > 0) { - $_SESSION["takeposterminal"]=$setterminal; + $_SESSION["takeposterminal"] = $setterminal; } -$langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter")); +$langs->loadLangs(array("bills", "orders", "commercial", "cashdesk", "receiptprinter")); /* * View */ // Title -$title='TakePOS - Dolibarr '.DOL_VERSION; -if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; -$head=' +$title = 'TakePOS - Dolibarr '.DOL_VERSION; +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; +$head = ''; @@ -66,14 +66,14 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); '; } - $out.= ''; + $out.= ''; } else // In most cases, this is not used. We used instead function with no specific list of colors { diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 90cc0a142cb..34802a57a5d 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -788,12 +788,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -802,12 +802,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -816,17 +816,17 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -836,7 +836,7 @@ if ($action == 'create' || $action == 'adduserldap') require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $generated_password=getRandomPassword(false); } - $password=$generated_password; + $password=(GETPOSTISSET('password')?GETPOST('password'):$generated_password); // Password print ''; @@ -1004,12 +1004,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -1018,12 +1018,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -1032,12 +1032,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -1114,12 +1114,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -1128,7 +1128,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; } @@ -1137,7 +1137,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; } @@ -1183,7 +1183,7 @@ if ($action == 'create' || $action == 'adduserldap') print $langs->trans("Note"); print '\n"; @@ -1204,7 +1204,7 @@ if ($action == 'create' || $action == 'adduserldap') // Position/Job print ''; print ''; // Default warehouse @@ -1226,7 +1226,7 @@ if ($action == 'create' || $action == 'adduserldap') print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm'); print ''; print ''; print "\n"; @@ -1236,14 +1236,14 @@ if ($action == 'create' || $action == 'adduserldap') print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm'); print ''; print ''; print "\n"; // Salary print ''; print ''; print "\n"; } @@ -1251,7 +1251,7 @@ if ($action == 'create' || $action == 'adduserldap') // Weeklyhours print ''; print ''; print "\n"; @@ -2446,7 +2446,7 @@ else print ''; print '
        '; if (! empty($ldap_lastname)) { - print ''; + print ''; print $ldap_lastname; } else { - print ''; + print ''; } print '
        '; if (! empty($ldap_firstname)) { - print ''; + print ''; print $ldap_firstname; } else { - print ''; + print ''; } print '
        '; if (! empty($ldap_login)) { - print ''; + print ''; print $ldap_login; } elseif (! empty($ldap_loginsmb)) { - print ''; + print ''; print $ldap_loginsmb; } else { - print ''; + print ''; } print '
        '.$langs->trans("Password").''; if (! empty($ldap_phone)) { - print ''; + print ''; print $ldap_phone; } else { - print ''; + print ''; } print '
        '; if (! empty($ldap_mobile)) { - print ''; + print ''; print $ldap_mobile; } else { - print ''; + print ''; } print '
        '; if (! empty($ldap_fax)) { - print ''; + print ''; print $ldap_fax; } else { - print ''; + print ''; } print '
        '; if (! empty($ldap_mail)) { - print ''; + print ''; print $ldap_mail; } else { - print ''; + print ''; } print '
        '.$langs->trans("AccountancyCode").''; - print ''; + print ''; print '
        '.$langs->trans("ColorUser").''; - print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); + print $formother->selectColor(GETPOSTISSET('color')?GETPOST('color', 'alphanohtml'):$object->color, 'color', null, 1, '', 'hideifnotset'); print '
        '; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note', '', '', 120, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%'); + $doleditor=new DolEditor('note', GETPOSTISSET('note')?GETPOST('note', 'none'):'', '', 120, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%'); $doleditor->Create(); print "
        '.$langs->trans("PostOrFunction").''; - print ''; + print ''; print '
        '; - print ''; + print ''; print '
        '; - print ''; + print ''; print '
        '.$langs->trans("Salary").''; - print ''; + print ''; print '
        '.$langs->trans("WeeklyHours").''; - print ''; + print ''; print '
        '; if ($caneditfield) { - print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); + print $formother->selectColor(GETPOSTISSET('color')?GETPOST('color', 'alphanohtml'):$object->color, 'color', null, 1, '', 'hideifnotset'); }else{ print $formother->showColor($object->color, ''); } From 07880dd835521f4d856b476de60b498b90c2e4a5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 14 Nov 2019 16:00:08 +0000 Subject: [PATCH 256/299] Fixing style errors. --- htdocs/adherents/type.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index f49dd73874a..b1b18e3ed31 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -280,8 +280,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') $membertype->id = $objp->rowid; $membertype->ref = $objp->rowid; $membertype->label = $objp->rowid; - $membertype->status = $objp->status; - + $membertype->status = $objp->status; + print '
        '; print $membertype->getNomUrl(1); @@ -427,7 +427,7 @@ if ($rowid > 0) print ''; - // Morphy + // Morphy print ''; print ''; From 8ef9728470f23bfd61f97db1c767ca90a0a80335 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Nov 2019 17:28:23 +0100 Subject: [PATCH 257/299] Fix permission on file --- htdocs/install/mysql/tables/llx_c_holiday_types.sql | 0 htdocs/install/mysql/tables/llx_c_price_expression.sql | 0 htdocs/install/mysql/tables/llx_c_ticket_category.sql | 0 htdocs/install/mysql/tables/llx_c_ticket_severity.sql | 0 htdocs/install/mysql/tables/llx_c_ticket_type.sql | 0 htdocs/install/mysql/tables/llx_expensereport.sql | 0 htdocs/install/mysql/tables/llx_product.sql | 0 htdocs/install/mysql/tables/llx_product_fournisseur_price.sql | 0 htdocs/install/mysql/tables/llx_product_price.sql | 0 htdocs/install/mysql/tables/llx_ticket.key.sql | 0 10 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 htdocs/install/mysql/tables/llx_c_holiday_types.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_c_price_expression.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_c_ticket_category.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_c_ticket_severity.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_c_ticket_type.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_expensereport.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_product.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_product_fournisseur_price.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_product_price.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_ticket.key.sql diff --git a/htdocs/install/mysql/tables/llx_c_holiday_types.sql b/htdocs/install/mysql/tables/llx_c_holiday_types.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_price_expression.sql b/htdocs/install/mysql/tables/llx_c_price_expression.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_ticket_category.sql b/htdocs/install/mysql/tables/llx_c_ticket_category.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_ticket_severity.sql b/htdocs/install/mysql/tables/llx_c_ticket_severity.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_ticket_type.sql b/htdocs/install/mysql/tables/llx_c_ticket_type.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_expensereport.sql b/htdocs/install/mysql/tables/llx_expensereport.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_product_price.sql b/htdocs/install/mysql/tables/llx_product_price.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_ticket.key.sql b/htdocs/install/mysql/tables/llx_ticket.key.sql old mode 100755 new mode 100644 From 4ea3fe7609c3302b42b965fb354816320876f609 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 14 Nov 2019 17:57:29 +0100 Subject: [PATCH 258/299] NEW get user connected informations in REST API --- htdocs/user/class/api_users.class.php | 83 +++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 778823d3d7d..a7d98ca0b2d 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -108,6 +108,7 @@ class Users extends DolibarrApi if ($result) { + $i = 0; $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) @@ -159,6 +160,41 @@ class Users extends DolibarrApi return $this->_cleanObjectDatas($this->useraccount); } + /** + * Get properties of user connected + * + * @url GET /info + * + * @return array|mixed Data without useless information + * + * @throws 401 RestException Insufficient rights + * @throws 404 RestException User not found + * @throws 404 RestException User group not found + */ + public function getInfo() + { + $apiUser = DolibarrApiAccess::$user; + + $result = $this->useraccount->fetch($apiUser->id); + if (!$result) { + throw new RestException(404, 'User not found'); + } + + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + } + + $usergroup = new UserGroup($this->db); + $userGroupList = $usergroup->listGroupsForUser($apiUser->id, false); + if (!is_array($userGroupList)) { + throw new RestException(404, 'User group not found'); + } + + $this->useraccount = $this->_cleanObjectDatas($this->useraccount); + $this->useraccount->user_group_list = $this->_cleanUserGroupListDatas($userGroupList); + + return $this->useraccount; + } /** * Create user account @@ -414,6 +450,53 @@ class Users extends DolibarrApi return $object; } + /** + * Clean sensible user group list datas + * + * @param array $objectList Array of object to clean + * @return array Array of cleaned object properties + */ + private function _cleanUserGroupListDatas($objectList) + { + $cleanObjectList = array(); + + foreach ($objectList as $object) { + $cleanObject = parent::_cleanObjectDatas($object); + + unset($cleanObject->default_values); + unset($cleanObject->lastsearch_values); + unset($cleanObject->lastsearch_values_tmp); + + unset($cleanObject->total_ht); + unset($cleanObject->total_tva); + unset($cleanObject->total_localtax1); + unset($cleanObject->total_localtax2); + unset($cleanObject->total_ttc); + + unset($cleanObject->libelle_incoterms); + unset($cleanObject->location_incoterms); + + unset($cleanObject->fk_delivery_address); + unset($cleanObject->fk_incoterms); + unset($cleanObject->all_permissions_are_loaded); + unset($cleanObject->shipping_method_id); + unset($cleanObject->nb_rights); + unset($cleanObject->search_sid); + unset($cleanObject->ldap_sid); + unset($cleanObject->clicktodial_loaded); + + unset($cleanObject->datec); + unset($cleanObject->datem); + unset($cleanObject->members); + unset($cleanObject->note); + unset($cleanObject->note_private); + + $cleanObjectList[] = $cleanObject; + } + + return $cleanObjectList; + } + /** * Validate fields before create or update object * From fc55123af0b9b37b9afca4ade68a49919cdf6723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 18:31:09 +0100 Subject: [PATCH 259/299] Update api_thirdparties.class.php --- htdocs/societe/class/api_thirdparties.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index b8fbb099fb3..8a29d653912 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -112,7 +112,7 @@ class Thirdparties extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $sqlfilters = '') { - global $db, $conf; + global $db; $obj_ret = array(); @@ -137,7 +137,7 @@ class Thirdparties extends DolibarrApi $sql .= ' AND t.entity IN ('.getEntity('societe').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; //if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; - if ($socid) $sql .= " AND t.rowid IN (".$socids.")"; + if ($socids) $sql .= " AND t.rowid IN (".$socids.")"; if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($search_sale > 0) @@ -172,6 +172,7 @@ class Thirdparties extends DolibarrApi { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; while ($i < $min) { $obj = $db->fetch_object($result); @@ -1722,7 +1723,7 @@ class Thirdparties extends DolibarrApi * * Return an array with thirdparty informations * - * @param int $rowid Id of third party to load + * @param int $rowid Id of third party to load * @param string $ref Reference of third party, name (Warning, this can return several records) * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) * @param string $ref_int Internal reference of third party (not used by dolibarr) @@ -1740,6 +1741,7 @@ class Thirdparties extends DolibarrApi */ private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') { + global $conf; if(! DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } From 1936b11db81173b6a4d3fb6b28df9b8eb8df1eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 18:40:30 +0100 Subject: [PATCH 260/299] doxygen --- htdocs/user/class/user.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a2083f35bec..c5a3add278d 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2083,9 +2083,9 @@ class User extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Read clicktodial information for user + * Read clicktodial information for user * - * @return <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function fetch_clicktodial() { @@ -2123,7 +2123,7 @@ class User extends CommonObject /** * Update clicktodial info * - * @return integer + * @return int <0 if KO, >0 if OK */ public function update_clicktodial() { From 91eb6eb7d7af9c5879355d0411647729873c1cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 18:44:18 +0100 Subject: [PATCH 261/299] Update user.class.php --- htdocs/user/class/user.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index c5a3add278d..4144a27685b 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2886,7 +2886,7 @@ class User extends CommonObject /** * Return and array with all instanciated first level children users of current user * - * @return void + * @return User[]|int * @see getAllChildIds() */ public function get_children() From e73202c2af6565ed82799cf944694a4a673a9f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 18:47:16 +0100 Subject: [PATCH 262/299] Update user.class.php --- htdocs/user/class/user.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 4144a27685b..104ff767299 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2895,7 +2895,7 @@ class User extends CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user"; $sql .= " WHERE fk_user = ".$this->id; - dol_syslog(get_class($this)."::get_children result=".$result, LOG_DEBUG); + dol_syslog(get_class($this)."::get_children sql=".$sql, LOG_DEBUG); $res = $this->db->query($sql); if ($res) { From 67d05cae1baf2d6859e46c01384f9856cf22ecce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 19:06:14 +0100 Subject: [PATCH 263/299] doxygen --- htdocs/projet/class/project.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index f969679a9f6..0ec6652f20b 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -88,6 +88,15 @@ class Project extends CommonObject public $thirdparty_name; // To store name of thirdparty (defined only in some cases) public $user_author_id; //!< Id of project creator. Not defined if shared project. + + /** + * @var int user close id + */ + public $fk_user_close; + + /** + * @var int user close id + */ public $user_close_id; public $public; //!< Tell if this is a public or private project public $budget_amount; From 892b61f1c2872d4218ba44a839356021564d5fdb Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 14 Nov 2019 20:02:44 +0100 Subject: [PATCH 264/299] Update adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 77fa991d07f..304f54b4c30 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -627,7 +627,8 @@ class AdherentType extends CommonObject return -1; } } - + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label by the nature of a adherent (physical or moral) * @@ -642,7 +643,8 @@ class AdherentType extends CommonObject else return $langs->trans("MorPhy"); //return $morphy; } - + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return clicable name (with picto eventually) * From f369fa06a61aca17ab8b3ecb7bc44341c3798d1f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 14 Nov 2019 19:04:18 +0000 Subject: [PATCH 265/299] Fixing style errors. --- htdocs/adherents/class/adherent_type.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 304f54b4c30..cb1f80bb081 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -627,7 +627,7 @@ class AdherentType extends CommonObject return -1; } } - + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label by the nature of a adherent (physical or moral) @@ -643,7 +643,7 @@ class AdherentType extends CommonObject else return $langs->trans("MorPhy"); //return $morphy; } - + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return clicable name (with picto eventually) From fc2e0d4f9544b2df718c3c2ba112da9088bddc1e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 14 Nov 2019 20:09:36 +0100 Subject: [PATCH 266/299] Update adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index cb1f80bb081..a658cff86b8 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -671,6 +671,7 @@ class AdherentType extends CommonObject return $result; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of status (activity, closed) * From 332c91aa11ccdd91d118e248b8689871cb80c94c Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 14 Nov 2019 20:10:14 +0100 Subject: [PATCH 267/299] Update adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index a658cff86b8..14a0c0186a5 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -628,7 +628,6 @@ class AdherentType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label by the nature of a adherent (physical or moral) * @@ -644,7 +643,6 @@ class AdherentType extends CommonObject //return $morphy; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return clicable name (with picto eventually) * From 7e52c70321fdd5270f7ae94419e8858b6ea50a30 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Nov 2019 21:16:18 +0100 Subject: [PATCH 268/299] FIX Advisory ID: usd20190067 --- htdocs/core/lib/functions.lib.php | 6 ++++-- htdocs/fourn/class/fournisseur.product.class.php | 2 +- htdocs/product/fournisseurs.php | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9d926b3bc98..071b7a3b794 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5134,16 +5134,18 @@ function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, if ($idprodfournprice > 0) { - if (! class_exists('ProductFournisseur')) + 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')) + 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; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index faa681b0e88..786a650efb3 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -499,7 +499,7 @@ class ProductFournisseur extends Product $sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; $sql.=" pfp.barcode, pfp.fk_barcode_type"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " WHERE pfp.rowid = ".$rowid; + $sql.= " WHERE pfp.rowid = ".(int) $rowid; dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 560f5b1b574..0bda7d44564 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -254,8 +254,8 @@ if (empty($reshook)) { $supplier=new Fournisseur($db); $result=$supplier->fetch($id_fourn); - if (isset($_POST['ref_fourn_price_id'])) - $object->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']); + if (GETPOSTISSET('ref_fourn_price_id')) + $object->fetch_product_fournisseur_price(GETPOST('ref_fourn_price_id', 'int')); $newprice = price2num(GETPOST("price", "alpha")); From 71003281168583e6d0d8edd01be81223b5971a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 21:25:12 +0100 Subject: [PATCH 269/299] doxygen menubase class --- htdocs/core/class/menubase.class.php | 95 +++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index d47146abc64..3af8d3924a8 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2009-2012 Regis Houssin - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 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 @@ -45,17 +45,32 @@ class Menubase public $errors = array(); /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; + /** + * @var string Menu handler + */ public $menu_handler; + + /** + * @var string Module name if record is added by a module + */ public $module; + + /** + * @var string Menu top or left + */ public $type; + + /** + * @var string Name family/module for top menu (home, companies, ...) + */ public $mainmenu; /** - * @var int ID + * @var int 0 or Id of mother menu line, or -1 if we use fk_mainmenu and fk_leftmenu */ public $fk_menu; @@ -70,23 +85,71 @@ class Menubase public $fk_leftmenu; /** - * @var int position + * @var int Sort order of entry */ public $position; + + /** + * @var string Relative (or absolute) url to go + */ public $url; + + /** + * @var string Target of Url link + */ public $target; + + /** + * @var string Key for menu translation + * @deprecated + * @see title + */ public $titre; + + /** + * @var string Key for menu translation + */ + public $title; + + /** + * @var string Lang file to load for translation + */ public $langs; + + /** + * @var string Not used + * @deprecated + */ public $level; - public $leftmenu; //langs=trim($this->langs); $this->perms=trim($this->perms); $this->enabled=trim($this->enabled); - $this->user=trim($this->user); + $this->user = (int) $this->user; if (empty($this->position)) $this->position=0; if (! $this->level) $this->level=0; @@ -246,7 +309,7 @@ class Menubase */ public function update($user = null, $notrigger = 0) { - global $conf, $langs; + //global $conf, $langs; // Clean parameters $this->rowid=trim($this->rowid); @@ -265,7 +328,7 @@ class Menubase $this->langs=trim($this->langs); $this->perms=trim($this->perms); $this->enabled=trim($this->enabled); - $this->user=trim($this->user); + $this->user = (int) $this->user; // Check parameters // Put here code to add control on parameters values @@ -311,7 +374,7 @@ class Menubase */ public function fetch($id, $user = null) { - global $langs; + //global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; @@ -385,7 +448,7 @@ class Menubase */ public function delete($user) { - global $conf, $langs; + //global $conf, $langs; $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; $sql.= " WHERE rowid=".$this->id; From 837c7276aba8ab2df1cda27fb2a4b61b18c702f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 14 Nov 2019 21:57:21 +0100 Subject: [PATCH 270/299] API New get categories linked to an object --- .../categories/class/api_categories.class.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 0f2a425fe87..5b8f0cdbe39 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -264,6 +264,41 @@ class Categories extends DolibarrApi ) ); } + + /** + * List categories of an object + * + * Get the list of categories linked to an object + * + * @param int $id Object ID + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @return array Array of category objects + * + * @throws RestException + * + * @url GET /object/{type}/{id} + */ + public function getListForObject($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + { + // TODO add other types + if (!in_array($type, ['product'/*, 'member', 'customer', 'supplier', 'contact'*/])) { + throw new RestException(401); + } + + if($type == 'product' && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); + + if( ! count($categories)) { + throw new RestException(404, 'No category found for this object'); + } + return $categories; + } /** * Link an object to a category by id From b2d18a8e0c011f5011c42450eb4cacdd3fb4335b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 14 Nov 2019 20:56:31 +0000 Subject: [PATCH 271/299] Fixing style errors. --- htdocs/categories/class/api_categories.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 5b8f0cdbe39..92ce17642ab 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -264,7 +264,7 @@ class Categories extends DolibarrApi ) ); } - + /** * List categories of an object * @@ -278,7 +278,7 @@ class Categories extends DolibarrApi * @return array Array of category objects * * @throws RestException - * + * * @url GET /object/{type}/{id} */ public function getListForObject($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) @@ -287,13 +287,13 @@ class Categories extends DolibarrApi if (!in_array($type, ['product'/*, 'member', 'customer', 'supplier', 'contact'*/])) { throw new RestException(401); } - + if($type == 'product' && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); - + if( ! count($categories)) { throw new RestException(404, 'No category found for this object'); } From 88692fe95d62628a7d4fd89fd0fd4aa2c86e71ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 14 Nov 2019 22:00:46 +0100 Subject: [PATCH 272/299] Doc for $page --- htdocs/categories/class/api_categories.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 92ce17642ab..a202ee97df9 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -275,6 +275,7 @@ class Categories extends DolibarrApi * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list + * @param int $page Page number * @return array Array of category objects * * @throws RestException From 100827ae0be85e0891f2879cde9050beaac00caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 14 Nov 2019 22:16:08 +0100 Subject: [PATCH 273/299] Fix error process --- htdocs/categories/class/api_categories.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index a202ee97df9..d532c481c24 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -295,8 +295,11 @@ class Categories extends DolibarrApi $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); - if( ! count($categories)) { - throw new RestException(404, 'No category found for this object'); + if( ! is_array($categories)) { + if ($categories == 0) { + throw new RestException(404, 'No category found for this object'); + } + throw new RestException(500, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors)); } return $categories; } From 0f907fbc297143dcdec0d58a79c97f6d4817e680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 14 Nov 2019 22:26:15 +0100 Subject: [PATCH 274/299] $type is mandatory --- htdocs/categories/class/api_categories.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index d532c481c24..5cb733789ee 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -282,7 +282,7 @@ class Categories extends DolibarrApi * * @url GET /object/{type}/{id} */ - public function getListForObject($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { // TODO add other types if (!in_array($type, ['product'/*, 'member', 'customer', 'supplier', 'contact'*/])) { From 0c9b4fe16b3a72445722107f465443242de89007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 14 Nov 2019 22:36:16 +0100 Subject: [PATCH 275/299] Add all types --- htdocs/categories/class/api_categories.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 5cb733789ee..aa908ec7965 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -284,14 +284,21 @@ class Categories extends DolibarrApi */ public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - // TODO add other types - if (!in_array($type, ['product'/*, 'member', 'customer', 'supplier', 'contact'*/])) { + if (!in_array($type, ['product', 'member', 'customer', 'supplier', 'contact'])) { throw new RestException(401); } - if($type == 'product' && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if($type == Categorie::TYPE_PRODUCT && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); - } + } elseif ($type == Categorie::TYPE_CONTACT && ! DolibarrApiAccess::$user->rights->contact->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_CUSTOMER && ! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_SUPPLIER && ! DolibarrApiAccess::$user->rights->fournisseur->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_MEMBER && ! DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); From bb8a4e9efcbb1ca93353322963821576c6742339 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 15 Nov 2019 09:02:21 +0100 Subject: [PATCH 276/299] FIX better look compatibility with Multicompany --- htdocs/user/card.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index e522f542621..1430ccc8483 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2005,15 +2005,6 @@ else } } - if ($caneditgroup) - { - print ''."\n"; - print ''; - print ''; - } - - print '
        '.$langs->trans("MemberNature").''.$object->getmorphylib($object->morphy).'
        '."\n"; - // Other form for add user to group $parameters = array('caneditgroup' => $caneditgroup, 'groupslist' => $groupslist, 'exclude' => $exclude); $reshook = $hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -2021,6 +2012,14 @@ else if (empty($reshook)) { + if ($caneditgroup) + { + print ''."\n"; + print ''; + print ''; + } + + print '
        '."\n"; print ''."\n"; print ''; } - } - print "
        '.$langs->trans("Groups").''; if ($caneditgroup) @@ -2068,15 +2067,15 @@ else { print '
        '.$langs->trans("None").'
        "; + print "
        "; - if ($caneditgroup) - { - print ''; + if ($caneditgroup) + { + print ''; + } + print "
        "; } - print "
        "; } } } From fa3c63ea28f4872b24f73f5f3eb579a94b53c7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 15 Nov 2019 14:47:08 +0100 Subject: [PATCH 277/299] API New can include childs when get a category --- htdocs/categories/class/api_categories.class.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index aa908ec7965..ffbfff4d90f 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -71,11 +71,12 @@ class Categories extends DolibarrApi * Return an array with category informations * * @param int $id ID of category + * @param bool $include_childs Include child categories list (true or false) * @return array|mixed data without useless information * * @throws RestException */ - public function get($id) + public function get($id, $include_childs = false) { if (! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); @@ -89,6 +90,17 @@ class Categories extends DolibarrApi if ( ! DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + + if ($include_childs) { + $cats = $this->category->get_filles(); + if (!is_array($cats)) { + throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors)); + } + $this->category->childs = []; + foreach ($cats as $cat) { + $this->category->childs[] = $this->_cleanObjectDatas($cat); + } + } return $this->_cleanObjectDatas($this->category); } From cc6d8f159bf102f8b8a81541680d15b2b0d1896d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 15 Nov 2019 13:47:40 +0000 Subject: [PATCH 278/299] Fixing style errors. --- htdocs/categories/class/api_categories.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index ffbfff4d90f..3dff8066070 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -90,7 +90,7 @@ class Categories extends DolibarrApi if ( ! DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + if ($include_childs) { $cats = $this->category->get_filles(); if (!is_array($cats)) { From 71a683658887123fc896330705acf53dc5e0f5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 15 Nov 2019 16:12:35 +0100 Subject: [PATCH 279/299] Implement categorie field ref_ext --- htdocs/categories/class/categorie.class.php | 25 ++++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 033f3f38100..6bbc0afcb1c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -240,25 +240,30 @@ class Categorie extends CommonObject /** * Load category into memory from database * - * @param int $id Id of category - * @param string $label Label of category - * @param string $type Type of category ('product', '...') or (0, 1, ...) + * @param int $id Id of category + * @param string $label Label of category + * @param string $type Type of category ('product', '...') or (0, 1, ...) + * @param string $ref_ext External reference of object * @return int <0 if KO, >0 if OK */ - public function fetch($id, $label = '', $type = null) + public function fetch($id, $label = '', $type = null, $ref_ext = '') { global $conf; // Check parameters - if (empty($id) && empty($label)) return -1; + if (empty($id) && empty($label) && empty($ref_ext)) return -1; if (!is_numeric($type)) $type = $this->MAP_ID[$type]; - $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type"; + $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; if ($id > 0) { $sql .= " WHERE rowid = ".$id; } + elseif (!empty($ref_ext)) + { + $sql .= " WHERE ref_ext LIKE '".$this->db->escape($ref_ext)."'"; + } else { $sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")"; @@ -282,6 +287,7 @@ class Categorie extends CommonObject $this->socid = $res['fk_soc']; $this->visible = $res['visible']; $this->type = $res['type']; + $this->ref_ext = $res['ref_ext']; $this->entity = $res['entity']; // Retreive all extrafield @@ -334,6 +340,7 @@ class Categorie extends CommonObject $this->description = trim($this->description); $this->color = trim($this->color); $this->import_key = trim($this->import_key); + $this->ref_ext = trim($this->ref_ext); if (empty($this->visible)) $this->visible = 0; $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); @@ -359,6 +366,7 @@ class Categorie extends CommonObject $sql .= " visible,"; $sql .= " type,"; $sql .= " import_key,"; + $sql .= " ref_ext,"; $sql .= " entity"; $sql .= ") VALUES ("; $sql .= $this->db->escape($this->fk_parent).","; @@ -372,6 +380,7 @@ class Categorie extends CommonObject $sql .= "'".$this->db->escape($this->visible)."',"; $sql .= $this->db->escape($type).","; $sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').","; + $sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : 'null').","; $sql .= $this->db->escape($conf->entity); $sql .= ")"; @@ -446,6 +455,7 @@ class Categorie extends CommonObject // Clean parameters $this->label = trim($this->label); $this->description = trim($this->description); + $this->ref_ext = trim($this->ref_ext); $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); $this->visible = ($this->visible != "" ? intval($this->visible) : 0); @@ -461,6 +471,7 @@ class Categorie extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; $sql .= " SET label = '".$this->db->escape($this->label)."',"; $sql .= " description = '".$this->db->escape($this->description)."',"; + $sql .= " ref_ext = '".$this->db->escape($this->ref_ext)."',"; $sql .= " color = '".$this->db->escape($this->color)."'"; if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { @@ -918,6 +929,7 @@ class Categorie extends CommonObject $categories[$i]['description'] = $category_static->description; $categories[$i]['color'] = $category_static->color; $categories[$i]['socid'] = $category_static->socid; + $categories[$i]['ref_ext'] = $category_static->ref_ext; $categories[$i]['visible'] = $category_static->visible; $categories[$i]['type'] = $category_static->type; $categories[$i]['entity'] = $category_static->entity; @@ -1082,6 +1094,7 @@ class Categorie extends CommonObject $this->cats[$obj->rowid]['description'] = !empty($obj->description_trans) ? $obj->description_trans : $obj->description; $this->cats[$obj->rowid]['color'] = $obj->color; $this->cats[$obj->rowid]['visible'] = $obj->visible; + $this->cats[$obj->rowid]['ref_ext'] = $obj->ref_ext; $i++; } } From 4332834ff7cd0b28ecab32837f889c97c22569dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 15 Nov 2019 23:08:25 +0100 Subject: [PATCH 280/299] Add all types everywhere --- .../categories/class/api_categories.class.php | 118 +++++++++++++++--- 1 file changed, 100 insertions(+), 18 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 3dff8066070..d1b2973041e 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -296,21 +296,27 @@ class Categories extends DolibarrApi */ public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (!in_array($type, ['product', 'member', 'customer', 'supplier', 'contact'])) { + if (!in_array($type, [ + Categorie::TYPE_PRODUCT, + Categorie::TYPE_CONTACT, + Categorie::TYPE_CUSTOMER, + Categorie::TYPE_SUPPLIER, + Categorie::TYPE_MEMBER + ])) { throw new RestException(401); } - + if($type == Categorie::TYPE_PRODUCT && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } elseif ($type == Categorie::TYPE_CONTACT && ! DolibarrApiAccess::$user->rights->contact->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_CUSTOMER && ! DolibarrApiAccess::$user->rights->societe->lire) { + } elseif ($type == Categorie::TYPE_CUSTOMER && ! DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_SUPPLIER && ! DolibarrApiAccess::$user->rights->fournisseur->lire) { + } elseif ($type == Categorie::TYPE_SUPPLIER && ! DolibarrApiAccess::$user->rights->fournisseur->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_MEMBER && ! DolibarrApiAccess::$user->rights->adherent->lire) { + } elseif ($type == Categorie::TYPE_MEMBER && ! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); - } + } $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); @@ -349,13 +355,32 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - - // TODO Add all types - if ($type === "product") { + + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } @@ -410,13 +435,32 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - - // TODO Add all types - if ($type === "product") { + + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } @@ -471,13 +515,32 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - - // TODO Add all types - if ($type === "product") { + + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } @@ -530,13 +593,32 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - - // TODO Add all types - if ($type === "product") { + + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } From 17667d6a1be453e7b6195f122811320ddf2396bd Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 15 Nov 2019 22:08:56 +0000 Subject: [PATCH 281/299] Fixing style errors. --- htdocs/categories/class/api_categories.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index d1b2973041e..e916255f7b5 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -305,7 +305,7 @@ class Categories extends DolibarrApi ])) { throw new RestException(401); } - + if($type == Categorie::TYPE_PRODUCT && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } elseif ($type == Categorie::TYPE_CONTACT && ! DolibarrApiAccess::$user->rights->contact->lire) { @@ -355,7 +355,7 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -435,7 +435,7 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -515,7 +515,7 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -593,7 +593,7 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); From 3898db3956cd2bf46f9a8da32818e88f2fac6181 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Nov 2019 00:39:23 +0100 Subject: [PATCH 282/299] FIX #12446 --- htdocs/core/class/conf.class.php | 10 +++++----- htdocs/core/photos_resize.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 0aae646b385..d35ddf946fb 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -354,11 +354,11 @@ class Conf $this->propal->dir_output=$rootfordata."/propale"; $this->propal->dir_temp=$rootfordata."/propale/temp"; - // For backward compatibility - $this->banque->multidir_output = array($this->entity => $rootfordata."/bank"); - $this->banque->multidir_temp = array($this->entity => $rootfordata."/bank/temp"); - $this->banque->dir_output=$rootfordata."/bank"; - $this->banque->dir_temp=$rootfordata."/bank/temp"; + // For bank storage + $this->bank->multidir_output = array($this->entity => $rootfordata."/bank"); + $this->bank->multidir_temp = array($this->entity => $rootfordata."/bank/temp"); + $this->bank->dir_output = $rootfordata."/bank"; + $this->bank->dir_temp = $rootfordata."/bank/temp"; // For medias storage $this->medias->multidir_output = array($this->entity => $rootfordata."/medias"); diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 826ed5fdd45..ba37ee0aa66 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -218,7 +218,7 @@ elseif ($modulepart == 'bank') { $result = $object->fetch($id); if ($result <= 0) dol_print_error($db, 'Failed to load object'); - $dir=$conf->banque->dir_output; // By default + $dir=$conf->bank->dir_output; // By default } } else { From d2aa4ba54e3d2b3dc2492c8ce24d8116c370f55c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Nov 2019 00:41:55 +0100 Subject: [PATCH 283/299] Update adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 14a0c0186a5..5006becb053 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -489,7 +489,7 @@ class AdherentType extends CommonObject { global $langs, $conf; - $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut, d.duration, d.subscription, d.mail_valid, d.note, d.vote"; + $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.rowid = ".(int) $rowid; @@ -506,8 +506,8 @@ class AdherentType extends CommonObject $this->ref = $obj->rowid; $this->label = $obj->label; $this->morphy = $obj->morphy; - $this->statut = $obj->statut; - $this->status = $obj->statut; + $this->statut = $obj->status; // deprecated + $this->status = $obj->status; $this->duration = $obj->duration; $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1); $this->duration_unit = substr($obj->duration, -1); From 5c0976a778084c23f0973adf37ec71d1e04c316e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 16 Nov 2019 09:58:14 +0100 Subject: [PATCH 284/299] doxygen accountancy class --- .../class/accountancysystem.class.php | 16 +++++++- .../class/accountingjournal.class.php | 18 ++++++-- .../accountancy/class/bookkeeping.class.php | 41 ++++++++++++++++++- .../install/mysql/migration/3.5.0-3.6.0.sql | 0 .../install/mysql/migration/3.6.0-3.7.0.sql | 0 .../install/mysql/migration/3.7.0-3.8.0.sql | 0 htdocs/install/mysql/migration/repair.sql | 0 .../tables/llx_accounting_bookkeeping.sql | 12 +++--- 8 files changed, 75 insertions(+), 12 deletions(-) mode change 100755 => 100644 htdocs/install/mysql/migration/3.5.0-3.6.0.sql mode change 100755 => 100644 htdocs/install/mysql/migration/3.6.0-3.7.0.sql mode change 100755 => 100644 htdocs/install/mysql/migration/3.7.0-3.8.0.sql mode change 100755 => 100644 htdocs/install/mysql/migration/repair.sql diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 4f93aa18875..c59e87dfd93 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -36,7 +36,7 @@ class AccountancySystem /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var int ID @@ -48,7 +48,14 @@ class AccountancySystem */ public $fk_pcg_version; + /** + * @var string pcg type + */ public $pcg_type; + + /** + * @var string pcg subtype + */ public $pcg_subtype; /** @@ -61,7 +68,14 @@ class AccountancySystem */ public $label; + /** + * @var string account number + */ public $account_number; + + /** + * @var string account parent + */ public $account_parent; /** diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 886b2ade2d4..1191187a139 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -42,8 +42,7 @@ class AccountingJournal extends CommonObject public $fk_element = ''; /** - * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - * @var int + * @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 0; @@ -57,6 +56,9 @@ class AccountingJournal extends CommonObject */ public $rowid; + /** + * @var string Accounting journal code + */ public $code; /** @@ -64,9 +66,19 @@ class AccountingJournal extends CommonObject */ public $label; - public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new + /** + * @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new + */ + public $nature; + + /** + * @var int is active or not + */ public $active; + /** + * @var array array of lines + */ public $lines; /** diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 69c17f3484e..d8a33ac1054 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -38,7 +38,7 @@ class BookKeeping extends CommonObject public $error; /** - * @var string[] Error codes (or messages) + * @var string[] Array of Error codes (or messages) */ public $errors = array(); @@ -67,7 +67,14 @@ class BookKeeping extends CommonObject */ public $id; + /** + * @var string Date of source document, in db date NOT NULL + */ public $doc_date; + + /** + * @var int Deadline for payment + */ public $date_lim_reglement; /** @@ -119,9 +126,25 @@ class BookKeeping extends CommonObject * @var string label operation */ public $label_operation; + + /** + * @var float FEC:Debit + */ public $debit; + + /** + * @var float FEC:Credit + */ public $credit; + + /** + * @var float FEC:Amount (Not necessary) + */ public $montant; + + /** + * @var string FEC:Sens (Not necessary) + */ public $sens; /** @@ -129,9 +152,24 @@ class BookKeeping extends CommonObject */ public $fk_user_author; + /** + * @var string key for import + */ public $import_key; + + /** + * @var string code journal + */ public $code_journal; + + /** + * @var string label journal + */ public $journal_label; + + /** + * @var int accounting transaction id + */ public $piece_num; /** @@ -140,7 +178,6 @@ class BookKeeping extends CommonObject public $picto = 'generic'; - /** * Constructor * diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index f851061db63..cf1c3334092 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -17,7 +17,7 @@ -- -- ============================================================================ -CREATE TABLE llx_accounting_bookkeeping +CREATE TABLE llx_accounting_bookkeeping ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- | multi company id @@ -27,7 +27,7 @@ CREATE TABLE llx_accounting_bookkeeping doc_ref varchar(300) NOT NULL, -- FEC:PieceRef | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid - thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) + thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number @@ -45,12 +45,12 @@ CREATE TABLE llx_accounting_bookkeeping fk_user_author integer NOT NULL, -- | user creating fk_user_modif integer, -- | user making last change date_creation datetime, -- FEC:EcritureDate | creation date - tms timestamp, -- | date last modification + tms timestamp, -- | date last modification fk_user integer NULL, -- The id of user that validate the accounting source document code_journal varchar(32) NOT NULL, -- FEC:JournalCode journal_label varchar(255), -- FEC:JournalLib - date_validated datetime, -- FEC:ValidDate | if empty: movement not validated / if not empty: movement validated (No deleting / No modification) - date_export datetime DEFAULT NULL, -- + date_validated datetime, -- FEC:ValidDate | if empty: movement not validated / if not empty: movement validated (No deleting / No modification) + date_export datetime DEFAULT NULL, -- import_key varchar(14), - extraparams varchar(255) -- for other parameters with json format + extraparams varchar(255) -- for other parameters with json format ) ENGINE=innodb; From 2d73dc8f5cfcdc266c07979a2454a2511dac0a7e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Nov 2019 12:17:37 +0100 Subject: [PATCH 285/299] Fix new line --- htdocs/website/index.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index d35ca0130cb..2a3279631f2 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3036,14 +3036,16 @@ if ($action == 'editmeta' || $action == 'createcontainer') { print ''.$langs->trans('ThisPageHasTranslationPages').':
        '; $i = 0; + $tmppage = new WebsitePage($db); while ($obj = $db->fetch_object($resql)) { - $tmppage = new WebsitePage($db); - $tmppage->fetch($obj->rowid); - if ($i > 0) print ' - '; - print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')
        '; - $translatedby++; - $i++; + $result = $tmppage->fetch($obj->rowid); + if ($result > 0) { + if ($i > 0) print '
        '; + print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')'; + $translatedby++; + $i++; + } } } } From 53bbfcff6b7ec3ed406f3eef706c0bd215895d39 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Nov 2019 12:43:32 +0100 Subject: [PATCH 286/299] Fix link translation of --- htdocs/website/index.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 2a3279631f2..f34b629b733 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1398,7 +1398,7 @@ if ($action == 'updatemeta') $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); - $objectpage->fk_page = GETPOST('pageidfortranslation', 'int'); + $objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0); $newdatecreation = dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int')); if ($newdatecreation) $objectpage->date_creation = $newdatecreation; @@ -3061,10 +3061,9 @@ if ($action == 'editmeta' || $action == 'createcontainer') } elseif ($result > 0) { - $translationof = 0; - //$translationof = $sourcepage->id; + $translationof = $objectpage->fk_page; print ''.$langs->trans('ThisPageIsTranslationOf').' '; - print $formwebsite->selectContainer($website, 'pageidfortranslation', $translationof, 1, $action, 'minwidth300'); + print $formwebsite->selectContainer($website, 'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action, 'minwidth300', array($objectpage->id)); } } print '
        \n"; @@ -823,7 +823,7 @@ if ($rowid > 0) print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 70191b5eb28..1ca019f5988 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -391,11 +391,11 @@ if ($action == 'create') // Other attributes $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; print "\n"; @@ -606,7 +606,7 @@ if ($rowid > 0) print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 3578e0e0c60..d252171b38f 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -278,7 +278,7 @@ if ($user->rights->categorie->creer) print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index a45ca818dbc..9c653decdff 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -180,7 +180,7 @@ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index fa0e9c78de2..73408beefb0 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1115,7 +1115,7 @@ if ($action == 'create') print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; @@ -1519,7 +1519,7 @@ if ($id > 0) print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index a2d8c0a373b..8deb8100c72 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1242,7 +1242,7 @@ else print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f949e118599..803d699077f 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1771,7 +1771,7 @@ if ($action == 'create' && $usercancreate) } }; - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } // Template to use by default diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 3baf50fcc2c..7e14516e4cd 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -443,7 +443,7 @@ if ($action == 'create') print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; @@ -945,7 +945,7 @@ else print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index c80a0cd0ab8..ab93b2f0f97 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -344,8 +344,6 @@ if ($action == 'create') $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print ''; - // Category if (is_array($options) && count($options) && $conf->categorie->enabled) { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 48cd8e81054..b6997922e2a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3282,11 +3282,11 @@ if ($action == 'create') } // Other attributes - $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="2"', 'cols'=>2); + $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="2"', 'cols' => '2'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } // Template to use by default diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 741d106ab48..391bdb64bcb 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -829,7 +829,7 @@ else print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print "
        "; @@ -1162,12 +1162,12 @@ else } // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols'=>3); + $parameters = array('colspan' => ' colspan="3"', 'cols'=> '3'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } $object->load_ref_elements(); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 724a19bdbb8..8336ce11e17 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1265,13 +1265,13 @@ if ($action == 'create') } // Other attributes - $parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"', 'cols'=>3); + $parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"', 'cols' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Other attributes if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print "\n"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8aa24819efd..360ac2f019d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6614,10 +6614,19 @@ abstract class CommonObject // Load language if required if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); - $colspan = '3'; + $colspan = ''; if (is_array($params) && count($params) > 0) { - if (array_key_exists('colspan', $params)) { - $colspan = $params['colspan']; + if (array_key_exists('cols', $params)) { + $colspan = $params['cols']; + } + elseif (array_key_exists('colspan', $params)) { // For backward compatibility. Use cols instead now. + $reg = array(); + if (preg_match('/colspan="(\d+)"/', $params['colspan'], $reg)) { + $colspan = $reg[1]; + } + else { + $colspan = $params['colspan']; + } } } @@ -6659,7 +6668,7 @@ abstract class CommonObject } } - $out .= $extrafields->showSeparator($key, $this); + $out .= $extrafields->showSeparator($key, $this, ($colspan + 1)); } else { @@ -6679,9 +6688,9 @@ abstract class CommonObject $domData .= ' data-targetelement="'.$this->element.'"'; $domData .= ' data-targetid="'.$this->id.'"'; - $html_id = !empty($this->id) ? 'extrarow-'.$this->element.'_'.$key.'_'.$this->id : ''; + $html_id = (empty($this->id) ? '' : 'extrarow-'.$this->element.'_'.$key.'_'.$this->id); - $out .= ''; + $out .= ''; if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan = '0'; } @@ -6724,9 +6733,8 @@ abstract class CommonObject $out .= ''; $html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : ''; - - $out .= ''; - //$out .=''; + + $out .= ''; switch ($mode) { case "view": diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 81dffc51b67..889a38efddb 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1957,13 +1957,14 @@ class ExtraFields * * @param string $key Key of attribute * @param string $object Object + * @param int $colspan Value of colspan to use (it must includes the first column with title) * @return string HTML code with line for separator */ - public function showSeparator($key, $object) + public function showSeparator($key, $object, $colspan = 2) { global $langs; - $out = ''; + $out = ''; $out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]); $out .= ''; diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 223661bf280..e20db4be2d2 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -455,7 +455,7 @@ if ($action == 'create') print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; @@ -589,7 +589,7 @@ if (!empty($id) && $action == 'edit') print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print "\n"; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 02db386f236..3f7abd4b4e5 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1025,7 +1025,7 @@ if ($action == 'create') print "\n"; // Other attributes - $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); + $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3', 'socid' => $socid); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $expe, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -1034,7 +1034,7 @@ if ($action == 'create') if ($object->fetch_optionals() > 0) { $expe->array_options = array_merge($expe->array_options, $object->array_options); } - print $expe->showOptionals($extrafields, 'edit'); + print $expe->showOptionals($extrafields, 'edit', $parameters); } @@ -1994,7 +1994,7 @@ elseif ($id || $ref) } // Other attributes - $parameters = array('colspan' => ' colspan="3"'); + $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 5cb869c6817..b24259d797a 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1532,11 +1532,11 @@ if ($action == 'create') } // Other attributes - $parameters = array('colspan' => ' colspan="3"'); + $parameters = array('colspan' => ' colspan="3"', 'cols' => 3); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index eb5c959db7f..9371c6a308a 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -906,18 +906,17 @@ if ($action == 'create') print '
        '; print ''; + print ''; + print ''; dol_fiche_head(''); print ''; - print ''; print ''; - print ''; - // Ref - print ''; + print ''; // Description (must be a textarea and not html must be allowed (used in list view) print ''; @@ -963,15 +962,15 @@ if ($action == 'create') // Model print ''; print ''; - print '"; // Public note print ''; - print ''; - print ''; + print ''; print ''; - print ''; print ''; - print ''; - // Payment term - print ''; // Payment mode - print ''; @@ -1636,7 +1634,7 @@ if ($action == 'create') if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) { $langs->load("bank"); - print ''; } @@ -1647,10 +1645,9 @@ if ($action == 'create') $formproject = new FormProjets($db); $langs->load('projects'); - print ''; } @@ -1659,7 +1656,7 @@ if ($action == 'create') { print ''; print ''; - print ''; } @@ -1669,7 +1666,7 @@ if ($action == 'create') { print ''; print ''; - print ''; } @@ -1700,26 +1697,26 @@ if ($action == 'create') print ''; $newclassname = $classname; - print ''; - print ''; - print '"; + print ''; + print ''; + print '"; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE { - print '"; + print '"; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF { - print '"; + print '"; } - print '"; + print '"; if (!empty($conf->multicurrency->enabled)) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } } diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index 7927af38786..098b6b93710 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -336,22 +336,22 @@ if ($action == 'create' && !$error) { print '
        '.$langs->trans("ThirdParty").''.$soc->getNomUrl(1).'
        '.$langs->trans('Ref').''.$langs->trans("Draft").'
        '.$langs->trans('Ref').''.$langs->trans("Draft").'
        '.$langs->trans("Description").'
        '.$langs->trans("DefaultModel").''; + print ''; $liste = ModelePDFFicheinter::liste_modeles($db); print $form->selectarray('model', $liste, $conf->global->FICHEINTER_ADDON_PDF); print "
        '.$langs->trans('NotePublic').''; + print ''.$langs->trans('NotePublic').''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); //print ''; @@ -982,7 +981,7 @@ if ($action == 'create') { print '
        '.$langs->trans('NotePrivate').''; + print ''; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); //print ''; @@ -990,7 +989,7 @@ if ($action == 'create') } // Other attributes - $parameters = array('colspan' => ' colspan="2"'); + $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 9701f43d993..7e330635de8 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1610,15 +1610,13 @@ if ($action == 'create') print '
        '.$langs->trans('RefSupplier').'
        '.$langs->trans('PaymentConditionsShort').''; + print '
        '.$langs->trans('PaymentConditionsShort').''; $form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); print '
        '.$langs->trans('PaymentMode').''; + print '
        '.$langs->trans('PaymentMode').''; $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); print '
        '.$langs->trans('BankAccount').''; + print '
        '.$langs->trans('BankAccount').''; $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print '
        '.$langs->trans('Project').''; + print '
        '.$langs->trans('Project').''; $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1); print '   id).'">'.$langs->trans("AddProject").''; - print '
        '; + print ''; print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print '
        '.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; + print ''; print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print '
        '.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
        '.$langs->trans('AmountHT').''.price($objectsrc->total_ht).'
        '.$langs->trans('AmountVAT').''.price($objectsrc->total_tva)."
        '.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
        '.$langs->trans('AmountHT').''.price($objectsrc->total_ht).'
        '.$langs->trans('AmountVAT').''.price($objectsrc->total_tva)."
        '.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1)."
        '.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1)."
        '.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2)."
        '.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2)."
        '.$langs->trans('AmountTTC').''.price($objectsrc->total_ttc)."
        '.$langs->trans('AmountTTC').''.price($objectsrc->total_ttc)."
        '.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
        '.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva).'
        '.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc).'
        '.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
        '.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva).'
        '.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc).'
        '; // Ref - print ''; + print ''; // Ref supplier print ''; print ''; // Date invoice - print ''; // Payment term - print ''; // Payment mode - print ''; // Project @@ -359,7 +359,7 @@ if ($action == 'create' && !$error) { $formproject = new FormProjets($db); $langs->load('projects'); - print ''; } @@ -367,9 +367,7 @@ if ($action == 'create' && !$error) { // Other attributes $parameters = array( 'objectsrc' => $objectsrc, - 'idsrc' => $listoforders, - 'colspan' => ' colspan="2"', - 'cols'=>2 + 'idsrc' => $listoforders ); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -390,7 +388,7 @@ if ($action == 'create' && !$error) { // Public note print ''; print ''; - print ''; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index a5793cc66c8..8fccf28c472 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1146,7 +1146,7 @@ else } // Other attributes - $parameters = array('colspan' => 3); + $parameters = array('colspan' => 3, 'cols' => '3'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 2fd5f950e4d..6609d6c3968 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1274,7 +1274,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) print ''; print ''; - $parameters = array('colspan' => 2); + $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print '
        '.$langs->trans('Ref').''.$langs->trans('Draft').'
        '.$langs->trans('Ref').''.$langs->trans('Draft').'
        '.$langs->trans('RefSupplier').'
        '.$langs->trans('Date').''; + print '
        '.$langs->trans('Date').''; print $html->selectDate('', '', '', '', '', "add", 1, 1); print '
        '.$langs->trans('PaymentConditionsShort').''; + print '
        '.$langs->trans('PaymentConditionsShort').''; $html->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); print '
        '.$langs->trans('PaymentMode').''; + print '
        '.$langs->trans('PaymentMode').''; $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); print '
        '.$langs->trans('Project').''; + print '
        '.$langs->trans('Project').''; $formproject->select_projects($soc->id, $projectid, 'projectid'); print '
        '.$langs->trans('NotePublic').''; + print ''; print '
        '; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 6f8c5648275..034e0076f09 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -721,12 +721,12 @@ else print ''; // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols'=>3); + $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } // Tags-Categories if ($conf->categorie->enabled) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index d76ee06ab5a..d4c0130ce84 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -864,7 +864,7 @@ if ($action == 'create') print "\n"; // Other attributes - $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); + $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3', 'socid'=>$socid); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -875,7 +875,7 @@ if ($action == 'create') if ($object->fetch_optionals() > 0) { $recept->array_options = array_merge($recept->array_options, $object->array_options); } - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } // Incoterms diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index cfd3e7f8b95..0793282cd86 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1536,12 +1536,12 @@ else } // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); + $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } // Assign a sale representative @@ -2200,12 +2200,12 @@ else } // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); + $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } // Webservices url/key diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index adb39743af7..584fcd0f4a5 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1244,11 +1244,11 @@ if ($action == 'create') } // Other attributes - $parameters = array('colspan' => ' colspan="3"'); + $parameters = array('colspan' => ' colspan="3"', 'cols' => 3); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 54a1b7dce88..ff0c74dad69 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -304,7 +304,7 @@ if ($action == 'create') print "\n"; // Other attributes - $parameters = array('object' => $object, 'colspan' => ' colspan="2"'); + $parameters = array('object' => $object); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) From e7276f9044a2e052aca6758f72a52a5a46fc2c9e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Nov 2019 23:22:28 +0100 Subject: [PATCH 291/299] Fix scrutinizer error --- htdocs/user/class/api_users.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index a7d98ca0b2d..27682262d59 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -190,10 +190,9 @@ class Users extends DolibarrApi throw new RestException(404, 'User group not found'); } - $this->useraccount = $this->_cleanObjectDatas($this->useraccount); $this->useraccount->user_group_list = $this->_cleanUserGroupListDatas($userGroupList); - return $this->useraccount; + return $this->_cleanObjectDatas($this->useraccount); } /** From 1648fc142e97cfca0a5a8a5158b01959ca906203 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Sat, 16 Nov 2019 22:24:29 +0000 Subject: [PATCH 292/299] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- .../adherents/class/adherent_type.class.php | 260 ++++----- .../categories/class/api_categories.class.php | 134 ++--- htdocs/categories/class/categorie.class.php | 18 +- htdocs/contrat/card.php | 200 +++---- htdocs/core/class/commonobject.class.php | 528 +++++++++--------- htdocs/core/class/conf.class.php | 372 ++++++------ htdocs/core/class/html.formwebsite.class.php | 82 +-- htdocs/core/class/menubase.class.php | 374 ++++++------- htdocs/core/photos_resize.php | 168 +++--- .../societe/class/api_thirdparties.class.php | 30 +- htdocs/user/class/api_users.class.php | 50 +- 11 files changed, 1108 insertions(+), 1108 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 5006becb053..442d8cf091f 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -99,9 +99,9 @@ class AdherentType extends CommonObject public $mail_valid; /** @var array Array of members */ - public $members=array(); + public $members = array(); - public $multilangs=array(); + public $multilangs = array(); /** @@ -127,8 +127,8 @@ class AdherentType extends CommonObject $current_lang = $langs->getDefaultLang(); $sql = "SELECT lang, label, description, email"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql.= " WHERE fk_type=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; $result = $this->db->query($sql); if ($result) { @@ -138,7 +138,7 @@ class AdherentType extends CommonObject if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. { $this->label = $obj->label; - $this->description = $obj->description; + $this->description = $obj->description; $this->email = $obj->email; } $this->multilangs["$obj->lang"]["label"] = $obj->label; @@ -149,7 +149,7 @@ class AdherentType extends CommonObject } else { - $this->error="Error: ".$this->db->lasterror()." - ".$sql; + $this->error = "Error: ".$this->db->lasterror()." - ".$sql; return -1; } } @@ -171,75 +171,75 @@ class AdherentType extends CommonObject { if ($key == $current_lang) { $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql.= " WHERE fk_type=".$this->id; - $sql.= " AND lang='".$key."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; + $sql .= " AND lang='".$key."'"; $result = $this->db->query($sql); if ($this->db->num_rows($result)) // if there is already a description line for this language { $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql2.= " SET "; - $sql2.= " label='".$this->db->escape($this->label)."',"; - $sql2.= " description='".$this->db->escape($this->description)."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->other)."'"; + $sql2 .= " SET "; + $sql2 .= " label='".$this->db->escape($this->label)."',"; + $sql2 .= " description='".$this->db->escape($this->description)."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email='".$this->db->escape($this->other)."'"; } - $sql2.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; + $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", email"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email"; } - $sql2.= ")"; - $sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->label)."',"; - $sql2.= " '".$this->db->escape($this->description)."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->other)."'"; + $sql2 .= ")"; + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',"; + $sql2 .= " '".$this->db->escape($this->description)."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->other)."'"; } - $sql2.= ")"; + $sql2 .= ")"; } dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key); - if (! $this->db->query($sql2)) { - $this->error=$this->db->lasterror(); + if (!$this->db->query($sql2)) { + $this->error = $this->db->lasterror(); return -1; } } elseif (isset($this->multilangs[$key])) { $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql.= " WHERE fk_type=".$this->id; - $sql.= " AND lang='".$key."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; + $sql .= " AND lang='".$key."'"; $result = $this->db->query($sql); if ($this->db->num_rows($result)) // if there is already a description line for this language { $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql2.= " SET "; - $sql2.= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->multilangs["$key"]["other"])."'"; + $sql2 .= " SET "; + $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email='".$this->db->escape($this->multilangs["$key"]["other"])."'"; } - $sql2.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; + $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", email"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email"; } - $sql2.= ")"; - $sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2.= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; + $sql2 .= ")"; + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; } - $sql2.= ")"; + $sql2 .= ")"; } // We do not save if main fields are empty if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) { - if (! $this->db->query($sql2)) { - $this->error=$this->db->lasterror(); + if (!$this->db->query($sql2)) { + $this->error = $this->db->lasterror(); return -1; } } @@ -272,7 +272,7 @@ class AdherentType extends CommonObject public function delMultiLangs($langtodelete, $user) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; + $sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG); $result = $this->db->query($sql); @@ -289,7 +289,7 @@ class AdherentType extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); return -1; } @@ -306,22 +306,22 @@ class AdherentType extends CommonObject { global $langs, $conf; - $error=0; + $error = 0; - $this->statut=(int) $this->statut; - $this->label=trim($this->label); + $this->statut = (int) $this->statut; + $this->label = trim($this->label); $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type ("; - $sql.= " morphy"; - $sql.= ", libelle"; - $sql.= ", entity"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->morphy)."'"; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", ".$conf->entity; - $sql.= ")"; + $sql .= " morphy"; + $sql .= ", libelle"; + $sql .= ", entity"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->morphy)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", ".$conf->entity; + $sql .= ")"; dol_syslog("Adherent_type::create", LOG_DEBUG); $result = $this->db->query($sql); @@ -336,15 +336,15 @@ class AdherentType extends CommonObject return -3; } - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_TYPE_CREATE', $user); + $result = $this->call_trigger('MEMBER_TYPE_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -358,7 +358,7 @@ class AdherentType extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -375,23 +375,23 @@ class AdherentType extends CommonObject { global $langs, $conf, $hookmanager; - $error=0; + $error = 0; - $this->label=trim($this->label); + $this->label = trim($this->label); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type "; - $sql.= "SET "; - $sql.= "statut = ".$this->statut.","; - $sql.= "libelle = '".$this->db->escape($this->label) ."',"; - $sql.= "morphy = '".$this->db->escape($this->morphy) ."',"; - $sql.= "subscription = '".$this->db->escape($this->subscription)."',"; - $sql.= "duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) ."',"; - $sql.= "note = '".$this->db->escape($this->note)."',"; - $sql.= "vote = ".(integer) $this->db->escape($this->vote).","; - $sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'"; - $sql.= " WHERE rowid =".$this->id; + $sql .= "SET "; + $sql .= "statut = ".$this->statut.","; + $sql .= "libelle = '".$this->db->escape($this->label)."',"; + $sql .= "morphy = '".$this->db->escape($this->morphy)."',"; + $sql .= "subscription = '".$this->db->escape($this->subscription)."',"; + $sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',"; + $sql .= "note = '".$this->db->escape($this->note)."',"; + $sql .= "vote = ".(integer) $this->db->escape($this->vote).","; + $sql .= "mail_valid = '".$this->db->escape($this->mail_valid)."'"; + $sql .= " WHERE rowid =".$this->id; $result = $this->db->query($sql); if ($result) @@ -399,34 +399,34 @@ class AdherentType extends CommonObject $this->description = $this->db->escape($this->note); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { if ($this->setMultiLangs($user) < 0) { - $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; return -2; } } - $action='update'; + $action = 'update'; // Actions on extra fields - 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->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_TYPE_MODIFY', $user); + $result = $this->call_trigger('MEMBER_TYPE_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -440,7 +440,7 @@ class AdherentType extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -458,13 +458,13 @@ class AdherentType extends CommonObject $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('MEMBER_TYPE_DELETE', $user); + $result = $this->call_trigger('MEMBER_TYPE_DELETE', $user); if ($result < 0) { $error++; $this->db->rollback(); return -2; } // End call triggers @@ -474,7 +474,7 @@ class AdherentType extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -495,7 +495,7 @@ class AdherentType extends CommonObject dol_syslog("Adherent_type::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -506,10 +506,10 @@ class AdherentType extends CommonObject $this->ref = $obj->rowid; $this->label = $obj->label; $this->morphy = $obj->morphy; - $this->statut = $obj->status; // deprecated + $this->statut = $obj->status; // deprecated $this->status = $obj->status; $this->duration = $obj->duration; - $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1); + $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); $this->duration_unit = substr($obj->duration, -1); $this->subscription = $obj->subscription; $this->mail_valid = $obj->mail_valid; @@ -517,7 +517,7 @@ class AdherentType extends CommonObject $this->vote = $obj->vote; // multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $this->getMultiLangs(); } } @@ -526,7 +526,7 @@ class AdherentType extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -540,15 +540,15 @@ class AdherentType extends CommonObject public function liste_array() { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $adherenttypes = array(); $sql = "SELECT rowid, libelle as label"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql.= " WHERE entity IN (".getEntity('member_type').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type"; + $sql .= " WHERE entity IN (".getEntity('member_type').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $nump = $this->db->num_rows($resql); @@ -585,13 +585,13 @@ class AdherentType extends CommonObject { global $conf, $user; - $ret=array(); + $ret = array(); $sql = "SELECT a.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; - $sql.= " WHERE a.entity IN (".getEntity('member').")"; - $sql.= " AND a.fk_adherent_type = ".$this->id; - if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')'; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; + $sql .= " WHERE a.entity IN (".getEntity('member').")"; + $sql .= " AND a.fk_adherent_type = ".$this->id; + if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')'; dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG); $resql = $this->db->query($sql); @@ -599,31 +599,31 @@ class AdherentType extends CommonObject { while ($obj = $this->db->fetch_object($resql)) { - if (! array_key_exists($obj->rowid, $ret)) + if (!array_key_exists($obj->rowid, $ret)) { if ($mode < 2) { - $memberstatic=new Adherent($this->db); + $memberstatic = new Adherent($this->db); if ($mode == 1) { $memberstatic->fetch($obj->rowid, '', '', '', false, false); } else { $memberstatic->fetch($obj->rowid); } - $ret[$obj->rowid]=$memberstatic; + $ret[$obj->rowid] = $memberstatic; } - else $ret[$obj->rowid]=$obj->rowid; + else $ret[$obj->rowid] = $obj->rowid; } } $this->db->free($resql); - $this->members=$ret; + $this->members = $ret; return $ret; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -655,15 +655,15 @@ class AdherentType extends CommonObject { global $langs; - $result=''; - $label=$langs->trans("ShowTypeCard", $this->label); + $result = ''; + $label = $langs->trans("ShowTypeCard", $this->label); $linkstart = '
        '; - $linkend=''; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label, $maxlen):$this->label); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); $result .= $linkend; return $result; @@ -723,10 +723,10 @@ class AdherentType extends CommonObject { // phpcs:enable global $conf; - $dn=''; - if ($mode==0) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN; - if ($mode==1) $dn=$conf->global->LDAP_MEMBER_TYPE_DN; - if ($mode==2) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES]; + $dn = ''; + if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN; + if ($mode == 1) $dn = $conf->global->LDAP_MEMBER_TYPE_DN; + if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES]; return $dn; } @@ -741,27 +741,27 @@ class AdherentType extends CommonObject public function _load_ldap_info() { // phpcs:enable - global $conf,$langs; + global $conf, $langs; - $info=array(); + $info = array(); // Object classes - $info["objectclass"]=explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS); + $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS); // Champs - if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label; - if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1); - if (! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) + if ($this->label && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label; + if ($this->note && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1); + if (!empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) { - $valueofldapfield=array(); - foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database. + $valueofldapfield = array(); + foreach ($this->members as $key=>$val) // This is array of users for group into dolibarr database. { - $member=new Adherent($this->db); + $member = new Adherent($this->db); $member->fetch($val->id, '', '', '', false, false); $info2 = $member->_load_ldap_info(); $valueofldapfield[] = $member->_load_ldap_dn($info2); } - $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:''); + $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield) ? $valueofldapfield : ''); } return $info; } @@ -780,18 +780,18 @@ class AdherentType extends CommonObject // Initialise parametres $this->id = 0; $this->ref = 'MTSPEC'; - $this->specimen=1; + $this->specimen = 1; - $this->label='MEMBERS TYPE SPECIMEN'; - $this->note='This is a note'; - $this->mail_valid='This is welcome email'; - $this->subscription=1; - $this->vote=0; + $this->label = 'MEMBERS TYPE SPECIMEN'; + $this->note = 'This is a note'; + $this->mail_valid = 'This is welcome email'; + $this->subscription = 1; + $this->vote = 0; - $this->statut=1; + $this->statut = 1; // Members of this member type is just me - $this->members=array( + $this->members = array( $user->id => $user ); } @@ -805,7 +805,7 @@ class AdherentType extends CommonObject { global $conf; - if (! empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) + if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) { return $this->mail_valid; } @@ -823,7 +823,7 @@ class AdherentType extends CommonObject global $conf; // mail_subscription not defined so never used - if (! empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined + if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined { return $this->mail_subscription; } @@ -841,7 +841,7 @@ class AdherentType extends CommonObject global $conf; // NOTE mail_resiliate not defined so never used - if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined + if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined { return $this->mail_resiliate; } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index e916255f7b5..459b61ba740 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -78,16 +78,16 @@ class Categories extends DolibarrApi */ public function get($id, $include_childs = false) { - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->category->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if ( ! DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { + if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -126,50 +126,50 @@ class Categories extends DolibarrApi $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $sql = "SELECT t.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('category').')'; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as t"; + $sql .= ' WHERE t.entity IN ('.getEntity('category').')'; if (!empty($type)) { - $sql.= ' AND t.type='.array_search($type, Categories::$TYPES); + $sql .= ' AND t.type='.array_search($type, Categories::$TYPES); } // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $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) { $obj = $db->fetch_object($result); $category_static = new Categorie($db); - if($category_static->fetch($obj->rowid)) { + if ($category_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($category_static); } $i++; @@ -178,7 +178,7 @@ class Categories extends DolibarrApi else { throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No category found'); } return $obj_ret; @@ -192,14 +192,14 @@ class Categories extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->categorie->creer) { + if (!DolibarrApiAccess::$user->rights->categorie->creer) { throw new RestException(401); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->category->$field = $value; } if ($this->category->create(DolibarrApiAccess::$user) < 0) { @@ -217,20 +217,20 @@ class Categories extends DolibarrApi */ public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->categorie->creer) { + if (!DolibarrApiAccess::$user->rights->categorie->creer) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if ( ! DolibarrApi::_checkAccessToResource('category', $this->category->id)) { + 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) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->category->$field = $value; } @@ -253,19 +253,19 @@ class Categories extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->categorie->supprimer) { + if (!DolibarrApiAccess::$user->rights->categorie->supprimer) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if ( ! DolibarrApi::_checkAccessToResource('category', $this->category->id)) { + 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)) { + if (!$this->category->delete(DolibarrApiAccess::$user)) { throw new RestException(401, 'error when delete category'); } @@ -306,21 +306,21 @@ class Categories extends DolibarrApi throw new RestException(401); } - if($type == Categorie::TYPE_PRODUCT && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if ($type == Categorie::TYPE_PRODUCT && !(DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_CONTACT && ! DolibarrApiAccess::$user->rights->contact->lire) { + } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_CUSTOMER && ! DolibarrApiAccess::$user->rights->societe->lire) { + } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_SUPPLIER && ! DolibarrApiAccess::$user->rights->fournisseur->lire) { + } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->rights->fournisseur->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_MEMBER && ! DolibarrApiAccess::$user->rights->adherent->lire) { + } elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); - if( ! is_array($categories)) { + if (!is_array($categories)) { if ($categories == 0) { throw new RestException(404, 'No category found for this object'); } @@ -347,37 +347,37 @@ class Categories extends DolibarrApi throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } if ($type === Categorie::TYPE_PRODUCT) { - if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { throw new RestException(401); } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if(! DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); } $object = new Adherent($this->db); @@ -388,7 +388,7 @@ class Categories extends DolibarrApi if (!empty($object)) { $result = $object->fetch($object_id); if ($result > 0) { - $result=$this->category->add_type($object, $type); + $result = $this->category->add_type($object, $type); if ($result < 0) { if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); @@ -427,37 +427,37 @@ class Categories extends DolibarrApi throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } if ($type === Categorie::TYPE_PRODUCT) { - if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { throw new RestException(401); } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if(! DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); } $object = new Adherent($this->db); @@ -468,7 +468,7 @@ class Categories extends DolibarrApi if (!empty($object)) { $result = $object->fetch('', $object_ref); if ($result > 0) { - $result=$this->category->add_type($object, $type); + $result = $this->category->add_type($object, $type); if ($result < 0) { if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); @@ -507,37 +507,37 @@ class Categories extends DolibarrApi throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } if ($type === Categorie::TYPE_PRODUCT) { - if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { throw new RestException(401); } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if(! DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); } $object = new Adherent($this->db); @@ -548,7 +548,7 @@ class Categories extends DolibarrApi if (!empty($object)) { $result = $object->fetch((int) $object_id); if ($result > 0) { - $result=$this->category->del_type($object, $type); + $result = $this->category->del_type($object, $type); if ($result < 0) { throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); } @@ -585,37 +585,37 @@ class Categories extends DolibarrApi throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } if ($type === Categorie::TYPE_PRODUCT) { - if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { throw new RestException(401); } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if(! DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); } $object = new Adherent($this->db); @@ -626,7 +626,7 @@ class Categories extends DolibarrApi if (!empty($object)) { $result = $object->fetch('', (string) $object_ref); if ($result > 0) { - $result=$this->category->del_type($object, $type); + $result = $this->category->del_type($object, $type); if ($result < 0) { throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); } @@ -736,7 +736,7 @@ class Categories extends DolibarrApi { dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG); - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } @@ -746,11 +746,11 @@ class Categories extends DolibarrApi } $result = $this->category->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'category not found'); } - if (! DolibarrApi::_checkAccessToResource('category', $this->category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 6bbc0afcb1c..67cd2a4f5e0 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -781,18 +781,18 @@ class Categorie extends CommonObject $objs = array(); - $obj = new $this->MAP_OBJ_CLASS[$type]( $this->db ); + $obj = new $this->MAP_OBJ_CLASS[$type]($this->db); - $sql = "SELECT c.fk_" . $this->MAP_CAT_FK[$type]; - $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as c"; - $sql .= ", " . MAIN_DB_PREFIX . $this->MAP_OBJ_TABLE[$type] . " as o"; - $sql .= " WHERE o.entity IN (" . getEntity($obj->element).")"; + $sql = "SELECT c.fk_".$this->MAP_CAT_FK[$type]; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]." as c"; + $sql .= ", ".MAIN_DB_PREFIX.$this->MAP_OBJ_TABLE[$type]." as o"; + $sql .= " WHERE o.entity IN (".getEntity($obj->element).")"; $sql .= " AND c.fk_categorie = ".$this->id; - $sql .= " AND c.fk_" . $this->MAP_CAT_FK[$type] . " = o.rowid"; + $sql .= " AND c.fk_".$this->MAP_CAT_FK[$type]." = o.rowid"; // Protection for external users if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) { - $sql.= " AND o.rowid = ".$user->socid; + $sql .= " AND o.rowid = ".$user->socid; } if ($limit > 0 || $offset > 0) $sql .= $this->db->plimit($limit + 1, $offset); $sql .= $this->db->order($sortfield, $sortorder); @@ -929,7 +929,7 @@ class Categorie extends CommonObject $categories[$i]['description'] = $category_static->description; $categories[$i]['color'] = $category_static->color; $categories[$i]['socid'] = $category_static->socid; - $categories[$i]['ref_ext'] = $category_static->ref_ext; + $categories[$i]['ref_ext'] = $category_static->ref_ext; $categories[$i]['visible'] = $category_static->visible; $categories[$i]['type'] = $category_static->type; $categories[$i]['entity'] = $category_static->entity; @@ -1569,7 +1569,7 @@ class Categorie extends CommonObject $sql .= " AND rowid = '".$id."'"; } - $res = $this->db->query($sql); + $res = $this->db->query($sql); if ($res) { while ($rec = $this->db->fetch_array($res)) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 8336ce11e17..efd521e9ec0 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -40,39 +40,39 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->projet->enabled)) { +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->loadLangs(array("contracts","orders","companies","bills","products",'compta')); +$langs->loadLangs(array("contracts", "orders", "companies", "bills", "products", 'compta')); -$action=GETPOST('action', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); $socid = GETPOST('socid', 'int'); $id = GETPOST('id', 'int'); -$ref=GETPOST('ref', 'alpha'); -$origin=GETPOST('origin', 'alpha'); -$originid=GETPOST('originid', 'int'); +$ref = GETPOST('ref', 'alpha'); +$origin = GETPOST('origin', 'alpha'); +$originid = GETPOST('originid', 'int'); -$datecontrat=''; -$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0); +$datecontrat = ''; +$usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0); // Security check -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'contrat', $id); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'contrat', $id); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('contractcard','globalcard')); +$hookmanager->initHooks(array('contractcard', 'globalcard')); $object = new Contrat($db); $extrafields = new ExtraFields($db); // Load object -if ($id > 0 || ! empty($ref) && $action!='add') { +if ($id > 0 || !empty($ref) && $action != 'add') { $ret = $object->fetch($id, $ref); if ($ret > 0) $ret = $object->fetch_thirdparty(); @@ -444,8 +444,8 @@ if (empty($reshook)) $error++; } - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) { setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); @@ -528,46 +528,46 @@ if (empty($reshook)) { if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat/100)), 'MU'); + $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } else { - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat/100)), 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } } - $desc=$prod->description; - $desc=dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + $desc = $prod->description; + $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $fk_unit = $prod->fk_unit; } else { - $pu_ht=GETPOST('price_ht'); + $pu_ht = GETPOST('price_ht'); $price_base_type = 'HT'; - $tva_tx=GETPOST('tva_tx')?str_replace('*', '', GETPOST('tva_tx')):0; // tva_tx field may be disabled, so we use vat rate 0 - $tva_npr=preg_match('/\*/', GETPOST('tva_tx'))?1:0; - $desc=$product_desc; - $fk_unit= GETPOST('units', 'alpha'); + $tva_tx = GETPOST('tva_tx') ?str_replace('*', '', GETPOST('tva_tx')) : 0; // tva_tx field may be disabled, so we use vat rate 0 + $tva_npr = preg_match('/\*/', GETPOST('tva_tx')) ? 1 : 0; + $desc = $product_desc; + $fk_unit = GETPOST('units', 'alpha'); } - $localtax1_tx=get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); - $localtax2_tx=get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); + $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); // ajout prix achat $fk_fournprice = $_POST['fournprice']; - if ( ! empty($_POST['buying_price']) ) + if (!empty($_POST['buying_price'])) $pa_ht = $_POST['buying_price']; else $pa_ht = null; - $info_bits=0; + $info_bits = 0; if ($tva_npr) $info_bits |= 0x01; - if (((! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) - || empty($conf->global->MAIN_USE_ADVANCED_PERMS) ) && ($price_min && (price2num($pu_ht)*(1-price2num($remise_percent)/100) < price2num($price_min)))) + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) + || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { $object->error = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); - $result = -1 ; + $result = -1; } else { @@ -1239,34 +1239,34 @@ if ($action == 'create') print ""; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load('projects'); - $formproject=new FormProjets($db); + $formproject = new FormProjets($db); print ''.$langs->trans("Project").''; - $formproject->select_projects(($soc->id>0?$soc->id:-1), $projectid, "projectid", 0, 0, 1, 1); - print '   id).'">' . $langs->trans("AddProject") . ''; + $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, "projectid", 0, 0, 1, 1); + print '   id).'">'.$langs->trans("AddProject").''; print ""; } print ''.$langs->trans("NotePublic").''; - $doleditor=new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; if (empty($user->socid)) { print ''.$langs->trans("NotePrivate").''; - $doleditor=new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; } // Other attributes - $parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"', 'cols' => '3'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Other attributes @@ -1389,62 +1389,62 @@ else // Contract card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref=''; - if (! empty($modCodeContract->code_auto)) { - $morehtmlref.=$object->ref; + $morehtmlref = ''; + if (!empty($modCodeContract->code_auto)) { + $morehtmlref .= $object->ref; } else { - $morehtmlref.=$form->editfieldkey("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 3); - $morehtmlref.=$form->editfieldval("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 2); + $morehtmlref .= $form->editfieldkey("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 3); + $morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 2); } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); // Ref supplier - $morehtmlref.='
        '; - $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); + $morehtmlref .= '
        '; + $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); // Thirdparty - $morehtmlref.='
        '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherContracts").')'; + $morehtmlref .= '
        '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
        '.$langs->trans('Project') . ' '; + $morehtmlref .= '
        '.$langs->trans('Project').' '; if ($user->rights->contrat->creer) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
        '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
        '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); @@ -1619,7 +1619,7 @@ else // Quantity print ''.$objp->qty.''; // Unit - if($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans($object->lines[$cursorline-1]->getLabelOfUnit()).''; + if ($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).''; // Discount if ($objp->remise_percent > 0) { @@ -1717,32 +1717,32 @@ else print ''; if ($objp->fk_product) { - $productstatic->id=$objp->fk_product; - $productstatic->type=$objp->ptype; - $productstatic->ref=$objp->pref; - $productstatic->entity=$objp->pentity; + $productstatic->id = $objp->fk_product; + $productstatic->type = $objp->ptype; + $productstatic->ref = $objp->pref; + $productstatic->entity = $objp->pentity; print $productstatic->getNomUrl(1, '', 32); - print $objp->label?' - '.dol_trunc($objp->label, 32):''; + print $objp->label ? ' - '.dol_trunc($objp->label, 32) : ''; print '
        '; } else { - print $objp->label?$objp->label.'
        ':''; + print $objp->label ? $objp->label.'
        ' : ''; } // editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); - $doleditor=new DolEditor('product_desc', $objp->description, '', 92, 'dolibarr_details', '', false, true, $enable, $nbrows, '90%'); + $nbrows = ROWS_2; + if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; + $enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0); + $doleditor = new DolEditor('product_desc', $objp->description, '', 92, 'dolibarr_details', '', false, true, $enable, $nbrows, '90%'); $doleditor->Create(); print ''; // VAT print ''; - print $form->load_tva("eltva_tx", $objp->tva_tx.($objp->vat_src_code?(' ('.$objp->vat_src_code.')'):''), $mysoc, $object->thirdparty, $objp->fk_product, $objp->info_bits, $objp->product_type, 0, 1); + print $form->load_tva("eltva_tx", $objp->tva_tx.($objp->vat_src_code ? (' ('.$objp->vat_src_code.')') : ''), $mysoc, $object->thirdparty, $objp->fk_product, $objp->info_bits, $objp->product_type, 0, 1); print ''; // Price @@ -1767,7 +1767,7 @@ else // Discount print '%'; - if (! empty($usemargins)) + if (!empty($usemargins)) { print ''; if ($objp->fk_product) print ''; @@ -1885,27 +1885,27 @@ else // Area with status and activation info of line if ($object->statut > 0) { - print ''; + print '
        '; print ''; - print ''; + print ''; print '
        '.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).''.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline - 1]->getLibStatut(4).''; if ($user->socid == 0) { if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline') { - $tmpaction='activateline'; - $tmpactionpicto='play'; - $tmpactiontext=$langs->trans("Activate"); + $tmpaction = 'activateline'; + $tmpactionpicto = 'play'; + $tmpactiontext = $langs->trans("Activate"); if ($objp->statut == 4) { - $tmpaction='unactivateline'; - $tmpactionpicto='playstop'; - $tmpactiontext=$langs->trans("Disable"); + $tmpaction = 'unactivateline'; + $tmpactionpicto = 'playstop'; + $tmpactiontext = $langs->trans("Disable"); } - if (($tmpaction=='activateline' && $user->rights->contrat->activer) || ($tmpaction=='unactivateline' && $user->rights->contrat->desactiver)) + if (($tmpaction == 'activateline' && $user->rights->contrat->activer) || ($tmpaction == 'unactivateline' && $user->rights->contrat->desactiver)) { - print ''; + print ''; print img_picto($tmpactiontext, $tmpactionpicto); print ''; } @@ -2060,24 +2060,24 @@ else // Form to add new line if ($user->rights->contrat->creer && ($object->statut == 0)) { - $dateSelector=1; + $dateSelector = 1; print "\n"; - print '
        + print ' - + '; print '
        '; - print ''; // Array with (n*2)+1 lines + print '
        '; // Array with (n*2)+1 lines // Form to add new line if ($action != 'editline') { - $forcetoshowtitlelines=1; - if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts + $forcetoshowtitlelines = 1; + if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts // Add free products/services $object->formAddObjectLine(1, $mysoc, $soc); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 360ac2f019d..a70cf20503a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -429,12 +429,12 @@ abstract class CommonObject /** * @var integer|string $date_validation; */ - public $date_validation; // Date validation + public $date_validation; // Date validation /** * @var integer|string $date_modification; */ - public $date_modification; // Date last change (tms field) + public $date_modification; // Date last change (tms field) public $next_prev_filter; @@ -574,7 +574,7 @@ abstract class CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $tmparray = getCountry($this->country_id, 'all'); $this->country_code = $tmparray['code']; - $this->country = $tmparray['label']; + $this->country = $tmparray['label']; } if ($withregion && $this->state_id && (empty($this->state_code) || empty($this->state) || empty($this->region) || empty($this->region_cpde))) @@ -602,123 +602,123 @@ abstract class CommonObject { global $conf, $langs; - $countriesusingstate=array('AU','US','IN','GB','ES','UK','TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS + $countriesusingstate = array('AU', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS - $contactid=0; - $thirdpartyid=0; + $contactid = 0; + $thirdpartyid = 0; if ($this->element == 'societe') { - $thirdpartyid=$this->id; + $thirdpartyid = $this->id; } if ($this->element == 'contact') { - $contactid=$this->id; - $thirdpartyid=$object->fk_soc; + $contactid = $this->id; + $thirdpartyid = $object->fk_soc; } if ($this->element == 'user') { - $contactid=$this->contact_id; - $thirdpartyid=$object->fk_soc; + $contactid = $this->contact_id; + $thirdpartyid = $object->fk_soc; } - $out=''; + $out = ''; - $outdone=0; + $outdone = 0; $coords = $this->getFullAddress(1, ', ', $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT); if ($coords) { - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { $namecoords = ''; - if ( $this->element == 'contact' && ! empty($conf->global->MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS)) + if ($this->element == 'contact' && !empty($conf->global->MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS)) { - $namecoords.= $object->name.'
        '; + $namecoords .= $object->name.'
        '; } - $namecoords.= $this->getFullName($langs, 1).'
        '.$coords; + $namecoords .= $this->getFullName($langs, 1).'
        '.$coords; // hideonsmatphone because copyToClipboard call jquery dialog that does not work with jmobile - $out.=''; - $out.=img_picto($langs->trans("Address"), 'object_address.png'); - $out.=' '; + $out .= ''; + $out .= img_picto($langs->trans("Address"), 'object_address.png'); + $out .= ' '; } - $out.=dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++; + $out .= dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++; $outdone++; } - if (! in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress + if (!in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) { if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) { - $out.=($outdone?' - ':'').$this->region.' - '.$this->state; + $out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state; } else { - $out.=($outdone?' - ':'').$this->state; + $out .= ($outdone ? ' - ' : '').$this->state; } $outdone++; } - if (! empty($this->phone) || ! empty($this->phone_pro) || ! empty($this->phone_mobile) || ! empty($this->phone_perso) || ! empty($this->fax) || ! empty($this->office_phone) || ! empty($this->user_mobile) || ! empty($this->office_fax)) $out.=($outdone?'
        ':''); - if (! empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone - $out.=dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; + if (!empty($this->phone) || !empty($this->phone_pro) || !empty($this->phone_mobile) || !empty($this->phone_perso) || !empty($this->fax) || !empty($this->office_phone) || !empty($this->user_mobile) || !empty($this->office_fax)) $out .= ($outdone ? '
        ' : ''); + if (!empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone + $out .= dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; } - if (! empty($this->phone_pro)) { - $out.=dol_print_phone($this->phone_pro, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; + if (!empty($this->phone_pro)) { + $out .= dol_print_phone($this->phone_pro, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; } - if (! empty($this->phone_mobile)) { - $out.=dol_print_phone($this->phone_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; + if (!empty($this->phone_mobile)) { + $out .= dol_print_phone($this->phone_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; } - if (! empty($this->phone_perso)) { - $out.=dol_print_phone($this->phone_perso, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePerso")); $outdone++; + if (!empty($this->phone_perso)) { + $out .= dol_print_phone($this->phone_perso, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePerso")); $outdone++; } - if (! empty($this->office_phone)) { - $out.=dol_print_phone($this->office_phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; + if (!empty($this->office_phone)) { + $out .= dol_print_phone($this->office_phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; } - if (! empty($this->user_mobile)) { - $out.=dol_print_phone($this->user_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; + if (!empty($this->user_mobile)) { + $out .= dol_print_phone($this->user_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; } - if (! empty($this->fax)) { - $out.=dol_print_phone($this->fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; + if (!empty($this->fax)) { + $out .= dol_print_phone($this->fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; } - if (! empty($this->office_fax)) { - $out.=dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; + if (!empty($this->office_fax)) { + $out .= dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; } - $out.='
        '; - $outdone=0; - if (! empty($this->email)) + $out .= '
        '; + $outdone = 0; + if (!empty($this->email)) { - $out.=dol_print_email($this->email, $this->id, $object->id, 'AC_EMAIL', 0, 0, 1); + $out .= dol_print_email($this->email, $this->id, $object->id, 'AC_EMAIL', 0, 0, 1); $outdone++; } - if (! empty($this->url)) + if (!empty($this->url)) { //$out.=dol_print_url($this->url,'_goout',0,1);//steve changed to blank - $out.=dol_print_url($this->url, '_blank', 0, 1); + $out .= dol_print_url($this->url, '_blank', 0, 1); $outdone++; } - $out.='
        '; - if (! empty($conf->socialnetworks->enabled)) + $out .= '
        '; + if (!empty($conf->socialnetworks->enabled)) { - if (is_array($this->socialnetworks) && count($this->socialnetworks)>0) { + if (is_array($this->socialnetworks) && count($this->socialnetworks) > 0) { foreach ($this->socialnetworks as $key => $value) { - $out.=dol_print_socialnetworks($value, $this->id, $object->id, $key); + $out .= dol_print_socialnetworks($value, $this->id, $object->id, $key); $outdone++; } } else { - if ($this->skype) $out.=dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); + if ($this->skype) $out .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); $outdone++; - if ($this->jabberid) $out.=dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); + if ($this->jabberid) $out .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); $outdone++; - if ($this->twitter) $out.=dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); + if ($this->twitter) $out .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); $outdone++; - if ($this->facebook) $out.=dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); + if ($this->facebook) $out .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); $outdone++; - if ($this->linkedin) $out.=dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); + if ($this->linkedin) $out .= dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); $outdone++; } } - $out.='
        '; + $out .= '
        '; - $out.=''; + $out .= ''; return $out; } @@ -1086,49 +1086,49 @@ abstract class CommonObject // phpcs:enable global $langs; - $tab=array(); + $tab = array(); - $sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user - if ($source == 'internal') $sql.=", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; - if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid, t.statut as statuscontact"; - $sql.= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email"; - $sql.= ", tc.source, tc.element, tc.code, tc.libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; - $sql.= ", ".MAIN_DB_PREFIX."element_contact ec"; - if ($source == 'internal') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; - if ($source == 'external'|| $source == 'thirdparty') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; - $sql.= " WHERE ec.element_id =".$this->id; - $sql.= " AND ec.fk_c_type_contact=tc.rowid"; - $sql.= " AND tc.element='".$this->db->escape($this->element)."'"; - if ($code) $sql.= " AND tc.code = '".$this->db->escape($code)."'"; - if ($source == 'internal') $sql.= " AND tc.source = 'internal'"; - if ($source == 'external' || $source == 'thirdparty') $sql.= " AND tc.source = 'external'"; - $sql.= " AND tc.active=1"; - if ($status >= 0) $sql.= " AND ec.statut = ".$status; - $sql.=" ORDER BY t.lastname ASC"; + $sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user + if ($source == 'internal') $sql .= ", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; + if ($source == 'external' || $source == 'thirdparty') $sql .= ", t.fk_soc as socid, t.statut as statuscontact"; + $sql .= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email"; + $sql .= ", tc.source, tc.element, tc.code, tc.libelle"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact ec"; + if ($source == 'internal') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; + if ($source == 'external' || $source == 'thirdparty') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; + $sql .= " WHERE ec.element_id =".$this->id; + $sql .= " AND ec.fk_c_type_contact=tc.rowid"; + $sql .= " AND tc.element='".$this->db->escape($this->element)."'"; + if ($code) $sql .= " AND tc.code = '".$this->db->escape($code)."'"; + if ($source == 'internal') $sql .= " AND tc.source = 'internal'"; + if ($source == 'external' || $source == 'thirdparty') $sql .= " AND tc.source = 'external'"; + $sql .= " AND tc.active=1"; + if ($status >= 0) $sql .= " AND ec.statut = ".$status; + $sql .= " ORDER BY t.lastname ASC"; dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - if (! $list) + if (!$list) { - $transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code; - $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); - $tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id, - 'nom'=>$obj->lastname, // For backward compatibility + $transkey = "TypeContact_".$obj->element."_".$obj->source."_".$obj->code; + $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); + $tab[$i] = array('source'=>$obj->source, 'socid'=>$obj->socid, 'id'=>$obj->id, + 'nom'=>$obj->lastname, // For backward compatibility 'civility'=>$obj->civility, 'lastname'=>$obj->lastname, 'firstname'=>$obj->firstname, 'email'=>$obj->email, 'login'=>$obj->login, 'photo'=>$obj->photo, 'statuscontact'=>$obj->statuscontact, 'rowid'=>$obj->rowid, 'code'=>$obj->code, 'libelle'=>$libelle_type, 'status'=>$obj->statuslink, 'fk_c_type_contact'=>$obj->fk_c_type_contact); } else { - $tab[$i]=$obj->id; + $tab[$i] = $obj->id; } $i++; @@ -1900,23 +1900,23 @@ abstract class CommonObject } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - if (! empty($this->fields['fk_project'])) // Common case + if (!empty($this->fields['fk_project'])) // Common case { - if ($projectid) $sql.= ' SET fk_project = '.$projectid; - else $sql.= ' SET fk_project = NULL'; - $sql.= ' WHERE rowid = '.$this->id; + if ($projectid) $sql .= ' SET fk_project = '.$projectid; + else $sql .= ' SET fk_project = NULL'; + $sql .= ' WHERE rowid = '.$this->id; } elseif ($this->table_element == 'actioncomm') // Special case for actioncomm { - if ($projectid) $sql.= ' SET fk_project = '.$projectid; - else $sql.= ' SET fk_project = NULL'; - $sql.= ' WHERE id = '.$this->id; + if ($projectid) $sql .= ' SET fk_project = '.$projectid; + else $sql .= ' SET fk_project = NULL'; + $sql .= ' WHERE id = '.$this->id; } else // Special case for old architecture objects { - if ($projectid) $sql.= ' SET fk_projet = '.$projectid; - else $sql.= ' SET fk_projet = NULL'; - $sql.= ' WHERE rowid = '.$this->id; + if ($projectid) $sql .= ' SET fk_projet = '.$projectid; + else $sql .= ' SET fk_projet = NULL'; + $sql .= ' WHERE rowid = '.$this->id; } dol_syslog(get_class($this)."::setProject", LOG_DEBUG); @@ -3851,19 +3851,19 @@ abstract class CommonObject $totalWeight += $weight * $qty * $trueWeightUnit; } else { - $totalWeight += $weight * $qty; // This may be wrong if we mix different units + $totalWeight += $weight * $qty; // This may be wrong if we mix different units } } if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) { //print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit; - $trueVolumeUnit=pow(10, $volumeUnit); + $trueVolumeUnit = pow(10, $volumeUnit); //print $line->volume; $totalVolume += $volume * $qty * $trueVolumeUnit; } else { - $totalVolume += $volume * $qty; // This may be wrong if we mix different units + $totalVolume += $volume * $qty; // This may be wrong if we mix different units } } @@ -4017,11 +4017,11 @@ abstract class CommonObject */ public function formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir = '/core/tpl') { - global $conf,$user,$langs,$object,$hookmanager,$extrafields; + global $conf, $user, $langs, $object, $hookmanager, $extrafields; global $form; // Line extrafield - if (! is_object($extrafields)) + if (!is_object($extrafields)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); @@ -4108,15 +4108,15 @@ abstract class CommonObject $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_title.tpl.php'; } if (empty($conf->file->strict_mode)) { - $res=@include $tpl; + $res = @include $tpl; } else { - $res=include $tpl; // for debug + $res = include $tpl; // for debug } if ($res) break; } } - $i = 0; + $i = 0; print "\n"; foreach ($this->lines as $line) @@ -4130,12 +4130,12 @@ abstract class CommonObject if (empty($line->fk_parent_line)) { $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element); - $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } else { $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line); - $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } } if (empty($reshook)) @@ -4167,21 +4167,21 @@ abstract class CommonObject */ public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl') { - global $conf,$langs,$user,$object,$hookmanager; + global $conf, $langs, $user, $object, $hookmanager; global $form; - global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! + global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! $object_rights = $this->getRights(); - $element=$this->element; + $element = $this->element; - $text=''; $description=''; $type=0; + $text = ''; $description = ''; $type = 0; // Show product and description - $type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type); + $type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type); // Try to enhance type detection using date_start and date_end for free lines where type was not saved. - if (! empty($line->date_start)) $type=1; // deprecated - if (! empty($line->date_end)) $type=1; // deprecated + if (!empty($line->date_start)) $type = 1; // deprecated + if (!empty($line->date_end)) $type = 1; // deprecated // Ligne en mode visu if ($action != 'editline' || $selected != $line->id) @@ -4318,19 +4318,19 @@ abstract class CommonObject print ''; print ''; print ''; - $i = 0; + $i = 0; - if (! empty($this->lines)) + if (!empty($this->lines)) { foreach ($this->lines as $line) { - if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) + if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) { if (empty($line->fk_parent_line)) { - $parameters=array('line'=>$line, 'i'=>$i); - $action=''; - $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('line'=>$line, 'i'=>$i); + $action = ''; + $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } } else @@ -4623,48 +4623,48 @@ abstract class CommonObject { global $conf, $langs, $user, $hookmanager, $action; - $srctemplatepath=''; + $srctemplatepath = ''; - $parameters = array('modelspath'=>$modelspath,'modele'=>$modele,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'hidedesc'=>$hidedesc,'hideref'=>$hideref, 'moreparams'=>$moreparams); + $parameters = array('modelspath'=>$modelspath, 'modele'=>$modele, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'hidedesc'=>$hidedesc, 'hideref'=>$hideref, 'moreparams'=>$moreparams); $reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null')); + dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); // Increase limit for PDF build - $err=error_reporting(); + $err = error_reporting(); error_reporting(0); @set_time_limit(120); error_reporting($err); // If selected model is a filename template (then $modele="modelname" or "modelname:filename") - $tmp=explode(':', $modele, 2); - if (! empty($tmp[1])) + $tmp = explode(':', $modele, 2); + if (!empty($tmp[1])) { - $modele=$tmp[0]; - $srctemplatepath=$tmp[1]; + $modele = $tmp[0]; + $srctemplatepath = $tmp[1]; } // Search template files - $file=''; - $classname=''; - $filefound=0; - $dirmodels=array('/'); - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; + $classname = ''; + $filefound = 0; + $dirmodels = array('/'); + if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - foreach(array('doc','pdf') as $prefix) + foreach (array('doc', 'pdf') as $prefix) { - if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php + if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php else $file = $prefix."_".$modele.".modules.php"; // On verifie l'emplacement du modele - $file=dol_buildpath($reldir.$modelspath.$file, 0); + $file = dol_buildpath($reldir.$modelspath.$file, 0); if (file_exists($file)) { - $filefound=1; - $classname=$prefix.'_'.$modele; + $filefound = 1; + $classname = $prefix.'_'.$modele; break; } } @@ -4674,7 +4674,7 @@ abstract class CommonObject // If generator was found if ($filefound) { - global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. + global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. require_once $file; @@ -4683,32 +4683,32 @@ abstract class CommonObject // If generator is ODT, we must have srctemplatepath defined, if not we set it. if ($obj->type == 'odt' && empty($srctemplatepath)) { - $varfortemplatedir=$obj->scandir; - if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir)) + $varfortemplatedir = $obj->scandir; + if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir)) { - $dirtoscan=$conf->global->$varfortemplatedir; + $dirtoscan = $conf->global->$varfortemplatedir; - $listoffiles=array(); + $listoffiles = array(); // Now we add first model found in directories scanned - $listofdir=explode(',', $dirtoscan); - foreach($listofdir as $key => $tmpdir) + $listofdir = explode(',', $dirtoscan); + foreach ($listofdir as $key => $tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { unset($listofdir[$key]); continue; } + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } if (is_dir($tmpdir)) { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } if (count($listoffiles)) { - foreach($listoffiles as $record) + foreach ($listoffiles as $record) { - $srctemplatepath=$record['fullname']; + $srctemplatepath = $record['fullname']; break; } } @@ -4716,27 +4716,27 @@ abstract class CommonObject if (empty($srctemplatepath)) { - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; + $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; return -1; } } - if ($obj->type == 'odt' && ! empty($srctemplatepath)) + if ($obj->type == 'odt' && !empty($srctemplatepath)) { - if (! dol_is_file($srctemplatepath)) + if (!dol_is_file($srctemplatepath)) { - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; + $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; return -1; } } // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. - $sav_charset_output=$outputlangs->charset_output; + $sav_charset_output = $outputlangs->charset_output; if (in_array(get_class($this), array('Adherent'))) { - $arrayofrecords = array(); // The write_file of templates of adherent class need this var + $arrayofrecords = array(); // The write_file of templates of adherent class need this var $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); } else @@ -4747,46 +4747,46 @@ abstract class CommonObject if ($resultwritefile > 0) { - $outputlangs->charset_output=$sav_charset_output; + $outputlangs->charset_output = $sav_charset_output; // We delete old preview require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_delete_preview($this); // Index file in database - if (! empty($obj->result['fullpath'])) + if (!empty($obj->result['fullpath'])) { $destfull = $obj->result['fullpath']; $upload_dir = dirname($destfull); $destfile = basename($destfull); $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir { $filename = basename($destfile); $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($this->db); - $result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename); + $ecmfile = new EcmFiles($this->db); + $result = $ecmfile->fetch(0, '', ($rel_dir ? $rel_dir.'/' : '').$filename); // Set the public "share" key $setsharekey = false; if ($this->element == 'propal') { - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok - if ($useonlinesignature) $setsharekey=true; - if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok + if ($useonlinesignature) $setsharekey = true; + if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true; } - if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; + if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey = true; } - if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; + if ($this->element == 'facture' && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey = true; } - if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; + if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey = true; } if ($setsharekey) { @@ -4799,11 +4799,11 @@ abstract class CommonObject if ($result > 0) { - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content $ecmfile->fullpath_orig = ''; $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content $result = $ecmfile->update($user); if ($result < 0) { setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); @@ -4814,11 +4814,11 @@ abstract class CommonObject $ecmfile->entity = $conf->entity; $ecmfile->filepath = $rel_dir; $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content $ecmfile->fullpath_orig = ''; $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content $ecmfile->src_object_type = $this->table_element; $ecmfile->src_object_id = $this->id; @@ -4834,15 +4834,15 @@ abstract class CommonObject //var_dump($obj->update_main_doc_field);exit; // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) - $update_main_doc_field=0; - if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; - if ($update_main_doc_field && ! empty($this->table_element)) + $update_main_doc_field = 0; + if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1; + if ($update_main_doc_field && !empty($this->table_element)) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { dol_print_error($this->db); } else { $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; @@ -4862,14 +4862,14 @@ abstract class CommonObject } else { - $outputlangs->charset_output=$sav_charset_output; + $outputlangs->charset_output = $sav_charset_output; dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); return -1; } } else { - $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); + $this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); dol_print_error('', $this->error); return -1; } @@ -4963,26 +4963,26 @@ abstract class CommonObject public function call_trigger($trigger_name, $user) { // phpcs:enable - global $langs,$conf; + global $langs, $conf; - if (! is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers. + if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers. include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs = new Translate('', $conf); } - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers($trigger_name, $this, $user, $langs, $conf); + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interface = new Interfaces($this->db); + $result = $interface->run_triggers($trigger_name, $this, $user, $langs, $conf); if ($result < 0) { if (!empty($this->errors)) { - $this->errors=array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice. + $this->errors = array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice. } else { - $this->errors=$interface->errors; + $this->errors = $interface->errors; } } return $result; @@ -6088,77 +6088,77 @@ abstract class CommonObject } if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { - $data[$obj->rowid]=$labeltoshow; + $data[$obj->rowid] = $labeltoshow; } - if (! empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName . ':' . $obj->{$parentField}; + if (!empty($InfoFieldList[3]) && $parentField) { + $parent = $parentName.':'.$obj->{$parentField}; } - $data[$obj->rowid]=$labeltoshow; + $data[$obj->rowid] = $labeltoshow; } - $i ++; + $i++; } $this->db->free($resql); - $out=$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); } else { - print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
        '; + print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.
        '; } } } elseif ($type == 'link') { - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]' + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]' $param_list_array = explode(':', $param_list[0]); - $showempty=(($required && $default != '')?0:1); + $showempty = (($required && $default != '') ? 0 : 1); - $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, '', 0, empty($val['disabled'])?0:1); + $out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, '', 0, empty($val['disabled']) ? 0 : 1); - if (! empty($param_list_array[2])) // If we set to add a create button + if (!empty($param_list_array[2])) // If we set to add a create button { - if (! GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled". + if (!GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled". { - list($class,$classfile)=explode(':', $param_list[0]); - if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); - else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); + list($class, $classfile) = explode(':', $param_list[0]); + if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path = dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); + else $url_path = dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); $paramforthenewlink = ''; - $paramforthenewlink .= (GETPOSTISSET('action')?'&action='.GETPOST('action', 'aZ09'):''); - $paramforthenewlink .= (GETPOSTISSET('id')?'&id='.GETPOST('id', 'int'):''); + $paramforthenewlink .= (GETPOSTISSET('action') ? '&action='.GETPOST('action', 'aZ09') : ''); + $paramforthenewlink .= (GETPOSTISSET('id') ? '&id='.GETPOST('id', 'int') : ''); $paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--'; // TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page - $out.=''; + $out .= ''; } } } elseif ($type == 'password') { // If prefix is 'search_', field is used as a filter, we use a common text field. - $out=''; + $out = ''; } elseif ($type == 'array') { $newval = $val; $newval['type'] = 'varchar(256)'; - $out=''; + $out = ''; $inputs = array(); - if(! empty($value)) { - foreach($value as $option) { - $out.= ' '; - $out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $morecss).'
        '; + if (!empty($value)) { + foreach ($value as $option) { + $out .= ' '; + $out .= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $morecss).'
        '; } } - $out.= ''; + $out .= ''; $newInput = ' '; - $newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $morecss).'
        '; + $newInput .= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $morecss).'
        '; - if(! empty($conf->use_javascript_ajax)) { - $out.= ' + if (!empty($conf->use_javascript_ajax)) { + $out .= '
        '.$langs->trans('ReductionShort').''.$form->showCheckAddButtons('checkforselect', 1).'